Code: Select all
jmp 0x08:pm_start
Here is my stage 2 code:
Code: Select all
[ORG 0x4000]
[BITS 16]
lgdt [gdtr] ; load gdt register
mov ebx, 0xBEEF0000
mov eax, cr0 ; switch to protected mode by
or al,1 ; setting the protected mode bit
mov cr0, eax ; in CR0
jmp 0x08:flush_gdt
[BITS 32]
flush_gdt:
mov ebx, 0xBEEF0001
mov ax, 0x10
mov ebx, 0xBEEF0002
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov bx, 0xBEE2
ret
mov eax, 0xDEADBEEF
mov ebx, 0xDEADBEEF
jmp $
[BITS 16]
; GDT
gdtr:
dw gdt_end - gdt - 1 ; last byte in table
dd gdt ; start of table
gdt dd 0,0 ; entry 0 is always unused
flatdesc db 0xff, 0xff, 0, 0, 0, 10010010b, 11001111b, 0
gdt_end:
Code: Select all
CPU is in protected mode (active)
00017825947i[CPU0 ] CS.mode = 16 bit
00017825947i[CPU0 ] SS.mode = 16 bit
00017825947i[CPU0 ] EFER = 0x00000000
00017825947i[CPU0 ] | EAX=60000011 EBX=beef0000 ECX=00090010 EDX=00000080
00017825947i[CPU0 ] | ESP=0000ffd6 EBP=00000000 ESI=000e0000 EDI=0000ffac
00017825947i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af PF cf
00017825947i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00017825947i[CPU0 ] | CS:4000( 0004| 0| 0) 00040000 0000ffff 0 0
00017825947i[CPU0 ] | DS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00017825947i[CPU0 ] | SS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00017825947i[CPU0 ] | ES:4000( 0005| 0| 0) 00040000 0000ffff 0 0
00017825947i[CPU0 ] | FS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00017825947i[CPU0 ] | GS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00017825947i[CPU0 ] | EIP=00000013 (00000013)
00017825947i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
00017825947i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
(0).[17825947] [0x0000000000040013] 4000:0000000000000013 (unk. ctxt): jmp far 0008:4018 ; ea18400800
Code: Select all
in al, 0x92
or al, 2
out 0x92, al