sandbox: Add 64-bit sandbox
PATCH v3 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.
---
v2 -> v3:
* Fixed compile warning involving FDT_ADDR_T_NONE
* Added sandbox64 to MAINTAINERS
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/MAINTAINERS | 8 + board/sandbox/README.sandbox | 7 +- cmd/demo.c | 6 +- configs/sandbox64_defconfig | 200 ++++++++++++++++++++++++ drivers/demo/demo-simple.c | 2 +- include/fdtdec.h | 2 +- 12 files changed, 570 insertions(+), 17 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/MAINTAINERS +8 -0
@@ -5,6 +5,14 @@ F: board/sandbox/ F: include/configs/sandbox.h F: configs/sandbox_defconfig +SANDBOX64 BOARD +M: Simon Glass <[email protected]> +M: Mario Six <[email protected]> +S: Maintained +F: board/sandbox/ +F: include/configs/sandbox.h +F: configs/sandbox64_defconfig + SANDBOX_NOBLK BOARD M: Simon Glass <[email protected]> S: Maintained
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 ;
include/fdtdec.h +1 -1
@@ -24,7 +24,7 @@typedef phys_addr_t fdt_addr_t ;typedef phys_size_t fdt_size_t ;#ifdef CONFIG_PHYS_64BIT -#define FDT_ADDR_T_NONE (-1ULL) +#define FDT_ADDR_T_NONE (-1U)#define fdt_addr_to_cpu (reg) be64_to_cpu(reg)#define fdt_size_to_cpu (reg) be64_to_cpu(reg)typedef fdt64_t fdt_val_t ;
--
2.13.6
PATCH v3 1/1 sandbox: Add 64-bit sandbox
Hi,
Quoted 22 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]>---
v2 -> v3:
* Fixed compile warning involvingFDT_ADDR_T_NONE
* Added sandbox64 toMAINTAINERSv1 -> 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 16 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/MAINTAINERS | 8 + board/sandbox/README.sandbox | 7 +- cmd/demo.c | 6 +- configs/sandbox64_defconfig | 200 ++++++++++++++++++++++++ drivers/demo/demo-simple.c | 2 +- include/fdtdec.h | 2 +- 12 files changed, 570 insertions(+), 17 deletions(-) create mode 100644 arch/sandbox/dts/sandbox64.dts create mode 100644 configs/sandbox64_defconfig
Sorry for missing this at the time. This was applied and is now in mainline.
Regards,
Simon