From 49eb099b806bc2049cfe8fbeb9c2f1a309a37878 Mon Sep 17 00:00:00 2001 From: Jacek Galowicz Date: Wed, 13 Jun 2012 09:36:28 +0200 Subject: [PATCH] Reverted the removal of configure_gdt_entry() Commit 227cc198905c42a52af8076e3f9f3542118f276f "add alpha version of x64 support" removed configure_gdt_entry(), but this is used within the lguest branch. --- arch/x86/include/asm/gdt.h | 10 ++++++++++ arch/x86/kernel/gdt.c | 28 +++++++++++++++------------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/gdt.h b/arch/x86/include/asm/gdt.h index 75f8ffe8..c86a5d4b 100644 --- a/arch/x86/include/asm/gdt.h +++ b/arch/x86/include/asm/gdt.h @@ -122,6 +122,16 @@ typedef struct { */ void gdt_install(void); +/** @brief Configures and returns a GDT descriptor with chosen attributes + * + * Just feed this function with address, limit and the flags + * you have seen in idt.h + * + * @return a preconfigured gdt descriptor + */ +void configure_gdt_entry(gdt_entry_t *dest_entry, unsigned long base, unsigned long limit, + unsigned char access, unsigned char gran); + #ifdef __cplusplus } #endif diff --git a/arch/x86/kernel/gdt.c b/arch/x86/kernel/gdt.c index c625c8c1..c5a1e673 100644 --- a/arch/x86/kernel/gdt.c +++ b/arch/x86/kernel/gdt.c @@ -188,26 +188,28 @@ int create_default_frame(task_t* task, entry_point_t ep, void* arg) return 0; } -/** @brief Configures GDT descriptor with chosen attributes - * - * Just feed this function with address, limit and the flags - * you have seen in gdt.h - */ +/* Setup a descriptor in the Global Descriptor Table */ static void gdt_set_gate(int num, unsigned long base, unsigned long limit, - unsigned char access, unsigned char gran) + unsigned char access, unsigned char gran) +{ + configure_gdt_entry(&gdt[num], base, limit, access, gran); +} + +void configure_gdt_entry(gdt_entry_t *dest_entry, unsigned long base, unsigned long limit, + unsigned char access, unsigned char gran) { /* Setup the descriptor base address */ - gdt[num].base_low = (base & 0xFFFF); - gdt[num].base_middle = (base >> 16) & 0xFF; - gdt[num].base_high = (base >> 24) & 0xFF; + dest_entry->base_low = (base & 0xFFFF); + dest_entry->base_middle = (base >> 16) & 0xFF; + dest_entry->base_high = (base >> 24) & 0xFF; /* Setup the descriptor limits */ - gdt[num].limit_low = (limit & 0xFFFF); - gdt[num].granularity = ((limit >> 16) & 0x0F); + dest_entry->limit_low = (limit & 0xFFFF); + dest_entry->granularity = ((limit >> 16) & 0x0F); /* Finally, set up the granularity and access flags */ - gdt[num].granularity |= (gran & 0xF0); - gdt[num].access = access; + dest_entry->granularity |= (gran & 0xF0); + dest_entry->access = access; } /*