summaryrefslogtreecommitdiffstats
path: root/arch/sandbox
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/Kconfig21
-rw-r--r--arch/sandbox/Makefile14
-rw-r--r--arch/sandbox/board/.gitignore1
-rw-r--r--arch/sandbox/board/Makefile7
-rw-r--r--arch/sandbox/board/barebox.lds.S2
-rw-r--r--arch/sandbox/board/board.c10
-rw-r--r--arch/sandbox/board/console.c4
-rw-r--r--arch/sandbox/board/devices.c4
-rw-r--r--arch/sandbox/board/hostfile.c87
-rw-r--r--arch/sandbox/board/led.c9
-rw-r--r--arch/sandbox/board/power.c22
-rw-r--r--arch/sandbox/board/stickypage.S3
-rw-r--r--arch/sandbox/board/watchdog.c34
-rw-r--r--arch/sandbox/configs/sandbox_defconfig4
-rw-r--r--arch/sandbox/dts/Makefile2
-rw-r--r--arch/sandbox/dts/sandbox.dts7
-rw-r--r--arch/sandbox/include/asm/barebox.lds.h3
-rw-r--r--arch/sandbox/include/asm/common.h2
-rw-r--r--arch/sandbox/include/asm/debug_ll.h16
-rw-r--r--arch/sandbox/include/asm/dma.h18
-rw-r--r--arch/sandbox/include/asm/linkage.h8
-rw-r--r--arch/sandbox/include/asm/reset_source.h16
-rw-r--r--arch/sandbox/include/asm/word-at-a-time.h2
-rw-r--r--arch/sandbox/mach-sandbox/include/mach/linux.h6
-rw-r--r--arch/sandbox/os/Makefile4
-rw-r--r--arch/sandbox/os/common.c74
-rw-r--r--arch/sandbox/os/libc_malloc.c28
27 files changed, 271 insertions, 137 deletions
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index a8bca8757f..3419b6e4f6 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -15,19 +15,17 @@ config SANDBOX
select PARTITION_DISK
select ARCH_HAS_STACK_DUMP if ASAN
select GENERIC_FIND_NEXT_BIT
- select HAS_ARCH_SJLJ
+ select ARCH_HAS_SJLJ
+ select ARCH_HAS_CTRLC
+ select HAS_DEBUG_LL
+ select ARCH_DMA_DEFAULT_COHERENT
default y
config ARCH_TEXT_BASE
hex
default 0x00000000
-config SANDBOX_REEXEC
- prompt "exec(2) reset handler"
- def_bool y
- help
- The normal reset handler hangs barebox. On Linux, barebox
- instead can exec itself to simulate a reset.
+menu "Sandbox specific settings"
config PHYS_ADDR_T_64BIT
bool
@@ -51,5 +49,14 @@ config 32BIT
config SANDBOX_LINUX_I386
bool "32-bit x86 barebox" if CC_HAS_LINUX_I386_SUPPORT
+config SANDBOX_REEXEC
+ prompt "exec(2) reset handler"
+ def_bool y
+ help
+ The normal reset handler hangs barebox. On Linux, barebox
+ instead can exec itself to simulate a reset.
+
config SDL
bool
+
+endmenu
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index aee6bccc9c..c2906c0b1c 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -30,7 +30,9 @@ KBUILD_CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \
-Dopendir=barebox_opendir -Dreaddir=barebox_readdir \
-Dclosedir=barebox_closedir -Dreadlink=barebox_readlink \
-Doptarg=barebox_optarg -Doptind=barebox_optind \
- -Dsetjmp=barebox_setjmp -Dlongjmp=barebox_longjmp
+ -Dsetjmp=barebox_setjmp -Dlongjmp=barebox_longjmp \
+ -Dmkdir=barebox_mkdir -Ddirname=barebox_dirname \
+ -Dremove=barebox_remove -Dputchar=barebox_putchar
machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y))
@@ -41,11 +43,11 @@ archprepare: maketools
PHONY += maketools
ifeq ($(CONFIG_SDL),y)
-SDL_LIBS := $(shell pkg-config sdl2 --libs)
+SDL_LIBS := $(shell $(PKG_CONFIG) sdl2 --libs)
endif
ifeq ($(CONFIG_GPIO_LIBFTDI1),y)
-FTDI1_LIBS := $(shell pkg-config libftdi1 --libs)
+FTDI1_LIBS := $(shell $(PKG_CONFIG) libftdi1 --libs)
endif
ifeq ($(CONFIG_ASAN),y)
@@ -74,11 +76,7 @@ cmd_barebox__ = $(CC) -o $@ $(BAREBOX_LDFLAGS)
common-y += $(BOARD) arch/sandbox/os/ arch/sandbox/lib/
-stickypage.bin:
- @$(kecho) " LN stickypage.bin"
- @ln -fs arch/sandbox/board/stickypage.bin stickypage.bin
-
-KBUILD_IMAGE := barebox stickypage.bin
+KBUILD_IMAGE := barebox
common-$(CONFIG_OFTREE) += arch/sandbox/dts/
diff --git a/arch/sandbox/board/.gitignore b/arch/sandbox/board/.gitignore
index c0acd24b98..03987a7009 100644
--- a/arch/sandbox/board/.gitignore
+++ b/arch/sandbox/board/.gitignore
@@ -1,4 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
barebox.lds
-stickypage.bin
diff --git a/arch/sandbox/board/Makefile b/arch/sandbox/board/Makefile
index 11688c5aba..b4bab02163 100644
--- a/arch/sandbox/board/Makefile
+++ b/arch/sandbox/board/Makefile
@@ -13,9 +13,4 @@ obj-$(CONFIG_LED) += led.o
extra-y += barebox.lds
-extra-y += stickypage.bin
-
-OBJCOPYFLAGS_stickypage.bin = -O binary
-
-%.bin: %.o
- $(call if_changed,objcopy)
+obj-y += stickypage.o
diff --git a/arch/sandbox/board/barebox.lds.S b/arch/sandbox/board/barebox.lds.S
index 84d085a259..ab2801f3d2 100644
--- a/arch/sandbox/board/barebox.lds.S
+++ b/arch/sandbox/board/barebox.lds.S
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#include <asm-generic/barebox.lds.h>
+#include <asm/barebox.lds.h>
SECTIONS
{
diff --git a/arch/sandbox/board/board.c b/arch/sandbox/board/board.c
index 43e355afe8..c8d1c99897 100644
--- a/arch/sandbox/board/board.c
+++ b/arch/sandbox/board/board.c
@@ -29,23 +29,23 @@ struct fb_videomode mode = {
.yres = 480,
};
-static struct device_d tap_device = {
+static struct device tap_device = {
.id = DEVICE_ID_DYNAMIC,
.name = "tap",
};
-static struct device_d sdl_device = {
+static struct device sdl_device = {
.id = DEVICE_ID_DYNAMIC,
.name = "sdlfb",
.platform_data = &mode,
};
-static struct device_d devrandom_device = {
+static struct device devrandom_device = {
.id = DEVICE_ID_DYNAMIC,
.name = "devrandom",
};
-static int devices_init(struct device_d *dev)
+static int devices_init(struct device *dev)
{
platform_device_register(&tap_device);
@@ -68,7 +68,7 @@ static struct of_device_id sandbox_dt_ids[] = {
};
BAREBOX_DEEP_PROBE_ENABLE(sandbox_dt_ids);
-static struct driver_d sandbox_board_drv = {
+static struct driver sandbox_board_drv = {
.name = "sandbox-board",
.of_compatible = sandbox_dt_ids,
.probe = devices_init,
diff --git a/arch/sandbox/board/console.c b/arch/sandbox/board/console.c
index cea62d57b1..274ef67aef 100644
--- a/arch/sandbox/board/console.c
+++ b/arch/sandbox/board/console.c
@@ -21,10 +21,10 @@
int barebox_register_console(int stdinfd, int stdoutfd)
{
- struct device_d *dev;
+ struct device *dev;
struct linux_console_data *data;
- dev = xzalloc(sizeof(struct device_d) + sizeof(struct linux_console_data));
+ dev = xzalloc(sizeof(struct device) + sizeof(struct linux_console_data));
data = (struct linux_console_data *)(dev + 1);
diff --git a/arch/sandbox/board/devices.c b/arch/sandbox/board/devices.c
index f7305a8ead..ecd24e9207 100644
--- a/arch/sandbox/board/devices.c
+++ b/arch/sandbox/board/devices.c
@@ -14,7 +14,7 @@ unsigned char __pci_iobase[IO_SPACE_LIMIT];
static LIST_HEAD(sandbox_device_list);
-int sandbox_add_device(struct device_d *dev)
+int sandbox_add_device(struct device *dev)
{
list_add(&dev->list, &sandbox_device_list);
@@ -23,7 +23,7 @@ int sandbox_add_device(struct device_d *dev)
static int sandbox_device_init(void)
{
- struct device_d *dev, *tmp;
+ struct device *dev, *tmp;
list_for_each_entry_safe(dev, tmp, &sandbox_device_list, list) {
/* reset the list_head before registering for real */
diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 52165adec8..7afad95b6d 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -24,6 +24,7 @@
#include <errno.h>
#include <linux/err.h>
#include <mach/hostfile.h>
+#include <featctrl.h>
#include <xfuncs.h>
struct hf_priv {
@@ -33,6 +34,7 @@ struct hf_priv {
};
const char *filename;
int fd;
+ struct feature_controller feat;
};
static ssize_t hf_read(struct hf_priv *priv, void *buf, size_t count, loff_t offset, ulong flags)
@@ -89,25 +91,48 @@ static struct block_device_ops hf_blk_ops = {
.write = hf_blk_write,
};
-static void hf_info(struct device_d *dev)
+static void hf_info(struct device *dev)
{
struct hf_priv *priv = dev->priv;
printf("file: %s\n", priv->filename);
}
-static int hf_probe(struct device_d *dev)
+static int hostfile_feat_check(struct feature_controller *feat, int idx)
{
- struct device_node *np = dev->device_node;
+ struct hf_priv *priv = container_of(feat, struct hf_priv, feat);
+
+ return priv->fd >= 0 ? FEATCTRL_OKAY : FEATCTRL_GATED;
+}
+
+static int hf_probe(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
struct hf_priv *priv = xzalloc(sizeof(*priv));
struct cdev *cdev;
- bool is_blockdev;
+ bool is_featctrl = false, is_blockdev;
u64 reg[2];
int err;
if (!np)
return -ENODEV;
+ dev->priv = priv;
+ priv->fd = -1;
+
+ if (IS_ENABLED(CONFIG_FEATURE_CONTROLLER) &&
+ of_property_read_bool(np, "barebox,feature-controller")) {
+ priv->feat.dev = dev;
+ priv->feat.check = hostfile_feat_check;
+
+ err = feature_controller_register(&priv->feat);
+ if (err)
+ return err;
+
+ is_featctrl = true;
+ }
+
+
err = of_property_read_u64_array(np, "reg", reg, ARRAY_SIZE(reg));
if (err)
return err;
@@ -120,16 +145,15 @@ static int hf_probe(struct device_d *dev)
return err;
if (priv->fd < 0)
- return priv->fd;
+ return is_featctrl ? 0 : priv->fd;
dev->info = hf_info;
- dev->priv = priv;
is_blockdev = of_property_read_bool(np, "barebox,blockdev");
cdev = is_blockdev ? &priv->blk.cdev : &priv->cdev;
- cdev->device_node = np;
+ cdev_set_of_node(cdev, np);
if (is_blockdev) {
cdev->name = np->name;
@@ -137,15 +161,12 @@ static int hf_probe(struct device_d *dev)
priv->blk.ops = &hf_blk_ops;
priv->blk.blockbits = SECTOR_SHIFT;
priv->blk.num_blocks = reg[1] / SECTOR_SIZE;
+ priv->blk.type = BLK_TYPE_VIRTUAL;
err = blockdevice_register(&priv->blk);
if (err)
return err;
- err = parse_partition_table(&priv->blk);
- if (err)
- dev_warn(dev, "No partition table found\n");
-
dev_info(dev, "registered as block device\n");
} else {
cdev->name = np->name;
@@ -164,7 +185,7 @@ static int hf_probe(struct device_d *dev)
of_parse_partitions(cdev, np);
of_partitions_register_fixup(cdev);
- return 0;
+ return of_platform_populate(np, NULL, dev);
}
static __maybe_unused struct of_device_id hostfile_dt_ids[] = {
@@ -174,8 +195,9 @@ static __maybe_unused struct of_device_id hostfile_dt_ids[] = {
/* sentinel */
}
};
+MODULE_DEVICE_TABLE(of, hostfile_dt_ids);
-static struct driver_d hf_drv = {
+static struct driver hf_drv = {
.name = "hostfile",
.of_compatible = DRV_OF_COMPAT(hostfile_dt_ids),
.probe = hf_probe,
@@ -227,7 +249,20 @@ static int of_hostfile_map_fixup(struct device_node *root, void *ctx)
struct device_node *node;
int ret;
- for_each_compatible_node_from(node, root, NULL, hostfile_dt_ids->compatible) {
+ for_each_compatible_node_from(node, root, NULL, "barebox,stickypage") {
+ char *filename;
+
+ filename = linux_get_stickypage_path();
+ if (!filename) {
+ pr_err("error allocating stickypage\n");
+ continue;
+ }
+
+ of_property_write_string(node, "barebox,filename", filename);
+ of_property_write_string(node, "compatible", "barebox,hostfile");
+ }
+
+ for_each_compatible_node_from(node, root, NULL, "barebox,hostfile") {
struct hf_info hf = {};
uint64_t reg[2] = {};
@@ -239,13 +274,6 @@ static int of_hostfile_map_fixup(struct device_node *root, void *ctx)
continue;
}
- if (memcmp(hf.filename, "$build/", 7) == 0) {
- char *fullpath = xasprintf("%s/%s", linux_get_builddir(),
- hf.filename + sizeof "$build/" - 1);
-
- hf.filename = fullpath;
- }
-
hf.is_blockdev = of_property_read_bool(node, "barebox,blockdev");
hf.is_cdev = of_property_read_bool(node, "barebox,cdev");
hf.is_readonly = of_property_read_bool(node, "barebox,read-only");
@@ -257,23 +285,14 @@ static int of_hostfile_map_fixup(struct device_node *root, void *ctx)
ret = linux_open_hostfile(&hf);
if (ret)
- goto out;
+ continue;
reg[0] = hf.base;
reg[1] = hf.size;
- ret = of_property_write_u64_array(node, "reg", reg, ARRAY_SIZE(reg));
- if (ret)
- goto out;
-
- ret = of_property_write_bool(node, "barebox,blockdev", hf.is_blockdev);
- if (ret)
- goto out;
-
- ret = of_property_write_u32(node, "barebox,fd", hf.fd);
-out:
- if (ret)
- pr_err("error fixing up %s: %pe\n", hf.devname, ERR_PTR(ret));
+ of_property_write_u64_array(node, "reg", reg, ARRAY_SIZE(reg));
+ of_property_write_bool(node, "barebox,blockdev", hf.is_blockdev);
+ of_property_write_u32(node, "barebox,fd", hf.fd);
}
return 0;
diff --git a/arch/sandbox/board/led.c b/arch/sandbox/board/led.c
index b7ab81112b..ced7e82f99 100644
--- a/arch/sandbox/board/led.c
+++ b/arch/sandbox/board/led.c
@@ -26,9 +26,9 @@ static void sandbox_led_set(struct led *led, unsigned int brightness)
sandbox_led.active = true;
}
-static int sandbox_led_of_probe(struct device_d *dev)
+static int sandbox_led_of_probe(struct device *dev)
{
- struct device_node *np = dev->device_node;
+ struct device_node *np = dev->of_node;
int ret;
if (sandbox_led.led.set)
@@ -47,7 +47,7 @@ static int sandbox_led_of_probe(struct device_d *dev)
return 0;
}
-static void sandbox_led_of_remove(struct device_d *dev)
+static void sandbox_led_of_remove(struct device *dev)
{
if (sandbox_led.active)
sandbox_led_set(NULL, 0);
@@ -57,8 +57,9 @@ static struct of_device_id sandbox_led_of_ids[] = {
{ .compatible = "barebox,sandbox-led", },
{ }
};
+MODULE_DEVICE_TABLE(of, sandbox_led_of_ids);
-static struct driver_d sandbox_led_of_driver = {
+static struct driver sandbox_led_of_driver = {
.name = "sandbox-led",
.probe = sandbox_led_of_probe,
.remove = sandbox_led_of_remove,
diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c
index 009b410eaa..8300c589c7 100644
--- a/arch/sandbox/board/power.c
+++ b/arch/sandbox/board/power.c
@@ -5,7 +5,7 @@
#include <poweroff.h>
#include <restart.h>
#include <mach/linux.h>
-#include <reset_source.h>
+#include <asm/reset_source.h>
#include <linux/nvmem-consumer.h>
struct sandbox_power {
@@ -18,7 +18,8 @@ static void sandbox_poweroff(struct poweroff_handler *poweroff)
{
struct sandbox_power *power = container_of(poweroff, struct sandbox_power, poweroff);
- nvmem_cell_write(power->reset_source_cell, &(u8) { RESET_POR }, 1);
+ sandbox_save_reset_source(power->reset_source_cell, RESET_POR);
+
linux_exit();
}
@@ -29,16 +30,14 @@ static void sandbox_rst_hang(struct restart_handler *rst)
static void sandbox_rst_reexec(struct restart_handler *rst)
{
- u8 reason = RESET_RST;
struct sandbox_power *power = container_of(rst, struct sandbox_power, rst_reexec);
- if (!IS_ERR(power->reset_source_cell))
- WARN_ON(nvmem_cell_write(power->reset_source_cell, &reason, 1) <= 0);
+ sandbox_save_reset_source(power->reset_source_cell, RESET_RST);
linux_reexec();
}
-static int sandbox_power_probe(struct device_d *dev)
+static int sandbox_power_probe(struct device *dev)
{
struct sandbox_power *power = xzalloc(sizeof(*power));
size_t len;
@@ -66,9 +65,13 @@ static int sandbox_power_probe(struct device_d *dev)
if (IS_ENABLED(CONFIG_SANDBOX_REEXEC))
restart_handler_register(&power->rst_reexec);
- power->reset_source_cell = of_nvmem_cell_get(dev->device_node, "reset-source");
+ power->reset_source_cell = of_nvmem_cell_get(dev->of_node,
+ "reset-source");
if (IS_ERR(power->reset_source_cell)) {
- dev_warn(dev, "No reset source info available: %pe\n", power->reset_source_cell);
+ if (PTR_ERR(power->reset_source_cell) != -EPROBE_DEFER)
+ dev_warn(dev, "No reset source info available: %pe\n",
+ power->reset_source_cell);
+ power->reset_source_cell = NULL;
return 0;
}
@@ -86,8 +89,9 @@ static __maybe_unused struct of_device_id sandbox_power_dt_ids[] = {
{ .compatible = "barebox,sandbox-power" },
{ /* sentinel */ }
};
+MODULE_DEVICE_TABLE(of, sandbox_power_dt_ids);
-static struct driver_d sandbox_power_drv = {
+static struct driver sandbox_power_drv = {
.name = "sandbox-power",
.of_compatible = sandbox_power_dt_ids,
.probe = sandbox_power_probe,
diff --git a/arch/sandbox/board/stickypage.S b/arch/sandbox/board/stickypage.S
index f1915ab986..1d3861c373 100644
--- a/arch/sandbox/board/stickypage.S
+++ b/arch/sandbox/board/stickypage.S
@@ -1,5 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */
+.section .note.GNU-stack,"",%progbits
+.section .rodata.stickypage,"a"
+
.globl stickypage;
stickypage:
diff --git a/arch/sandbox/board/watchdog.c b/arch/sandbox/board/watchdog.c
index daaf549642..074c96a8a9 100644
--- a/arch/sandbox/board/watchdog.c
+++ b/arch/sandbox/board/watchdog.c
@@ -7,7 +7,7 @@
#include <of.h>
#include <watchdog.h>
#include <linux/nvmem-consumer.h>
-#include <reset_source.h>
+#include <asm/reset_source.h>
struct sandbox_watchdog {
struct watchdog wdd;
@@ -30,18 +30,17 @@ static int sandbox_watchdog_set_timeout(struct watchdog *wdd, unsigned int timeo
if (timeout > wdd->timeout_max)
return -EINVAL;
- nvmem_cell_write(wd->reset_source_cell, &(u8) { RESET_WDG }, 1);
+ sandbox_save_reset_source(wd->reset_source_cell, RESET_WDG);
linux_watchdog_set_timeout(timeout);
return 0;
}
-static int sandbox_watchdog_probe(struct device_d *dev)
+static int sandbox_watchdog_probe(struct device *dev)
{
- struct device_node *np = dev->device_node;
+ struct device_node *np = dev->of_node;
struct sandbox_watchdog *wd;
struct watchdog *wdd;
- int ret;
wd = xzalloc(sizeof(*wd));
@@ -50,23 +49,17 @@ static int sandbox_watchdog_probe(struct device_d *dev)
wdd->set_timeout = sandbox_watchdog_set_timeout;
wdd->timeout_max = 1000;
- wd->cant_disable = of_property_read_bool(np, "barebox,cant-disable");
-
- ret = watchdog_register(wdd);
- if (ret) {
- dev_err(dev, "Failed to register watchdog device\n");
- return ret;
- }
-
- wd->reset_source_cell = of_nvmem_cell_get(dev->device_node, "reset-source");
+ wd->reset_source_cell = of_nvmem_cell_get(np, "reset-source");
if (IS_ERR(wd->reset_source_cell)) {
- dev_warn(dev, "No reset source info available: %pe\n", wd->reset_source_cell);
- goto out;
+ if (PTR_ERR(wd->reset_source_cell) != -EPROBE_DEFER)
+ dev_warn(dev, "No reset source info available: %pe\n",
+ wd->reset_source_cell);
+ wd->reset_source_cell = NULL;
}
-out:
- dev_info(dev, "probed\n");
- return 0;
+ wd->cant_disable = of_property_read_bool(np, "barebox,cant-disable");
+
+ return watchdog_register(wdd);
}
@@ -74,8 +67,9 @@ static __maybe_unused struct of_device_id sandbox_watchdog_dt_ids[] = {
{ .compatible = "barebox,sandbox-watchdog" },
{ /* sentinel */ }
};
+MODULE_DEVICE_TABLE(of, sandbox_watchdog_dt_ids);
-static struct driver_d sandbox_watchdog_drv = {
+static struct driver sandbox_watchdog_drv = {
.name = "sandbox-watchdog",
.of_compatible = sandbox_watchdog_dt_ids,
.probe = sandbox_watchdog_probe,
diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig
index 881762444b..1bb98c550c 100644
--- a/arch/sandbox/configs/sandbox_defconfig
+++ b/arch/sandbox/configs/sandbox_defconfig
@@ -86,6 +86,7 @@ CONFIG_CMD_OF_FIXUP_STATUS=y
CONFIG_CMD_OF_OVERLAY=y
CONFIG_CMD_OFTREE=y
CONFIG_CMD_TIME=y
+CONFIG_CMD_UPTIME=y
CONFIG_CMD_STATE=y
CONFIG_CMD_DHRYSTONE=y
CONFIG_CMD_SPD_DECODE=y
@@ -95,7 +96,9 @@ CONFIG_NET_NFS=y
CONFIG_NET_NETCONSOLE=y
CONFIG_NET_SNTP=y
CONFIG_NET_FASTBOOT=y
+CONFIG_FEATURE_CONTROLLER=y
CONFIG_OFDEVICE=y
+# CONFIG_FEATURE_CONTROLLER_FIXUP is not set
CONFIG_OF_BAREBOX_DRIVERS=y
CONFIG_OF_BAREBOX_ENV_IN_FS=y
CONFIG_OF_OVERLAY_LIVE=y
@@ -146,7 +149,6 @@ CONFIG_XZ_DECOMPRESS=y
CONFIG_BASE64=y
CONFIG_LZO_DECOMPRESS=y
CONFIG_BMP=y
-CONFIG_PNG=y
CONFIG_FONT_8x16=y
CONFIG_FONT_7x14=y
CONFIG_FONT_MINI_4x6=y
diff --git a/arch/sandbox/dts/Makefile b/arch/sandbox/dts/Makefile
index 9af91cb72c..79625b103e 100644
--- a/arch/sandbox/dts/Makefile
+++ b/arch/sandbox/dts/Makefile
@@ -7,4 +7,4 @@ obj-$(CONFIG_OFTREE) += \
# created.
obj- += dummy.o
-clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts
+clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.z
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 5b2cab219e..f3fe6ce65c 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -31,6 +31,8 @@
backend = <&part_state>;
backend-storage-type = "direct";
backend-stridesize = <64>;
+ /* suppres sandbox warnings when stickypage is missing */
+ barebox,feature-gates = <&stickypage>;
#address-cells = <1>;
#size-cells = <1>;
@@ -54,10 +56,11 @@
};
stickypage: stickypage {
- compatible = "barebox,hostfile", "syscon", "simple-mfd";
- barebox,filename = "$build/stickypage.bin";
+ compatible = "barebox,stickypage", "syscon";
reg = <0 0 0 4096>;
barebox,cdev; /* no caching allowed */
+ barebox,feature-controller;
+ #feature-cells = <0>;
bmode: reboot-mode {
compatible = "nvmem-reboot-mode";
diff --git a/arch/sandbox/include/asm/barebox.lds.h b/arch/sandbox/include/asm/barebox.lds.h
new file mode 100644
index 0000000000..540d740959
--- /dev/null
+++ b/arch/sandbox/include/asm/barebox.lds.h
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <asm-generic/barebox.lds.h>
diff --git a/arch/sandbox/include/asm/common.h b/arch/sandbox/include/asm/common.h
index 66ed2f5e9c..002dfb52b5 100644
--- a/arch/sandbox/include/asm/common.h
+++ b/arch/sandbox/include/asm/common.h
@@ -3,6 +3,4 @@
#ifndef ASM_COMMON_H
#define ASM_COMMON_H
-#define ARCH_HAS_CTRLC
-
#endif /* ASM_COMMON_H */
diff --git a/arch/sandbox/include/asm/debug_ll.h b/arch/sandbox/include/asm/debug_ll.h
new file mode 100644
index 0000000000..7bef871058
--- /dev/null
+++ b/arch/sandbox/include/asm/debug_ll.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_DEBUG_LL__
+#define __ASM_DEBUG_LL__
+
+#undef putchar
+
+static inline void PUTC_LL(char ch)
+{
+ int putchar(int c);
+ putchar(ch);
+}
+
+#define putchar barebox_putchar
+
+#endif /* __ASM_DEBUG_LL__ */
diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h
index 958d10e2a1..cafbb7fe6a 100644
--- a/arch/sandbox/include/asm/dma.h
+++ b/arch/sandbox/include/asm/dma.h
@@ -12,11 +12,7 @@
#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));
-}
+#define DMA_ALIGNMENT 64
#define dma_alloc_coherent dma_alloc_coherent
static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
@@ -43,15 +39,15 @@ static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
free(mem);
}
-#define dma_sync_single_for_cpu dma_sync_single_for_cpu
-static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
- enum dma_data_direction dir)
+#define arch_sync_dma_for_cpu arch_sync_dma_for_cpu
+static inline void arch_sync_dma_for_cpu(void *vaddr, size_t size,
+ enum dma_data_direction dir)
{
}
-#define dma_sync_single_for_device dma_sync_single_for_device
-static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
- enum dma_data_direction dir)
+#define arch_sync_dma_for_device arch_sync_dma_for_device
+static inline void arch_sync_dma_for_device(void *vaddr, size_t size,
+ enum dma_data_direction dir)
{
}
diff --git a/arch/sandbox/include/asm/linkage.h b/arch/sandbox/include/asm/linkage.h
new file mode 100644
index 0000000000..1d78d9169b
--- /dev/null
+++ b/arch/sandbox/include/asm/linkage.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_LINKAGE_H
+#define __ASM_LINKAGE_H
+
+/* referenced by <linux/linkage.h> */
+
+#endif
diff --git a/arch/sandbox/include/asm/reset_source.h b/arch/sandbox/include/asm/reset_source.h
new file mode 100644
index 0000000000..1690299c47
--- /dev/null
+++ b/arch/sandbox/include/asm/reset_source.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef __SANDBOX_RESET_SOURCE_H
+#define __SANDBOX_RESET_SOURCE_H
+
+#include <reset_source.h>
+#include <linux/nvmem-consumer.h>
+
+static inline void sandbox_save_reset_source(struct nvmem_cell *reset_source_cell,
+ enum reset_src_type src)
+{
+ if (reset_source_cell)
+ WARN_ON(nvmem_cell_write(reset_source_cell, &(u8) { src }, 1) <= 0);
+}
+
+#endif
diff --git a/arch/sandbox/include/asm/word-at-a-time.h b/arch/sandbox/include/asm/word-at-a-time.h
new file mode 100644
index 0000000000..f6306fb896
--- /dev/null
+++ b/arch/sandbox/include/asm/word-at-a-time.h
@@ -0,0 +1,2 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#include <asm-generic/word-at-a-time.h>
diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h
index 1584d8065c..f4d91f08de 100644
--- a/arch/sandbox/mach-sandbox/include/mach/linux.h
+++ b/arch/sandbox/mach-sandbox/include/mach/linux.h
@@ -5,9 +5,9 @@
struct hf_info;
-struct device_d;
+struct device;
-int sandbox_add_device(struct device_d *dev);
+int sandbox_add_device(struct device *dev);
struct fb_bitfield;
@@ -15,7 +15,7 @@ int linux_register_device(const char *name, void *start, void *end);
int tap_alloc(const char *dev);
uint64_t linux_get_time(void);
int linux_open(const char *filename, int readwrite);
-const char *linux_get_builddir(void);
+char *linux_get_stickypage_path(void);
int linux_open_hostfile(struct hf_info *hf);
int linux_read(int fd, void *buf, size_t count);
int linux_read_nonblock(int fd, void *buf, size_t count);
diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile
index ebcbe5833b..055ce1a316 100644
--- a/arch/sandbox/os/Makefile
+++ b/arch/sandbox/os/Makefile
@@ -20,8 +20,8 @@ endif
obj-y = common.o tap.o setjmp.o
obj-$(CONFIG_MALLOC_LIBC) += libc_malloc.o
-CFLAGS_sdl.o = $(shell pkg-config sdl2 --cflags)
+CFLAGS_sdl.o = $(shell $(PKG_CONFIG) sdl2 --cflags)
obj-$(CONFIG_SDL) += sdl.o
-CFLAGS_ftdi.o = $(shell pkg-config libftdi1 --cflags)
+CFLAGS_ftdi.o = $(shell $(PKG_CONFIG) libftdi1 --cflags)
obj-$(CONFIG_GPIO_LIBFTDI1) += ftdi.o
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 2878eda29e..3446074f99 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -75,6 +75,15 @@ static void cookmode(void)
tcsetattr(0, TCSANOW, &term_orig);
}
+static char *stickypage_path;
+
+static void prepare_exit(void)
+{
+ cookmode();
+ if (stickypage_path)
+ remove(stickypage_path);
+}
+
int linux_tstc(int fd)
{
struct timeval tv = {
@@ -122,7 +131,7 @@ uint64_t linux_get_time(void)
void __attribute__((noreturn)) linux_exit(void)
{
- cookmode();
+ prepare_exit();
exit(0);
}
@@ -167,7 +176,7 @@ void linux_reexec(void)
void linux_hang(void)
{
- cookmode();
+ prepare_exit();
/* falls through to generic hang() */
}
@@ -329,19 +338,60 @@ static int add_image(const char *_str, char *devname_template, int *devname_numb
return ret;
}
-const char *linux_get_builddir(void)
+extern uint8_t stickypage[4096];
+
+char *linux_get_stickypage_path(void)
{
- static char path[4097];
- int ret;
+ size_t nwritten;
+ ssize_t ret;
+ int fd;
- if (!path[0]) {
- ret = selfpath(path, sizeof(path));
- if (ret < 0)
- return NULL;
- dirname(path);
+ ret = asprintf(&stickypage_path, "%s/barebox/stickypage.%lu",
+ getenv("XDG_RUNTIME_DIR") ?: "/run", (long)getpid());
+ if (ret < 0)
+ goto err_asprintf;
+
+ ret = mkdir(dirname(stickypage_path), 0755);
+ if (ret < 0 && errno != EEXIST) {
+ perror("mkdir");
+ goto err_creat;
}
- return path;
+ stickypage_path[strlen(stickypage_path)] = '/';
+
+ fd = open(stickypage_path, O_CREAT | O_WRONLY | O_TRUNC | O_EXCL, 0644);
+ if (fd < 0) {
+ if (errno == EEXIST)
+ return stickypage_path;
+
+ perror("open");
+ goto err_creat;
+ }
+
+ for (nwritten = 0; nwritten < sizeof(stickypage); ) {
+ ret = write(fd, &stickypage[nwritten], sizeof(stickypage) - nwritten);
+ if (ret < 0) {
+ if (errno == EINTR || errno == EAGAIN)
+ continue;
+ perror("write");
+ goto err_write;
+ }
+
+ nwritten += ret;
+ }
+
+ close(fd);
+
+ return stickypage_path;
+
+err_write:
+ close(fd);
+err_creat:
+ free(stickypage_path);
+err_asprintf:
+ stickypage_path = NULL;
+
+ return NULL;
}
int linux_open_hostfile(struct hf_info *hf)
@@ -469,7 +519,7 @@ int main(int argc, char *argv[])
char *aux;
#ifdef CONFIG_ASAN
- __sanitizer_set_death_callback(cookmode);
+ __sanitizer_set_death_callback(prepare_exit);
#endif
while (1) {
diff --git a/arch/sandbox/os/libc_malloc.c b/arch/sandbox/os/libc_malloc.c
index 74e3e26805..975c41b0ec 100644
--- a/arch/sandbox/os/libc_malloc.c
+++ b/arch/sandbox/os/libc_malloc.c
@@ -6,18 +6,30 @@
#include <stdlib.h>
#include <malloc.h>
+#define BAREBOX_ENOMEM 12
+extern int barebox_errno;
+
void barebox_malloc_stats(void)
{
}
void *barebox_memalign(size_t alignment, size_t bytes)
{
- return memalign(alignment, bytes);
+ void *mem = memalign(alignment, bytes);
+ if (!mem)
+ barebox_errno = BAREBOX_ENOMEM;
+
+ return mem;
}
void *barebox_malloc(size_t size)
{
- return malloc(size);
+
+ void *mem = malloc(size);
+ if (!mem)
+ barebox_errno = BAREBOX_ENOMEM;
+
+ return mem;
}
void barebox_free(void *ptr)
@@ -27,10 +39,18 @@ void barebox_free(void *ptr)
void *barebox_realloc(void *ptr, size_t size)
{
- return realloc(ptr, size);
+ void *mem = realloc(ptr, size);
+ if (!mem)
+ barebox_errno = BAREBOX_ENOMEM;
+
+ return mem;
}
void *barebox_calloc(size_t n, size_t elem_size)
{
- return calloc(n, elem_size);
+ void *mem = calloc(n, elem_size);
+ if (!mem)
+ barebox_errno = BAREBOX_ENOMEM;
+
+ return mem;
}