Kaynağa Gözat

[libcpu/aarch64] 修改V2P的方式;

wangxiaoyao 3 yıl önce
ebeveyn
işleme
14b7271791

+ 21 - 0
libcpu/aarch64/common/cpu_ops_common.h

@@ -0,0 +1,21 @@
+#ifndef __CPU_OPS_COMMON_H__
+#define __CPU_OPS_COMMON_H__
+
+#include <rthw.h>
+#include <rtthread.h>
+#include <mmu.h>
+#include "entry_point.h"
+
+static inline rt_uint64_t get_secondary_entry_pa(void)
+{
+    rt_uint64_t secondary_entry_pa = (rt_uint64_t)rt_hw_mmu_v2p(&mmu_info, _secondary_cpu_entry);
+
+    if (!secondary_entry_pa)
+    {
+        LOG_E("Failed to translate 'secondary_entry_pa' to physical address");
+        return -1;
+    }
+    return secondary_entry_pa;
+}
+
+#endif /* __CPU_OPS_COMMON_H__ */

+ 2 - 2
libcpu/aarch64/common/cpu_psci.c

@@ -13,12 +13,12 @@
 #define DBG_TAG "libcpu.aarch64.cpu_psci"
 #define DBG_LVL DBG_INFO
 #include <rtdbg.h>
+#include "cpu_ops_common.h"
 
 #include "cpu.h"
 #include "errno.h"
 #include "psci.h"
 #include "psci_api.h"
-#include "entry_point.h"
 
 static int (*_psci_init)(void) = psci_init;
 
@@ -41,7 +41,7 @@ static int cpu_psci_cpu_init(rt_uint32_t cpuid)
 
 static int cpu_psci_cpu_boot(rt_uint32_t cpuid)
 {
-    rt_uint64_t secondary_entry_pa = (rt_uint64_t)_secondary_cpu_entry + PV_OFFSET;
+    rt_uint64_t secondary_entry_pa = get_secondary_entry_pa();
     if (!psci_ops.cpu_on) {
         LOG_E("Uninitialized psci operation");
         return -1;

+ 2 - 2
libcpu/aarch64/common/cpu_spin_table.c

@@ -14,10 +14,10 @@
 #define DBG_TAG "libcpu.aarch64.cpu_spin_table"
 #define DBG_LVL DBG_INFO
 #include <rtdbg.h>
+#include "cpu_ops_common.h"
 
 #ifdef RT_USING_FDT
 #include <dtb_node.h>
-#include "entry_point.h"
 
 static rt_uint64_t cpu_release_addr[RT_CPUS_NR];
 
@@ -37,7 +37,7 @@ static int spin_table_cpu_init(rt_uint32_t cpuid)
 
 static int spin_table_cpu_boot(rt_uint32_t cpuid)
 {
-    rt_uint64_t secondary_entry_pa = (rt_uint64_t)_secondary_cpu_entry + PV_OFFSET;
+    rt_uint64_t secondary_entry_pa = get_secondary_entry_pa();
     // map release_addr to addressable place
     void *rel_va = rt_ioremap((void *)cpu_release_addr[cpuid], sizeof(cpu_release_addr[0]));