addrmap: Support on sandbox
authorSimon Glass <sjg@chromium.org>
Wed, 13 Jul 2022 12:06:58 +0000 (06:06 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 26 Jul 2022 08:30:56 +0000 (02:30 -0600)
Update this feature so that it works on sandbox, using a basic identity
mapping. This allows us to run the 'ut addrmap' test.

Also fix up the test to use the correct macros to access the linker
list, so that the 'ut addrmap' command actually works.

Signed-off-by: Simon Glass <sjg@chromium.org>
board/sandbox/sandbox.c
configs/sandbox_defconfig
include/addr_map.h
lib/addr_map.c
test/cmd/addrmap.c

index e054f300c4a5dadf7064ebf3ced81f7a3ddfaad8..ca9a2ca5b17cf1a1915f4d78b91204fe0a8d3dbc 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <addr_map.h>
 #include <cpu_func.h>
 #include <cros_ec.h>
 #include <dm.h>
@@ -155,3 +156,11 @@ int board_late_init(void)
        return 0;
 }
 #endif
+
+int init_addr_map(void)
+{
+       if (IS_ENABLED(CONFIG_ADDR_MAP))
+               addrmap_set_entry(0, 0, CONFIG_SYS_SDRAM_SIZE, 0);
+
+       return 0;
+}
index d50ce91cd1e93c0897bc984f7a776e9e4bee3564..eba7bcbb483b77e29697f7204d1bca8f80bb613a 100644 (file)
@@ -315,6 +315,7 @@ CONFIG_WDT_GPIO=y
 CONFIG_WDT_SANDBOX=y
 CONFIG_FS_CBFS=y
 CONFIG_FS_CRAMFS=y
+CONFIG_ADDR_MAP=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_ECDSA=y
 CONFIG_ECDSA_VERIFY=y
index 55d3a6a165acb9afb2f3ec7843ab9f8d7ce859c1..db3712b5d3022a8b310884fe1c5acacbb034d9d0 100644 (file)
@@ -14,7 +14,9 @@ struct addrmap {
        unsigned long vaddr;
 };
 
+#ifdef CONFIG_ADDR_MAP
 extern struct addrmap address_map[CONFIG_SYS_NUM_ADDR_MAP];
+#endif
 
 phys_addr_t addrmap_virt_to_phys(void *vaddr);
 void *addrmap_phys_to_virt(phys_addr_t paddr);
index fb2ef400078c2d18884f0a87fcdcce533db16346..9b3e0a544e478e00c4ec8cdc09ab2fce0d9dc2dc 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <addr_map.h>
+#include <mapmem.h>
 
 struct addrmap address_map[CONFIG_SYS_NUM_ADDR_MAP];
 
@@ -18,7 +19,7 @@ phys_addr_t addrmap_virt_to_phys(void * vaddr)
                if (address_map[i].size == 0)
                        continue;
 
-               addr = (u64)((u32)vaddr);
+               addr = map_to_sysmem(vaddr);
                base = (u64)(address_map[i].vaddr);
                upper = (u64)(address_map[i].size) + base - 1;
 
@@ -48,7 +49,7 @@ void *addrmap_phys_to_virt(phys_addr_t paddr)
 
                        offset = address_map[i].paddr - address_map[i].vaddr;
 
-                       return (void *)(unsigned long)(paddr - offset);
+                       return map_sysmem(paddr - offset, 0);
                }
        }
 
index fb744485bbf9ff2bea6cf913b2acddc280587ad0..1eb5955db1726ab46cb470c69581071bcf490efd 100644 (file)
@@ -29,9 +29,8 @@ ADDRMAP_TEST(addrmap_test_basic, UT_TESTF_CONSOLE_REC);
 
 int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
-       struct unit_test *tests = ll_entry_start(struct unit_test,
-                                                addrmap_test);
-       const int n_ents = ll_entry_count(struct unit_test, addrmap_test);
+       struct unit_test *tests = UNIT_TEST_SUITE_START(addrmap_test);
+       const int n_ents = UNIT_TEST_SUITE_COUNT(addrmap_test);
 
        return cmd_ut_category("cmd_addrmap", "cmd_addrmap_", tests, n_ents,
                               argc, argv);