Going into protected mode fails
Posted: Mon Mar 07, 2022 5:05 am
I am trying to enable protected mode with this assembly code
And here is my .data
This fails in Bochs 2.7 with the following error
Code: Select all
cli
xor ax, ax
mov ds, ax
db 66h
lgdt[gdt_desc]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 01h:clear_pipe
[BITS 32]
clear_pipe:
mov ax, 2h
mov ds, ax
;mov ss, ax
mov esp, 090000h
;mov al, 1Bh
;mov ah, 'P'
;mov edx, 0B8000h
;mov [edx], ax
mov byte [0B8000h], 'P'
mov byte [0B8001h], 1Bh
jmp $
Code: Select all
gdt:
gdt_null:
dq 0
gdt_code:
dw 0FFFFh ;0-15
dw 0 ;16-31
db 0;0-7
db 10011010b ;8-15
db 11001111b ;GB0(1:avl)(4:limit)
db 0
gdt_data:
dw 0FFFFh
dw 0
db 0
db 10010010b
db 11001111b
db 0
gdt_end:
gdt_desc:
dw gdt_end - gdt
dd gdt
TIMES 510 - ($ - $$) db 0 ;Fill the rest of sector with nop
db 0x55,0xAA
Can't figure out why it says jump_protected: cs == 0 while we see jmpf 0x0001:7c1a. Obviously segment selector is 1 not null.00036095263i[BIOS ] Booting from 0000:7c00
00036095377e[CPU0 ] jump_protected: cs == 0
00036095377e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00036095377e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
00036095377i[CPU0 ] CPU is in protected mode (active)
00036095377i[CPU0 ] CS.mode = 16 bit
00036095377i[CPU0 ] SS.mode = 16 bit
00036095377i[CPU0 ] EFER = 0x00000000
00036095377i[CPU0 ] | EAX=60000011 EBX=00000000 ECX=00090000 EDX=00000080
00036095377i[CPU0 ] | ESP=0000ffd6 EBP=00000000 ESI=000e0000 EDI=0000ffac
00036095377i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af PF cf
00036095377i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00036095377i[CPU0 ] | CS:0000( 0004| 0| 0) 00000000 0000ffff 0 0
00036095377i[CPU0 ] | DS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00036095377i[CPU0 ] | SS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00036095377i[CPU0 ] | ES:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00036095377i[CPU0 ] | FS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00036095377i[CPU0 ] | GS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00036095377i[CPU0 ] | EIP=00007c15 (00007c15)
00036095377i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
00036095377i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00036095377i[CPU0 ] 0x0000000000007c15>> jmpf 0x0001:7c1a : EA1A7C0100
00036095377e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00036095377i[SYS ] bx_pc_system_c::Reset(HARDWARE) called