00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT! -*- c++ -*- 00002 00003 #ifndef idt_h 00004 #define idt_h 00005 00006 #include "idt_init.h" 00007 #include "initcalls.h" 00008 #include "kmem.h" 00009 #include "mem_layout.h" 00010 #include "types.h" 00011 #include "x86desc.h" 00012 00013 // 00014 // INTERFACE definition follows 00015 // 00016 00017 /* 00018 * Fiasco Interrupt Descriptor Table (IDT) Code 00019 */ 00020 00021 00022 class Idt_entry : public X86desc 00023 { 00024 00025 public: 00026 inline Idt_entry(); 00027 00028 // interrupt gate 00029 inline Idt_entry(Address entry, Unsigned16 selector, Unsigned8 access); 00030 00031 // task gate 00032 inline Idt_entry(Unsigned16 selector, Unsigned8 access); 00033 00034 inline void clear(); 00035 00036 inline Address offset(); 00037 00038 inline Unsigned8 word_count(); 00039 }; 00040 00041 class Idt 00042 { 00043 friend class Jdb_kern_info_bench; 00044 public: 00045 // idt entries for 0x20 CPU exceptions, 0x10 IRQs, 7 syscalls, 00046 // 0x3e/0x3f for APIC exceptions 00047 static const unsigned _idt_max = 0x40; 00048 private: 00049 static const Address _idt = Mem_layout::Idt; 00050 00051 public: 00052 static FIASCO_INIT void init_table(Idt_init_entry *src); 00053 00058 static FIASCO_INIT void init(); 00059 00068 static void set_entry(unsigned vector, Address entry, bool user); 00069 00070 static inline Address idt(); 00071 00077 static inline void set(Pseudo_descriptor *desc); 00078 00079 static inline void get(Pseudo_descriptor *desc); 00080 00084 static void set_timer_vector_run(void); 00085 00089 static void set_timer_vector_stop(void); 00090 00091 private: 00096 static void set_writable(bool writable); 00097 }; 00098 00099 // 00100 // IMPLEMENTATION of inline functions (and needed classes) 00101 // 00102 00103 00104 00105 00106 inline Idt_entry::Idt_entry() 00107 {} 00108 00109 00110 // interrupt gate 00111 00112 inline Idt_entry::Idt_entry(Address entry, Unsigned16 selector, Unsigned8 access) 00113 { 00114 _data.i._offset_low = entry & 0x0000ffff; 00115 _data.i._selector = selector; 00116 _data.i._zero = 0; 00117 _data.i._access = access | Access_present; 00118 _data.i._offset_high = (entry & 0xffff0000) >> 16; 00119 } 00120 00121 00122 // task gate 00123 00124 inline Idt_entry::Idt_entry(Unsigned16 selector, Unsigned8 access) 00125 { 00126 _data.t._selector = selector; 00127 _data.t._access = access | Access_present; 00128 _data.t._avail1 = 0; 00129 _data.t._avail2 = 0; 00130 _data.t._avail3 = 0; 00131 } 00132 00133 00134 00135 inline void 00136 Idt_entry::clear() 00137 { 00138 _data.r = 0; 00139 } 00140 00141 00142 00143 inline Address 00144 Idt_entry::offset() 00145 { 00146 return idt_entry_offset(); 00147 } 00148 00149 00150 00151 inline Unsigned8 00152 Idt_entry::word_count() 00153 { 00154 return _data.i._zero; 00155 } 00156 00157 00158 00159 inline Address 00160 Idt::idt() 00161 { 00162 return _idt; 00163 } 00164 00165 00172 inline void 00173 Idt::set(Pseudo_descriptor *desc) 00174 { 00175 asm volatile ("lidt %0" : : "m" (*desc)); 00176 } 00177 00178 00179 00180 inline void 00181 Idt::get(Pseudo_descriptor *desc) 00182 { 00183 asm volatile ("sidt %0" : "=m" (*desc) : : "memory"); 00184 } 00185 00186 #endif // idt_h