3rd (269008768) exception with no resolution

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
neil

3rd (269008768) exception with no resolution

Post by neil »

Hello everybody !
I'm a newbie in osdev and I'm trying to transform my first mono kernel into a micro kernel architecture. I am also using GRUB and creating a multiboot compliant kernel (http://www.gnu.org/software/grub/manual/multiboot).
But as creating a new kernel initialization, my emulator (Bochs) throws an exception (I think a triple fault, even if I don't know what is it :)
Here is the log:
00008365740e[CPU  ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
========================================================================
Event type: ERROR
Device: [CPU  ]
Message: exception(): 3rd (269008768) exception with no resolution, shutdown status is 7fffd710h, resetting

A ERROR has occurred.  Do you want to:
  cont       - continue execution
  alwayscont - continue execution, and don't ask again.
               This affects only ERROR events from device [CPU  ]
  die        - stop execution now
  abort      - dump core
Choose one of the actions above: [die] die
00008365740i[SYS  ] Last time is 1077442389
00008365740i[XGUI ] Exit.
00008365740i[CPU  ] protected mode
00008365740i[CPU  ] CS.d_b = 32 bit
00008365740i[CPU  ] SS.d_b = 32 bit
00008365740i[CPU  ] | EAX=00000000  EBX=0002bdc0  ECX=000003c6  EDX=00000006
00008365740i[CPU  ] | ESP=001059bc  EBP=001059d4  ESI=0002bed9  EDI=0002beda
00008365740i[CPU  ] | IOPL=0 NV UP EI PL ZR NA PE NC
00008365740i[CPU  ] | SEG selector     base    limit G D
00008365740i[CPU  ] | SEG sltr(index|ti|rpl)     base    limit G D
00008365740i[CPU  ] |  DS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00008365740i[CPU  ] |  ES:0010( 0002| 0|  0) 00000000 000fffff 1 1
00008365740i[CPU  ] |  FS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00008365740i[CPU  ] |  GS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00008365740i[CPU  ] |  SS:0010( 0002| 0|  0) 00000000 000fffff 1 1
00008365740i[CPU  ] |  CS:0008( 0001| 0|  0) 00000000 000fffff 1 1
00008365740i[CPU  ] | EIP=001000e4 (001000e4)
00008365740i[CPU  ] | CR0=0x60000011 CR1=0x00000000 CR2=0x00000000
00008365740i[CPU  ] | CR3=0x00000000 CR4=0x00000000
00008365740i[     ] restoring default signal behavior

The exception is thrown when I try to activate the interruptions via sti:

/* Kernel initialization. */
void cmain (unsigned long address) {
    init_printk () ;
    printk ("Esperanza version 0.0.1\n") ;

    // Init the GDT
    init_gdt () ;

    // Verify the GDT
    kgdtr.size = 0 ;
    kgdtr.address = 0 ;
    asm("sgdtl (kgdtr)");
    printk("GDT address: 0x%x, size: 0x%x\n",
        kgdtr.address, kgdtr.size) ;

    // Init the IDT
    init_idt () ;

    // Verify the GDT
    kidtr.size = 0 ;
    kidtr.address = 0 ;
    asm("sidtl (kidtr)");
    printk("IDT address: 0x%x, size: 0x%x\n",
        kidtr.address, kidtr.size) ;

    init_pic () ;

    init_pit () ;

    // Enable interruptions
    printk ("Back\n") ;
    sti () ;    // <-- EXCEPTION

    // Infinite loop
    for (;;) ;
}

Don't know if anybody had got the same error, or have suggestions, but please help! (And excuse my poor english!)
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

RE:3rd (269008768) exception with no resolution

Post by bubach »

Are you sure that the IDT is correct?

/ Christoffer
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
neil

RE:3rd (269008768) exception with no resolution

Post by neil »

Well, I think everything is okay, I used the same code with my last kernel (I had the same error when I put the lidt instruction in the C code instead of the ASM, but don't know why ?!).

Here is the IDT code :

idt.h :

#ifndef __IDT_H
#define __IDT_H

#include <next.h>

#define IDT_ADDRESS 0x800
#define IDT_ENTRY_COUNT 0xff
#define IDT_ENTRY_SIZE 8
#define IDT_SIZE (IDT_ENTRY_COUNT * IDT_ENTRY_SIZE)
#define IDT_ENTRY(i) ((IDT_Entry *) (IDT_ADDRESS + i * IDT_ENTRY_SIZE))

#define INT_GATE  0x8e00

#define cli() asm ("cli")
#define sti() asm ("sti")
#define iret asm ("leave \n \
   sti \n \
                   iret") ;
#define eoi() asm ("mov $0x20, %al \n \
                    out %al, $0x20") ;
#define eoi2() asm ("mov $0x20, %al \n \
                     out %al, $0xa0") ;

/** Entry in the IDT. */
typedef struct {
    /** First part of the offset (bits 0-15) */
    nx_ushort offset_first ;
    /** Selector */
    nx_ushort selector ;
    /** Type of the entry. */
    nx_ushort type ;
    /** Second part of the offset (bits 16-31) */
    nx_ushort offset_second ;
} IDT_Entry __attribute__ ((packed)) ;

/** Structure loaded into IDTR. */
typedef struct {
    /** Size of the IDT. */
    nx_ushort size ;
    /** Address of the IDT. */
    nx_uint address ;
} IDTR __attribute__ ((packed)) ;

IDTR kidtr ;

/** Initialize the IDT. */
void init_idt () ;
void init_idt_entry (void * offset,
                     nx_ushort selector,
                     nx_ushort type,
                     IDT_Entry * entry) ;

/** Catch-all interrupt gate. */
void int_default () ;

#endif


idt.c:

#include <gdt.h>
#include <idt.h>
#include <panic.h>
#include <pic.h>
#include <printk.h>


void init_idt_entry (void * function,
                     nx_ushort selector,
                     nx_ushort type,
                     IDT_Entry * entry) {

    nx_uint offset = (nx_uint) function ;
    entry->offset_first = offset & 0xffff ;
    entry->selector = selector ;
    entry->type = type ;
    entry->offset_second = offset >> 16 ;
}

void init_idt () {

    int i ;
    for (i = 0 ; i < IDT_ENTRY_COUNT ; i++)
        init_idt_entry (int_default, KERNEL_CODE, INT_GATE, IDT_ENTRY (i)) ;

    kidtr.size = IDT_SIZE ;
    kidtr.address = IDT_ADDRESS ;

    // Load IDTR
    asm ("lidtl (kidtr)");

    printk ("\tIDT initialized\n") ;
}

/**
* Used to catch unmanaged interrupts.
*/
void int_default () {

    panic ("Unmanaged interruption") ;
}


And here is the screen before the interruption:
Esperanza version 0.0.1
        GDT initialized
GDT address: 0x0, size: 0x800
        IDT initialized
IDT address: 0x800, size: 0x7f8
        PIT initialized
Back

/ Neil Dökkalfar
neil

RE:3rd (269008768) exception with no resolution

Post by neil »

Don't know why, and THAT's the thing I wanna know, the following code works :

kload.asm

[BITS 32]

%define MULTIBOOT_HEADER_MAGIC 0x1badb002
%define MULTIBOOT_HEADER_FLAGS 0x00000003


global start, _start

extern init_printk, printk, init_gdt, init_idt, init_pic, init_pit, cmain

start:
_start:

jmp multiboot_entry

multiboot_header:


align 4

; Magic number
dd MULTIBOOT_HEADER_MAGIC

; Multiboot flags
dd MULTIBOOT_HEADER_FLAGS

; The checksum
dd - (MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)


multiboot_entry:

mov esp, 0x90000

push 0
popf

; Init the screen
call init_printk

; Display a message
push hello
        call printk
        add esp, 4

; Init the new GDT
call init_gdt
lgdt [gdtptr]
        mov ax, 0x10
        mov ds, ax
        mov es, ax
        mov fs, ax
        mov gs, ax
        mov ss, ax

        jmp dword 0x08:next
next:

; Init interrupts
lidt [idtptr]
call init_idt

; Init PIC
call init_pic

; Init the Programmable interrupt controller
call init_pit

; Enable interrupts
        sti

; Jump to the kernel
push ebx
call cmain


; GDT pointer used to load the new GDT
gdtptr:
dw 0x800    ; Size
        dd 0x000    ; Address


; IDT pointer used to load IDT
idtptr:
dw 0x400    ; Size
        dd 0x800    ; Address


; Messages
hello db 'Kernel is speaking', 10, 0

/Neil Dökkalfar <[email protected]>
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

RE:3rd (269008768) exception with no resolution

Post by bubach »

I don´t know what the problem is, but you could check on this forum:
http://www.mega-tokyo.com/forum/
You may already know about that forum, but i post the link anyway.. ;-)
They are a bit more active (faster and better responses) i think...

/ Christoffer
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
Post Reply