turns out huge unreal mode isn't supported in bochs

huge unreal mode is 4GiB code in 16bit mode + 4GiB data
we will just use the regular big flat model instead (64KiB code/4GiB data)
This commit is contained in:
2024-10-13 14:50:49 -04:00
parent 963dec5281
commit ce6240249a

View File

@@ -305,15 +305,12 @@ EnterUnrealMode:
pop ax ; save cs to ax to setup far jump pop ax ; save cs to ax to setup far jump
mov word [__UNREAL_SEGMENT], ax mov word [__UNREAL_SEGMENT], ax
shl eax, 4 lgdt [((__STAGE2_SEGMENT << 4) + unreal_gdt_info)] ; load unreal gdt
add eax, unreal_gdt_start ; ax contains the physical address of gdt table
mov dword [unreal_gdt_ptr], eax ; update gdt ptr in unreal_gdt_info
lgdt [dword ((__STAGE2_SEGMENT << 4) + unreal_gdt_info)] ; calculate linear address for lgdt to consume
mov eax, cr0 mov eax, cr0
or al,1 ; set pmode bit or al,1 ; set pmode bit
mov cr0, eax ; switch to pmode mov cr0, eax ; switch to pmode
jmp short $+2
;jmp far 0x0008:EnterUnrealMode.load_cs ;jmp far 0x0008:EnterUnrealMode.load_cs
db 0xEA ; jmp far imm16:imm16 db 0xEA ; jmp far imm16:imm16
@@ -330,7 +327,8 @@ EnterUnrealMode:
and al,0xFE ; toggle bit 1 of cr0 and al,0xFE ; toggle bit 1 of cr0
mov cr0, eax ; back to realmode mov cr0, eax ; back to realmode
jmp short $+2
;jmp far 0x0008:EnterUnrealMode.unload_cs ;jmp far 0x0008:EnterUnrealMode.unload_cs
db 0xEA ; jmp far imm16:imm16 db 0xEA ; jmp far imm16:imm16
dw EnterUnrealMode.unload_cs ; error_far_ptr dw EnterUnrealMode.unload_cs ; error_far_ptr
@@ -400,19 +398,19 @@ unreal_gdt_start:
; entry 0 (null descriptor) ; entry 0 (null descriptor)
dq 0 ; first entry is null dq 0 ; first entry is null
; entry 1 (16-bit code segment with 4 GiB flat mapping) ; entry 1 (16bit code 64KiB limit)
dq 0x0000FFFF ; Base Address(15:0) 31:16, Segment Limit(15:0) 15:0 dd 0x0000FFFF ; Base Address(15:0) 31:16, Segment Limit(15:0) 15:0
db 0x00 ; Base Address 23:16 db 0x00 ; Base Address 23:16
db 1001_1010b ; Access Byte: Present, ring0, S = 1, executable (1), non-conforming, readable, Accessed db 1001_1010b ; Access Byte: Present, ring0, S = 1, executable (1), non-conforming, readable, Accessed
db 1000_1111b ; Flags: GR = 4KiB, attr = <DB/L/Avl>, Granularity = 4KiB & 16:19 of limit db 0000_0000b ; Flags: GR = 4KiB, attr = <DB/L/Avl>, Granularity = 4KiB & 16:19 of limit
db 0000_0000b ; Base Address 31:24 db 0x00 ; Base Address 31:24
; entry 2 (16-bit data segment with 4 GiB flat mapping) ; entry 2 (16bit data segment with 4 GiB flat mapping)
dq 0x0000FFFF ; Base Address(15:0) 31:16, Segment Limit(15:0) 15:0 dd 0x0000FFFF ; Base Address(15:0) 31:16, Segment Limit(15:0) 15:0
db 0x00 ; Base Address(23:16) db 0x00 ; Base Address(23:16)
db 1001_0010b ; Access Byte: Present, ring0, S = 1, data (0), non-confirming, writable, present db 1001_0010b ; Access Byte: Present, ring0, S = 1, data (0), non-confirming, writable, present
db 1000_1111b ; Flags: GR = 4KiB, attr = <16-bit/?/?>, Granularity = 4KiB & 16:19 of limit db 1000_1111b ; Flags: GR = 4KiB, attr = <16-bit/?/?>, Granularity = 4KiB & 16:19 of limit
db 0000_0000b ; Base Address(31:24) db 0x00 ; Base Address(31:24)
unreal_gdt_end: unreal_gdt_end:
ALIGN 16, db 0 ALIGN 16, db 0