2022-09-14 16:50:44 -05:00
|
|
|
[ORG 0x7c00]
|
|
|
|
[BITS 16]
|
|
|
|
|
|
|
|
xor ax, ax
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
|
|
|
mov ah, 0x42
|
|
|
|
mov si, addr_packet
|
|
|
|
int 0x13
|
2023-01-31 21:26:43 -06:00
|
|
|
jnc entry
|
2022-09-14 16:50:44 -05:00
|
|
|
push 0xb800
|
|
|
|
pop es
|
|
|
|
xor di, di
|
|
|
|
mov si, string
|
|
|
|
mov cx, 10
|
|
|
|
mov ah, 0x7
|
|
|
|
err_print:
|
|
|
|
lodsb
|
|
|
|
stosw
|
|
|
|
loop err_print
|
|
|
|
hlt_loop:
|
|
|
|
hlt
|
|
|
|
jmp hlt_loop
|
2023-01-31 21:26:43 -06:00
|
|
|
entry:
|
|
|
|
cli ; no interrupts
|
|
|
|
xor ax,ax
|
|
|
|
mov ds, ax
|
|
|
|
lgdt [gdt_desc] ; load gdt register
|
|
|
|
mov eax, cr0 ; set pmode bit
|
|
|
|
or al, 1
|
|
|
|
mov cr0, eax
|
|
|
|
jmp 08h:Pmode
|
|
|
|
[BITS 32]
|
|
|
|
Pmode:
|
|
|
|
mov ax, 0x10
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
|
|
|
mov esi, 0x8000
|
|
|
|
mov edi, 0x100000
|
|
|
|
mov ecx, 0x10000
|
|
|
|
rep movsb
|
|
|
|
jmp 08h:0x100000
|
|
|
|
gdt_desc:
|
|
|
|
dw gdt_end - gdt
|
|
|
|
dd gdt
|
|
|
|
gdt:
|
|
|
|
gdt_null: dq 0
|
|
|
|
gdt_code: dw 0xFFFF, 0 ; bits 0-15 limit (4GB), bits 0-15 base address
|
|
|
|
db 0 ; bits 16-23 base address
|
|
|
|
db 10011010b ; access byte
|
|
|
|
db 11001111b ; bits 16-19 limit (4GB), 4 bits flags
|
|
|
|
db 0 ; bits 24-31 base address
|
|
|
|
gdt_data: dw 0xFFFF, 0 ; bits 0-15 limit (4GB), bits 0-15 base address
|
|
|
|
db 0 ; bits 16-23 base address
|
|
|
|
db 10010010b ; access byte
|
|
|
|
db 11001111b ; bits 16-19 limit (4GB), 4 bits flags
|
|
|
|
db 0 ; bits 24-31 base address
|
|
|
|
gdt_end:
|
2022-09-14 16:50:44 -05:00
|
|
|
|
|
|
|
string: db 'DISK ERROR'
|
|
|
|
|
|
|
|
addr_packet:
|
|
|
|
db 0x10, 0x00 ; size, reserved
|
2022-09-21 17:14:11 -05:00
|
|
|
dw 0x39 ; blocks
|
2022-09-14 16:50:44 -05:00
|
|
|
dd 0x8000 ; transfer buffer
|
|
|
|
dq 1 ; start block
|