Update of /cvsroot/trion/trion v0.2/loader In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv2298 Modified Files: console.cpp console.hpp entry.asm heap_manager.cpp heap_manager.hpp main.cpp mp_detect.cpp mp_detect.hpp Removed Files: pmode.asm Log Message: no message Index: main.cpp =================================================================== RCS file: /cvsroot/trion/trion v0.2/loader/main.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** main.cpp 2 Jun 2006 21:11:21 -0000 1.18 --- main.cpp 24 Jun 2006 15:01:32 -0000 1.19 *************** *** 38,71 **** // ----------------------------------------------------------------------- ! #include "../object/std_types.hpp" ! #include "console.hpp" ! ! #include "heap_manager.hpp" ! #include "mp_detect.hpp" ! ! #include "../hal/hal_object.hpp" ! #include "../hal/cpu_info.hpp" ! #include "../hal/mmu.hpp" ! #include "../hal/idt.hpp" ! #include "../hal/exception.hpp" ! #include "../hal/apic_local.hpp" ! #include "../hal/timer.hpp" ! #include "../hal/irq.hpp" ! #include "../hal/ipi.hpp" ! #include "../hal/systemcall.hpp" ! #include "../hal/task_context.hpp" ! hal_object* boot_hal; ! extern "C" void user_main() { ! asm("mov %ss, %eax\n" ! "mov %eax, %ds\n" ! "mov %eax, %es\n" ! "mov %eax, %fs\n" ! "mov %eax, %gs\n" ! ); // Print a red 'A' in the upper-left corner of the screen --- 38,66 ---- // ----------------------------------------------------------------------- ! #include <std_types.hpp> ! #include <console.hpp> ! #include <heap_manager.hpp> ! #include <mp_detect.hpp> ! #include <hal_object.hpp> ! #include <mmu.hpp> ! #include <idt.hpp> ! #include <exception.hpp> ! #include <apic_local.hpp> ! #include <timer.hpp> ! #include <irq.hpp> ! #include <ipi.hpp> ! #include <cpu_info.hpp> ! #include <gdt.hpp> ! #include <ports.hpp> ! #include <systemcall.hpp> ! #include <task_context.hpp> ! extern "C" u32b user_main() { ! asm("mov %ss, %eax\n" "mov %eax, %ds\n" "mov %eax, %es\n" ! "mov %eax, %fs\n" "mov %eax, %gs\n"); // Print a red 'A' in the upper-left corner of the screen *************** *** 85,94 **** vidmem[(160+78)*2 + 1] = 4; ! while(true); // Wait for IRQs } ! extern "C" int main(uint image_size, uint processor, uint magic, void* grub) { ! uint number_processors; if(processor == 0) --- 80,96 ---- vidmem[(160+78)*2 + 1] = 4; ! // Try accessing some I/O ports by moving the x86 hardware cursor ! asm("mov $0x0f, %al\n" "mov $0x3d4, %dx\n" "out %al, %dx\n"); ! asm("mov $0x9e, %al\n" "mov $0x3d5, %dx\n" "out %al, %dx\n"); ! ! asm("mov $0x0e, %al\n" "mov $0x3d4, %dx\n" "out %al, %dx\n"); ! asm("mov $0x00, %al\n" "mov $0x3d5, %dx\n" "out %al, %dx\n"); ! ! while(true); // Waiting for IRQs } ! extern "C" int main(u32b image_size, u32b processor, u32b magic, void* grub) { ! static u32b number_processors; if(processor == 0) *************** *** 96,106 **** number_processors = 1; ! // Create the global heap-manager class object ! new (heap_manager_reserved) heap_manager(); ! new (cpu_info_reserved) cpu_info(); ! // Spawn an instance of the mmu class ! hal_object* hal = boot_hal = heap().CreateHalObject(processor); ! hal->memory = new (heap().AllocateMemory(sizeof(mmu))) mmu(0xE0000000 + image_size); // Create a console object to be able to print debug messages --- 98,112 ---- number_processors = 1; ! // Create the global heap-manager object ! new (virt_allocator_reserved) memory_stack(0xE0000000 + image_size + 0x2000); ! new (phys_allocator_reserved) memory_stack(0x00100000 + image_size + 0x5000); ! new (heap_manager_reserved) heap_manager(0xE0000000 + image_size + 0x1000); ! // Create a new hal-object instance ! heap().CreateHalObject(processor); ! hal_object& hal = get_hal_object(); ! ! // Spawn an instance of the memory-mapper class ! hal.set_memory(heap().CreateObject<memory_mapper>(0x00100000 + image_size)); // Create a console object to be able to print debug messages *************** *** 111,132 **** // Enable the IDT and activate exception handling ! hal->vector = new (heap().AllocateMemory(sizeof(idt))) idt(); ! hal->faults = new (heap().AllocateMemory(sizeof(exception))) exception(); // Initialize the local APIC and enable all I/O APICs mp_detect* multi = new (mp_detect_reserved) mp_detect(); ! hal->lapic = new (heap().AllocateMemory(sizeof(local_apic))) local_apic(); ! hal->clock = new (heap().AllocateMemory(sizeof(timer))) timer(); ! hal->inter = new (heap().AllocateMemory(sizeof(ipi))) ipi(); new (irq_logic_reserved) irq_logic(); // Prepare everything for user-mode ! hal->context = new (heap().AllocateMemory(sizeof(task_context))) task_context(); ! hal->syscall = new (heap().AllocateMemory(sizeof(systemcall))) systemcall(); // Enable hyperthreading and try to boot all application processors ! number_processors += multi->EnableHyperthreading(); ! number_processors += multi->BootAllProcessors(); cout() << endl << "All " << number_processors << " processors have been booted" << endl; --- 117,142 ---- // Enable the IDT and activate exception handling ! hal.set_idt(heap().CreateObject<idt_table>()); ! hal.set_exceptions(heap().CreateObject<exception>()); // Initialize the local APIC and enable all I/O APICs mp_detect* multi = new (mp_detect_reserved) mp_detect(); ! ! hal.set_info(heap().CreateObject<cpu_info>()); ! hal.set_lapic(heap().CreateObject<local_apic>()); ! hal.set_timer(heap().CreateObject<apic_timer>()); ! hal.set_ipi(heap().CreateObject<cpu_messages>()); new (irq_logic_reserved) irq_logic(); // Prepare everything for user-mode ! hal.set_gdt(heap().CreateObject<gdt_table>()); ! hal.set_context(heap().CreateObject<task_context>()); ! hal.set_syscall(heap().CreateObject<systemcall>()); ! hal.set_port(heap().CreateObject<port_protect>()); // Enable hyperthreading and try to boot all application processors ! multi->EnableHyperthreading(); ! multi->BootAllProcessors(); cout() << endl << "All " << number_processors << " processors have been booted" << endl; *************** *** 136,171 **** // Install a small user-task for testing purposes ! hal->memory->CreatePageTable(0x00000000, 0x8000, mmu::USER_MODE | mmu::READ_WRITE); ! hal->memory->MapPage((void*)0x00000000, 0x100000, mmu::USER_MODE | mmu::READ_WRITE); // user-mode code ! hal->memory->MapPage((void*)0x00001000, 0x10000, mmu::USER_MODE | mmu::READ_WRITE); // stack space ! hal->memory->MapPage((void*)0x00002000, 0xB8000, mmu::USER_MODE | mmu::READ_WRITE); // video memory ! uint task_entry = (uint)&user_main - 0xE0000000; // Switch to the user-mode code ! hal->syscall->InvokeUserTask(task_entry, 0x2000); } else { ap_flag |= 1; // Indicates that the processor has been booted ! cout() << "An application processor was booted (# "<< processor << ")" << endl; // Spawn an instance of all hal classes.. ! hal_object* hal = boot_hal = heap().CreateHalObject(processor); ! hal->memory = new (heap().AllocateMemory(sizeof(mmu))) mmu(0xE0000000 + image_size); ! hal->vector = new (heap().AllocateMemory(sizeof(idt))) idt(); ! hal->faults = new (heap().AllocateMemory(sizeof(exception))) exception(); ! hal->lapic = new (heap().AllocateMemory(sizeof(local_apic))) local_apic(); ! hal->clock = new (heap().AllocateMemory(sizeof(timer))) timer(); ! hal->inter = new (heap().AllocateMemory(sizeof(ipi))) ipi(); ! number_processors += multiprocessor().EnableHyperthreading(); ap_flag |= 2; // Indicates that the hal is fully initialized, next AP may get started - asm("sti"); while(true) asm("hlt"); } --- 146,191 ---- // Install a small user-task for testing purposes ! hal(memory)[0] = memory_mapper::user_mode(0x8000); // Create a new page-table ! hal(memory)[0][0] = memory_mapper::user_mode(0x100000); // User Code ! hal(memory)[0][1] = memory_mapper::user_mode(0x10000); // Stack Space ! hal(memory)[0][2] = memory_mapper::user_mode(0xB8000); // Video Memory ! u32b task_entry = (u32b)&user_main - 0xE0000000; ! ! // Create a port bitmap for the task and enable the required ports ! hal(port).EnablePort<u08b>(0x3d4); ! hal(port).EnablePort<u08b>(0x3d5); ! ! hal(context).SetPortMap(hal(port).GetPortMap()); // Switch to the user-mode code ! hal(syscall).InvokeUserTask(task_entry, 0x2000); } else { ap_flag |= 1; // Indicates that the processor has been booted ! ! number_processors++; // Spawn an instance of all hal classes.. ! heap().CreateHalObject(processor); ! hal_object& hal = get_hal_object(); ! hal.set_memory(heap().CreateObject<memory_mapper>(0x00100000 + image_size)); ! hal.set_idt(heap().CreateObject<idt_table>()); ! hal.set_exceptions(heap().CreateObject<exception>()); ! hal.set_lapic(heap().CreateObject<local_apic>()); ! hal.set_timer(heap().CreateObject<apic_timer>()); ! hal.set_ipi(heap().CreateObject<cpu_messages>()); ! hal.set_gdt(heap().CreateObject<gdt_table>()); ! hal.set_context(heap().CreateObject<task_context>()); ! hal.set_syscall(heap().CreateObject<systemcall>()); ! hal.set_port(heap().CreateObject<port_protect>()); ap_flag |= 2; // Indicates that the hal is fully initialized, next AP may get started while(true) asm("hlt"); } --- pmode.asm DELETED --- Index: mp_detect.hpp =================================================================== RCS file: /cvsroot/trion/trion v0.2/loader/mp_detect.hpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** mp_detect.hpp 22 May 2006 15:19:08 -0000 1.10 --- mp_detect.hpp 24 Jun 2006 15:01:32 -0000 1.11 *************** *** 41,56 **** #define __LOADER__MP_DETECT__ ! #include "../object/std_types.hpp" ! #include "../hal/hal_object.hpp" ! #include "heap_manager.hpp" struct SmpFloatingPointer { ! unsigned long Magic; ! unsigned long Table; ! unsigned char Length; ! unsigned char Version; ! unsigned char Checksum; ! unsigned char Feature[5]; }__attribute__ ((__packed__)); --- 41,56 ---- #define __LOADER__MP_DETECT__ ! #include <std_types.hpp> ! #include <heap_manager.hpp> ! #include <hal_object.hpp> struct SmpFloatingPointer { ! u32b Magic; ! u32b Table; ! u08b Length; ! u08b Version; ! u08b Checksum; ! u08b Feature[5]; }__attribute__ ((__packed__)); *************** *** 58,74 **** struct SmpConfigTable { ! unsigned long Magic; ! unsigned short BaseLength; ! unsigned char Version; ! unsigned char Checksum; ! unsigned char OemString[8]; ! unsigned char ProductString[12]; ! unsigned long OemTable; ! unsigned short OemLength; ! unsigned short EntryCount; ! unsigned long LocalApic; ! unsigned short ExtendedLength; ! unsigned char ExtendedChecksum; ! unsigned char Reserved; }__attribute__ ((__packed__)); --- 58,74 ---- struct SmpConfigTable { ! u32b Magic; ! u16b BaseLength; ! u08b Version; ! u08b Checksum; ! u08b OemString[8]; ! u08b ProductString[12]; ! u32b OemTable; ! u16b OemLength; ! u16b EntryCount; ! u32b LocalApic; ! u16b ExtendedLength; ! u08b ExtendedChecksum; ! u08b Reserved; }__attribute__ ((__packed__)); *************** *** 76,80 **** struct SmpConfigEntry { ! unsigned char Type; }__attribute__((__packed__)); --- 76,80 ---- struct SmpConfigEntry { ! u08b Type; }__attribute__((__packed__)); *************** *** 82,91 **** struct SmpConfigCPU : SmpConfigEntry { ! unsigned char LocalApicID; ! unsigned char LocalApicVersion; ! unsigned char Flags; ! unsigned long Signature; ! unsigned long Features; ! unsigned long Reserved[2]; }__attribute__ ((packed)); --- 82,91 ---- struct SmpConfigCPU : SmpConfigEntry { ! u08b LocalApicID; ! u08b LocalApicVersion; ! u08b Flags; ! u32b Signature; ! u32b Features; ! u32b Reserved[2]; }__attribute__ ((packed)); *************** *** 93,98 **** struct SmpConfigBus : SmpConfigEntry { ! unsigned char BusID; ! unsigned char TypeString[6]; } __attribute__ ((packed)); --- 93,98 ---- struct SmpConfigBus : SmpConfigEntry { ! u08b BusID; ! char TypeString[6]; } __attribute__ ((packed)); *************** *** 100,107 **** struct SmpConfigIOApic : SmpConfigEntry { ! unsigned char ApicID; ! unsigned char ApicVersion; ! unsigned char Flags; ! unsigned long BaseAddr; }__attribute__ ((packed)); --- 100,107 ---- struct SmpConfigIOApic : SmpConfigEntry { ! u08b ApicID; ! u08b ApicVersion; ! u08b Flags; ! u32b BaseAddr; }__attribute__ ((packed)); *************** *** 109,118 **** struct SmpConfigInterrupt : SmpConfigEntry { ! unsigned char IntType; ! unsigned short Flags; ! unsigned char SourceID; ! unsigned char SourceIRQ; ! unsigned char DestID; ! unsigned char DestIRQ; }__attribute__ ((packed)); --- 109,118 ---- struct SmpConfigInterrupt : SmpConfigEntry { ! u08b IntType; ! u16b Flags; ! u08b SourceID; ! u08b SourceIRQ; ! u08b DestID; ! u08b DestIRQ; }__attribute__ ((packed)); *************** *** 132,136 **** private: ! uint entry, last_entry; SmpConfigEntry* address; --- 132,136 ---- private: ! u16b entry, last_entry; SmpConfigEntry* address; *************** *** 145,149 **** bool operator!=(iterator it); ! iterator operator++(int t); SmpConfigEntry* operator*(); --- 145,150 ---- bool operator!=(iterator it); ! iterator& operator++(); ! iterator operator++(int t); SmpConfigEntry* operator*(); *************** *** 154,168 **** private: SmpConfigEntry* config_table; ! uint entry_count, apic_address; vRange* window; ! void RelocateEntrypoint(uint relocation_address); ! uint GetCMOSValue(uint address); ! uint DetectFloatingPointer(uint start_address, uint length); bool CheckBootstrap(iterator cpu); bool CheckDisabled (iterator cpu); ! uint GetLocalApicID(iterator cpu); public: --- 155,170 ---- private: SmpConfigEntry* config_table; ! u32b entry_count, apic_address; vRange* window; ! void RelocateEntrypoint(u32b relocation_address); ! u16b GetCMOSValue(u32b address); ! ! u32b DetectFloatingPointer(u32b start_address, u32b length); bool CheckBootstrap(iterator cpu); bool CheckDisabled (iterator cpu); ! u08b GetLocalApicID(iterator cpu); public: *************** *** 173,182 **** iterator end(); - uint GetNumberEntries(entry_type type); - bool BootProcessor(iterator cpu); - uint BootAllProcessors(); ! uint EnableHyperthreading(); }; --- 175,184 ---- iterator end(); bool BootProcessor(iterator cpu); ! u08b BootAllProcessors(); ! u08b EnableHyperthreading(); ! ! u08b GetNumberEntries(entry_type type); }; *************** *** 184,188 **** mp_detect& multiprocessor(); ! extern volatile uint ap_flag; #endif --- 186,190 ---- mp_detect& multiprocessor(); ! extern volatile u32b ap_flag; #endif Index: mp_detect.cpp =================================================================== RCS file: /cvsroot/trion/trion v0.2/loader/mp_detect.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** mp_detect.cpp 22 May 2006 15:19:08 -0000 1.12 --- mp_detect.cpp 24 Jun 2006 15:01:32 -0000 1.13 *************** *** 38,59 **** // ----------------------------------------------------------------------- ! #include "mp_detect.hpp" ! #include "console.hpp" ! #include "../hal/timer.hpp" ! #include "../hal/ipi.hpp" ! #include "../hal/cpu_info.hpp" ! extern "C" unsigned char ap_code_start[]; ! extern "C" unsigned char ap_code_end[]; ! volatile uint ap_flag; mp_detect::mp_detect() { // Get possible locations of the multiprocessor floating pointer from the CMOS ! uint ebda = GetCMOSValue(0x40E) << 4; ! uint lastK = GetCMOSValue(0x413) << 10; ! uint bios = 0x000F0000; // Relocate the entrypoint to a lower address so that it can be reached from real-mode --- 38,60 ---- // ----------------------------------------------------------------------- ! #include <mp_detect.hpp> ! #include <console.hpp> ! #include <hal_object.hpp> ! #include <cpu_info.hpp> ! #include <timer.hpp> ! #include <ipi.hpp> ! extern "C" u32b ap_code_start[]; ! extern "C" u32b ap_code_end[]; ! volatile u32b ap_flag; mp_detect::mp_detect() { // Get possible locations of the multiprocessor floating pointer from the CMOS ! u32b ebda = GetCMOSValue(0x40E) << 4; ! u32b lastK = GetCMOSValue(0x413) << 10; ! u32b bios = 0x000F0000; // Relocate the entrypoint to a lower address so that it can be reached from real-mode *************** *** 61,66 **** // Search for the multiprocessor floating pointer ! uint table(0); ! uint address = (ebda) ? ebda : lastK; table = DetectFloatingPointer(address, 0x400); --- 62,67 ---- // Search for the multiprocessor floating pointer ! u32b table(0); ! u32b address = (ebda) ? ebda : lastK; table = DetectFloatingPointer(address, 0x400); *************** *** 69,73 **** if(table && !config_table) { ! cout() << "Standard multiprocessor configuration " << reinterpret_cast<uint>(table) << endl; cout() << " will be used" << endl << endl; --- 70,74 ---- if(table && !config_table) { ! cout() << "Standard multiprocessor configuration " << reinterpret_cast<u32b>(table) << endl; cout() << " will be used" << endl << endl; *************** *** 79,92 **** { cout() << "A multiprocessor configuration table was detected "; ! cout() << "at address " << reinterpret_cast<uint>(table) << endl << endl; ! uint table_base = reinterpret_cast<uint>(table) &0xFFFFF000; ! uint table_offset = reinterpret_cast<uint>(table) &0x00000FFF; ! // Map the configuration table statically in ! window = new (heap().AllocateMemory(sizeof(vRange))) vRange(table_base); ! uint virt_address = reinterpret_cast<uint>(window->GetVirtualBase()); ! // Gather the neccessary information from the config table SmpConfigTable* vtable = reinterpret_cast<SmpConfigTable*>(virt_address + table_offset); entry_count = vtable->EntryCount; --- 80,93 ---- { cout() << "A multiprocessor configuration table was detected "; ! cout() << "at address " << reinterpret_cast<u32b>(table) << endl << endl; ! u32b table_base = reinterpret_cast<u32b>(table) &0xFFFFF000; ! u32b table_offset = reinterpret_cast<u32b>(table) &0x00000FFF; ! // Map the configuration table statically ! window = heap().CreateObject<vRange>(table_base); ! u32b virt_address = reinterpret_cast<u32b>(window->GetVirtualBase()); ! // Gather the neccessary information from the configuration table SmpConfigTable* vtable = reinterpret_cast<SmpConfigTable*>(virt_address + table_offset); entry_count = vtable->EntryCount; *************** *** 109,162 **** } ! void mp_detect::RelocateEntrypoint(uint relocation_address) { vRange virt_range(relocation_address); ! uint virt_address = reinterpret_cast<uint>(virt_range.GetVirtualBase()); ! for(uint i = 0; i < (uint)ap_code_end - (uint)ap_code_start; i++) ! ((uchar*)virt_address)[i] = ap_code_start[i]; } ! uint mp_detect::GetCMOSValue(uint address) { vRange virt_range(0); ! uint virt_address = reinterpret_cast<uint>(virt_range.GetVirtualBase()); ! return *(reinterpret_cast<ushort*>(virt_address + address)); } ! uint mp_detect::DetectFloatingPointer(uint start_address, uint length) { ! uint pbase = start_address &0xFFFFF000; ! uint offset = start_address &0xFFF; ! uint pages = (length + offset + 0xFFF)/4096; ! for(uint i=0; i<pages; i++) { vRange virt_range(pbase + i*4096); ! ulong* vpage = static_cast<ulong*>(virt_range.GetVirtualBase()); ! for(int j=0; j<1024; j+=4) { ! if(vpage[j] == '_PM_') { // Calculate the checksume of the structure ! uchar checksum = 0x00000000; ! uchar* mp_float = reinterpret_cast<uchar*>(&vpage[j]); ! for(int k=0; k<16; k++) checksum += mp_float[k]; if(checksum == 0) { ! if(vpage[j+1]) // Return a pointer to the configuration table if available { ! config_table = reinterpret_cast<SmpConfigEntry*>(vpage[j+1]); ! return vpage[j+1]; } ! else // Return the number of the standard configuration used { config_table = 0; ! return vpage[j+3] &0xFF; } } --- 110,168 ---- } ! void mp_detect::RelocateEntrypoint(u32b relocation_address) { vRange virt_range(relocation_address); ! u32b* virt_address = static_cast<u32b*>(virt_range.GetVirtualBase()); ! u16b length = reinterpret_cast<u32b>(ap_code_end) - reinterpret_cast<u32b>(ap_code_start); ! memcopy(ap_code_start, &ap_code_start[length], virt_address); } ! u16b mp_detect::GetCMOSValue(u32b address) { vRange virt_range(0); ! u32b virt_address = reinterpret_cast<u32b>(virt_range.GetVirtualBase()); ! return *reinterpret_cast<u16b*>(virt_address + address); } ! u32b mp_detect::DetectFloatingPointer(u32b start_address, u32b length) { ! u32b pbase = start_address &0xFFFFF000; ! u32b offset = start_address &0xFFF; ! u16b pages = (length + offset + 0xFFF)/4096; ! ! for(u16b i=0; i<pages; i++) { vRange virt_range(pbase + i*4096); ! u32b* vpage = static_cast<u32b*>(virt_range.GetVirtualBase()); ! for(u16b j=0; j<1024; j+=4) { ! SmpFloatingPointer* fp = reinterpret_cast<SmpFloatingPointer*>(&vpage[j]); ! ! if(fp->Magic == '_PM_') { // Calculate the checksume of the structure ! u08b checksum = 0x00; ! u08b* mp_float = reinterpret_cast<u08b*>(fp); ! for(u08b k=0; k<16; k++) checksum += mp_float[k]; if(checksum == 0) { ! if(fp->Table) { ! // Return a pointer to the configuration table if available ! config_table = reinterpret_cast<SmpConfigEntry*>(fp->Table); ! return fp->Table; } ! else { + // Return the number of the standard configuration used config_table = 0; ! return fp->Feature[0]; } } *************** *** 174,178 **** iterator it; it.address = config_table; ! it.entry = 0; it.last_entry = entry_count - 1; --- 180,184 ---- iterator it; it.address = config_table; ! it.entry = 0; it.last_entry = entry_count - 1; *************** *** 199,210 **** } ! uint mp_detect::GetNumberEntries(entry_type type) { ! uint counter = 0; ! ! for(iterator it = begin(type); it != end(); it++) ! { ! counter++; ! } return counter; } --- 205,212 ---- } ! u08b mp_detect::GetNumberEntries(entry_type type) { ! u08b counter = 0; ! for(iterator it = begin(type); it != end(); ++it) counter++; return counter; } *************** *** 220,224 **** } ! uint mp_detect::GetLocalApicID(iterator cpu) { return (static_cast<SmpConfigCPU*>(*cpu)->LocalApicID); --- 222,226 ---- } ! u08b mp_detect::GetLocalApicID(iterator cpu) { return (static_cast<SmpConfigCPU*>(*cpu)->LocalApicID); *************** *** 227,243 **** bool mp_detect::BootProcessor(iterator cpu) { ! heap().AllocateApStack(); ap_flag = 0; ! uint apic_id = GetLocalApicID(cpu); ! boot_hal->inter->SendInitIPI (apic_id); ! boot_hal->inter->SendStartupIPI(apic_id); ! boot_hal->inter->SendStartupIPI(apic_id); ! boot_hal->clock->SetTimer(timer_id(current), 0x1000000); // Check if the processor responds - if so, wait until it finished booting ! while(boot_hal->clock->GetTimer(timer_id(current)) > 0 && !(ap_flag &1)); while(ap_flag &1 && !(ap_flag &2)); --- 229,247 ---- bool mp_detect::BootProcessor(iterator cpu) { ! heap().AllocateMpStack(); ap_flag = 0; ! hal_object& hal = get_hal_object(); ! u08b apic_id = GetLocalApicID(cpu); ! // Start the INIT-SIPI-SIPI sequence ! hal(ipi).SendInitIPI(apic_id); ! hal(ipi).SendStartupIPI(apic_id); ! // hal(ipi).SendStartupIPI(apic_id); NOTE Caused problems on bochs when AP halts immediately ! hal(timer).SetTimer(timer_id(current), 0x1000000); // Check if the processor responds - if so, wait until it finished booting ! while(hal(timer).GetTimer(timer_id(current)) > 0 && !(ap_flag &1)); while(ap_flag &1 && !(ap_flag &2)); *************** *** 245,269 **** } ! uint mp_detect::BootAllProcessors() { ! bool result = true; ! uint num_cpu = 0; ! for(iterator entry = begin(TYPE_CPU); entry != end(); entry++) { if(!CheckBootstrap(entry) && !CheckDisabled(entry)) { ! result &= BootProcessor(entry); num_cpu++; } } ! return (result) ? num_cpu : 0; } ! uint mp_detect::EnableHyperthreading() { ! uint processors = 0; ! if(info().GetProcessorInfo().hyper_threading) { // On hyperthreading CPUs the APIC ID is split into two parts: package ID and logical ID --- 249,272 ---- } ! u08b mp_detect::BootAllProcessors() { ! u08b num_cpu = 0; ! for(iterator entry = begin(TYPE_CPU); entry != end(); ++entry) { if(!CheckBootstrap(entry) && !CheckDisabled(entry)) { ! BootProcessor(entry); num_cpu++; } } ! return num_cpu; } ! u08b mp_detect::EnableHyperthreading() { ! u08b processors = 0; ! if(get_hal_object()(info).GetProcessorInfo().hyper_threading) { // On hyperthreading CPUs the APIC ID is split into two parts: package ID and logical ID *************** *** 271,299 **** // the number of logical processors per physical package: log2(logical_per_package) // Get the number of logical processors per physical CPU ! uint number_logical = ((info().cpuid<cpu_info::EBX>(1) >> 16) &0xff); ! uint current_logical = boot_hal->lapic->GetPhysicalID() &(number_logical-1); if(current_logical++ == 0) // Primary CPU is always booted first { ! for(uint i = current_logical; i < number_logical; i++) { // Cyle through the logical processors and send an SIPI-SIPI_INIT sequence to each of them ! heap().AllocateApStack(); ap_flag = 0; ! uint apic_id = (boot_hal->lapic->GetPhysicalID() &(0xffffffff - (number_logical-1))) | i; ! boot_hal->inter->SendInitIPI (apic_id); ! boot_hal->inter->SendStartupIPI(apic_id); ! boot_hal->inter->SendStartupIPI(apic_id); ! boot_hal->clock->SetTimer(timer_id(current), 0x1000000); // Check if the processor responds - if so, wait until it finished booting ! while(boot_hal->clock->GetTimer(timer_id(current)) > 0 && !(ap_flag &1)); while(ap_flag &1 && !(ap_flag &2)); ! if(ap_flag) processors++; } } --- 274,305 ---- // the number of logical processors per physical package: log2(logical_per_package) + hal_object& hal = get_hal_object(); + // Get the number of logical processors per physical CPU ! u08b number_logical = ((get_hal_object()(info).cpuid<cpu_info::EBX>(1) >> 16) &0xff); ! u08b current_logical = hal(lapic).GetPhysicalID() &(number_logical-1); if(current_logical++ == 0) // Primary CPU is always booted first { ! for(u08b i=current_logical; i<number_logical; i++) { // Cyle through the logical processors and send an SIPI-SIPI_INIT sequence to each of them ! heap().AllocateMpStack(); ap_flag = 0; ! u08b apic_id = ... [truncated message content] |