gdt.c (910B)
1 #include <module.h> 2 #include <types.h> 3 #include <pc/gdt/gdt.h> 4 #include <interfaceUtilisateur/console/console.h> 5 6 MODULE(Gdt); 7 8 static DescripteurSegment tableDescripteursSegment[] = { 9 [0] = descripteurSegmentNULL, 10 [1] = descripteurSegmentBasicFlatModel(SEGMENT_CODE), 11 [2] = descripteurSegmentBasicFlatModel(SEGMENT_DONNEES) 12 }; 13 14 void initGdt (void** etat) { 15 *etat = etatGdt; 16 17 etatGdt->tableDescripteursSegment = tableDescripteursSegment; 18 etatGdt->registreGDTR.base = etatGdt->tableDescripteursSegment; 19 etatGdt->registreGDTR.limite = sizeof (tableDescripteursSegment) - 1; 20 21 asm volatile ("\ 22 lgdt %0 \n\ 23 ljmp %1, $label \n\ 24 label: \n\ 25 movw %2, %%ax \n\ 26 movw %%ax, %%ds \n\ 27 movw %%ax, %%es \n\ 28 movw %%ax, %%fs \n\ 29 movw %%ax, %%gs \n\ 30 movw %%ax, %%ss" 31 : 32 : "m" (etatGdt->registreGDTR), "g" (8), "g" (16) 33 : "memory", "eax" 34 ); 35 } 36 37 void deinitGdt (void** etat) { 38 *etat = NULL; 39 }