mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 15:26:47 +00:00
bugfix: 修复部分机器上无法正确启动多核的问题
This commit is contained in:
parent
94fb900bb7
commit
1084edaa98
@ -208,5 +208,6 @@ void Start_Kernel(void)
|
||||
void ignore_int()
|
||||
{
|
||||
kwarn("Unknown interrupt or fault at RIP.\n");
|
||||
sti();
|
||||
}
|
||||
#pragma GCC pop_options
|
@ -52,19 +52,34 @@ void smp_init()
|
||||
ipi_send_IPI(DEST_PHYSICAL, IDLE, ICR_LEVEL_DE_ASSERT, EDGE_TRIGGER, 0x00, ICR_INIT, ICR_ALL_EXCLUDE_Self, 0x00);
|
||||
|
||||
kdebug("total_processor_num=%d", total_processor_num);
|
||||
kdebug("rflags=%#018lx", get_rflags());
|
||||
// total_processor_num = 3;
|
||||
for (int i = 1; i < total_processor_num; ++i) // i从1开始,不初始化bsp
|
||||
for (int i = 0; i < total_processor_num; ++i) // i从1开始,不初始化bsp
|
||||
{
|
||||
io_mfence();
|
||||
if (proc_local_apic_structs[i]->ACPI_Processor_UID == 0)
|
||||
--total_processor_num;
|
||||
io_mfence();
|
||||
if (proc_local_apic_structs[i]->local_apic_id > total_processor_num)
|
||||
// if (proc_local_apic_structs[i]->ACPI_Processor_UID == 0)
|
||||
// --total_processor_num;
|
||||
// io_mfence();
|
||||
// if (proc_local_apic_structs[i]->local_apic_id > total_processor_num)
|
||||
// {
|
||||
// --total_processor_num;
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// 跳过BSP
|
||||
kdebug("[core %d] acpi processor UID=%d, APIC ID=%d, flags=%#010lx", i, proc_local_apic_structs[i]->ACPI_Processor_UID, proc_local_apic_structs[i]->local_apic_id, proc_local_apic_structs[i]->flags);
|
||||
if (proc_local_apic_structs[i]->local_apic_id == 0)
|
||||
{
|
||||
--total_processor_num;
|
||||
continue;
|
||||
}
|
||||
kdebug("[core %d] acpi processor UID=%d, APIC ID=%d, flags=%#010lx", i, proc_local_apic_structs[i]->ACPI_Processor_UID, proc_local_apic_structs[i]->local_apic_id, proc_local_apic_structs[i]->flags);
|
||||
if (!((proc_local_apic_structs[i]->flags & 0x1) || (proc_local_apic_structs[i]->flags & 0x2)))
|
||||
{
|
||||
--total_processor_num;
|
||||
kdebug("processor %d cannot be enabled.", proc_local_apic_structs[i]->ACPI_Processor_UID);
|
||||
continue;
|
||||
}
|
||||
// continue;
|
||||
io_mfence();
|
||||
spin_lock(&multi_core_starting_lock);
|
||||
preempt_enable(); // 由于ap处理器的pcb与bsp的不同,因此ap处理器放锁时,bsp的自旋锁持有计数不会发生改变,需要手动恢复preempt count
|
||||
@ -91,10 +106,12 @@ void smp_init()
|
||||
set_tss64((uint *)cpu_core_info[current_starting_cpu].tss_vaddr, cpu_core_info[current_starting_cpu].stack_start, cpu_core_info[current_starting_cpu].stack_start, cpu_core_info[current_starting_cpu].stack_start,
|
||||
cpu_core_info[current_starting_cpu].ist_stack_start, cpu_core_info[current_starting_cpu].ist_stack_start, cpu_core_info[current_starting_cpu].ist_stack_start, cpu_core_info[current_starting_cpu].ist_stack_start, cpu_core_info[current_starting_cpu].ist_stack_start, cpu_core_info[current_starting_cpu].ist_stack_start, cpu_core_info[current_starting_cpu].ist_stack_start);
|
||||
io_mfence();
|
||||
kdebug("to send ipi");
|
||||
// 连续发送两次start-up IPI
|
||||
ipi_send_IPI(DEST_PHYSICAL, IDLE, ICR_LEVEL_DE_ASSERT, EDGE_TRIGGER, 0x20, ICR_Start_up, ICR_No_Shorthand, proc_local_apic_structs[i]->local_apic_id);
|
||||
io_mfence();
|
||||
ipi_send_IPI(DEST_PHYSICAL, IDLE, ICR_LEVEL_DE_ASSERT, EDGE_TRIGGER, 0x20, ICR_Start_up, ICR_No_Shorthand, proc_local_apic_structs[i]->local_apic_id);
|
||||
kdebug("send ipi ok");
|
||||
}
|
||||
io_mfence();
|
||||
while (num_cpu_started != total_processor_num)
|
||||
|
Loading…
x
Reference in New Issue
Block a user