33 #include "gdt-layout.h"
35 #include "prot-domains.h"
36 #include "segmentation.h"
38 #define GDT_MEM_PL0 (SEG_DESCTYPE_NSYS | SEG_GRAN_PAGE)
39 #define GDT_CODE_PL0 (GDT_MEM_PL0 | SEG_TYPE_CODE_EXRD)
40 #define GDT_DATA_PL0 (GDT_MEM_PL0 | SEG_TYPE_DATA_RDWR)
53 gdt[GDT_NUM_FIXED_DESC];
56 ((((uintptr_t)&_ebss_gdt_addr) - \
57 (uintptr_t)gdt)/sizeof(segment_desc_t))
60 static void ATTR_CODE_BOOT
61 set_descriptor(
unsigned int index,
68 if(GDT_LEN <= index) {
72 segment_desc_init(&descriptor, base, len, flag);
75 gdt_insert_boot(index, descriptor);
79 gdt_copy_desc_change_dpl(
unsigned int dest_idx,
85 if((GDT_LEN <= dest_idx) || (GDT_LEN <= src_idx)) {
89 gdt_lookup(src_idx, &desc);
90 SEG_SET_FLAG(desc, DPL, dpl);
91 gdt_insert(dest_idx, desc);
108 gdtr.base = KERN_DATA_OFF_TO_PHYS_ADDR(gdt);
111 set_descriptor(GDT_IDX_NULL, 0, 0, 0);
112 set_descriptor(GDT_IDX_CODE_FLAT, 0, 0x100000, GDT_CODE_PL0);
113 set_descriptor(GDT_IDX_DATA_FLAT, 0, 0x100000, GDT_DATA_PL0);
116 __asm__ __volatile__ (
"lgdt %0" ::
"m" (gdtr));
132 KERN_WRITEL(gdt[idx].raw_lo, desc.raw_lo);
133 KERN_WRITEL(gdt[idx].raw_hi, desc.raw_hi);
139 if((GDT_LEN <= idx) || (desc ==
NULL)) {
143 KERN_READL(desc->raw_lo, gdt[idx].raw_lo);
144 KERN_READL(desc->raw_hi, gdt[idx].raw_hi);
#define __attribute__(nothing)
Define attribute to nothing since it isn't handled by IAR.
#define NULL
The null pointer.