General protection exception with updated Pure64

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
hmerovich
Posts: 2
Joined: Fri Oct 27, 2017 6:49 pm

General protection exception with updated Pure64

Post by hmerovich »

I am using an updated version of Pure64 system to build our own simple OS in flat mode under QEMU
https://bitbucket.org/RowDaBoat/x64barebones/

As I want to define my own IRQ handler I update the kernel.c file to call a load_idt function

typedef struct {
uint16_t offset_l, selector;
uint8_t cero, access;
uint16_t offset_m;
uint32_t offset_h, other_cero;
} DESCR_INT;

#pragma pack(pop)


DESCR_INT * idt = (DESCR_INT *) 0;

void setup_IDT_entry (int index, uint8_t selector, uint64_t offset, uint8_t access);

void load_idt() {
_cli();
setup_IDT_entry (0x20, 0x08, (uint64_t)&_irq00Handler, ACS_INT); // timer tick
setup_IDT_entry (0x21, 0x08, (uint64_t)&_irq01Handler, ACS_INT); // keyboard

picMasterMask(0xFC);
picSlaveMask(0xFF);

_sti();
}

void setup_IDT_entry (int index, uint8_t selector, uint64_t offset, uint8_t access) {
idt[index].selector = selector;
idt[index].offset_l = offset & 0xFFFF;
idt[index].offset_m = (offset >> 16) & 0xFFFF;
idt[index].offset_h = (offset >> 32) & 0xFFFFFFFF;
idt[index].access = access;
idt[index].cero = 0;
idt[index].other_cero = (uint64_t) 0;
}

but I get an exception 13 as soon as I get the first interrupt so I add

ncNewline();
ncPrint(" irq00Handler entry at 0x");
ncPrintHex((uint64_t)&_irq00Handler);
ncNewline();
and I find that the function pointer to _irq00handler is 0x4156575552515350.
This problem happens with Ubuntu 17.04 but when I rum the code with Ubuntu 14.04 it works fine and the pointer is around 0x100000 as expected.

Any idea about the cuase of this behavior?

Thanks in advance
Post Reply