diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index 0f0ee985..29033d0e 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -327,18 +327,23 @@ void smp_start(uint32_t id) } #endif -static unsigned int* search_apic(unsigned int base, unsigned int limit) { - uint32_t* ptr; +#if 1 +static apic_mp_t* search_apic(size_t base, size_t limit) { + size_t ptr; + apic_mp_t* tmp; - for (ptr = (uint32_t*) base; (uint32_t) ptr < limit; ptr++) { - if (*ptr == MP_FLT_SIGNATURE) { - if (!(((apic_mp_t*)ptr)->version > 4) && ((apic_mp_t*)ptr)->features[0]) - return ptr; - } + for (ptr=base; ptr<=limit-sizeof(uint32_t); ptr++) { + tmp = (apic_mp_t*) ptr; + + if (tmp->signature == MP_FLT_SIGNATURE) { + if (!((tmp->version > 4) || tmp->features[0])) + return tmp; } + } return NULL; } +#endif #if MAX_CORES > 1 int smp_init(void) @@ -362,7 +367,7 @@ int smp_init(void) */ bootaddr = (char*) SMP_SETUP_ADDR; memcpy(bootaddr, boot_code, sizeof(boot_code)); - for(j=0; jflags & MULTIBOOT_INFO_MEM_MAP)) { multiboot_memory_map_t* mmap = (multiboot_memory_map_t*) mb_info->mmap_addr; multiboot_memory_map_t* mmap_end = (void*) ((size_t) mb_info->mmap_addr + mb_info->mmap_length); @@ -576,10 +581,19 @@ static int apic_probe(void) if (mmap->type == MULTIBOOT_MEMORY_RESERVED) { addr = mmap->addr; - for(i=0; ilen-sizeof(uint32_t); i++, addr++) { + /* + * MultiProcessor Specification 1.4: + * ================================= + * The following is a list of the suggested memory spaces for the MP configuration table: + * a. In the first kilobyte of Extended BIOS Data Area (EBDA), or + * b. Within the last kilobyte of system base memory if the EBDA segment is undefined, or + * c. At the top of system physical memory, or + * d. In the BIOS read-only memory space between 0E0000h and 0FFFFFh. + */ + for(i=0; (ilen-sizeof(uint32_t)) && (addr < 0x0FFFFF); i++, addr++) { if (*((uint32_t*) addr) == MP_FLT_SIGNATURE) { apic_mp = (apic_mp_t*) addr; - if (!(apic_mp->version > 4) && apic_mp->features[0]) + if (!((apic_mp->version > 4) || apic_mp->features[0])) goto found_mp; } } @@ -593,6 +607,7 @@ found_mp: if (!apic_mp) goto no_mp; + kprintf("Found MP config table at 0x%x\n", apic_mp); kprintf("System uses Multiprocessing Specification 1.%u\n", apic_mp->version); kprintf("MP features 1: %u\n", apic_mp->features[0]); diff --git a/arch/x86/kernel/entry.asm b/arch/x86/kernel/entry.asm index e2e2d84a..8fd0e8c3 100644 --- a/arch/x86/kernel/entry.asm +++ b/arch/x86/kernel/entry.asm @@ -440,10 +440,10 @@ extern syscall_handler ; used to realize system calls isrsyscall: - ;push ds - ;push fs - ;push gs - ;push es + push ds + push fs + push gs + push es push ebp push edi push esi @@ -460,10 +460,10 @@ isrsyscall: pop esi pop edi pop ebp - ;pop es - ;pop gs - ;pop fs - ;pop ds + pop es + pop gs + pop fs + pop ds iret global irq0