summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-08-08 15:28:53 +0300
committerTom Rini <trini@konsulko.com>2020-08-08 15:28:53 +0300
commit626b2df302fce4bf91a240f186ba447046db4741 (patch)
treeb211041ab3bfd5876da4f6064bc7f666e0ab23c4
parent7d914bc76b18b644e27d0cf367e745fc2c4fe1c7 (diff)
parentacb021e48c619b49029102acc781e904c6471c86 (diff)
downloadu-boot-626b2df302fce4bf91a240f186ba447046db4741.tar.xz
Merge branch '2020-08-07-misc-improvements'
- SquashFS support - Assorted bugfixes
-rw-r--r--.travis.yml1
-rw-r--r--MAINTAINERS12
-rw-r--r--arch/arm/dts/ca-presidio-engboard.dts31
-rw-r--r--cmd/Kconfig8
-rw-r--r--cmd/Makefile1
-rw-r--r--cmd/mem.c30
-rw-r--r--cmd/sqfs.c42
-rw-r--r--common/console.c4
-rw-r--r--common/spl/Kconfig9
-rw-r--r--configs/sandbox_defconfig2
-rw-r--r--doc/README.commands2
-rw-r--r--drivers/led/Kconfig8
-rw-r--r--drivers/led/Makefile1
-rw-r--r--drivers/led/led_cortina.c298
-rw-r--r--fs/Kconfig2
-rw-r--r--fs/Makefile2
-rw-r--r--fs/fs.c18
-rw-r--r--fs/squashfs/Kconfig11
-rw-r--r--fs/squashfs/Makefile7
-rw-r--r--fs/squashfs/sqfs.c1538
-rw-r--r--fs/squashfs/sqfs_decompressor.c59
-rw-r--r--fs/squashfs/sqfs_decompressor.h58
-rw-r--r--fs/squashfs/sqfs_dir.c91
-rw-r--r--fs/squashfs/sqfs_filesystem.h300
-rw-r--r--fs/squashfs/sqfs_inode.c155
-rw-r--r--fs/squashfs/sqfs_utils.h49
-rw-r--r--include/console.h40
-rw-r--r--include/dm/test.h9
-rw-r--r--include/fs.h1
-rw-r--r--include/squashfs.h25
-rw-r--r--include/test/suites.h1
-rw-r--r--include/test/test.h11
-rw-r--r--include/test/ut.h59
-rw-r--r--include/u-boot/zlib.h32
-rw-r--r--lib/Kconfig7
-rw-r--r--lib/zlib/uncompr.c97
-rw-r--r--lib/zlib/zlib.c3
-rw-r--r--test/cmd/Makefile3
-rw-r--r--test/cmd/mem.c20
-rw-r--r--test/cmd/mem_search.c108
-rw-r--r--test/cmd_ut.c12
-rw-r--r--test/dm/acpi.c28
-rw-r--r--test/dm/acpi_dp.c2
-rw-r--r--test/dm/acpigen.c18
-rw-r--r--test/dm/adc.c16
-rw-r--r--test/dm/audio.c2
-rw-r--r--test/dm/axi.c6
-rw-r--r--test/dm/blk.c10
-rw-r--r--test/dm/board.c2
-rw-r--r--test/dm/bootcount.c2
-rw-r--r--test/dm/bus.c26
-rw-r--r--test/dm/button.c6
-rw-r--r--test/dm/cache.c2
-rw-r--r--test/dm/clk.c6
-rw-r--r--test/dm/clk_ccf.c2
-rw-r--r--test/dm/core.c30
-rw-r--r--test/dm/cpu.c2
-rw-r--r--test/dm/devres.c12
-rw-r--r--test/dm/dma.c6
-rw-r--r--test/dm/dsi_host.c2
-rw-r--r--test/dm/eth.c16
-rw-r--r--test/dm/fdtdec.c4
-rw-r--r--test/dm/firmware.c2
-rw-r--r--test/dm/gpio.c20
-rw-r--r--test/dm/hwspinlock.c2
-rw-r--r--test/dm/i2c.c16
-rw-r--r--test/dm/i2s.c2
-rw-r--r--test/dm/irq.c10
-rw-r--r--test/dm/led.c12
-rw-r--r--test/dm/mailbox.c2
-rw-r--r--test/dm/mdio.c2
-rw-r--r--test/dm/mdio_mux.c2
-rw-r--r--test/dm/misc.c2
-rw-r--r--test/dm/mmc.c4
-rw-r--r--test/dm/nop.c2
-rw-r--r--test/dm/ofnode.c12
-rw-r--r--test/dm/ofread.c2
-rw-r--r--test/dm/osd.c4
-rw-r--r--test/dm/p2sb.c2
-rw-r--r--test/dm/panel.c2
-rw-r--r--test/dm/pch.c4
-rw-r--r--test/dm/pci.c26
-rw-r--r--test/dm/pci_ep.c2
-rw-r--r--test/dm/phy.c6
-rw-r--r--test/dm/pmc.c2
-rw-r--r--test/dm/pmic.c10
-rw-r--r--test/dm/power-domain.c2
-rw-r--r--test/dm/pwm.c2
-rw-r--r--test/dm/ram.c2
-rw-r--r--test/dm/regmap.c10
-rw-r--r--test/dm/regulator.c20
-rw-r--r--test/dm/remoteproc.c4
-rw-r--r--test/dm/reset.c6
-rw-r--r--test/dm/rng.c2
-rw-r--r--test/dm/rtc.c14
-rw-r--r--test/dm/serial.c2
-rw-r--r--test/dm/sf.c4
-rw-r--r--test/dm/simple-pm-bus.c2
-rw-r--r--test/dm/smem.c2
-rw-r--r--test/dm/soc.c2
-rw-r--r--test/dm/sound.c4
-rw-r--r--test/dm/spi.c4
-rw-r--r--test/dm/spmi.c6
-rw-r--r--test/dm/syscon-reset.c2
-rw-r--r--test/dm/syscon.c6
-rw-r--r--test/dm/sysreset.c8
-rw-r--r--test/dm/tee.c2
-rw-r--r--test/dm/test-fdt.c46
-rw-r--r--test/dm/test-main.c10
-rw-r--r--test/dm/timer.c2
-rw-r--r--test/dm/usb.c12
-rw-r--r--test/dm/video.c26
-rw-r--r--test/dm/virtio.c8
-rw-r--r--test/dm/wdt.c2
-rw-r--r--test/lib/lmb.c18
-rw-r--r--test/py/tests/test_env.py5
-rw-r--r--test/py/tests/test_fs/conftest.py6
-rw-r--r--test/py/tests/test_fs/test_squashfs/sqfs_common.py42
-rw-r--r--test/py/tests/test_fs/test_squashfs/test_sqfs_load.py33
-rw-r--r--test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py26
-rw-r--r--test/py/tests/test_shell_basics.py6
-rw-r--r--test/ut.c22
122 files changed, 3535 insertions, 352 deletions
diff --git a/.travis.yml b/.travis.yml
index 66ccf5b2ee..7e9e65f04f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -51,6 +51,7 @@ addons:
- sbsigntool
- fakeroot
- mtd-utils
+ - squashfs-tools
install:
# Clone uboot-test-hooks
diff --git a/MAINTAINERS b/MAINTAINERS
index 889a73f15f..e35d5d4fcb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -181,6 +181,7 @@ F: board/cortina/common/
F: drivers/gpio/cortina_gpio.c
F: drivers/watchdog/cortina_wdt.c
F: drivers/serial/serial_cortina.c
+F: drivers/led/led_cortina.c
F: drivers/mmc/ca_dw_mmc.c
F: drivers/i2c/i2c-cortina.c
F: drivers/i2c/i2c-cortina.h
@@ -766,6 +767,7 @@ F: board/cortina/common/
F: drivers/gpio/cortina_gpio.c
F: drivers/watchdog/cortina_wdt.c
F: drivers/serial/serial_cortina.c
+F: drivers/led/led_cortina.c
F: drivers/mmc/ca_dw_mmc.c
F: drivers/i2c/i2c-cortina.c
F: drivers/i2c/i2c-cortina.h
@@ -868,7 +870,7 @@ S: Maintained
F: arch/powerpc/
POWERPC MPC8XX
-M: Christophe Leroy <christophe.leroy@csgroup.eu>
+M: Christophe Leroy <christophe.leroy@c-s.fr>
S: Maintained
T: git https://gitlab.denx.de/u-boot/custodians/u-boot-mpc8xx.git
F: arch/powerpc/cpu/mpc8xx/
@@ -969,6 +971,14 @@ S: Maintained
F: drivers/spmi/
F: include/spmi/
+SQUASHFS
+M: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+S: Maintained
+F: fs/squashfs/
+F: include/sqfs.h
+F: cmd/sqfs.c
+F: test/py/tests/test_fs/test_squashfs/
+
TARGET_BCMNS3
M: Bharat Gooty <bharat.gooty@broadcom.com>
M: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
diff --git a/arch/arm/dts/ca-presidio-engboard.dts b/arch/arm/dts/ca-presidio-engboard.dts
index 40c93d7042..eef433e768 100644
--- a/arch/arm/dts/ca-presidio-engboard.dts
+++ b/arch/arm/dts/ca-presidio-engboard.dts
@@ -64,4 +64,35 @@
spi-max-frequency = <108000000>;
};
};
+
+ leds: led-controller@f43200f0 {
+ compatible = "cortina,ca-leds";
+ reg = <0x0 0xf43200f0 0x40>;
+
+ cortina,blink-rate1 = <256>;
+ cortina,blink-rate2 = <512>;
+
+ led@0 {
+ pin = <0>;
+ active-low;
+ blink-sel =<0>;
+ port = <0>;
+ off-event = <0>;
+ label = "led0";
+ };
+
+ led@1 {
+ pin = <1>;
+ active-low;
+ blink-sel =<1>;
+ label = "led1";
+ };
+
+ led@2 {
+ pin = <2>;
+ active-low;
+ label = "led2";
+ };
+
+ };
};
diff --git a/cmd/Kconfig b/cmd/Kconfig
index e11176451b..23d7e27dc8 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -724,7 +724,7 @@ config CMD_MEMORY
base - print or set address offset
loop - initialize loop on address range
-config MEM_SEARCH
+config CMD_MEM_SEARCH
bool "ms - Memory search"
help
Memory-search command
@@ -2090,6 +2090,12 @@ config CMD_FAT
help
Support for the FAT fs
+config CMD_SQUASHFS
+ bool "SquashFS command support"
+ select FS_SQUASHFS
+ help
+ Enables SquashFS filesystem commands (e.g. load, ls).
+
config CMD_FS_GENERIC
bool "filesystem commands"
help
diff --git a/cmd/Makefile b/cmd/Makefile
index 70750375d1..ef2a22f9b1 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_CMD_EXT4) += ext4.o
obj-$(CONFIG_CMD_EXT2) += ext2.o
obj-$(CONFIG_CMD_FAT) += fat.o
obj-$(CONFIG_CMD_FDT) += fdt.o
+obj-$(CONFIG_CMD_SQUASHFS) += sqfs.o
obj-$(CONFIG_CMD_FLASH) += flash.o
obj-$(CONFIG_CMD_FPGA) += fpga.o
obj-$(CONFIG_CMD_FPGAD) += fpgad.o
diff --git a/cmd/mem.c b/cmd/mem.c
index 575893c18d..190e2b94a7 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -53,7 +53,8 @@ static ulong dp_last_length = 0x40;
static ulong mm_last_addr, mm_last_size;
static ulong base_address = 0;
-#ifdef CONFIG_MEM_SEARCH
+#ifdef CONFIG_CMD_MEM_SEARCH
+static ulong dp_last_ms_length;
static u8 search_buf[64];
static uint search_len;
#endif
@@ -367,7 +368,7 @@ static int do_mem_cp(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
-#ifdef CONFIG_MEM_SEARCH
+#ifdef CONFIG_CMD_MEM_SEARCH
static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -377,6 +378,7 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
ulong last_pos; /* Offset of last match in 'size' units*/
ulong last_addr; /* Address of last displayed line */
int limit = 10;
+ int used_len;
int count;
int size;
int i;
@@ -384,12 +386,12 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
/* We use the last specified parameters, unless new ones are entered */
addr = dp_last_addr;
size = dp_last_size;
- length = dp_last_length;
+ length = dp_last_ms_length;
if (argc < 3)
return CMD_RET_USAGE;
- if ((!flag & CMD_FLAG_REPEAT)) {
+ if (!(flag & CMD_FLAG_REPEAT)) {
/*
* Check for a size specification.
* Defaults to long if no or incorrect specification.
@@ -398,7 +400,8 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
if (size < 0 && size != -2 /* string */)
return 1;
- argc--; argv++;
+ argc--;
+ argv++;
while (argc && *argv[0] == '-') {
int ch = argv[0][1];
@@ -408,7 +411,8 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
limit = simple_strtoul(argv[0] + 2, NULL, 16);
else
return CMD_RET_USAGE;
- argc--; argv++;
+ argc--;
+ argv++;
}
/* Address is specified since argc > 1 */
@@ -421,7 +425,7 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
/* Read the bytes to search for */
end = search_buf + sizeof(search_buf);
for (i = 2, ptr = search_buf; i < argc && ptr < end; i++) {
- if (SUPPORT_64BIT_DATA && size == 8) {
+ if (MEM_SUPPORT_64BIT_DATA && size == 8) {
u64 val = simple_strtoull(argv[i], NULL, 16);
*(u64 *)ptr = val;
@@ -460,7 +464,8 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
last_pos = 0;
last_addr = 0;
count = 0;
- for (offset = 0; offset <= bytes - search_len && count < limit;
+ for (offset = 0;
+ offset < bytes && offset <= bytes - search_len && count < limit;
offset += size) {
void *ptr = buf + offset;
@@ -495,9 +500,10 @@ static int do_mem_search(struct cmd_tbl *cmdtp, int flag, int argc,
unmap_sysmem(buf);
- dp_last_addr = addr + offset / size;
+ used_len = offset / size;
+ dp_last_addr = addr + used_len;
dp_last_size = size;
- dp_last_length = length - offset / size;
+ dp_last_ms_length = length < used_len ? 0 : length - used_len;
return count ? 0 : CMD_RET_FAILURE;
}
@@ -1337,13 +1343,13 @@ U_BOOT_CMD(
"[.b, .w, .l" HELP_Q "] addr1 addr2 count"
);
-#ifdef CONFIG_MEM_SEARCH
+#ifdef CONFIG_CMD_MEM_SEARCH
/**************************************************/
U_BOOT_CMD(
ms, 255, 1, do_mem_search,
"memory search",
"[.b, .w, .l" HELP_Q ", .s] [-q | -<n>] address #-of-objects <value>..."
- " -q = quiet, -l<val> = match limit" :
+ " -q = quiet, -l<val> = match limit"
);
#endif
diff --git a/cmd/sqfs.c b/cmd/sqfs.c
new file mode 100644
index 0000000000..107038c4cf
--- /dev/null
+++ b/cmd/sqfs.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ *
+ * squashfs.c: implements SquashFS related commands
+ */
+
+#include <command.h>
+#include <fs.h>
+#include <squashfs.h>
+
+static int do_sqfs_ls(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
+{
+ return do_ls(cmdtp, flag, argc, argv, FS_TYPE_SQUASHFS);
+}
+
+U_BOOT_CMD(sqfsls, 4, 1, do_sqfs_ls,
+ "List files in directory. Default: root (/).",
+ "<interface> [<dev[:part]>] [directory]\n"
+ " - list files from 'dev' on 'interface' in 'directory'\n"
+);
+
+static int do_sqfs_load(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
+{
+ return do_load(cmdtp, flag, argc, argv, FS_TYPE_SQUASHFS);
+}
+
+U_BOOT_CMD(sqfsload, 7, 0, do_sqfs_load,
+ "load binary file from a SquashFS filesystem",
+ "<interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]\n"
+ " - Load binary file 'filename' from 'dev' on 'interface'\n"
+ " to address 'addr' from SquashFS filesystem.\n"
+ " 'pos' gives the file position to start loading from.\n"
+ " If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.\n"
+ " 'bytes' gives the size to load. If 'bytes' is 0 or omitted,\n"
+ " the load stops on end of file.\n"
+ " If either 'pos' or 'bytes' are not aligned to\n"
+ " ARCH_DMA_MINALIGN then a misaligned buffer warning will\n"
+ " be printed and performance will suffer for the load."
+);
diff --git a/common/console.c b/common/console.c
index 07c483f820..8e50af1f9d 100644
--- a/common/console.c
+++ b/common/console.c
@@ -635,10 +635,12 @@ void console_record_reset(void)
membuff_purge((struct membuff *)&gd->console_in);
}
-void console_record_reset_enable(void)
+int console_record_reset_enable(void)
{
console_record_reset();
gd->flags |= GD_FLG_RECORD;
+
+ return 0;
}
int console_record_readline(char *str, int maxlen)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 10605f1bab..af8255a8d6 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -577,6 +577,15 @@ config SPL_FS_EXT4
filesystem from within SPL. Support for the underlying block
device (e.g. MMC or USB) must be enabled separately.
+config SPL_FS_SQUASHFS
+ bool "Support SquashFS filesystems"
+ select FS_SQUASHFS
+ help
+ Enable support for SquashFS filesystems with SPL. This permits
+ U-Boot (or Linux in Falcon mode) to be loaded from a SquashFS
+ filesystem from within SPL. Support for the underlying block
+ device (e.g. MMC or USB) must be enabled separately.
+
config SPL_FS_FAT
bool "Support FAT filesystems"
select FS_FAT
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index f4f97f34ff..8309ce6a8b 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -42,6 +42,7 @@ CONFIG_CMD_NVEDIT_SELECT=y
CONFIG_LOOPW=y
CONFIG_CMD_MD5SUM=y
CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_MEM_SEARCH=y
CONFIG_CMD_MX_CYCLIC=y
CONFIG_CMD_MEMTEST=y
CONFIG_SYS_MEMTEST_START=0x00100000
@@ -88,6 +89,7 @@ CONFIG_CMD_TPM=y
CONFIG_CMD_TPM_TEST=y
CONFIG_CMD_BTRFS=y
CONFIG_CMD_CBFS=y
+CONFIG_CMD_SQUASHFS=y
CONFIG_CMD_CRAMFS=y
CONFIG_CMD_EXT4_WRITE=y
CONFIG_CMD_MTDPARTS=y
diff --git a/doc/README.commands b/doc/README.commands
index 229f86d8fb..22ab063fdc 100644
--- a/doc/README.commands
+++ b/doc/README.commands
@@ -183,4 +183,4 @@ static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_cmd_items, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_cmd_items, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig
index 667593405e..cc87fbf395 100644
--- a/drivers/led/Kconfig
+++ b/drivers/led/Kconfig
@@ -35,6 +35,14 @@ config LED_BCM6858
This option enables support for LEDs connected to the BCM6858
HW has blinking capabilities and up to 32 LEDs can be controlled.
+config LED_CORTINA
+ bool "LED Support for Cortina Access CAxxxx SoCs"
+ depends on LED && (CORTINA_PLATFORM)
+ help
+ This option enables support for LEDs connected to the Cortina
+ Access CAxxxx SOCs.
+
+
config LED_BLINK
bool "Support LED blinking"
depends on LED
diff --git a/drivers/led/Makefile b/drivers/led/Makefile
index 3654dd3c04..8e3ae7f146 100644
--- a/drivers/led/Makefile
+++ b/drivers/led/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_LED_BCM6328) += led_bcm6328.o
obj-$(CONFIG_LED_BCM6358) += led_bcm6358.o
obj-$(CONFIG_LED_BCM6858) += led_bcm6858.o
obj-$(CONFIG_$(SPL_)LED_GPIO) += led_gpio.o
+obj-$(CONFIG_LED_CORTINA) += led_cortina.o
diff --git a/drivers/led/led_cortina.c b/drivers/led/led_cortina.c
new file mode 100644
index 0000000000..8fd6fd1539
--- /dev/null
+++ b/drivers/led/led_cortina.c
@@ -0,0 +1,298 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/*
+ * Copyright (C) 2020 Cortina-Access
+ * Author: Jway Lin <jway.lin@cortina-access.com>
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <led.h>
+#include <log.h>
+#include <asm/io.h>
+#include <dm/lists.h>
+#include <linux/bitops.h>
+
+#define LED_MAX_HW_BLINK 127
+#define LED_MAX_COUNT 16
+
+/* LED_CONTROL fields */
+#define LED_BLINK_RATE1_SHIFT 0
+#define LED_BLINK_RATE1_MASK 0xff
+#define LED_BLINK_RATE2_SHIFT 8
+#define LED_BLINK_RATE2_MASK 0xff
+#define LED_CLK_TEST BIT(16)
+#define LED_CLK_POLARITY BIT(17)
+#define LED_CLK_TEST_MODE BIT(16)
+#define LED_CLK_TEST_RX_TEST BIT(30)
+#define LED_CLK_TEST_TX_TEST BIT(31)
+
+/* LED_CONFIG fields */
+#define LED_EVENT_ON_SHIFT 0
+#define LED_EVENT_ON_MASK 0x7
+#define LED_EVENT_BLINK_SHIFT 3
+#define LED_EVENT_BLINK_MASK 0x7
+#define LED_EVENT_OFF_SHIFT 6
+#define LED_EVENT_OFF_MASK 0x7
+#define LED_OFF_ON_SHIFT 9
+#define LED_OFF_ON_MASK 0x3
+#define LED_PORT_SHIFT 11
+#define LED_PORT_MASK 0x7
+#define LED_OFF_VAL BIT(14)
+#define LED_SW_EVENT BIT(15)
+#define LED_BLINK_SEL BIT(16)
+
+/* LED_CONFIG structures */
+struct cortina_led_cfg {
+ void __iomem *regs;
+ u32 pin; /* LED pin nubmer */
+ bool active_low; /*Active-High or Active-Low*/
+ u32 off_event; /* set led off event (RX,TX,SW)*/
+ u32 blink_event; /* set led blink event (RX,TX,SW)*/
+ u32 on_event; /* set led on event (RX,TX,SW)*/
+ u32 port; /* corresponding ethernet port */
+ int blink_sel; /* select blink-rate1 or blink-rate2 */
+};
+
+/* LED_control structures */
+struct cortina_led_platdata {
+ void __iomem *ctrl_regs;
+ u16 rate1; /* blink rate setting 0 */
+ u16 rate2; /* blink rate setting 1 */
+};
+
+enum ca_led_state_t {
+ CA_EVENT_MODE = 0,
+ CA_LED_ON = 1,
+ CA_LED_OFF,
+};
+
+static void cortina_led_write(void __iomem *reg, unsigned long data)
+{
+ writel(data, reg);
+}
+
+static unsigned long cortina_led_read(void __iomem *reg)
+{
+ return readl(reg);
+}
+
+static enum led_state_t cortina_led_get_state(struct udevice *dev)
+{
+ struct cortina_led_cfg *priv = dev_get_priv(dev);
+ enum led_state_t state = LEDST_OFF;
+ u32 val;
+
+ val = readl(priv->regs);
+
+ if (val & LED_SW_EVENT)
+ state = LEDST_ON;
+
+ return state;
+}
+
+static int cortina_led_set_state(struct udevice *dev, enum led_state_t state)
+{
+ u32 val;
+ struct cortina_led_cfg *priv = dev_get_priv(dev);
+
+ val = readl(priv->regs);
+ val &= ~(LED_OFF_ON_MASK << LED_OFF_ON_SHIFT);
+
+ switch (state) {
+ case LEDST_OFF:
+ val &= ~LED_SW_EVENT;
+ val |= CA_LED_OFF << LED_OFF_ON_SHIFT;
+ cortina_led_write(priv->regs, val);
+ break;
+ case LEDST_ON:
+ val |= LED_SW_EVENT;
+ val |= CA_LED_ON << LED_OFF_ON_SHIFT;
+ cortina_led_write(priv->regs, val);
+ break;
+ case LEDST_TOGGLE:
+ if (cortina_led_get_state(dev) == LEDST_OFF)
+ return cortina_led_set_state(dev, LEDST_ON);
+ else
+ return cortina_led_set_state(dev, LEDST_OFF);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static const struct led_ops cortina_led_ops = {
+ .get_state = cortina_led_get_state,
+ .set_state = cortina_led_set_state,
+};
+
+static int ca_led_ofdata_to_platdata(struct udevice *dev)
+{
+ struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev);
+
+ /* Top-level LED node */
+ if (!uc_plat->label) {
+ struct cortina_led_platdata *plt = dev_get_platdata(dev);
+
+ plt->rate1 =
+ dev_read_u32_default(dev, "Cortina,blink-rate1", 256);
+ plt->rate2 =
+ dev_read_u32_default(dev, "Cortina,blink-rate2", 512);
+ plt->ctrl_regs = dev_remap_addr(dev);
+ } else {
+ struct cortina_led_cfg *priv = dev_get_priv(dev);
+
+ priv->regs = dev_remap_addr(dev_get_parent(dev));
+ priv->pin = dev_read_u32_default(dev, "pin", LED_MAX_COUNT);
+ priv->blink_sel = dev_read_u32_default(dev, "blink-sel", 0);
+ priv->off_event = dev_read_u32_default(dev, "off-event", 0);
+ priv->blink_event = dev_read_u32_default(dev, "blink-event", 0);
+ priv->on_event = dev_read_u32_default(dev, "on-event", 0);
+ priv->port = dev_read_u32_default(dev, "port", 0);
+
+ if (dev_read_bool(dev, "active-low"))
+ priv->active_low = true;
+ else
+ priv->active_low = false;
+ }
+
+ return 0;
+}
+
+static int cortina_led_probe(struct udevice *dev)
+{
+ struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev);
+
+ /* Top-level LED node */
+ if (!uc_plat->label) {
+ struct cortina_led_platdata *platdata = dev_get_platdata(dev);
+ u32 reg_value, val;
+ u16 rate1, rate2;
+
+ if (!platdata->ctrl_regs)
+ return -EINVAL;
+
+ reg_value = 0;
+ reg_value |= LED_CLK_POLARITY;
+
+ rate1 = platdata->rate1;
+ rate2 = platdata->rate2;
+
+ val = rate1 / 16 - 1;
+ rate1 = val > LED_MAX_HW_BLINK ?
+ LED_MAX_HW_BLINK : val;
+ reg_value |= (rate1 & LED_BLINK_RATE1_MASK) <<
+ LED_BLINK_RATE1_SHIFT;
+
+ val = rate2 / 16 - 1;
+ rate2 = val > LED_MAX_HW_BLINK ?
+ LED_MAX_HW_BLINK : val;
+ reg_value |= (rate2 & LED_BLINK_RATE2_MASK) <<
+ LED_BLINK_RATE2_SHIFT;
+
+ cortina_led_write(platdata->ctrl_regs, reg_value);
+
+ } else {
+ struct cortina_led_cfg *priv = dev_get_priv(dev);
+ void __iomem *regs;
+ u32 val, port, off_event, blink_event, on_event;
+
+ regs = priv->regs;
+ if (!regs)
+ return -EINVAL;
+
+ if (priv->pin >= LED_MAX_COUNT)
+ return -EINVAL;
+
+ priv->regs = regs + 4 + priv->pin * 4;
+
+ val = cortina_led_read(priv->regs);
+
+ if (priv->active_low)
+ val |= LED_OFF_VAL;
+ else
+ val &= ~LED_OFF_VAL;
+
+ if (priv->blink_sel == 0)
+ val &= ~LED_BLINK_SEL;
+ else if (priv->blink_sel == 1)
+ val |= LED_BLINK_SEL;
+
+ off_event = priv->off_event;
+ val &= ~(LED_EVENT_OFF_MASK << LED_EVENT_OFF_SHIFT);
+ if (off_event != 0)
+ val |= BIT(off_event) << LED_EVENT_OFF_SHIFT;
+
+ blink_event = priv->blink_event;
+ val &= ~(LED_EVENT_BLINK_MASK << LED_EVENT_BLINK_SHIFT);
+ if (blink_event != 0)
+ val |= BIT(blink_event) << LED_EVENT_BLINK_SHIFT;
+
+ on_event = priv->on_event;
+ val &= ~(LED_EVENT_ON_MASK << LED_EVENT_ON_SHIFT);
+ if (on_event != 0)
+ val |= BIT(on_event) << LED_EVENT_ON_SHIFT;
+
+ port = priv->port;
+ val &= ~(LED_PORT_MASK << LED_PORT_SHIFT);
+ val |= port << LED_PORT_SHIFT;
+
+ /* force off */
+ val &= ~(LED_OFF_ON_MASK << LED_OFF_ON_SHIFT);
+ val |= CA_LED_OFF << LED_OFF_ON_SHIFT;
+
+ cortina_led_write(priv->regs, val);
+ }
+
+ return 0;
+}
+
+static int cortina_led_bind(struct udevice *parent)
+{
+ ofnode node;
+
+ dev_for_each_subnode(node, parent) {
+ struct led_uc_plat *uc_plat;
+ struct udevice *dev;
+ const char *label;
+ int ret;
+
+ label = ofnode_read_string(node, "label");
+ if (!label) {
+ debug("%s: node %s has no label\n", __func__,
+ ofnode_get_name(node));
+ return -EINVAL;
+ }
+
+ ret = device_bind_driver_to_node(parent, "ca-leds",
+ ofnode_get_name(node),
+ node, &dev);
+ if (ret)
+ return ret;
+ uc_plat = dev_get_uclass_platdata(dev);
+ uc_plat->label = label;
+ }
+
+ return 0;
+}
+
+static const struct udevice_id ca_led_ids[] = {
+ { .compatible = "cortina,ca-leds" },
+ { /* sentinel */ }
+};
+
+U_BOOT_DRIVER(cortina_led) = {
+ .name = "ca-leds",
+ .id = UCLASS_LED,
+ .of_match = ca_led_ids,
+ .ofdata_to_platdata = ca_led_ofdata_to_platdata,
+ .bind = cortina_led_bind,
+ .probe = cortina_led_probe,
+ .platdata_auto_alloc_size = sizeof(struct cortina_led_platdata),
+ .priv_auto_alloc_size = sizeof(struct cortina_led_cfg),
+ .ops = &cortina_led_ops,
+};
diff --git a/fs/Kconfig b/fs/Kconfig
index 1cb9831be8..620af7f044 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -22,4 +22,6 @@ source "fs/cramfs/Kconfig"
source "fs/yaffs2/Kconfig"
+source "fs/squashfs/Kconfig"
+
endmenu
diff --git a/fs/Makefile b/fs/Makefile
index 42e669c40c..937cbcf6e8 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_FS_LOADER) += fs.o
obj-$(CONFIG_SPL_FS_FAT) += fat/
obj-$(CONFIG_SPL_FS_EXT4) += ext4/
obj-$(CONFIG_SPL_FS_CBFS) += cbfs/
+obj-$(CONFIG_SPL_FS_SQUASHFS) += squashfs/
else
obj-y += fs.o
@@ -23,5 +24,6 @@ obj-$(CONFIG_SANDBOX) += sandbox/
obj-$(CONFIG_CMD_UBIFS) += ubifs/
obj-$(CONFIG_YAFFS2) += yaffs2/
obj-$(CONFIG_CMD_ZFS) += zfs/
+obj-$(CONFIG_FS_SQUASHFS) += squashfs/
endif
obj-y += fs_internal.o
diff --git a/fs/fs.c b/fs/fs.c
index edd8adc21b..17e4bc33f7 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -22,6 +22,7 @@
#include <div64.h>
#include <linux/math64.h>
#include <efi_loader.h>
+#include <squashfs.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -58,6 +59,9 @@ static int fs_ls_generic(const char *dirname)
if (dent->type == FS_DT_DIR) {
printf(" %s/\n", dent->name);
ndirs++;
+ } else if (dent->type == FS_DT_LNK) {
+ printf(" <SYM> %s\n", dent->name);
+ nfiles++;
} else {
printf(" %8lld %s\n", dent->size, dent->name);
nfiles++;
@@ -277,6 +281,20 @@ static struct fstype_info fstypes[] = {
.ln = fs_ln_unsupported,
},
#endif
+#if IS_ENABLED(CONFIG_FS_SQUASHFS)
+ {
+ .fstype = FS_TYPE_SQUASHFS,
+ .name = "squashfs",
+ .probe = sqfs_probe,
+ .opendir = sqfs_opendir,
+ .readdir = sqfs_readdir,
+ .ls = fs_ls_generic,
+ .read = sqfs_read,
+ .size = sqfs_size,
+ .close = sqfs_close,
+ .closedir = sqfs_closedir,
+ },
+#endif
{
.fstype = FS_TYPE_ANY,
.name = "unsupported",
diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig
new file mode 100644
index 0000000000..54ab1618f1
--- /dev/null
+++ b/fs/squashfs/Kconfig
@@ -0,0 +1,11 @@
+config FS_SQUASHFS
+ bool "Enable SquashFS filesystem support"
+ select ZLIB_UNCOMPRESS
+ help
+ This provides support for reading images from SquashFS filesystem.
+ Squashfs is a compressed read-only filesystem for Linux.
+ It uses zlib, lz4, lzo, or xz compression to compress files, inodes
+ and directories. Squashfs is intended for general read-only
+ filesystem use, for archival use (i.e. in cases where a .tar.gz file
+ may be used), and in constrained block device/memory systems (e.g.
+ embedded systems) where low overhead is needed.
diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
new file mode 100644
index 0000000000..ba66ee821c
--- /dev/null
+++ b/fs/squashfs/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+obj-$(CONFIG_$(SPL_)FS_SQUASHFS) = sqfs.o \
+ sqfs_inode.o \
+ sqfs_dir.o \
+ sqfs_decompressor.o
diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
new file mode 100644
index 0000000000..340e5ebdb9
--- /dev/null
+++ b/fs/squashfs/sqfs.c
@@ -0,0 +1,1538 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ *
+ * sqfs.c: SquashFS filesystem implementation
+ */
+
+#include <asm/unaligned.h>
+#include <errno.h>
+#include <fs.h>
+#include <linux/types.h>
+#include <linux/byteorder/little_endian.h>
+#include <linux/byteorder/generic.h>
+#include <memalign.h>
+#include <stdlib.h>
+#include <string.h>
+#include <squashfs.h>
+#include <part.h>
+
+#include "sqfs_decompressor.h"
+#include "sqfs_filesystem.h"
+#include "sqfs_utils.h"
+
+struct squashfs_ctxt {
+ struct disk_partition cur_part_info;
+ struct blk_desc *cur_dev;
+ struct squashfs_super_block *sblk;
+};
+
+static struct squashfs_ctxt ctxt;
+
+static int sqfs_disk_read(__u32 block, __u32 nr_blocks, void *buf)
+{
+ ulong ret;
+
+ if (!ctxt.cur_dev)
+ return -1;
+
+ ret = blk_dread(ctxt.cur_dev, ctxt.cur_part_info.start + block,
+ nr_blocks, buf);
+
+ if (ret != nr_blocks)
+ return -1;
+
+ return ret;
+}
+
+static int sqfs_read_sblk(struct squashfs_super_block **sblk)
+{
+ *sblk = malloc_cache_aligned(ctxt.cur_dev->blksz);
+ if (!*sblk)
+ return -ENOMEM;
+
+ if (sqfs_disk_read(0, 1, *sblk) != 1) {
+ free(*sblk);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int sqfs_count_tokens(const char *filename)
+{
+ int token_count = 1, l;
+
+ for (l = 1; l < strlen(filename); l++) {
+ if (filename[l] == '/')
+ token_count++;
+ }
+
+ /* Ignore trailing '/' in path */
+ if (filename[strlen(filename) - 1] == '/')
+ token_count--;
+
+ if (!token_count)
+ token_count = 1;
+
+ return token_count;
+}
+
+/*
+ * Calculates how many blocks are needed for the buffer used in sqfs_disk_read.
+ * The memory section (e.g. inode table) start offset and its end (i.e. the next
+ * table start) must be specified. It also calculates the offset from which to
+ * start reading the buffer.
+ */
+static int sqfs_calc_n_blks(__le64 start, __le64 end, u64 *offset)
+{
+ u64 start_, table_size;
+
+ table_size = le64_to_cpu(end) - le64_to_cpu(start);
+ start_ = le64_to_cpu(start) / ctxt.cur_dev->blksz;
+ *offset = le64_to_cpu(start) - (start_ * ctxt.cur_dev->blksz);
+
+ return DIV_ROUND_UP(table_size + *offset, ctxt.cur_dev->blksz);
+}
+
+/*
+ * Retrieves fragment block entry and returns true if the fragment block is
+ * compressed
+ */
+static int sqfs_frag_lookup(u32 inode_fragment_index,
+ struct squashfs_fragment_block_entry *e)
+{
+ u64 start, n_blks, src_len, table_offset, start_block;
+ unsigned char *metadata_buffer, *metadata, *table;
+ struct squashfs_fragment_block_entry *entries;
+ struct squashfs_super_block *sblk = ctxt.sblk;
+ unsigned long dest_len;
+ int block, offset, ret;
+ u16 header, comp_type;
+
+ comp_type = get_unaligned_le16(&sblk->compression);
+
+ if (inode_fragment_index >= get_unaligned_le32(&sblk->fragments))
+ return -EINVAL;
+
+ start = get_unaligned_le64(&sblk->fragment_table_start) /
+ ctxt.cur_dev->blksz;
+ n_blks = sqfs_calc_n_blks(sblk->fragment_table_start,
+ sblk->export_table_start,
+ &table_offset);
+
+ /* Allocate a proper sized buffer to store the fragment index table */
+ table = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
+ if (!table)
+ return -ENOMEM;
+
+ if (sqfs_disk_read(start, n_blks, table) < 0) {
+ free(table);
+ return -EINVAL;
+ }
+
+ block = SQFS_FRAGMENT_INDEX(inode_fragment_index);
+ offset = SQFS_FRAGMENT_INDEX_OFFSET(inode_fragment_index);
+
+ /*
+ * Get the start offset of the metadata block that contains the right
+ * fragment block entry
+ */
+ start_block = get_unaligned_le64(table + table_offset + block *
+ sizeof(u64));
+
+ start = start_block / ctxt.cur_dev->blksz;
+ n_blks = sqfs_calc_n_blks(cpu_to_le64(start_block),
+ sblk->fragment_table_start, &table_offset);
+
+ metadata_buffer = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
+ if (!metadata_buffer) {
+ ret = -ENOMEM;
+ goto free_table;
+ }
+
+ if (sqfs_disk_read(start, n_blks, metadata_buffer) < 0) {
+ ret = -EINVAL;
+ goto free_buffer;
+ }
+
+ /* Every metadata block starts with a 16-bit header */
+ header = get_unaligned_le16(metadata_buffer + table_offset);
+ metadata = metadata_buffer + table_offset + SQFS_HEADER_SIZE;
+
+ entries = malloc(SQFS_METADATA_BLOCK_SIZE);
+ if (!entries) {
+ ret = -ENOMEM;
+ goto free_buffer;
+ }
+
+ if (SQFS_COMPRESSED_METADATA(header)) {
+ src_len = SQFS_METADATA_SIZE(header);
+ dest_len = SQFS_METADATA_BLOCK_SIZE;
+ ret = sqfs_decompress(comp_type, entries, &dest_len, metadata,
+ src_len);
+ if (ret) {
+ ret = -EINVAL;
+ goto free_entries;
+ }
+ } else {
+ memcpy(entries, metadata, SQFS_METADATA_SIZE(header));
+ }
+
+ *e = entries[offset];
+ ret = SQFS_COMPRESSED_BLOCK(e->size);
+
+free_entries:
+ free(entries);
+free_buffer:
+ free(metadata_buffer);
+free_table:
+ free(table);
+
+ return ret;
+}
+
+/*
+ * The entry name is a flexible array member, and we don't know its size before
+ * actually reading the entry. So we need a first copy to retrieve this size so
+ * we can finally copy the whole struct.
+ */
+static int sqfs_read_entry(struct squashfs_directory_entry **dest, void *src)
+{
+ struct squashfs_directory_entry *tmp;
+ u16 sz;
+
+ tmp = src;
+ sz = get_unaligned_le16(src + sizeof(*tmp) - sizeof(u16));
+ /*
+ * 'src' points to the begin of a directory entry, and 'sz' gets its
+ * 'name_size' member's value. name_size is actually the string
+ * length - 1, so adding 2 compensates this difference and adds space
+ * for the trailling null byte.
+ */
+ *dest = malloc(sizeof(*tmp) + sz + 2);
+ if (!*dest)
+ return -ENOMEM;
+
+ memcpy(*dest, src, sizeof(*tmp) + sz + 1);
+ (*dest)->name[sz + 1] = '\0';
+
+ return 0;
+}
+
+static int sqfs_get_tokens_length(char **tokens, int count)
+{
+ int length = 0, i;
+
+ /*
+ * 1 is added to the result of strlen to consider the slash separator
+ * between the tokens.
+ */
+ for (i = 0; i < count; i++)
+ length += strlen(tokens[i]) + 1;
+
+ return length;
+}
+
+/* Takes a token list and returns a single string with '/' as separator. */
+static char *sqfs_concat_tokens(char **token_list, int token_count)
+{
+ char *result;
+ int i, length = 0, offset = 0;
+
+ length = sqfs_get_tokens_length(token_list, token_count);
+
+ result = malloc(length + 1);
+ result[length] = '\0';
+
+ for (i = 0; i < token_count; i++) {
+ strcpy(result + offset, token_list[i]);
+ offset += strlen(token_list[i]);
+ result[offset++] = '/';
+ }
+
+ return result;
+}
+
+/*
+ * Differently from sqfs_concat_tokens, sqfs_join writes the result into a
+ * previously allocated string, and returns the number of bytes written.
+ */
+static int sqfs_join(char **strings, char *dest, int start, int end,
+ char separator)
+{
+ int i, offset = 0;
+
+ for (i = start; i < end; i++) {
+ strcpy(dest + offset, strings[i]);
+ offset += strlen(strings[i]);
+ if (i < end - 1)
+ dest[offset++] = separator;
+ }
+
+ return offset;
+}
+
+/*
+ * Fills the given token list using its size (count) and a source string (str)
+ */
+static int sqfs_tokenize(char **tokens, int count, const char *str)
+{
+ char *aux, *strc;
+ int i, j;
+
+ strc = strdup(str);
+ if (!strc)
+ return -ENOMEM;
+
+ if (!strcmp(strc, "/")) {
+ tokens[0] = strdup(strc);
+ if (!tokens[0]) {
+ free(strc);
+ return -ENOMEM;
+ }
+ } else {
+ for (j = 0; j < count; j++) {
+ aux = strtok(!j ? strc : NULL, "/");
+ tokens[j] = strdup(aux);
+ if (!tokens[j]) {
+ for (i = 0; i < j; i++)
+ free(tokens[i]);
+ free(strc);
+ return -ENOMEM;
+ }
+ }
+ }
+
+ free(strc);
+
+ return 0;
+}
+
+/*
+ * Remove last 'updir + 1' tokens from the base path tokens list. This leaves us
+ * with a token list containing only the tokens needed to form the resolved
+ * path, and returns the decremented size of the token list.
+ */
+static int sqfs_clean_base_path(char **base, int count, int updir)
+{
+ int i;
+
+ for (i = count - updir - 1; i < count; i++)
+ free(base[i]);
+
+ return count - updir - 1;
+}
+
+/*
+ * Given the base ("current dir.") path and the relative one, generate the
+ * absolute path.
+ */
+static char *sqfs_get_abs_path(const char *base, const char *rel)
+{
+ char **base_tokens, **rel_tokens, *resolved = NULL;
+ int ret, bc, rc, i, updir = 0, resolved_size = 0, offset = 0;
+
+ /* Memory allocation for the token lists */
+ bc = sqfs_count_tokens(base);
+ rc = sqfs_count_tokens(rel);
+ if (bc < 1 || rc < 1)
+ return NULL;
+
+ base_tokens = malloc(bc * sizeof(char *));
+ if (!base_tokens)
+ return NULL;
+
+ rel_tokens = malloc(rc * sizeof(char *));
+ if (!rel_tokens)
+ goto free_b_tokens;
+
+ /* Fill token lists */
+ ret = sqfs_tokenize(base_tokens, bc, base);
+ if (ret)
+ goto free_r_tokens;
+
+ sqfs_tokenize(rel_tokens, rc, rel);
+ if (ret)
+ goto free_r_tokens;
+
+ /* count '..' occurrences in target path */
+ for (i = 0; i < rc; i++) {
+ if (!strcmp(rel_tokens[i], ".."))
+ updir++;
+ }
+
+ /* Remove the last token and the '..' occurrences */
+ bc = sqfs_clean_base_path(base_tokens, bc, updir);
+ if (bc < 0)
+ goto free_r_tokens;
+
+ /* Calculate resolved path size */
+ if (!bc)
+ resolved_size++;
+
+ resolved_size += sqfs_get_tokens_length(base_tokens, bc) +
+ sqfs_get_tokens_length(rel_tokens, rc);
+
+ resolved = malloc(resolved_size + 1);
+ if (!resolved)
+ goto free_r_tokens_loop;
+
+ /* Set resolved path */
+ memset(resolved, '\0', resolved_size + 1);
+ offset += sqfs_join(base_tokens, resolved + offset, 0, bc, '/');
+ resolved[offset++] = '/';
+ offset += sqfs_join(rel_tokens, resolved + offset, updir, rc, '/');
+
+free_r_tokens_loop:
+ for (i = 0; i < rc; i++)
+ free(rel_tokens[i]);
+ for (i = 0; i < bc; i++)
+ free(base_tokens[i]);
+free_r_tokens:
+ free(rel_tokens);
+free_b_tokens:
+ free(base_tokens);
+
+ return resolved;
+}
+
+static char *sqfs_resolve_symlink(struct squashfs_symlink_inode *sym,
+ const char *base_path)
+{
+ char *resolved, *target;
+ u32 sz;
+
+ sz = get_unaligned_le32(&sym->symlink_size);
+ target = malloc(sz + 1);
+ if (!target)
+ return NULL;
+
+ /*
+ * There is no trailling null byte in the symlink's target path, so a
+ * copy is made and a '\0' is added at its end.
+ */
+ target[sz] = '\0';
+ /* Get target name (relative path) */
+ strncpy(target, sym->symlink, sz);
+
+ /* Relative -> absolute path conversion */
+ resolved = sqfs_get_abs_path(base_path, target);
+
+ free(target);
+
+ return resolved;
+}
+
+/*
+ * m_list contains each metadata block's position, and m_count is the number of
+ * elements of m_list. Those metadata blocks come from the compressed directory
+ * table.
+ */
+static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list,
+ int token_count, u32 *m_list, int m_count)
+{
+ struct squashfs_super_block *sblk = ctxt.sblk;
+ char *path, *target, **sym_tokens, *res, *rem;
+ int j, ret, new_inode_number, offset;
+ struct squashfs_symlink_inode *sym;
+ struct squashfs_ldir_inode *ldir;
+ struct squashfs_dir_inode *dir;
+ struct fs_dir_stream *dirsp;
+ struct fs_dirent *dent;
+ unsigned char *table;
+
+ dirsp = (struct fs_dir_stream *)dirs;
+
+ /* Start by root inode */
+ table = sqfs_find_inode(dirs->inode_table, le32_to_cpu(sblk->inodes),
+ sblk->inodes, sblk->block_size);
+
+ /* root is a regular directory, not an extended one */
+ dir = (struct squashfs_dir_inode *)table;
+
+ /* get directory offset in directory table */
+ offset = sqfs_dir_offset(table, m_list, m_count);
+ dirs->table = &dirs->dir_table[offset];
+
+ /* Setup directory header */
+ dirs->dir_header = malloc(SQFS_DIR_HEADER_SIZE);
+ if (!dirs->dir_header)
+ return -ENOMEM;
+
+ memcpy(dirs->dir_header, dirs->table, SQFS_DIR_HEADER_SIZE);
+
+ /* Initialize squashfs_dir_stream members */
+ dirs->table += SQFS_DIR_HEADER_SIZE;
+ dirs->size = get_unaligned_le16(&dir->file_size) - SQFS_DIR_HEADER_SIZE;
+ dirs->entry_count = dirs->dir_header->count + 1;
+
+ /* No path given -> root directory */
+ if (!strcmp(token_list[0], "/")) {
+ dirs->table = &dirs->dir_table[offset];
+ memcpy(&dirs->i_dir, dir, sizeof(*dir));
+ return 0;
+ }
+
+ for (j = 0; j < token_count; j++) {
+ if (!sqfs_is_dir(get_unaligned_le16(&dir->inode_type))) {
+ printf("** Cannot find directory. **\n");
+ return -EINVAL;
+ }
+
+ while (!sqfs_readdir(dirsp, &dent)) {
+ ret = strcmp(dent->name, token_list[j]);
+ if (!ret)
+ break;
+ free(dirs->entry);
+ }
+
+ if (ret) {
+ printf("** Cannot find directory. **\n");
+ return -EINVAL;
+ }
+
+ /* Redefine inode as the found token */
+ new_inode_number = dirs->entry->inode_offset +
+ dirs->dir_header->inode_number;
+
+ /* Get reference to inode in the inode table */
+ table = sqfs_find_inode(dirs->inode_table, new_inode_number,
+ sblk->inodes, sblk->block_size);
+ dir = (struct squashfs_dir_inode *)table;
+
+ /* Check for symbolic link and inode type sanity */
+ if (get_unaligned_le16(&dir->inode_type) == SQFS_SYMLINK_TYPE) {
+ sym = (struct squashfs_symlink_inode *)table;
+ /* Get first j + 1 tokens */
+ path = sqfs_concat_tokens(token_list, j + 1);
+ /* Resolve for these tokens */
+ target = sqfs_resolve_symlink(sym, path);
+ /* Join remaining tokens */
+ rem = sqfs_concat_tokens(token_list + j + 1, token_count -
+ j - 1);
+ /* Concatenate remaining tokens and symlink's target */
+ res = malloc(strlen(rem) + strlen(target) + 1);
+ strcpy(res, target);
+ res[strlen(target)] = '/';
+ strcpy(res + strlen(target) + 1, rem);
+ token_count = sqfs_count_tokens(res);
+
+ if (token_count < 0)
+ return -EINVAL;
+
+ sym_tokens = malloc(token_count * sizeof(char *));
+ if (!sym_tokens)
+ return -EINVAL;
+
+ /* Fill tokens list */
+ ret = sqfs_tokenize(sym_tokens, token_count, res);
+ if (ret)
+ return -EINVAL;
+ free(dirs->entry);
+
+ ret = sqfs_search_dir(dirs, sym_tokens, token_count,
+ m_list, m_count);
+ return ret;
+ } else if (!sqfs_is_dir(get_unaligned_le16(&dir->inode_type))) {
+ printf("** Cannot find directory. **\n");
+ free(dirs->entry);
+ return -EINVAL;
+ }
+
+ /* Check if it is an extended dir. */
+ if (get_unaligned_le16(&dir->inode_type) == SQFS_LDIR_TYPE)
+ ldir = (struct squashfs_ldir_inode *)table;
+
+ /* Get dir. offset into the directory table */
+ offset = sqfs_dir_offset(table, m_list, m_count);
+ dirs->table = &dirs->dir_table[offset];
+
+ /* Copy directory header */
+ memcpy(dirs->dir_header, &dirs->dir_table[offset],
+ SQFS_DIR_HEADER_SIZE);
+
+ /* Check for empty directory */
+ if (sqfs_is_empty_dir(table)) {
+ printf("Empty directory.\n");
+ free(dirs->entry);
+ return SQFS_EMPTY_DIR;
+ }
+
+ dirs->table += SQFS_DIR_HEADER_SIZE;
+ dirs->size = get_unaligned_le16(&dir->file_size);
+ dirs->entry_count = dirs->dir_header->count + 1;
+ dirs->size -= SQFS_DIR_HEADER_SIZE;
+ free(dirs->entry);
+ }
+
+ offset = sqfs_dir_offset(table, m_list, m_count);
+ dirs->table = &dirs->dir_table[offset];
+
+ if (get_unaligned_le16(&dir->inode_type) == SQFS_DIR_TYPE)
+ memcpy(&dirs->i_dir, dir, sizeof(*dir));
+ else
+ memcpy(&dirs->i_ldir, ldir, sizeof(*ldir));
+
+ return 0;
+}
+
+/*
+ * Inode and directory tables are stored as a series of metadata blocks, and
+ * given the compressed size of this table, we can calculate how much metadata
+ * blocks are needed to store the result of the decompression, since a
+ * decompressed metadata block should have a size of 8KiB.
+ */
+static int sqfs_count_metablks(void *table, u32 offset, int table_size)
+{
+ int count = 0, cur_size = 0, ret;
+ u32 data_size;
+ bool comp;
+
+ do {
+ ret = sqfs_read_metablock(table, offset + cur_size, &comp,
+ &data_size);
+ if (ret)
+ return -EINVAL;
+ cur_size += data_size + SQFS_HEADER_SIZE;
+ count++;
+ } while (cur_size < table_size);
+
+ return count;
+}
+
+/*
+ * Storing the metadata blocks header's positions will be useful while looking
+ * for an entry in the directory table, using the reference (index and offset)
+ * given by its inode.
+ */
+static int sqfs_get_metablk_pos(u32 *pos_list, void *table, u32 offset,
+ int metablks_count)
+{
+ u32 data_size, cur_size = 0;
+ int j, ret = 0;
+ bool comp;
+
+ if (!metablks_count)
+ return -EINVAL;
+
+ for (j = 0; j < metablks_count; j++) {
+ ret = sqfs_read_metablock(table, offset + cur_size, &comp,
+ &data_size);
+ if (ret)
+ return -EINVAL;
+
+ cur_size += data_size + SQFS_HEADER_SIZE;
+ pos_list[j] = cur_size;
+ }
+
+ return ret;
+}
+
+static int sqfs_read_inode_table(unsigned char **inode_table)
+{
+ struct squashfs_super_block *sblk = ctxt.sblk;
+ u64 start, n_blks, table_offset, table_size;
+ int j, ret = 0, metablks_count, comp_type;
+ unsigned char *src_table, *itb;
+ u32 src_len, dest_offset = 0;
+ unsigned long dest_len;
+ bool compressed;
+
+ comp_type = get_unaligned_le16(&sblk->compression);
+ table_size = get_unaligned_le64(&sblk->directory_table_start) -
+ get_unaligned_le64(&sblk->inode_table_start);
+ start = get_unaligned_le64(&sblk->inode_table_start) /
+ ctxt.cur_dev->blksz;
+ n_blks = sqfs_calc_n_blks(sblk->inode_table_start,
+ sblk->directory_table_start, &table_offset);
+
+ /* Allocate a proper sized buffer (itb) to store the inode table */
+ itb = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
+ if (!itb)
+ return -ENOMEM;
+
+ if (sqfs_disk_read(start, n_blks, itb) < 0) {
+ ret = -EINVAL;
+ goto free_itb;
+ }
+
+ /* Parse inode table (metadata block) header */
+ ret = sqfs_read_metablock(itb, table_offset, &compressed, &src_len);
+ if (ret) {
+ ret = -EINVAL;
+ goto free_itb;
+ }
+
+ /* Calculate size to store the whole decompressed table */
+ metablks_count = sqfs_count_metablks(itb, table_offset, table_size);
+ if (metablks_count < 1) {
+ ret = -EINVAL;
+ goto free_itb;
+ }
+
+ *inode_table = malloc(metablks_count * SQFS_METADATA_BLOCK_SIZE);
+ if (!*inode_table) {
+ ret = -ENOMEM;
+ goto free_itb;
+ }
+
+ src_table = itb + table_offset + SQFS_HEADER_SIZE;
+
+ /* Extract compressed Inode table */
+ for (j = 0; j < metablks_count; j++) {
+ sqfs_read_metablock(itb, table_offset, &compressed, &src_len);
+ if (compressed) {
+ dest_len = SQFS_METADATA_BLOCK_SIZE;
+ ret = sqfs_decompress(comp_type, *inode_table +
+ dest_offset, &dest_len,
+ src_table, src_len);
+ if (ret) {
+ free(*inode_table);
+ goto free_itb;
+ }
+
+ } else {
+ memcpy(*inode_table + (j * SQFS_METADATA_BLOCK_SIZE),
+ src_table, src_len);
+ }
+
+ /*
+ * Offsets to the decompression destination, to the metadata
+ * buffer 'itb' and to the decompression source, respectively.
+ */
+ dest_offset += dest_len;
+ table_offset += src_len + SQFS_HEADER_SIZE;
+ src_table += src_len + SQFS_HEADER_SIZE;
+ }
+
+free_itb:
+ free(itb);
+
+ return ret;
+}
+
+static int sqfs_read_directory_table(unsigned char **dir_table, u32 **pos_list)
+{
+ u64 start, n_blks, table_offset, table_size;
+ int j, ret = 0, metablks_count = -1, comp_type;
+ struct squashfs_super_block *sblk = ctxt.sblk;
+ unsigned char *src_table, *dtb;
+ u32 src_len, dest_offset = 0;
+ unsigned long dest_len;
+ bool compressed;
+
+ comp_type = get_unaligned_le16(&sblk->compression);
+
+ /* DIRECTORY TABLE */
+ table_size = get_unaligned_le64(&sblk->fragment_table_start) -
+ get_unaligned_le64(&sblk->directory_table_start);
+ start = get_unaligned_le64(&sblk->directory_table_start) /
+ ctxt.cur_dev->blksz;
+ n_blks = sqfs_calc_n_blks(sblk->directory_table_start,
+ sblk->fragment_table_start, &table_offset);
+
+ /* Allocate a proper sized buffer (dtb) to store the directory table */
+ dtb = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
+ if (!dtb)
+ return -ENOMEM;
+
+ if (sqfs_disk_read(start, n_blks, dtb) < 0)
+ goto free_dtb;
+
+ /* Parse directory table (metadata block) header */
+ ret = sqfs_read_metablock(dtb, table_offset, &compressed, &src_len);
+ if (ret)
+ goto free_dtb;
+
+ /* Calculate total size to store the whole decompressed table */
+ metablks_count = sqfs_count_metablks(dtb, table_offset, table_size);
+ if (metablks_count < 1)
+ goto free_dtb;
+
+ *dir_table = malloc(metablks_count * SQFS_METADATA_BLOCK_SIZE);
+ if (!*dir_table)
+ goto free_dtb;
+
+ *pos_list = malloc(metablks_count * sizeof(u32));
+ if (!*pos_list) {
+ free(*dir_table);
+ goto free_dtb;
+ }
+
+ ret = sqfs_get_metablk_pos(*pos_list, dtb, table_offset,
+ metablks_count);
+ if (ret) {
+ metablks_count = -1;
+ free(*dir_table);
+ free(*pos_list);
+ goto free_dtb;
+ }
+
+ src_table = dtb + table_offset + SQFS_HEADER_SIZE;
+
+ /* Extract compressed Directory table */
+ dest_offset = 0;
+ for (j = 0; j < metablks_count; j++) {
+ sqfs_read_metablock(dtb, table_offset, &compressed, &src_len);
+ if (compressed) {
+ dest_len = SQFS_METADATA_BLOCK_SIZE;
+ ret = sqfs_decompress(comp_type, *dir_table +
+ (j * SQFS_METADATA_BLOCK_SIZE),
+ &dest_len, src_table, src_len);
+ if (ret) {
+ metablks_count = -1;
+ free(*dir_table);
+ goto free_dtb;
+ }
+
+ if (dest_len < SQFS_METADATA_BLOCK_SIZE) {
+ dest_offset += dest_len;
+ break;
+ }
+ } else {
+ memcpy(*dir_table + (j * SQFS_METADATA_BLOCK_SIZE),
+ src_table, src_len);
+ }
+
+ /*
+ * Offsets to the decompression destination, to the metadata
+ * buffer 'dtb' and to the decompression source, respectively.
+ */
+ dest_offset += dest_len;
+ table_offset += src_len + SQFS_HEADER_SIZE;
+ src_table += src_len + SQFS_HEADER_SIZE;
+ }
+
+free_dtb:
+ free(dtb);
+
+ return metablks_count;
+}
+
+int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp)
+{
+ unsigned char *inode_table = NULL, *dir_table = NULL;
+ int j, token_count, ret = 0, metablks_count;
+ struct squashfs_dir_stream *dirs;
+ char **token_list, *path;
+ u32 *pos_list = NULL;
+
+ dirs = malloc(sizeof(*dirs));
+ if (!dirs)
+ return -EINVAL;
+
+ ret = sqfs_read_inode_table(&inode_table);
+ if (ret)
+ return -EINVAL;
+
+ metablks_count = sqfs_read_directory_table(&dir_table, &pos_list);
+ if (metablks_count < 1)
+ return -EINVAL;
+
+ /* Tokenize filename */
+ token_count = sqfs_count_tokens(filename);
+ if (token_count < 0)
+ return -EINVAL;
+
+ path = strdup(filename);
+ if (!path)
+ return -ENOMEM;
+
+ token_list = malloc(token_count * sizeof(char *));
+ if (!token_list) {
+ ret = -EINVAL;
+ goto free_path;
+ }
+
+ /* Fill tokens list */
+ ret = sqfs_tokenize(token_list, token_count, path);
+ if (ret)
+ goto free_tokens;
+ /*
+ * ldir's (extended directory) size is greater than dir, so it works as
+ * a general solution for the malloc size, since 'i' is a union.
+ */
+ dirs->inode_table = inode_table;
+ dirs->dir_table = dir_table;
+ ret = sqfs_search_dir(dirs, token_list, token_count, pos_list,
+ metablks_count);
+ if (ret)
+ goto free_tokens;
+
+ if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE)
+ dirs->size = le16_to_cpu(dirs->i_dir.file_size);
+ else
+ dirs->size = le32_to_cpu(dirs->i_ldir.file_size);
+
+ /* Setup directory header */
+ memcpy(dirs->dir_header, dirs->table, SQFS_DIR_HEADER_SIZE);
+ dirs->entry_count = dirs->dir_header->count + 1;
+ dirs->size -= SQFS_DIR_HEADER_SIZE;
+
+ /* Setup entry */
+ dirs->entry = NULL;
+ dirs->table += SQFS_DIR_HEADER_SIZE;
+
+ *dirsp = (struct fs_dir_stream *)dirs;
+
+free_tokens:
+ for (j = 0; j < token_count; j++)
+ free(token_list[j]);
+ free(token_list);
+ free(pos_list);
+free_path:
+ free(path);
+
+ return ret;
+}
+
+int sqfs_readdir(struct fs_dir_stream *fs_dirs, struct fs_dirent **dentp)
+{
+ struct squashfs_super_block *sblk = ctxt.sblk;
+ struct squashfs_dir_stream *dirs;
+ struct squashfs_lreg_inode *lreg;
+ struct squashfs_base_inode *base;
+ struct squashfs_reg_inode *reg;
+ int i_number, offset = 0, ret;
+ struct fs_dirent *dent;
+ unsigned char *ipos;
+
+ dirs = (struct squashfs_dir_stream *)fs_dirs;
+ if (!dirs->size) {
+ *dentp = NULL;
+ return -SQFS_STOP_READDIR;
+ }
+
+ dent = &dirs->dentp;
+
+ if (!dirs->entry_count) {
+ if (dirs->size > SQFS_DIR_HEADER_SIZE) {
+ dirs->size -= SQFS_DIR_HEADER_SIZE;
+ } else {
+ *dentp = NULL;
+ dirs->size = 0;
+ return -SQFS_STOP_READDIR;
+ }
+
+ if (dirs->size > SQFS_EMPTY_FILE_SIZE) {
+ /* Read follow-up (emitted) dir. header */
+ memcpy(dirs->dir_header, dirs->table,
+ SQFS_DIR_HEADER_SIZE);
+ dirs->entry_count = dirs->dir_header->count + 1;
+ ret = sqfs_read_entry(&dirs->entry, dirs->table +
+ SQFS_DIR_HEADER_SIZE);
+ if (ret)
+ return -SQFS_STOP_READDIR;
+
+ dirs->table += SQFS_DIR_HEADER_SIZE;
+ }
+ } else {
+ ret = sqfs_read_entry(&dirs->entry, dirs->table);
+ if (ret)
+ return -SQFS_STOP_READDIR;
+ }
+
+ i_number = dirs->dir_header->inode_number + dirs->entry->inode_offset;
+ ipos = sqfs_find_inode(dirs->inode_table, i_number, sblk->inodes,
+ sblk->block_size);
+
+ base = (struct squashfs_base_inode *)ipos;
+
+ /* Set entry type and size */
+ switch (dirs->entry->type) {
+ case SQFS_DIR_TYPE:
+ case SQFS_LDIR_TYPE:
+ dent->type = FS_DT_DIR;
+ break;
+ case SQFS_REG_TYPE:
+ case SQFS_LREG_TYPE:
+ /*
+ * Entries do not differentiate extended from regular types, so
+ * it needs to be verified manually.
+ */
+ if (get_unaligned_le16(&base->inode_type) == SQFS_LREG_TYPE) {
+ lreg = (struct squashfs_lreg_inode *)ipos;
+ dent->size = get_unaligned_le64(&lreg->file_size);
+ } else {
+ reg = (struct squashfs_reg_inode *)ipos;
+ dent->size = get_unaligned_le32(&reg->file_size);
+ }
+
+ dent->type = FS_DT_REG;
+ break;
+ case SQFS_BLKDEV_TYPE:
+ case SQFS_CHRDEV_TYPE:
+ case SQFS_LBLKDEV_TYPE:
+ case SQFS_LCHRDEV_TYPE:
+ case SQFS_FIFO_TYPE:
+ case SQFS_SOCKET_TYPE:
+ case SQFS_LFIFO_TYPE:
+ case SQFS_LSOCKET_TYPE:
+ dent->type = SQFS_MISC_ENTRY_TYPE;
+ break;
+ case SQFS_SYMLINK_TYPE:
+ case SQFS_LSYMLINK_TYPE:
+ dent->type = FS_DT_LNK;
+ break;
+ default:
+ return -SQFS_STOP_READDIR;
+ }
+
+ /* Set entry name */
+ strncpy(dent->name, dirs->entry->name, dirs->entry->name_size + 1);
+ dent->name[dirs->entry->name_size + 1] = '\0';
+
+ offset = dirs->entry->name_size + 1 + SQFS_ENTRY_BASE_LENGTH;
+ dirs->entry_count--;
+
+ /* Decrement size to be read */
+ if (dirs->size > offset)
+ dirs->size -= offset;
+ else
+ dirs->size = 0;
+
+ /* Keep a reference to the current entry before incrementing it */
+ dirs->table += offset;
+
+ *dentp = dent;
+
+ return 0;
+}
+
+int sqfs_probe(struct blk_desc *fs_dev_desc, struct disk_partition *fs_partition)
+{
+ struct squashfs_super_block *sblk;
+ int ret;
+
+ ctxt.cur_dev = fs_dev_desc;
+ ctxt.cur_part_info = *fs_partition;
+
+ ret = sqfs_read_sblk(&sblk);
+ if (ret)
+ return ret;
+
+ /* Make sure it has a valid SquashFS magic number*/
+ if (get_unaligned_le32(&sblk->s_magic) != SQFS_MAGIC_NUMBER) {
+ printf("Bad magic number for SquashFS image.\n");
+ ctxt.cur_dev = NULL;
+ return -EINVAL;
+ }
+
+ ctxt.sblk = sblk;
+
+ return 0;
+}
+
+static char *sqfs_basename(char *path)
+{
+ char *fname;
+
+ fname = path + strlen(path) - 1;
+ while (fname >= path) {
+ if (*fname == '/') {
+ fname++;
+ break;
+ }
+
+ fname--;
+ }
+
+ return fname;
+}
+
+static char *sqfs_dirname(char *path)
+{
+ char *fname;
+
+ fname = sqfs_basename(path);
+ --fname;
+ *fname = '\0';
+
+ return path;
+}
+
+/*
+ * Takes a path to file and splits it in two parts: the filename itself and the
+ * directory's path, e.g.:
+ * path: /path/to/file.txt
+ * file: file.txt
+ * dir: /path/to
+ */
+static int sqfs_split_path(char **file, char **dir, const char *path)
+{
+ char *dirc, *basec, *bname, *dname, *tmp_path;
+ int ret = 0;
+
+ /* check for first slash in path*/
+ if (path[0] == '/') {
+ tmp_path = strdup(path);
+ if (!tmp_path)
+ return -ENOMEM;
+ } else {
+ tmp_path = malloc(strlen(path) + 2);
+ if (!tmp_path)
+ return -ENOMEM;
+ tmp_path[0] = '/';
+ strcpy(tmp_path + 1, path);
+ }
+
+ /* String duplicates */
+ dirc = strdup(tmp_path);
+ if (!dirc) {
+ ret = -ENOMEM;
+ goto free_tmp;
+ }
+
+ basec = strdup(tmp_path);
+ if (!basec) {
+ ret = -ENOMEM;
+ goto free_dirc;
+ }
+
+ dname = sqfs_dirname(dirc);
+ bname = sqfs_basename(basec);
+
+ *file = strdup(bname);
+
+ if (!*file) {
+ ret = -ENOMEM;
+ goto free_basec;
+ }
+
+ if (*dname == '\0') {
+ *dir = malloc(2);
+ if (!*dir) {
+ ret = -ENOMEM;
+ goto free_basec;
+ }
+
+ (*dir)[0] = '/';
+ (*dir)[1] = '\0';
+ } else {
+ *dir = strdup(dname);
+ if (!*dir) {
+ ret = -ENOMEM;
+ goto free_basec;
+ }
+ }
+
+free_basec:
+ free(basec);
+free_dirc:
+ free(dirc);
+free_tmp:
+ free(tmp_path);
+
+ return ret;
+}
+
+static int sqfs_get_regfile_info(struct squashfs_reg_inode *reg,
+ struct squashfs_file_info *finfo,
+ struct squashfs_fragment_block_entry *fentry,
+ __le32 blksz)
+{
+ int datablk_count = 0, ret;
+
+ finfo->size = get_unaligned_le32(&reg->file_size);
+ finfo->offset = get_unaligned_le32(&reg->offset);
+ finfo->start = get_unaligned_le32(&reg->start_block);
+ finfo->frag = SQFS_IS_FRAGMENTED(get_unaligned_le32(&reg->fragment));
+
+ if (finfo->frag) {
+ datablk_count = finfo->size / le32_to_cpu(blksz);
+ ret = sqfs_frag_lookup(get_unaligned_le32(&reg->fragment),
+ fentry);
+ if (ret < 0)
+ return -EINVAL;
+ finfo->comp = true;
+ } else {
+ datablk_count = DIV_ROUND_UP(finfo->size, le32_to_cpu(blksz));
+ }
+
+ finfo->blk_sizes = malloc(datablk_count * sizeof(u32));
+ if (!finfo->blk_sizes)
+ return -ENOMEM;
+
+ return datablk_count;
+}
+
+static int sqfs_get_lregfile_info(struct squashfs_lreg_inode *lreg,
+ struct squashfs_file_info *finfo,
+ struct squashfs_fragment_block_entry *fentry,
+ __le32 blksz)
+{
+ int datablk_count = 0, ret;
+
+ finfo->size = get_unaligned_le64(&lreg->file_size);
+ finfo->offset = get_unaligned_le32(&lreg->offset);
+ finfo->start = get_unaligned_le64(&lreg->start_block);
+ finfo->frag = SQFS_IS_FRAGMENTED(get_unaligned_le32(&lreg->fragment));
+
+ if (finfo->frag) {
+ datablk_count = finfo->size / le32_to_cpu(blksz);
+ ret = sqfs_frag_lookup(get_unaligned_le32(&lreg->fragment),
+ fentry);
+ if (ret < 0)
+ return -EINVAL;
+ finfo->comp = true;
+ } else {
+ datablk_count = DIV_ROUND_UP(finfo->size, le32_to_cpu(blksz));
+ }
+
+ finfo->blk_sizes = malloc(datablk_count * sizeof(u32));
+ if (!finfo->blk_sizes)
+ return -ENOMEM;
+
+ return datablk_count;
+}
+
+int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len,
+ loff_t *actread)
+{
+ char *dir, *fragment_block, *datablock = NULL, *data_buffer = NULL;
+ char *fragment, *file, *resolved, *data;
+ u64 start, n_blks, table_size, data_offset, table_offset;
+ int ret, j, i_number, comp_type, datablk_count = 0;
+ struct squashfs_super_block *sblk = ctxt.sblk;
+ struct squashfs_fragment_block_entry frag_entry;
+ struct squashfs_file_info finfo = {0};
+ struct squashfs_symlink_inode *symlink;
+ struct fs_dir_stream *dirsp = NULL;
+ struct squashfs_dir_stream *dirs;
+ struct squashfs_lreg_inode *lreg;
+ struct squashfs_base_inode *base;
+ struct squashfs_reg_inode *reg;
+ unsigned long dest_len;
+ struct fs_dirent *dent;
+ unsigned char *ipos;
+
+ *actread = 0;
+
+ comp_type = get_unaligned_le16(&sblk->compression);
+
+ /*
+ * sqfs_opendir will uncompress inode and directory tables, and will
+ * return a pointer to the directory that contains the requested file.
+ */
+ sqfs_split_path(&file, &dir, filename);
+ ret = sqfs_opendir(dir, &dirsp);
+ if (ret) {
+ sqfs_closedir(dirsp);
+ goto free_paths;
+ }
+
+ dirs = (struct squashfs_dir_stream *)dirsp;
+
+ /* For now, only regular files are able to be loaded */
+ while (!sqfs_readdir(dirsp, &dent)) {
+ ret = strcmp(dent->name, file);
+ if (!ret)
+ break;
+
+ free(dirs->entry);
+ }
+
+ if (ret) {
+ printf("File not found.\n");
+ *actread = 0;
+ sqfs_closedir(dirsp);
+ ret = -ENOENT;
+ goto free_paths;
+ }
+
+ i_number = dirs->dir_header->inode_number + dirs->entry->inode_offset;
+ ipos = sqfs_find_inode(dirs->inode_table, i_number, sblk->inodes,
+ sblk->block_size);
+
+ base = (struct squashfs_base_inode *)ipos;
+ switch (get_unaligned_le16(&base->inode_type)) {
+ case SQFS_REG_TYPE:
+ reg = (struct squashfs_reg_inode *)ipos;
+ datablk_count = sqfs_get_regfile_info(reg, &finfo, &frag_entry,
+ sblk->block_size);
+ if (datablk_count < 0) {
+ ret = -EINVAL;
+ goto free_paths;
+ }
+
+ memcpy(finfo.blk_sizes, ipos + sizeof(*reg),
+ datablk_count * sizeof(u32));
+ break;
+ case SQFS_LREG_TYPE:
+ lreg = (struct squashfs_lreg_inode *)ipos;
+ datablk_count = sqfs_get_lregfile_info(lreg, &finfo,
+ &frag_entry,
+ sblk->block_size);
+ if (datablk_count < 0) {
+ ret = -EINVAL;
+ goto free_paths;
+ }
+
+ memcpy(finfo.blk_sizes, ipos + sizeof(*lreg),
+ datablk_count * sizeof(u32));
+ break;
+ case SQFS_SYMLINK_TYPE:
+ case SQFS_LSYMLINK_TYPE:
+ symlink = (struct squashfs_symlink_inode *)ipos;
+ resolved = sqfs_resolve_symlink(symlink, filename);
+ ret = sqfs_read(resolved, buf, offset, len, actread);
+ free(resolved);
+ goto free_paths;
+ case SQFS_BLKDEV_TYPE:
+ case SQFS_CHRDEV_TYPE:
+ case SQFS_LBLKDEV_TYPE:
+ case SQFS_LCHRDEV_TYPE:
+ case SQFS_FIFO_TYPE:
+ case SQFS_SOCKET_TYPE:
+ case SQFS_LFIFO_TYPE:
+ case SQFS_LSOCKET_TYPE:
+ default:
+ printf("Unsupported entry type\n");
+ ret = -EINVAL;
+ goto free_paths;
+ }
+
+ /* If the user specifies a length, check its sanity */
+ if (len) {
+ if (len > finfo.size) {
+ ret = -EINVAL;
+ goto free_paths;
+ }
+
+ finfo.size = len;
+ }
+
+ if (datablk_count) {
+ data_offset = finfo.start;
+ datablock = malloc(get_unaligned_le32(&sblk->block_size));
+ if (!datablock) {
+ ret = -ENOMEM;
+ goto free_paths;
+ }
+ }
+
+ for (j = 0; j < datablk_count; j++) {
+ start = data_offset / ctxt.cur_dev->blksz;
+ table_size = SQFS_BLOCK_SIZE(finfo.blk_sizes[j]);
+ table_offset = data_offset - (start * ctxt.cur_dev->blksz);
+ n_blks = DIV_ROUND_UP(table_size + table_offset,
+ ctxt.cur_dev->blksz);
+
+ data_buffer = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
+
+ if (!data_buffer) {
+ ret = -ENOMEM;
+ goto free_datablk;
+ }
+
+ ret = sqfs_disk_read(start, n_blks, data_buffer);
+ if (ret < 0) {
+ /*
+ * Possible causes: too many data blocks or too large
+ * SquashFS block size. Tip: re-compile the SquashFS
+ * image with mksquashfs's -b <block_size> option.
+ */
+ printf("Error: too many data blocks to be read.\n");
+ goto free_buffer;
+ }
+
+ data = data_buffer + table_offset;
+
+ /* Load the data */
+ if (SQFS_COMPRESSED_BLOCK(finfo.blk_sizes[j])) {
+ dest_len = get_unaligned_le32(&sblk->block_size);
+ ret = sqfs_decompress(comp_type, datablock, &dest_len,
+ data, table_size);
+ if (ret)
+ goto free_buffer;
+
+ memcpy(buf + offset + *actread, datablock, dest_len);
+ *actread += dest_len;
+ } else {
+ memcpy(buf + offset + *actread, data, table_size);
+ *actread += table_size;
+ }
+
+ data_offset += table_size;
+ }
+
+ free(finfo.blk_sizes);
+
+ /*
+ * There is no need to continue if the file is not fragmented.
+ */
+ if (!finfo.frag) {
+ ret = 0;
+ goto free_buffer;
+ }
+
+ start = frag_entry.start / ctxt.cur_dev->blksz;
+ table_size = SQFS_BLOCK_SIZE(frag_entry.size);
+ table_offset = frag_entry.start - (start * ctxt.cur_dev->blksz);
+ n_blks = DIV_ROUND_UP(table_size + table_offset, ctxt.cur_dev->blksz);
+
+ fragment = malloc_cache_aligned(n_blks * ctxt.cur_dev->blksz);
+
+ if (!fragment) {
+ ret = -ENOMEM;
+ goto free_buffer;
+ }
+
+ ret = sqfs_disk_read(start, n_blks, fragment);
+ if (ret < 0)
+ goto free_fragment;
+
+ /* File compressed and fragmented */
+ if (finfo.frag && finfo.comp) {
+ dest_len = get_unaligned_le32(&sblk->block_size);
+ fragment_block = malloc(dest_len);
+ if (!fragment_block) {
+ ret = -ENOMEM;
+ goto free_fragment;
+ }
+
+ ret = sqfs_decompress(comp_type, fragment_block, &dest_len,
+ (void *)fragment + table_offset,
+ frag_entry.size);
+ if (ret) {
+ free(fragment_block);
+ goto free_fragment;
+ }
+
+ for (j = offset + *actread; j < finfo.size; j++) {
+ memcpy(buf + j, &fragment_block[finfo.offset + j], 1);
+ (*actread)++;
+ }
+
+ free(fragment_block);
+
+ } else if (finfo.frag && !finfo.comp) {
+ fragment_block = (void *)fragment + table_offset;
+
+ for (j = offset + *actread; j < finfo.size; j++) {
+ memcpy(buf + j, &fragment_block[finfo.offset + j], 1);
+ (*actread)++;
+ }
+ }
+
+free_fragment:
+ free(fragment);
+free_buffer:
+ if (datablk_count)
+ free(data_buffer);
+free_datablk:
+ if (datablk_count)
+ free(datablock);
+free_paths:
+ free(file);
+ free(dir);
+
+ return ret;
+}
+
+int sqfs_size(const char *filename, loff_t *size)
+{
+ struct squashfs_super_block *sblk = ctxt.sblk;
+ struct squashfs_symlink_inode *symlink;
+ struct fs_dir_stream *dirsp = NULL;
+ struct squashfs_base_inode *base;
+ struct squashfs_dir_stream *dirs;
+ struct squashfs_lreg_inode *lreg;
+ struct squashfs_reg_inode *reg;
+ char *dir, *file, *resolved;
+ struct fs_dirent *dent;
+ unsigned char *ipos;
+ int ret, i_number;
+
+ sqfs_split_path(&file, &dir, filename);
+ /*
+ * sqfs_opendir will uncompress inode and directory tables, and will
+ * return a pointer to the directory that contains the requested file.
+ */
+ ret = sqfs_opendir(dir, &dirsp);
+ if (ret) {
+ sqfs_closedir(dirsp);
+ ret = -EINVAL;
+ goto free_strings;
+ }
+
+ dirs = (struct squashfs_dir_stream *)dirsp;
+
+ while (!sqfs_readdir(dirsp, &dent)) {
+ ret = strcmp(dent->name, file);
+ if (!ret)
+ break;
+ free(dirs->entry);
+ }
+
+ if (ret) {
+ printf("File not found.\n");
+ *size = 0;
+ ret = -EINVAL;
+ goto free_strings;
+ }
+
+ i_number = dirs->dir_header->inode_number + dirs->entry->inode_offset;
+ ipos = sqfs_find_inode(dirs->inode_table, i_number, sblk->inodes,
+ sblk->block_size);
+ free(dirs->entry);
+
+ base = (struct squashfs_base_inode *)ipos;
+ switch (get_unaligned_le16(&base->inode_type)) {
+ case SQFS_REG_TYPE:
+ reg = (struct squashfs_reg_inode *)ipos;
+ *size = get_unaligned_le32(&reg->file_size);
+ break;
+ case SQFS_LREG_TYPE:
+ lreg = (struct squashfs_lreg_inode *)ipos;
+ *size = get_unaligned_le64(&lreg->file_size);
+ break;
+ case SQFS_SYMLINK_TYPE:
+ case SQFS_LSYMLINK_TYPE:
+ symlink = (struct squashfs_symlink_inode *)ipos;
+ resolved = sqfs_resolve_symlink(symlink, filename);
+ ret = sqfs_size(resolved, size);
+ free(resolved);
+ break;
+ case SQFS_BLKDEV_TYPE:
+ case SQFS_CHRDEV_TYPE:
+ case SQFS_LBLKDEV_TYPE:
+ case SQFS_LCHRDEV_TYPE:
+ case SQFS_FIFO_TYPE:
+ case SQFS_SOCKET_TYPE:
+ case SQFS_LFIFO_TYPE:
+ case SQFS_LSOCKET_TYPE:
+ default:
+ printf("Unable to recover entry's size.\n");
+ *size = 0;
+ ret = -EINVAL;
+ break;
+ }
+
+free_strings:
+ free(dir);
+ free(file);
+
+ sqfs_closedir(dirsp);
+
+ return ret;
+}
+
+void sqfs_close(void)
+{
+ free(ctxt.sblk);
+ ctxt.cur_dev = NULL;
+}
+
+void sqfs_closedir(struct fs_dir_stream *dirs)
+{
+ struct squashfs_dir_stream *sqfs_dirs;
+
+ sqfs_dirs = (struct squashfs_dir_stream *)dirs;
+ free(sqfs_dirs->inode_table);
+ free(sqfs_dirs->dir_table);
+ free(sqfs_dirs->dir_header);
+}
diff --git a/fs/squashfs/sqfs_decompressor.c b/fs/squashfs/sqfs_decompressor.c
new file mode 100644
index 0000000000..09ca6cf6d0
--- /dev/null
+++ b/fs/squashfs/sqfs_decompressor.c
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ */
+
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#if IS_ENABLED(CONFIG_ZLIB)
+#include <u-boot/zlib.h>
+#endif
+
+#include "sqfs_decompressor.h"
+#include "sqfs_filesystem.h"
+#include "sqfs_utils.h"
+
+#if IS_ENABLED(CONFIG_ZLIB)
+static void zlib_decompression_status(int ret)
+{
+ switch (ret) {
+ case Z_BUF_ERROR:
+ printf("Error: 'dest' buffer is not large enough.\n");
+ break;
+ case Z_DATA_ERROR:
+ printf("Error: corrupted compressed data.\n");
+ break;
+ case Z_MEM_ERROR:
+ printf("Error: insufficient memory.\n");
+ break;
+ }
+}
+#endif
+
+int sqfs_decompress(u16 comp_type, void *dest, unsigned long *dest_len,
+ void *source, u32 lenp)
+{
+ int ret = 0;
+
+ switch (comp_type) {
+#if IS_ENABLED(CONFIG_ZLIB)
+ case SQFS_COMP_ZLIB:
+ ret = uncompress(dest, dest_len, source, lenp);
+ if (ret) {
+ zlib_decompression_status(ret);
+ return -EINVAL;
+ }
+
+ break;
+#endif
+ default:
+ printf("Error: unknown compression type.\n");
+ return -EINVAL;
+ }
+
+ return ret;
+}
diff --git a/fs/squashfs/sqfs_decompressor.h b/fs/squashfs/sqfs_decompressor.h
new file mode 100644
index 0000000000..378965dda8
--- /dev/null
+++ b/fs/squashfs/sqfs_decompressor.h
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ */
+
+#ifndef SQFS_DECOMPRESSOR_H
+#define SQFS_DECOMPRESSOR_H
+
+#include <stdint.h>
+
+#define SQFS_COMP_ZLIB 1
+#define SQFS_COMP_LZMA 2
+#define SQFS_COMP_LZO 3
+#define SQFS_COMP_XZ 4
+#define SQFS_COMP_LZ4 5
+#define SQFS_COMP_ZSTD 6
+
+/* LZMA does not support any compression options */
+
+struct squashfs_gzip_opts {
+ u32 compression_level;
+ u16 window_size;
+ u16 strategies;
+};
+
+struct squashfs_xz_opts {
+ u32 dictionary_size;
+ u32 executable_filters;
+};
+
+struct squashfs_lz4_opts {
+ u32 version;
+ u32 flags;
+};
+
+struct squashfs_zstd_opts {
+ u32 compression_level;
+};
+
+struct squashfs_lzo_opts {
+ u32 algorithm;
+ u32 level;
+};
+
+union squashfs_compression_opts {
+ struct squashfs_gzip_opts *gzip;
+ struct squashfs_xz_opts *xz;
+ struct squashfs_lz4_opts *lz4;
+ struct squashfs_zstd_opts *zstd;
+ struct squashfs_lzo_opts *lzo;
+};
+
+int sqfs_decompress(u16 comp_type, void *dest, unsigned long *dest_len,
+ void *source, u32 lenp);
+
+#endif /* SQFS_DECOMPRESSOR_H */
diff --git a/fs/squashfs/sqfs_dir.c b/fs/squashfs/sqfs_dir.c
new file mode 100644
index 0000000000..5f7660aeae
--- /dev/null
+++ b/fs/squashfs/sqfs_dir.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ */
+
+#include <errno.h>
+#include <linux/types.h>
+#include <linux/byteorder/little_endian.h>
+#include <linux/byteorder/generic.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sqfs_filesystem.h"
+#include "sqfs_utils.h"
+
+bool sqfs_is_dir(u16 type)
+{
+ return type == SQFS_DIR_TYPE || type == SQFS_LDIR_TYPE;
+}
+
+/*
+ * Receives a pointer (void *) to a position in the inode table containing the
+ * directory's inode. Returns directory inode offset into the directory table.
+ * m_list contains each metadata block's position, and m_count is the number of
+ * elements of m_list. Those metadata blocks come from the compressed directory
+ * table.
+ */
+int sqfs_dir_offset(void *dir_i, u32 *m_list, int m_count)
+{
+ struct squashfs_base_inode *base = dir_i;
+ struct squashfs_ldir_inode *ldir;
+ struct squashfs_dir_inode *dir;
+ u32 start_block;
+ u16 offset;
+ int j;
+
+ switch (get_unaligned_le16(&base->inode_type)) {
+ case SQFS_DIR_TYPE:
+ dir = (struct squashfs_dir_inode *)base;
+ start_block = get_unaligned_le32(&dir->start_block);
+ offset = get_unaligned_le16(&dir->offset);
+ break;
+ case SQFS_LDIR_TYPE:
+ ldir = (struct squashfs_ldir_inode *)base;
+ start_block = get_unaligned_le32(&ldir->start_block);
+ offset = get_unaligned_le16(&ldir->offset);
+ break;
+ default:
+ printf("Error: this is not a directory.\n");
+ return -EINVAL;
+ }
+
+ for (j = 0; j < m_count; j++) {
+ if (m_list[j] == start_block)
+ return (++j * SQFS_METADATA_BLOCK_SIZE) + offset;
+ }
+
+ if (start_block == 0)
+ return offset;
+
+ printf("Error: invalid inode reference to directory table.\n");
+
+ return -EINVAL;
+}
+
+bool sqfs_is_empty_dir(void *dir_i)
+{
+ struct squashfs_base_inode *base = dir_i;
+ struct squashfs_ldir_inode *ldir;
+ struct squashfs_dir_inode *dir;
+ u32 file_size;
+
+ switch (get_unaligned_le16(&base->inode_type)) {
+ case SQFS_DIR_TYPE:
+ dir = (struct squashfs_dir_inode *)base;
+ file_size = get_unaligned_le16(&dir->file_size);
+ break;
+ case SQFS_LDIR_TYPE:
+ ldir = (struct squashfs_ldir_inode *)base;
+ file_size = get_unaligned_le16(&ldir->file_size);
+ break;
+ default:
+ printf("Error: this is not a directory.\n");
+ return false;
+ }
+
+ return file_size == SQFS_EMPTY_FILE_SIZE;
+}
diff --git a/fs/squashfs/sqfs_filesystem.h b/fs/squashfs/sqfs_filesystem.h
new file mode 100644
index 0000000000..d63e3a41ad
--- /dev/null
+++ b/fs/squashfs/sqfs_filesystem.h
@@ -0,0 +1,300 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ */
+
+#ifndef SQFS_FILESYSTEM_H
+#define SQFS_FILESYSTEM_H
+
+#include <asm/unaligned.h>
+#include <stdint.h>
+#include <fs.h>
+
+#define SQFS_UNCOMPRESSED_DATA 0x0002
+#define SQFS_MAGIC_NUMBER 0x73717368
+/* The three first members of squashfs_dir_index make a total of 12 bytes */
+#define SQFS_DIR_INDEX_BASE_LENGTH 12
+/* size of metadata (inode and directory) blocks */
+#define SQFS_METADATA_BLOCK_SIZE 8192
+/* Max. number of fragment entries in a metadata block is 512 */
+#define SQFS_MAX_ENTRIES 512
+/* Metadata blocks start by a 2-byte length header */
+#define SQFS_HEADER_SIZE 2
+#define SQFS_LREG_INODE_MIN_SIZE 56
+#define SQFS_DIR_HEADER_SIZE 12
+#define SQFS_MISC_ENTRY_TYPE -1
+#define SQFS_EMPTY_FILE_SIZE 3
+#define SQFS_STOP_READDIR 1
+#define SQFS_EMPTY_DIR -1
+/*
+ * A directory entry object has a fixed length of 8 bytes, corresponding to its
+ * first four members, plus the size of the entry name, which is equal to
+ * 'entry_name' + 1 bytes.
+ */
+#define SQFS_ENTRY_BASE_LENGTH 8
+/* Inode types */
+#define SQFS_DIR_TYPE 1
+#define SQFS_REG_TYPE 2
+#define SQFS_SYMLINK_TYPE 3
+#define SQFS_BLKDEV_TYPE 4
+#define SQFS_CHRDEV_TYPE 5
+#define SQFS_FIFO_TYPE 6
+#define SQFS_SOCKET_TYPE 7
+#define SQFS_LDIR_TYPE 8
+#define SQFS_LREG_TYPE 9
+#define SQFS_LSYMLINK_TYPE 10
+#define SQFS_LBLKDEV_TYPE 11
+#define SQFS_LCHRDEV_TYPE 12
+#define SQFS_LFIFO_TYPE 13
+#define SQFS_LSOCKET_TYPE 14
+
+struct squashfs_super_block {
+ __le32 s_magic;
+ __le32 inodes;
+ __le32 mkfs_time;
+ __le32 block_size;
+ __le32 fragments;
+ __le16 compression;
+ __le16 block_log;
+ __le16 flags;
+ __le16 no_ids;
+ __le16 s_major;
+ __le16 s_minor;
+ __le64 root_inode;
+ __le64 bytes_used;
+ __le64 id_table_start;
+ __le64 xattr_id_table_start;
+ __le64 inode_table_start;
+ __le64 directory_table_start;
+ __le64 fragment_table_start;
+ __le64 export_table_start;
+};
+
+struct squashfs_directory_index {
+ u32 index;
+ u32 start;
+ u32 size;
+ char name[0];
+};
+
+struct squashfs_base_inode {
+ __le16 inode_type;
+ __le16 mode;
+ __le16 uid;
+ __le16 guid;
+ __le32 mtime;
+ __le32 inode_number;
+};
+
+struct squashfs_ipc_inode {
+ __le16 inode_type;
+ __le16 mode;
+ __le16 uid;
+ __le16 guid;
+ __le32 mtime;
+ __le32 inode_number;
+ __le32 nlink;
+};
+
+struct squashfs_lipc_inode {
+ __le16 inode_type;
+ __le16 mode;
+ __le16 uid;
+ __le16 guid;
+ __le32 mtime;
+ __le32 inode_number;
+ __le32 nlink;
+ __le32 xattr;
+};
+
+struct squashfs_dev_inode {
+ __le16 inode_type;
+ __le16 mode;
+ __le16 uid;
+ __le16 guid;
+ __le32 mtime;
+ __le32 inode_number;
+ __le32 nlink;
+ __le32 rdev;
+};
+
+struct squashfs_ldev_inode {
+ __le16 inode_type;
+ __le16 mode;
+ __le16 uid;
+ __le16 guid;
+ __le32 mtime;
+ __le32 inode_number;
+ __le32 nlink;
+ __le32 rdev;
+ __le32 xattr;
+};
+
+struct squashfs_symlink_inode {
+ __le16 inode_type;
+ __le16 mode;
+ __le16 uid;
+ __le16 guid;
+ __le32 mtime;
+ __le32 inode_number;
+ __le32 nlink;
+ __le32 symlink_size;
+ char symlink[0];
+};
+
+struct squashfs_reg_inode {
+ __le16 inode_type;
+ __le16 mode;
+ __le16 uid;
+ __le16 guid;
+ __le32 mtime;
+ __le32 inode_number;
+ __le32 start_block;
+ __le32 fragment;
+ __le32 offset;
+ __le32 file_size;
+ __le32 block_list[0];
+};
+
+struct squashfs_lreg_inode {
+ __le16 inode_type;
+ __le16 mode;
+ __le16 uid;
+ __le16 guid;
+ __le32 mtime;
+ __le32 inode_number;
+ __le64 start_block;
+ __le64 file_size;
+ __le64 sparse;
+ __le32 nlink;
+ __le32 fragment;
+ __le32 offset;
+ __le32 xattr;
+ __le32 block_list[0];
+};
+
+struct squashfs_dir_inode {
+ __le16 inode_type;
+ __le16 mode;
+ __le16 uid;
+ __le16 guid;
+ __le32 mtime;
+ __le32 inode_number;
+ __le32 start_block;
+ __le32 nlink;
+ __le16 file_size;
+ __le16 offset;
+ __le32 parent_inode;
+};
+
+struct squashfs_ldir_inode {
+ __le16 inode_type;
+ __le16 mode;
+ __le16 uid;
+ __le16 guid;
+ __le32 mtime;
+ __le32 inode_number;
+ __le32 nlink;
+ __le32 file_size;
+ __le32 start_block;
+ __le32 parent_inode;
+ __le16 i_count;
+ __le16 offset;
+ __le32 xattr;
+ struct squashfs_directory_index index[0];
+};
+
+union squashfs_inode {
+ struct squashfs_base_inode *base;
+ struct squashfs_dev_inode *dev;
+ struct squashfs_ldev_inode *ldev;
+ struct squashfs_symlink_inode *symlink;
+ struct squashfs_reg_inode *reg;
+ struct squashfs_lreg_inode *lreg;
+ struct squashfs_dir_inode *dir;
+ struct squashfs_ldir_inode *ldir;
+ struct squashfs_ipc_inode *ipc;
+ struct squashfs_lipc_inode *lipc;
+};
+
+struct squashfs_directory_entry {
+ u16 offset;
+ u16 inode_offset;
+ u16 type;
+ u16 name_size;
+ char name[0];
+};
+
+struct squashfs_directory_header {
+ u32 count;
+ u32 start;
+ u32 inode_number;
+};
+
+struct squashfs_fragment_block_entry {
+ u64 start;
+ u32 size;
+ u32 _unused;
+};
+
+struct squashfs_dir_stream {
+ struct fs_dir_stream fs_dirs;
+ struct fs_dirent dentp;
+ /*
+ * 'size' is the uncompressed size of the entire listing, including
+ * headers. 'entry_count' is the number of entries following a
+ * specific header. Both variables are decremented in sqfs_readdir() so
+ * the function knows when the end of the directory is reached.
+ */
+ size_t size;
+ int entry_count;
+ /* SquashFS structures */
+ struct squashfs_directory_header *dir_header;
+ struct squashfs_directory_entry *entry;
+ /*
+ * 'table' points to a position into the directory table. Both 'table'
+ * and 'inode' are defined for the first time in sqfs_opendir().
+ * 'table's value changes in sqfs_readdir().
+ */
+ unsigned char *table;
+ union squashfs_inode i;
+ struct squashfs_dir_inode i_dir;
+ struct squashfs_ldir_inode i_ldir;
+ /*
+ * References to the tables' beginnings. They are assigned in
+ * sqfs_opendir() and freed in sqfs_closedir().
+ */
+ unsigned char *inode_table;
+ unsigned char *dir_table;
+};
+
+struct squashfs_file_info {
+ /* File size in bytes (uncompressed) */
+ size_t size;
+ /* Reference to list of data blocks's sizes */
+ u32 *blk_sizes;
+ /* Offset into the fragment block */
+ u32 offset;
+ /* Offset in which the data blocks begin */
+ u64 start;
+ /* Is file fragmented? */
+ bool frag;
+ /* Compressed fragment */
+ bool comp;
+};
+
+void *sqfs_find_inode(void *inode_table, int inode_number, __le32 inode_count,
+ __le32 block_size);
+
+int sqfs_dir_offset(void *dir_i, u32 *m_list, int m_count);
+
+int sqfs_read_metablock(unsigned char *file_mapping, int offset,
+ bool *compressed, u32 *data_size);
+
+bool sqfs_is_empty_dir(void *dir_i);
+
+bool sqfs_is_dir(u16 type);
+
+#endif /* SQFS_FILESYSTEM_H */
diff --git a/fs/squashfs/sqfs_inode.c b/fs/squashfs/sqfs_inode.c
new file mode 100644
index 0000000000..b037a9b2ac
--- /dev/null
+++ b/fs/squashfs/sqfs_inode.c
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ */
+
+#include <asm/unaligned.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "sqfs_decompressor.h"
+#include "sqfs_filesystem.h"
+#include "sqfs_utils.h"
+
+int sqfs_inode_size(struct squashfs_base_inode *inode, u32 blk_size)
+{
+ switch (get_unaligned_le16(&inode->inode_type)) {
+ case SQFS_DIR_TYPE:
+ return sizeof(struct squashfs_dir_inode);
+
+ case SQFS_REG_TYPE: {
+ struct squashfs_reg_inode *reg =
+ (struct squashfs_reg_inode *)inode;
+ u32 fragment = get_unaligned_le32(&reg->fragment);
+ u32 file_size = get_unaligned_le32(&reg->file_size);
+ unsigned int blk_list_size;
+
+ if (SQFS_IS_FRAGMENTED(fragment))
+ blk_list_size = file_size / blk_size;
+ else
+ blk_list_size = DIV_ROUND_UP(file_size, blk_size);
+
+ return sizeof(*reg) + blk_list_size * sizeof(u32);
+ }
+
+ case SQFS_LDIR_TYPE: {
+ struct squashfs_ldir_inode *ldir =
+ (struct squashfs_ldir_inode *)inode;
+ u16 i_count = get_unaligned_le16(&ldir->i_count);
+ unsigned int index_list_size = 0, l = 0;
+ struct squashfs_directory_index *di;
+ u32 sz;
+
+ if (i_count == 0)
+ return sizeof(*ldir);
+
+ di = ldir->index;
+ while (l < i_count + 1) {
+ sz = get_unaligned_le32(&di->size) + 1;
+ index_list_size += sz;
+ di = (void *)di + sizeof(*di) + sz;
+ l++;
+ }
+
+ return sizeof(*ldir) + index_list_size +
+ (i_count + 1) * SQFS_DIR_INDEX_BASE_LENGTH;
+ }
+
+ case SQFS_LREG_TYPE: {
+ struct squashfs_lreg_inode *lreg =
+ (struct squashfs_lreg_inode *)inode;
+ u32 fragment = get_unaligned_le32(&lreg->fragment);
+ u64 file_size = get_unaligned_le64(&lreg->file_size);
+ unsigned int blk_list_size;
+
+ if (fragment == 0xFFFFFFFF)
+ blk_list_size = DIV_ROUND_UP(file_size, blk_size);
+ else
+ blk_list_size = file_size / blk_size;
+
+ return sizeof(*lreg) + blk_list_size * sizeof(u32);
+ }
+
+ case SQFS_SYMLINK_TYPE:
+ case SQFS_LSYMLINK_TYPE: {
+ struct squashfs_symlink_inode *symlink =
+ (struct squashfs_symlink_inode *)inode;
+
+ return sizeof(*symlink) +
+ get_unaligned_le32(&symlink->symlink_size);
+ }
+
+ case SQFS_BLKDEV_TYPE:
+ case SQFS_CHRDEV_TYPE:
+ return sizeof(struct squashfs_dev_inode);
+ case SQFS_LBLKDEV_TYPE:
+ case SQFS_LCHRDEV_TYPE:
+ return sizeof(struct squashfs_ldev_inode);
+ case SQFS_FIFO_TYPE:
+ case SQFS_SOCKET_TYPE:
+ return sizeof(struct squashfs_ipc_inode);
+ case SQFS_LFIFO_TYPE:
+ case SQFS_LSOCKET_TYPE:
+ return sizeof(struct squashfs_lipc_inode);
+ default:
+ printf("Error while searching inode: unknown type.\n");
+ return -EINVAL;
+ }
+}
+
+/*
+ * Given the uncompressed inode table, the inode to be found and the number of
+ * inodes in the table, return inode position in case of success.
+ */
+void *sqfs_find_inode(void *inode_table, int inode_number, __le32 inode_count,
+ __le32 block_size)
+{
+ struct squashfs_base_inode *base;
+ unsigned int offset = 0, k;
+ int sz;
+
+ if (!inode_table) {
+ printf("%s: Invalid pointer to inode table.\n", __func__);
+ return NULL;
+ }
+
+ for (k = 0; k < le32_to_cpu(inode_count); k++) {
+ base = inode_table + offset;
+ if (get_unaligned_le32(&base->inode_number) == inode_number)
+ return inode_table + offset;
+
+ sz = sqfs_inode_size(base, le32_to_cpu(block_size));
+ if (sz < 0)
+ return NULL;
+
+ offset += sz;
+ }
+
+ printf("Inode not found.\n");
+
+ return NULL;
+}
+
+int sqfs_read_metablock(unsigned char *file_mapping, int offset,
+ bool *compressed, u32 *data_size)
+{
+ unsigned char *data;
+ u16 header;
+
+ data = file_mapping + offset;
+ header = get_unaligned((u16 *)data);
+ *compressed = SQFS_COMPRESSED_METADATA(header);
+ *data_size = SQFS_METADATA_SIZE(header);
+
+ if (*data_size > SQFS_METADATA_BLOCK_SIZE) {
+ printf("Invalid metatada block size: %d bytes.\n", *data_size);
+ return -EINVAL;
+ }
+
+ return 0;
+}
diff --git a/fs/squashfs/sqfs_utils.h b/fs/squashfs/sqfs_utils.h
new file mode 100644
index 0000000000..1260abe22b
--- /dev/null
+++ b/fs/squashfs/sqfs_utils.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ */
+
+#ifndef SQFS_UTILS_H
+#define SQFS_UTILS_H
+
+#include <linux/bitops.h>
+#include <linux/kernel.h>
+#include <stdbool.h>
+
+#define SQFS_FRAGMENT_INDEX_OFFSET(A) ((A) % SQFS_MAX_ENTRIES)
+#define SQFS_FRAGMENT_INDEX(A) ((A) / SQFS_MAX_ENTRIES)
+#define SQFS_BLOCK_SIZE(A) ((A) & GENMASK(23, 0))
+#define SQFS_CHECK_FLAG(flag, bit) (((flag) >> (bit)) & 1)
+/* Useful for both fragment and data blocks */
+#define SQFS_COMPRESSED_BLOCK(A) (!((A) & BIT(24)))
+/* SQFS_COMPRESSED_DATA strictly used with super block's 'flags' member */
+#define SQFS_COMPRESSED_DATA(A) (!((A) & 0x0002))
+#define SQFS_IS_FRAGMENTED(A) ((A) != 0xFFFFFFFF)
+/*
+ * These two macros work as getters for a metada block header, retrieving the
+ * data size and if it is compressed/uncompressed
+ */
+#define SQFS_COMPRESSED_METADATA(A) (!((A) & BIT(15)))
+#define SQFS_METADATA_SIZE(A) ((A) & GENMASK(14, 0))
+
+struct squashfs_super_block_flags {
+ /* check: unused
+ * uncompressed_ids: not supported
+ */
+ bool uncompressed_inodes;
+ bool uncompressed_data;
+ bool check;
+ bool uncompressed_frags;
+ bool no_frags;
+ bool always_frags;
+ bool duplicates;
+ bool exportable;
+ bool uncompressed_xattrs;
+ bool no_xattrs;
+ bool compressor_options;
+ bool uncompressed_ids;
+};
+
+#endif /* SQFS_UTILS_H */
diff --git a/include/console.h b/include/console.h
index 4c6b8f2614..432f892b6c 100644
--- a/include/console.h
+++ b/include/console.h
@@ -8,6 +8,7 @@
#define __CONSOLE_H
#include <stdbool.h>
+#include <linux/errno.h>
extern char console_buffer[];
@@ -21,11 +22,14 @@ void clear_ctrlc(void); /* clear the Control-C condition */
int disable_ctrlc(int); /* 1 to disable, 0 to enable Control-C detect */
int confirm_yesno(void); /* 1 if input is "y", "Y", "yes" or "YES" */
+#ifdef CONFIG_CONSOLE_RECORD
/**
* console_record_init() - set up the console recording buffers
*
* This should be called as soon as malloc() is available so that the maximum
* amount of console output can be recorded.
+ *
+ * @return 0 if OK, -ENOMEM if out of memory
*/
int console_record_init(void);
@@ -40,8 +44,10 @@ void console_record_reset(void);
* console_record_reset_enable() - reset and enable the console buffers
*
* This should be called to enable the console buffer.
+ *
+ * @return 0 (always)
*/
-void console_record_reset_enable(void);
+int console_record_reset_enable(void);
/**
* console_record_readline() - Read a line from the console output
@@ -61,6 +67,38 @@ int console_record_readline(char *str, int maxlen);
* @return available bytes (0 if empty)
*/
int console_record_avail(void);
+#else
+static inline int console_record_init(void)
+{
+ /* Always succeed, since it is not enabled */
+
+ return 0;
+}
+
+static inline void console_record_reset(void)
+{
+ /* Nothing to do here */
+}
+
+static inline int console_record_reset_enable(void)
+{
+ /* Cannot enable it as it is not supported */
+ return -ENOSYS;
+}
+
+static inline int console_record_readline(char *str, int maxlen)
+{
+ /* Nothing to read */
+ return 0;
+}
+
+static inline int console_record_avail(void)
+{
+ /* There is never anything available */
+ return 0;
+}
+
+#endif /* !CONFIG_CONSOLE_RECORD */
/**
* console_announce_r() - print a U-Boot console on non-serial consoles
diff --git a/include/dm/test.h b/include/dm/test.h
index 2c92d41278..b2adce730a 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -144,15 +144,6 @@ struct dm_test_state {
struct udevice *removed;
};
-/* Test flags for each test */
-enum {
- DM_TESTF_SCAN_PDATA = 1 << 0, /* test needs platform data */
- DM_TESTF_PROBE_TEST = 1 << 1, /* probe test uclass */
- DM_TESTF_SCAN_FDT = 1 << 2, /* scan device tree */
- DM_TESTF_FLAT_TREE = 1 << 3, /* test needs flat DT */
- DM_TESTF_LIVE_TREE = 1 << 4, /* needs live device tree */
-};
-
/* Declare a new driver model test */
#define DM_TEST(_name, _flags) UNIT_TEST(_name, _flags, dm_test)
diff --git a/include/fs.h b/include/fs.h
index b08b1f40c5..0794b50d10 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -15,6 +15,7 @@ struct cmd_tbl;
#define FS_TYPE_SANDBOX 3
#define FS_TYPE_UBIFS 4
#define FS_TYPE_BTRFS 5
+#define FS_TYPE_SQUASHFS 6
struct blk_desc;
diff --git a/include/squashfs.h b/include/squashfs.h
new file mode 100644
index 0000000000..819cf8c2da
--- /dev/null
+++ b/include/squashfs.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ *
+ * squashfs.h: SquashFS filesystem implementation.
+ */
+
+#ifndef _SQFS_H_
+#define _SQFS_H_
+
+struct disk_partition;
+
+int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp);
+int sqfs_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp);
+int sqfs_probe(struct blk_desc *fs_dev_desc,
+ struct disk_partition *fs_partition);
+int sqfs_read(const char *filename, void *buf, loff_t offset,
+ loff_t len, loff_t *actread);
+int sqfs_size(const char *filename, loff_t *size);
+void sqfs_close(void);
+void sqfs_closedir(struct fs_dir_stream *dirs);
+
+#endif /* SQFS_H */
diff --git a/include/test/suites.h b/include/test/suites.h
index f120b3a82a..ab7b3bd9ca 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -34,6 +34,7 @@ int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[]);
diff --git a/include/test/test.h b/include/test/test.h
index 029288de88..67c7d69d48 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -7,6 +7,7 @@
#define __TEST_TEST_H
#include <malloc.h>
+#include <linux/bitops.h>
/*
* struct unit_test_state - Entire state of test system
@@ -27,6 +28,16 @@ struct unit_test_state {
char actual_str[256];
};
+/* Test flags for each test */
+enum {
+ UT_TESTF_SCAN_PDATA = BIT(0), /* test needs platform data */
+ UT_TESTF_PROBE_TEST = BIT(1), /* probe test uclass */
+ UT_TESTF_SCAN_FDT = BIT(2), /* scan device tree */
+ UT_TESTF_FLAT_TREE = BIT(3), /* test needs flat DT */
+ UT_TESTF_LIVE_TREE = BIT(4), /* needs live device tree */
+ UT_TESTF_CONSOLE_REC = BIT(5), /* needs console recording */
+};
+
/**
* struct unit_test - Information about a unit test
*
diff --git a/include/test/ut.h b/include/test/ut.h
index 6ab2f8830d..3295cd4e54 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -58,6 +58,31 @@ int ut_check_console_line(struct unit_test_state *uts, const char *fmt, ...)
__attribute__ ((format (__printf__, 2, 3)));
/**
+ * ut_check_console_linen() - Check part of the next console line
+ *
+ * This creates a string and then checks it against the next line of console
+ * output obtained with console_record_readline(). Only the length of the
+ * string is checked
+ *
+ * After the function returns, uts->expect_str holds the expected string and
+ * uts->actual_str holds the actual string read from the console.
+ *
+ * @uts: Test state
+ * @fmt: printf() format string for the error, followed by args
+ * @return 0 if OK, other value on error
+ */
+int ut_check_console_linen(struct unit_test_state *uts, const char *fmt, ...)
+ __attribute__ ((format (__printf__, 2, 3)));
+
+/**
+ * ut_check_skipline() - Check that the next console line exists and skip it
+ *
+ * @uts: Test state
+ * @return 0 if OK, other value on error
+ */
+int ut_check_skipline(struct unit_test_state *uts);
+
+/**
* ut_check_console_end() - Check there is no more console output
*
* After the function returns, uts->actual_str holds the actual string read
@@ -152,6 +177,23 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
} \
}
+/*
+ * Assert that two string expressions are equal, up to length of the
+ * first
+ */
+#define ut_asserteq_strn(expr1, expr2) { \
+ const char *_val1 = (expr1), *_val2 = (expr2); \
+ int _len = strlen(_val1); \
+ \
+ if (memcmp(_val1, _val2, _len)) { \
+ ut_failf(uts, __FILE__, __LINE__, __func__, \
+ #expr1 " = " #expr2, \
+ "Expected \"%.*s\", got \"%.*s\"", \
+ _len, _val1, _len, _val2); \
+ return CMD_RET_FAILURE; \
+ } \
+}
+
/* Assert that two memory areas are equal */
#define ut_asserteq_mem(expr1, expr2, len) { \
const u8 *_val1 = (u8 *)(expr1), *_val2 = (u8 *)(expr2); \
@@ -231,6 +273,23 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
return CMD_RET_FAILURE; \
} \
+/* Assert that the next console output line matches up to the length */
+#define ut_assert_nextlinen(fmt, args...) \
+ if (ut_check_console_linen(uts, fmt, ##args)) { \
+ ut_failf(uts, __FILE__, __LINE__, __func__, \
+ "console", "\nExpected '%s',\n got '%s'", \
+ uts->expect_str, uts->actual_str); \
+ return CMD_RET_FAILURE; \
+ } \
+
+/* Assert that there is a 'next' console output line, and skip it */
+#define ut_assert_skipline() \
+ if (ut_check_skipline(uts)) { \
+ ut_failf(uts, __FILE__, __LINE__, __func__, \
+ "console", "\nExpected a line, got end"); \
+ return CMD_RET_FAILURE; \
+ } \
+
/* Assert that there is no more console output */
#define ut_assert_console_end() \
if (ut_check_console_end(uts)) { \
diff --git a/include/u-boot/zlib.h b/include/u-boot/zlib.h
index e23ceb50ca..a33cc8780d 100644
--- a/include/u-boot/zlib.h
+++ b/include/u-boot/zlib.h
@@ -110,6 +110,12 @@ extern "C" {
# define voidp z_voidp
#endif
+#if defined(ZLIB_CONST) && !defined(z_const)
+# define z_const const
+#else
+# define z_const
+#endif
+
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif
@@ -710,6 +716,32 @@ ZEXTERN uInt ZEXPORT crc32 OF((uInt crc, const Bytef *buf, uInt len));
if (crc != original_crc) error();
*/
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+/*
+ Decompresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total size
+ of the destination buffer, which must be large enough to hold the entire
+ uncompressed data. (The size of the uncompressed data must have been saved
+ previously by the compressor and transmitted to the decompressor by some
+ mechanism outside the scope of this compression library.) Upon exit, destLen
+ is the actual size of the uncompressed data.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
+ the case where there is not enough room, uncompress() will fill the output
+ buffer with the uncompressed data up to that point.
+*/
+
+ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen));
+/*
+ Same as uncompress, except that sourceLen is a pointer, where the
+ length of the source is *sourceLen. On return, *sourceLen is the number of
+ source bytes consumed.
+*/
+
ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
const char *version, int stream_size));
#define inflateInit(strm) \
diff --git a/lib/Kconfig b/lib/Kconfig
index 2142bd06e6..089348af73 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -460,6 +460,13 @@ config GZIP
help
This enables support for GZIP compression algorithm.
+config ZLIB_UNCOMPRESS
+ bool "Enables zlib's uncompress() functionality"
+ help
+ This enables an extra zlib functionality: the uncompress() function,
+ which decompresses data from a buffer into another, knowing their
+ sizes. Unlike gunzip(), there is no header parsing.
+
config GZIP_COMPRESSED
bool
select ZLIB
diff --git a/lib/zlib/uncompr.c b/lib/zlib/uncompr.c
new file mode 100644
index 0000000000..21e93933b2
--- /dev/null
+++ b/lib/zlib/uncompr.c
@@ -0,0 +1,97 @@
+/* uncompr.c -- decompress a memory buffer
+ * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#define ZLIB_INTERNAL
+#include "zlib.h"
+
+/* ===========================================================================
+ Decompresses the source buffer into the destination buffer. *sourceLen is
+ the byte length of the source buffer. Upon entry, *destLen is the total size
+ of the destination buffer, which must be large enough to hold the entire
+ uncompressed data. (The size of the uncompressed data must have been saved
+ previously by the compressor and transmitted to the decompressor by some
+ mechanism outside the scope of this compression library.) Upon exit,
+ *destLen is the size of the decompressed data and *sourceLen is the number
+ of source bytes consumed. Upon return, source + *sourceLen points to the
+ first unused input byte.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_BUF_ERROR if there was not enough room in the output buffer, or
+ Z_DATA_ERROR if the input data was corrupted, including if the input data is
+ an incomplete zlib stream.
+*/
+int ZEXPORT uncompress2(dest, destLen, source, sourceLen)
+ Bytef *dest;
+ uLongf *destLen;
+ const Bytef *source;
+ uLong *sourceLen;
+
+{
+ z_stream stream;
+ int err;
+ const uInt max = (uInt)-1;
+ uLong len, left;
+ /* for detection of incomplete stream when *destLen == 0 */
+ Byte buf[1];
+
+ len = *sourceLen;
+ if (*destLen) {
+ left = *destLen;
+ *destLen = 0;
+ } else {
+ left = 1;
+ dest = buf;
+ }
+
+ stream.next_in = (z_const Bytef *)source;
+ stream.avail_in = 0;
+ stream.zalloc = (alloc_func)0;
+ stream.zfree = (free_func)0;
+ stream.opaque = (voidpf)0;
+
+ err = inflateInit(&stream);
+ if (err != Z_OK)
+ return err;
+
+ stream.next_out = dest;
+ stream.avail_out = 0;
+
+ do {
+ if (stream.avail_out == 0) {
+ stream.avail_out = left > (uLong)max ? max : (uInt)left;
+ left -= stream.avail_out;
+ }
+
+ if (stream.avail_in == 0) {
+ stream.avail_in = len > (uLong)max ? max : (uInt)len;
+ len -= stream.avail_in;
+ }
+
+ err = inflate(&stream, Z_NO_FLUSH);
+ } while (err == Z_OK);
+
+ *sourceLen -= len + stream.avail_in;
+ if (dest != buf)
+ *destLen = stream.total_out;
+ else if (stream.total_out && err == Z_BUF_ERROR)
+ left = 1;
+
+ inflateEnd(&stream);
+ return err == Z_STREAM_END ? Z_OK :
+ err == Z_NEED_DICT ? Z_DATA_ERROR :
+ err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
+ err;
+}
+
+int ZEXPORT uncompress(dest, destLen, source, sourceLen)
+ Bytef *dest;
+ uLongf *destLen;
+ const Bytef *source;
+ uLong sourceLen;
+{
+ return uncompress2(dest, destLen, source, &sourceLen);
+}
diff --git a/lib/zlib/zlib.c b/lib/zlib/zlib.c
index 7e1570292c..90e05e7d4d 100644
--- a/lib/zlib/zlib.c
+++ b/lib/zlib/zlib.c
@@ -30,3 +30,6 @@
#include "inflate.c"
#include "zutil.c"
#include "adler32.c"
+#if IS_ENABLED(CONFIG_ZLIB_UNCOMPRESS)
+#include "uncompr.c"
+#endif
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 85d38f09e8..859dcda239 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -2,4 +2,5 @@
#
# Copyright (c) 2013 Google, Inc
-obj-$(CONFIG_MEM_SEARCH) += mem_search.o
+obj-y += mem.o
+obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
diff --git a/test/cmd/mem.c b/test/cmd/mem.c
new file mode 100644
index 0000000000..fa6770e8c0
--- /dev/null
+++ b/test/cmd/mem.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Executes tests for memory-related commands
+ *
+ * Copyright 2020 Google LLC
+ */
+
+#include <common.h>
+#include <command.h>
+#include <test/suites.h>
+#include <test/test.h>
+
+int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ struct unit_test *tests = ll_entry_start(struct unit_test, mem_test);
+ const int n_ents = ll_entry_count(struct unit_test, mem_test);
+
+ return cmd_ut_category("cmd_mem", "cmd_mem_", tests, n_ents, argc,
+ argv);
+}
diff --git a/test/cmd/mem_search.c b/test/cmd/mem_search.c
index d57bfad398..94942793a4 100644
--- a/test/cmd/mem_search.c
+++ b/test/cmd/mem_search.c
@@ -14,8 +14,11 @@
#define BUF_SIZE 0x100
+/* Declare a new mem test */
+#define MEM_TEST(_name, _flags) UNIT_TEST(_name, _flags, mem_test)
+
/* Test 'ms' command with bytes */
-static int dm_test_ms_b(struct unit_test_state *uts)
+static int mem_test_ms_b(struct unit_test_state *uts)
{
u8 *buf;
@@ -25,7 +28,7 @@ static int dm_test_ms_b(struct unit_test_state *uts)
buf[0x31] = 0x12;
buf[0xff] = 0x12;
buf[0x100] = 0x12;
- console_record_reset();
+ ut_assertok(console_record_reset_enable());
run_command("ms.b 1 ff 12", 0);
ut_assert_nextline("00000030: 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................");
ut_assert_nextline("--");
@@ -41,10 +44,10 @@ static int dm_test_ms_b(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ms_b, 0);
+MEM_TEST(mem_test_ms_b, UT_TESTF_CONSOLE_REC);
/* Test 'ms' command with 16-bit values */
-static int dm_test_ms_w(struct unit_test_state *uts)
+static int mem_test_ms_w(struct unit_test_state *uts)
{
u16 *buf;
@@ -52,7 +55,7 @@ static int dm_test_ms_w(struct unit_test_state *uts)
memset(buf, '\0', BUF_SIZE);
buf[0x34 / 2] = 0x1234;
buf[BUF_SIZE / 2] = 0x1234;
- console_record_reset();
+ ut_assertok(console_record_reset_enable());
run_command("ms.w 0 80 1234", 0);
ut_assert_nextline("00000030: 0000 0000 1234 0000 0000 0000 0000 0000 ....4...........");
ut_assert_nextline("1 match");
@@ -66,10 +69,10 @@ static int dm_test_ms_w(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ms_w, 0);
+MEM_TEST(mem_test_ms_w, UT_TESTF_CONSOLE_REC);
/* Test 'ms' command with 32-bit values */
-static int dm_test_ms_l(struct unit_test_state *uts)
+static int mem_test_ms_l(struct unit_test_state *uts)
{
u32 *buf;
@@ -77,7 +80,7 @@ static int dm_test_ms_l(struct unit_test_state *uts)
memset(buf, '\0', BUF_SIZE);
buf[0x38 / 4] = 0x12345678;
buf[BUF_SIZE / 4] = 0x12345678;
- console_record_reset();
+ ut_assertok(console_record_reset_enable());
run_command("ms 0 40 12345678", 0);
ut_assert_nextline("00000030: 00000000 00000000 12345678 00000000 ........xV4.....");
ut_assert_nextline("1 match");
@@ -87,7 +90,7 @@ static int dm_test_ms_l(struct unit_test_state *uts)
ut_asserteq(0x38, env_get_hex("memaddr", 0));
ut_asserteq(0x38 / 4, env_get_hex("mempos", 0));
- console_record_reset();
+ ut_assertok(console_record_reset_enable());
run_command("ms 0 80 12345679", 0);
ut_assert_nextline("0 matches");
ut_assert_console_end();
@@ -100,10 +103,10 @@ static int dm_test_ms_l(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ms_l, 0);
+MEM_TEST(mem_test_ms_l, UT_TESTF_CONSOLE_REC);
/* Test 'ms' command with continuation */
-static int dm_test_ms_cont(struct unit_test_state *uts)
+static int mem_test_ms_cont(struct unit_test_state *uts)
{
char *const args[] = {"ms.b", "0", "100", "34"};
int repeatable;
@@ -114,7 +117,7 @@ static int dm_test_ms_cont(struct unit_test_state *uts)
memset(buf, '\0', BUF_SIZE);
for (i = 5; i < 0x33; i += 3)
buf[i] = 0x34;
- console_record_reset();
+ ut_assertok(console_record_reset_enable());
run_command("ms.b 0 100 34", 0);
ut_assert_nextlinen("00000000: 00 00 00 00 00 34 00 00 34 00 00 34 00 00 34 00");
ut_assert_nextline("--");
@@ -132,7 +135,7 @@ static int dm_test_ms_cont(struct unit_test_state *uts)
* run_command() ignoes the repeatable flag when using hush, so call
* cmd_process() directly
*/
- console_record_reset();
+ ut_assertok(console_record_reset_enable());
cmd_process(CMD_FLAG_REPEAT, 4, args, &repeatable, NULL);
ut_assert_nextlinen("00000020: 34 00 00 34 00 00 34 00 00 34 00 00 34 00 00 34");
ut_assert_nextline("--");
@@ -150,10 +153,54 @@ static int dm_test_ms_cont(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ms_cont, 0);
+MEM_TEST(mem_test_ms_cont, UT_TESTF_CONSOLE_REC);
+
+/* Test that an 'ms' command with continuation stops at the end of the range */
+static int mem_test_ms_cont_end(struct unit_test_state *uts)
+{
+ char *const args[] = {"ms.b", "1", "ff", "12"};
+ int repeatable;
+ u8 *buf;
+
+ buf = map_sysmem(0, BUF_SIZE);
+ memset(buf, '\0', BUF_SIZE);
+ buf[0x0] = 0x12;
+ buf[0x31] = 0x12;
+ buf[0xff] = 0x12;
+ buf[0x100] = 0x12;
+ ut_assertok(console_record_reset_enable());
+ run_command("ms.b 1 ff 12", 0);
+ ut_assert_nextlinen("00000030");
+ ut_assert_nextlinen("--");
+ ut_assert_nextlinen("000000f0");
+ ut_assert_nextlinen("2 matches");
+ ut_assert_console_end();
+
+ /*
+ * run_command() ignoes the repeatable flag when using hush, so call
+ * cmd_process() directly.
+ *
+ * This should produce no matches.
+ */
+ ut_assertok(console_record_reset_enable());
+ cmd_process(CMD_FLAG_REPEAT, 4, args, &repeatable, NULL);
+ ut_assert_nextlinen("0 matches");
+ ut_assert_console_end();
+
+ /* One more time */
+ ut_assertok(console_record_reset_enable());
+ cmd_process(CMD_FLAG_REPEAT, 4, args, &repeatable, NULL);
+ ut_assert_nextlinen("0 matches");
+ ut_assert_console_end();
+
+ unmap_sysmem(buf);
+
+ return 0;
+}
+MEM_TEST(mem_test_ms_cont_end, UT_TESTF_CONSOLE_REC);
/* Test 'ms' command with multiple values */
-static int dm_test_ms_mult(struct unit_test_state *uts)
+static int mem_test_ms_mult(struct unit_test_state *uts)
{
static const char str[] = "hello";
char *buf;
@@ -163,7 +210,7 @@ static int dm_test_ms_mult(struct unit_test_state *uts)
strcpy(buf + 0x1e, str);
strcpy(buf + 0x63, str);
strcpy(buf + BUF_SIZE - strlen(str) + 1, str);
- console_record_reset();
+ ut_assertok(console_record_reset_enable());
run_command("ms.b 0 100 68 65 6c 6c 6f", 0);
ut_assert_nextline("00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 68 65 ..............he");
ut_assert_nextline("00000020: 6c 6c 6f 00 00 00 00 00 00 00 00 00 00 00 00 00 llo.............");
@@ -179,10 +226,10 @@ static int dm_test_ms_mult(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ms_mult, 0);
+MEM_TEST(mem_test_ms_mult, UT_TESTF_CONSOLE_REC);
/* Test 'ms' command with string */
-static int dm_test_ms_s(struct unit_test_state *uts)
+static int mem_test_ms_s(struct unit_test_state *uts)
{
static const char str[] = "hello";
static const char str2[] = "hellothere";
@@ -193,7 +240,7 @@ static int dm_test_ms_s(struct unit_test_state *uts)
strcpy(buf + 0x1e, str);
strcpy(buf + 0x63, str);
strcpy(buf + 0xa1, str2);
- console_record_reset();
+ ut_assertok(console_record_reset_enable());
run_command("ms.s 0 100 hello", 0);
ut_assert_nextline("00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 68 65 ..............he");
ut_assert_nextline("00000020: 6c 6c 6f 00 00 00 00 00 00 00 00 00 00 00 00 00 llo.............");
@@ -208,7 +255,7 @@ static int dm_test_ms_s(struct unit_test_state *uts)
ut_asserteq(0xa1, env_get_hex("memaddr", 0));
ut_asserteq(0xa1, env_get_hex("mempos", 0));
- console_record_reset();
+ ut_assertok(console_record_reset_enable());
run_command("ms.s 0 100 hello there", 0);
ut_assert_nextline("000000a0: 00 68 65 6c 6c 6f 74 68 65 72 65 00 00 00 00 00 .hellothere.....");
ut_assert_nextline("1 match");
@@ -222,10 +269,10 @@ static int dm_test_ms_s(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ms_s, 0);
+MEM_TEST(mem_test_ms_s, UT_TESTF_CONSOLE_REC);
/* Test 'ms' command with limit */
-static int dm_test_ms_limit(struct unit_test_state *uts)
+static int mem_test_ms_limit(struct unit_test_state *uts)
{
u8 *buf;
@@ -235,7 +282,7 @@ static int dm_test_ms_limit(struct unit_test_state *uts)
buf[0x31] = 0x12;
buf[0x62] = 0x12;
buf[0x76] = 0x12;
- console_record_reset();
+ ut_assertok(console_record_reset_enable());
run_command("ms.b -l2 1 ff 12", 0);
ut_assert_nextline("00000030: 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................");
ut_assert_nextline("--");
@@ -251,10 +298,10 @@ static int dm_test_ms_limit(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ms_limit, 0);
+MEM_TEST(mem_test_ms_limit, UT_TESTF_CONSOLE_REC);
/* Test 'ms' command in quiet mode */
-static int dm_test_ms_quiet(struct unit_test_state *uts)
+static int mem_test_ms_quiet(struct unit_test_state *uts)
{
u8 *buf;
@@ -264,12 +311,15 @@ static int dm_test_ms_quiet(struct unit_test_state *uts)
buf[0x31] = 0x12;
buf[0x62] = 0x12;
buf[0x76] = 0x12;
- console_record_reset();
- run_command("ms.b -l2 1 ff 12", 0);
+ ut_assertok(console_record_reset_enable());
+ run_command("ms.b -q -l2 1 ff 12", 0);
ut_assert_console_end();
unmap_sysmem(buf);
+ ut_asserteq(2, env_get_hex("memmatches", 0));
+ ut_asserteq(0x62, env_get_hex("memaddr", 0));
+ ut_asserteq(0x61, env_get_hex("mempos", 0));
+
return 0;
}
-DM_TEST(dm_test_ms_quiet, 0);
-
+MEM_TEST(mem_test_ms_quiet, UT_TESTF_CONSOLE_REC);
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index cc9543c315..8f0bc688a2 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <command.h>
+#include <console.h>
#include <test/suites.h>
#include <test/test.h>
@@ -34,6 +35,15 @@ int cmd_ut_category(const char *name, const char *prefix,
continue;
printf("Test: %s\n", test->name);
+ if (test->flags & UT_TESTF_CONSOLE_REC) {
+ int ret = console_record_reset_enable();
+
+ if (ret) {
+ printf("Skipping: Console recording disabled\n");
+ continue;
+ }
+ }
+
uts.start = mallinfo();
test->func(&uts);
@@ -64,6 +74,7 @@ static struct cmd_tbl cmd_ut_sub[] = {
#ifdef CONFIG_UT_LOG
U_BOOT_CMD_MKENT(log, CONFIG_SYS_MAXARGS, 1, do_ut_log, "", ""),
#endif
+ U_BOOT_CMD_MKENT(mem, CONFIG_SYS_MAXARGS, 1, do_ut_mem, "", ""),
#ifdef CONFIG_UT_TIME
U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),
#endif
@@ -135,6 +146,7 @@ static char ut_help_text[] =
#ifdef CONFIG_UT_LOG
"ut log [test-name] - test logging functions\n"
#endif
+ "ut mem [test-name] - test memory-related commands\n"
#ifdef CONFIG_UT_OPTEE
"ut optee [test-name]\n"
#endif
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index bb8550ffb1..16aa1616c9 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -171,7 +171,7 @@ static int dm_test_acpi_get_name(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_get_name, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_get_name, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test acpi_get_table_revision() */
static int dm_test_acpi_get_table_revision(struct unit_test_state *uts)
@@ -184,7 +184,7 @@ static int dm_test_acpi_get_table_revision(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_acpi_get_table_revision,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test acpi_create_dmar() */
static int dm_test_acpi_create_dmar(struct unit_test_state *uts)
@@ -200,7 +200,7 @@ static int dm_test_acpi_create_dmar(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_create_dmar, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_create_dmar, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test acpi_fill_header() */
static int dm_test_acpi_fill_header(struct unit_test_state *uts)
@@ -227,7 +227,7 @@ static int dm_test_acpi_fill_header(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_fill_header, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_fill_header, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test ACPI write_tables() */
static int dm_test_acpi_write_tables(struct unit_test_state *uts)
@@ -268,7 +268,7 @@ static int dm_test_acpi_write_tables(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_write_tables, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_write_tables, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test basic ACPI functions */
static int dm_test_acpi_basic(struct unit_test_state *uts)
@@ -296,7 +296,7 @@ static int dm_test_acpi_basic(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_basic, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_basic, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test acpi_setup_base_tables */
static int dm_test_acpi_setup_base_tables(struct unit_test_state *uts)
@@ -344,7 +344,7 @@ static int dm_test_acpi_setup_base_tables(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_acpi_setup_base_tables,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test 'acpi list' command */
static int dm_test_acpi_cmd_list(struct unit_test_state *uts)
@@ -386,7 +386,7 @@ static int dm_test_acpi_cmd_list(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_cmd_list, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_cmd_list, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test 'acpi dump' command */
static int dm_test_acpi_cmd_dump(struct unit_test_state *uts)
@@ -417,7 +417,7 @@ static int dm_test_acpi_cmd_dump(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_cmd_dump, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_cmd_dump, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test acpi_device_path() */
static int dm_test_acpi_device_path(struct unit_test_state *uts)
@@ -454,7 +454,7 @@ static int dm_test_acpi_device_path(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_device_path, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_device_path, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test acpi_device_status() */
static int dm_test_acpi_device_status(struct unit_test_state *uts)
@@ -466,7 +466,7 @@ static int dm_test_acpi_device_status(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_device_status, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_device_status, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test acpi_fill_ssdt() */
static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts)
@@ -496,7 +496,7 @@ static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_fill_ssdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_fill_ssdt, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test acpi_inject_dsdt() */
static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts)
@@ -526,7 +526,7 @@ static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_inject_dsdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_inject_dsdt, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test 'acpi items' command */
static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
@@ -565,4 +565,4 @@ static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_cmd_items, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_cmd_items, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/acpi_dp.c b/test/dm/acpi_dp.c
index 93604b87e1..e0fa61263c 100644
--- a/test/dm/acpi_dp.c
+++ b/test/dm/acpi_dp.c
@@ -489,4 +489,4 @@ static int dm_test_acpi_dp_copy(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_dp_copy, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_dp_copy, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/acpigen.c b/test/dm/acpigen.c
index 14a758d08a..1b2767e732 100644
--- a/test/dm/acpigen.c
+++ b/test/dm/acpigen.c
@@ -167,7 +167,7 @@ static int dm_test_acpi_interrupt(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_interrupt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_interrupt, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test emitting a GPIO descriptor */
static int dm_test_acpi_gpio(struct unit_test_state *uts)
@@ -212,7 +212,7 @@ static int dm_test_acpi_gpio(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_gpio, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test emitting a GPIO descriptor with an interrupt */
static int dm_test_acpi_gpio_irq(struct unit_test_state *uts)
@@ -257,7 +257,7 @@ static int dm_test_acpi_gpio_irq(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_gpio_irq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_gpio_irq, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test emitting either a GPIO or interrupt descriptor */
static int dm_test_acpi_interrupt_or_gpio(struct unit_test_state *uts)
@@ -297,7 +297,7 @@ static int dm_test_acpi_interrupt_or_gpio(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_acpi_interrupt_or_gpio,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test emitting an I2C descriptor */
static int dm_test_acpi_i2c(struct unit_test_state *uts)
@@ -329,7 +329,7 @@ static int dm_test_acpi_i2c(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_i2c, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_i2c, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test emitting a SPI descriptor */
static int dm_test_acpi_spi(struct unit_test_state *uts)
@@ -365,7 +365,7 @@ static int dm_test_acpi_spi(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_spi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_spi, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test emitting a length */
static int dm_test_acpi_len(struct unit_test_state *uts)
@@ -806,7 +806,7 @@ static int dm_test_acpi_gpio_toggle(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_gpio_toggle, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_gpio_toggle, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test writing ACPI code to output power-sequence info */
static int dm_test_acpi_power_seq(struct unit_test_state *uts)
@@ -873,7 +873,7 @@ static int dm_test_acpi_power_seq(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_power_seq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_power_seq, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test writing values */
static int dm_test_acpi_write_values(struct unit_test_state *uts)
@@ -947,7 +947,7 @@ static int dm_test_acpi_scope(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_acpi_scope, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_acpi_scope, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test writing a resource template */
static int dm_test_acpi_resource_template(struct unit_test_state *uts)
diff --git a/test/dm/adc.c b/test/dm/adc.c
index 7fa1d48dd9..8c6e4b0604 100644
--- a/test/dm/adc.c
+++ b/test/dm/adc.c
@@ -33,7 +33,7 @@ static int dm_test_adc_bind(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_adc_bind, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_adc_bind, UT_TESTF_SCAN_FDT);
static int dm_test_adc_wrong_channel_selection(struct unit_test_state *uts)
{
@@ -44,7 +44,7 @@ static int dm_test_adc_wrong_channel_selection(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_adc_wrong_channel_selection, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_adc_wrong_channel_selection, UT_TESTF_SCAN_FDT);
static int dm_test_adc_supply(struct unit_test_state *uts)
{
@@ -80,7 +80,7 @@ static int dm_test_adc_supply(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_adc_supply, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_adc_supply, UT_TESTF_SCAN_FDT);
struct adc_channel adc_channel_test_data[] = {
{ 0, SANDBOX_ADC_CHANNEL0_DATA },
@@ -105,7 +105,7 @@ static int dm_test_adc_single_channel_conversion(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_adc_single_channel_conversion, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_adc_single_channel_conversion, UT_TESTF_SCAN_FDT);
static int dm_test_adc_multi_channel_conversion(struct unit_test_state *uts)
{
@@ -128,7 +128,7 @@ static int dm_test_adc_multi_channel_conversion(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_adc_multi_channel_conversion, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_adc_multi_channel_conversion, UT_TESTF_SCAN_FDT);
static int dm_test_adc_single_channel_shot(struct unit_test_state *uts)
{
@@ -144,7 +144,7 @@ static int dm_test_adc_single_channel_shot(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_adc_single_channel_shot, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_adc_single_channel_shot, UT_TESTF_SCAN_FDT);
static int dm_test_adc_multi_channel_shot(struct unit_test_state *uts)
{
@@ -164,7 +164,7 @@ static int dm_test_adc_multi_channel_shot(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_adc_multi_channel_shot, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_adc_multi_channel_shot, UT_TESTF_SCAN_FDT);
static const int dm_test_adc_uV_data[SANDBOX_ADC_CHANNELS] = {
((u64)SANDBOX_ADC_CHANNEL0_DATA * SANDBOX_BUCK2_INITIAL_EXPECTED_UV) /
@@ -195,4 +195,4 @@ static int dm_test_adc_raw_to_uV(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_adc_raw_to_uV, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_adc_raw_to_uV, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/audio.c b/test/dm/audio.c
index 4bb86e3214..add15ae20e 100644
--- a/test/dm/audio.c
+++ b/test/dm/audio.c
@@ -32,4 +32,4 @@ static int dm_test_audio(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_audio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_audio, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/axi.c b/test/dm/axi.c
index 5b1bbab0b8..dc029df5e4 100644
--- a/test/dm/axi.c
+++ b/test/dm/axi.c
@@ -23,7 +23,7 @@ static int dm_test_axi_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_axi_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_axi_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that sandbox PCI bus numbering works correctly */
static int dm_test_axi_busnum(struct unit_test_state *uts)
@@ -35,7 +35,7 @@ static int dm_test_axi_busnum(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_axi_busnum, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_axi_busnum, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that we can use the store device correctly */
static int dm_test_axi_store(struct unit_test_state *uts)
@@ -76,4 +76,4 @@ static int dm_test_axi_store(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_axi_store, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_axi_store, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/blk.c b/test/dm/blk.c
index 80d671e561..f34c13f751 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -43,7 +43,7 @@ static int dm_test_blk_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_blk_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_blk_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int count_blk_devices(void)
{
@@ -89,7 +89,7 @@ static int dm_test_blk_usb(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_blk_usb, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_blk_usb, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that we can find block devices without probing them */
static int dm_test_blk_find(struct unit_test_state *uts)
@@ -110,7 +110,7 @@ static int dm_test_blk_find(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_blk_find, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_blk_find, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that block device numbering works as expected */
static int dm_test_blk_devnum(struct unit_test_state *uts)
@@ -145,7 +145,7 @@ static int dm_test_blk_devnum(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_blk_devnum, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_blk_devnum, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that we can get a block from its parent */
static int dm_test_blk_get_from_parent(struct unit_test_state *uts)
@@ -163,4 +163,4 @@ static int dm_test_blk_get_from_parent(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_blk_get_from_parent, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_blk_get_from_parent, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/board.c b/test/dm/board.c
index ff50d6c38b..f3e7f63f25 100644
--- a/test/dm/board.c
+++ b/test/dm/board.c
@@ -56,4 +56,4 @@ static int dm_test_board(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_board, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_board, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/bootcount.c b/test/dm/bootcount.c
index 9fd3751ef7..f911984698 100644
--- a/test/dm/bootcount.c
+++ b/test/dm/bootcount.c
@@ -28,5 +28,5 @@ static int dm_test_bootcount(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_bootcount, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_bootcount, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/bus.c b/test/dm/bus.c
index 0707267361..865e8bd9fb 100644
--- a/test/dm/bus.c
+++ b/test/dm/bus.c
@@ -138,7 +138,7 @@ static int dm_test_bus_children(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_bus_children, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_bus_children, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test our functions for accessing children */
static int dm_test_bus_children_funcs(struct unit_test_state *uts)
@@ -177,7 +177,7 @@ static int dm_test_bus_children_funcs(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_bus_children_funcs, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_bus_children_funcs, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_bus_children_of_offset(struct unit_test_state *uts)
{
@@ -201,7 +201,7 @@ static int dm_test_bus_children_of_offset(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_bus_children_of_offset,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
/* Test that we can iterate through children */
static int dm_test_bus_children_iterators(struct unit_test_state *uts)
@@ -232,7 +232,7 @@ static int dm_test_bus_children_iterators(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_bus_children_iterators,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that the bus can store data about each child */
static int test_bus_parent_data(struct unit_test_state *uts)
@@ -299,7 +299,7 @@ static int dm_test_bus_parent_data(struct unit_test_state *uts)
{
return test_bus_parent_data(uts);
}
-DM_TEST(dm_test_bus_parent_data, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_bus_parent_data, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* As above but the size is controlled by the uclass */
static int dm_test_bus_parent_data_uclass(struct unit_test_state *uts)
@@ -329,7 +329,7 @@ static int dm_test_bus_parent_data_uclass(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_bus_parent_data_uclass,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that the bus ops are called when a child is probed/removed */
static int dm_test_bus_parent_ops(struct unit_test_state *uts)
@@ -368,7 +368,7 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_bus_parent_ops, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_bus_parent_ops, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int test_bus_parent_platdata(struct unit_test_state *uts)
{
@@ -443,7 +443,7 @@ static int dm_test_bus_parent_platdata(struct unit_test_state *uts)
{
return test_bus_parent_platdata(uts);
}
-DM_TEST(dm_test_bus_parent_platdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_bus_parent_platdata, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* As above but the size is controlled by the uclass */
static int dm_test_bus_parent_platdata_uclass(struct unit_test_state *uts)
@@ -472,7 +472,7 @@ static int dm_test_bus_parent_platdata_uclass(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_bus_parent_platdata_uclass,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that the child post_bind method is called */
static int dm_test_bus_child_post_bind(struct unit_test_state *uts)
@@ -493,7 +493,7 @@ static int dm_test_bus_child_post_bind(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_bus_child_post_bind, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_bus_child_post_bind, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that the child post_bind method is called */
static int dm_test_bus_child_post_bind_uclass(struct unit_test_state *uts)
@@ -515,7 +515,7 @@ static int dm_test_bus_child_post_bind_uclass(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_bus_child_post_bind_uclass,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/*
* Test that the bus' uclass' child_pre_probe() is called before the
@@ -549,7 +549,7 @@ static int dm_test_bus_child_pre_probe_uclass(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_bus_child_pre_probe_uclass,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/*
* Test that the bus' uclass' child_post_probe() is called after the
@@ -582,4 +582,4 @@ static int dm_test_bus_child_post_probe_uclass(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_bus_child_post_probe_uclass,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/button.c b/test/dm/button.c
index 890f470d97..9117801736 100644
--- a/test/dm/button.c
+++ b/test/dm/button.c
@@ -25,7 +25,7 @@ static int dm_test_button_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_button_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_button_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of the button uclass using the button_gpio driver */
static int dm_test_button_gpio(struct unit_test_state *uts)
@@ -50,7 +50,7 @@ static int dm_test_button_gpio(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_button_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_button_gpio, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test obtaining an BUTTON by label */
static int dm_test_button_label(struct unit_test_state *uts)
@@ -71,4 +71,4 @@ static int dm_test_button_label(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_button_label, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_button_label, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/cache.c b/test/dm/cache.c
index 2e244b109f..bbd8f98d00 100644
--- a/test/dm/cache.c
+++ b/test/dm/cache.c
@@ -19,4 +19,4 @@ static int dm_test_reset(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_reset, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_reset, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/clk.c b/test/dm/clk.c
index 7a39760f25..edca3b49f6 100644
--- a/test/dm/clk.c
+++ b/test/dm/clk.c
@@ -34,7 +34,7 @@ static int dm_test_clk_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_clk_base, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_clk_base, UT_TESTF_SCAN_FDT);
static int dm_test_clk(struct unit_test_state *uts)
{
@@ -161,7 +161,7 @@ static int dm_test_clk(struct unit_test_state *uts)
SANDBOX_CLK_ID_UART1));
return 0;
}
-DM_TEST(dm_test_clk, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_clk, UT_TESTF_SCAN_FDT);
static int dm_test_clk_bulk(struct unit_test_state *uts)
{
@@ -199,4 +199,4 @@ static int dm_test_clk_bulk(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_clk_bulk, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_clk_bulk, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/clk_ccf.c b/test/dm/clk_ccf.c
index da2292a51a..050fa80453 100644
--- a/test/dm/clk_ccf.c
+++ b/test/dm/clk_ccf.c
@@ -96,4 +96,4 @@ static int dm_test_clk_ccf(struct unit_test_state *uts)
return 1;
}
-DM_TEST(dm_test_clk_ccf, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_clk_ccf, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/core.c b/test/dm/core.c
index 9b73ec3aa6..8ed5bf7370 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -167,7 +167,7 @@ static int dm_test_autobind_uclass_pdata_alloc(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_autobind_uclass_pdata_alloc, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_autobind_uclass_pdata_alloc, UT_TESTF_SCAN_PDATA);
/* Test that binding with uclass platdata setting occurs correctly */
static int dm_test_autobind_uclass_pdata_valid(struct unit_test_state *uts)
@@ -193,7 +193,7 @@ static int dm_test_autobind_uclass_pdata_valid(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_autobind_uclass_pdata_valid, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_autobind_uclass_pdata_valid, UT_TESTF_SCAN_PDATA);
/* Test that autoprobe finds all the expected devices */
static int dm_test_autoprobe(struct unit_test_state *uts)
@@ -261,7 +261,7 @@ static int dm_test_autoprobe(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_autoprobe, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_autoprobe, UT_TESTF_SCAN_PDATA);
/* Check that we see the correct platdata in each device */
static int dm_test_platdata(struct unit_test_state *uts)
@@ -279,7 +279,7 @@ static int dm_test_platdata(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_platdata, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_platdata, UT_TESTF_SCAN_PDATA);
/* Test that we can bind, probe, remove, unbind a driver */
static int dm_test_lifecycle(struct unit_test_state *uts)
@@ -335,7 +335,7 @@ static int dm_test_lifecycle(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_lifecycle, DM_TESTF_SCAN_PDATA | DM_TESTF_PROBE_TEST);
+DM_TEST(dm_test_lifecycle, UT_TESTF_SCAN_PDATA | UT_TESTF_PROBE_TEST);
/* Test that we can bind/unbind and the lists update correctly */
static int dm_test_ordering(struct unit_test_state *uts)
@@ -391,7 +391,7 @@ static int dm_test_ordering(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ordering, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_ordering, UT_TESTF_SCAN_PDATA);
/* Check that we can perform operations on a device (do a ping) */
int dm_check_operations(struct unit_test_state *uts, struct udevice *dev,
@@ -449,7 +449,7 @@ static int dm_test_operations(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_operations, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_operations, UT_TESTF_SCAN_PDATA);
/* Remove all drivers and check that things work */
static int dm_test_remove(struct unit_test_state *uts)
@@ -471,7 +471,7 @@ static int dm_test_remove(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_remove, DM_TESTF_SCAN_PDATA | DM_TESTF_PROBE_TEST);
+DM_TEST(dm_test_remove, UT_TESTF_SCAN_PDATA | UT_TESTF_PROBE_TEST);
/* Remove and recreate everything, check for memory leaks */
static int dm_test_leak(struct unit_test_state *uts)
@@ -756,7 +756,7 @@ static int dm_test_uclass_devices_find(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_uclass_devices_find, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_uclass_devices_find, UT_TESTF_SCAN_PDATA);
static int dm_test_uclass_devices_find_by_name(struct unit_test_state *uts)
{
@@ -793,7 +793,7 @@ static int dm_test_uclass_devices_find_by_name(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_uclass_devices_find_by_name, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_uclass_devices_find_by_name, UT_TESTF_SCAN_FDT);
static int dm_test_uclass_devices_get(struct unit_test_state *uts)
{
@@ -810,7 +810,7 @@ static int dm_test_uclass_devices_get(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_uclass_devices_get, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_uclass_devices_get, UT_TESTF_SCAN_PDATA);
static int dm_test_uclass_devices_get_by_name(struct unit_test_state *uts)
{
@@ -854,7 +854,7 @@ static int dm_test_uclass_devices_get_by_name(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_uclass_devices_get_by_name, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_uclass_devices_get_by_name, UT_TESTF_SCAN_FDT);
static int dm_test_device_get_uclass_id(struct unit_test_state *uts)
{
@@ -865,7 +865,7 @@ static int dm_test_device_get_uclass_id(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_device_get_uclass_id, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_device_get_uclass_id, UT_TESTF_SCAN_PDATA);
static int dm_test_uclass_names(struct unit_test_state *uts)
{
@@ -874,7 +874,7 @@ static int dm_test_uclass_names(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_uclass_names, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_uclass_names, UT_TESTF_SCAN_PDATA);
static int dm_test_inactive_child(struct unit_test_state *uts)
{
@@ -905,4 +905,4 @@ static int dm_test_inactive_child(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_inactive_child, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_inactive_child, UT_TESTF_SCAN_PDATA);
diff --git a/test/dm/cpu.c b/test/dm/cpu.c
index 0a75c91087..28869c1d6f 100644
--- a/test/dm/cpu.c
+++ b/test/dm/cpu.c
@@ -47,4 +47,4 @@ static int dm_test_cpu(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_cpu, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_cpu, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/devres.c b/test/dm/devres.c
index 550787495d..e1e088a3ca 100644
--- a/test/dm/devres.c
+++ b/test/dm/devres.c
@@ -40,7 +40,7 @@ static int dm_test_devres_alloc(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_devres_alloc, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_devres_alloc, UT_TESTF_SCAN_PDATA);
/* Test devm_kfree() can be used to free memory too */
static int dm_test_devres_free(struct unit_test_state *uts)
@@ -68,7 +68,7 @@ static int dm_test_devres_free(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_devres_free, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_devres_free, UT_TESTF_SCAN_PDATA);
/* Test that kzalloc() returns memory that is zeroed */
@@ -88,7 +88,7 @@ static int dm_test_devres_kzalloc(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_devres_kzalloc, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_devres_kzalloc, UT_TESTF_SCAN_PDATA);
/* Test that devm_kmalloc_array() allocates an array that can be set */
static int dm_test_devres_kmalloc_array(struct unit_test_state *uts)
@@ -111,7 +111,7 @@ static int dm_test_devres_kmalloc_array(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_devres_kmalloc_array, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_devres_kmalloc_array, UT_TESTF_SCAN_PDATA);
/* Test that devm_kcalloc() allocates a zeroed array */
static int dm_test_devres_kcalloc(struct unit_test_state *uts)
@@ -140,7 +140,7 @@ static int dm_test_devres_kcalloc(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_devres_kcalloc, DM_TESTF_SCAN_PDATA);
+DM_TEST(dm_test_devres_kcalloc, UT_TESTF_SCAN_PDATA);
/* Test devres releases resources automatically as expected */
static int dm_test_devres_phase(struct unit_test_state *uts)
@@ -186,4 +186,4 @@ static int dm_test_devres_phase(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_devres_phase, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_devres_phase, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/dma.c b/test/dm/dma.c
index 1cdc813619..cce47cb218 100644
--- a/test/dm/dma.c
+++ b/test/dm/dma.c
@@ -35,7 +35,7 @@ static int dm_test_dma_m2m(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_dma_m2m, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_dma_m2m, UT_TESTF_SCAN_FDT);
static int dm_test_dma(struct unit_test_state *uts)
{
@@ -77,7 +77,7 @@ static int dm_test_dma(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_dma, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_dma, UT_TESTF_SCAN_FDT);
static int dm_test_dma_rx(struct unit_test_state *uts)
{
@@ -122,4 +122,4 @@ static int dm_test_dma_rx(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_dma_rx, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_dma_rx, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/dsi_host.c b/test/dm/dsi_host.c
index 97917a17c1..6e0a5df704 100644
--- a/test/dm/dsi_host.c
+++ b/test/dm/dsi_host.c
@@ -56,4 +56,4 @@ static int dm_test_dsi_host(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_dsi_host, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_dsi_host, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/eth.c b/test/dm/eth.c
index 1a3eb1839c..fa8a69da70 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -40,7 +40,7 @@ static int dm_test_eth(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_eth, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_eth, UT_TESTF_SCAN_FDT);
static int dm_test_eth_alias(struct unit_test_state *uts)
{
@@ -64,7 +64,7 @@ static int dm_test_eth_alias(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_eth_alias, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_eth_alias, UT_TESTF_SCAN_FDT);
static int dm_test_eth_prime(struct unit_test_state *uts)
{
@@ -84,7 +84,7 @@ static int dm_test_eth_prime(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_eth_prime, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_eth_prime, UT_TESTF_SCAN_FDT);
/**
* This test case is trying to test the following scenario:
@@ -145,7 +145,7 @@ static int dm_test_eth_act(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_eth_act, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_eth_act, UT_TESTF_SCAN_FDT);
/* The asserts include a return on fail; cleanup in the caller */
static int _dm_test_eth_rotate1(struct unit_test_state *uts)
@@ -217,7 +217,7 @@ static int dm_test_eth_rotate(struct unit_test_state *uts)
return retval;
}
-DM_TEST(dm_test_eth_rotate, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_eth_rotate, UT_TESTF_SCAN_FDT);
/* The asserts include a return on fail; cleanup in the caller */
static int _dm_test_net_retry(struct unit_test_state *uts)
@@ -260,7 +260,7 @@ static int dm_test_net_retry(struct unit_test_state *uts)
return retval;
}
-DM_TEST(dm_test_net_retry, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_net_retry, UT_TESTF_SCAN_FDT);
static int sb_check_arp_reply(struct udevice *dev, void *packet,
unsigned int len)
@@ -345,7 +345,7 @@ static int dm_test_eth_async_arp_reply(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_eth_async_arp_reply, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_eth_async_arp_reply, UT_TESTF_SCAN_FDT);
static int sb_check_ping_reply(struct udevice *dev, void *packet,
unsigned int len)
@@ -430,4 +430,4 @@ static int dm_test_eth_async_ping_reply(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_eth_async_ping_reply, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_eth_async_ping_reply, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/fdtdec.c b/test/dm/fdtdec.c
index 56f6f4f6cc..716993f706 100644
--- a/test/dm/fdtdec.c
+++ b/test/dm/fdtdec.c
@@ -58,7 +58,7 @@ static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fdtdec_set_carveout,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
{
@@ -127,4 +127,4 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fdtdec_add_reserved_memory,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
diff --git a/test/dm/firmware.c b/test/dm/firmware.c
index 2b4f49af80..f37bccfe4a 100644
--- a/test/dm/firmware.c
+++ b/test/dm/firmware.c
@@ -20,4 +20,4 @@ static int dm_test_firmware_probe(struct unit_test_state *uts)
"sandbox-firmware", &dev));
return 0;
}
-DM_TEST(dm_test_firmware_probe, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_firmware_probe, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/gpio.c b/test/dm/gpio.c
index f3c467e9ac..4848152644 100644
--- a/test/dm/gpio.c
+++ b/test/dm/gpio.c
@@ -145,7 +145,7 @@ static int dm_test_gpio(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_gpio, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that GPIO open-drain/open-source emulation works correctly */
static int dm_test_gpio_opendrain_opensource(struct unit_test_state *uts)
@@ -234,7 +234,7 @@ static int dm_test_gpio_opendrain_opensource(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_gpio_opendrain_opensource,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that sandbox anonymous GPIOs work correctly */
static int dm_test_gpio_anon(struct unit_test_state *uts)
@@ -256,7 +256,7 @@ static int dm_test_gpio_anon(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_gpio_anon, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_gpio_anon, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that gpio_requestf() works as expected */
static int dm_test_gpio_requestf(struct unit_test_state *uts)
@@ -274,7 +274,7 @@ static int dm_test_gpio_requestf(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_gpio_requestf, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_gpio_requestf, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that gpio_request() copies its string */
static int dm_test_gpio_copy(struct unit_test_state *uts)
@@ -296,7 +296,7 @@ static int dm_test_gpio_copy(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_gpio_copy, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_gpio_copy, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that we don't leak memory with GPIOs */
static int dm_test_gpio_leak(struct unit_test_state *uts)
@@ -308,7 +308,7 @@ static int dm_test_gpio_leak(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_gpio_leak, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_gpio_leak, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that we can find GPIOs using phandles */
static int dm_test_gpio_phandles(struct unit_test_state *uts)
@@ -382,7 +382,7 @@ static int dm_test_gpio_phandles(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_gpio_phandles, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_gpio_phandles, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Check the gpio pin configuration get from device tree information */
static int dm_test_gpio_get_dir_flags(struct unit_test_state *uts)
@@ -418,7 +418,7 @@ static int dm_test_gpio_get_dir_flags(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_gpio_get_dir_flags, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_gpio_get_dir_flags, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of gpio_get_acpi() */
static int dm_test_gpio_get_acpi(struct unit_test_state *uts)
@@ -447,7 +447,7 @@ static int dm_test_gpio_get_acpi(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_gpio_get_acpi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_gpio_get_acpi, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of gpio_get_acpi() with an interrupt GPIO */
static int dm_test_gpio_get_acpi_irq(struct unit_test_state *uts)
@@ -479,4 +479,4 @@ static int dm_test_gpio_get_acpi_irq(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_gpio_get_acpi_irq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_gpio_get_acpi_irq, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/hwspinlock.c b/test/dm/hwspinlock.c
index 49c52bcd63..995759d4d7 100644
--- a/test/dm/hwspinlock.c
+++ b/test/dm/hwspinlock.c
@@ -38,4 +38,4 @@ static int dm_test_hwspinlock_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_hwspinlock_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_hwspinlock_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/i2c.c b/test/dm/i2c.c
index 25b2c7c617..681ce45107 100644
--- a/test/dm/i2c.c
+++ b/test/dm/i2c.c
@@ -42,7 +42,7 @@ static int dm_test_i2c_find(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_i2c_find, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_i2c_find, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_i2c_read_write(struct unit_test_state *uts)
{
@@ -59,7 +59,7 @@ static int dm_test_i2c_read_write(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_i2c_read_write, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_i2c_read_write, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_i2c_speed(struct unit_test_state *uts)
{
@@ -81,7 +81,7 @@ static int dm_test_i2c_speed(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_i2c_speed, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_i2c_speed, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_i2c_offset_len(struct unit_test_state *uts)
{
@@ -98,7 +98,7 @@ static int dm_test_i2c_offset_len(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_i2c_offset_len, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_i2c_offset_len, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_i2c_probe_empty(struct unit_test_state *uts)
{
@@ -113,7 +113,7 @@ static int dm_test_i2c_probe_empty(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_i2c_probe_empty, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_i2c_probe_empty, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_i2c_bytewise(struct unit_test_state *uts)
{
@@ -168,7 +168,7 @@ static int dm_test_i2c_bytewise(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_i2c_bytewise, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_i2c_bytewise, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_i2c_offset(struct unit_test_state *uts)
{
@@ -241,7 +241,7 @@ static int dm_test_i2c_offset(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_i2c_offset, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_i2c_offset, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_i2c_addr_offset(struct unit_test_state *uts)
{
@@ -306,4 +306,4 @@ static int dm_test_i2c_addr_offset(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_i2c_addr_offset, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_i2c_addr_offset, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/i2s.c b/test/dm/i2s.c
index 7a017be064..c2bf4d5604 100644
--- a/test/dm/i2s.c
+++ b/test/dm/i2s.c
@@ -30,4 +30,4 @@ static int dm_test_i2s(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_i2s, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_i2s, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/irq.c b/test/dm/irq.c
index 51bae31b0f..51dd5e4abb 100644
--- a/test/dm/irq.c
+++ b/test/dm/irq.c
@@ -31,7 +31,7 @@ static int dm_test_irq_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_irq_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_irq_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of irq_first_device_type() */
static int dm_test_irq_type(struct unit_test_state *uts)
@@ -43,7 +43,7 @@ static int dm_test_irq_type(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_irq_type, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_irq_type, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of irq_read_and_clear() */
static int dm_test_read_and_clear(struct unit_test_state *uts)
@@ -60,7 +60,7 @@ static int dm_test_read_and_clear(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_read_and_clear, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_read_and_clear, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of irq_request() */
static int dm_test_request(struct unit_test_state *uts)
@@ -75,7 +75,7 @@ static int dm_test_request(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_request, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_request, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of irq_get_acpi() */
static int dm_test_irq_get_acpi(struct unit_test_state *uts)
@@ -97,4 +97,4 @@ static int dm_test_irq_get_acpi(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_irq_get_acpi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_irq_get_acpi, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/led.c b/test/dm/led.c
index 3d5ad9363b..8b587d0a22 100644
--- a/test/dm/led.c
+++ b/test/dm/led.c
@@ -26,7 +26,7 @@ static int dm_test_led_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_led_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_led_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of the LED 'default-state' device tree property */
static int dm_test_led_default_state(struct unit_test_state *uts)
@@ -45,7 +45,7 @@ static int dm_test_led_default_state(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_led_default_state, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_led_default_state, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of the led uclass using the led_gpio driver */
static int dm_test_led_gpio(struct unit_test_state *uts)
@@ -70,7 +70,7 @@ static int dm_test_led_gpio(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_led_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_led_gpio, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that we can toggle LEDs */
static int dm_test_led_toggle(struct unit_test_state *uts)
@@ -95,7 +95,7 @@ static int dm_test_led_toggle(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_led_toggle, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_led_toggle, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test obtaining an LED by label */
static int dm_test_led_label(struct unit_test_state *uts)
@@ -116,7 +116,7 @@ static int dm_test_led_label(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_led_label, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_led_label, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test LED blinking */
#ifdef CONFIG_LED_BLINK
@@ -139,5 +139,5 @@ static int dm_test_led_blink(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_led_blink, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_led_blink, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
#endif
diff --git a/test/dm/mailbox.c b/test/dm/mailbox.c
index e9c8ab1a95..7ad8a1cbba 100644
--- a/test/dm/mailbox.c
+++ b/test/dm/mailbox.c
@@ -29,4 +29,4 @@ static int dm_test_mailbox(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_mailbox, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_mailbox, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/mdio.c b/test/dm/mdio.c
index 758bbb2cc5..64347e1275 100644
--- a/test/dm/mdio.c
+++ b/test/dm/mdio.c
@@ -55,4 +55,4 @@ static int dm_test_mdio(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_mdio, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_mdio, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/mdio_mux.c b/test/dm/mdio_mux.c
index 0b3f85a53b..950f385d17 100644
--- a/test/dm/mdio_mux.c
+++ b/test/dm/mdio_mux.c
@@ -78,4 +78,4 @@ static int dm_test_mdio_mux(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_mdio_mux, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_mdio_mux, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/misc.c b/test/dm/misc.c
index 641070972d..1506fdefe3 100644
--- a/test/dm/misc.c
+++ b/test/dm/misc.c
@@ -81,4 +81,4 @@ static int dm_test_misc(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_misc, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_misc, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/mmc.c b/test/dm/mmc.c
index 8e1fd3fe51..4e5136c850 100644
--- a/test/dm/mmc.c
+++ b/test/dm/mmc.c
@@ -23,7 +23,7 @@ static int dm_test_mmc_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_mmc_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_mmc_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_mmc_blk(struct unit_test_state *uts)
{
@@ -42,4 +42,4 @@ static int dm_test_mmc_blk(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_mmc_blk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_mmc_blk, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/nop.c b/test/dm/nop.c
index 8b3b646892..2cd92c5240 100644
--- a/test/dm/nop.c
+++ b/test/dm/nop.c
@@ -71,4 +71,4 @@ static int dm_test_nop(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_nop, DM_TESTF_FLAT_TREE | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_nop, UT_TESTF_FLAT_TREE | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index e01acc4fe9..8bfb706602 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -17,7 +17,7 @@ static int dm_test_ofnode_compatible(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ofnode_compatible, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_ofnode_compatible, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_ofnode_by_prop_value(struct unit_test_state *uts)
{
@@ -44,7 +44,7 @@ static int dm_test_ofnode_by_prop_value(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ofnode_by_prop_value, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_ofnode_by_prop_value, UT_TESTF_SCAN_FDT);
static int dm_test_ofnode_fmap(struct unit_test_state *uts)
{
@@ -59,7 +59,7 @@ static int dm_test_ofnode_fmap(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ofnode_fmap, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_ofnode_fmap, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_ofnode_read(struct unit_test_state *uts)
{
@@ -85,7 +85,7 @@ static int dm_test_ofnode_read(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ofnode_read, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_ofnode_read, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_ofnode_read_chosen(struct unit_test_state *uts)
{
@@ -114,7 +114,7 @@ static int dm_test_ofnode_read_chosen(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ofnode_read_chosen, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_ofnode_read_chosen, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_ofnode_get_child_count(struct unit_test_state *uts)
{
@@ -135,4 +135,4 @@ static int dm_test_ofnode_get_child_count(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_ofnode_get_child_count,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/ofread.c b/test/dm/ofread.c
index f2a1382259..9064426e21 100644
--- a/test/dm/ofread.c
+++ b/test/dm/ofread.c
@@ -47,4 +47,4 @@ static int dm_test_ofnode_get_property_by_prop(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_ofnode_get_property_by_prop,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/osd.c b/test/dm/osd.c
index 8784867ecb..6279b391ca 100644
--- a/test/dm/osd.c
+++ b/test/dm/osd.c
@@ -132,7 +132,7 @@ static int dm_test_osd_basics(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_osd_basics, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_osd_basics, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_osd_extended(struct unit_test_state *uts)
{
@@ -216,4 +216,4 @@ static int dm_test_osd_extended(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_osd_extended, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_osd_extended, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/p2sb.c b/test/dm/p2sb.c
index ccb75cf375..df24709141 100644
--- a/test/dm/p2sb.c
+++ b/test/dm/p2sb.c
@@ -25,4 +25,4 @@ static int dm_test_p2sb_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_p2sb_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_p2sb_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/panel.c b/test/dm/panel.c
index 410e8f3907..a840fb4951 100644
--- a/test/dm/panel.c
+++ b/test/dm/panel.c
@@ -77,4 +77,4 @@ static int dm_test_panel(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_panel, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_panel, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/pch.c b/test/dm/pch.c
index bf17a31ccf..53f7bbf180 100644
--- a/test/dm/pch.c
+++ b/test/dm/pch.c
@@ -34,7 +34,7 @@ static int dm_test_pch_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pch_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pch_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test sandbox PCH ioctl */
static int dm_test_pch_ioctl(struct unit_test_state *uts)
@@ -53,4 +53,4 @@ static int dm_test_pch_ioctl(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pch_ioctl, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pch_ioctl, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/pci.c b/test/dm/pci.c
index a492fc0355..fd66ed7899 100644
--- a/test/dm/pci.c
+++ b/test/dm/pci.c
@@ -20,7 +20,7 @@ static int dm_test_pci_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pci_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that sandbox PCI bus numbering and device works correctly */
static int dm_test_pci_busdev(struct unit_test_state *uts)
@@ -55,7 +55,7 @@ static int dm_test_pci_busdev(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_busdev, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pci_busdev, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that we can use the swapcase device correctly */
static int dm_test_pci_swapcase(struct unit_test_state *uts)
@@ -108,7 +108,7 @@ static int dm_test_pci_swapcase(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_swapcase, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pci_swapcase, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that we can dynamically bind the device driver correctly */
static int dm_test_pci_drvdata(struct unit_test_state *uts)
@@ -130,7 +130,7 @@ static int dm_test_pci_drvdata(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_drvdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pci_drvdata, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that devices on PCI bus#2 can be accessed correctly */
static int dm_test_pci_mixed(struct unit_test_state *uts)
@@ -193,7 +193,7 @@ static int dm_test_pci_mixed(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_mixed, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pci_mixed, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test looking up PCI capability and extended capability */
static int dm_test_pci_cap(struct unit_test_state *uts)
@@ -245,7 +245,7 @@ static int dm_test_pci_cap(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_cap, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pci_cap, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test looking up BARs in EA capability structure */
static int dm_test_pci_ea(struct unit_test_state *uts)
@@ -294,7 +294,7 @@ static int dm_test_pci_ea(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_ea, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pci_ea, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test the dev_read_addr_pci() function */
static int dm_test_pci_addr_flat(struct unit_test_state *uts)
@@ -316,14 +316,14 @@ static int dm_test_pci_addr_flat(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_addr_flat, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT |
- DM_TESTF_FLAT_TREE);
+DM_TEST(dm_test_pci_addr_flat, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT |
+ UT_TESTF_FLAT_TREE);
/*
* Test the dev_read_addr_pci() function with livetree. That function is
* not currently fully implemented, in that it fails to return the BAR address.
* Once that is implemented this test can be removed and dm_test_pci_addr_flat()
- * can be used for both flattree and livetree by removing the DM_TESTF_FLAT_TREE
+ * can be used for both flattree and livetree by removing the UT_TESTF_FLAT_TREE
* flag above.
*/
static int dm_test_pci_addr_live(struct unit_test_state *uts)
@@ -338,8 +338,8 @@ static int dm_test_pci_addr_live(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_addr_live, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT |
- DM_TESTF_LIVE_TREE);
+DM_TEST(dm_test_pci_addr_live, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT |
+ UT_TESTF_LIVE_TREE);
/* Test device_is_on_pci_bus() */
static int dm_test_pci_on_bus(struct unit_test_state *uts)
@@ -353,4 +353,4 @@ static int dm_test_pci_on_bus(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_on_bus, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pci_on_bus, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/pci_ep.c b/test/dm/pci_ep.c
index a29d00eebe..9b03b8bae3 100644
--- a/test/dm/pci_ep.c
+++ b/test/dm/pci_ep.c
@@ -61,5 +61,5 @@ static int dm_test_pci_ep_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pci_ep_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pci_ep_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/phy.c b/test/dm/phy.c
index 1a59899327..75d05a14c0 100644
--- a/test/dm/phy.c
+++ b/test/dm/phy.c
@@ -53,7 +53,7 @@ static int dm_test_phy_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_phy_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_phy_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of the phy uclass using the sandbox phy driver operations */
static int dm_test_phy_ops(struct unit_test_state *uts)
@@ -111,7 +111,7 @@ static int dm_test_phy_ops(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_phy_ops, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_phy_ops, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_phy_bulk(struct unit_test_state *uts)
{
@@ -144,4 +144,4 @@ static int dm_test_phy_bulk(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_phy_bulk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_phy_bulk, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/pmc.c b/test/dm/pmc.c
index 1a222838ab..e70227e780 100644
--- a/test/dm/pmc.c
+++ b/test/dm/pmc.c
@@ -30,4 +30,4 @@ static int dm_test_pmc_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pmc_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pmc_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/pmic.c b/test/dm/pmic.c
index 8c2766aeac..ce671202fb 100644
--- a/test/dm/pmic.c
+++ b/test/dm/pmic.c
@@ -44,7 +44,7 @@ static int dm_test_power_pmic_get(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_pmic_get, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_pmic_get, UT_TESTF_SCAN_FDT);
/* PMIC get method - MC34708 - for 3 bytes transmission */
static int dm_test_power_pmic_mc34708_get(struct unit_test_state *uts)
@@ -54,7 +54,7 @@ static int dm_test_power_pmic_mc34708_get(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_pmic_mc34708_get, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_pmic_mc34708_get, UT_TESTF_SCAN_FDT);
/* Test PMIC I/O */
static int dm_test_power_pmic_io(struct unit_test_state *uts)
@@ -83,7 +83,7 @@ static int dm_test_power_pmic_io(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_pmic_io, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_pmic_io, UT_TESTF_SCAN_FDT);
#define MC34708_PMIC_REG_COUNT 64
#define MC34708_PMIC_TEST_VAL 0x125534
@@ -101,7 +101,7 @@ static int dm_test_power_pmic_mc34708_regs_check(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_pmic_mc34708_regs_check, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_pmic_mc34708_regs_check, UT_TESTF_SCAN_FDT);
static int dm_test_power_pmic_mc34708_rw_val(struct unit_test_state *uts)
{
@@ -128,4 +128,4 @@ static int dm_test_power_pmic_mc34708_rw_val(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_pmic_mc34708_rw_val, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_pmic_mc34708_rw_val, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/power-domain.c b/test/dm/power-domain.c
index 52f88c5a36..8604b5d72d 100644
--- a/test/dm/power-domain.c
+++ b/test/dm/power-domain.c
@@ -46,4 +46,4 @@ static int dm_test_power_domain(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_domain, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_domain, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/pwm.c b/test/dm/pwm.c
index 8cc911e1ad..0de6dba1ba 100644
--- a/test/dm/pwm.c
+++ b/test/dm/pwm.c
@@ -29,4 +29,4 @@ static int dm_test_pwm_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_pwm_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_pwm_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/ram.c b/test/dm/ram.c
index 2456466b56..f01236c8cd 100644
--- a/test/dm/ram.c
+++ b/test/dm/ram.c
@@ -25,4 +25,4 @@ static int dm_test_ram_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ram_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_ram_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/regmap.c b/test/dm/regmap.c
index 42cc4cb0c0..bd21c8365d 100644
--- a/test/dm/regmap.c
+++ b/test/dm/regmap.c
@@ -67,7 +67,7 @@ static int dm_test_regmap_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_regmap_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_regmap_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test we can access a regmap through syscon */
static int dm_test_regmap_syscon(struct unit_test_state *uts)
@@ -93,7 +93,7 @@ static int dm_test_regmap_syscon(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_regmap_syscon, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_regmap_syscon, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Read/Write/Modify test */
static int dm_test_regmap_rw(struct unit_test_state *uts)
@@ -127,7 +127,7 @@ static int dm_test_regmap_rw(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_regmap_rw, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_regmap_rw, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Get/Set test */
static int dm_test_regmap_getset(struct unit_test_state *uts)
@@ -158,7 +158,7 @@ static int dm_test_regmap_getset(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_regmap_getset, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_regmap_getset, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Read polling test */
static int dm_test_regmap_poll(struct unit_test_state *uts)
@@ -186,4 +186,4 @@ static int dm_test_regmap_poll(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_regmap_poll, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_regmap_poll, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/regulator.c b/test/dm/regulator.c
index f412ec20c5..0e7a232a70 100644
--- a/test/dm/regulator.c
+++ b/test/dm/regulator.c
@@ -90,7 +90,7 @@ static int dm_test_power_regulator_get(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_regulator_get, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_regulator_get, UT_TESTF_SCAN_FDT);
/* Test regulator set and get Voltage method */
static int dm_test_power_regulator_set_get_voltage(struct unit_test_state *uts)
@@ -117,7 +117,7 @@ static int dm_test_power_regulator_set_get_voltage(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_regulator_set_get_voltage, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_regulator_set_get_voltage, UT_TESTF_SCAN_FDT);
/* Test regulator set and get Current method */
static int dm_test_power_regulator_set_get_current(struct unit_test_state *uts)
@@ -156,7 +156,7 @@ static int dm_test_power_regulator_set_get_current(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_regulator_set_get_current, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_regulator_set_get_current, UT_TESTF_SCAN_FDT);
/* Test regulator set and get Enable method */
static int dm_test_power_regulator_set_get_enable(struct unit_test_state *uts)
@@ -175,7 +175,7 @@ static int dm_test_power_regulator_set_get_enable(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_regulator_set_get_enable, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_regulator_set_get_enable, UT_TESTF_SCAN_FDT);
/* Test regulator set and get enable if allowed method */
static
@@ -196,7 +196,7 @@ int dm_test_power_regulator_set_enable_if_allowed(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_regulator_set_enable_if_allowed, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_regulator_set_enable_if_allowed, UT_TESTF_SCAN_FDT);
/* Test regulator set and get mode method */
static int dm_test_power_regulator_set_get_mode(struct unit_test_state *uts)
@@ -215,7 +215,7 @@ static int dm_test_power_regulator_set_get_mode(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_regulator_set_get_mode, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_regulator_set_get_mode, UT_TESTF_SCAN_FDT);
/* Test regulator set and get suspend Voltage method */
static int dm_test_power_regulator_set_get_suspend_voltage(struct unit_test_state *uts)
@@ -245,7 +245,7 @@ static int dm_test_power_regulator_set_get_suspend_voltage(struct unit_test_stat
}
return 0;
}
-DM_TEST(dm_test_power_regulator_set_get_suspend_voltage, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_regulator_set_get_suspend_voltage, UT_TESTF_SCAN_FDT);
/* Test regulator set and get suspend Enable method */
static int dm_test_power_regulator_set_get_suspend_enable(struct unit_test_state *uts)
@@ -272,7 +272,7 @@ static int dm_test_power_regulator_set_get_suspend_enable(struct unit_test_state
}
return 0;
}
-DM_TEST(dm_test_power_regulator_set_get_suspend_enable, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_regulator_set_get_suspend_enable, UT_TESTF_SCAN_FDT);
/* Test regulator autoset method */
static int dm_test_power_regulator_autoset(struct unit_test_state *uts)
@@ -305,7 +305,7 @@ static int dm_test_power_regulator_autoset(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_regulator_autoset, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_regulator_autoset, UT_TESTF_SCAN_FDT);
/*
* Struct setting: to keep the expected output settings.
@@ -401,4 +401,4 @@ static int dm_test_power_regulator_autoset_list(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_power_regulator_autoset_list, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_power_regulator_autoset_list, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/remoteproc.c b/test/dm/remoteproc.c
index c6bf2c4c46..1cc07bc808 100644
--- a/test/dm/remoteproc.c
+++ b/test/dm/remoteproc.c
@@ -68,7 +68,7 @@ static int dm_test_remoteproc_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_remoteproc_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_remoteproc_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
#define DEVICE_TO_PHYSICAL_OFFSET 0x1000
/**
@@ -256,4 +256,4 @@ static int dm_test_remoteproc_elf(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_remoteproc_elf, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_remoteproc_elf, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/reset.c b/test/dm/reset.c
index 8232807264..f5f366151f 100644
--- a/test/dm/reset.c
+++ b/test/dm/reset.c
@@ -39,7 +39,7 @@ static int dm_test_reset_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_reset_base, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_reset_base, UT_TESTF_SCAN_FDT);
static int dm_test_reset(struct unit_test_state *uts)
{
@@ -64,7 +64,7 @@ static int dm_test_reset(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_reset, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_reset, UT_TESTF_SCAN_FDT);
static int dm_test_reset_bulk(struct unit_test_state *uts)
{
@@ -94,4 +94,4 @@ static int dm_test_reset_bulk(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_reset_bulk, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_reset_bulk, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/rng.c b/test/dm/rng.c
index 583ce9eddf..5b34c93ed6 100644
--- a/test/dm/rng.c
+++ b/test/dm/rng.c
@@ -24,4 +24,4 @@ static int dm_test_rng_read(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_rng_read, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_rng_read, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/rtc.c b/test/dm/rtc.c
index 42a9195b73..8ab997c87d 100644
--- a/test/dm/rtc.c
+++ b/test/dm/rtc.c
@@ -28,7 +28,7 @@ static int dm_test_rtc_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_rtc_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_rtc_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static void show_time(const char *msg, struct rtc_time *time)
{
@@ -131,7 +131,7 @@ static int dm_test_rtc_set_get(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_rtc_set_get, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_rtc_set_get, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_rtc_read_write(struct unit_test_state *uts)
{
@@ -175,7 +175,7 @@ static int dm_test_rtc_read_write(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_rtc_read_write, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_rtc_read_write, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test 'rtc list' command */
static int dm_test_rtc_cmd_list(struct unit_test_state *uts)
@@ -189,7 +189,7 @@ static int dm_test_rtc_cmd_list(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_rtc_cmd_list, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_rtc_cmd_list, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test 'rtc read' and 'rtc write' commands */
static int dm_test_rtc_cmd_rw(struct unit_test_state *uts)
@@ -232,7 +232,7 @@ static int dm_test_rtc_cmd_rw(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_rtc_cmd_rw, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_rtc_cmd_rw, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Reset the time */
static int dm_test_rtc_reset(struct unit_test_state *uts)
@@ -258,7 +258,7 @@ static int dm_test_rtc_reset(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_rtc_reset, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_rtc_reset, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Check that two RTC devices can be used independently */
static int dm_test_rtc_dual(struct unit_test_state *uts)
@@ -290,4 +290,4 @@ static int dm_test_rtc_dual(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_rtc_dual, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_rtc_dual, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/serial.c b/test/dm/serial.c
index a1b122ec1d..0662b5f09b 100644
--- a/test/dm/serial.c
+++ b/test/dm/serial.c
@@ -69,4 +69,4 @@ static int dm_test_serial(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_serial, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_serial, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/sf.c b/test/dm/sf.c
index 0f2808fca4..cc1fc4d69a 100644
--- a/test/dm/sf.c
+++ b/test/dm/sf.c
@@ -65,7 +65,7 @@ static int dm_test_spi_flash(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_spi_flash, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_spi_flash, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Functional test that sandbox SPI flash works correctly */
static int dm_test_spi_flash_func(struct unit_test_state *uts)
@@ -93,4 +93,4 @@ static int dm_test_spi_flash_func(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_spi_flash_func, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_spi_flash_func, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/simple-pm-bus.c b/test/dm/simple-pm-bus.c
index 978c7f191e..792c745058 100644
--- a/test/dm/simple-pm-bus.c
+++ b/test/dm/simple-pm-bus.c
@@ -42,4 +42,4 @@ static int dm_test_simple_pm_bus(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_simple_pm_bus, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_simple_pm_bus, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/smem.c b/test/dm/smem.c
index 21dd96e409..a797026cb5 100644
--- a/test/dm/smem.c
+++ b/test/dm/smem.c
@@ -24,5 +24,5 @@ static int dm_test_smem_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_smem_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_smem_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/soc.c b/test/dm/soc.c
index 3ad0f561f2..17e1b5ba01 100644
--- a/test/dm/soc.c
+++ b/test/dm/soc.c
@@ -117,4 +117,4 @@ static int dm_test_soc(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_soc, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_soc, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/sound.c b/test/dm/sound.c
index 9cb9961058..b73f6ab111 100644
--- a/test/dm/sound.c
+++ b/test/dm/sound.c
@@ -33,7 +33,7 @@ static int dm_test_sound(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_sound, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_sound, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of the 'start beep' operations */
static int dm_test_sound_beep(struct unit_test_state *uts)
@@ -54,4 +54,4 @@ static int dm_test_sound_beep(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_sound_beep, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_sound_beep, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/spi.c b/test/dm/spi.c
index 10b89e7acf..fb180aed1f 100644
--- a/test/dm/spi.c
+++ b/test/dm/spi.c
@@ -92,7 +92,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_spi_find, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_spi_find, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that sandbox SPI works correctly */
static int dm_test_spi_xfer(struct unit_test_state *uts)
@@ -124,4 +124,4 @@ static int dm_test_spi_xfer(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_spi_xfer, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_spi_xfer, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/spmi.c b/test/dm/spmi.c
index 4aae1f166d..114fd2d22e 100644
--- a/test/dm/spmi.c
+++ b/test/dm/spmi.c
@@ -44,7 +44,7 @@ static int dm_test_spmi_probe(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_spmi_probe, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_spmi_probe, UT_TESTF_SCAN_FDT);
/* Test if it's possible to read bus directly and indirectly */
static int dm_test_spmi_access(struct unit_test_state *uts)
@@ -69,7 +69,7 @@ static int dm_test_spmi_access(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_spmi_access, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_spmi_access, UT_TESTF_SCAN_FDT);
/* Test if it's possible to access GPIO that should be in pmic */
@@ -110,4 +110,4 @@ static int dm_test_spmi_access_peripheral(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_spmi_access_peripheral, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_spmi_access_peripheral, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/syscon-reset.c b/test/dm/syscon-reset.c
index edabdb2e78..eeaddf8839 100644
--- a/test/dm/syscon-reset.c
+++ b/test/dm/syscon-reset.c
@@ -56,4 +56,4 @@ static int dm_test_syscon_reset(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_syscon_reset, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_syscon_reset, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/syscon.c b/test/dm/syscon.c
index b2d0ade95e..be23297233 100644
--- a/test/dm/syscon.c
+++ b/test/dm/syscon.c
@@ -29,7 +29,7 @@ static int dm_test_syscon_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_syscon_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_syscon_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test system controller finding */
static int dm_test_syscon_by_driver_data(struct unit_test_state *uts)
@@ -46,7 +46,7 @@ static int dm_test_syscon_by_driver_data(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_syscon_by_driver_data, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_syscon_by_driver_data, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test system controller by phandle */
static int dm_test_syscon_by_phandle(struct unit_test_state *uts)
@@ -81,4 +81,4 @@ static int dm_test_syscon_by_phandle(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_syscon_by_phandle, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_syscon_by_phandle, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/sysreset.c b/test/dm/sysreset.c
index e5cd18cd82..aec97b1cbb 100644
--- a/test/dm/sysreset.c
+++ b/test/dm/sysreset.c
@@ -44,7 +44,7 @@ static int dm_test_sysreset_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_sysreset_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_sysreset_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_sysreset_get_status(struct unit_test_state *uts)
{
@@ -63,7 +63,7 @@ static int dm_test_sysreset_get_status(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_sysreset_get_status, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_sysreset_get_status, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that we can walk through the sysreset devices */
static int dm_test_sysreset_walk(struct unit_test_state *uts)
@@ -91,7 +91,7 @@ static int dm_test_sysreset_walk(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_sysreset_walk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_sysreset_walk, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_sysreset_get_last(struct unit_test_state *uts)
{
@@ -110,4 +110,4 @@ static int dm_test_sysreset_get_last(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_sysreset_get_last, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_sysreset_get_last, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/tee.c b/test/dm/tee.c
index fec9551fb2..ddbdcfb0cf 100644
--- a/test/dm/tee.c
+++ b/test/dm/tee.c
@@ -115,4 +115,4 @@ static int dm_test_tee(struct unit_test_state *uts)
return rc;
}
-DM_TEST(dm_test_tee, DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_tee, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index c64ac405ed..ac8ce99f51 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -390,7 +390,7 @@ static int dm_test_fdt_uclass_seq(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_fdt_uclass_seq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_fdt_uclass_seq, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that we can find a device by device tree offset */
static int dm_test_fdt_offset(struct unit_test_state *uts)
@@ -420,7 +420,7 @@ static int dm_test_fdt_offset(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fdt_offset,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
/**
* Test various error conditions with uclass_first_device() and
@@ -461,7 +461,7 @@ static int dm_test_first_next_device(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_first_next_device, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_first_next_device, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test iteration through devices in a uclass */
static int dm_test_uclass_foreach(struct unit_test_state *uts)
@@ -482,7 +482,7 @@ static int dm_test_uclass_foreach(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_uclass_foreach, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_uclass_foreach, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/**
* check_devices() - Check return values and pointers
@@ -562,7 +562,7 @@ static int dm_test_first_next_ok_device(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_first_next_ok_device, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_first_next_ok_device, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static const struct udevice_id fdt_dummy_ids[] = {
{ .compatible = "denx,u-boot-fdt-dummy", },
@@ -617,7 +617,7 @@ static int dm_test_fdt_translation(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_fdt_translation, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_fdt_translation, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_fdt_remap_addr_flat(struct unit_test_state *uts)
{
@@ -637,7 +637,7 @@ static int dm_test_fdt_remap_addr_flat(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fdt_remap_addr_flat,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
static int dm_test_fdt_remap_addr_index_flat(struct unit_test_state *uts)
{
@@ -659,7 +659,7 @@ static int dm_test_fdt_remap_addr_index_flat(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fdt_remap_addr_index_flat,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
static int dm_test_fdt_remap_addr_name_flat(struct unit_test_state *uts)
{
@@ -681,7 +681,7 @@ static int dm_test_fdt_remap_addr_name_flat(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fdt_remap_addr_name_flat,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
static int dm_test_fdt_remap_addr_live(struct unit_test_state *uts)
{
@@ -701,7 +701,7 @@ static int dm_test_fdt_remap_addr_live(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fdt_remap_addr_live,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_fdt_remap_addr_index_live(struct unit_test_state *uts)
{
@@ -723,7 +723,7 @@ static int dm_test_fdt_remap_addr_index_live(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fdt_remap_addr_index_live,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_fdt_remap_addr_name_live(struct unit_test_state *uts)
{
@@ -745,7 +745,7 @@ static int dm_test_fdt_remap_addr_name_live(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_fdt_remap_addr_name_live,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_fdt_livetree_writing(struct unit_test_state *uts)
{
@@ -797,7 +797,7 @@ static int dm_test_fdt_livetree_writing(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_fdt_livetree_writing, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_fdt_livetree_writing, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_fdt_disable_enable_by_path(struct unit_test_state *uts)
{
@@ -824,8 +824,8 @@ static int dm_test_fdt_disable_enable_by_path(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_fdt_disable_enable_by_path, DM_TESTF_SCAN_PDATA |
- DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_fdt_disable_enable_by_path, UT_TESTF_SCAN_PDATA |
+ UT_TESTF_SCAN_FDT);
/* Test a few uclass phandle functions */
static int dm_test_fdt_phandle(struct unit_test_state *uts)
@@ -847,7 +847,7 @@ static int dm_test_fdt_phandle(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_fdt_phandle, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_fdt_phandle, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test device_find_first_child_by_uclass() */
static int dm_test_first_child(struct unit_test_state *uts)
@@ -874,7 +874,7 @@ static int dm_test_first_child(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_first_child, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_first_child, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test integer functions in dm_read_...() */
static int dm_test_read_int(struct unit_test_state *uts)
@@ -919,7 +919,7 @@ static int dm_test_read_int(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_read_int, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_read_int, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int dm_test_read_int_index(struct unit_test_state *uts)
{
@@ -948,7 +948,7 @@ static int dm_test_read_int_index(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_read_int_index, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_read_int_index, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test iteration through devices by drvdata */
static int dm_test_uclass_drvdata(struct unit_test_state *uts)
@@ -969,7 +969,7 @@ static int dm_test_uclass_drvdata(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_uclass_drvdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_uclass_drvdata, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test device_first_child_ofdata_err(), etc. */
static int dm_test_child_ofdata(struct unit_test_state *uts)
@@ -988,7 +988,7 @@ static int dm_test_child_ofdata(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_child_ofdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_child_ofdata, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test device_first_child_err(), etc. */
static int dm_test_first_child_probe(struct unit_test_state *uts)
@@ -1007,7 +1007,7 @@ static int dm_test_first_child_probe(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_first_child_probe, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_first_child_probe, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test that ofdata is read for parents before children */
static int dm_test_ofdata_order(struct unit_test_state *uts)
@@ -1032,4 +1032,4 @@ static int dm_test_ofdata_order(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_ofdata_order, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_ofdata_order, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 6d197d0d61..38b7b1481a 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -89,11 +89,11 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,
ut_assertok(dm_test_init(uts, of_live));
uts->start = mallinfo();
- if (test->flags & DM_TESTF_SCAN_PDATA)
+ if (test->flags & UT_TESTF_SCAN_PDATA)
ut_assertok(dm_scan_platdata(false));
- if (test->flags & DM_TESTF_PROBE_TEST)
+ if (test->flags & UT_TESTF_PROBE_TEST)
ut_assertok(do_autoprobe(uts));
- if (test->flags & DM_TESTF_SCAN_FDT)
+ if (test->flags & UT_TESTF_SCAN_FDT)
ut_assertok(dm_extended_scan_fdt(gd->fdt_blob, false));
/*
@@ -168,7 +168,7 @@ static int dm_test_main(const char *test_name)
/* Run with the live tree if possible */
runs = 0;
if (IS_ENABLED(CONFIG_OF_LIVE)) {
- if (!(test->flags & DM_TESTF_FLAT_TREE)) {
+ if (!(test->flags & UT_TESTF_FLAT_TREE)) {
ut_assertok(dm_do_test(uts, test, true));
runs++;
}
@@ -178,7 +178,7 @@ static int dm_test_main(const char *test_name)
* Run with the flat tree if we couldn't run it with live tree,
* or it is a core test.
*/
- if (!(test->flags & DM_TESTF_LIVE_TREE) &&
+ if (!(test->flags & UT_TESTF_LIVE_TREE) &&
(!runs || dm_test_run_on_flattree(test))) {
ut_assertok(dm_do_test(uts, test, false));
runs++;
diff --git a/test/dm/timer.c b/test/dm/timer.c
index 4aa5eeac75..95dab97665 100644
--- a/test/dm/timer.c
+++ b/test/dm/timer.c
@@ -22,4 +22,4 @@ static int dm_test_timer_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_timer_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_timer_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/usb.c b/test/dm/usb.c
index 6cbb66c82b..db4b8ba0f7 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -34,7 +34,7 @@ static int dm_test_usb_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_usb_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_usb_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/*
* Test that we can use the flash stick. This is more of a functional test. It
@@ -61,7 +61,7 @@ static int dm_test_usb_flash(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_usb_flash, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_usb_flash, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* test that we can handle multiple storage devices */
static int dm_test_usb_multi(struct unit_test_state *uts)
@@ -77,7 +77,7 @@ static int dm_test_usb_multi(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_usb_multi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_usb_multi, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* test that we have an associated ofnode with the usb device */
static int dm_test_usb_fdt_node(struct unit_test_state *uts)
@@ -99,7 +99,7 @@ static int dm_test_usb_fdt_node(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_usb_fdt_node, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_usb_fdt_node, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int count_usb_devices(void)
{
@@ -143,7 +143,7 @@ static int dm_test_usb_stop(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_usb_stop, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_usb_stop, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/**
* dm_test_usb_keyb() - test USB keyboard driver
@@ -435,4 +435,4 @@ static int dm_test_usb_keyb(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_usb_keyb, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_usb_keyb, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/video.c b/test/dm/video.c
index 9523a0173d..1af948dca3 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -40,7 +40,7 @@ static int dm_test_video_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/**
* compress_frame_buffer() - Compress the frame buffer and return its size
@@ -146,7 +146,7 @@ static int dm_test_video_text(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_text, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_text, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test handling of special characters in the console */
static int dm_test_video_chars(struct unit_test_state *uts)
@@ -162,7 +162,7 @@ static int dm_test_video_chars(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_chars, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_chars, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
#ifdef CONFIG_VIDEO_ANSI
#define ANSI_ESC "\x1b"
@@ -195,7 +195,7 @@ static int dm_test_video_ansi(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_ansi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_ansi, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
#endif
/**
@@ -252,7 +252,7 @@ static int dm_test_video_context(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_context, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_context, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test rotated text output through the console uclass */
static int dm_test_video_rotation1(struct unit_test_state *uts)
@@ -261,7 +261,7 @@ static int dm_test_video_rotation1(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_rotation1, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_rotation1, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test rotated text output through the console uclass */
static int dm_test_video_rotation2(struct unit_test_state *uts)
@@ -270,7 +270,7 @@ static int dm_test_video_rotation2(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_rotation2, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_rotation2, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test rotated text output through the console uclass */
static int dm_test_video_rotation3(struct unit_test_state *uts)
@@ -279,7 +279,7 @@ static int dm_test_video_rotation3(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_rotation3, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_rotation3, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Read a file into memory and return a pointer to it */
static int read_file(struct unit_test_state *uts, const char *fname,
@@ -317,7 +317,7 @@ static int dm_test_video_bmp(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_bmp, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_bmp, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test drawing a compressed bitmap file */
static int dm_test_video_bmp_comp(struct unit_test_state *uts)
@@ -333,7 +333,7 @@ static int dm_test_video_bmp_comp(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_bmp_comp, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_bmp_comp, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test TrueType console */
static int dm_test_video_truetype(struct unit_test_state *uts)
@@ -348,7 +348,7 @@ static int dm_test_video_truetype(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_truetype, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_truetype, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test scrolling TrueType console */
static int dm_test_video_truetype_scroll(struct unit_test_state *uts)
@@ -369,7 +369,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_truetype_scroll, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_truetype_scroll, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test TrueType backspace, within and across lines */
static int dm_test_video_truetype_bs(struct unit_test_state *uts)
@@ -390,4 +390,4 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_video_truetype_bs, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_video_truetype_bs, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/virtio.c b/test/dm/virtio.c
index 6361cd5333..2e876c36e4 100644
--- a/test/dm/virtio.c
+++ b/test/dm/virtio.c
@@ -36,7 +36,7 @@ static int dm_test_virtio_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_virtio_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_virtio_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test all of the virtio uclass ops */
static int dm_test_virtio_all_ops(struct unit_test_state *uts)
@@ -85,7 +85,7 @@ static int dm_test_virtio_all_ops(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_virtio_all_ops, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_virtio_all_ops, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test of the virtio driver that does not have required driver ops */
static int dm_test_virtio_missing_ops(struct unit_test_state *uts)
@@ -103,7 +103,7 @@ static int dm_test_virtio_missing_ops(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_virtio_missing_ops, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_virtio_missing_ops, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Test removal of virtio device driver */
static int dm_test_virtio_remove(struct unit_test_state *uts)
@@ -127,4 +127,4 @@ static int dm_test_virtio_remove(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_virtio_remove, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_virtio_remove, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/wdt.c b/test/dm/wdt.c
index c704098b24..24b991dff6 100644
--- a/test/dm/wdt.c
+++ b/test/dm/wdt.c
@@ -38,4 +38,4 @@ static int dm_test_wdt_base(struct unit_test_state *uts)
return 0;
}
-DM_TEST(dm_test_wdt_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(dm_test_wdt_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/lib/lmb.c b/test/lib/lmb.c
index a344987509..644ee78758 100644
--- a/test/lib/lmb.c
+++ b/test/lib/lmb.c
@@ -201,7 +201,7 @@ static int lib_test_lmb_simple(struct unit_test_state *uts)
return test_multi_alloc_512mb(uts, 0xE0000000);
}
-DM_TEST(lib_test_lmb_simple, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(lib_test_lmb_simple, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Create two memory regions with one reserved region and allocate */
static int lib_test_lmb_simple_x2(struct unit_test_state *uts)
@@ -217,7 +217,7 @@ static int lib_test_lmb_simple_x2(struct unit_test_state *uts)
return test_multi_alloc_512mb_x2(uts, 0xE0000000, 0x40000000);
}
-DM_TEST(lib_test_lmb_simple_x2, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(lib_test_lmb_simple_x2, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Simulate 512 MiB RAM, allocate some blocks that fit/don't fit */
static int test_bigblock(struct unit_test_state *uts, const phys_addr_t ram)
@@ -284,7 +284,7 @@ static int lib_test_lmb_big(struct unit_test_state *uts)
return test_bigblock(uts, 0xE0000000);
}
-DM_TEST(lib_test_lmb_big, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(lib_test_lmb_big, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Simulate 512 MiB RAM, allocate a block without previous reservation */
static int test_noreserved(struct unit_test_state *uts, const phys_addr_t ram,
@@ -359,7 +359,7 @@ static int lib_test_lmb_noreserved(struct unit_test_state *uts)
return test_noreserved(uts, 0xE0000000, 4, 1);
}
-DM_TEST(lib_test_lmb_noreserved, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(lib_test_lmb_noreserved, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
static int lib_test_lmb_unaligned_size(struct unit_test_state *uts)
{
@@ -374,7 +374,7 @@ static int lib_test_lmb_unaligned_size(struct unit_test_state *uts)
return test_noreserved(uts, 0xE0000000, 5, 8);
}
-DM_TEST(lib_test_lmb_unaligned_size, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(lib_test_lmb_unaligned_size, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/*
* Simulate a RAM that starts at 0 and allocate down to address 0, which must
* fail as '0' means failure for the lmb_alloc functions.
@@ -417,7 +417,7 @@ static int lib_test_lmb_at_0(struct unit_test_state *uts)
return 0;
}
-DM_TEST(lib_test_lmb_at_0, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(lib_test_lmb_at_0, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Check that calling lmb_reserve with overlapping regions fails. */
static int lib_test_lmb_overlapping_reserve(struct unit_test_state *uts)
@@ -456,7 +456,7 @@ static int lib_test_lmb_overlapping_reserve(struct unit_test_state *uts)
}
DM_TEST(lib_test_lmb_overlapping_reserve,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/*
* Simulate 512 MiB RAM, reserve 3 blocks, allocate addresses in between.
@@ -586,7 +586,7 @@ static int lib_test_lmb_alloc_addr(struct unit_test_state *uts)
return test_alloc_addr(uts, 0xE0000000);
}
-DM_TEST(lib_test_lmb_alloc_addr, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+DM_TEST(lib_test_lmb_alloc_addr, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
/* Simulate 512 MiB RAM, reserve 3 blocks, check addresses in between */
static int test_get_unreserved_size(struct unit_test_state *uts,
@@ -658,4 +658,4 @@ static int lib_test_lmb_get_free_size(struct unit_test_state *uts)
}
DM_TEST(lib_test_lmb_get_free_size,
- DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py
index 86ec1b36d3..2ae8f25381 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -416,7 +416,10 @@ def mk_env_ext4(state_test_env):
else:
try:
u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent)
- u_boot_utils.run_and_log(c, 'mkfs.ext4 -O ^metadata_csum %s' % persistent)
+ u_boot_utils.run_and_log(c, 'mkfs.ext4 %s' % persistent)
+ sb_content = u_boot_utils.run_and_log(c, 'tune2fs -l %s' % persistent)
+ if 'metadata_csum' in sb_content:
+ u_boot_utils.run_and_log(c, 'tune2fs -O ^metadata_csum %s' % persistent)
except CalledProcessError:
call('rm -f %s' % persistent, shell=True)
raise
diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py
index ee82169c2a..58e8cd46ee 100644
--- a/test/py/tests/test_fs/conftest.py
+++ b/test/py/tests/test_fs/conftest.py
@@ -149,8 +149,6 @@ def mk_fs(config, fs_type, size, id):
mkfs_opt = '-F 16'
elif fs_type == 'fat32':
mkfs_opt = '-F 32'
- elif fs_type == 'ext4':
- mkfs_opt = '-O ^metadata_csum'
else:
mkfs_opt = ''
@@ -167,6 +165,10 @@ def mk_fs(config, fs_type, size, id):
% (fs_img, count), shell=True)
check_call('mkfs.%s %s %s'
% (fs_lnxtype, mkfs_opt, fs_img), shell=True)
+ if fs_type == 'ext4':
+ sb_content = check_output('tune2fs -l %s' % fs_img, shell=True).decode()
+ if 'metadata_csum' in sb_content:
+ check_call('tune2fs -O ^metadata_csum %s' % fs_img, shell=True)
return fs_img
except CalledProcessError:
call('rm -f %s' % fs_img, shell=True)
diff --git a/test/py/tests/test_fs/test_squashfs/sqfs_common.py b/test/py/tests/test_fs/test_squashfs/sqfs_common.py
new file mode 100644
index 0000000000..9ef7b19ad9
--- /dev/null
+++ b/test/py/tests/test_fs/test_squashfs/sqfs_common.py
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 Bootlin
+# Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+
+import os
+import random
+import string
+
+def sqfs_get_random_letters(size):
+ letters = []
+ for i in range(0, size):
+ letters.append(random.choice(string.ascii_letters))
+
+ return ''.join(letters)
+
+def sqfs_generate_file(path, size):
+ content = sqfs_get_random_letters(size)
+ file = open(path, "w")
+ file.write(content)
+ file.close()
+
+# generate image with three files and a symbolic link
+def sqfs_generate_image():
+ src = "test/py/tests/test_fs/test_squashfs/sqfs_src/"
+ dest = "test/py/tests/test_fs/test_squashfs/sqfs"
+ os.mkdir(src)
+ sqfs_generate_file(src + "frag_only", 100)
+ sqfs_generate_file(src + "blks_frag", 5100)
+ sqfs_generate_file(src + "blks_only", 4096)
+ os.symlink("frag_only", src + "sym")
+ os.system("mksquashfs " + src + " " + dest + " -b 4096 -always-use-fragments")
+
+# removes all files created by sqfs_generate_image()
+def sqfs_clean():
+ src = "test/py/tests/test_fs/test_squashfs/sqfs_src/"
+ dest = "test/py/tests/test_fs/test_squashfs/sqfs"
+ os.remove(src + "frag_only")
+ os.remove(src + "blks_frag")
+ os.remove(src + "blks_only")
+ os.remove(src + "sym")
+ os.rmdir(src)
+ os.remove(dest)
diff --git a/test/py/tests/test_fs/test_squashfs/test_sqfs_load.py b/test/py/tests/test_fs/test_squashfs/test_sqfs_load.py
new file mode 100644
index 0000000000..9b828fdf04
--- /dev/null
+++ b/test/py/tests/test_fs/test_squashfs/test_sqfs_load.py
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 Bootlin
+# Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+
+import os
+import pytest
+from sqfs_common import *
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('cmd_fs_generic')
+@pytest.mark.buildconfigspec('cmd_squashfs')
+@pytest.mark.buildconfigspec('fs_squashfs')
+@pytest.mark.requiredtool('mksquashfs')
+def test_sqfs_load(u_boot_console):
+ sqfs_generate_image()
+ command = "sqfsload host 0 $kernel_addr_r "
+ path = "test/py/tests/test_fs/test_squashfs/sqfs"
+
+ try:
+ output = u_boot_console.run_command("host bind 0 " + path)
+ output = u_boot_console.run_command(command + "xxx")
+ assert "File not found." in output
+ output = u_boot_console.run_command(command + "frag_only")
+ assert "100 bytes read in" in output
+ output = u_boot_console.run_command(command + "blks_frag")
+ assert "5100 bytes read in" in output
+ output = u_boot_console.run_command(command + "blks_only")
+ assert "4096 bytes read in" in output
+ output = u_boot_console.run_command(command + "sym")
+ assert "100 bytes read in" in output
+ except:
+ sqfs_clean()
+ sqfs_clean()
diff --git a/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py
new file mode 100644
index 0000000000..dc31f1a50e
--- /dev/null
+++ b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 Bootlin
+# Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+
+import os
+import pytest
+from sqfs_common import *
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('cmd_fs_generic')
+@pytest.mark.buildconfigspec('cmd_squashfs')
+@pytest.mark.buildconfigspec('fs_squashfs')
+@pytest.mark.requiredtool('mksquashfs')
+def test_sqfs_ls(u_boot_console):
+ sqfs_generate_image()
+ path = "test/py/tests/test_fs/test_squashfs/sqfs"
+ try:
+ output = u_boot_console.run_command("host bind 0 " + path)
+ output = u_boot_console.run_command("sqfsls host 0")
+ assert "4 file(s), 0 dir(s)" in output
+ assert "<SYM> sym" in output
+ output = u_boot_console.run_command("sqfsls host 0 xxx")
+ assert "** Cannot find directory. **" in output
+ except:
+ sqfs_clean()
+ sqfs_clean()
diff --git a/test/py/tests/test_shell_basics.py b/test/py/tests/test_shell_basics.py
index f54f7b7425..68a3f892f6 100644
--- a/test/py/tests/test_shell_basics.py
+++ b/test/py/tests/test_shell_basics.py
@@ -34,11 +34,11 @@ def test_shell_semicolon_three(u_boot_console):
def test_shell_run(u_boot_console):
"""Test the "run" shell command."""
- u_boot_console.run_command('setenv foo "setenv monty 1; setenv python 2"')
+ u_boot_console.run_command('setenv foo \'setenv monty 1; setenv python 2\'')
u_boot_console.run_command('run foo')
- response = u_boot_console.run_command('echo $monty')
+ response = u_boot_console.run_command('echo ${monty}')
assert response.strip() == '1'
- response = u_boot_console.run_command('echo $python')
+ response = u_boot_console.run_command('echo ${python}')
assert response.strip() == '2'
u_boot_console.run_command('setenv foo')
u_boot_console.run_command('setenv monty')
diff --git a/test/ut.c b/test/ut.c
index c64f0b554d..95bdd66de6 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -59,6 +59,28 @@ int ut_check_console_line(struct unit_test_state *uts, const char *fmt, ...)
return strcmp(uts->expect_str, uts->actual_str);
}
+int ut_check_console_linen(struct unit_test_state *uts, const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ vsnprintf(uts->expect_str, sizeof(uts->expect_str), fmt, args);
+ va_end(args);
+ console_record_readline(uts->actual_str, sizeof(uts->actual_str));
+
+ return strncmp(uts->expect_str, uts->actual_str,
+ strlen(uts->expect_str));
+}
+
+int ut_check_skipline(struct unit_test_state *uts)
+{
+ if (!console_record_avail())
+ return -ENFILE;
+ console_record_readline(uts->actual_str, sizeof(uts->actual_str));
+
+ return 0;
+}
+
int ut_check_console_end(struct unit_test_state *uts)
{
if (!console_record_avail())