#include <const.h>
#include <arch/i386.h>
#include <arch/paging.h>
#include <kernel/console.h>
#include <kernel/kernel.h>
#include <kernel/task.h>
#include <arch/mem.h>
Go to the source code of this file.
Functions | |||||||||
| word | setup_GDT_entry (word limit, dword base, byte attribs0_7, byte attribs8_15) | ||||||||
Initialize a GDT entry.
| |||||||||
| void | remove_GDT_entry (word sel) | ||||||||
Remove a GDT entry.
| |||||||||
| void | install_GDT () | ||||||||
| Initialize the Global Descriptor Table with the default selectors and update the segment registers. | |||||||||
Variables | |||||||||
| volatile gdt_entry_t | gdt [GDT_DIM] | ||||||||
| Global Descriptor Table (GDT). | |||||||||
| gdt_reg | gdt_ptr | ||||||||
| GDT pointer. | |||||||||
Definition in file mem.c.
|
|
Initialize the Global Descriptor Table with the default selectors and update the segment registers.
Definition at line 93 of file mem.c.
00094 {
00095 // First of all reset all entries in the GDT //
00096 memset(&gdt, 0, sizeof(gdt));
00097
00098 // ------------- Reserved entries in the GDT ------------------ //
00099
00100 // Dummy descriptor//
00101 setup_GDT_entry(0, 0, 0, 0);
00102 // KERNEL_DATA descriptor 0x08 //
00103 setup_GDT_entry(0xFFFF, 0, DATA_SEG, (ATTR_GRANUL | ATTR_32BIT | 0xF));
00104 // KERNEL_CODE descriptor 0x10 //
00105 setup_GDT_entry(0xFFFF, 0, CODE_SEG, (ATTR_GRANUL | ATTR_32BIT | 0xF));
00106 // USER_DATA descriptor 0x18 //
00107 setup_GDT_entry(0xFFFF, 0, (DATA_SEG | DPL_3), (ATTR_GRANUL | ATTR_32BIT | 0xF));
00108 // USER_CODE descriptor 0x20 //
00109 setup_GDT_entry(0xFFFF, 0, (CODE_SEG | DPL_3), (ATTR_GRANUL | ATTR_32BIT | 0xF));
00110
00111 // --------- End of reserved entries in the GDT --------------- //
00112
00113 // Set up the GDT pointer //
00114 gdt_ptr.limit = (uint16_t)(GDT_DIM * GDT_ENTRY_DIM - 1);
00115 gdt_ptr.base = (size_t)gdt;
00116
00117 // Load info into GDTR //
00118 __asm__ __volatile__ ("lgdtl (%0)" : : "r"(&gdt_ptr));
00119
00120 // Update segment registers //
00121 k_update_segment_regs();
00122 }
|
|
|
Remove a GDT entry.
Definition at line 74 of file mem.c.
00075 {
00076 dword IF = GET_IF();
00077
00078 disable();
00079
00080 gdt[sel/GDT_ENTRY_DIM].limit = 0;
00081 gdt[sel/GDT_ENTRY_DIM].base0_15 = 0;
00082 gdt[sel/GDT_ENTRY_DIM].base16_23 = 0;
00083 gdt[sel/GDT_ENTRY_DIM].base24_31 = 0;
00084 gdt[sel/GDT_ENTRY_DIM].attribs0_7 = 0;
00085 gdt[sel/GDT_ENTRY_DIM].attribs8_15 = 0;
00086
00087 SET_IF(IF);
00088 }
|
|
||||||||||||||||||||
|
Initialize a GDT entry.
Definition at line 44 of file mem.c.
00045 {
00046 // Skip the dummy entry (#0).
00047 register unsigned short i=1;
00048 dword IF = GET_IF();
00049
00050 disable();
00051 for (; i<GDT_DIM; i++)
00052 {
00053 if (!(gdt[i].limit))
00054 {
00055 gdt[i].limit = limit;
00056 gdt[i].base0_15 = base & 0xFFFF;
00057 gdt[i].base16_23 = (base >> 16) & 0xFF;
00058 gdt[i].base24_31 = (base >> 24) & 0xFF;
00059 gdt[i].attribs0_7 = attribs0_7;
00060 gdt[i].attribs8_15 = attribs8_15;
00061
00062 SET_IF(IF);
00063
00064 // Return the selector.
00065 return(i * GDT_ENTRY_DIM);
00066 }
00067 }
00068 error("Out of GDT entries!");
00069 return( NULL );
00070 }
|
|
|
Global Descriptor Table (GDT).
|
|
|
GDT pointer.
|
1.2.18