simplify the APIC and GDT code

This commit is contained in:
Stefan Lankes 2012-06-10 23:40:22 +02:00
parent f5f6163589
commit 1e275732c5
5 changed files with 13 additions and 21 deletions

View file

@ -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
*

View file

@ -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;

View file

@ -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;
}

View file

@ -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();

View file

@ -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();