OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 2:57 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: General protection exception with updated Pure64
PostPosted: Wed Nov 01, 2017 10:51 am 
Offline

Joined: Fri Oct 27, 2017 6:49 pm
Posts: 2
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 gcc 7.1 but when I rum the code with Ubuntu 14.04 gcc 5 it works fine and the pointer is around 0x100000 as expected.

Any idea about the cuase of this behavior?

Thanks in advance


Top
 Profile  
 
 Post subject: Re: General protection exception with updated Pure64
PostPosted: Thu Nov 02, 2017 10:40 am 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 692
hmerovich wrote:
DESCR_INT * idt = (DESCR_INT *) 0;
You don't show all your code (it would be a bonus if you made your project available). But the line above is suspect. You initialize the idt to 0. Did you intend to put the idt at memory address zero? You also don't show us where you use the lidt instruction to load the IDT. We also don't see the data structure you pass to LIDT that has the size of the IDT and a pointer to the IDT.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 90 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group