From 1e275732c5d2fa08326086a33b5df17829a90062 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 10 Jun 2012 23:40:22 +0200 Subject: [PATCH] simplify the APIC and GDT code --- arch/x86/include/asm/tasks.h | 3 +-- arch/x86/kernel/apic.c | 13 ++++++------- arch/x86/kernel/gdt.c | 10 ++-------- arch/x86/mm/page32.c | 4 ++-- arch/x86/mm/page64.c | 4 ++-- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/tasks.h b/arch/x86/include/asm/tasks.h index 6761b240..fc138802 100644 --- a/arch/x86/include/asm/tasks.h +++ b/arch/x86/include/asm/tasks.h @@ -75,12 +75,11 @@ int create_default_frame(task_t* task, entry_point_t ep, void* arg); /** @brief Register a task's TSS at GDT * - * @param task Pointer to task structure * @return * - 0 on success * - -EINVAL (-22) on failure */ -int register_task(task_t* task); +int register_task(void); /** @brief Jump back to user code * diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index 3d76c425..e0abceb3 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -289,7 +289,7 @@ extern int smp_main(void); void smp_start(uint32_t id) { - uint32_t i; + size_t i; atomic_int32_inc(&cpu_online); @@ -309,7 +309,7 @@ void smp_start(uint32_t id) idt_install(); /* enable paging */ - write_cr3((uint32_t)get_boot_pgd()); + write_cr3((size_t)get_boot_pgd()); i = read_cr0(); i = i | (1 << 31); write_cr0(i); @@ -320,9 +320,9 @@ void smp_start(uint32_t id) /* * we turned on paging - * => now, we are able to register our task for Task State Switching + * => now, we are able to register our task */ - register_task(per_core(current_task)); + register_task(); // enable additional cpu features cpu_detection(); @@ -577,16 +577,14 @@ static int apic_probe(void) uint32_t i, count; int isa_bus = -1; -#if 1 #ifdef CONFIG_X86_32 +#if 1 apic_mp = search_apic(0xF0000, 0x100000); if (apic_mp) goto found_mp; apic_mp = search_apic(0x9F000, 0xA0000); if (apic_mp) goto found_mp; -#elif defined(CONFIG_X86_64) -#endif #else // searching MP signature in the reserved memory areas if (mb_info && (mb_info->flags & MULTIBOOT_INFO_MEM_MAP)) { @@ -619,6 +617,7 @@ static int apic_probe(void) } } #endif +#endif found_mp: if (!apic_mp) goto no_mp; diff --git a/arch/x86/kernel/gdt.c b/arch/x86/kernel/gdt.c index ebd73536..9dce69ac 100644 --- a/arch/x86/kernel/gdt.c +++ b/arch/x86/kernel/gdt.c @@ -39,12 +39,6 @@ static gdt_entry_t gdt[GDT_ENTRIES] = {[0 ... GDT_ENTRIES-1] = {0, 0, 0, 0, 0, */ extern void gdt_flush(void); -/* - * This is defined in entry.asm. We use this for a - * hardware-based task switch. - */ -extern void tss_switch(uint32_t id); - size_t* get_current_stack(void) { task_t* curr_task = per_core(current_task); @@ -61,12 +55,12 @@ size_t get_stack(uint32_t id) return (size_t) kstacks[id] + KERNEL_STACK_SIZE - sizeof(size_t); } -int register_task(task_t* task) +int register_task(void) { uint16_t sel; sel = (CORE_ID+5) << 3; - asm volatile ("mov %0, %%ax; ltr %%ax" : : "ir"(sel) : "%eax"); + asm volatile ("ltr %%ax" : : "a"(sel)); return 0; } diff --git a/arch/x86/mm/page32.c b/arch/x86/mm/page32.c index e29ec26b..a63a53fc 100644 --- a/arch/x86/mm/page32.c +++ b/arch/x86/mm/page32.c @@ -820,9 +820,9 @@ int arch_paging_init(void) /* * we turned on paging - * => now, we are able to register our task for Task State Switching + * => now, we are able to register our task */ - register_task(per_core(current_task)); + register_task(); // APIC registers into the kernel address space map_apic(); diff --git a/arch/x86/mm/page64.c b/arch/x86/mm/page64.c index f9f81331..06aaeb23 100644 --- a/arch/x86/mm/page64.c +++ b/arch/x86/mm/page64.c @@ -635,9 +635,9 @@ int arch_paging_init(void) /* * we turned on paging - * => now, we are able to register our task for Task State Switching + * => now, we are able to register our task */ - register_task(per_core(current_task)); + register_task(); // APIC registers into the kernel address space map_apic();