sandbox: Add 64-bit sandbox
PATCH v2 1/1 sandbox: Add 64-bit sandbox
From: Mario Six <[email protected]>
To debug device tree issues involving 32- and 64-bit platforms, it is useful to have a generic 64-bit platform available.
Add a version of the sandbox that uses 64-bit integers for its physical addresses as well as a modified device tree.
---
v1 -> v2:
* Renamed CONFIG_SANDBOX_64BIT to CONFIG_HOST_64BIT to make semantics more easily understandable
* Switched control of integer width to depend on CONFIG_PHYS_64BIT instead of CONFIG_SANDBOX64
* Extended the sandbox README with information about the 64-bit sandbox
--- arch/sandbox/Kconfig | 16 +- arch/sandbox/cpu/cpu.c | 2 +- arch/sandbox/dts/Makefile | 4 + arch/sandbox/dts/sandbox64.dts | 317 +++++++++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/io.h | 6 + arch/sandbox/include/asm/types.h | 17 ++- board/sandbox/README.sandbox | 7 +- cmd/demo.c | 6 +- configs/sandbox64_defconfig | 200 ++++++++++++++++++++++++ drivers/demo/demo-simple.c | 2 +- 10 files changed, 561 insertions(+), 16 deletions(-) create mode 100644 arch/sandbox/dts/sandbox64.dts create mode 100644 configs/sandbox64_defconfig
arch/sandbox/Kconfig +11 -5
@@ -10,6 +10,11 @@ config SYS_BOARD config SYS_CPU default "sandbox" +config SANDBOX64 + bool "Use 64-bit addresses" + select PHYS_64BIT + select HOST_64BIT + config SANDBOX_SPL bool "Enable SPL for sandbox" select SUPPORT_SPL
@@ -20,24 +25,25 @@ config SYS_CONFIG_NAME choice prompt "Run sandbox on 32/64-bit host" - default SANDBOX_64BIT + default HOST_64BIT help Sandbox can be built on 32-bit and 64-bit hosts. The default is to build on a 64-bit host and run on a 64-bit host. If you want to run sandbox on a 32-bit host, change it here. -config SANDBOX_32BIT +config HOST_32BIT bool "32-bit host" + depends on !PHYS_64BIT -config SANDBOX_64BIT +config HOST_64BIT bool "64-bit host" endchoice config SANDBOX_BITS_PER_LONG int - default 32 if SANDBOX_32BIT - default 64 if SANDBOX_64BIT + default 32 if HOST_32BIT + default 64 if HOST_64BIT endmenu
arch/sandbox/cpu/cpu.c +1 -1
@@ -76,7 +76,7 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)if (enable_pci_map && !pci_map_physmem (paddr, &len, &map_dev, &ptr)) {if (plen != len) {printf ("%s: Warning: partial map at %x, wanted %lx, got %lx\n" , - __func__, paddr, len, plen); + __func__, (uint )paddr, len, plen); } map_len = len;return ptr;
arch/sandbox/dts/Makefile +4 -0
@@ -2,7 +2,11 @@ # SPDX-License-Identifier: GPL-2.0+ # +ifdef CONFIG_SANDBOX64 +dtb-$(CONFIG_SANDBOX) += sandbox64.dtb +else dtb-$(CONFIG_SANDBOX) += sandbox.dtb +endif dtb-$(CONFIG_UT_DM) += test.dtb targets += $(dtb-y)
arch/sandbox/dts/sandbox64.dts new file +317 -0
317 lines not on this page · raw message
arch/sandbox/include/asm/io.h +6 -0
@@ -43,9 +43,15 @@ phys_addr_t map_to_sysmem(const void *ptr);#define readb (addr) ((void)addr, 0)#define readw (addr) ((void)addr, 0)#define readl (addr) ((void)addr, 0) +#ifdef CONFIG_SANDBOX64 +#define readq (addr) ((void)addr, 0) +#endif #define writeb (v, addr) ((void)addr)#define writew (v, addr) ((void)addr)#define writel (v, addr) ((void)addr) +#ifdef CONFIG_SANDBOX64 +#define writeq (v, addr) ((void)addr) +#endif /* * Clear and set bits in one shot. These macros can be used to clear and
arch/sandbox/include/asm/types.h +13 -4
@@ -51,14 +51,23 @@ typedef __UINT64_TYPE__ u64;#endif /* -* Number of bits in a C 'long' on this architecture. Set this to 32 when -* building on a 32-bit machine. +* Number of bits in a C 'long' on this architecture. */ -#define BITS_PER_LONG 32 - +#ifdef CONFIG_PHYS64 +#define BITS_PER_LONG 64 +#else /* CONFIG_PHYS64 */ +#define BITS_PER_LONG 32 +#endif /* CONFIG_PHYS64 */ + +#ifdef CONFIG_PHYS64 +typedef unsigned long long dma_addr_t ; +typedef u64 phys_addr_t ; +typedef u64 phys_size_t ; +#else /* CONFIG_PHYS64 */ typedef unsigned long dma_addr_t ;typedef u32 phys_addr_t ;typedef u32 phys_size_t ; +#endif /* CONFIG_PHYS64 */ #endif /* __KERNEL__ */
board/sandbox/README.sandbox +5 -2
@@ -24,8 +24,11 @@ single board in board/sandbox. CONFIG_SANDBOX_BIG_ENDIAN should be defined when running on big-endian machines. -By default sandbox builds and runs on 64-bit hosts. If you are going to build -and run sandbox on a 32-bit host, select CONFIG_SANDBOX_32BIT. +There are two versions of the sandbox: One using 32-bit-wide integers, and one +using 64-bit-wide integers. The 32-bit version can be build and run on either +32 or 64-bit hosts by either selecting or deselecting CONFIG_SANDBOX_32BIT; by +default, the sandbox it built for a 32-bit host. The sandbox using 64-bit-wide +integers can only be built on 64-bit hosts. Note that standalone/API support is not available at present.
cmd/demo.c +3 -3
@@ -71,9 +71,9 @@ int do_demo_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])dev ; ret = uclass_next_device(&dev)) {printf ("entry %d - instance %08x, ops %08x, platdata %08x\n" , - i++,map_to_sysmem (dev), -map_to_sysmem (dev->driver->ops), -map_to_sysmem (dev_get_platdata (dev))); + i++, (uint )map_to_sysmem (dev), + (uint )map_to_sysmem (dev->driver->ops), + (uint )map_to_sysmem (dev_get_platdata (dev))); }return cmd_process_error (cmdtp, ret);
configs/sandbox64_defconfig new file +200 -0
200 lines not on this page · raw message
drivers/demo/demo-simple.c +1 -1
@@ -17,7 +17,7 @@ static int simple_hello(struct udevice *dev, int ch) {const struct dm_demo_pdata *pdata =dev_get_platdata (dev); -printf ("Hello from %08x: %s %d\n" ,map_to_sysmem (dev), pdata->colour, +printf ("Hello from %08x: %s %d\n" , (uint )map_to_sysmem (dev), pdata->colour, pdata->sides);return 0 ;
--
2.11.0
PATCH v2 1/1 sandbox: Add 64-bit sandbox
Quoted 19 lines · Mario Six
From: Mario Six <[email protected]>
To debug device tree issues involving 32- and 64-bit platforms, it is useful to have a generic 64-bit platform available.
Add a version of the sandbox that uses 64-bit integers for its physical addresses as well as a modified device tree.
Signed-off-by Mario Six <[email protected]>Reviewed-by Simon Glass <[email protected]>---
v1 -> v2:
* RenamedCONFIG_SANDBOX_64BITtoCONFIG_HOST_64BITto make semantics more easily understandable
* Switched control of integer width to depend onCONFIG_PHYS_64BITinstead ofCONFIG_SANDBOX64
* Extended the sandbox README with information about the 64-bit sandbox
Quoted 14 lines
--- arch/sandbox/Kconfig | 16 +- arch/sandbox/cpu/cpu.c | 2 +- arch/sandbox/dts/Makefile | 4 + arch/sandbox/dts/sandbox64.dts | 317 +++++++++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/io.h | 6 + arch/sandbox/include/asm/types.h | 17 ++- board/sandbox/README.sandbox | 7 +- cmd/demo.c | 6 +- configs/sandbox64_defconfig | 200 ++++++++++++++++++++++++ drivers/demo/demo-simple.c | 2 +- 10 files changed, 561 insertions(+), 16 deletions(-) create mode 100644 arch/sandbox/dts/sandbox64.dts create mode 100644 configs/sandbox64_defconfig
Applied to u-boot-dm, thanks!
PATCH v2 1/1 sandbox: Add 64-bit sandbox
Hi Mario,
Quoted 35 lines · Simon Glass
Quoted 19 lines · Mario Six
From: Mario Six <[email protected]>
To debug device tree issues involving 32- and 64-bit platforms, it is useful to have a generic 64-bit platform available.
Add a version of the sandbox that uses 64-bit integers for its physical addresses as well as a modified device tree.
Signed-off-by Mario Six <[email protected]>Reviewed-by Simon Glass <[email protected]>---
v1 -> v2:
* RenamedCONFIG_SANDBOX_64BITtoCONFIG_HOST_64BITto make semantics more easily understandable
* Switched control of integer width to depend onCONFIG_PHYS_64BITinstead ofCONFIG_SANDBOX64
* Extended the sandbox README with information about the 64-bit sandboxQuoted 14 lines
--- arch/sandbox/Kconfig | 16 +- arch/sandbox/cpu/cpu.c | 2 +- arch/sandbox/dts/Makefile | 4 + arch/sandbox/dts/sandbox64.dts | 317 +++++++++++++++++++++++++++++++++++++++ arch/sandbox/include/asm/io.h | 6 + arch/sandbox/include/asm/types.h | 17 ++- board/sandbox/README.sandbox | 7 +- cmd/demo.c | 6 +- configs/sandbox64_defconfig | 200 ++++++++++++++++++++++++ drivers/demo/demo-simple.c | 2 +- 10 files changed, 561 insertions(+), 16 deletions(-) create mode 100644 arch/sandbox/dts/sandbox64.dts create mode 100644 configs/sandbox64_defconfig
Quoted 1 line
Applied to u-boot-dm, thanks!
Unfortunately I had to drop this as it caused warnings when building:
lib/fdtdec.c: In function ‘fdtdec_get_addr_size_auto_noparent’:include/fdtdec.h:27:25: warning: large integer implicitly truncated to unsigned type [-Woverflow]
#define FDT_ADDR_T_NONE (-1ULL)
Would you please take a look? Also can you add a MAINTAINER file for sandbox/sandbox64?
Sorry for the late notice.
Thanks,
Simon