www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

gdt.h (2217B)


      1 #ifndef PC_GDT_GDT_H
      2 #define PC_GDT_GDT_H
      3 
      4 #include <types.h>
      5 
      6 typedef enum {
      7 	SEGMENT_DONNEES = 0,
      8 	SEGMENT_CODE = 1
      9 } TypeSegmentCodeDonnees;
     10 
     11 typedef enum {
     12 	DESCRIPTEUR_SEGMENT_SYSTEME = 0,
     13 	DESCRIPTEUR_SEGMENT_CODE_DONNEES = 1
     14 } TypeDescripteurSegment;
     15 
     16 typedef enum {
     17 	TAILLE_OPERATION_16 = 0,
     18 	TAILLE_OPERATION_32 = 1
     19 } TailleOperationSegment;
     20 
     21 /* Union avec TailleOperationSegment */
     22 typedef enum {
     23 	LIMITE_HAUTE_64Ko = 0,
     24 	LIMITE_HAUTE_4Go = 1
     25 } LimiteHauteSegment;
     26 
     27 typedef enum {
     28 	GRANULARITE_1octet = 0,
     29 	GRANULARITE_4Ko = 1
     30 } GranulariteSegment;
     31 
     32 /* x86-doc-vol3.pdf section 3.4.5, fig 3-8 */
     33 typedef struct DescripteurSegment {
     34 	uint16 limite_15_0;
     35 	
     36 	uint16 base_15_0;
     37 	
     38 	uint8 base_23_16;
     39 	bool accede:1;
     40 	bool lecture_ecriture:1;
     41 	bool expansionBas_conforme:1;
     42 	TypeSegmentCodeDonnees codeDonnees:1;
     43 	
     44 	TypeDescripteurSegment typeDescripteur:1;
     45 	uint8 niveauPrivilegeDescripteur:2;
     46 	bool  present:1;
     47 	
     48 	uint8 limite_19_16:4;
     49 	uint8 _disponible:1;
     50 	uint8 _reserve:1; /* Segment de code 64 bits (IA32 seulement) */
     51 	TailleOperationSegment tailleOperation:1;
     52 	/* union avec ci-dessus : LimiteHauteSegment limiteHaute:1; */
     53 	GranulariteSegment granularite:1;
     54 	uint8 base_31_24;
     55 } PACKED ALIGNED(8) DescripteurSegment;
     56 
     57 #define descripteurSegmentNULL { \
     58 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
     59 }
     60 
     61 #define descripteurSegmentBasicFlatModel(_codeDonnees) \
     62 	{ \
     63 		.limite_15_0 = 0xFFFF, \
     64 		.base_15_0 = 0x0000, \
     65 		.base_23_16 = 0x00, \
     66 		.accede = FALSE, \
     67 		.lecture_ecriture = TRUE, \
     68 		.expansionBas_conforme = FALSE, \
     69 		.codeDonnees = _codeDonnees, \
     70 		.typeDescripteur = DESCRIPTEUR_SEGMENT_CODE_DONNEES, \
     71 		.niveauPrivilegeDescripteur = 0, \
     72 		.present = 1, \
     73 		.limite_19_16 = 0xF, \
     74 		._disponible = 0, \
     75 		._reserve = 0, \
     76 		.tailleOperation = TAILLE_OPERATION_32, \
     77 		.granularite = GRANULARITE_4Ko, \
     78 		.base_31_24 = 0 \
     79 	}
     80 
     81 
     82 /* x86-doc-vol3.pdf section 2.4.1, fig 2.5 */
     83 typedef struct RegistreGDTR {
     84 	uint16 limite;
     85 	DescripteurSegment* base;
     86 } PACKED ALIGNED (4) RegistreGDTR;
     87 /* TODO : Vérifier le ALIGNED 4 :
     88  * x86-doc-vol3.pdf section 3.5.1, 2e page */
     89 
     90 
     91 typedef struct EtatGdt {
     92 	DescripteurSegment* tableDescripteursSegment;
     93 	RegistreGDTR registreGDTR;
     94 } EtatGdt;
     95 
     96 #endif