I have many problems while entering protected mode.
Here is code i wanted to enter protected mode:
Code: Select all
[BITS 16]
[ORG 0x8000]
CLI
lgdt [GDTP]
Mov eax,CR0
Or eax,000000001h
Mov CR0,eax
Jmp 08h:CLEAR
[BITS 32]
CLEAR:
Mov ax,010h
Mov ds,ax
makelooping:
jmp makelooping
GDT:
dq 00000000000000000h
dw 0FFFFh
dw 00000h
db 00h
db 010011010b
db 011001111b
db 00h
dw 0FFFFh
dw 00000h
db 00h
db 010010010b
db 011001111b
db 00h
GDTP:
dw GDTP-GDT-1
dd GDT
Above code seems to be fine, but Bochs prints error like:
00014092315e[CPU0 ] fetch_raw_descriptor: GDT: index (f) 1 > limit (0)
What does it mean ? Why it can not enter protected mode ?
I am using nasm.
As you can see below (part cut from below's log) my GDT seems to be not loaded into, old segments are in:
Below bochs output:00014092315i[CPU0 ] | SEG selector base limit G D
00014092315i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00014092315i[CPU0 ] | CS:0800( 0004| 0| 0) 00008000 0000ffff 0 0
00014092315i[CPU0 ] | DS:0800( 0005| 0| 0) 00008000 0000ffff 0 0
00014092315i[CPU0 ] | SS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00014092315i[CPU0 ] | ES:0800( 0005| 0| 0) 00008000 0000ffff 0 0
00014092315i[CPU0 ] | FS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00014092315i[CPU0 ] | GS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
========================================================================
Bochs x86 Emulator 2.4.5
Build from CVS snapshot, on April 25, 2010
========================================================================
00000000000i[ ] reading configuration from bochsrc
00000000000i[ ] Ignoring magic break points
00000000000i[ ] installing x module as the Bochs GUI
00000000000i[ ] Bochs x86 Emulator 2.4.5
00000000000i[ ] Build from CVS snapshot, on April 25, 2010
00000000000i[ ] System configuration
00000000000i[ ] processors: 1 (cores=1, HT threads=1)
00000000000i[ ] A20 line support: yes
00000000000i[ ] CPU configuration
00000000000i[ ] level: 6
00000000000i[ ] SMP support: no
00000000000i[ ] APIC support: yes
00000000000i[ ] FPU support: yes
00000000000i[ ] MMX support: yes
00000000000i[ ] 3dnow! support: no
00000000000i[ ] SEP support: yes
00000000000i[ ] SSE support: sse2
00000000000i[ ] XSAVE support: no
00000000000i[ ] AES support: no
00000000000i[ ] MOVBE support: no
00000000000i[ ] x86-64 support: no
00000000000i[ ] MWAIT support: no
00000000000i[ ] VMX support: no
00000000000i[ ] Optimization configuration
00000000000i[ ] RepeatSpeedups support: no
00000000000i[ ] Trace cache support: no
00000000000i[ ] Fast function calls: no
00000000000i[ ] Devices configuration
00000000000i[ ] ACPI support: no
00000000000i[ ] NE2000 support: no
00000000000i[ ] PCI support: no, enabled=no
00000000000i[ ] SB16 support: no
00000000000i[ ] USB support: no
00000000000i[ ] VGA extension support: vbe
00000000000i[MEM0 ] allocated memory at 0x7f5e6afd0010. after alignment, vector=0x7f5e6afd1000
00000000000i[MEM0 ] 32.00MB
00000000000i[MEM0 ] mem block size = 0x00100000, blocks=32
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('/usr/local/share/bochs/BIOS-bochs-latest')
00000000000i[MEM0 ] rom at 0xc0000/40448 ('/usr/local/share/bochs/VGABIOS-lgpl-latest')
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Tue Oct 8 15:06:27 2013 (time0=1381237587)
00000000000i[DMA ] channel 4 used by cascade
00000000000i[DMA ] channel 2 used by Floppy Drive
00000000000i[FDD ] tried to open 'im.IMA' read/write: Permission denied
00000000000i[FDD ] fd0: 'im.IMA' ro=1, h=2,t=80,spt=18
00000000000i[VGA ] interval=50000
00000000000i[MEM0 ] Register memory access handlers: 0x000a0000 - 0x000bffff
00000000000i[XGUI ] test_alloc_colors: 16 colors available out of 16 colors tried
00000000000i[XGUI ] font 8 wide x 16 high, display depth = 24
(.:4925): Gtk-CRITICAL **: IA__gtk_widget_show: assertion `GTK_IS_WIDGET (widget)' failed
00000000000i[MEM0 ] Register memory access handlers: 0xe0000000 - 0xe0ffffff
00000000000i[VGA ] VBE Bochs Display Extension Enabled
00000000000i[ ] init_dev of 'unmapped' plugin device by virtual method
00000000000i[ ] init_dev of 'biosdev' plugin device by virtual method
00000000000i[ ] init_dev of 'speaker' plugin device by virtual method
00000000000i[SPEAK] Failed to open /dev/console: No such file or directory
00000000000i[SPEAK] Deactivating beep on console
00000000000i[ ] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[ ] init_dev of 'iodebug' plugin device by virtual method
00000000000i[ ] init_dev of 'ioapic' plugin device by virtual method
00000000000i[IOAP ] initializing I/O APIC
00000000000i[MEM0 ] Register memory access handlers: 0xfec00000 - 0xfec00fff
00000000000i[ ] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD ] will paste characters every 1000 keyboard ticks
00000000000i[ ] init_dev of 'harddrv' plugin device by virtual method
00000000000i[HD ] Using boot sequence floppy, none, none
00000000000i[HD ] Floppy boot signature check is enabled
00000000000i[ ] init_dev of 'serial' plugin device by virtual method
00000000000i[SER ] com1 at 0x03f8 irq 4
00000000000i[ ] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
00000000000i[ ] register state of 'unmapped' plugin device by virtual method
00000000000i[ ] register state of 'biosdev' plugin device by virtual method
00000000000i[ ] register state of 'speaker' plugin device by virtual method
00000000000i[ ] register state of 'extfpuirq' plugin device by virtual method
00000000000i[ ] register state of 'iodebug' plugin device by virtual method
00000000000i[ ] register state of 'ioapic' plugin device by virtual method
00000000000i[ ] register state of 'keyboard' plugin device by virtual method
00000000000i[ ] register state of 'harddrv' plugin device by virtual method
00000000000i[ ] register state of 'serial' plugin device by virtual method
00000000000i[ ] register state of 'parallel' plugin device by virtual method
00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00000000000i[CPU0 ] cpu hardware reset
00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0xfee00000
00000000000i[CPU0 ] CPUID[0x00000000]: 00000003 756e6547 6c65746e 49656e69
00000000000i[CPU0 ] CPUID[0x00000001]: 00000f00 00000800 00000000 078bfbff
00000000000i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000000]: 80000004 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00000000000i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00000000000i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00000000000i[ ] reset of 'unmapped' plugin device by virtual method
00000000000i[ ] reset of 'biosdev' plugin device by virtual method
00000000000i[ ] reset of 'speaker' plugin device by virtual method
00000000000i[ ] reset of 'extfpuirq' plugin device by virtual method
00000000000i[ ] reset of 'iodebug' plugin device by virtual method
00000000000i[ ] reset of 'ioapic' plugin device by virtual method
00000000000i[ ] reset of 'keyboard' plugin device by virtual method
00000000000i[ ] reset of 'harddrv' plugin device by virtual method
00000000000i[ ] reset of 'serial' plugin device by virtual method
00000000000i[ ] reset of 'parallel' plugin device by virtual method
00000000000i[XGUI ] [x] Mouse off
00000003305i[BIOS ] $Revision: 1.247 $ $Date: 2010/04/04 19:33:50 $
00000318057i[KBD ] reset-disable command received
00000444815i[VBIOS] VGABios $Id: vgabios.c,v 1.69 2009/04/07 18:18:20 vruppert Exp $
00000444886i[VGA ] VBE known Display Interface b0c0
00000444918i[VGA ] VBE known Display Interface b0c5
00000447843i[VBIOS] VBE Bios $Id: vbe.c,v 1.62 2009/01/25 15:46:25 vruppert Exp $
00000600000i[XGUI ] charmap update. Font Height is 16
00000760532i[BIOS ] Starting rombios32
00000761029i[BIOS ] Shutdown flag 0
00000761710i[BIOS ] ram_size=0x02000000
00000762188i[BIOS ] ram_end=32MB
00000802748i[BIOS ] Found 1 cpu(s)
00000822017i[BIOS ] bios_table_addr: 0x000fbc18 end=0x000fcc00
00000834694i[BIOS ] bios_table_cur_addr: 0x000fbc18
00012943038i[BIOS ] Booting from 0000:7c00
00014092315e[CPU0 ] fetch_raw_descriptor: GDT: index (f) 1 > limit (0)
00014092315e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00014092315e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
00014092315i[CPU0 ] CPU is in protected mode (active)
00014092315i[CPU0 ] CS.d_b = 16 bit
00014092315i[CPU0 ] SS.d_b = 16 bit
00014092315i[CPU0 ] | EAX=60000011 EBX=00000007 ECX=00000000 EDX=00000022
00014092315i[CPU0 ] | ESP=0000ffd4 EBP=00000000 ESI=000e013f EDI=0000009b
00014092315i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af PF cf
00014092315i[CPU0 ] | SEG selector base limit G D
00014092315i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00014092315i[CPU0 ] | CS:0800( 0004| 0| 0) 00008000 0000ffff 0 0
00014092315i[CPU0 ] | DS:0800( 0005| 0| 0) 00008000 0000ffff 0 0
00014092315i[CPU0 ] | SS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00014092315i[CPU0 ] | ES:0800( 0005| 0| 0) 00008000 0000ffff 0 0
00014092315i[CPU0 ] | FS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00014092315i[CPU0 ] | GS:0000( 0005| 0| 0) 00000000 0000ffff 0 0
00014092315i[CPU0 ] | EIP=00000014 (00000014)
00014092315i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
00014092315i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00014092315e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00014092315i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00014092315i[CPU0 ] cpu hardware reset
00014092315i[APIC0] allocate APIC id=0 (MMIO enabled) to 0xfee00000
00014092315i[CPU0 ] CPUID[0x00000000]: 00000003 756e6547 6c65746e 49656e69
00014092315i[CPU0 ] CPUID[0x00000001]: 00000f00 00000800 00000000 078bfbff
00014092315i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00014092315i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
00014092315i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
00014092315i[CPU0 ] CPUID[0x80000000]: 80000004 00000000 00000000 00000000
00014092315i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000000 00000000
00014092315i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00014092315i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00014092315i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00014092315i[ ] reset of 'unmapped' plugin device by virtual method
00014092315i[ ] reset of 'biosdev' plugin device by virtual method
00014092315i[ ] reset of 'speaker' plugin device by virtual method
00014092315i[ ] reset of 'extfpuirq' plugin device by virtual method
00014092315i[ ] reset of 'iodebug' plugin device by virtual method
00014092315i[ ] reset of 'ioapic' plugin device by virtual method
00014092315i[ ] reset of 'keyboard' plugin device by virtual method
00014092315i[ ] reset of 'harddrv' plugin device by virtual method
00014092315i[ ] reset of 'serial' plugin device by virtual method
00014092315i[ ] reset of 'parallel' plugin device by virtual method