diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index 0f0ee985..a916222c 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -327,18 +327,20 @@ void smp_start(uint32_t id) } #endif -static unsigned int* search_apic(unsigned int base, unsigned int limit) { - uint32_t* ptr; +#ifndef CONFIG_MULTIBOOT +static apic_mp_t* search_apic(size_t base, size_t limit) { + size_t ptr; - for (ptr = (uint32_t*) base; (uint32_t) ptr < limit; ptr++) { - if (*ptr == MP_FLT_SIGNATURE) { + for (ptr=base; ptr<=limit-sizeof(uint32_t); ptr++) { + if (*((uint32_t*) ptr) == MP_FLT_SIGNATURE) { if (!(((apic_mp_t*)ptr)->version > 4) && ((apic_mp_t*)ptr)->features[0]) - return ptr; - } + return (apic_mp_t*) ptr; } + } return NULL; } +#endif #if MAX_CORES > 1 int smp_init(void) @@ -362,7 +364,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,7 +578,16 @@ 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]) @@ -593,6 +604,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]);