summaryrefslogtreecommitdiffstats
path: root/arch/sandbox
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-06-11 07:35:39 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-06-11 07:35:39 +0200
commit1fb15fcfe9ecb079b88df7eb01f1e29144cd8f96 (patch)
tree651ae01bac7ed264934baccd0fccbfeec6905da6 /arch/sandbox
parentd6757bacf8180b17692682c58dd6a9938d0c3c1d (diff)
parentaa2cd910c7465eaf6de04da1b4d110205ad63c77 (diff)
downloadbarebox-1fb15fcfe9ecb079b88df7eb01f1e29144cd8f96.tar.gz
barebox-1fb15fcfe9ecb079b88df7eb01f1e29144cd8f96.tar.xz
Merge branch 'for-next/sandbox-compile-test'
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/Kconfig17
-rw-r--r--arch/sandbox/Makefile12
-rw-r--r--arch/sandbox/include/asm/atomic.h2
-rw-r--r--arch/sandbox/include/asm/bitsperlong.h11
-rw-r--r--arch/sandbox/include/asm/dma.h53
-rw-r--r--arch/sandbox/include/asm/io.h11
-rw-r--r--arch/sandbox/os/Makefile2
-rw-r--r--arch/sandbox/os/common.c2
8 files changed, 96 insertions, 14 deletions
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 6ec71a99e5..3f10709021 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -1,9 +1,12 @@
+source "scripts/Kconfig.include"
+
config SANDBOX
bool
select OFTREE
select GPIOLIB
select ARCH_HAS_UBSAN_SANITIZE_ALL
select HAVE_ARCH_KASAN
+ select HAS_DMA
default y
config ARCH_TEXT_BASE
@@ -20,3 +23,17 @@ config SANDBOX_UNWIND
default y
select ARCH_HAS_STACK_DUMP
depends on UBSAN || KASAN
+
+config CC_IS_64BIT
+ def_bool $(success,$(srctree)/scripts/gcc-64bitptr.sh $(CC))
+
+config CC_HAS_LINUX_I386_SUPPORT
+ def_bool $(cc-option,-m32) && $(ld-option,-m elf_i386)
+
+config 64BIT
+ bool
+ default n if SANDBOX_LINUX_I386
+ default CC_IS_64BIT
+
+config SANDBOX_LINUX_I386
+ bool "32-bit x86 barebox" if CC_HAS_LINUX_I386_SUPPORT
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 3917cade94..c08ea0cf83 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -52,11 +52,21 @@ ifeq ($(CONFIG_UBSAN),y)
SANITIZER_LIBS += -fsanitize=undefined
endif
-cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(BAREBOX_LDS) \
+ifeq ($(CONFIG_SANDBOX_LINUX_I386),y)
+KBUILD_CFLAGS += -m32
+KBUILD_LDFLAGS += -m elf_i386
+KBUILD_AFLAGS += -m32
+BAREBOX_LDFLAGS += -m32
+endif
+
+BAREBOX_LDFLAGS += \
+ -Wl,-T,$(BAREBOX_LDS) \
-Wl,--whole-archive $(BAREBOX_OBJS) -Wl,--no-whole-archive \
-lrt -lpthread $(SDL_LIBS) $(FTDI1_LIBS) \
$(SANITIZER_LIBS)
+cmd_barebox__ = $(CC) -o $@ $(BAREBOX_LDFLAGS)
+
common-y += $(BOARD) arch/sandbox/os/ arch/sandbox/lib/
common-$(CONFIG_OFTREE) += arch/sandbox/dts/
diff --git a/arch/sandbox/include/asm/atomic.h b/arch/sandbox/include/asm/atomic.h
new file mode 100644
index 0000000000..af12dee130
--- /dev/null
+++ b/arch/sandbox/include/asm/atomic.h
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <asm-generic/atomic.h>
diff --git a/arch/sandbox/include/asm/bitsperlong.h b/arch/sandbox/include/asm/bitsperlong.h
index 00c1fc2625..6dc0bb0c13 100644
--- a/arch/sandbox/include/asm/bitsperlong.h
+++ b/arch/sandbox/include/asm/bitsperlong.h
@@ -1,10 +1 @@
-#ifndef __ASM_BITSPERLONG_H
-#define __ASM_BITSPERLONG_H
-
-#ifdef __x86_64__
-#define BITS_PER_LONG 64
-#else
-#define BITS_PER_LONG 32
-#endif
-
-#endif /* __ASM_BITSPERLONG_H */
+#include <asm-generic/bitsperlong.h>
diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h
index 459536779e..5e72d8e7df 100644
--- a/arch/sandbox/include/asm/dma.h
+++ b/arch/sandbox/include/asm/dma.h
@@ -8,6 +8,57 @@
#ifndef __ASM_DMA_H
#define __ASM_DMA_H
-/* empty*/
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <driver.h>
+
+#define dma_alloc dma_alloc
+static inline void *dma_alloc(size_t size)
+{
+ return xmemalign(64, ALIGN(size, 64));
+}
+
+static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
+{
+ void *ret = xmemalign(4096, size);
+ if (dma_handle)
+ *dma_handle = (dma_addr_t)ret;
+
+ memset(ret, 0, size);
+
+ return ret;
+}
+
+static inline void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
+{
+ return dma_alloc_coherent(size, dma_handle);
+}
+
+static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
+ size_t size)
+{
+ free(mem);
+}
+
+static inline dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
+ enum dma_data_direction dir)
+{
+ return (dma_addr_t)ptr;
+}
+
+static inline void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
+ enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
+ enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
+ enum dma_data_direction dir)
+{
+}
#endif /* __ASM_DMA_H */
diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index cb891df5c8..6a0e77aead 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -4,5 +4,16 @@
#define IO_SPACE_LIMIT 0
#include <asm-generic/io.h>
+#include <asm-generic/bitio.h>
+
+static inline void *phys_to_virt(unsigned long phys)
+{
+ return (void *)phys;
+}
+
+static inline unsigned long virt_to_phys(volatile void *mem)
+{
+ return (unsigned long)mem;
+}
#endif /* __ASM_SANDBOX_IO_H */
diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile
index c012c9cf01..ed921443e0 100644
--- a/arch/sandbox/os/Makefile
+++ b/arch/sandbox/os/Makefile
@@ -6,7 +6,7 @@ KBUILD_CPPFLAGS = $(patsubst %,-I$(srctree)/%include,$(machdirs))
KBUILD_CPPFLAGS += -DCONFIG_MALLOC_SIZE=$(CONFIG_MALLOC_SIZE)
-KBUILD_CFLAGS := -Wall
+KBUILD_CFLAGS += -Wall
NOSTDINC_FLAGS :=
obj-y = common.o tap.o
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index e67ea14138..382a923040 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -236,7 +236,7 @@ static int add_image(char *str, char *devname_template, int *devname_number)
filename = devname;
snprintf(tmp, sizeof(tmp),
devname_template, (*devname_number)++);
- devname = strdup(tmp);
+ devname = tmp;
}
printf("add %s backed by file %s%s\n", devname,