Browse Source

[libcpu][aarch64] Fixed the rt_hw_secondary_cpu_bsp_start() bug (#8898)

* fix rt_hw_secondary_cpu_bsp_start() bug

* timer init

* comment
liYangYang 1 year ago
parent
commit
dbf8a26e6c

+ 0 - 46
bsp/qemu-virt64-aarch64/drivers/secondary_cpu.c

@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2006-2022, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date           Author       Notes
- */
-#include <rthw.h>
-#include <rtthread.h>
-#include <cpu.h>
-#include "gic.h"
-#include "interrupt.h"
-#include "mmu.h"
-#include "gtimer.h"
-
-#ifdef BSP_USING_GICV3
-#include <gicv3.h>
-#endif
-
-#ifdef RT_USING_SMP
-
-extern unsigned long MMUTable[];
-
-void rt_hw_secondary_cpu_bsp_start(void)
-{
-    rt_hw_spin_lock(&_cpus_lock);
-
-    rt_hw_mmu_ktbl_set((unsigned long)MMUTable);
-
-    // interrupt init
-    rt_hw_vector_init();
-
-    arm_gic_cpu_init(0, 0);
-
-#ifdef BSP_USING_GICV3
-    arm_gic_redist_init(0, 0);
-#endif /* BSP_USING_GICV3 */
-
-    // local timer init
-    rt_hw_gtimer_init();
-
-    rt_system_scheduler_start();
-}
-
-#endif // SMP

+ 3 - 0
libcpu/aarch64/common/SConscript

@@ -14,6 +14,9 @@ if GetDepend('RT_USING_OFW') == False:
 if GetDepend('RT_USING_PIC') == True:
     SrcRemove(src, ['gicv3.c', 'gic.c', 'gtimer.c', 'interrupt.c'])
 
+if GetDepend('RT_HWTIMER_ARM_ARCH') == True:
+    SrcRemove(src, ['gtimer.c'])
+
 group = DefineGroup('libcpu', src, depend = [''], CPPPATH = CPPPATH)
 
 # build for sub-directory

+ 17 - 2
libcpu/aarch64/common/setup.c

@@ -23,6 +23,8 @@
 #include <stdlib.h>
 #include <ioremap.h>
 #include <rtdevice.h>
+#include <gic.h>
+#include <gicv3.h>
 
 #define SIZE_KB  1024
 #define SIZE_MB (1024 * SIZE_KB)
@@ -456,10 +458,12 @@ void rt_hw_common_setup(void)
 
     /* initialize uart */
     rt_hw_uart_init();
+#endif
 
+#ifndef RT_HWTIMER_ARM_ARCH
     /* initialize timer for os tick */
     rt_hw_gtimer_init();
-#endif
+#endif /* !RT_HWTIMER_ARM_ARCH */
 
 #ifdef RT_USING_COMPONENTS_INIT
     rt_components_board_init();
@@ -540,9 +544,20 @@ rt_weak void rt_hw_secondary_cpu_bsp_start(void)
 #ifdef RT_USING_PIC
     rt_pic_irq_init();
 #else
-    rt_hw_interrupt_init();
+    /* initialize vector table */
+    rt_hw_vector_init();
+
+    arm_gic_cpu_init(0, 0);
+#ifdef BSP_USING_GICV3
+    arm_gic_redist_init(0, 0);
+#endif /* BSP_USING_GICV3 */
 #endif
 
+#ifndef RT_HWTIMER_ARM_ARCH
+    /* initialize timer for os tick */
+    rt_hw_gtimer_local_enable();
+#endif /* !RT_HWTIMER_ARM_ARCH */
+
     rt_dm_secondary_cpu_init();
 
     rt_hw_interrupt_umask(RT_SCHEDULE_IPI);