This commit is contained in:
fslongjin 2022-04-04 18:50:58 +08:00
parent 60dc9f4932
commit 5df54732f5
3 changed files with 16 additions and 9 deletions

View File

@ -114,7 +114,7 @@ void apic_local_apic_init()
cpu_cpuid(1, 0, &a, &b, &c, &d); cpu_cpuid(1, 0, &a, &b, &c, &d);
kdebug("CPUID 0x01, eax:%#010lx, ebx:%#010lx, ecx:%#010lx, edx:%#010lx", a, b, c, d); //kdebug("CPUID 0x01, eax:%#010lx, ebx:%#010lx, ecx:%#010lx, edx:%#010lx", a, b, c, d);
// 判断是否支持APIC和xAPIC // 判断是否支持APIC和xAPIC
if ((1 << 9) & d) if ((1 << 9) & d)
@ -152,7 +152,7 @@ void apic_local_apic_init()
"rdmsr \n\t" "rdmsr \n\t"
: "=a"(eax), "=d"(edx)::"memory"); : "=a"(eax), "=d"(edx)::"memory");
kdebug("After enable xAPIC and x2APIC: edx=%#010x, eax=%#010x", edx, eax); //kdebug("After enable xAPIC and x2APIC: edx=%#010x, eax=%#010x", edx, eax);
// 检测是否成功启用xAPIC和x2APIC // 检测是否成功启用xAPIC和x2APIC
if (eax & 0xc00) if (eax & 0xc00)
@ -194,7 +194,7 @@ void apic_local_apic_init()
: :
:"memory"); :"memory");
*/ */
kdebug("After setting SVR: edx=%#010x, eax=%#010x", edx, eax); //kdebug("After setting SVR: edx=%#010x, eax=%#010x", edx, eax);
if (eax & 0x100) if (eax & 0x100)
kinfo("APIC Software Enabled."); kinfo("APIC Software Enabled.");
@ -209,8 +209,8 @@ void apic_local_apic_init()
"rdmsr \n\t" "rdmsr \n\t"
: "=a"(eax), "=d"(edx)::"memory"); : "=a"(eax), "=d"(edx)::"memory");
kdebug("get Local APIC ID: edx=%#010x, eax=%#010x", edx, eax); //kdebug("get Local APIC ID: edx=%#010x, eax=%#010x", edx, eax);
kdebug("local_apic_id=%#018lx", *(uint *)(APIC_LOCAL_APIC_VIRT_BASE_ADDR + LOCAL_APIC_OFFSET_Local_APIC_ID)); //kdebug("local_apic_id=%#018lx", *(uint *)(APIC_LOCAL_APIC_VIRT_BASE_ADDR + LOCAL_APIC_OFFSET_Local_APIC_ID));
// 获取Local APIC Version // 获取Local APIC Version
// 0x803处是 Local APIC Version register // 0x803处是 Local APIC Version register
@ -462,7 +462,7 @@ void apic_ioapic_edge_ack(ul irq_num) // 边沿触发
* @param total * @param total
* @return uint * @return uint
*/ */
uint apic_get_ics(const uint type, ul *ret_vaddr[], uint *total) uint apic_get_ics(const uint type, ul ret_vaddr[], uint *total)
{ {
void *ent = (void *)(madt) + sizeof(struct acpi_Multiple_APIC_Description_Table_t); void *ent = (void *)(madt) + sizeof(struct acpi_Multiple_APIC_Description_Table_t);
struct apic_Interrupt_Controller_Structure_header_t *header = (struct apic_Interrupt_Controller_Structure_header_t *)ent; struct apic_Interrupt_Controller_Structure_header_t *header = (struct apic_Interrupt_Controller_Structure_header_t *)ent;
@ -475,7 +475,7 @@ uint apic_get_ics(const uint type, ul *ret_vaddr[], uint *total)
header = (struct apic_Interrupt_Controller_Structure_header_t *)ent; header = (struct apic_Interrupt_Controller_Structure_header_t *)ent;
if (header->type == type) if (header->type == type)
{ {
*(ret_vaddr[cnt++]) = (ul)ent; ret_vaddr[cnt++] = (ul)ent;
flag = true; flag = true;
} }
ent += header->length; ent += header->length;

View File

@ -283,7 +283,7 @@ void apic_init();
* @param total * @param total
* @return uint * @return uint
*/ */
uint apic_get_ics(const uint type, ul *ret_vaddr[], uint * total); uint apic_get_ics(const uint type, ul ret_vaddr[], uint * total);
// =========== 中断控制操作接口 ============ // =========== 中断控制操作接口 ============
void apic_ioapic_enable(ul irq_num); void apic_ioapic_enable(ul irq_num);

View File

@ -7,7 +7,14 @@ void smp_init()
{ {
ul tmp_vaddr[MAX_SUPPORTED_PROCESSOR_NUM] = {0}; ul tmp_vaddr[MAX_SUPPORTED_PROCESSOR_NUM] = {0};
apic_get_ics(ACPI_ICS_TYPE_PROCESSOR_LOCAL_APIC, &tmp_vaddr, &total_processor_num); apic_get_ics(ACPI_ICS_TYPE_PROCESSOR_LOCAL_APIC, tmp_vaddr, &total_processor_num);
kdebug("processor num=%d", total_processor_num); kdebug("processor num=%d", total_processor_num);
for (int i = 0; i < total_processor_num; ++i)
proc_local_apic_structs[i] = (struct acpi_Processor_Local_APIC_Structure_t *)(tmp_vaddr[i]);
for (int i = 0; i < total_processor_num; ++i)
{
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]->ACPI_ID, proc_local_apic_structs[i]->flags);
}
} }