summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-11-14 16:54:37 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-11-14 16:54:37 +0100
commit66544641b2dd00c37e16d8e1ac39a34ec4e57cb8 (patch)
treee6da99bd0d182f7f49a5c414425a4d40265274d4
parent5f41ca465e2afae789ac76faa8dcfbac849b4ff9 (diff)
parenta4b49c69c3ad1cf0e92943921a699fbe586b5706 (diff)
downloadbarebox-66544641b2dd00c37e16d8e1ac39a34ec4e57cb8.tar.gz
barebox-66544641b2dd00c37e16d8e1ac39a34ec4e57cb8.tar.xz
Merge branch 'for-next/misc'
-rw-r--r--Makefile10
-rw-r--r--arch/arm/configs/am335x_mlo_defconfig1
-rw-r--r--arch/arm/configs/am35xx_pfc200_xload_defconfig1
-rw-r--r--arch/arm/configs/archosg9_defconfig1
-rw-r--r--arch/arm/configs/archosg9_xload_defconfig1
-rw-r--r--arch/arm/configs/omap3430_sdp3430_per_uart_defconfig1
-rw-r--r--arch/arm/configs/omap3530_beagle_defconfig1
-rw-r--r--arch/arm/configs/omap3530_beagle_per_uart_defconfig1
-rw-r--r--arch/arm/configs/omap3530_beagle_xload_defconfig1
-rw-r--r--arch/arm/configs/omap3_evm_defconfig1
-rw-r--r--arch/arm/configs/omap_defconfig1
-rw-r--r--arch/arm/configs/panda_defconfig1
-rw-r--r--arch/arm/configs/panda_xload_defconfig1
-rw-r--r--arch/arm/configs/phytec-phycard-omap3-xload_defconfig1
-rw-r--r--arch/arm/configs/phytec-phycard-omap3_defconfig1
-rw-r--r--arch/arm/configs/phytec-phycard-omap4-xload_defconfig1
-rw-r--r--arch/arm/configs/phytec-phycard-omap4_defconfig1
-rw-r--r--arch/arm/configs/phytec-phycore-omap4460-xload-mmc_defconfig1
-rw-r--r--arch/arm/configs/phytec-phycore-omap4460-xload-nand_defconfig1
-rw-r--r--arch/arm/configs/phytec-phycore-omap4460_defconfig1
-rw-r--r--arch/arm/include/asm/unwind.h7
-rw-r--r--arch/arm/lib32/unwind.c116
-rw-r--r--arch/arm/mach-imx/include/mach/imx8mq.h7
-rw-r--r--arch/arm/mach-imx/romapi.c2
-rw-r--r--arch/sandbox/configs/sandbox_defconfig2
-rw-r--r--commands/Kconfig27
-rw-r--r--commands/Makefile2
-rw-r--r--commands/stat.c62
-rw-r--r--commands/uptime.c82
-rw-r--r--common/hush.c9
-rw-r--r--drivers/gpio/Kconfig6
-rw-r--r--drivers/gpio/Makefile1
-rw-r--r--drivers/gpio/gpio-latch.c195
-rw-r--r--drivers/mfd/axp20x.c2
-rw-r--r--drivers/nvmem/core.c22
-rw-r--r--drivers/of/base.c2
-rw-r--r--fs/fs.c107
-rw-r--r--include/debug_ll.h16
-rw-r--r--include/fs.h3
-rw-r--r--include/linux/bitmap.h7
-rw-r--r--include/linux/bitops.h16
-rw-r--r--include/linux/err.h2
-rw-r--r--include/string.h1
-rw-r--r--lib/Makefile2
-rw-r--r--lib/bitmap.c10
-rw-r--r--lib/hexdump.c12
-rw-r--r--lib/readline.c7
-rw-r--r--lib/string.c5
-rw-r--r--pbl/decomp.c26
-rw-r--r--test/self/Kconfig2
-rw-r--r--test/self/Makefile2
51 files changed, 687 insertions, 104 deletions
diff --git a/Makefile b/Makefile
index fc11189d23..683ed536b5 100644
--- a/Makefile
+++ b/Makefile
@@ -453,8 +453,14 @@ KBUILD_CFLAGS_MODULE := -DMODULE
LDFLAGS_barebox := -Map barebox.map
# Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
-LDFLAGS_barebox += $(call ld-option, --no-dynamic-linker)
-LDFLAGS_pbl += $(call ld-option, --no-dynamic-linker)
+LDFLAGS_common += $(call ld-option, --no-dynamic-linker)
+# Avoid 'missing .note.GNU-stack section implies executable stack' warnings on binutils 2.39+
+LDFLAGS_common += -z noexecstack
+# Avoid '... has a LOAD segment with RWX permissions' warnings on binutils 2.39+
+LDFLAGS_common += $(call ld-option,--no-warn-rwx-segments)
+
+LDFLAGS_barebox += $(LDFLAGS_common)
+LDFLAGS_pbl += $(LDFLAGS_common)
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL PYTHON3 UTS_MACHINE
diff --git a/arch/arm/configs/am335x_mlo_defconfig b/arch/arm/configs/am335x_mlo_defconfig
index 83bb20e4b5..57602ba309 100644
--- a/arch/arm/configs/am335x_mlo_defconfig
+++ b/arch/arm/configs/am335x_mlo_defconfig
@@ -21,7 +21,6 @@ CONFIG_SHELL_NONE=y
CONFIG_CONSOLE_ACTIVATE_NONE=y
CONFIG_OFDEVICE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
CONFIG_DRIVER_SPI_OMAP3=y
CONFIG_MTD=y
# CONFIG_MTD_WRITE is not set
diff --git a/arch/arm/configs/am35xx_pfc200_xload_defconfig b/arch/arm/configs/am35xx_pfc200_xload_defconfig
index da55382f05..710e39ff61 100644
--- a/arch/arm/configs/am35xx_pfc200_xload_defconfig
+++ b/arch/arm/configs/am35xx_pfc200_xload_defconfig
@@ -17,7 +17,6 @@ CONFIG_SHELL_NONE=y
# CONFIG_TIMESTAMP is not set
CONFIG_CONSOLE_SIMPLE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
# CONFIG_SPI is not set
CONFIG_MTD=y
# CONFIG_MTD_WRITE is not set
diff --git a/arch/arm/configs/archosg9_defconfig b/arch/arm/configs/archosg9_defconfig
index aafd849185..dd509fca72 100644
--- a/arch/arm/configs/archosg9_defconfig
+++ b/arch/arm/configs/archosg9_defconfig
@@ -67,7 +67,6 @@ CONFIG_CMD_TIME=y
CONFIG_NET=y
CONFIG_NET_NETCONSOLE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT=y
CONFIG_NET_USB=y
CONFIG_NET_USB_SMSC95XX=y
diff --git a/arch/arm/configs/archosg9_xload_defconfig b/arch/arm/configs/archosg9_xload_defconfig
index 27f471cf0b..b6a0475d40 100644
--- a/arch/arm/configs/archosg9_xload_defconfig
+++ b/arch/arm/configs/archosg9_xload_defconfig
@@ -14,7 +14,6 @@ CONFIG_SHELL_NONE=y
# CONFIG_TIMESTAMP is not set
CONFIG_CONSOLE_SIMPLE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT=y
# CONFIG_SPI is not set
CONFIG_MCI=y
diff --git a/arch/arm/configs/omap3430_sdp3430_per_uart_defconfig b/arch/arm/configs/omap3430_sdp3430_per_uart_defconfig
index d43355cdf1..646a392b6b 100644
--- a/arch/arm/configs/omap3430_sdp3430_per_uart_defconfig
+++ b/arch/arm/configs/omap3430_sdp3430_per_uart_defconfig
@@ -23,5 +23,4 @@ CONFIG_CMD_LOADB=y
# CONFIG_CMD_CLEAR is not set
# CONFIG_CMD_ECHO is not set
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
# CONFIG_SPI is not set
diff --git a/arch/arm/configs/omap3530_beagle_defconfig b/arch/arm/configs/omap3530_beagle_defconfig
index 5d09abf615..e959bdfde3 100644
--- a/arch/arm/configs/omap3530_beagle_defconfig
+++ b/arch/arm/configs/omap3530_beagle_defconfig
@@ -72,7 +72,6 @@ CONFIG_NET=y
CONFIG_NET_NFS=y
CONFIG_NET_NETCONSOLE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
CONFIG_NET_USB=y
CONFIG_NET_USB_ASIX=y
CONFIG_NET_USB_SMSC95XX=y
diff --git a/arch/arm/configs/omap3530_beagle_per_uart_defconfig b/arch/arm/configs/omap3530_beagle_per_uart_defconfig
index e4112b4910..2439bd955e 100644
--- a/arch/arm/configs/omap3530_beagle_per_uart_defconfig
+++ b/arch/arm/configs/omap3530_beagle_per_uart_defconfig
@@ -22,5 +22,4 @@ CONFIG_CMD_LOADB=y
# CONFIG_CMD_CLEAR is not set
# CONFIG_CMD_ECHO is not set
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
# CONFIG_SPI is not set
diff --git a/arch/arm/configs/omap3530_beagle_xload_defconfig b/arch/arm/configs/omap3530_beagle_xload_defconfig
index e9484ed852..0a47479f18 100644
--- a/arch/arm/configs/omap3530_beagle_xload_defconfig
+++ b/arch/arm/configs/omap3530_beagle_xload_defconfig
@@ -17,7 +17,6 @@ CONFIG_SHELL_NONE=y
# CONFIG_TIMESTAMP is not set
CONFIG_CONSOLE_SIMPLE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
# CONFIG_SPI is not set
CONFIG_MTD=y
# CONFIG_MTD_WRITE is not set
diff --git a/arch/arm/configs/omap3_evm_defconfig b/arch/arm/configs/omap3_evm_defconfig
index 973acbff68..8c5df029a7 100644
--- a/arch/arm/configs/omap3_evm_defconfig
+++ b/arch/arm/configs/omap3_evm_defconfig
@@ -21,5 +21,4 @@ CONFIG_CMD_RESET=y
# CONFIG_CMD_RM is not set
# CONFIG_CMD_RMDIR is not set
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
# CONFIG_SPI is not set
diff --git a/arch/arm/configs/omap_defconfig b/arch/arm/configs/omap_defconfig
index ae4d1a67da..433d9bdd7d 100644
--- a/arch/arm/configs/omap_defconfig
+++ b/arch/arm/configs/omap_defconfig
@@ -100,7 +100,6 @@ CONFIG_NET_NFS=y
CONFIG_NET_NETCONSOLE=y
CONFIG_OF_BAREBOX_DRIVERS=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
CONFIG_DRIVER_NET_CPSW=y
CONFIG_DRIVER_NET_DAVINCI_EMAC=y
CONFIG_MICREL_PHY=y
diff --git a/arch/arm/configs/panda_defconfig b/arch/arm/configs/panda_defconfig
index 9c1efe168a..b199e7990b 100644
--- a/arch/arm/configs/panda_defconfig
+++ b/arch/arm/configs/panda_defconfig
@@ -62,7 +62,6 @@ CONFIG_CMD_TIME=y
CONFIG_NET=y
CONFIG_NET_NETCONSOLE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
CONFIG_NET_USB=y
CONFIG_NET_USB_SMSC95XX=y
# CONFIG_SPI is not set
diff --git a/arch/arm/configs/panda_xload_defconfig b/arch/arm/configs/panda_xload_defconfig
index e3d87c42dd..bc33882c85 100644
--- a/arch/arm/configs/panda_xload_defconfig
+++ b/arch/arm/configs/panda_xload_defconfig
@@ -12,7 +12,6 @@ CONFIG_SHELL_NONE=y
# CONFIG_TIMESTAMP is not set
CONFIG_CONSOLE_SIMPLE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
# CONFIG_SPI is not set
CONFIG_MCI=y
CONFIG_MCI_STARTUP=y
diff --git a/arch/arm/configs/phytec-phycard-omap3-xload_defconfig b/arch/arm/configs/phytec-phycard-omap3-xload_defconfig
index 6eab808f7c..26a539f7f7 100644
--- a/arch/arm/configs/phytec-phycard-omap3-xload_defconfig
+++ b/arch/arm/configs/phytec-phycard-omap3-xload_defconfig
@@ -17,7 +17,6 @@ CONFIG_SHELL_NONE=y
# CONFIG_TIMESTAMP is not set
CONFIG_CONSOLE_SIMPLE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
# CONFIG_SPI is not set
CONFIG_MTD=y
# CONFIG_MTD_WRITE is not set
diff --git a/arch/arm/configs/phytec-phycard-omap3_defconfig b/arch/arm/configs/phytec-phycard-omap3_defconfig
index 6cc1c1e80b..a9abf12a13 100644
--- a/arch/arm/configs/phytec-phycard-omap3_defconfig
+++ b/arch/arm/configs/phytec-phycard-omap3_defconfig
@@ -54,7 +54,6 @@ CONFIG_NET_NFS=y
CONFIG_NET_NETCONSOLE=y
CONFIG_NET_RESOLV=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
CONFIG_DRIVER_NET_SMC911X=y
# CONFIG_SPI is not set
CONFIG_MTD=y
diff --git a/arch/arm/configs/phytec-phycard-omap4-xload_defconfig b/arch/arm/configs/phytec-phycard-omap4-xload_defconfig
index af3ada6343..a1859140db 100644
--- a/arch/arm/configs/phytec-phycard-omap4-xload_defconfig
+++ b/arch/arm/configs/phytec-phycard-omap4-xload_defconfig
@@ -13,7 +13,6 @@ CONFIG_SHELL_NONE=y
# CONFIG_TIMESTAMP is not set
CONFIG_CONSOLE_SIMPLE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
# CONFIG_SPI is not set
CONFIG_MTD=y
# CONFIG_MTD_WRITE is not set
diff --git a/arch/arm/configs/phytec-phycard-omap4_defconfig b/arch/arm/configs/phytec-phycard-omap4_defconfig
index 2f3970725d..a0bb846a6d 100644
--- a/arch/arm/configs/phytec-phycard-omap4_defconfig
+++ b/arch/arm/configs/phytec-phycard-omap4_defconfig
@@ -36,7 +36,6 @@ CONFIG_CMD_GPIO=y
CONFIG_NET=y
CONFIG_NET_NFS=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
CONFIG_DRIVER_NET_KS8851_MLL=y
# CONFIG_SPI is not set
CONFIG_MTD=y
diff --git a/arch/arm/configs/phytec-phycore-omap4460-xload-mmc_defconfig b/arch/arm/configs/phytec-phycore-omap4460-xload-mmc_defconfig
index 61f85c837f..19365a6fcd 100644
--- a/arch/arm/configs/phytec-phycore-omap4460-xload-mmc_defconfig
+++ b/arch/arm/configs/phytec-phycore-omap4460-xload-mmc_defconfig
@@ -15,7 +15,6 @@ CONFIG_SHELL_NONE=y
# CONFIG_TIMESTAMP is not set
CONFIG_CONSOLE_SIMPLE=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
# CONFIG_SPI is not set
CONFIG_MCI=y
CONFIG_MCI_STARTUP=y
diff --git a/arch/arm/configs/phytec-phycore-omap4460-xload-nand_defconfig b/arch/arm/configs/phytec-phycore-omap4460-xload-nand_defconfig
index 77f124b33f..14cab44b5d 100644
--- a/arch/arm/configs/phytec-phycore-omap4460-xload-nand_defconfig
+++ b/arch/arm/configs/phytec-phycore-omap4460-xload-nand_defconfig
@@ -16,7 +16,6 @@ CONFIG_SHELL_NONE=y
CONFIG_CONSOLE_SIMPLE=y
CONFIG_PARTITION=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
# CONFIG_SPI is not set
CONFIG_MTD=y
# CONFIG_MTD_WRITE is not set
diff --git a/arch/arm/configs/phytec-phycore-omap4460_defconfig b/arch/arm/configs/phytec-phycore-omap4460_defconfig
index e65a76570b..7d5369cb23 100644
--- a/arch/arm/configs/phytec-phycore-omap4460_defconfig
+++ b/arch/arm/configs/phytec-phycore-omap4460_defconfig
@@ -49,7 +49,6 @@ CONFIG_CMD_TIME=y
CONFIG_NET=y
CONFIG_NET_NFS=y
CONFIG_DRIVER_SERIAL_NS16550=y
-CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
CONFIG_DRIVER_NET_SMC911X=y
CONFIG_SMSC_PHY=y
# CONFIG_SPI is not set
diff --git a/arch/arm/include/asm/unwind.h b/arch/arm/include/asm/unwind.h
index 319527ec9b..37aba2aa4c 100644
--- a/arch/arm/include/asm/unwind.h
+++ b/arch/arm/include/asm/unwind.h
@@ -16,14 +16,15 @@ enum unwind_reason_code {
};
struct unwind_idx {
- unsigned long addr;
+ unsigned long addr_offset;
unsigned long insn;
};
struct unwind_table {
struct list_head list;
- struct unwind_idx *start;
- struct unwind_idx *stop;
+ const struct unwind_idx *start;
+ const struct unwind_idx *origin;
+ const struct unwind_idx *stop;
unsigned long begin_addr;
unsigned long end_addr;
};
diff --git a/arch/arm/lib32/unwind.c b/arch/arm/lib32/unwind.c
index 79bf7420d7..6f73cb1b73 100644
--- a/arch/arm/lib32/unwind.c
+++ b/arch/arm/lib32/unwind.c
@@ -28,7 +28,7 @@ EXPORT_SYMBOL(__aeabi_unwind_cpp_pr2);
struct unwind_ctrl_block {
unsigned long vrs[16]; /* virtual register set */
- unsigned long *insn; /* pointer to the current instructions word */
+ const unsigned long *insn; /* pointer to the current instructions word */
int entries; /* number of entries left to interpret */
int byte; /* current byte number in the instructions word */
};
@@ -42,8 +42,9 @@ enum regs {
#define THREAD_SIZE 8192
-extern struct unwind_idx __start_unwind_idx[];
-extern struct unwind_idx __stop_unwind_idx[];
+extern const struct unwind_idx __start_unwind_idx[];
+static const struct unwind_idx *__origin_unwind_idx;
+extern const struct unwind_idx __stop_unwind_idx[];
/* Convert a prel31 symbol to an absolute address */
#define prel31_to_addr(ptr) \
@@ -71,44 +72,99 @@ static void dump_backtrace_entry(unsigned long where, unsigned long from,
}
/*
- * Binary search in the unwind index. The entries entries are
+ * Binary search in the unwind index. The entries are
* guaranteed to be sorted in ascending order by the linker.
+ *
+ * start = first entry
+ * origin = first entry with positive offset (or stop if there is no such entry)
+ * stop - 1 = last entry
*/
-static struct unwind_idx *search_index(unsigned long addr,
- struct unwind_idx *first,
- struct unwind_idx *last)
+static const struct unwind_idx *search_index(unsigned long addr,
+ const struct unwind_idx *start,
+ const struct unwind_idx *origin,
+ const struct unwind_idx *stop)
{
- pr_debug("%s(%08lx, %p, %p)\n", __func__, addr, first, last);
+ unsigned long addr_prel31;
+
+ pr_debug("%s(%08lx, %p, %p, %p)\n",
+ __func__, addr, start, origin, stop);
+
+ /*
+ * only search in the section with the matching sign. This way the
+ * prel31 numbers can be compared as unsigned longs.
+ */
+ if (addr < (unsigned long)start)
+ /* negative offsets: [start; origin) */
+ stop = origin;
+ else
+ /* positive offsets: [origin; stop) */
+ start = origin;
+
+ /* prel31 for address relavive to start */
+ addr_prel31 = (addr - (unsigned long)start) & 0x7fffffff;
+
+ while (start < stop - 1) {
+ const struct unwind_idx *mid = start + ((stop - start) >> 1);
+
+ /*
+ * As addr_prel31 is relative to start an offset is needed to
+ * make it relative to mid.
+ */
+ if (addr_prel31 - ((unsigned long)mid - (unsigned long)start) <
+ mid->addr_offset)
+ stop = mid;
+ else {
+ /* keep addr_prel31 relative to start */
+ addr_prel31 -= ((unsigned long)mid -
+ (unsigned long)start);
+ start = mid;
+ }
+ }
- if (addr < first->addr) {
+ if (likely(start->addr_offset <= addr_prel31))
+ return start;
+ else {
pr_warning("unwind: Unknown symbol address %08lx\n", addr);
return NULL;
- } else if (addr >= last->addr)
- return last;
+ }
+}
- while (first < last - 1) {
- struct unwind_idx *mid = first + ((last - first + 1) >> 1);
+static const struct unwind_idx *unwind_find_origin(
+ const struct unwind_idx *start, const struct unwind_idx *stop)
+{
+ pr_debug("%s(%p, %p)\n", __func__, start, stop);
+ while (start < stop - 1) {
+ const struct unwind_idx *mid = start + ((stop - start) >> 1);
- if (addr < mid->addr)
- last = mid;
+ if (mid->addr_offset >= 0x40000000)
+ /* negative offset */
+ start = mid;
else
- first = mid;
+ /* positive offset */
+ stop = mid;
}
- return first;
-}
+ pr_debug("%s -> %p\n", __func__, stop);
+ return stop;
+ }
-static struct unwind_idx *unwind_find_idx(unsigned long addr)
+static const struct unwind_idx *unwind_find_idx(unsigned long addr)
{
- struct unwind_idx *idx = NULL;
+ const struct unwind_idx *idx = NULL;
pr_debug("%s(%08lx)\n", __func__, addr);
- if (is_kernel_text(addr))
+ if (is_kernel_text(addr)) {
+ if (unlikely(!__origin_unwind_idx))
+ __origin_unwind_idx =
+ unwind_find_origin(__start_unwind_idx,
+ __stop_unwind_idx);
+
/* main unwind table */
idx = search_index(addr, __start_unwind_idx,
- __stop_unwind_idx - 1);
- else {
+ __origin_unwind_idx,
+ __stop_unwind_idx);
+ } else {
/* module unwinding not supported */
}
@@ -232,7 +288,7 @@ static int unwind_exec_insn(struct unwind_ctrl_block *ctrl)
int unwind_frame(struct stackframe *frame)
{
unsigned long high, low;
- struct unwind_idx *idx;
+ const struct unwind_idx *idx;
struct unwind_ctrl_block ctrl;
/* only go to a higher address on the stack */
@@ -342,15 +398,3 @@ void dump_stack(void)
{
unwind_backtrace(NULL);
}
-
-static int unwind_init(void)
-{
- struct unwind_idx *idx;
-
- /* Convert the symbol addresses to absolute values */
- for (idx = __start_unwind_idx; idx < __stop_unwind_idx; idx++)
- idx->addr = prel31_to_addr(&idx->addr);
-
- return 0;
-}
-core_initcall(unwind_init);
diff --git a/arch/arm/mach-imx/include/mach/imx8mq.h b/arch/arm/mach-imx/include/mach/imx8mq.h
index d02c5f23cf..e58a3935f7 100644
--- a/arch/arm/mach-imx/include/mach/imx8mq.h
+++ b/arch/arm/mach-imx/include/mach/imx8mq.h
@@ -58,10 +58,13 @@ static inline int imx8mq_cpu_revision(void)
{
void __iomem *anatop = IOMEM(MX8MQ_ANATOP_BASE_ADDR);
void __iomem *ocotp = IOMEM(MX8MQ_OCOTP_BASE_ADDR);
+ void __iomem *rom = IOMEM(0x0);
uint32_t revision = FIELD_GET(DIGPROG_MINOR,
readl(anatop + MX8MQ_ANATOP_DIGPROG));
uint32_t rom_version;
+ OPTIMIZER_HIDE_VAR(rom);
+
if (revision != IMX_CHIP_REV_1_0)
return revision;
/*
@@ -74,9 +77,9 @@ static inline int imx8mq_cpu_revision(void)
* For B0 chip, the DIGPROG is not updated, still TO1.0.
* we have to check ROM version further
*/
- rom_version = readb(IOMEM(IMX8MQ_ROM_VERSION_A0));
+ rom_version = readb(IOMEM(rom + IMX8MQ_ROM_VERSION_A0));
if (rom_version != IMX_CHIP_REV_1_0) {
- rom_version = readb(IOMEM(IMX8MQ_ROM_VERSION_B0));
+ rom_version = readb(IOMEM(rom + IMX8MQ_ROM_VERSION_B0));
if (rom_version >= IMX_CHIP_REV_2_0)
revision = IMX_CHIP_REV_2_0;
}
diff --git a/arch/arm/mach-imx/romapi.c b/arch/arm/mach-imx/romapi.c
index 5d00d71154..56bf7e135f 100644
--- a/arch/arm/mach-imx/romapi.c
+++ b/arch/arm/mach-imx/romapi.c
@@ -35,6 +35,8 @@ int imx8mp_bootrom_load_image(void)
{
struct rom_api *rom_api = (void *)0x980;
+ OPTIMIZER_HIDE_VAR(rom_api);
+
return imx8m_bootrom_load_image(rom_api);
}
diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig
index 881762444b..16138d9274 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
@@ -146,7 +147,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/commands/Kconfig b/commands/Kconfig
index 9894ecb9aa..a59616ad14 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -947,6 +947,20 @@ config CMD_LS
-C column format (opposite of long format)
-R list subdirectories recursively
+config CMD_STAT
+ tristate
+ prompt "stat"
+ select PRINTF_UUID
+ help
+ Display file status
+
+ Usage: stat [-L] [FILEDIR...]
+
+ Display status information about the specified files or directories.
+
+ Options:
+ -L follow symlinks
+
config CMD_MD5SUM
tristate
select COMPILE_HASH
@@ -2275,6 +2289,19 @@ config CMD_TIME
Note: This command depends on COMMAND being interruptible,
otherwise the timer may overrun resulting in incorrect results
+config CMD_UPTIME
+ bool "uptime"
+ help
+ uptime - Tell how long barebox has been running
+
+ Usage: uptime [-n]
+
+ This command formats the number of elapsed nanoseconds
+ as measured with the current clocksource.
+
+ Options:
+ -n output elapsed time in nanoseconds
+
config CMD_STATE
tristate
depends on STATE
diff --git a/commands/Makefile b/commands/Makefile
index 068fbb32da..cac1d4f253 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_CMD_POWEROFF) += poweroff.o
obj-$(CONFIG_CMD_GO) += go.o
obj-$(CONFIG_CMD_PARTITION) += partition.o
obj-$(CONFIG_CMD_LS) += ls.o
+obj-$(CONFIG_CMD_STAT) += stat.o
obj-$(CONFIG_CMD_CD) += cd.o
obj-$(CONFIG_CMD_PWD) += pwd.o
obj-$(CONFIG_CMD_MKDIR) += mkdir.o
@@ -79,6 +80,7 @@ obj-$(CONFIG_CMD_WD) += wd.o
obj-$(CONFIG_CMD_LED_TRIGGER) += trigger.o
obj-$(CONFIG_CMD_USB) += usb.o
obj-$(CONFIG_CMD_TIME) += time.o
+obj-$(CONFIG_CMD_UPTIME) += uptime.o
obj-$(CONFIG_CMD_OFTREE) += oftree.o
obj-$(CONFIG_CMD_OF_DIFF) += of_diff.o
obj-$(CONFIG_CMD_OF_PROPERTY) += of_property.o
diff --git a/commands/stat.c b/commands/stat.c
new file mode 100644
index 0000000000..153eac50f1
--- /dev/null
+++ b/commands/stat.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// SPDX-FileCopyrightText: © 2022 Ahmad Fatoum, Pengutronix
+
+#include <common.h>
+#include <command.h>
+#include <fs.h>
+#include <linux/stat.h>
+#include <errno.h>
+#include <malloc.h>
+#include <getopt.h>
+#include <stringlist.h>
+
+static int do_stat(int argc, char *argv[])
+{
+ int (*statfn)(const char *, struct stat *) = lstat;
+ int ret, opt, exitcode = 0;
+ char **filename;
+ struct stat st;
+
+ while((opt = getopt(argc, argv, "L")) > 0) {
+ switch(opt) {
+ case 'L':
+ statfn = stat;
+ break;
+ default:
+ return COMMAND_ERROR_USAGE;
+ }
+ }
+
+ if (optind == argc)
+ return COMMAND_ERROR_USAGE;
+
+ for (filename = &argv[optind]; *filename; filename++) {
+ ret = statfn(*filename, &st);
+
+ if (ret) {
+ printf("%s: %s: %m\n", argv[0], *filename);
+ exitcode = COMMAND_ERROR;
+ continue;
+ }
+
+ stat_print(*filename, &st);
+ }
+
+ return exitcode;
+}
+
+BAREBOX_CMD_HELP_START(stat)
+BAREBOX_CMD_HELP_TEXT("Display status information about the specified files")
+BAREBOX_CMD_HELP_TEXT("or directories.")
+BAREBOX_CMD_HELP_TEXT("")
+BAREBOX_CMD_HELP_TEXT("Options:")
+BAREBOX_CMD_HELP_OPT ("-L", "follow links")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(stat)
+ .cmd = do_stat,
+ BAREBOX_CMD_DESC("display file status")
+ BAREBOX_CMD_OPTS("[-L] [FILEDIR...]")
+ BAREBOX_CMD_GROUP(CMD_GRP_FILE)
+ BAREBOX_CMD_HELP(cmd_stat_help)
+BAREBOX_CMD_END
diff --git a/commands/uptime.c b/commands/uptime.c
new file mode 100644
index 0000000000..d67538631c
--- /dev/null
+++ b/commands/uptime.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <common.h>
+#include <command.h>
+#include <clock.h>
+#include <getopt.h>
+#include <linux/math64.h>
+
+#define NSEC_PER_MINUTE (NSEC_PER_SEC * 60LL)
+#define NSEC_PER_HOUR (NSEC_PER_MINUTE * 60LL)
+#define NSEC_PER_DAY (NSEC_PER_HOUR * 24LL)
+#define NSEC_PER_WEEK (NSEC_PER_DAY * 7LL)
+
+static bool print_with_unit(u64 val, const char *unit, bool comma)
+{
+ if (!val)
+ return comma;
+
+ printf("%s%llu %s%s", comma ? ", " : "", val, unit, val > 1 ? "s" : "");
+ return true;
+}
+
+static int do_uptime(int argc, char *argv[])
+{
+ u64 timestamp, weeks, days, hours, minutes;
+ bool comma = false;
+ int opt;
+
+ timestamp = get_time_ns();
+
+ while((opt = getopt(argc, argv, "n")) > 0) {
+ switch(opt) {
+ case 'n':
+ printf("up %lluns\n", timestamp);
+ return 0;
+ default:
+ return COMMAND_ERROR_USAGE;
+ }
+ }
+
+ if (optind != argc)
+ return COMMAND_ERROR_USAGE;
+
+ printf("up ");
+
+ weeks = div64_u64_rem(timestamp, NSEC_PER_WEEK, &timestamp);
+ days = div64_u64_rem(timestamp, NSEC_PER_DAY, &timestamp);
+ hours = div64_u64_rem(timestamp, NSEC_PER_HOUR, &timestamp);
+ minutes = div64_u64_rem(timestamp, NSEC_PER_MINUTE, &timestamp);
+
+ comma = print_with_unit(weeks, "week", false);
+ comma = print_with_unit(days, "day", comma);
+ comma = print_with_unit(hours, "hour", comma);
+ comma = print_with_unit(minutes, "minute", comma);
+
+ if (!comma) {
+ u64 seconds = div64_u64_rem(timestamp, NSEC_PER_SEC, &timestamp);
+ print_with_unit(seconds, "second", false);
+ }
+
+ printf("\n");
+
+ return 0;
+}
+
+BAREBOX_CMD_HELP_START(uptime)
+BAREBOX_CMD_HELP_TEXT("This command formats the number of elapsed nanoseconds")
+BAREBOX_CMD_HELP_TEXT("as measured with the current clocksource")
+BAREBOX_CMD_HELP_TEXT("Note: Timekeeping is co-operative. If long running code does")
+BAREBOX_CMD_HELP_TEXT("not use delay/is_timeout/get_time_ns/getchar functions")
+BAREBOX_CMD_HELP_TEXT("timer may overrun resulting in incorrect results")
+BAREBOX_CMD_HELP_TEXT("Options:")
+BAREBOX_CMD_HELP_OPT ("-n", "output elapsed time in nanoseconds")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(uptime)
+ .cmd = do_uptime,
+ BAREBOX_CMD_DESC("Tell how long barebox has been running")
+ BAREBOX_CMD_OPTS("[-n]")
+ BAREBOX_CMD_GROUP(CMD_GRP_MISC)
+ BAREBOX_CMD_HELP(cmd_uptime_help)
+BAREBOX_CMD_END
diff --git a/common/hush.c b/common/hush.c
index 6a089fabf1..5138a1a45a 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -617,6 +617,7 @@ static int builtin_exit(struct p_context *ctx, struct child_prog *child,
static void remove_quotes_in_str(char *src)
{
char *trg = src;
+ bool in_double_quotes = false;
while (*src) {
if (*src == '\'') {
@@ -629,6 +630,7 @@ static void remove_quotes_in_str(char *src)
/* drop quotes */
if (*src == '"') {
+ in_double_quotes = !in_double_quotes;
src++;
continue;
}
@@ -654,6 +656,13 @@ static void remove_quotes_in_str(char *src)
continue;
}
+ /* replace '\ ' with ' ' */
+ if (!in_double_quotes && *src == '\\' && *(src + 1) == ' ') {
+ *trg++ = ' ';
+ src += 2;
+ continue;
+ }
+
*trg++ = *src++;
}
*trg = 0;
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index ab75fe4ed9..dd2b56d256 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -205,6 +205,12 @@ config GPIO_ZYNQ
help
Say yes here to support Xilinx Zynq GPIO controller.
+config GPIO_LATCH
+ tristate "GPIO latch driver"
+ help
+ Say yes here to enable a driver for GPIO multiplexers based on latches
+ connected to other GPIOs.
+
endmenu
endif
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index fcb6a232e0..90ab0a8b28 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -28,3 +28,4 @@ obj-$(CONFIG_GPIO_RASPBERRYPI_EXP) += gpio-raspberrypi-exp.o
obj-$(CONFIG_GPIO_SIFIVE) += gpio-sifive.o
obj-$(CONFIG_GPIO_STARFIVE) += gpio-starfive-vic.o
obj-$(CONFIG_GPIO_ZYNQ) += gpio-zynq.o
+obj-$(CONFIG_GPIO_LATCH) += gpio-latch.o
diff --git a/drivers/gpio/gpio-latch.c b/drivers/gpio/gpio-latch.c
new file mode 100644
index 0000000000..2a89f22401
--- /dev/null
+++ b/drivers/gpio/gpio-latch.c
@@ -0,0 +1,195 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * GPIO latch driver
+ *
+ * Copyright (C) 2022 Sascha Hauer <s.hauer@pengutronix.de>
+ *
+ * This driver implements a GPIO (or better GPO as there is no input)
+ * multiplexer based on latches like this:
+ *
+ * CLK0 ----------------------. ,--------.
+ * CLK1 -------------------. `--------|> #0 |
+ * | | |
+ * OUT0 ----------------+--|-----------|D0 Q0|-----|<
+ * OUT1 --------------+-|--|-----------|D1 Q1|-----|<
+ * OUT2 ------------+-|-|--|-----------|D2 Q2|-----|<
+ * OUT3 ----------+-|-|-|--|-----------|D3 Q3|-----|<
+ * OUT4 --------+-|-|-|-|--|-----------|D4 Q4|-----|<
+ * OUT5 ------+-|-|-|-|-|--|-----------|D5 Q5|-----|<
+ * OUT6 ----+-|-|-|-|-|-|--|-----------|D6 Q6|-----|<
+ * OUT7 --+-|-|-|-|-|-|-|--|-----------|D7 Q7|-----|<
+ * | | | | | | | | | `--------'
+ * | | | | | | | | |
+ * | | | | | | | | | ,--------.
+ * | | | | | | | | `-----------|> #1 |
+ * | | | | | | | | | |
+ * | | | | | | | `--------------|D0 Q0|-----|<
+ * | | | | | | `----------------|D1 Q1|-----|<
+ * | | | | | `------------------|D2 Q2|-----|<
+ * | | | | `--------------------|D3 Q3|-----|<
+ * | | | `----------------------|D4 Q4|-----|<
+ * | | `------------------------|D5 Q5|-----|<
+ * | `--------------------------|D6 Q6|-----|<
+ * `----------------------------|D7 Q7|-----|<
+ * `--------'
+ *
+ * The above is just an example. The actual number of number of latches and
+ * the number of inputs per latch is derived from the number of GPIOs given
+ * in the corresponding device tree properties.
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <io.h>
+#include <of.h>
+#include <gpio.h>
+#include <init.h>
+#include <of_gpio.h>
+#include <linux/bitmap.h>
+
+struct gpio_latch_priv {
+ struct gpio_chip gc;
+ int *clk_gpios;
+ int *latched_gpios;
+ int n_latched_gpios;
+ unsigned int setup_duration_ns;
+ unsigned int clock_duration_ns;
+ unsigned long *shadow;
+};
+
+static int gpio_latch_get_direction(struct gpio_chip *gc, unsigned int offset)
+{
+ return 0;
+}
+
+static void gpio_latch_set(struct gpio_chip *gc, unsigned int offset, int val)
+{
+ struct gpio_latch_priv *priv = container_of(gc, struct gpio_latch_priv, gc);
+ int latch = offset / priv->n_latched_gpios;
+ int i;
+
+ assign_bit(offset, priv->shadow, val);
+
+ for (i = 0; i < priv->n_latched_gpios; i++)
+ gpio_set_value(priv->latched_gpios[i],
+ test_bit(latch * priv->n_latched_gpios + i, priv->shadow));
+
+ ndelay(priv->setup_duration_ns);
+ gpio_set_value(priv->clk_gpios[latch], 1);
+ ndelay(priv->clock_duration_ns);
+ gpio_set_value(priv->clk_gpios[latch], 0);
+}
+static int gpio_latch_direction_output(struct gpio_chip *gc, unsigned gpio, int val)
+{
+ gpio_latch_set(gc, gpio, val);
+
+ return 0;
+}
+
+#define DURATION_NS_MAX 5000
+
+static struct gpio_ops gpio_latch_gpio_ops = {
+ .direction_output = gpio_latch_direction_output,
+ .set = gpio_latch_set,
+ .get_direction = gpio_latch_get_direction,
+};
+
+static int gpio_latch_probe(struct device_d *dev)
+{
+ struct gpio_latch_priv *priv;
+ int n_latches, i, ret;
+ struct device_node *np = dev->device_node;
+ enum of_gpio_flags flags;
+
+ priv = xzalloc(sizeof(*priv));
+
+ n_latches = of_gpio_named_count(np, "clk-gpios");
+ if (n_latches < 0) {
+ dev_err(dev, "invalid or missing clk-gpios");
+ ret = -EINVAL;
+ goto err_gpio;
+ }
+
+ priv->n_latched_gpios = of_gpio_named_count(np, "latched-gpios");
+ if (priv->n_latched_gpios < 0) {
+ dev_err(dev, "invalid or missing latched-gpios");
+ ret = -EINVAL;
+ goto err_gpio;
+ }
+
+ priv->clk_gpios = xzalloc(sizeof(int) * n_latches);
+ priv->latched_gpios = xzalloc(sizeof(int) * priv->n_latched_gpios);
+
+ for (i = 0; i < n_latches; i++) {
+ priv->clk_gpios[i] = of_get_named_gpio_flags(np, "clk-gpios",
+ i, &flags);
+ ret = gpio_request_one(priv->clk_gpios[i],
+ flags & OF_GPIO_ACTIVE_LOW ? GPIOF_ACTIVE_LOW : 0,
+ dev_name(dev));
+ if (ret) {
+ dev_err(dev, "Cannot request gpio %d: %s\n", priv->clk_gpios[i],
+ strerror(-ret));
+ goto err_gpio;
+ }
+
+ gpio_direction_output(priv->clk_gpios[i], 0);
+ }
+
+ for (i = 0; i < priv->n_latched_gpios; i++) {
+ priv->latched_gpios[i] = of_get_named_gpio_flags(np, "latched-gpios",
+ i, &flags);
+ ret = gpio_request_one(priv->latched_gpios[i],
+ flags & OF_GPIO_ACTIVE_LOW ? GPIOF_ACTIVE_LOW : 0,
+ dev_name(dev));
+ if (ret) {
+ dev_err(dev, "Cannot request gpio %d: %s\n", priv->latched_gpios[i],
+ strerror(-ret));
+ goto err_gpio;
+ }
+ }
+
+ priv->shadow = bitmap_zalloc(n_latches * priv->n_latched_gpios);
+
+ of_property_read_u32(np, "setup-duration-ns", &priv->setup_duration_ns);
+ if (priv->setup_duration_ns > DURATION_NS_MAX) {
+ dev_warn(dev, "setup-duration-ns too high, limit to %d\n",
+ DURATION_NS_MAX);
+ priv->setup_duration_ns = DURATION_NS_MAX;
+ }
+
+ of_property_read_u32(np, "clock-duration-ns", &priv->clock_duration_ns);
+ if (priv->clock_duration_ns > DURATION_NS_MAX) {
+ dev_warn(dev, "clock-duration-ns too high, limit to %d\n",
+ DURATION_NS_MAX);
+ priv->clock_duration_ns = DURATION_NS_MAX;
+ }
+
+ priv->gc.ops = &gpio_latch_gpio_ops;
+ priv->gc.ngpio = n_latches * priv->n_latched_gpios;
+ priv->gc.base = -1;
+ priv->gc.dev = dev;
+
+ return gpiochip_add(&priv->gc);
+
+err_gpio:
+ return ret;
+}
+
+static const struct of_device_id gpio_latch_ids[] = {
+ {
+ .compatible = "gpio-latch",
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct driver_d gpio_latch_driver = {
+ .name = "gpio-latch",
+ .probe = gpio_latch_probe,
+ .of_compatible = DRV_OF_COMPAT(gpio_latch_ids),
+};
+device_platform_driver(gpio_latch_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
+MODULE_DESCRIPTION("GPIO latch driver");
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 0a53eaea7c..8d9de59e7d 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -354,8 +354,6 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
if (axp20x->variant != AXP288_ID)
poweroff_handler_register(&axp20x->poweroff);
- dev_info(axp20x->dev, "AXP20X driver loaded\n");
-
return 0;
}
EXPORT_SYMBOL(axp20x_device_probe);
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index c89ad08f81..8e07bdb501 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -526,7 +526,7 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem,
int rc;
rc = nvmem->bus->read(nvmem->priv, cell->offset, buf, cell->bytes);
- if (IS_ERR_VALUE(rc))
+ if (rc)
return rc;
/* shift bits in-place */
@@ -561,7 +561,7 @@ void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
return ERR_PTR(-ENOMEM);
rc = __nvmem_cell_read(nvmem, cell, buf, len);
- if (IS_ERR_VALUE(rc)) {
+ if (rc) {
kfree(buf);
return ERR_PTR(rc);
}
@@ -591,7 +591,7 @@ static inline void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
/* setup the first byte with lsb bits from nvmem */
rc = nvmem->bus->read(nvmem->priv, cell->offset, &v, 1);
- if (IS_ERR_VALUE(rc))
+ if (rc)
return ERR_PTR(rc);
*b++ |= GENMASK(bit_offset - 1, 0) & v;
@@ -612,7 +612,7 @@ static inline void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
/* setup the last byte with msb bits from nvmem */
rc = nvmem->bus->read(nvmem->priv, cell->offset + cell->bytes - 1,
&v, 1);
- if (IS_ERR_VALUE(rc))
+ if (rc)
return ERR_PTR(rc);
*p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) & v;
@@ -652,7 +652,7 @@ int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len)
if (cell->bit_offset || cell->nbits)
kfree(buf);
- if (IS_ERR_VALUE(rc))
+ if (rc)
return rc;
return len;
@@ -680,11 +680,11 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
return -EINVAL;
rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
- if (IS_ERR_VALUE(rc))
+ if (rc)
return rc;
rc = __nvmem_cell_read(nvmem, &cell, buf, &len);
- if (IS_ERR_VALUE(rc))
+ if (rc)
return rc;
return len;
@@ -710,7 +710,7 @@ int nvmem_device_cell_write(struct nvmem_device *nvmem,
return -EINVAL;
rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
- if (IS_ERR_VALUE(rc))
+ if (rc)
return rc;
return nvmem_cell_write(&cell, buf, cell.bytes);
@@ -744,8 +744,7 @@ int nvmem_device_read(struct nvmem_device *nvmem,
return 0;
rc = nvmem->bus->read(nvmem->priv, offset, buf, bytes);
-
- if (IS_ERR_VALUE(rc))
+ if (rc)
return rc;
return bytes;
@@ -778,8 +777,7 @@ int nvmem_device_write(struct nvmem_device *nvmem,
return 0;
rc = nvmem->bus->write(nvmem->priv, offset, buf, bytes);
-
- if (IS_ERR_VALUE(rc))
+ if (rc)
return rc;
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ea2a88764b..2eee1279a9 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -32,7 +32,7 @@ bool of_node_name_eq(const struct device_node *np, const char *name)
return false;
node_name = kbasename(np->full_name);
- len = strchrnul(node_name, '@') - node_name;
+ len = strchrnul(node_name, '@') - node_name;
return (strlen(name) == len) && (strncmp(node_name, name, len) == 0);
}
diff --git a/fs/fs.c b/fs/fs.c
index 24a3319544..b5a0912405 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -67,6 +67,110 @@ char *mkmodestr(unsigned long mode, char *str)
}
EXPORT_SYMBOL(mkmodestr);
+void cdev_print(const struct cdev *cdev)
+{
+ bool uuid_set;
+
+ if (cdev->dev || cdev->master || cdev->partname) {
+ printf("Origin: %s", dev_name(cdev->dev) ?: "None");
+ if (cdev->master)
+ printf("\tMaster: %s", cdev->master->name);
+ if (cdev->partname)
+ printf("\tPartition: %s", cdev->partname);
+ printf("\n");
+ }
+ printf("Ocount: %d\tFlags: 0x%02x", cdev->open, cdev->flags);
+ if (cdev->flags) {
+ printf(" (");
+ if (cdev->flags & DEVFS_IS_CHARACTER_DEV)
+ printf(" cdev");
+ if (cdev->flags & DEVFS_PARTITION_FIXED)
+ printf(" fixed-partition");
+ if (cdev->flags & DEVFS_PARTITION_READONLY)
+ printf(" readonly-partition");
+ if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
+ printf(" table-partition");
+ if (cdev->flags & DEVFS_IS_MCI_MAIN_PART_DEV)
+ printf(" mci-main-partition");
+ if (cdev->mtd)
+ printf(" mtd");
+ printf(" )");
+ }
+ printf("\n");
+
+ uuid_set = memchr_inv(cdev->uuid, 0x00 ,sizeof(cdev->uuid));
+ if (cdev->filetype || cdev->dos_partition_type || uuid_set) {
+ if (cdev->filetype)
+ printf("Filetype: %s\t", file_type_to_string(cdev->filetype));
+ if (cdev->dos_partition_type)
+ printf("DOS parttype: 0x%02x\t", cdev->dos_partition_type);
+ if (uuid_set)
+ printf("UUID: %pUl", cdev->uuid);
+ printf("\n");
+ }
+}
+EXPORT_SYMBOL(cdev_print);
+
+static struct fs_device_d *get_fsdevice_by_path(const char *path);
+
+void stat_print(const char *filename, const struct stat *st)
+{
+ struct block_device *bdev = NULL;
+ struct fs_device_d *fdev;
+ struct cdev *cdev = NULL;
+ const char *type = NULL;
+ char modestr[11];
+
+ mkmodestr(st->st_mode, modestr);
+
+ switch (st->st_mode & S_IFMT) {
+ case S_IFDIR: type = "directory"; break;
+ case S_IFBLK: type = "block special file"; break;
+ case S_IFCHR: type = "character special file"; break;
+ case S_IFIFO: type = "fifo"; break;
+ case S_IFLNK: type = "symbolic link"; break;
+ case S_IFSOCK: type = "socket"; break;
+ case S_IFREG: type = "regular file"; break;
+ }
+
+ printf(" File: %s\n", filename);
+
+ if (st->st_mode & S_IFCHR) {
+ char *path;
+
+ path = canonicalize_path(filename);
+ if (path) {
+ const char *devicefile = devpath_to_name(path);
+
+ cdev = cdev_by_name(devicefile);
+ if (cdev)
+ bdev = cdev_get_block_device(cdev);
+
+ free(path);
+ }
+ }
+
+ printf(" Size: %-20llu", st->st_size);
+ if (bdev)
+ printf("Blocks: %llu\tIO Block: %u\t",
+ (u64)bdev->num_blocks, 1 << bdev->blockbits);
+
+ if (type)
+ printf(" %s", type);
+
+ fdev = get_fsdevice_by_path(filename);
+
+ printf("\nDevice: %s\tInode: %lu\tLinks: %u\n",
+ fdev ? dev_name(&fdev->dev) : "<unknown>",
+ st->st_ino, st->st_nlink);
+ printf("Access: (%04o/%s)\tUid: (%u)\tGid: (%u)\n",
+ st->st_mode & 07777, modestr, st->st_uid, st->st_gid);
+
+ if (cdev)
+ cdev_print(cdev);
+}
+EXPORT_SYMBOL(stat_print);
+
static char *cwd;
static struct dentry *cwd_dentry;
static struct vfsmount *cwd_mnt;
@@ -91,7 +195,6 @@ postcore_initcall(init_fs);
struct filename;
-static struct fs_device_d *get_fsdevice_by_path(const char *path);
static int filename_lookup(struct filename *name, unsigned flags,
struct path *path);;
static struct filename *getname(const char *filename);
@@ -1853,7 +1956,7 @@ static inline int step_into(struct nameidata *nd, struct path *path,
static int walk_component(struct nameidata *nd, int flags)
{
- struct path path;
+ struct path path = {};
int err;
/*
diff --git a/include/debug_ll.h b/include/debug_ll.h
index 735033b314..856a157bf5 100644
--- a/include/debug_ll.h
+++ b/include/debug_ll.h
@@ -33,17 +33,25 @@ static inline void putc_ll(char value)
PUTC_LL(value);
}
-static inline void puthex_ll(unsigned long value)
+static inline void puthexc_ll(unsigned char value)
{
int i; unsigned char ch;
- for (i = sizeof(unsigned long) * 2; i--; ) {
+ for (i = 2; i--; ) {
ch = ((value >> (i * 4)) & 0xf);
ch += (ch >= 10) ? 'a' - 10 : '0';
putc_ll(ch);
}
}
+static inline void puthex_ll(unsigned long value)
+{
+ int i;
+
+ for (i = sizeof(unsigned long); i--; )
+ puthexc_ll(value >> (i * 8));
+}
+
/*
* Be careful with puts_ll, it only works if the binary is running at the
* link address which often is not the case during early startup. If in doubt
@@ -66,6 +74,10 @@ static inline void putc_ll(char value)
{
}
+static inline void puthexc_ll(unsigned char value)
+{
+}
+
static inline void puthex_ll(unsigned long value)
{
}
diff --git a/include/fs.h b/include/fs.h
index b501db38ad..f96839f9eb 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -147,6 +147,9 @@ int ls(const char *path, ulong flags);
char *mkmodestr(unsigned long mode, char *str);
+void stat_print(const char *filename, const struct stat *st);
+void cdev_print(const struct cdev *cdev);
+
char *canonicalize_path(const char *pathname);
char *get_mounted_path(const char *path);
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index adaf5428fe..7d06fac68d 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -81,6 +81,13 @@
*/
/*
+ * Allocation and deallocation of bitmap.
+ * Provided in lib/bitmap.c to avoid circular dependency.
+ */
+unsigned long *bitmap_zalloc(unsigned int nbits);
+unsigned long *bitmap_xzalloc(unsigned int nbits);
+
+/*
* lib/bitmap.c provides these functions:
*/
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 645fd2e6f6..eb5ff37f2f 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -2,7 +2,7 @@
#ifndef _LINUX_BITOPS_H
#define _LINUX_BITOPS_H
-#include <asm/types.h>
+#include <linux/types.h>
#ifdef __KERNEL__
#define BIT(nr) (1UL << (nr))
@@ -194,6 +194,20 @@ static inline unsigned long __ffs64(u64 word)
return __ffs((unsigned long)word);
}
+/**
+ * assign_bit - Assign value to a bit in memory
+ * @nr: the bit to set
+ * @addr: the address to start counting from
+ * @value: the value to assign
+ */
+static inline void assign_bit(long nr, volatile unsigned long *addr, bool value)
+{
+ if (value)
+ set_bit(nr, addr);
+ else
+ clear_bit(nr, addr);
+}
+
#ifdef __KERNEL__
#ifndef set_mask_bits
diff --git a/include/linux/err.h b/include/linux/err.h
index 69efc7c4ac..db7ad6cc5b 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -19,7 +19,7 @@
#ifndef __ASSEMBLY__
-#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
+#define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
static inline void *ERR_PTR(long error)
{
diff --git a/include/string.h b/include/string.h
index d423bee6fb..499f2ec03c 100644
--- a/include/string.h
+++ b/include/string.h
@@ -4,6 +4,7 @@
#include <linux/string.h>
+void *mempcpy(void *dest, const void *src, size_t count);
int strtobool(const char *str, int *val);
char *strsep_unescaped(char **, const char *);
char *stpcpy(char *dest, const char *src);
diff --git a/lib/Makefile b/lib/Makefile
index 3f6653d74e..21afb233fa 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -60,7 +60,7 @@ obj-y += wchar.o
obj-y += libfile.o
obj-y += bitmap.o
obj-y += gcd.o
-obj-y += hexdump.o
+obj-pbl-y += hexdump.o
obj-$(CONFIG_FONTS) += fonts/
obj-$(CONFIG_BAREBOX_LOGO) += logo/
obj-y += reed_solomon/
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 5be6651941..dfc0f06b13 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -837,3 +837,13 @@ void bitmap_copy_le(void *dst, const unsigned long *src, int nbits)
}
}
EXPORT_SYMBOL(bitmap_copy_le);
+
+unsigned long *bitmap_zalloc(unsigned int nbits)
+{
+ return calloc(BITS_TO_LONGS(nbits), sizeof(unsigned long));
+}
+
+unsigned long *bitmap_xzalloc(unsigned int nbits)
+{
+ return xzalloc(BITS_TO_LONGS(nbits) * sizeof(unsigned long));
+}
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 033e1d28d1..a71474a553 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -10,6 +10,7 @@
#include <linux/log2.h>
#include <linux/printk.h>
#include <asm/unaligned.h>
+#include <pbl.h>
const char hex_asc[] = "0123456789abcdef";
EXPORT_SYMBOL(hex_asc);
@@ -243,9 +244,13 @@ void dev_print_hex_dump(struct device_d *dev, const char *level,
const u8 *ptr = buf;
int i, linelen, remaining = len;
unsigned char linebuf[32 * 3 + 2 + 32 + 1];
- char *name;
+ char *name = "";
- name = basprintf("%s%s", dev ? dev_name(dev) : "", dev ? ": " : "");
+ if (IN_PBL)
+ dev = NULL;
+
+ if (dev)
+ name = basprintf("%s: ", dev_name(dev));
if (rowsize != 16 && rowsize != 32)
rowsize = 16;
@@ -273,6 +278,7 @@ void dev_print_hex_dump(struct device_d *dev, const char *level,
}
}
- free(name);
+ if (dev)
+ free(name);
}
EXPORT_SYMBOL(dev_print_hex_dump);
diff --git a/lib/readline.c b/lib/readline.c
index 37d5b0a343..92bec3d1d8 100644
--- a/lib/readline.c
+++ b/lib/readline.c
@@ -230,9 +230,14 @@ int readline(const char *prompt, char *buf, int len)
}
i = 0;
- while (completestr[i])
+ while (completestr[i]) {
+ if (completestr[i] == ' ' && completestr[i + 1])
+ cread_add_char('\\', insert, &num,
+ &eol_num, buf, len);
+
cread_add_char(completestr[i++], insert, &num,
&eol_num, buf, len);
+ }
#endif
break;
diff --git a/lib/string.c b/lib/string.c
index 6389217d5b..005f4532bb 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -603,6 +603,11 @@ void *__memcpy(void * dest, const void *src, size_t count)
__alias(__default_memcpy);
#endif
+void *mempcpy(void *dest, const void *src, size_t count)
+{
+ return memcpy(dest, src, count) + count;
+}
+EXPORT_SYMBOL(mempcpy);
#ifndef __HAVE_ARCH_MEMMOVE
/**
diff --git a/pbl/decomp.c b/pbl/decomp.c
index 553895bac5..ebdf81ddfb 100644
--- a/pbl/decomp.c
+++ b/pbl/decomp.c
@@ -70,20 +70,20 @@ int pbl_barebox_verify(const void *compressed_start, unsigned int len,
sha256_update(&d, compressed_start, len);
sha256_final(&d, computed_hash);
if (IS_ENABLED(CONFIG_DEBUG_LL)) {
- putc_ll('C');
- putc_ll('H');
- putc_ll('\n');
- for (i = 0; i < SHA256_DIGEST_SIZE; i++) {
- puthex_ll(computed_hash[i]);
- putc_ll('\n');
- }
- putc_ll('I');
- putc_ll('H');
+ puts_ll("CH ");
+
+ for (i = 0; i < SHA256_DIGEST_SIZE; i++)
+ puthexc_ll(computed_hash[i]);
+
+ puts_ll("\nIH ");
+
+ for (i = 0; i < SHA256_DIGEST_SIZE; i++)
+ puthexc_ll(char_hash[i]);
+
putc_ll('\n');
- for (i = 0; i < SHA256_DIGEST_SIZE; i++) {
- puthex_ll(char_hash[i]);
- putc_ll('\n');
- }
+
+ pr_debug("Hexdump of first 64 bytes of %u\n", len);
+ print_hex_dump_bytes("", DUMP_PREFIX_ADDRESS, compressed_start, 64);
}
return memcmp(hash, computed_hash, SHA256_DIGEST_SIZE);
diff --git a/test/self/Kconfig b/test/self/Kconfig
index f3cb6601e3..5c69819599 100644
--- a/test/self/Kconfig
+++ b/test/self/Kconfig
@@ -33,7 +33,7 @@ config SELFTEST_ENABLE_ALL
select SELFTEST_PROGRESS_NOTIFIER
select SELFTEST_OF_MANIPULATION
select SELFTEST_ENVIRONMENT_VARIABLES if ENVIRONMENT_VARIABLES
- select SELFTEST_FS_RAMFS
+ imply SELFTEST_FS_RAMFS
imply SELFTEST_TFTP
help
Selects all self-tests compatible with current configuration
diff --git a/test/self/Makefile b/test/self/Makefile
index 6f2c0d3940..c7c729cba0 100644
--- a/test/self/Makefile
+++ b/test/self/Makefile
@@ -6,4 +6,4 @@ obj-$(CONFIG_SELFTEST_PRINTF) += printf.o
obj-$(CONFIG_SELFTEST_PROGRESS_NOTIFIER) += progress-notifier.o
obj-$(CONFIG_SELFTEST_OF_MANIPULATION) += of_manipulation.o of_manipulation.dtb.o
obj-$(CONFIG_SELFTEST_ENVIRONMENT_VARIABLES) += envvar.o
-obj-$(CONFIG_FS_RAMFS) += ramfs.o
+obj-$(CONFIG_SELFTEST_FS_RAMFS) += ramfs.o