This is the code of my second bootloader:
Code: Select all
bits 16
org 0x500
jmp Start
%include "gdt.inc"
Start:
cli
xor ax, ax
mov ds, ax
mov es, ax
mov ax, 0x9000
mov ss, ax
mov sp, 0xffff
sti
call InstallGDT
;; Here is some code to open A20
;; Here is some code to enable pmode
cli
hlt
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This is gdt.inc, a separate file
%ifndef START_GDT_INCLUDED
%define START_GDT_INCLUDED
bits 16
InstallGDT:
cli
pusha
lgdt [GDT]
sti
popa
ret
StartGDT:
dd 0
dd 0
dw 0ffffh ; limit low
dw 0 ; base low
db 0 ; base middle
db 10011010b ; access
db 11001111b ; granularity
db 0 ; base high
dw 0ffffh ; limit low
dw 0 ; base low
db 0 ; base middle
db 10010010b ; access
db 11001111b ; granularity
db 0 ; base high
EndGDT:
GDT:
dw EndGDT - StartGDT - 1 ; limit (Size of GDT)
dd StartGDT ; base of GDT
%endif
Code: Select all
00:00:07.437803 ****************** Guest state at power off ******************
00:00:07.437811 Guest CPUM (VCPU 0) state:
00:00:07.437821 eax=00000011 ebx=00000000 ecx=00010002 edx=00000000 esi=0000f4a0 edi=0000fff0
00:00:07.437829 eip=0000004a esp=0000fffe ebp=00000000 iopl=0 nv up di pl nz na po nc
00:00:07.437836 cs={0500 base=0000000000005000 limit=0000ffff flags=0000009b} dr0=00000000 dr1=00000000
00:00:07.437847 ds={0000 base=0000000000000000 limit=0000ffff flags=00000093} dr2=00000000 dr3=00000000
00:00:07.437852 es={0500 base=0000000000005000 limit=0000ffff flags=00000093} dr4=00000000 dr5=00000000
00:00:07.437858 fs={0000 base=0000000000000000 limit=0000ffff flags=00000093} dr6=ffff0ff0 dr7=00000400
00:00:07.437864 gs={0000 base=0000000000000000 limit=0000ffff flags=00000093} cr0=00000011 cr2=00000000
00:00:07.437870 ss={0000 base=0000000000000000 limit=0000ffff flags=00000093} cr3=00000000 cr4=00000000
00:00:07.437875 gdtr=0000000000000000:0000 idtr=0000000000000000:ffff eflags=00000046
00:00:07.437880 ldtr={0000 base=00000000 limit=0000ffff flags=00000082}
00:00:07.437884 tr ={0000 base=00000000 limit=0000ffff flags=0000008b}
00:00:07.437888 SysEnter={cs=0000 eip=00000000 esp=00000000}
00:00:07.437892 FCW=037f FSW=0000 FTW=0000 FOP=0000 MXCSR=00001f80 MXCSR_MASK=0000ffff
00:00:07.437897 FPUIP=00000000 CS=0000 Rsrvd1=0000 FPUDP=00000000 DS=0000 Rsvrd2=0000
00:00:07.437902 ST(0)=FPR0={0000'00000000'00000000} t0 +0.0000000000000000000000 ^ 0
00:00:07.437910 ST(1)=FPR1={0000'00000000'00000000} t0 +0.0000000000000000000000 ^ 0
00:00:07.437917 ST(2)=FPR2={0000'00000000'00000000} t0 +0.0000000000000000000000 ^ 0
00:00:07.437923 ST(3)=FPR3={0000'00000000'00000000} t0 +0.0000000000000000000000 ^ 0
00:00:07.437929 ST(4)=FPR4={0000'00000000'00000000} t0 +0.0000000000000000000000 ^ 0
00:00:07.437935 ST(5)=FPR5={0000'00000000'00000000} t0 +0.0000000000000000000000 ^ 0
00:00:07.437941 ST(6)=FPR6={0000'00000000'00000000} t0 +0.0000000000000000000000 ^ 0
00:00:07.437947 ST(7)=FPR7={0000'00000000'00000000} t0 +0.0000000000000000000000 ^ 0
00:00:07.437954 XMM0 =00000000'00000000'00000000'00000000 XMM1 =00000000'00000000'00000000'00000000
00:00:07.437962 XMM2 =00000000'00000000'00000000'00000000 XMM3 =00000000'00000000'00000000'00000000
00:00:07.437972 XMM4 =00000000'00000000'00000000'00000000 XMM5 =00000000'00000000'00000000'00000000
00:00:07.437979 XMM6 =00000000'00000000'00000000'00000000 XMM7 =00000000'00000000'00000000'00000000
00:00:07.437987 XMM8 =00000000'00000000'00000000'00000000 XMM9 =00000000'00000000'00000000'00000000
00:00:07.437995 XMM10=00000000'00000000'00000000'00000000 XMM11=00000000'00000000'00000000'00000000
00:00:07.438003 XMM12=00000000'00000000'00000000'00000000 XMM13=00000000'00000000'00000000'00000000
00:00:07.438010 XMM14=00000000'00000000'00000000'00000000 XMM15=00000000'00000000'00000000'00000000
00:00:07.438019 EFER =0000000000000000
00:00:07.438021 PAT =0007040600070406
00:00:07.438027 STAR =0000000000000000
00:00:07.438029 CSTAR =0000000000000000
00:00:07.438031 LSTAR =0000000000000000
00:00:07.438033 SFMASK =0000000000000000
00:00:07.438035 KERNELGSBASE =0000000000000000
00:00:07.438038 ***
00:00:07.438045 Guest paging mode: Protected (changed 4 times), A20 enabled (changed 2 times)
Thanks!