Home arrow Forums
OSDEV Forums  


Sill
User

Fresh Osdever
Posts: 3
graphgraph
Karma: 0  
Kernel reboots after keybord IRQ1 - 2008/05/17 13:54 Well, after many hours of work and many drops of sudor... i stick.

I have a bootloader loads kernel from raw-data floppy, unblock A20, setts primitives stack and GDT and jump to C coded kernel.

There I set new GDT and IDT tables, reroute hardware IRQs, set IRQ1 and enable it (and disabling all others).
After that I 'sti' and make a for(;;

To this point all seems to be OK.

But when I press any key, the kernel is rebooting, with bochs log listed below.

I try all things i could invent or find over the Inet.
I googled all Internet, i think (-;

What have I do wrong??

If someone could look up my code it's all in attachment. It is prepared to compiling on FreeBSD by typing 'sh make.sh'.

I just can’t look anymore at Vi with asm/c mash (-;
Help! (-:


The Bochs rebooting log:
Code:

 00091058500i[CPU0 CPU is in protected mode (active) 00091058500i[CPU0 CS.d_b 32 bit 00091058500i[CPU0 SS.d_b 32 bit 00091058500i[CPU0 EFER   0x00000000 00091058500i[CPU0 ] | RAX=0000000000000000  RBX=0000000000000010 00091058500i[CPU0 ] | RCX=0000000000000008  RDX=0000000000000007 00091058500i[CPU0 ] | RSP=0000000000007fd0  RBP=0000000000000000 00091058500i[CPU0 ] | RSI=00000000ffff88ca  RDI=0000000000080001 00091058500i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000 00091058500i[CPU0 ] | R10=0000000000000000  R11=0000000000000000 00091058500i[CPU0 ] | R12=0000000000000000  R13=0000000000000000 00091058500i[CPU0 ] | R14=0000000000000000  R15=0000000000000000 00091058500i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df IF tf sf zf af pf cf 00091058500i[CPU0 ] | SEG selector     base    limit G D 00091058500i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D 00091058500i[CPU0 ] |  CS:000800010|  000000000 000fffff 1 1 00091058500i[CPU0 ] |  DS:001000020|  000000000 000fffff 1 1 00091058500i[CPU0 ] |  SS:001000020|  000000000 000fffff 1 1 00091058500i[CPU0 ] |  ES:001000020|  000000000 000fffff 1 1 00091058500i[CPU0 ] |  FS:001000020|  000000000 000fffff 1 1 00091058500i[CPU0 ] |  GS:001000020|  000000000 000fffff 1 1 00091058500i[CPU0 ] |  MSR_FS_BASE:0000000000000000 00091058500i[CPU0 ] |  MSR_GS_BASE:0000000000000000 00091058500i[CPU0 ] | RIP=0000000000011130 (0000000000011130) 00091058500i[CPU0 ] | CR0=0x00000011 CR1=0x0 CR2=0x0000000000000000 00091058500i[CPU0 ] | CR3=0x00000000 CR4=0x00000000 00091058500i[CPU0 ] >> jmp .+0xfffffffe (0x00011130) : EBFE 00091058500e[CPU0 exception(): 3rd (13exception with no resolutionshutdown status is 00hresetting 00091058500i[SYS  bx_pc_system_c::Reset(SOFTWAREcalled 00091058500i[CPU0 cpu software reset

File Attachment:
File name: os.zip
File size:14447 bytes


Post edited by: Sill, at: 2008/05/17 14:10
  | | The administrator has disabled public write access.
OSDEV
Community
Advertisement
   
Flux
User

Fresh Osdever
Posts: 4
graphgraph
Karma: 0  
Re:Kernel reboots after keybord IRQ1 - 2008/05/18 11:29 You got a triple fault. This means there's an error in your interrupt handling.

When an interrupt can't be delivered to correct handler (probably due to a faulty IDT) the CPU triggers a double fault interrupt instead.

If the double fault interrupt can't be delivered either, you get a triple fault, which means that the CPU resets.
  | | The administrator has disabled public write access.
Sill
User

Fresh Osdever
Posts: 3
graphgraph
Karma: 0  
Re:Kernel reboots after keybord IRQ1 - 2008/05/18 15:04 (sorry for big parts of code but i have not idea how to avid this)

In entry.asm (the 'header' linked to the kernel.c) i have:
Code:

 cli lgdt [gdt_descr] lidt [idt_descr] jmp .1 .1: ... call reroute_irqs ... [EXTERN __main] call __main ... idt_descr:  dw 256*8-1  dd idt [GLOBAL idt] idt:  times 256 dd 0,0 ...  [GLOBAL _irq1]  _irq1:  (ISR codeI`ve even tried hlt for test purposes) ...



Then in C code I set IDT table entry by code like this:
Code:

 #define __byte(x,y)     (((unsigned char *)&(y))[x]) #define cached_21       (__byte(0,cached_irq_mask)) #define cached_A1       (__byte(1,cached_irq_mask)) static unsigned int cached_irq_mask 0xffff; typedef struct {         unsigned short offset_0;         unsigned short selector;         unsigned short type;         unsigned short offset_16; } gate_desc[256]; extern gate_desc idt; void set_gate(int nunsigned long irq_handleunsigned short type) {         idt[n].offset_0  irq_handle;         idt[n].selector  0x08;         idt[n].type      type;         idt[n].offset_16 = (irq_handle >> 16); } void disable_irq(unsigned int irq) {         unsigned int mask = (<< irq);         cached_irq_mask |= mask;         if (irq 8) {                 outb(cached_A1,0xA1);         } else {                 outb(cached_21,0x21);         } } void enable_irq(unsigned int irq) {         unsigned int mask = ~(<< irq);         cached_irq_mask &= mask;         if (irq 8) {                 outb(cached_A1,0xA1);         } else {                 outb(cached_21,0x21);         } } // entry point of kernel void __main() {         int i 0;         for( 016++ ) {                 disable_irq(i);         }         enable_irq(1);         set_gate(0x21, (unsigned long)&_irq10x8E00);         sti();         for( ; ; ); }



What can be wrong?
I really have no idea...
  | | The administrator has disabled public write access.

A WebArticles site. Sponsored by Evoleto. Motorola V525 / Business Directory / Delaware Incorporation / Home Made Bazaar