I continued the tutorial
http://www.osdever.net/bkerndev/index.php?the_id=90
now comes to Sections
Introduction
Getting Started
The basic kernel
Linking sources
Printing onscreen
The GDT
The IDT
Writing ISRs
the main function is
void kmain()
{
/* You would add commands after here */
int i ;
gdt_install();
idt_install();
isrs_install();
init_video();
puts("isrs:Hello World!\n");
i = 10/0;
putch(i);
}
in the kmain, I call i=10/0 to test Division By Zero Exception ,
but both vmware and boch won't print the Division By Zero Exception on screen.
Division By Zero Exception not printed on emulation(both boc
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Division By Zero Exception not printed on emulation(both
considering your level, may i suggest once again that you took the time to compile a version of BOCHS that has an internal debugger and take the time to consider the debug commands
?
Oh, just a hint: make sure the compiler let you do the "i=10/0" ... that seems sooo obvious it's something that cannot be done. Pick your .o file and try "objdump -drS <yourKernel.o> | less" then search for the "div ..."
If everything was fine, you will start debugging step by step from your kmain() function (or wrapper), execute to "n"ext instruction until you find the "div xxx", then "s"tep over it, which will trigger the exception and jump to your handler code. You should then have more tools to figure out why nothing gets printed ...
Code: Select all
pbreak 0x100000
c
n
n
n ... (until the "div ..." instruction is met)
Oh, just a hint: make sure the compiler let you do the "i=10/0" ... that seems sooo obvious it's something that cannot be done. Pick your .o file and try "objdump -drS <yourKernel.o> | less" then search for the "div ..."
If everything was fine, you will start debugging step by step from your kmain() function (or wrapper), execute to "n"ext instruction until you find the "div xxx", then "s"tep over it, which will trigger the exception and jump to your handler code. You should then have more tools to figure out why nothing gets printed ...
Re:Division By Zero Exception not printed on emulation(both
the boch.out loggedPype.Clicker wrote:
Oh, just a hint: make sure the compiler let you do the "i=10/0" ... that seems sooo obvious it's something that cannot be done. Pick your .o file and try "objdump -drS <yourKernel.o> | less" then search for the "div ..."
Code: Select all
00072410423e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00072410423i[CPU0 ] protected mode
00072410423i[CPU0 ] CS.d_b = 32 bit
00072410423i[CPU0 ] SS.d_b = 32 bit
00072410423i[CPU0 ] | EAX=0000000a EBX=0002bd20 ECX=00000000 EDX=00000000
00072410423i[CPU0 ] | ESP=00103ff0 EBP=00067ec4 ESI=0002be3f EDI=0002be40
00072410423i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf ZF af PF cf
00072410423i[CPU0 ] | SEG selector base limit G D
00072410423i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00072410423i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00072410423i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00072410423i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00072410423i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00072410423i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00072410423i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00072410423i[CPU0 ] | EIP=00100296 (00100296)
00072410423i[CPU0 ] | CR0=0x00000011 CR1=0 CR2=0x00000000
00072410423i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00072410423i[CPU0 ] >> f7
00072410423i[CPU0 ] >> f9
00072410423i[CPU0 ] >> : idiv eax, ecx
00072410423i[SYS ] bx_pc_system_c::Reset(SOFTWARE) called
00072410423i[APIC0] local apic in CPU 0 initializing
it sounds very nice to have the ablity to step over it, I would get the source and compile a one with debug supported.If everything was fine, you will start debugging step by step from your kmain() function (or wrapper), execute to "n"ext instruction until you find the "div xxx", then "s"tep over it, which will trigger the exception and jump to your handler code. You should then have more tools to figure out why nothing gets printed ...
thanks.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Division By Zero Exception not printed on emulation(both
That's clearly a triple fault: while trying to handle the division by zero, there has been another fault (GPF, most likely) and even the "double fault" handler couldn't work properly.asmboozer wrote: the boch.out loggedCode: Select all
00072410423e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting ... 00072410423i[CPU0 ] >> : idiv eax, ecx 00072410423i[SYS ] bx_pc_system_c::Reset(SOFTWARE) called 00072410423i[APIC0] local apic in CPU 0 initializing
I suggest you have a look at the TroubleShooting pages of the FAQ: you might find more suggestions to see what's going wrong here.