From 2a54d1599f4c3a95b1d39db45888b49c36465af3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 19 May 2013 16:45:35 -0700 Subject: sandbox: Use uint64_t instead of u64 for time The uint64_t type is defined in linux/types.h, so is safer than u64, which is not actually a Linux type. Change-Id: Ifc9a369e6543250c49117b8d3cb3a676eee43e04 Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 3 ++- include/os.h | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index c2e5f57193..db66fd31f2 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -136,7 +137,7 @@ void os_usleep(unsigned long usec) usleep(usec); } -u64 __attribute__((no_instrument_function)) os_get_nsec(void) +uint64_t __attribute__((no_instrument_function)) os_get_nsec(void) { #if defined(CLOCK_MONOTONIC) && defined(_POSIX_MONOTONIC_CLOCK) struct timespec tp; diff --git a/include/os.h b/include/os.h index 8665f70edb..950433daa3 100644 --- a/include/os.h +++ b/include/os.h @@ -11,6 +11,8 @@ #ifndef __OS_H__ #define __OS_H__ +#include + struct sandbox_state; /** @@ -116,7 +118,7 @@ void os_usleep(unsigned long usec); * * \return A monotonic increasing time scaled in nano seconds */ -u64 os_get_nsec(void); +uint64_t os_get_nsec(void); /** * Parse arguments and update sandbox state. -- cgit v1.2.3 From cbe5cdfcd31633edce4ee78ebc008b922de571e3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 10 Nov 2013 10:26:48 -0700 Subject: sandbox: Use system headers first for sandbox's os.c This file must be compiled with system headers, even if U-Boot has headers of the same name. The existing solution for this is good enough for libfdt, but fails when we have headers like stdint.h in U-Boot. Use -idirafter instead of -I, and remove the -nostdinc and other things that we don't want for this file. The best way to do this is to keep a copy of the original flags, rather than trying to filter them later. Signed-off-by: Simon Glass --- arch/sandbox/cpu/Makefile | 6 ++++-- config.mk | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/sandbox/cpu/Makefile b/arch/sandbox/cpu/Makefile index 404ff6793f..58c2537762 100644 --- a/arch/sandbox/cpu/Makefile +++ b/arch/sandbox/cpu/Makefile @@ -10,5 +10,7 @@ obj-y := cpu.o os.o start.o state.o # os.c is build in the system environment, so needs standard includes -$(obj)os.o: ALL_CFLAGS := $(filter-out -nostdinc,$(ALL_CFLAGS)) -$(obj).depend.os: CPPFLAGS := $(filter-out -nostdinc,$(CPPFLAGS)) +$(obj)os.o: ALL_CFLAGS := $(BASE_CPPFLAGS) \ + $(patsubst %, -idirafter %, $(BASE_INCLUDE_DIRS)) +$(obj).depend.os: CPPFLAGS := $(BASE_CPPFLAGS) \ + $(patsubst %, -idirafter %, $(BASE_INCLUDE_DIRS)) diff --git a/config.mk b/config.mk index 206de203cc..d5b09a0095 100644 --- a/config.mk +++ b/config.mk @@ -250,11 +250,16 @@ Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file) endif endif +# Sandbox needs the base flags and includes, so keep them around +BASE_CPPFLAGS := $(CPPFLAGS) + ifneq ($(OBJTREE),$(SRCTREE)) -CPPFLAGS += -I$(OBJTREE)/include +BASE_INCLUDE_DIRS := $(OBJTREE)/include endif -CPPFLAGS += -I$(TOPDIR)/include -I$(SRCTREE)/arch/$(ARCH)/include +BASE_INCLUDE_DIRS += $(TOPDIR)/include $(SRCTREE)/arch/$(ARCH)/include + +CPPFLAGS += $(patsubst %, -I%, $(BASE_INCLUDE_DIRS)) CPPFLAGS += -fno-builtin -ffreestanding -nostdinc \ -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS) -- cgit v1.2.3 From 0eb2acee394b16dd734f5f48b2cbf2f22065d060 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 10 Nov 2013 10:26:53 -0700 Subject: sandbox: config: Don't use 64-bit physical memory Sandbox uses an emulated memory map which is quite small. We don't need the CONFIG_PHYS_64BIT option since we can address memory with a 32-bit offset into our ram_buf. Adjust the phys_addr_t and phys_size_t types accordingly. Signed-off-by: Simon Glass Signed-off-by: Simon Glass Reviewed-by: Hung-ying Tyan --- arch/sandbox/include/asm/types.h | 4 ++-- include/configs/sandbox.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/sandbox/include/asm/types.h b/arch/sandbox/include/asm/types.h index 88c84bae7c..6d3eb1f3de 100644 --- a/arch/sandbox/include/asm/types.h +++ b/arch/sandbox/include/asm/types.h @@ -48,8 +48,8 @@ typedef unsigned long long u64; #define BITS_PER_LONG CONFIG_SANDBOX_BITS_PER_LONG typedef unsigned long dma_addr_t; -typedef unsigned long phys_addr_t; -typedef unsigned long phys_size_t; +typedef u32 phys_addr_t; +typedef u32 phys_size_t; #endif /* __KERNEL__ */ diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 0884ad3a02..a4edc624bc 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -75,7 +75,6 @@ #define CONFIG_SYS_LOAD_ADDR 0x00000000 #define CONFIG_SYS_MEMTEST_START 0x00100000 #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + 0x1000) -#define CONFIG_PHYS_64BIT #define CONFIG_SYS_FDT_LOAD_ADDR 0x1000000 /* Size of our emulated memory */ -- cgit v1.2.3 From 370b6c5c4d764192399a220095a2dd1054314147 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 10 Nov 2013 10:26:54 -0700 Subject: sandbox: Correct data sizes and printf() strings in fdtdec.c There are a few wwrnings in this file when building for sandbox. Addresses coming from the device tree need to be treated as ulong as elsewhere in U-Boot and we must use map_sysmem() to convert to a pointer when needed. Signed-off-by: Simon Glass Signed-off-by: Simon Glass Reviewed-by: Hung-ying Tyan --- lib/fdtdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 51fa868333..207314fa72 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -86,10 +86,10 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, size = (fdt_size_t *)((char *)cell + sizeof(fdt_addr_t)); *sizep = fdt_size_to_cpu(*size); - debug("addr=%p, size=%p\n", (void *)addr, - (void *)*sizep); + debug("addr=%08lx, size=%08x\n", + (ulong)addr, *sizep); } else { - debug("%p\n", (void *)addr); + debug("%08lx\n", (ulong)addr); } return addr; } @@ -611,7 +611,7 @@ int fdtdec_decode_region(const void *blob, int node, if (!cell || (len != sizeof(fdt_addr_t) * 2)) return -1; - *ptrp = (void *)fdt_addr_to_cpu(*cell); + *ptrp = map_sysmem(fdt_addr_to_cpu(*cell), *size); *size = fdt_size_to_cpu(cell[1]); debug("%s: size=%zx\n", __func__, *size); return 0; -- cgit v1.2.3 From ed072b96efd7a5de51cef01c3d4bed4db0e391f0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 7 Nov 2013 09:31:58 -0700 Subject: sandbox: Make map_to_sysmem() use a constant pointer Very often a constant pointer is passed to this function, so we should declare this, since map_to_sysmem() does not change the pointer. Signed-off-by: Simon Glass --- arch/sandbox/include/asm/io.h | 2 +- include/common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index 9ac6a5f00d..7956041171 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -38,6 +38,6 @@ static inline void unmap_sysmem(const void *vaddr) } /* Map from a pointer to our RAM buffer */ -phys_addr_t map_to_sysmem(void *ptr); +phys_addr_t map_to_sysmem(const void *ptr); #endif diff --git a/include/common.h b/include/common.h index 409515f498..8ca67f64fa 100644 --- a/include/common.h +++ b/include/common.h @@ -923,7 +923,7 @@ static inline void unmap_sysmem(const void *vaddr) { } -static inline phys_addr_t map_to_sysmem(void *ptr) +static inline phys_addr_t map_to_sysmem(const void *ptr) { return (phys_addr_t)(uintptr_t)ptr; } -- cgit v1.2.3