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:
|
2023-02-01 14:18:27 -06:00
|
|
|
mov eax, 0x10
|
2023-01-31 21:26:43 -06:00
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
2023-02-01 14:18:27 -06:00
|
|
|
mov fs, ax
|
|
|
|
mov gs, ax
|
|
|
|
mov ss, ax
|
|
|
|
in al, 0x92
|
|
|
|
test al, 2
|
|
|
|
jnz after
|
|
|
|
or al, 2
|
|
|
|
and al, 0xFE
|
|
|
|
out 0x92, al
|
|
|
|
after:
|
2023-01-31 21:26:43 -06:00
|
|
|
mov esi, 0x8000
|
|
|
|
mov edi, 0x100000
|
2023-02-01 20:42:05 -06:00
|
|
|
mov ecx, 0x10000
|
2023-01-31 21:26:43 -06:00
|
|
|
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
|
2023-02-02 21:40:39 -06:00
|
|
|
addr_packet_transfer_buff: dd 0x08000000 ; transfer buffer
|
|
|
|
addr_packet_start_block: dq 1 ; start block
|