OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 4:24 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: the idt again
PostPosted: Tue Sep 11, 2001 11:00 pm 
this code doesn´t work
*********************************************

struct
{
unsigned short size;
unsigned long *basis;
}__attribute__((packed)) IDTR;

typedef struct
{
unsigned short offset_0_15;
unsigned short selektor;

unsigned char type;
unsigned char leer;
unsigned short offset_16_31;
}__attribute__((packed)) GATE;

void int_null();
void intgate(void *addr,unsigned char num_int,unsigned char type);
void lidt();
void setup_idt();
void int0();
void int1();
void int2();
void int3();
void int4();
void int5();
void int6();
void int7();
void int8();
void int9();
void int10();
void int11();
void int12();
void int13();
void int14();
void int15();
void int16();
void int17();

extern GATE idt[256];
#include "types.h"
void intgate(void *addr ,unsigned char num_int,unsigned char type)
{
unsigned short codesegment=0x10;

idt[num_int].offset_0_15=(unsigned short)(((unsigned long)addr)&0xffff);
idt[num_int].selektor=codesegment;
idt[num_int].type=type;
idt[num_int].leer=0;
idt[num_int].offset_16_31=(unsigned short)(((unsigned long)addr)>>16);
}

void lidt()
{


IDTR.size=2057;
IDTR.basis=0x78;
__asm__("lidt %0": :"m" (IDTR));
}


void setup_idt()
{
int i;

intgate(int0,0,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int1,1,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int2,2,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int3,3,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int4,4,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int5,5,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int6,6,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int7,7,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int8,8,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int9,9,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int10,10,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int11,11,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int12,12,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int13,13,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int14,14,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int15,15,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int16,16,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
intgate(int17,17,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);
for (i=18;i<256;i++)
intgate(int_null,i,INTGATE_80386 | SYSTEM | DPL0 | PRESENT);

lidt();

}

void int0()
{
writescreen("Division durch 0 Fault:",0x1f);
while(1);

}


void int1()
{

writescreen("Debug Ausnahme",0x1f);
while(1);
}


void int2()
{
writescreen("unbekannter error",0x1f);
while(1);

}


void int3()
{
writescreen("Unterbrechungspunkt",0x1f);
while(1);

}


void int4()
{
writescreen("Overflow",0x1f);
while(1);

}


void int5()
{
writescreen("hmmmmmm",0x1f);
while(1);

}


void int6()
{
writescreen("Falscher Opcode",0x1f);
while(1);

}


void int7()
{
writescreen("Coprozessor Fault",0x1f);
while(1);

}


void int8()
{
writescreen("Double Fault",0x1f);
while(1);

}


void int9()
{
writescreen("Coprozessor Fault2",0x1f);
while(1);

}


void int10()
{
writescreen("Invalid TSS",0x1f);
while(1);
}


void int11()
{
writescreen("Segment nicht vorhanden",0x1f);
while(1);

}


void int12()
{
writescreen("Stack exception",0x1f);
while(1);

}


void int13()
{
writescreen("General Protection Fault",0x1f);
while(1);

}


void int14()
{
writescreen("Paging fehler:",0x1f);
while(1);

}


void int15()
{
writescreen("Unknown error",0x1f);
while(1);

}


void int16()
{
writescreen("Coprozessor fault3",0x1f);
while(1);

}


void int17()
{
writescreen("critical error",0x1f);
while(1);

}

void int_null()
{
writescreen("intxx:",0x07);
while(1);
}
*************************************************
if i cause the divide 0 error the computer reboots
what must i change that the idt works probably
PLS HELP!!!!!!!!!!!!
[email protected]


Top
  
 
 Post subject: RE:the idt again
PostPosted: Tue Sep 11, 2001 11:00 pm 
perhaps i reprogrammend the pic not probably
******************PIC.h*********************
#ifndef __8259_H
#define __8259_H
void init8259();
void enable_irq(unsigned short num);
void disable_irq(unsigned short num);
#define ICW1 0x11
#define ICW4 0x01
#define MASTERPIC 0x20
#define MASTERIMR 0x21
#define SLAVEPIC 0xa0
#define SLAVEIMR 0xa1
#define EOI 0x20

#define M_VEC 0x68
#define S_VEC 0x70

#define OCW3_IRR 0x0A
#define OCW3_ISR 0x0B
#endif
*********************pic.c**************************
unsigned int irq_mask=0xffff;
void init8259()
{
/*ICW1*/
outbyte(MASTERPIC,ICW1);
outbyte(SLAVEPIC,ICW1);
/*ICW2*/
outbyte(MASTERPIC+1,M_VEC);
outbyte(SLAVEPIC+1,S_VEC);
/*ICW3*/
outbyte(MASTERPIC+1,0x3);
outbyte(SLAVEPIC+1,2);
/*ICW4*/
outbyte(MASTERPIC+1,ICW4);
outbyte(SLAVEPIC+1,ICW4);
/*masken aller interrupts über das imr register*/
outbyte(MASTERIMR,0xff);
outbyte(SLAVEIMR,0xff);
}
void enable_irq(unsigned short num)
{
irq_mask&=~(1<<num);
if(num>=8)
irq_mask&=~(1<<2);

outbyte(MASTERPIC+1,irq_mask&0xff);
outbyte(SLAVEPIC+1,(irq_mask>>8)&0xff);
}

void disable_irq(unsigned short num)
{
irq_mask=irq_mask|(1<<num);
if((irq_mask&0xff00)==0xff00)
irq_mask=irq_mask|(1<<2);
outbyte(MASTERPIC+1,irq_mask&0xff);
outbyte(SLAVEPIC+1,(irq_mask>>8) &0xff);
}
_______________________________________________
pleas i really need help!


Top
  
 
 Post subject: RE:the idt again
PostPosted: Tue Sep 11, 2001 11:00 pm 
>#define M_VEC 0x68
>#define S_VEC 0x70

You've programmed these as your master and
slave vector for hardware interrupts, which means
your "divide by zero" interrupt should be at
0x68 (assuming it's the first hardware interrupt,
which if I recall correctly, it is).

You're setting your interrupts starting at 0...
not 0x68. Try that, and see what happens.

j.weeks

ps - I just skimmed through the code... but
hopefully this is the only problem.


Top
  
 
 Post subject: RE:the idt again
PostPosted: Wed Sep 12, 2001 11:00 pm 
the problem is solved
only the gatestruct was false
thx to M.Schuetz


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 125 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