CTAOS v6
This commit is contained in:
9
SysCore/drivers/cpu/idt/idt.asm
Normal file
9
SysCore/drivers/cpu/idt/idt.asm
Normal file
@@ -0,0 +1,9 @@
|
||||
bits 32
|
||||
|
||||
; !!! IDT !!!
|
||||
; Loads the IDT defined in '_idtp'
|
||||
global _i86_IdtLoad
|
||||
extern _idtp
|
||||
_i86_IdtLoad:
|
||||
lidt [_idtp]
|
||||
ret
|
45
SysCore/drivers/cpu/idt/idt.c
Normal file
45
SysCore/drivers/cpu/idt/idt.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/******************************************************************
|
||||
* idt.h - INTERRUPT DESCRIPTOR TABLE *
|
||||
* Contains structures and function declarations for IDT *
|
||||
******************************************************************/
|
||||
#include <system.h>
|
||||
#include "idt.h"
|
||||
|
||||
extern void i86_IdtLoad();
|
||||
/* Declare an IDT of 256 entries. */
|
||||
struct IdtEntry idt[256];
|
||||
struct IdtPointer idtp;
|
||||
|
||||
/* Use this function to set an entry in the IDT. Alot simpler
|
||||
* than twiddling with the GDT ;) */
|
||||
void i86_IdtSetGate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags)
|
||||
{
|
||||
/* The interrupt routine's base address */
|
||||
idt[num].base_lo = (base & 0xFFFF);
|
||||
idt[num].base_hi = (base >> 16) & 0xFFFF;
|
||||
|
||||
/* The segment or 'selector' that this IDT entry will use
|
||||
* is set here, along with any access flags */
|
||||
idt[num].sel = sel;
|
||||
idt[num].always0 = 0;
|
||||
idt[num].flags = flags;
|
||||
}
|
||||
|
||||
struct IdtEntry* i86_IdtGetGate(unsigned char num)
|
||||
{
|
||||
return &idt[num];
|
||||
}
|
||||
|
||||
/* Installs the IDT */
|
||||
void i86_IdtInstall()
|
||||
{
|
||||
/* Sets the special IDT pointer up, just like in 'gdt.c' */
|
||||
idtp.limit = (sizeof (struct IdtEntry) * 256) - 1;
|
||||
idtp.base = (unsigned int)&idt;
|
||||
|
||||
/* Clear out the entire IDT, initializing it to zeros */
|
||||
memset (&idt, 0, sizeof(struct IdtEntry) * 256);
|
||||
|
||||
/* Points the processor's internal register to the new IDT */
|
||||
i86_IdtLoad();
|
||||
}
|
31
SysCore/drivers/cpu/idt/idt.h
Normal file
31
SysCore/drivers/cpu/idt/idt.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/******************************************************************
|
||||
* idt.h - INTERRUPT DESCRIPTOR TABLE *
|
||||
* Contains structures and function declarations for IDT *
|
||||
******************************************************************/
|
||||
|
||||
#ifndef __IDT_H
|
||||
#define __IDT_H
|
||||
|
||||
/* Defines an IDT entry */
|
||||
struct IdtEntry
|
||||
{
|
||||
unsigned short base_lo;
|
||||
unsigned short sel;
|
||||
unsigned char always0;
|
||||
unsigned char flags;
|
||||
unsigned short base_hi;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct IdtPointer
|
||||
{
|
||||
unsigned short limit;
|
||||
unsigned int base;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/* This exists in 'start.asm', and is used to load our IDT */
|
||||
extern void i86_IdtSetGate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags);
|
||||
extern struct IdtEntry* i86_IdtGetGate(unsigned char num);
|
||||
extern void i86_IdtInstall();
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user