fslongjin 2 lat temu
rodzic
commit
5df54732f5

+ 7 - 7
kernel/driver/interrupt/apic/apic.c

@@ -114,7 +114,7 @@ void apic_local_apic_init()
 
     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
     if ((1 << 9) & d)
@@ -152,7 +152,7 @@ void apic_local_apic_init()
                          "rdmsr  \n\t"
                          : "=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
     if (eax & 0xc00)
@@ -194,7 +194,7 @@ void apic_local_apic_init()
                 :
                 :"memory");
                 */
-    kdebug("After setting SVR: edx=%#010x, eax=%#010x", edx, eax);
+    //kdebug("After setting SVR: edx=%#010x, eax=%#010x", edx, eax);
 
     if (eax & 0x100)
         kinfo("APIC Software Enabled.");
@@ -209,8 +209,8 @@ void apic_local_apic_init()
                          "rdmsr  \n\t"
                          : "=a"(eax), "=d"(edx)::"memory");
 
-    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("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));
 
     // 获取Local APIC Version
     // 0x803处是 Local APIC Version register
@@ -462,7 +462,7 @@ void apic_ioapic_edge_ack(ul irq_num) // 边沿触发
  * @param total 返回数组的元素总个数
  * @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);
     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;
         if (header->type == type)
         {
-            *(ret_vaddr[cnt++]) = (ul)ent;
+            ret_vaddr[cnt++] = (ul)ent;
             flag = true;
         }
         ent += header->length;

+ 1 - 1
kernel/driver/interrupt/apic/apic.h

@@ -283,7 +283,7 @@ void apic_init();
  * @param total 返回数组的元素总个数
  * @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);

+ 8 - 1
kernel/smp/smp.c

@@ -7,7 +7,14 @@ void smp_init()
 {
     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);
+    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);
+    }
 }