/* * GeekOS IDT initialization code * Copyright (c) 2001, David H. Hovemeyer * $Revision: 1.1 $ * * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "COPYING". */ #include #include #include #include /* ---------------------------------------------------------------------- * Private data and functions * ---------------------------------------------------------------------- */ /* * Allocated */ //static union IDT_Descriptor s_IDT[ NUM_IDT_ENTRIES ]; static union IDT_Descriptor *s_IDT = (union IDT_Descriptor *)IDT_LOCATION; /* * These symbols are defined in lowlevel.asm, and define the * size of the interrupt entry point table and the sizes * of the individual entry points. This gives us sufficient * information to build the IDT. */ extern char g_entryPointTableStart, g_entryPointTableEnd; extern int g_handlerSizeNoErr, g_handlerSizeErr; /* * Table of C interrupt handler functions. * Note that this is public only because it is used * in lowlevel.asm. Other code should not refer to it. */ Interrupt_Handler g_interruptTable[ NUM_IDT_ENTRIES ]; void DumpIDT() { int i; Print("IDT Contents:\n"); for (i=0;i> 16; /* Install the new table in the IDTR. */ Load_IDTR(limitAndBase); } /* * Initialize an interrupt gate with given handler address * and descriptor privilege level. */ void Init_Interrupt_Gate(union IDT_Descriptor* desc, ulong_t addr, int dpl) { desc->ig.offsetLow = addr & 0xffff; desc->ig.segmentSelector = KERNEL_CS; desc->ig.reserved = 0; desc->ig.signature = 0x70; /* == 01110000b */ desc->ig.dpl = dpl; desc->ig.present = 1; desc->ig.offsetHigh = addr >> 16; } /* * Install a C handler function for given interrupt. * This is a lower-level notion than an "IRQ", which specifically * means an interrupt triggered by external hardware. * This function can install a handler for ANY interrupt. */ void Install_Interrupt_Handler(int interrupt, Interrupt_Handler handler) { KASSERT(interrupt >= 0 && interrupt < NUM_IDT_ENTRIES); g_interruptTable[interrupt] = handler; }