Any C crashes kernel
Posted: Sat May 05, 2007 1:54 pm
I'm very new to OS development. I've written a simple bootloader that does everything to get into protected mode (enable a20, set up gdt, etc.)(I haven't set up an IDT yet, though). I can get it to load and use the kernel entry point (which I can do whatever with), but including any C code at all kills it. Even just having something like crashes the kernel immediately. The last few lines in the bochs output before crash are:
Any ideas on what might be going wrong? I can post code/system stats if necessary.
Code: Select all
void main() {}
Code: Select all
00000320000e[CLVGA] character height = 1, skipping text update
00000400000e[CLVGA] character height = 1, skipping text update
00000480000i[XGUI ] charmap update. Font Height is 16
00024645358i[CPU ] BxError: instruction with opcode=0xff
00024645358i[CPU ] mod was c0, nnn was 7, rm was 7
00024645358i[CPU ] WARNING: Encountered an unknown instruction (signalling illegal instruction)
00024645358e[CPU ] interrupt(): gate descriptor is not valid sys seg
00024645358e[CPU ] interrupt(): gate descriptor is not valid sys seg
00024645358i[CPU ] protected mode
00024645358i[CPU ] CS.d_b = 32 bit
00024645358i[CPU ] SS.d_b = 32 bit
00024645358i[CPU ] | EAX=00000017 EBX=00000010 ECX=00000003 EDX=00000000
00024645358i[CPU ] | ESP=0009cff8 EBP=00000000 ESI=0000a3b0 EDI=0000ffde
00024645358i[CPU ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf ZF af PF cf
00024645358i[CPU ] | SEG selector base limit G D
00024645358i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00024645358i[CPU ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00024645358i[CPU ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00024645358i[CPU ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00024645358i[CPU ] | ES:ffff( 0000| 0| 0) 000ffff0 0000ffff 0 0
00024645358i[CPU ] | FS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00024645358i[CPU ] | GS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00024645358i[CPU ] | EIP=02000001 (02000001)
00024645358i[CPU ] | CR0=0x00000011 CR1=0 CR2=0x00000000
00024645358i[CPU ] | CR3=0x00000000 CR4=0x00000000
00024645358i[CPU ] >> (invalid) : FFFF
00024645358e[CPU ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00024645358i[SYS ] bx_pc_system_c::Reset(SOFTWARE) called