33 lines
643 B
NASM
33 lines
643 B
NASM
; Code related to memory segment from 0xFFFF0 - 0x10FFEF
|
|
|
|
; Check if 0000:0000 and FFFF:0010 point to the same memory
|
|
; ZF=1 when A20 disabled and HMA unusable
|
|
; ZF=0 when A20 enabled
|
|
a20_enabled:
|
|
mov ax, 0x0000
|
|
mov ds, ax
|
|
mov si, ax
|
|
mov ax, 0xFFFF
|
|
mov di, 0x0010
|
|
mov cx, 0x0200
|
|
repe cmpsw
|
|
ret
|
|
|
|
; Relocate kernel code to HMA
|
|
hma_relocate:
|
|
call a20_enabled
|
|
; TODO: talk to hw to enable a20
|
|
jz .end
|
|
mov ax, cs
|
|
mov ds, ax
|
|
mov si, 0x0010
|
|
mov ax, 0xFFFF
|
|
mov es, ax ; new code segment
|
|
mov ss, ax ; new stack segment
|
|
mov di, 0x0010
|
|
mov cx, 0x7FF8 ; 0xFFF0 divided by 2
|
|
repe movsw
|
|
jmp 0xFFFF:.end
|
|
.end:
|
|
ret
|