idt.h (1488B)
1 #ifndef PC_IDT_IDT_H 2 #define PC_IDT_IDT_H 3 4 #include <types.h> 5 6 typedef enum { 7 DESCRIPTEUR_PORTE_TACHE = 1, 8 DESCRIPTEUR_PORTE_INTERRUPTION = 2, 9 DESCRIPTEUR_PORTE_TRAPPE = 3 10 } TypeDescripteurInterruption; 11 12 typedef enum { 13 TAILLE_PORTE_16 = 0, 14 TAILLE_PORTE_32 = 1 15 } TaillePorte; 16 17 /* x86-doc-vol3.pdf section 5.11, fig 5-2 */ 18 typedef struct DescripteurInterruption { 19 uint16 offset_15_0; 20 21 uint16 selecteurSegment; 22 23 uint8 _zero_a; 24 /* TypeDescripteurInterruption type:2; 25 uint8 _un:1; 26 TaillePorte taillePorte:1; 27 uint8 _zero_b:1; */ 28 uint8 type:5; 29 30 uint8 niveauPrivilegeDescripteur:2; 31 bool present:1; 32 33 uint16 offset_31_16; 34 } PACKED ALIGNED(8) DescripteurInterruption; 35 36 37 /* x86-doc-vol3.pdf section 2.4.1, fig 2.5 */ 38 typedef struct RegistreIDTR { 39 uint16 limite; 40 DescripteurInterruption* base; 41 } PACKED ALIGNED (8) RegistreIDTR; 42 /* TODO : Vérifier le ALIGNED 4 : 43 * x86-doc-vol3.pdf section 3.5.1, 2e page */ 44 45 46 typedef void (*EnregistreurContexteInterruption) (); 47 typedef void (*GestionnaireInterruption) (); 48 49 50 typedef struct EtatIdt { 51 DescripteurInterruption tableDescripteursInterruption[256]; 52 int interruptionsDesactivees; 53 int nombreDescripteursInterruption; 54 RegistreIDTR registreIDTR; 55 } EtatIdt; 56 57 58 int desactiverInterruptions(); 59 int activerInterruptions(); 60 void definirGestionnaireInterruption(int numeroInterruption, GestionnaireInterruption gestionnaire); 61 void activerInterruption(int numeroInterruption); 62 void desactiverInterruption(int numeroInterruption); 63 64 #endif