summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2024-04-16 15:46:35 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2024-04-16 15:46:35 +0200
commit30955f79e7b3353f3c203efdb6eaf2a57b08c4c5 (patch)
treef46ed41b31354039b86967282a5a52807ef3d04f
parent10c24308965d3b24ee6ac18fa2e6219bc7e972a9 (diff)
parente476edd5322f789ed79d93a5849e8c4c998e3b3f (diff)
downloadbarebox-30955f79e7b3353f3c203efdb6eaf2a57b08c4c5.tar.gz
barebox-30955f79e7b3353f3c203efdb6eaf2a57b08c4c5.tar.xz
Merge branch 'for-next/misc' into next
-rw-r--r--Documentation/boards/rockchip.rst1
-rw-r--r--arch/arm/boards/Makefile1
-rw-r--r--arch/arm/boards/lxa-mc1/board.c13
-rw-r--r--arch/arm/boards/protonic-mecsbc/Makefile3
-rw-r--r--arch/arm/boards/protonic-mecsbc/board.c180
-rw-r--r--arch/arm/boards/protonic-mecsbc/lowlevel.c33
-rw-r--r--arch/arm/boards/raspberry-pi/rpi-common.c1
-rw-r--r--arch/arm/boards/skov-imx8mp/board.c15
-rw-r--r--arch/arm/configs/rockchip_v8_defconfig4
-rw-r--r--arch/arm/dts/Makefile1
-rw-r--r--arch/arm/dts/bootstate.dtsi45
-rw-r--r--arch/arm/dts/rk3568-mecsbc-linux.dts704
-rw-r--r--arch/arm/dts/rk3568-mecsbc.dts147
-rw-r--r--arch/arm/dts/stm32mp157c-lxa-mc1.dts14
-rw-r--r--arch/arm/lib32/bootm.c2
-rw-r--r--arch/arm/mach-rockchip/Kconfig6
-rw-r--r--arch/mips/include/asm/cpu.h30
-rw-r--r--arch/mips/include/asm/mipsregs.h12
-rw-r--r--arch/mips/lib/cpu-probe.c61
-rw-r--r--common/Kconfig580
-rw-r--r--common/Kconfig.debug153
-rw-r--r--common/Kconfig.debug_ll430
-rw-r--r--common/bootm.c52
-rw-r--r--common/console.c2
-rw-r--r--common/deep-probe.c6
-rw-r--r--common/env.c12
-rw-r--r--common/fastboot.c2
-rw-r--r--common/misc.c66
-rw-r--r--drivers/aiodev/core.c12
-rw-r--r--drivers/gpio/Kconfig6
-rw-r--r--drivers/gpio/Makefile1
-rw-r--r--drivers/gpio/gpio-intel.c198
-rw-r--r--drivers/gpio/gpiolib.c11
-rw-r--r--drivers/i2c/busses/Kconfig6
-rw-r--r--drivers/i2c/busses/Makefile1
-rw-r--r--drivers/i2c/busses/i2c-efi.c292
-rw-r--r--drivers/input/Kconfig11
-rw-r--r--drivers/input/gpio_keys.c6
-rw-r--r--drivers/input/imx_keypad.c7
-rw-r--r--drivers/input/input.c11
-rw-r--r--drivers/input/usb_kbd.c1
-rw-r--r--drivers/input/virtio_input.c1
-rw-r--r--drivers/mci/arasan-sdhci.c49
-rw-r--r--drivers/mci/mci-core.c4
-rw-r--r--drivers/mci/sdhci.c4
-rw-r--r--drivers/mtd/spi-nor/spi-nor.c3
-rw-r--r--drivers/net/phy/phy-core.c10
-rw-r--r--drivers/net/usb/ax88179_178a.c8
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c5
-rw-r--r--efi/guid.c1
-rw-r--r--images/Makefile.rockchip1
-rw-r--r--include/aiodev.h9
-rw-r--r--include/bootm.h8
-rw-r--r--include/common.h1
-rw-r--r--include/console.h1
-rw-r--r--include/efi.h3
-rw-r--r--include/input/input.h1
-rw-r--r--include/linux/gpio/consumer.h2
-rw-r--r--include/mach/zynqmp/firmware-zynqmp.h11
-rw-r--r--include/mci.h7
-rw-r--r--include/platform_data/gpio-intel.h23
-rw-r--r--include/string.h2
-rw-r--r--include/usb_dfu_trailer.h32
-rw-r--r--lib/bzlib_private.h521
-rw-r--r--lib/string.c6
-rw-r--r--lib/zstd/zstd_opt.h1014
-rw-r--r--net/nfs.h68
-rwxr-xr-xscripts/config230
68 files changed, 2878 insertions, 2286 deletions
diff --git a/Documentation/boards/rockchip.rst b/Documentation/boards/rockchip.rst
index 583b4f1720..aa2febc8eb 100644
--- a/Documentation/boards/rockchip.rst
+++ b/Documentation/boards/rockchip.rst
@@ -61,6 +61,7 @@ Supported Boards
- Pine64 Quartz64 Model A
- Radxa ROCK3 Model A
- Radxa CM3 (RK3566) IO Board
+- Protonic MECSBC
The steps described in the following target the RK3568 and the RK3568 EVB but
generally apply to both SoCs and all boards.
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 05fbcca175..84e777092d 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -109,6 +109,7 @@ obj-$(CONFIG_MACH_PM9G45) += pm9g45/
obj-$(CONFIG_MACH_POLYHEX_DEBIX) += polyhex-debix/
obj-$(CONFIG_MACH_PROTONIC_IMX6) += protonic-imx6/
obj-$(CONFIG_MACH_PROTONIC_IMX8M) += protonic-imx8m/
+obj-$(CONFIG_MACH_PROTONIC_MECSBC) += protonic-mecsbc/
obj-$(CONFIG_MACH_PROTONIC_STM32MP1) += protonic-stm32mp1/
obj-$(CONFIG_MACH_QIL_A9260) += qil-a926x/
obj-$(CONFIG_MACH_QIL_A9G20) += qil-a926x/
diff --git a/arch/arm/boards/lxa-mc1/board.c b/arch/arm/boards/lxa-mc1/board.c
index b377d4323e..8be265b0fc 100644
--- a/arch/arm/boards/lxa-mc1/board.c
+++ b/arch/arm/boards/lxa-mc1/board.c
@@ -31,6 +31,7 @@ static int of_fixup_regulator_supply_disable(struct device_node *root, void *pat
static int mc1_probe(struct device *dev)
{
+ struct device_node *state_node, *state_backend;
int flags;
flags = bootsource_get_instance() == 0 ? BBU_HANDLER_FLAG_DEFAULT : 0;
@@ -40,10 +41,18 @@ static int mc1_probe(struct device *dev)
stm32mp_bbu_mmc_register_handler("emmc", "/dev/mmc1.ssbl", flags);
- if (bootsource_get_instance() == 0)
+ if (bootsource_get_instance() == 0) {
of_device_enable_path("/chosen/environment-sd");
- else
+ state_backend = of_find_node_by_alias(NULL, "mmc0");
+ } else {
of_device_enable_path("/chosen/environment-emmc");
+ state_backend = of_find_node_by_alias(NULL, "mmc1");
+ }
+
+ state_node = of_find_node_by_alias(NULL, "state");
+ if (state_node)
+ of_property_write_u32(state_node, "backend",
+ of_node_create_phandle(state_backend));
barebox_set_hostname("lxa-mc1");
diff --git a/arch/arm/boards/protonic-mecsbc/Makefile b/arch/arm/boards/protonic-mecsbc/Makefile
new file mode 100644
index 0000000000..b37b6c870b
--- /dev/null
+++ b/arch/arm/boards/protonic-mecsbc/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-y += board.o
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/protonic-mecsbc/board.c b/arch/arm/boards/protonic-mecsbc/board.c
new file mode 100644
index 0000000000..56f7ca393a
--- /dev/null
+++ b/arch/arm/boards/protonic-mecsbc/board.c
@@ -0,0 +1,180 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#define pr_fmt(fmt) "MECSBC: " fmt
+
+#include <bootsource.h>
+#include <common.h>
+#include <deep-probe.h>
+#include <init.h>
+#include <mach/rockchip/bbu.h>
+#include <environment.h>
+#include <param.h>
+#include <of_device.h>
+#include <aiodev.h>
+#include <globalvar.h>
+
+struct mecsbc_model {
+ const char *name;
+ const char *shortname;
+};
+
+struct mecsbc_priv {
+ int hw_id;
+ int hw_rev;
+};
+
+static struct mecsbc_priv mecsbc_data;
+
+static int saradc_get_value(const char *chan)
+{
+ int ret, voltage;
+
+ ret = aiochannel_name_get_value(chan, &voltage);
+ if (ret) {
+ pr_warn_once("Cannot read ADC %s: %pe\n", chan, ERR_PTR(ret));
+ return 0;
+ }
+
+ return voltage;
+}
+
+static int mecsbc_get_vin_mv(void)
+{
+ return saradc_get_value("aiodev0.in_value2_mV") * 22;
+}
+
+static bool mecsbc_get_usb_boot(void)
+{
+ return saradc_get_value("aiodev0.in_value0_mV") < 74;
+}
+
+static int mecsbc_adc_id_values[] = {
+ 1800, 1662, 1521, 1354, 1214, 1059, 900, 742, 335, 589, 278, 137, 0
+};
+
+static int mecsbc_get_adc_id(const char *chan)
+{
+ int val;
+ unsigned int t;
+
+ val = saradc_get_value(chan) + 74;
+
+ for (t = 0; t < ARRAY_SIZE(mecsbc_adc_id_values); t++) {
+ if (val > mecsbc_adc_id_values[t])
+ return t;
+ }
+
+ return t;
+}
+
+static void mecsbc_process_adc(struct device *dev)
+{
+ mecsbc_data.hw_id = mecsbc_get_adc_id("aiodev0.in_value1_mV");
+ mecsbc_data.hw_rev = mecsbc_get_adc_id("aiodev0.in_value3_mV");
+
+ dev_add_param_uint32_ro(dev, "boardrev", &mecsbc_data.hw_rev, "%u");
+ dev_add_param_uint32_ro(dev, "boardid", &mecsbc_data.hw_id, "%u");
+
+ /* Check if we need to enable the USB gadget instead of booting */
+ if (mecsbc_get_usb_boot()) {
+ globalvar_add_simple("boot.default", "net");
+ globalvar_add_simple("usbgadget.acm", "1");
+ globalvar_add_simple("usbgadget.autostart", "1");
+ globalvar_add_simple("system.partitions", "/dev/mmc0(mmc0)");
+ pr_info("MECSBC: Enter USB recovery\n");
+ } else {
+ globalvar_add_simple("boot.default", "bootchooser");
+ }
+
+ pr_info("Board id: %d, revision %d\n", mecsbc_data.hw_id, mecsbc_data.hw_rev);
+ pr_info("VIN = %d V\n", mecsbc_get_vin_mv() / 1000);
+}
+
+static int mecsbc_sd_of_fixup(struct device_node *root, void *context)
+{
+ struct device *dev = context;
+ struct device_node *np;
+
+ dev_info(dev, "Fixing up /regulator-sd\n");
+
+ np = of_find_node_by_path_from(root, "/regulator-sd");
+ if (!np) {
+ dev_err(dev, "Cannot find /regulator-sd node\n");
+ return 0;
+ }
+
+ of_property_write_u32(np, "regulator-min-microvolt", 3300000);
+
+ return 0;
+}
+
+static int mecsbc_of_fixup_hwrev(struct device *dev)
+{
+ const char *compat;
+ char *buf;
+
+ compat = of_device_get_match_compatible(dev);
+
+ buf = xasprintf("%s-m%u-r%u", compat, mecsbc_data.hw_id,
+ mecsbc_data.hw_rev);
+ barebox_set_of_machine_compatible(buf);
+
+ free(buf);
+
+ if (mecsbc_data.hw_id == 0 && mecsbc_data.hw_rev == 0)
+ of_register_fixup(mecsbc_sd_of_fixup, dev);
+
+ return 0;
+}
+
+static int mecsbc_probe(struct device *dev)
+{
+ int ret = 0;
+ enum bootsource bootsource = bootsource_get();
+ int instance = bootsource_get_instance();
+ const struct mecsbc_model *model;
+ struct device_node *np;
+
+ np = of_find_node_by_name_address(NULL, "saradc@fe720000");
+ of_device_ensure_probed(np);
+
+ model = device_get_match_data(dev);
+
+ barebox_set_model(model->name);
+ barebox_set_hostname(model->shortname);
+
+ if (bootsource == BOOTSOURCE_MMC && instance == 1)
+ of_device_enable_path("/chosen/environment-sd");
+ else
+ of_device_enable_path("/chosen/environment-emmc");
+
+ rk3568_bbu_mmc_register("emmc", BBU_HANDLER_FLAG_DEFAULT, "/dev/mmc0");
+ rk3568_bbu_mmc_register("sd", 0, "/dev/mmc1");
+
+ mecsbc_process_adc(dev);
+ mecsbc_of_fixup_hwrev(dev);
+
+ return ret;
+}
+
+static const struct mecsbc_model mecsbc = {
+ .name = "Protonic MECSBC board",
+ .shortname = "mecsbc",
+};
+
+static const struct of_device_id mecsbc_of_match[] = {
+ {
+ .compatible = "prt,mecsbc",
+ .data = &mecsbc,
+ },
+ { /* sentinel */ },
+};
+
+static struct driver mecsbc_board_driver = {
+ .name = "board-mecsbc",
+ .probe = mecsbc_probe,
+ .of_compatible = mecsbc_of_match,
+};
+coredevice_platform_driver(mecsbc_board_driver);
+
+BAREBOX_DEEP_PROBE_ENABLE(mecsbc_of_match);
diff --git a/arch/arm/boards/protonic-mecsbc/lowlevel.c b/arch/arm/boards/protonic-mecsbc/lowlevel.c
new file mode 100644
index 0000000000..830d708b6e
--- /dev/null
+++ b/arch/arm/boards/protonic-mecsbc/lowlevel.c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <common.h>
+#include <asm/barebox-arm.h>
+#include <mach/rockchip/hardware.h>
+#include <mach/rockchip/atf.h>
+#include <debug_ll.h>
+
+extern char __dtb_rk3568_mecsbc_start[];
+
+ENTRY_FUNCTION(start_mecsbc, r0, r1, r2)
+{
+ /*
+ * MECSBC IO domain voltages are all +3.3V, except VCCIO4 and VCCIO6
+ * Both GMAC interfaces need this to work properly.
+ * FIXME: This is done by the io-domain driver as well, but there
+ * currently is no mechanism to make sure the driver gets probed
+ * before its consumers. Remove this setup once this issue is
+ * resolved.
+ */
+ writel(RK_SETBITS(0x50), 0xfdc20140);
+
+ putc_ll('>');
+
+ if (current_el() == 3)
+ relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
+ else
+ relocate_to_current_adr();
+
+ setup_c();
+
+ rk3568_barebox_entry(__dtb_rk3568_mecsbc_start);
+}
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 7c82c740e2..924d4425bd 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -192,6 +192,7 @@ static int rpi_env_init(void)
int ret;
device_detect_by_name("mci0");
+ device_detect_by_name("mci1");
diskdev = "/dev/disk0.0";
ret = stat(diskdev, &s);
diff --git a/arch/arm/boards/skov-imx8mp/board.c b/arch/arm/boards/skov-imx8mp/board.c
index 3b6eb7b080..3cb7a8752a 100644
--- a/arch/arm/boards/skov-imx8mp/board.c
+++ b/arch/arm/boards/skov-imx8mp/board.c
@@ -83,6 +83,13 @@ static const struct board_description imx8mp_variants[] = {
.dts_compatible_hdmi = "skov,imx8mp-skov-revb-hdmi",
.flags = SKOV_IMX8MP_HAS_HDMI,
},
+ [2] = {
+ .dts_compatible = "skov,imx8mp-skov-revc-bd500",
+ },
+};
+
+static const struct board_description imx8mp_basic_variant = {
+ .dts_compatible = "skov,imx8mp-skov-basic",
};
static int skov_imx8mp_fixup(struct device_node *root, void *data)
@@ -171,12 +178,12 @@ static int skov_imx8mp_init_variant(struct skov_imx8mp_priv *priv)
priv->variant_id = v;
if (v >= ARRAY_SIZE(imx8mp_variants)) {
- dev_err(dev, "Invalid variant %u\n", v);
- return -EINVAL;
+ dev_warn(dev, "Unsupported variant %u. Fall back to basic variant\n", v);
+ variant = &imx8mp_basic_variant;
+ } else {
+ variant = &imx8mp_variants[v];
}
- variant = &imx8mp_variants[v];
-
if (variant->flags & SKOV_IMX8MP_HAS_HDMI) {
ret = skov_imx8mp_get_hdmi(dev);
if (ret < 0)
diff --git a/arch/arm/configs/rockchip_v8_defconfig b/arch/arm/configs/rockchip_v8_defconfig
index 35ff8963a7..216a88e824 100644
--- a/arch/arm/configs/rockchip_v8_defconfig
+++ b/arch/arm/configs/rockchip_v8_defconfig
@@ -2,6 +2,7 @@ CONFIG_ARCH_ROCKCHIP=y
CONFIG_MACH_RK3568_EVB=y
CONFIG_MACH_RK3568_BPI_R2PRO=y
CONFIG_MACH_PINE64_QUARTZ64=y
+CONFIG_MACH_PROTONIC_MECSBC=y
CONFIG_MACH_RADXA_ROCK3=y
CONFIG_MACH_RADXA_ROCK5=y
CONFIG_MACH_RADXA_CM3=y
@@ -91,6 +92,8 @@ CONFIG_NET_NFS=y
CONFIG_NET_NETCONSOLE=y
CONFIG_OFDEVICE=y
CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_AIODEV=y
+CONFIG_ROCKCHIP_SARADC=y
CONFIG_DRIVER_SERIAL_NS16550=y
CONFIG_DRIVER_NET_DESIGNWARE_ROCKCHIP=y
CONFIG_DRIVER_NET_RTL8169=y
@@ -138,6 +141,7 @@ CONFIG_GENERIC_PHY=y
CONFIG_USB_NOP_XCEIV=y
CONFIG_PHY_ROCKCHIP_INNO_USB2=y
CONFIG_PHY_ROCKCHIP_NANENG_COMBO_PHY=y
+CONFIG_PHY_ROCKCHIP_SNPS_PCIE3=y
CONFIG_ROCKCHIP_IODOMAIN=y
# CONFIG_VIRTIO_MENU is not set
CONFIG_FS_CRAMFS=y
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 056d4d565b..7671b9e2ad 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -109,6 +109,7 @@ lwl-$(CONFIG_MACH_PROTONIC_IMX6) += \
imx6ul-prti6g.dtb.o \
imx6ull-jozacp.dtb.o
lwl-$(CONFIG_MACH_PROTONIC_IMX8M) += imx8mm-prt8mm.dtb.o
+lwl-$(CONFIG_MACH_PROTONIC_MECSBC) += rk3568-mecsbc.dtb.o
lwl-$(CONFIG_MACH_PROTONIC_STM32MP1) += \
stm32mp151-prtt1a.dtb.o \
stm32mp151-prtt1c.dtb.o \
diff --git a/arch/arm/dts/bootstate.dtsi b/arch/arm/dts/bootstate.dtsi
new file mode 100644
index 0000000000..aa767d4e3b
--- /dev/null
+++ b/arch/arm/dts/bootstate.dtsi
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
+
+bootstate {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ system0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ remaining_attempts@0 {
+ reg = <0x0 0x4>;
+ type = "uint32";
+ default = <3>;
+ };
+
+ priority@4 {
+ reg = <0x4 0x4>;
+ type = "uint32";
+ default = <20>;
+ };
+ };
+
+ system1 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ remaining_attempts@8 {
+ reg = <0x8 0x4>;
+ type = "uint32";
+ default = <3>;
+ };
+
+ priority@c {
+ reg = <0xc 0x4>;
+ type = "uint32";
+ default = <10>;
+ };
+ };
+
+ last_chosen@10 {
+ reg = <0x10 0x4>;
+ type = "uint32";
+ };
+};
diff --git a/arch/arm/dts/rk3568-mecsbc-linux.dts b/arch/arm/dts/rk3568-mecsbc-linux.dts
new file mode 100644
index 0000000000..4a36578614
--- /dev/null
+++ b/arch/arm/dts/rk3568-mecsbc-linux.dts
@@ -0,0 +1,704 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
+#include <dt-bindings/pinctrl/rockchip.h>
+#include <dt-bindings/soc/rockchip,vop2.h>
+#include <dt-bindings/pwm/pwm.h>
+#include <arm64/rockchip/rk3568.dtsi>
+
+/ {
+ model = "Protonic MECSBC";
+ compatible = "prt,mecsbc", "rockchip,rk3568";
+
+ aliases {
+ ethernet0 = &gmac0;
+ ethernet1 = &gmac1;
+ ethernet2 = &rtl8111;
+ mmc0 = &sdhci;
+ mmc1 = &sdmmc0;
+ };
+
+ chosen: chosen {
+ stdout-path = "serial2:1500000n8";
+ };
+
+ tas2562-sound {
+ compatible = "simple-audio-card";
+ simple-audio-card,format = "i2s";
+ simple-audio-card,name = "Speaker";
+ simple-audio-card,mclk-fs = <256>;
+
+ simple-audio-card,cpu {
+ sound-dai = <&i2s1_8ch>;
+ };
+
+ simple-audio-card,codec {
+ sound-dai = <&tas2562>;
+ };
+ };
+
+ vdd_gpu: regulator-vdd-gpu {
+ compatible = "pwm-regulator";
+ pwms = <&pwm1 0 5000 PWM_POLARITY_INVERTED>;
+ pinctrl-names = "default";
+ pinctrl = <&pwm1m0_pins>;
+ regulator-name = "vdd_gpu";
+ regulator-min-microvolt = <915000>;
+ regulator-max-microvolt = <1000000>;
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-settling-time-up-us = <250>;
+ pwm-dutycycle-range = <0 100>; /* dutycycle inverted 0% => 0.915V */
+ };
+
+ vdd_npu: regulator-vdd-npu {
+ compatible = "pwm-regulator";
+ pwms = <&pwm2 0 5000 PWM_POLARITY_INVERTED>;
+ pinctrl-names = "default";
+ pinctrl = <&pwm2m0_pins>;
+ regulator-name = "vdd_npu";
+ regulator-min-microvolt = <915000>;
+ regulator-max-microvolt = <1000000>;
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-settling-time-up-us = <250>;
+ pwm-dutycycle-range = <0 100>; /* dutycycle inverted 0% => 0.915V */
+ };
+
+ vcc_sd: bd2204-switch {
+ compatible = "regulator-gpio";
+ enable-gpios = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>;
+ gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_HIGH>;
+ regulator-name = "sdcard-gpio-supply";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ states = <1800000 0x1>, <3300000 0x0>;
+ };
+
+ p3v3: p3v3-regulator {
+ compatible = "regulator-fixed";
+ regulator-name = "p3v3";
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
+
+ p1v8: p1v8-regulator {
+ compatible = "regulator-fixed";
+ regulator-name = "p1v8";
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ };
+
+ portc0: connector_c0 {
+ compatible = "usb-c-connector";
+ label = "USB-C0";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+ usb_con_hs0: endpoint {
+ remote-endpoint = <&usb2phy0_host_portc0>;
+ };
+ };
+
+ port@1 {
+ reg = <1>;
+ usb_con_ss0: endpoint {
+ remote-endpoint = <&combphy0_portc0>;
+ };
+ };
+
+ port@2 {
+ reg = <2>;
+ usb_con_sbu0: endpoint {
+ remote-endpoint = <&edp_out_portc0>;
+ };
+ };
+ };
+ };
+
+ portc1: connector_c1 {
+ compatible = "usb-c-connector";
+ label = "USB-C1";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+ usb_con_hs1: endpoint {
+ remote-endpoint = <&usb2phy1_host_portc1>;
+ };
+ };
+
+ port@1 {
+ reg = <1>;
+ usb_con_ss1: endpoint {
+ remote-endpoint = <&combphy1_portc1>;
+ };
+ };
+
+ port@2 {
+ reg = <2>;
+ usb_con_sbu1: endpoint {
+ remote-endpoint = <&bridge_out_edp>;
+ };
+ };
+ };
+ };
+
+ edp0: edp@fe0c0000 {
+ compatible = "rockchip,rk3568-edp", "rockchip,rk3399-edp";
+ reg = <0x0 0xfe0c0000 0x0 0x10000>;
+ rockchip,grf = <&grf>;
+ interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cru CLK_EDP_200M>, <&cru PCLK_EDP_CTRL>, <&cru PCLK_EDPPHY_GRF>;
+ clock-names = "dp", "pclk", "grf";
+ power-domains = <&power RK3568_PD_VO>;
+ resets = <&cru SRST_P_EDP_CTRL>;
+ reset-names = "dp";
+ status = "okay";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ edp_in: port@0 {
+ reg = <0>;
+ };
+
+ edp_out: port@1 {
+ reg = <1>;
+ };
+ };
+ };
+};
+
+&combphy0 {
+ status = "okay";
+ port {
+ combphy0_portc0: endpoint {
+ remote-endpoint = <&usb_con_ss0>;
+ };
+ };
+};
+
+&combphy1 {
+ status = "okay";
+ port {
+ combphy1_portc1: endpoint {
+ remote-endpoint = <&usb_con_ss1>;
+ };
+ };
+};
+
+&combphy2 {
+ status = "okay";
+};
+
+&cpu0 {
+ cpu-supply = <&vdd_cpu>;
+};
+
+&cpu1 {
+ cpu-supply = <&vdd_cpu>;
+};
+
+&cpu2 {
+ cpu-supply = <&vdd_cpu>;
+};
+
+&cpu3 {
+ cpu-supply = <&vdd_cpu>;
+};
+
+&gmac0 {
+ assigned-clocks = <&cru SCLK_GMAC0_RX_TX>, <&cru SCLK_GMAC0>;
+ assigned-clock-parents = <&cru SCLK_GMAC0_RGMII_SPEED>, <&cru CLK_MAC0_2TOP>;
+ phy-handle = <&rgmii_phy0>;
+ phy-mode = "rgmii";
+ clock_in_out = "output";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gmac0_miim
+ &gmac0_tx_bus2
+ &gmac0_rx_bus2
+ &gmac0_rgmii_clk
+ &gmac0_clkinout
+ &gmac0_rgmii_bus>;
+ status = "okay";
+ tx_delay = <0x30>;
+ rx_delay = <0x10>;
+ fixed-link {
+ speed = <1000>;
+ full-duplex;
+ pause;
+ };
+};
+
+&gmac1 {
+ assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1>;
+ assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru CLK_MAC1_2TOP>;
+ phy-handle = <&rgmii_phy1>;
+ phy-mode = "rgmii";
+ clock_in_out = "output";
+ pinctrl-names = "default";
+ pinctrl-0 = <&gmac1m1_miim
+ &gmac1m1_tx_bus2
+ &gmac1m1_rx_bus2
+ &gmac1m1_rgmii_clk
+ &gmac1m1_clkinout
+ &gmac1m1_rgmii_bus>;
+ status = "okay";
+ tx_delay = <0x30>;
+ rx_delay = <0x10>;
+};
+
+&gpu {
+ mali-supply = <&vdd_gpu>;
+ status = "okay";
+};
+
+&i2c0 {
+ status = "okay";
+
+ vdd_cpu: regulator@60 {
+ compatible = "fcs,fan53555";
+ reg = <0x60>;
+ fcs,suspend-voltage-selector = <1>;
+ regulator-name = "vdd_cpu";
+ regulator-always-on;
+ regulator-boot-on;
+ regulator-min-microvolt = <800000>;
+ regulator-max-microvolt = <1150000>;
+ regulator-ramp-delay = <2300>;
+
+ regulator-state-mem {
+ regulator-off-in-suspend;
+ };
+ };
+
+ usbc_ctrl0: tps65987d@20 {
+ compatible = "ti,tps65987", "ti,tps6598x";
+ reg = <0x20>;
+ };
+};
+
+&i2c3 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c3m0_xfer>;
+ status = "okay";
+
+ tas2562: tas2562@4c {
+ compatible = "ti,tas2562";
+ reg = <0x4c>;
+ #sound-dai-cells = <0>;
+ shutdown-gpios = <&gpio1 RK_PD4 GPIO_ACTIVE_HIGH>;
+ interrupt-parent = <&gpio1>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_tas2562>;
+ interrupts = <RK_PD1 IRQ_TYPE_LEVEL_LOW>;
+ ti,imon-slot-no = <0>;
+ };
+
+ tc358867: tc358867@68 {
+ compatible = "toshiba,tc358767";
+ reg = <0x68>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_tc358867>;
+ reset-gpios = <&gpio1 RK_PD2 GPIO_ACTIVE_HIGH>;
+ clocks = <&cru CLK_CIF_OUT>;
+ clock-names = "ref";
+ toshiba,hpd-pin = <0>;
+ assigned-clocks = <&cru USB480M>, <&cru CLK_CIF_OUT>;
+ assigned-clock-parents = <0>, <&cru USB480M>;
+ assigned-clock-rates = <480000000>, <19200000>;
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+
+ bridge_in: endpoint {
+ remote-endpoint = <&dsi1_out_bridge>;
+ data-lanes = <1 2 3 4>;
+ };
+ };
+
+ port@2 {
+ reg = <2>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ bridge_out_aux: endpoint@0 {
+ remote-endpoint = <&panel_in_edp>;
+ };
+
+ bridge_out_edp: endpoint@1 {
+ remote-endpoint = <&usb_con_sbu1>;
+ };
+ };
+ };
+
+ aux-bus {
+ panel {
+ compatible = "edp-panel";
+
+ port {
+ panel_in_edp: endpoint {
+ remote-endpoint = <&bridge_out_aux>;
+ };
+ };
+ };
+ };
+ };
+};
+
+&i2c5 {
+ status = "okay";
+
+ usbc_ctrl1: tps65987d@20 {
+ compatible = "ti,tps65987", "ti,tps6598x";
+ reg = <0x20>;
+ };
+
+ tmp1075n@48 {
+ compatible = "ti,tmp1075";
+ reg = <0x48>;
+ };
+
+ pcf8563: rtc@51 {
+ compatible = "nxp,pcf85363";
+ reg = <0x51>;
+ #clock-cells = <0>;
+ clock-output-names = "rtcic_32kout";
+ };
+};
+
+&i2s1_8ch {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2s1m0_sclktx &i2s1m0_lrcktx &i2s1m0_sdi0 &i2s1m0_sdo0>;
+ rockchip,trcm-sync-tx-only;
+ status = "okay";
+};
+
+&mdio0 {
+ rgmii_phy0: ethernet-phy@8 {
+ compatible = "ethernet-phy-ieee802.3-c22";
+ reg = <0x8>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&eth_phy0_rst>;
+ reset-assert-us = <20000>;
+ reset-deassert-us = <100000>;
+ reset-gpios = <&gpio2 RK_PB2 GPIO_ACTIVE_LOW>;
+ };
+};
+
+&mdio1 {
+ rgmii_phy1: ethernet-phy@2 {
+ compatible = "ethernet-phy-ieee802.3-c22";
+ reg = <0x2>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&eth_phy1_rst>;
+ reset-assert-us = <20000>;
+ reset-deassert-us = <100000>;
+ reset-gpios = <&gpio4 RK_PB3 GPIO_ACTIVE_LOW>;
+ };
+};
+
+&pcie2x1 {
+ pinctrl-names = "default";
+ /* pinctrl-0 = <&pcie20m1_pins>; */
+ pinctrl-0 = <&pcie_reset_h>;
+ reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_HIGH>;
+ status = "okay";
+
+ pci@0,0 {
+ device_type = "pci";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+
+ reg = <0 0 0 0 0>;
+
+ rtl8111: net@0,0 {
+ reg = <0 0 0 0 0>;
+ };
+ };
+};
+
+&pcie30phy {
+ status = "okay";
+};
+
+&pcie3x2 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie30x2m1_pins>;
+ reset-gpios = <&gpio2 RK_PD6 GPIO_ACTIVE_HIGH>;
+ vpcie3v3-supply = <&p3v3>;
+ status = "okay";
+};
+
+&pinctrl {
+ ethernet {
+ eth_phy0_rst: eth_phy0_rst {
+ rockchip,pins = <2 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>;
+ };
+
+ eth_phy1_rst: eth_phy1_rst {
+ rockchip,pins = <4 RK_PB3 RK_FUNC_GPIO &pcfg_pull_none>;
+ };
+ };
+
+ tc358867 {
+ pinctrl_tc358867: tc358867 {
+ rockchip,pins = <1 RK_PD2 RK_FUNC_GPIO &pcfg_pull_none>,
+ <4 RK_PC0 1 &pcfg_pull_none>,
+ <1 RK_PD3 RK_FUNC_GPIO &pcfg_pull_up>;
+
+ };
+ };
+
+ tas2562 {
+ pinctrl_tas2562: tas2562 {
+ rockchip,pins = <1 RK_PD4 RK_FUNC_GPIO &pcfg_pull_up>;
+ };
+ };
+
+ pcie {
+ pcie_reset_h: pcie-reset-h {
+ rockchip,pins = <3 RK_PC1 RK_FUNC_GPIO &pcfg_pull_none>,
+ /* pcie20_clkreqnm1 */
+ <2 RK_PD0 4 &pcfg_pull_none>,
+ /* pcie20_wakenm1 */
+ <2 RK_PD1 4 &pcfg_pull_none>;
+ };
+ };
+
+};
+
+&pmu_io_domains {
+ pmuio1-supply = <&p3v3>;
+ pmuio2-supply = <&p3v3>;
+ vccio1-supply = <&p1v8>;
+ vccio2-supply = <&p1v8>;
+ /* vccio3-supply = <&vcc_sd>; */
+ vccio3-supply = <&p3v3>;
+ vccio4-supply = <&p1v8>;
+ vccio5-supply = <&p3v3>;
+ vccio6-supply = <&p1v8>;
+ vccio7-supply = <&p3v3>;
+ status = "okay";
+};
+
+&saradc {
+ vref-supply = <&p1v8>;
+ status = "okay";
+};
+
+&sdhci {
+ bus-width = <8>;
+ max-frequency = <200000000>;
+ non-removable;
+ pinctrl-names = "default";
+ pinctrl-0 = <&emmc_bus8 &emmc_clk &emmc_cmd &emmc_datastrobe>;
+ vmmc-supply = <&p3v3>;
+ vqmmc-supply = <&p1v8>;
+ supports-emmc;
+ mmc-hs200-1_8v;
+ non-removable;
+ status = "okay";
+};
+
+&sdmmc0 {
+ bus-width = <4>;
+ cap-sd-highspeed;
+ cd-gpios = <&gpio0 RK_PA4 GPIO_ACTIVE_LOW>;
+ disable-wp;
+ pinctrl-names = "default";
+ pinctrl-0 = <&sdmmc0_bus4 &sdmmc0_clk &sdmmc0_cmd &sdmmc0_det>;
+ sd-uhs-sdr50;
+ sd-uhs-sdr104;
+ vmmc-supply = <&p3v3>;
+ vqmmc-supply = <&vcc_sd>;
+ status = "okay";
+};
+
+&tsadc {
+ rockchip,hw-tshut-mode = <1>;
+ rockchip,hw-tshut-polarity = <0>;
+ status = "okay";
+};
+
+&uart2 {
+ status = "okay";
+};
+
+&usb_host0_ehci {
+ status = "okay";
+};
+
+&usb_host0_ohci {
+ status = "okay";
+};
+
+&usb_host0_xhci {
+ extcon = <&usb2phy0>;
+ status = "okay";
+};
+
+&usb_host1_ehci {
+ status = "okay";
+};
+
+&usb_host1_ohci {
+ status = "okay";
+};
+
+&usb_host1_xhci {
+ status = "okay";
+};
+
+&usb2phy0 {
+ status = "okay";
+};
+
+&usb2phy0_host {
+ status = "okay";
+ port {
+ usb2phy0_host_portc0: endpoint {
+ remote-endpoint = <&usb_con_hs0>;
+ };
+ };
+};
+
+&usb2phy0_otg {
+ status = "okay";
+};
+
+&usb2phy1 {
+ status = "okay";
+};
+
+&usb2phy1_host {
+ status = "okay";
+ port {
+ usb2phy1_host_portc1: endpoint {
+ remote-endpoint = <&usb_con_hs1>;
+ };
+ };
+};
+
+&usb2phy1_otg {
+ status = "okay";
+};
+
+&vop {
+ assigned-clocks = <&cru DCLK_VOP0>, <&cru DCLK_VOP1>;
+ assigned-clock-parents = <&pmucru PLL_HPLL>, <&cru PLL_VPLL>;
+ status = "okay";
+};
+
+&vop_mmu {
+ status = "okay";
+};
+
+&vp0 {
+ vp0_out_dsi1: endpoint@ROCKCHIP_VOP2_EP_MIPI1 {
+ reg = <ROCKCHIP_VOP2_EP_MIPI1>;
+ remote-endpoint = <&dsi1_in_vp0>;
+ };
+};
+
+&vp1 {
+ vp1_out_edp0: endpoint@ROCKCHIP_VOP2_EP_EDP0 {
+ reg = <ROCKCHIP_VOP2_EP_EDP0>;
+ remote-endpoint = <&edp_in_vp1>;
+ };
+};
+
+&dsi1 {
+ status = "okay";
+};
+
+&dsi_dphy1 {
+ status = "okay";
+};
+
+&dsi1_in {
+ dsi1_in_vp0: endpoint {
+ remote-endpoint = <&vp0_out_dsi1>;
+ };
+};
+
+&dsi1_out {
+ dsi1_out_bridge: endpoint {
+ remote-endpoint = <&bridge_in>;
+ };
+};
+
+&edp_in {
+ edp_in_vp1: endpoint {
+ remote-endpoint = <&vp1_out_edp0>;
+ };
+};
+
+&edp_out {
+ edp_out_portc0: endpoint {
+ remote-endpoint = <&usb_con_sbu0>;
+ };
+};
+
+&pwm1 {
+ status = "okay";
+};
+
+&pwm2 {
+ status = "okay";
+};
+
+&gpu_opp_table {
+ compatible = "operating-points-v2";
+
+ opp-200000000 {
+ opp-hz = /bits/ 64 <200000000>;
+ opp-microvolt = <915000>;
+ };
+
+ opp-300000000 {
+ opp-hz = /bits/ 64 <300000000>;
+ opp-microvolt = <915000>;
+ };
+
+ opp-400000000 {
+ opp-hz = /bits/ 64 <400000000>;
+ opp-microvolt = <915000>;
+ };
+
+ opp-600000000 {
+ opp-hz = /bits/ 64 <600000000>;
+ opp-microvolt = <920000>;
+ };
+
+ opp-700000000 {
+ opp-hz = /bits/ 64 <700000000>;
+ opp-microvolt = <950000>;
+ };
+
+ opp-800000000 {
+ opp-hz = /bits/ 64 <800000000>;
+ opp-microvolt = <1000000>;
+ };
+};
diff --git a/arch/arm/dts/rk3568-mecsbc.dts b/arch/arm/dts/rk3568-mecsbc.dts
new file mode 100644
index 0000000000..05893b8f72
--- /dev/null
+++ b/arch/arm/dts/rk3568-mecsbc.dts
@@ -0,0 +1,147 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+/dts-v1/;
+
+#include "rk3568-mecsbc-linux.dts"
+#include "rk356x.dtsi"
+
+/ {
+ aliases {
+ state = &state_emmc;
+ };
+
+ chosen: chosen {
+ environment-sd {
+ compatible = "barebox,environment";
+ device-path = &environment_sd;
+ status = "disabled";
+ };
+
+ environment-emmc {
+ compatible = "barebox,environment";
+ device-path = &environment_emmc;
+ status = "okay";
+ };
+ };
+
+ state_emmc: state {
+ magic = <0x292D3A3C>;
+ compatible = "barebox,state";
+ backend-type = "raw";
+ backend = <&state_backend_emmc>;
+ backend-stridesize = <0x400>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ bootstate {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ system0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ remaining_attempts {
+ reg = <0x0 0x4>;
+ type = "uint32";
+ default = <3>;
+ };
+
+ priority {
+ reg = <0x4 0x4>;
+ type = "uint32";
+ default = <21>;
+ };
+ };
+
+ system1 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ remaining_attempts {
+ reg = <0x10 0x4>;
+ type = "uint32";
+ default = <3>;
+ };
+
+ priority {
+ reg = <0x14 0x4>;
+ type = "uint32";
+ default = <20>;
+ };
+ };
+
+ last_chosen {
+ reg = <0x20 0x4>;
+ type = "uint32";
+ };
+ };
+
+ blobs {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ data_partitions {
+ reg = <0x26 0x100>;
+ type = "string";
+ };
+ };
+ };
+
+ reserved-memory {
+ #address-cells = <2>;
+ #size-cells = <2>;
+ ranges;
+
+ /* Address will be determined by the bootloader */
+ ramoops {
+ compatible = "ramoops";
+ };
+ };
+
+ reserved-memory {
+ #address-cells = <2>;
+ #size-cells = <2>;
+ ranges;
+
+ /* Address will be determined by the bootloader */
+ ramoops {
+ compatible = "ramoops";
+ };
+ };
+};
+
+&sdhci {
+ no-sd;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ /* eMMC reserved 8MiB for barebox (2 copies?), env and state */
+ environment_emmc: partition@7b0000 {
+ label = "barebox-environment";
+ reg = <0x0 0x7b0000 0x0 0x10000>;
+ };
+
+ /* eMMC state after barebox and environment */
+ state_backend_emmc: partition@7c0000 {
+ label = "state";
+ reg = <0x0 0x7c0000 0x0 0x40000>;
+ };
+ };
+};
+
+&sdmmc0 {
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ environment_sd: partition@7b0000 {
+ label = "barebox-environment";
+ reg = <0x0 0x7b0000 0x0 0x10000>;
+ };
+ };
+};
diff --git a/arch/arm/dts/stm32mp157c-lxa-mc1.dts b/arch/arm/dts/stm32mp157c-lxa-mc1.dts
index 1220a77c1b..29852ee9aa 100644
--- a/arch/arm/dts/stm32mp157c-lxa-mc1.dts
+++ b/arch/arm/dts/stm32mp157c-lxa-mc1.dts
@@ -7,6 +7,10 @@
#include "stm32mp151.dtsi"
/ {
+ aliases {
+ state = &state;
+ };
+
chosen {
environment-sd {
compatible = "barebox,environment";
@@ -21,6 +25,16 @@
};
};
+ state: state {
+ compatible = "barebox,state";
+ magic = <0x778ec0f4>;
+ /* backend is fixed up by board code */
+ backend-type = "raw";
+ backend-storage-type = "direct";
+ backend-stridesize = <0x40>;
+
+ #include "bootstate.dtsi"
+ };
};
&panel {
diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index e814593dce..aeb873a3a7 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -294,7 +294,7 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem,
}
if (IS_ENABLED(CONFIG_BOOTM_OPTEE)) {
- if (data->tee_file && !IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
+ if (data->tee_file && !bootm_signed_images_are_forced()) {
ret = bootm_load_tee_from_file(data);
if (ret)
return ret;
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 8cdf2c28a9..0e2b7810bc 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -91,6 +91,12 @@ config MACH_PINE64_QUARTZ64
help
Say Y here if you are using a Pine64 Quartz64
+config MACH_PROTONIC_MECSBC
+ select ARCH_RK3568
+ bool "Protonic MECSBC"
+ help
+ Say Y here if you are using a Protonic MECSBC
+
config MACH_RADXA_ROCK3
select ARCH_RK3568
bool "Radxa ROCK3"
diff --git a/arch/mips/include/asm/cpu.h b/arch/mips/include/asm/cpu.h
index 155e254a81..7fba0b77df 100644
--- a/arch/mips/include/asm/cpu.h
+++ b/arch/mips/include/asm/cpu.h
@@ -51,9 +51,25 @@
* These are the PRID's for when 23:16 == PRID_COMP_MIPS
*/
+#define PRID_IMP_QEMU_GENERIC 0x0000
+#define PRID_IMP_4KC 0x8000
+#define PRID_IMP_5KC 0x8100
+#define PRID_IMP_20KC 0x8200
+#define PRID_IMP_4KEC 0x8400
+#define PRID_IMP_4KSC 0x8600
+#define PRID_IMP_25KF 0x8800
+#define PRID_IMP_5KE 0x8900
+#define PRID_IMP_4KECR2 0x9000
+#define PRID_IMP_4KEMPR2 0x9100
+#define PRID_IMP_4KSD 0x9200
#define PRID_IMP_24K 0x9300
+#define PRID_IMP_34K 0x9500
#define PRID_IMP_24KE 0x9600
#define PRID_IMP_74K 0x9700
+#define PRID_IMP_1004K 0x9900
+#define PRID_IMP_1074K 0x9a00
+#define PRID_IMP_M14KC 0x9c00
+#define PRID_IMP_M14KEC 0x9e00
/*
* These are the PRID's for when 23:16 == PRID_COMP_BROADCOM
@@ -107,11 +123,15 @@ enum cpu_type_enum {
/*
* MIPS32 class processors
*/
- CPU_24K,
- CPU_74K,
- CPU_BMIPS3300,
- CPU_JZRISC,
- CPU_GS232,
+ CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_1004K, CPU_74K,
+ CPU_M14KC, CPU_M14KEC, CPU_1074K, CPU_BMIPS3300, CPU_JZRISC, CPU_GS232,
+
+ /*
+ * MIPS64 class processors
+ */
+ CPU_5KC, CPU_5KE, CPU_20KC, CPU_25KF,
+
+ CPU_QEMU_GENERIC,
CPU_LAST
};
diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h
index 9e7d656542..0b618320ff 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -406,18 +406,14 @@
#define MIPS_CONF1_PC (_ULCAST_(1) << 4)
#define MIPS_CONF1_MD (_ULCAST_(1) << 5)
#define MIPS_CONF1_C2 (_ULCAST_(1) << 6)
-#define MIPS_CONF1_DA_SHF 7
-#define MIPS_CONF1_DA (_ULCAST_(7) << 7)
-#define MIPS_CONF1_DL_SHF 10
-#define MIPS_CONF1_DL (_ULCAST_(7) << 10)
-#define MIPS_CONF1_DS_SHF 13
-#define MIPS_CONF1_DS (_ULCAST_(7) << 13)
-#define MIPS_CONF1_IA_SHF 16
-
#define MIPS_CONF1_DA (_ULCAST_(7) << 7)
+#define MIPS_CONF1_DA_SHF 7
#define MIPS_CONF1_DL (_ULCAST_(7) << 10)
+#define MIPS_CONF1_DL_SHF 10
#define MIPS_CONF1_DS (_ULCAST_(7) << 13)
+#define MIPS_CONF1_DS_SHF 13
#define MIPS_CONF1_IA (_ULCAST_(7) << 16)
+#define MIPS_CONF1_IA_SHF 16
#define MIPS_CONF1_IL (_ULCAST_(7) << 19)
#define MIPS_CONF1_IS (_ULCAST_(7) << 22)
#define MIPS_CONF1_TLBS (_ULCAST_(63)<< 25)
diff --git a/arch/mips/lib/cpu-probe.c b/arch/mips/lib/cpu-probe.c
index cbde43a595..fc20281597 100644
--- a/arch/mips/lib/cpu-probe.c
+++ b/arch/mips/lib/cpu-probe.c
@@ -17,7 +17,7 @@
#include <asm-generic/memory_layout.h>
#include <init.h>
-const char *__cpu_name;
+const char *__cpu_name = "unknown";
struct cpuinfo_mips cpu_data[1];
static char unknown_isa[] = KERN_ERR \
@@ -102,15 +102,72 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c)
{
decode_configs(c);
switch (c->processor_id & 0xff00) {
+ case PRID_IMP_QEMU_GENERIC:
+ c->cputype = CPU_QEMU_GENERIC;
+ __cpu_name = "MIPS GENERIC QEMU";
+ break;
+ case PRID_IMP_4KC:
+ c->cputype = CPU_4KC;
+ __cpu_name = "MIPS 4Kc";
+ break;
+ case PRID_IMP_4KEC:
+ case PRID_IMP_4KECR2:
+ c->cputype = CPU_4KEC;
+ __cpu_name = "MIPS 4KEc";
+ break;
+ case PRID_IMP_4KSC:
+ case PRID_IMP_4KSD:
+ c->cputype = CPU_4KSC;
+ __cpu_name = "MIPS 4KSc";
+ break;
+ case PRID_IMP_5KC:
+ c->cputype = CPU_5KC;
+ __cpu_name = "MIPS 5Kc";
+ break;
+ case PRID_IMP_5KE:
+ c->cputype = CPU_5KE;
+ __cpu_name = "MIPS 5KE";
+ break;
+ case PRID_IMP_20KC:
+ c->cputype = CPU_20KC;
+ __cpu_name = "MIPS 20Kc";
+ break;
case PRID_IMP_24K:
- case PRID_IMP_24KE:
c->cputype = CPU_24K;
__cpu_name = "MIPS 24Kc";
break;
+ case PRID_IMP_24KE:
+ c->cputype = CPU_24K;
+ __cpu_name = "MIPS 24KEc";
+ break;
+ case PRID_IMP_25KF:
+ c->cputype = CPU_25KF;
+ __cpu_name = "MIPS 25Kc";
+ break;
+ case PRID_IMP_34K:
+ c->cputype = CPU_34K;
+ __cpu_name = "MIPS 34Kc";
+ break;
case PRID_IMP_74K:
c->cputype = CPU_74K;
__cpu_name = "MIPS 74Kc";
break;
+ case PRID_IMP_M14KC:
+ c->cputype = CPU_M14KC;
+ __cpu_name = "MIPS M14Kc";
+ break;
+ case PRID_IMP_M14KEC:
+ c->cputype = CPU_M14KEC;
+ __cpu_name = "MIPS M14KEc";
+ break;
+ case PRID_IMP_1004K:
+ c->cputype = CPU_1004K;
+ __cpu_name = "MIPS 1004Kc";
+ break;
+ case PRID_IMP_1074K:
+ c->cputype = CPU_1074K;
+ __cpu_name = "MIPS 1074Kc";
+ break;
}
}
diff --git a/common/Kconfig b/common/Kconfig
index 0000dac874..98a5e99b75 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1239,584 +1239,8 @@ endif
endmenu
-menu "Debugging"
-
-config COMPILE_LOGLEVEL
- int "compile loglevel"
- default 6
- help
- This defines the maximum loglevel compiled into the binary. Less important
- messages will be compiled away resulting in a smaller binary.
-
- 0 system is unusable (emerg)
- 1 action must be taken immediately (alert)
- 2 critical conditions (crit)
- 3 error conditions (err)
- 4 warning conditions (warn)
- 5 normal but significant condition (notice)
- 6 informational (info)
- 7 debug-level messages (debug)
- 8 verbose debug messages (vdebug)
-
-config DEFAULT_LOGLEVEL
- int "default loglevel"
- default 7
- help
- This defines the default runtime loglevel. It can be changed using the
- global.loglevel variable. Available logelevels are:
-
- 0 system is unusable (emerg)
- 1 action must be taken immediately (alert)
- 2 critical conditions (crit)
- 3 error conditions (err)
- 4 warning conditions (warn)
- 5 normal but significant condition (notice)
- 6 informational (info)
- 7 debug-level messages (debug)
- 8 verbose debug messages (vdebug)
-
-config DEBUG_LL
- bool
- depends on HAS_DEBUG_LL
- prompt "Low level debug messages (read help)"
- help
- Enable this to get low level debug messages during barebox
- initialization. This is helpful if you are debugging code that
- executes before the console is initialized.
-
- This requires SoC specific support. Most SoCs require the
- debug UART to be initialized by a debugger or first stage
- bootloader.
-
- Note that selecting this option will limit barebox to a single
- UART definition, as specified below under "low-level debugging
- port". Attempting to boot the resulting image on a different
- platform *will not work*, so this option should not be enabled
- for builds that are intended to be portable.
-
-config ARCH_WANT_FRAME_POINTERS
- bool
-
-config FRAME_POINTER
- bool "Compile barebox with frame pointers" if COMPILE_TEST
- default y if ARCH_WANT_FRAME_POINTERS
- help
- Selected by platforms that expect frame pointer usage, e.g.
- when stack unwinding is enabled. The resulting barebox image
- will be slightly larger and slower, but it can give precise
- debugging information when print stack traces.
-
-config DEBUG_IMX_UART
- bool
-
-config DEBUG_ROCKCHIP_UART
- bool
-
-config DEBUG_OMAP_UART
- bool
-
-config DEBUG_BCM283X_UART
- bool
-
-choice
- prompt "Kernel low-level debugging port"
- depends on DEBUG_LL
-
-config DEBUG_IMX1_UART
- bool "i.MX1 Debug UART"
- depends on ARCH_IMX1
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on i.MX1.
-
-config DEBUG_IMX21_UART
- bool "i.MX21 Debug UART"
- depends on ARCH_IMX21
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on i.MX21.
-
-config DEBUG_IMX25_UART
- bool "i.MX25 Debug UART"
- depends on ARCH_IMX25
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on i.MX25.
-
-config DEBUG_IMX27_UART
- bool "i.MX27 Debug UART"
- depends on ARCH_IMX27
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on i.MX27.
-
-config DEBUG_IMX31_UART
- bool "i.MX31 Debug UART"
- depends on ARCH_IMX31
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on i.MX31.
-
-config DEBUG_IMX35_UART
- bool "i.MX35 Debug UART"
- depends on ARCH_IMX35
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on i.MX35.
-
-config DEBUG_IMX50_UART
- bool "i.MX50 Debug UART"
- depends on ARCH_IMX50
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on i.MX50.
-
-config DEBUG_IMX51_UART
- bool "i.MX51 Debug UART"
- depends on ARCH_IMX51
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on i.MX51.
-
-config DEBUG_IMX53_UART
- bool "i.MX53 Debug UART"
- depends on ARCH_IMX53
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on i.MX53.
-
-config DEBUG_IMX6Q_UART
- bool "i.MX6Q Debug UART"
- depends on ARCH_IMX6
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on i.MX6Q.
-
-config DEBUG_IMX7D_UART
- bool "i.MX7D Debug UART"
- depends on ARCH_IMX7
- select DEBUG_IMX_UART
- help
- Say Y here if you want barebox low-level debugging support
- on i.MX7D.
-
-config DEBUG_IMX8M_UART
- bool "i.MX8M Debug UART"
- depends on ARCH_IMX8M
- select DEBUG_IMX_UART
- help
- Say Y here if you want barebox low-level debugging support
- on i.MX8M*.
-
-config DEBUG_IMX9_UART
- bool "i.MX9 Debug UART"
- depends on ARCH_IMX93
- select DEBUG_IMX_UART
-
-config DEBUG_VEXPRESS_UART
- bool "Vexpress Debug UART"
- depends on ARCH_VEXPRESS
- help
- Say Y here if you want barebox low-level debugging support
- on Vexpress.
-
-config DEBUG_VF610_UART
- bool "VF610 Debug UART"
- depends on ARCH_VF610
- select DEBUG_IMX_UART
- help
- Say Y here if you want kernel low-level debugging support
- on VF610.
-
-config DEBUG_OMAP3_UART
- bool "OMAP3 Debug UART"
- depends on ARCH_OMAP3
- select DEBUG_OMAP_UART
- help
- Say Y here if you want kernel low-level debugging support
- on OMAP3.
-
-config DEBUG_OMAP4_UART
- bool "OMAP4 Debug UART"
- depends on ARCH_OMAP4
- select DEBUG_OMAP_UART
- help
- Say Y here if you want kernel low-level debugging support
- on OMAP4.
-
-config DEBUG_AM33XX_UART
- bool "AM33XX Debug UART"
- depends on ARCH_AM33XX
- select DEBUG_OMAP_UART
- help
- Say Y here if you want kernel low-level debugging support
- on AM33XX.
-
-config DEBUG_ROCKCHIP_RK3188_UART
- bool "RK3188 Debug UART"
- depends on ARCH_RK3188
- select DEBUG_ROCKCHIP_UART
- help
- Say Y here if you want kernel low-level debugging support
- on RK3188.
-
-config DEBUG_ROCKCHIP_RK3288_UART
- bool "RK3288 Debug UART"
- depends on ARCH_RK3288
- select DEBUG_ROCKCHIP_UART
- help
- Say Y here if you want kernel low-level debugging support
- on RK3288.
-
-config DEBUG_ROCKCHIP_RK3568_UART
- bool "RK3568 Debug UART"
- depends on ARCH_RK3568
- select DEBUG_ROCKCHIP_UART
- help
- Say Y here if you want kernel low-level debugging support
- on RK3568.
-
-config DEBUG_ROCKCHIP_RK3588_UART
- bool "RK3588 Debug UART"
- depends on ARCH_RK3588
- select DEBUG_ROCKCHIP_UART
- help
- Say Y here if you want kernel low-level debugging support
- on RK3588.
-
-config DEBUG_ROCKCHIP_RK3399_UART
- bool "RK3399 Debug UART"
- depends on ARCH_RK3399
- select DEBUG_ROCKCHIP_UART
- help
- Say Y here if you want kernel low-level debugging support
- on RK3399.
-
-config DEBUG_SOCFPGA_UART0
- bool "Use SOCFPGA UART0 for low-level debug"
- depends on ARCH_SOCFPGA
- help
- Say Y here if you want kernel low-level debugging support
- on SOCFPGA(Cyclone 5 and Arria 5) based platforms.
-
-config DEBUG_SOCFPGA_UART1
- bool "Use SOCFPGA UART1 for low-level debug"
- depends on ARCH_SOCFPGA
- help
- Say Y here if you want kernel low-level debugging support
- on SOCFPGA(Arria 10) based platforms.
-
-config DEBUG_STM32MP_UART
- bool "Use STM32MP UART4 for low-level debug"
- depends on ARCH_STM32
- help
- Say Y here if you want kernel low-level debugging support
- on STM32MP.
-
-config DEBUG_RPI1_UART
- bool "RaspberryPi 1 PL011 UART"
- depends on ARCH_BCM283X
- select DEBUG_BCM283X_UART
- help
- Say Y here if you want low-level debugging support on
- RaspberryPi 1 boards.
-
-config DEBUG_AT91_UART
- bool "AT91 Debug UART"
- depends on ARCH_AT91
- help
- Say Y here if you want barebox low-level debugging support
- on AT91 based platforms.
-
-config DEBUG_RPI2_3_UART
- bool "RaspberryPi 2/3 PL011 UART"
- depends on ARCH_BCM283X
- select DEBUG_BCM283X_UART
- help
- Say Y here if you want low-level debugging support on
- RaspberryPi 2 and 3 boards.
-
-config DEBUG_RPI3_MINI_UART
- bool "RaspberryPi 3 mini UART"
- depends on ARCH_BCM283X
- select DEBUG_BCM283X_UART
- help
- Say Y here if you want low-level debugging support on
- RaspberryPi 3 board mini UART.
-
-config DEBUG_RPI4_MINI_UART
- bool "RaspberryPi 4 mini UART"
- depends on ARCH_BCM283X
- select DEBUG_BCM283X_UART
- help
- Say Y here if you want low-level debugging support on
- RaspberryPi 4 board mini UART.
-
-config DEBUG_ZYNQMP_UART
- bool "Zynqmp Debug UART"
- depends on ARCH_ZYNQMP
- help
- Say Y here if you want kernel low-level debugging support
- on Zynqmp.
-
-config DEBUG_ERIZO
- bool "Erizo ns16550 port"
- depends on SOC_ERIZO
- select DEBUG_LL_NS16550
-
-config DEBUG_STARFIVE
- bool "Starfive ns16550 serial0 port"
- depends on SOC_STARFIVE
- select DEBUG_LL_NS16550
-
-config DEBUG_RISCV_VIRT
- bool "RISC-V Virt ns16550 port"
- depends on SOC_VIRT
- select DEBUG_LL_NS16550
-
-config DEBUG_RISCVEMU_HTIF
- bool "riscvemu HTIF port"
- depends on SOC_VIRT
- help
- When run without graphics support, tinyemu will expose access
- to the Virt I/O console as HTIF blocking console device as well.
- This is useful for low level debugging before Virt I/O DMA is
- initialized.
-
-config DEBUG_SIFIVE
- bool "SiFive serial0 port"
- depends on SOC_SIFIVE
-
-config DEBUG_LITEX
- bool "LiteX serial port"
- depends on SOC_LITEX
-
-config DEBUG_SUN20I
- bool "Allwinner Sun20i ns16550 serial0 port"
- depends on SOC_ALLWINNER_SUN20I
- select DEBUG_LL_NS16550
-
-config DEBUG_AM62X_UART
- bool "Texas Instruments AM62X debug UART"
- depends on ARCH_K3
-
-config DEBUG_QEMU_ARM64_VIRT
- bool "QEMU ARM64 Virt PL011 console"
- depends on ARCH_ARM64_VIRT
-
-endchoice
-
-config DEBUG_LL_NS16550
- bool
- help
- Selected by RISC-V platforms that use ns16550 for debug_ll
-
-config DEBUG_IMX_UART_PORT
- int "i.MX Debug UART Port Selection" if DEBUG_IMX1_UART || \
- DEBUG_IMX21_UART || \
- DEBUG_IMX25_UART || \
- DEBUG_IMX27_UART || \
- DEBUG_IMX31_UART || \
- DEBUG_IMX35_UART || \
- DEBUG_IMX51_UART || \
- DEBUG_IMX53_UART || \
- DEBUG_IMX6Q_UART || \
- DEBUG_IMX7D_UART || \
- DEBUG_IMX8M_UART || \
- DEBUG_IMX9_UART || \
- DEBUG_VF610_UART
- default 1
- depends on ARCH_IMX
- help
- Choose UART port on which kernel low-level debug messages
- should be output.
-
-config DEBUG_K3_UART_PORT
- int "K3 Debug UART Port Selection" if DEBUG_AM62X_UART
- default 0
- depends on ARCH_K3
- help
- Choose UART port on which kernel low-level debug messages
- should be output. Possible values are:
- AM62x: 0 - 6
-
-config DEBUG_OMAP_UART_PORT
- int "OMAP Debug UART Port Selection" if DEBUG_OMAP3_UART || \
- DEBUG_OMAP4_UART || \
- DEBUG_AM33XX_UART || \
- DEBUG_AM62X_UART
- default 1
- depends on ARCH_OMAP
- help
- Choose UART port on which kernel low-level debug messages
- should be output. Possible values are:
- OMAP3: 1 - 3
- OMAP4: 1 - 3
- AM33XX: 0 - 2
-
-config DEBUG_ROCKCHIP_UART_PORT
- int "RK3xxx UART debug port" if DEBUG_ROCKCHIP_RK3188_UART || \
- DEBUG_ROCKCHIP_RK3288_UART || \
- DEBUG_ROCKCHIP_RK3568_UART || \
- DEBUG_ROCKCHIP_RK3588_UART || \
- DEBUG_ROCKCHIP_RK3399_UART
- default 2
- depends on ARCH_ROCKCHIP
- help
- Choose UART port on which kernel low-level debug messages
- should be output.
-
-config DEBUG_SOCFPGA_UART_PHYS_ADDR
- hex "Physical base address of debug UART" if DEBUG_LL
- default 0xffc02000 if DEBUG_SOCFPGA_UART0
- default 0xffc02100 if DEBUG_SOCFPGA_UART1
- depends on ARCH_SOCFPGA
-
-config DEBUG_SOCFPGA_UART_CLOCK
- int "SoCFPGA UART debug clock" if DEBUG_LL
- default 100000000 if ARCH_SOCFPGA_CYCLONE5
- default 50000000 if ARCH_SOCFPGA_ARRIA10
- depends on ARCH_SOCFPGA
- help
- Choose UART root clock.
-
-
-config DEBUG_LAYERSCAPE_UART_PORT
- int "Layerscape UART port selection"
- depends on ARCH_LAYERSCAPE
- default 1
- help
- Select the UART port number used for early debugging here. Port
- numbers start counting from 1.
-
-config DEBUG_AT91_UART_BASE
- hex "AT91 Debug UART Port Selection" if DEBUG_AT91_UART
- default 0xfffff200 if SOC_AT91RM9200 || SOC_AT91SAM9260 \
- || SOC_AT91SAM9261 || SOC_AT91SAM9X5 \
- || SOC_AT91SAM9N12
- default 0xffffee00 if SOC_AT91SAM9263 || SOC_AT91SAM9G45 || SOC_SAMA5D3
- default 0xfc069000 if SOC_SAMA5D4
- default 0xf8020000 if SOC_SAMA5D2
- default 0xfffff200
- depends on ARCH_AT91
- help
- Specify UART port base address on which barebox low-level
- debug messages should be output.
-
-config DEBUG_INITCALLS
- bool "Trace initcalls"
- select CONSOLE_FLUSH_LINE_BREAK
- help
- If enabled this will print initcall traces.
-
-config DEBUG_PBL
- bool "Print PBL debugging information"
- depends on PBL_CONSOLE
- help
- If enabled this will enable all debug prints in the prebootloader.
- For this to work, a console needs to be configured in the
- board-specific entry point and configured for either DEBUG_LL
- or PBL_CONSOLE.
-
-config DEBUG_PROBES
- bool "Trace driver probes/removes"
- select CONSOLE_FLUSH_LINE_BREAK
- help
- If enabled this will log driver probe and remove traces. If DEBUG_LL is enabled,
- probes will be printed even before registering consoles. If it's disabled, they
- will be collected in the log and written out once a console is active.
-
- Removes are written to the log and will be printed as long as consoles exist.
- Most consoles do not implement a remove callback to remain operable until
- the very end. Consoles using DMA, however, must be removed.
-
-config DMA_API_DEBUG
- bool "Enable debugging of DMA-API usage"
- depends on HAS_DMA
- help
- Enable this option to debug the use of the DMA API by device drivers.
- With this option you will be able to detect common bugs in device
- drivers like double-freeing of DMA mappings or freeing mappings that
- were never allocated.
-
- This option causes a performance degradation. Use only if you want to
- debug device drivers and dma interactions.
-
- If unsure, say N.
-
-config DEBUG_LIST
- bool "Debug linked list manipulation"
- help
- Enable this to turn on extended checks in the linked-list
- walking routines.
-
- If unsure, say N.
-
-config PBL_BREAK
- bool "Execute software break on pbl start"
- depends on ARM && (!CPU_32v4T && !ARCH_TEGRA)
- help
- If enabled, barebox will be compiled with BKPT instruction
- on early pbl init. This option should be used only with JTAG debugger!
-
-config PRINTF_FULL
- bool "Support all extended printf format specifiers"
- help
- Adds support for lesser used format specifiers like UUIDs and
- hex strings. Code requiring them should select it directly,
- so this is mainly for debugging. If unsure, say no.
-
-source "lib/Kconfig.ubsan"
-source "lib/kasan/Kconfig"
-
-config ASAN
- bool "ASAN: runtime memory debugger"
- depends on HAVE_ARCH_ASAN
- help
- Enables ASAN (AddressSANitizer) - runtime memory debugger,
- designed to find out-of-bounds accesses and use-after-free bugs.
-
-config COMPILE_TEST
- bool "compile-test drivers of other platforms"
- default n
- help
- Some drivers can be compiled on a different platform than they are
- intended to be run on. Despite they cannot be used there due to
- missing HW support, developers still, opposing to users, might want
- to build such drivers to compile-test them.
-
- If you are a developer and want to build as much as currently possible,
- say Y here. If you are a user, say N here to avoid being prompted for
- inclusion of unrelated drivers.
-
-config WERROR
- bool "Compile barebox with warnings as errors"
- default COMPILE_TEST
- help
- A barebox build should not cause any compiler warnings, and this
- enables the '-Werror' flags to enforce that rule by default.
-
- However, if you have a new (or very old) compiler with odd and
- unusual warnings, or you have some architecture with problems,
- you may need to disable this config option in order to
- successfully build barebox.
-
- If in doubt, say Y.
-
-endmenu
-
-config HAS_DEBUG_LL
- bool
+source "common/Kconfig.debug"
+source "common/boards/Kconfig"
config DDR_SPD
bool
diff --git a/common/Kconfig.debug b/common/Kconfig.debug
new file mode 100644
index 0000000000..5d245de23c
--- /dev/null
+++ b/common/Kconfig.debug
@@ -0,0 +1,153 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+menu "Debugging"
+
+config COMPILE_LOGLEVEL
+ int "compile loglevel"
+ default 6
+ help
+ This defines the maximum loglevel compiled into the binary. Less important
+ messages will be compiled away resulting in a smaller binary.
+
+ 0 system is unusable (emerg)
+ 1 action must be taken immediately (alert)
+ 2 critical conditions (crit)
+ 3 error conditions (err)
+ 4 warning conditions (warn)
+ 5 normal but significant condition (notice)
+ 6 informational (info)
+ 7 debug-level messages (debug)
+ 8 verbose debug messages (vdebug)
+
+config DEFAULT_LOGLEVEL
+ int "default loglevel"
+ default 7
+ help
+ This defines the default runtime loglevel. It can be changed using the
+ global.loglevel variable. Available logelevels are:
+
+ 0 system is unusable (emerg)
+ 1 action must be taken immediately (alert)
+ 2 critical conditions (crit)
+ 3 error conditions (err)
+ 4 warning conditions (warn)
+ 5 normal but significant condition (notice)
+ 6 informational (info)
+ 7 debug-level messages (debug)
+ 8 verbose debug messages (vdebug)
+
+source "common/Kconfig.debug_ll"
+
+config ARCH_WANT_FRAME_POINTERS
+ bool
+
+config FRAME_POINTER
+ bool "Compile barebox with frame pointers" if COMPILE_TEST
+ default y if ARCH_WANT_FRAME_POINTERS
+ help
+ Selected by platforms that expect frame pointer usage, e.g.
+ when stack unwinding is enabled. The resulting barebox image
+ will be slightly larger and slower, but it can give precise
+ debugging information when print stack traces.
+
+config DEBUG_INITCALLS
+ bool "Trace initcalls"
+ select CONSOLE_FLUSH_LINE_BREAK
+ help
+ If enabled this will print initcall traces.
+
+config DEBUG_PBL
+ bool "Print PBL debugging information"
+ depends on PBL_CONSOLE
+ help
+ If enabled this will enable all debug prints in the prebootloader.
+ For this to work, a console needs to be configured in the
+ board-specific entry point and configured for either DEBUG_LL
+ or PBL_CONSOLE.
+
+config DEBUG_PROBES
+ bool "Trace driver probes/removes"
+ select CONSOLE_FLUSH_LINE_BREAK
+ help
+ If enabled this will log driver probe and remove traces. If DEBUG_LL is enabled,
+ probes will be printed even before registering consoles. If it's disabled, they
+ will be collected in the log and written out once a console is active.
+
+ Removes are written to the log and will be printed as long as consoles exist.
+ Most consoles do not implement a remove callback to remain operable until
+ the very end. Consoles using DMA, however, must be removed.
+
+config DMA_API_DEBUG
+ bool "Enable debugging of DMA-API usage"
+ depends on HAS_DMA
+ help
+ Enable this option to debug the use of the DMA API by device drivers.
+ With this option you will be able to detect common bugs in device
+ drivers like double-freeing of DMA mappings or freeing mappings that
+ were never allocated.
+
+ This option causes a performance degradation. Use only if you want to
+ debug device drivers and dma interactions.
+
+ If unsure, say N.
+
+config DEBUG_LIST
+ bool "Debug linked list manipulation"
+ help
+ Enable this to turn on extended checks in the linked-list
+ walking routines.
+
+ If unsure, say N.
+
+config PBL_BREAK
+ bool "Execute software break on pbl start"
+ depends on ARM && (!CPU_32v4T && !ARCH_TEGRA)
+ help
+ If enabled, barebox will be compiled with BKPT instruction
+ on early pbl init. This option should be used only with JTAG debugger!
+
+config PRINTF_FULL
+ bool "Support all extended printf format specifiers"
+ help
+ Adds support for lesser used format specifiers like UUIDs and
+ hex strings. Code requiring them should select it directly,
+ so this is mainly for debugging. If unsure, say no.
+
+source "lib/Kconfig.ubsan"
+source "lib/kasan/Kconfig"
+
+config ASAN
+ bool "ASAN: runtime memory debugger"
+ depends on HAVE_ARCH_ASAN
+ help
+ Enables ASAN (AddressSANitizer) - runtime memory debugger,
+ designed to find out-of-bounds accesses and use-after-free bugs.
+
+config COMPILE_TEST
+ bool "compile-test drivers of other platforms"
+ default n
+ help
+ Some drivers can be compiled on a different platform than they are
+ intended to be run on. Despite they cannot be used there due to
+ missing HW support, developers still, opposing to users, might want
+ to build such drivers to compile-test them.
+
+ If you are a developer and want to build as much as currently possible,
+ say Y here. If you are a user, say N here to avoid being prompted for
+ inclusion of unrelated drivers.
+
+config WERROR
+ bool "Compile barebox with warnings as errors"
+ default COMPILE_TEST
+ help
+ A barebox build should not cause any compiler warnings, and this
+ enables the '-Werror' flags to enforce that rule by default.
+
+ However, if you have a new (or very old) compiler with odd and
+ unusual warnings, or you have some architecture with problems,
+ you may need to disable this config option in order to
+ successfully build barebox.
+
+ If in doubt, say Y.
+
+endmenu
diff --git a/common/Kconfig.debug_ll b/common/Kconfig.debug_ll
new file mode 100644
index 0000000000..bdc1a7f3a6
--- /dev/null
+++ b/common/Kconfig.debug_ll
@@ -0,0 +1,430 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config HAS_DEBUG_LL
+ bool
+
+config DEBUG_LL
+ bool
+ depends on HAS_DEBUG_LL
+ prompt "Low level debug messages (read help)"
+ help
+ Enable this to get low level debug messages during barebox
+ initialization. This is helpful if you are debugging code that
+ executes before the console is initialized.
+
+ This requires SoC specific support. Most SoCs require the
+ debug UART to be initialized by a debugger or first stage
+ bootloader.
+
+ Note that selecting this option will limit barebox to a single
+ UART definition, as specified below under "low-level debugging
+ port". Attempting to boot the resulting image on a different
+ platform *will not work*, so this option should not be enabled
+ for builds that are intended to be portable.
+
+config DEBUG_IMX_UART
+ bool
+
+config DEBUG_ROCKCHIP_UART
+ bool
+
+config DEBUG_OMAP_UART
+ bool
+
+config DEBUG_BCM283X_UART
+ bool
+
+choice
+ prompt "Kernel low-level debugging port"
+ depends on DEBUG_LL
+
+config DEBUG_IMX1_UART
+ bool "i.MX1 Debug UART"
+ depends on ARCH_IMX1
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on i.MX1.
+
+config DEBUG_IMX21_UART
+ bool "i.MX21 Debug UART"
+ depends on ARCH_IMX21
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on i.MX21.
+
+config DEBUG_IMX25_UART
+ bool "i.MX25 Debug UART"
+ depends on ARCH_IMX25
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on i.MX25.
+
+config DEBUG_IMX27_UART
+ bool "i.MX27 Debug UART"
+ depends on ARCH_IMX27
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on i.MX27.
+
+config DEBUG_IMX31_UART
+ bool "i.MX31 Debug UART"
+ depends on ARCH_IMX31
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on i.MX31.
+
+config DEBUG_IMX35_UART
+ bool "i.MX35 Debug UART"
+ depends on ARCH_IMX35
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on i.MX35.
+
+config DEBUG_IMX50_UART
+ bool "i.MX50 Debug UART"
+ depends on ARCH_IMX50
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on i.MX50.
+
+config DEBUG_IMX51_UART
+ bool "i.MX51 Debug UART"
+ depends on ARCH_IMX51
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on i.MX51.
+
+config DEBUG_IMX53_UART
+ bool "i.MX53 Debug UART"
+ depends on ARCH_IMX53
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on i.MX53.
+
+config DEBUG_IMX6Q_UART
+ bool "i.MX6Q Debug UART"
+ depends on ARCH_IMX6
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on i.MX6Q.
+
+config DEBUG_IMX7D_UART
+ bool "i.MX7D Debug UART"
+ depends on ARCH_IMX7
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want barebox low-level debugging support
+ on i.MX7D.
+
+config DEBUG_IMX8M_UART
+ bool "i.MX8M Debug UART"
+ depends on ARCH_IMX8M
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want barebox low-level debugging support
+ on i.MX8M*.
+
+config DEBUG_IMX9_UART
+ bool "i.MX9 Debug UART"
+ depends on ARCH_IMX93
+ select DEBUG_IMX_UART
+
+config DEBUG_VEXPRESS_UART
+ bool "Vexpress Debug UART"
+ depends on ARCH_VEXPRESS
+ help
+ Say Y here if you want barebox low-level debugging support
+ on Vexpress.
+
+config DEBUG_VF610_UART
+ bool "VF610 Debug UART"
+ depends on ARCH_VF610
+ select DEBUG_IMX_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on VF610.
+
+config DEBUG_OMAP3_UART
+ bool "OMAP3 Debug UART"
+ depends on ARCH_OMAP3
+ select DEBUG_OMAP_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on OMAP3.
+
+config DEBUG_OMAP4_UART
+ bool "OMAP4 Debug UART"
+ depends on ARCH_OMAP4
+ select DEBUG_OMAP_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on OMAP4.
+
+config DEBUG_AM33XX_UART
+ bool "AM33XX Debug UART"
+ depends on ARCH_AM33XX
+ select DEBUG_OMAP_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on AM33XX.
+
+config DEBUG_ROCKCHIP_RK3188_UART
+ bool "RK3188 Debug UART"
+ depends on ARCH_RK3188
+ select DEBUG_ROCKCHIP_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on RK3188.
+
+config DEBUG_ROCKCHIP_RK3288_UART
+ bool "RK3288 Debug UART"
+ depends on ARCH_RK3288
+ select DEBUG_ROCKCHIP_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on RK3288.
+
+config DEBUG_ROCKCHIP_RK3568_UART
+ bool "RK3568 Debug UART"
+ depends on ARCH_RK3568
+ select DEBUG_ROCKCHIP_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on RK3568.
+
+config DEBUG_ROCKCHIP_RK3588_UART
+ bool "RK3588 Debug UART"
+ depends on ARCH_RK3588
+ select DEBUG_ROCKCHIP_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on RK3588.
+
+config DEBUG_ROCKCHIP_RK3399_UART
+ bool "RK3399 Debug UART"
+ depends on ARCH_RK3399
+ select DEBUG_ROCKCHIP_UART
+ help
+ Say Y here if you want kernel low-level debugging support
+ on RK3399.
+
+config DEBUG_SOCFPGA_UART0
+ bool "Use SOCFPGA UART0 for low-level debug"
+ depends on ARCH_SOCFPGA
+ help
+ Say Y here if you want kernel low-level debugging support
+ on SOCFPGA(Cyclone 5 and Arria 5) based platforms.
+
+config DEBUG_SOCFPGA_UART1
+ bool "Use SOCFPGA UART1 for low-level debug"
+ depends on ARCH_SOCFPGA
+ help
+ Say Y here if you want kernel low-level debugging support
+ on SOCFPGA(Arria 10) based platforms.
+
+config DEBUG_STM32MP_UART
+ bool "Use STM32MP UART4 for low-level debug"
+ depends on ARCH_STM32
+ help
+ Say Y here if you want kernel low-level debugging support
+ on STM32MP.
+
+config DEBUG_RPI1_UART
+ bool "RaspberryPi 1 PL011 UART"
+ depends on ARCH_BCM283X
+ select DEBUG_BCM283X_UART
+ help
+ Say Y here if you want low-level debugging support on
+ RaspberryPi 1 boards.
+
+config DEBUG_AT91_UART
+ bool "AT91 Debug UART"
+ depends on ARCH_AT91
+ help
+ Say Y here if you want barebox low-level debugging support
+ on AT91 based platforms.
+
+config DEBUG_RPI2_3_UART
+ bool "RaspberryPi 2/3 PL011 UART"
+ depends on ARCH_BCM283X
+ select DEBUG_BCM283X_UART
+ help
+ Say Y here if you want low-level debugging support on
+ RaspberryPi 2 and 3 boards.
+
+config DEBUG_RPI3_MINI_UART
+ bool "RaspberryPi 3 mini UART"
+ depends on ARCH_BCM283X
+ select DEBUG_BCM283X_UART
+ help
+ Say Y here if you want low-level debugging support on
+ RaspberryPi 3 board mini UART.
+
+config DEBUG_RPI4_MINI_UART
+ bool "RaspberryPi 4 mini UART"
+ depends on ARCH_BCM283X
+ select DEBUG_BCM283X_UART
+ help
+ Say Y here if you want low-level debugging support on
+ RaspberryPi 4 board mini UART.
+
+config DEBUG_ZYNQMP_UART
+ bool "Zynqmp Debug UART"
+ depends on ARCH_ZYNQMP
+ help
+ Say Y here if you want kernel low-level debugging support
+ on Zynqmp.
+
+config DEBUG_ERIZO
+ bool "Erizo ns16550 port"
+ depends on SOC_ERIZO
+ select DEBUG_LL_NS16550
+
+config DEBUG_STARFIVE
+ bool "Starfive ns16550 serial0 port"
+ depends on SOC_STARFIVE
+ select DEBUG_LL_NS16550
+
+config DEBUG_RISCV_VIRT
+ bool "RISC-V Virt ns16550 port"
+ depends on SOC_VIRT
+ select DEBUG_LL_NS16550
+
+config DEBUG_RISCVEMU_HTIF
+ bool "riscvemu HTIF port"
+ depends on SOC_VIRT
+ help
+ When run without graphics support, tinyemu will expose access
+ to the Virt I/O console as HTIF blocking console device as well.
+ This is useful for low level debugging before Virt I/O DMA is
+ initialized.
+
+config DEBUG_SIFIVE
+ bool "SiFive serial0 port"
+ depends on SOC_SIFIVE
+
+config DEBUG_LITEX
+ bool "LiteX serial port"
+ depends on SOC_LITEX
+
+config DEBUG_SUN20I
+ bool "Allwinner Sun20i ns16550 serial0 port"
+ depends on SOC_ALLWINNER_SUN20I
+ select DEBUG_LL_NS16550
+
+config DEBUG_AM62X_UART
+ bool "Texas Instruments AM62X debug UART"
+ depends on ARCH_K3
+
+config DEBUG_QEMU_ARM64_VIRT
+ bool "QEMU ARM64 Virt PL011 console"
+ depends on ARCH_ARM64_VIRT
+
+endchoice
+
+config DEBUG_LL_NS16550
+ bool
+ help
+ Selected by RISC-V platforms that use ns16550 for debug_ll
+
+config DEBUG_IMX_UART_PORT
+ int "i.MX Debug UART Port Selection" if DEBUG_IMX1_UART || \
+ DEBUG_IMX21_UART || \
+ DEBUG_IMX25_UART || \
+ DEBUG_IMX27_UART || \
+ DEBUG_IMX31_UART || \
+ DEBUG_IMX35_UART || \
+ DEBUG_IMX51_UART || \
+ DEBUG_IMX53_UART || \
+ DEBUG_IMX6Q_UART || \
+ DEBUG_IMX7D_UART || \
+ DEBUG_IMX8M_UART || \
+ DEBUG_IMX9_UART || \
+ DEBUG_VF610_UART
+ default 1
+ depends on ARCH_IMX
+ help
+ Choose UART port on which kernel low-level debug messages
+ should be output.
+
+config DEBUG_K3_UART_PORT
+ int "K3 Debug UART Port Selection" if DEBUG_AM62X_UART
+ default 0
+ depends on ARCH_K3
+ help
+ Choose UART port on which kernel low-level debug messages
+ should be output. Possible values are:
+ AM62x: 0 - 6
+
+config DEBUG_OMAP_UART_PORT
+ int "OMAP Debug UART Port Selection" if DEBUG_OMAP3_UART || \
+ DEBUG_OMAP4_UART || \
+ DEBUG_AM33XX_UART || \
+ DEBUG_AM62X_UART
+ default 1
+ depends on ARCH_OMAP
+ help
+ Choose UART port on which kernel low-level debug messages
+ should be output. Possible values are:
+ OMAP3: 1 - 3
+ OMAP4: 1 - 3
+ AM33XX: 0 - 2
+
+config DEBUG_ROCKCHIP_UART_PORT
+ int "RK3xxx UART debug port" if DEBUG_ROCKCHIP_RK3188_UART || \
+ DEBUG_ROCKCHIP_RK3288_UART || \
+ DEBUG_ROCKCHIP_RK3568_UART || \
+ DEBUG_ROCKCHIP_RK3588_UART || \
+ DEBUG_ROCKCHIP_RK3399_UART
+ default 2
+ depends on ARCH_ROCKCHIP
+ help
+ Choose UART port on which kernel low-level debug messages
+ should be output.
+
+config DEBUG_SOCFPGA_UART_PHYS_ADDR
+ hex "Physical base address of debug UART" if DEBUG_LL
+ default 0xffc02000 if DEBUG_SOCFPGA_UART0
+ default 0xffc02100 if DEBUG_SOCFPGA_UART1
+ depends on ARCH_SOCFPGA
+
+config DEBUG_SOCFPGA_UART_CLOCK
+ int "SoCFPGA UART debug clock" if DEBUG_LL
+ default 100000000 if ARCH_SOCFPGA_CYCLONE5
+ default 50000000 if ARCH_SOCFPGA_ARRIA10
+ depends on ARCH_SOCFPGA
+ help
+ Choose UART root clock.
+
+
+config DEBUG_LAYERSCAPE_UART_PORT
+ int "Layerscape UART port selection"
+ depends on ARCH_LAYERSCAPE
+ default 1
+ help
+ Select the UART port number used for early debugging here. Port
+ numbers start counting from 1.
+
+config DEBUG_AT91_UART_BASE
+ hex "AT91 Debug UART Port Selection" if DEBUG_AT91_UART
+ default 0xfffff200 if SOC_AT91RM9200 || SOC_AT91SAM9260 \
+ || SOC_AT91SAM9261 || SOC_AT91SAM9X5 \
+ || SOC_AT91SAM9N12
+ default 0xffffee00 if SOC_AT91SAM9263 || SOC_AT91SAM9G45 || SOC_SAMA5D3
+ default 0xfc069000 if SOC_SAMA5D4
+ default 0xf8020000 if SOC_SAMA5D2
+ default 0xfffff200
+ depends on ARCH_AT91
+ help
+ Specify UART port base address on which barebox low-level
+ debug messages should be output.
diff --git a/common/bootm.c b/common/bootm.c
index 4cc88eed76..c851ab0456 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -44,6 +44,7 @@ static struct image_handler *bootm_find_handler(enum filetype filetype,
static int bootm_appendroot;
static int bootm_earlycon;
static int bootm_provide_machine_id;
+static int bootm_provide_hostname;
static int bootm_verbosity;
void bootm_data_init_defaults(struct bootm_data *data)
@@ -61,6 +62,7 @@ void bootm_data_init_defaults(struct bootm_data *data)
data->verify = bootm_get_verify_mode();
data->appendroot = bootm_appendroot;
data->provide_machine_id = bootm_provide_machine_id;
+ data->provide_hostname = bootm_provide_hostname;
data->verbose = bootm_verbosity;
}
@@ -85,6 +87,29 @@ static const char * const bootm_verify_names[] = {
[BOOTM_VERIFY_SIGNATURE] = "signature",
};
+static bool force_signed_images = IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES);
+
+void bootm_force_signed_images(void)
+{
+ static unsigned int verify_mode = 0;
+
+ if (force_signed_images)
+ return;
+
+ /* recreate bootm.verify with a single enumeration as option */
+ globalvar_remove("bootm.verify");
+ globalvar_add_simple_enum("bootm.verify", &verify_mode,
+ &bootm_verify_names[BOOTM_VERIFY_SIGNATURE], 1);
+
+ bootm_verify_mode = BOOTM_VERIFY_SIGNATURE;
+ force_signed_images = true;
+}
+
+bool bootm_signed_images_are_forced(void)
+{
+ return force_signed_images;
+}
+
static int uimage_part_num(const char *partname)
{
if (!partname)
@@ -692,7 +717,7 @@ int bootm_boot(struct bootm_data *bootm_data)
goto err_out;
}
- if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
+ if (bootm_signed_images_are_forced()) {
data->verify = BOOTM_VERIFY_SIGNATURE;
/*
@@ -797,6 +822,27 @@ int bootm_boot(struct bootm_data *bootm_data)
free(machine_id_bootarg);
}
+ if (bootm_data->provide_hostname) {
+ const char *hostname = getenv_nonempty("global.hostname");
+ char *hostname_bootarg;
+
+ if (!hostname) {
+ pr_err("Providing hostname is enabled but no hostname is set\n");
+ ret = -EINVAL;
+ goto err_out;
+ }
+
+ if (!barebox_hostname_is_valid(hostname)) {
+ pr_err("Provided hostname is not compatible to systemd hostname requirements\n");
+ ret = -EINVAL;
+ goto err_out;
+ }
+
+ hostname_bootarg = basprintf("systemd.hostname=%s", hostname);
+ globalvar_add_simple("linux.bootargs.hostname", hostname_bootarg);
+ free(hostname_bootarg);
+ }
+
pr_info("\nLoading %s '%s'", file_type_to_string(os_type),
data->os_file);
if (os_type == filetype_uimage &&
@@ -956,12 +1002,13 @@ static int bootm_init(void)
globalvar_add_simple_bool("bootm.appendroot", &bootm_appendroot);
globalvar_add_simple_bool("bootm.earlycon", &bootm_earlycon);
globalvar_add_simple_bool("bootm.provide_machine_id", &bootm_provide_machine_id);
+ globalvar_add_simple_bool("bootm.provide_hostname", &bootm_provide_hostname);
if (IS_ENABLED(CONFIG_BOOTM_INITRD)) {
globalvar_add_simple("bootm.initrd", NULL);
globalvar_add_simple("bootm.initrd.loadaddr", NULL);
}
- if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES))
+ if (bootm_signed_images_are_forced())
bootm_verify_mode = BOOTM_VERIFY_SIGNATURE;
globalvar_add_simple_int("bootm.verbose", &bootm_verbosity, "%u");
@@ -1000,3 +1047,4 @@ BAREBOX_MAGICVAR(global.bootm.earlycon, "Add earlycon option to Kernel for early
BAREBOX_MAGICVAR(global.bootm.appendroot, "Add root= option to Kernel to mount rootfs from the device the Kernel comes from (default, device can be overridden via global.bootm.root_dev)");
BAREBOX_MAGICVAR(global.bootm.root_dev, "bootm default root device (overrides default device in global.bootm.appendroot)");
BAREBOX_MAGICVAR(global.bootm.provide_machine_id, "If true, append systemd.machine_id=$global.machine_id to Kernel command line");
+BAREBOX_MAGICVAR(global.bootm.provide_hostname, "If true, append systemd.hostname=$global.hostname to Kernel command line");
diff --git a/common/console.c b/common/console.c
index 5a0fd66ab3..73b4c4d4db 100644
--- a/common/console.c
+++ b/common/console.c
@@ -235,7 +235,7 @@ static void console_add_earlycon_param(struct console_device *cdev, unsigned bau
free(str);
}
-static void console_set_stdoutpath(struct console_device *cdev, unsigned baudrate)
+void console_set_stdoutpath(struct console_device *cdev, unsigned baudrate)
{
int id;
char *str;
diff --git a/common/deep-probe.c b/common/deep-probe.c
index 931e5a1770..b270a10f7f 100644
--- a/common/deep-probe.c
+++ b/common/deep-probe.c
@@ -7,18 +7,18 @@
#include <of.h>
enum deep_probe_state {
- DEEP_PROBE_UNKONWN = -1,
+ DEEP_PROBE_UNKNOWN = -1,
DEEP_PROBE_NOT_SUPPORTED,
DEEP_PROBE_SUPPORTED
};
-static enum deep_probe_state boardstate = DEEP_PROBE_UNKONWN;
+static enum deep_probe_state boardstate = DEEP_PROBE_UNKNOWN;
bool deep_probe_is_supported(void)
{
struct deep_probe_entry *board;
- if (boardstate > DEEP_PROBE_UNKONWN)
+ if (boardstate > DEEP_PROBE_UNKNOWN)
return boardstate;
/* determine boardstate */
diff --git a/common/env.c b/common/env.c
index 7a213cadb2..c231bc8b1d 100644
--- a/common/env.c
+++ b/common/env.c
@@ -336,10 +336,10 @@ const char *getenv_nonempty(const char *var)
{
const char *val = getenv(var);
- if (val && *val)
- return val;
+ if (isempty(val))
+ return NULL;
- return NULL;
+ return val;
}
EXPORT_SYMBOL(getenv_nonempty);
@@ -347,7 +347,7 @@ static int getenv_ull_base(const char *var, int base, unsigned long long *val)
{
const char *valstr = getenv(var);
- if (!valstr || !*valstr)
+ if (isempty(valstr))
return -EINVAL;
*val = simple_strtoull(valstr, NULL, base);
@@ -371,7 +371,7 @@ int getenv_ul(const char *var , unsigned long *val)
{
const char *valstr = getenv(var);
- if (!valstr || !*valstr)
+ if (isempty(valstr))
return -EINVAL;
*val = simple_strtoul(valstr, NULL, 0);
@@ -384,7 +384,7 @@ int getenv_uint(const char *var , unsigned int *val)
{
const char *valstr = getenv(var);
- if (!valstr || !*valstr)
+ if (isempty(valstr))
return -EINVAL;
*val = simple_strtoul(valstr, NULL, 0);
diff --git a/common/fastboot.c b/common/fastboot.c
index d8dabd89ab..f8a01dea7a 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -666,6 +666,7 @@ static void cb_flash(struct fastboot *fb, const char *cmd)
goto out;
}
+ /* Check if board-code registered a vendor-specific handler */
if (fb->cmd_flash) {
ret = fb->cmd_flash(fb, fentry, fb->tempname, fb->download_size);
if (ret != FASTBOOT_CMD_FALLTHROUGH)
@@ -940,6 +941,7 @@ void fastboot_exec_cmd(struct fastboot *fb, const char *cmdbuf)
g_fb = fb;
fb->active = true;
+ /* Check if board-code registered a vendor-specific handler */
if (fb->cmd_exec) {
ret = fb->cmd_exec(fb, cmdbuf);
if (ret != FASTBOOT_CMD_FALLTHROUGH)
diff --git a/common/misc.c b/common/misc.c
index 04ff4e6eb5..530f85f6e3 100644
--- a/common/misc.c
+++ b/common/misc.c
@@ -14,6 +14,7 @@
#include <of.h>
#include <restart.h>
#include <poweroff.h>
+#include <string.h>
#include <linux/stringify.h>
int errno;
@@ -147,6 +148,67 @@ static char *hostname;
static char *serial_number;
static char *of_machine_compatible;
+/* Note that HOST_NAME_MAX is 64 on Linux */
+#define BAREBOX_HOST_NAME_MAX 64
+
+static bool barebox_valid_ldh_char(char c)
+{
+ /* "LDH" -> "Letters, digits, hyphens", as per RFC 5890, Section 2.3.1 */
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9') || c == '-';
+}
+
+bool barebox_hostname_is_valid(const char *s)
+{
+ unsigned int n_dots = 0;
+ const char *p;
+ bool dot, hyphen;
+
+ /*
+ * Check if s looks like a valid hostname or FQDN. This does not do full
+ * DNS validation, but only checks if the name is composed of allowed
+ * characters and the length is not above the maximum allowed by Linux.
+ * Doesn't accept empty hostnames, hostnames with leading dots, and
+ * hostnames with multiple dots in a sequence. Doesn't allow hyphens at
+ * the beginning or end of label.
+ */
+ if (isempty(s))
+ return false;
+
+ for (p = s, dot = hyphen = true; *p; p++) {
+ if (*p == '.') {
+ if (dot || hyphen)
+ return false;
+
+ dot = true;
+ hyphen = false;
+ n_dots++;
+
+ } else if (*p == '-') {
+ if (dot)
+ return false;
+
+ dot = false;
+ hyphen = true;
+
+ } else {
+ if (!barebox_valid_ldh_char(*p))
+ return false;
+
+ dot = false;
+ hyphen = false;
+ }
+ }
+
+ if (dot || hyphen)
+ return false;
+
+ if (p - s > BAREBOX_HOST_NAME_MAX)
+ return false;
+
+ return true;
+}
+
/*
* The hostname is supposed to be the shortname of a board. It should
* contain only lowercase letters, numbers, '-', '_'. No whitespaces
@@ -157,6 +219,10 @@ void barebox_set_hostname(const char *__hostname)
globalvar_add_simple_string("hostname", &hostname);
free(hostname);
+
+ if (!barebox_hostname_is_valid(__hostname))
+ pr_warn("Hostname is not valid, please fix it\n");
+
hostname = xstrdup(__hostname);
}
diff --git a/drivers/aiodev/core.c b/drivers/aiodev/core.c
index 1fbb7b9188..5bdc4d83d4 100644
--- a/drivers/aiodev/core.c
+++ b/drivers/aiodev/core.c
@@ -73,6 +73,18 @@ int aiochannel_get_value(struct aiochannel *aiochan, int *value)
}
EXPORT_SYMBOL(aiochannel_get_value);
+int aiochannel_name_get_value(const char *chname, int *value)
+{
+ struct aiochannel *aio;
+
+ aio = aiochannel_by_name(chname);
+ if (IS_ERR(aio))
+ return PTR_ERR(aio);
+
+ return aiochannel_get_value(aio, value);
+}
+EXPORT_SYMBOL(aiochannel_name_get_value);
+
int aiochannel_get_index(struct aiochannel *aiochan)
{
return aiochan->index;
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 9f27addaa2..d9bb68e06b 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -219,6 +219,12 @@ config GPIO_LATCH
Say yes here to enable a driver for GPIO multiplexers based on latches
connected to other GPIOs.
+config GPIO_INTEL
+ bool "Intel GPIO driver"
+ depends on X86 || COMPILE_TEST
+ help
+ Say Y here to build support for the Intel GPIO driver.
+
endmenu
endif
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 628e975285..b0575ccf8c 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -30,3 +30,4 @@ obj-$(CONFIG_GPIO_SIFIVE) += gpio-sifive.o
obj-$(CONFIG_GPIO_STARFIVE) += gpio-starfive-vic.o
obj-$(CONFIG_GPIO_ZYNQ) += gpio-zynq.o
obj-$(CONFIG_GPIO_LATCH) += gpio-latch.o
+obj-$(CONFIG_GPIO_INTEL) += gpio-intel.o
diff --git a/drivers/gpio/gpio-intel.c b/drivers/gpio/gpio-intel.c
new file mode 100644
index 0000000000..ebec220f46
--- /dev/null
+++ b/drivers/gpio/gpio-intel.c
@@ -0,0 +1,198 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-FileCopyrightText: 2004 Tomas Marek, Elrest Solutions Company s.r.o.
+
+/*
+ * Based on the Linux kernel v6.8 drivers/pinctrl/intel/pinctrl-intel.c.
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <io.h>
+#include <gpio.h>
+
+#include <platform_data/gpio-intel.h>
+
+#define PADBAR 0x00c
+
+/* Offset from pad_regs */
+#define PADCFG0 0x000
+#define PADCFG0_RXEVCFG_MASK GENMASK(26, 25)
+#define PADCFG0_RXEVCFG_LEVEL (0 << 25)
+#define PADCFG0_RXEVCFG_EDGE (1 << 25)
+#define PADCFG0_RXEVCFG_DISABLED (2 << 25)
+#define PADCFG0_RXEVCFG_EDGE_BOTH (3 << 25)
+#define PADCFG0_PREGFRXSEL BIT(24)
+#define PADCFG0_RXINV BIT(23)
+#define PADCFG0_GPIROUTIOXAPIC BIT(20)
+#define PADCFG0_GPIROUTSCI BIT(19)
+#define PADCFG0_GPIROUTSMI BIT(18)
+#define PADCFG0_GPIROUTNMI BIT(17)
+#define PADCFG0_PMODE_SHIFT 10
+#define PADCFG0_PMODE_MASK GENMASK(13, 10)
+#define PADCFG0_PMODE_GPIO 0
+#define PADCFG0_GPIORXDIS BIT(9)
+#define PADCFG0_GPIOTXDIS BIT(8)
+#define PADCFG0_GPIORXSTATE BIT(1)
+#define PADCFG0_GPIOTXSTATE BIT(0)
+
+struct intel_gpio_chip {
+ struct gpio_chip chip;
+ void __iomem *community_pad_base;
+};
+
+static inline struct intel_gpio_chip *to_intel_gpio(struct gpio_chip *gc)
+{
+ return container_of(gc, struct intel_gpio_chip, chip);
+}
+
+static void __iomem *intel_gpio_padcfg0_reg(const struct intel_gpio_chip *chip,
+ const unsigned int gpio)
+{
+ const u32 pad_cfg_offset = 16;
+
+ return chip->community_pad_base + pad_cfg_offset * gpio;
+}
+
+static u32 intel_gpio_padcfg0_value(const struct intel_gpio_chip *chip,
+ const unsigned int gpio)
+{
+ return readl(intel_gpio_padcfg0_reg(chip, gpio));
+}
+
+static void intel_gpio_padcfg0_write(const struct intel_gpio_chip *chip,
+ const unsigned int gpio, u32 value)
+{
+ writel(value, intel_gpio_padcfg0_reg(chip, gpio));
+}
+
+static void intel_gpio_set_value(struct gpio_chip *gc, unsigned int gpio,
+ int value)
+{
+ struct intel_gpio_chip *chip = to_intel_gpio(gc);
+ u32 padcfg0;
+
+ padcfg0 = intel_gpio_padcfg0_value(chip, gpio);
+ if (value)
+ padcfg0 |= PADCFG0_GPIOTXSTATE;
+ else
+ padcfg0 &= ~PADCFG0_GPIOTXSTATE;
+ intel_gpio_padcfg0_write(chip, gpio, padcfg0);
+}
+
+static int intel_gpio_get_value(struct gpio_chip *gc, unsigned int gpio)
+{
+ struct intel_gpio_chip *chip = to_intel_gpio(gc);
+ u32 padcfg0;
+
+ padcfg0 = intel_gpio_padcfg0_value(chip, gpio);
+ if (!(padcfg0 & PADCFG0_GPIOTXDIS))
+ return !!(padcfg0 & PADCFG0_GPIOTXSTATE);
+
+ return !!(padcfg0 & PADCFG0_GPIORXSTATE);
+}
+
+static int intel_gpio_get_direction(struct gpio_chip *gc, unsigned int gpio)
+{
+ struct intel_gpio_chip *chip = to_intel_gpio(gc);
+ u32 padcfg0;
+
+ padcfg0 = intel_gpio_padcfg0_value(chip, gpio);
+
+ if (padcfg0 & PADCFG0_PMODE_MASK)
+ return -EINVAL;
+
+ if (padcfg0 & PADCFG0_GPIOTXDIS)
+ return GPIOF_DIR_IN;
+
+ return GPIOF_DIR_OUT;
+}
+
+static int intel_gpio_direction_input(struct gpio_chip *gc, unsigned int gpio)
+{
+ struct intel_gpio_chip *chip = to_intel_gpio(gc);
+ u32 padcfg0;
+
+ padcfg0 = intel_gpio_padcfg0_value(chip, gpio);
+ padcfg0 &= ~PADCFG0_GPIORXDIS;
+ padcfg0 |= PADCFG0_GPIOTXDIS;
+ intel_gpio_padcfg0_write(chip, gpio, padcfg0);
+
+ return 0;
+}
+
+static int intel_gpio_direction_output(struct gpio_chip *gc, unsigned int gpio,
+ int value)
+{
+ struct intel_gpio_chip *chip = to_intel_gpio(gc);
+ u32 padcfg0;
+
+ padcfg0 = intel_gpio_padcfg0_value(chip, gpio);
+ padcfg0 &= ~PADCFG0_GPIOTXDIS;
+ padcfg0 |= PADCFG0_GPIORXDIS;
+ if (value)
+ padcfg0 |= PADCFG0_GPIOTXSTATE;
+ else
+ padcfg0 &= ~PADCFG0_GPIOTXSTATE;
+ intel_gpio_padcfg0_write(chip, gpio, padcfg0);
+
+ return 0;
+}
+
+static struct gpio_ops intel_gpio_ops = {
+ .direction_input = intel_gpio_direction_input,
+ .direction_output = intel_gpio_direction_output,
+ .get_direction = intel_gpio_get_direction,
+ .get = intel_gpio_get_value,
+ .set = intel_gpio_set_value,
+};
+
+static int intel_gpio_probe(struct device *dev)
+{
+ const struct gpio_intel_platform_data *pdata;
+ struct intel_gpio_chip *intel_gpio;
+ void __iomem *community_pad_base;
+ void __iomem *community_base;
+ struct resource *iores;
+ int ret;
+
+ pdata = (struct gpio_intel_platform_data *)dev->platform_data;
+ if (!pdata) {
+ dev_err(dev, "Configuration missing!\n");
+ return -EINVAL;
+ }
+
+ iores = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(iores)) {
+ dev_err(dev, "Memory resource request failed: %ld\n",
+ PTR_ERR(iores));
+ return PTR_ERR(iores);
+ }
+
+ intel_gpio = xzalloc(sizeof(*intel_gpio));
+
+ intel_gpio->chip.ops = &intel_gpio_ops;
+ intel_gpio->chip.ngpio = pdata->ngpios;
+ intel_gpio->chip.dev = dev;
+
+ community_base = IOMEM(iores->start);
+ community_pad_base = IOMEM(community_base + readl(community_base + PADBAR));
+
+ intel_gpio->community_pad_base = community_pad_base;
+
+ ret = gpiochip_add(&intel_gpio->chip);
+
+ if (ret) {
+ dev_err(dev, "Couldn't add gpiochip: %pe\n", ERR_PTR(ret));
+ kfree(intel_gpio);
+ return ret;
+ }
+
+ return 0;
+}
+
+static struct driver_d intel_gpio_driver = {
+ .name = "intel-gpio",
+ .probe = intel_gpio_probe,
+};
+
+coredevice_platform_driver(intel_gpio_driver);
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 5bc261a010..a70e13eafc 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -172,16 +172,21 @@ int gpio_request(unsigned gpio, const char *label)
return gpiodesc_request(desc, label);
}
-bool gpio_slice_acquired(unsigned gpio)
+bool gpiod_slice_acquired(struct gpio_desc *desc)
{
- struct gpio_desc *desc = gpio_to_desc(gpio);
-
if (!desc)
return false;
return slice_acquired(&desc->chip->slice);
}
+bool gpio_slice_acquired(unsigned gpio)
+{
+ struct gpio_desc *desc = gpio_to_desc(gpio);
+
+ return gpiod_slice_acquired(desc);
+}
+
static void gpiodesc_free(struct gpio_desc *desc)
{
if (!desc->requested)
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index a274baf4b6..093b12b2ef 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -89,4 +89,10 @@ config I2C_CADENCE
Say Y here to include support for the Cadence I2C host controller found
in Zynq UltraScale+ MPSoCs.
+config I2C_EFI
+ bool "EFI I2C Master driver"
+ depends on EFI_PAYLOAD
+ help
+ Say Y here to include support for the EFI I2C Master driver.
+
endmenu
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index b4225995c0..30005c2bf8 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_I2C_AT91) += i2c-at91.o
obj-$(CONFIG_I2C_BCM283X) += i2c-bcm283x.o
+obj-$(CONFIG_I2C_EFI) += i2c-efi.o
obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
obj-$(CONFIG_I2C_IMX) += i2c-imx.o
lwl-$(CONFIG_I2C_IMX_EARLY) += i2c-imx-early.o
diff --git a/drivers/i2c/busses/i2c-efi.c b/drivers/i2c/busses/i2c-efi.c
new file mode 100644
index 0000000000..5f6cc0eed2
--- /dev/null
+++ b/drivers/i2c/busses/i2c-efi.c
@@ -0,0 +1,292 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * EFI I2C master driver
+ *
+ * Copyright (C) 2024 Elrest Solutions Company s.r.o.
+ * Author: Tomas Marek <tomas.marek@elrest.cz>
+ */
+
+#include <common.h>
+#include <i2c/i2c.h>
+#include <driver.h>
+#include <efi.h>
+#include <efi/efi-device.h>
+#include <efi/efi-util.h>
+#include <linux/kernel.h>
+
+/* Define EFI I2C transfer control flags */
+#define EFI_I2C_FLAG_READ 0x00000001
+
+#define EFI_I2C_ADDRESSING_10_BIT 0x80000000
+
+/* The set_bus_frequency() EFI call doesn't work (doesn't alter SPI clock
+ * frequency) if it's parameter is defined on the stack (observed with
+ * American Megatrends EFI Revision 5.19) - let's define it globaly.
+ */
+static unsigned int bus_clock;
+
+struct efi_i2c_capabilities {
+ u32 StructureSizeInBytes;
+ u32 MaximumReceiveBytes;
+ u32 MaximumTransmitBytes;
+ u32 MaximumTotalBytes;
+};
+
+struct efi_i2c_operation {
+ u32 Flags;
+ u32 LengthInBytes;
+ u8 *Buffer;
+};
+
+struct efi_i2c_request_packet {
+ unsigned int OperationCount;
+ struct efi_i2c_operation Operation[];
+};
+
+struct efi_i2c_master_protocol {
+ efi_status_t(EFIAPI * set_bus_frequency)(
+ struct efi_i2c_master_protocol *this,
+ unsigned int *bus_clock
+ );
+ efi_status_t(EFIAPI * reset)(
+ struct efi_i2c_master_protocol *this
+ );
+ efi_status_t(EFIAPI * start_request)(
+ struct efi_i2c_master_protocol *this,
+ unsigned int slave_address,
+ struct efi_i2c_request_packet *request_packet,
+ void *event,
+ efi_status_t *status
+ );
+ struct efi_i2c_capabilities *capabilities;
+};
+
+struct efi_i2c_priv {
+ struct efi_i2c_master_protocol *efi_protocol;
+ struct i2c_adapter adapter;
+};
+
+static inline struct efi_i2c_priv *
+adapter_to_efi_i2c_priv(struct i2c_adapter *a)
+{
+ return container_of(a, struct efi_i2c_priv, adapter);
+}
+
+static efi_status_t efi_i2c_request(
+ struct efi_i2c_request_packet *request,
+ const struct efi_i2c_priv *i2c_priv,
+ const unsigned int slave_address)
+{
+ const struct device *dev = &i2c_priv->adapter.dev;
+ efi_status_t efiret;
+
+ efiret = i2c_priv->efi_protocol->start_request(
+ i2c_priv->efi_protocol,
+ slave_address,
+ request,
+ NULL,
+ NULL
+ );
+
+ if (EFI_ERROR(efiret))
+ dev_err(dev, "I2C operation failed - %s (%lx)\n",
+ efi_strerror(efiret), -efiret);
+
+ return efiret;
+}
+
+static u32 efi_i2c_max_len(const struct efi_i2c_priv *i2c_priv,
+ const struct i2c_msg *msg)
+{
+ const struct efi_i2c_capabilities *capabilities =
+ i2c_priv->efi_protocol->capabilities;
+
+ if (msg->flags & I2C_M_RD)
+ return capabilities->MaximumReceiveBytes;
+ else
+ return capabilities->MaximumTransmitBytes;
+}
+
+static unsigned int efi_i2c_msg_op_cnt(const struct efi_i2c_priv *i2c_priv,
+ const struct i2c_msg *msg)
+{
+ unsigned int max_len;
+
+ max_len = efi_i2c_max_len(i2c_priv, msg);
+
+ return ((u64)msg->len + max_len - 1) / max_len;
+}
+
+static unsigned int efi_i2c_req_op_cnt(
+ const struct efi_i2c_priv *i2c_priv,
+ const struct i2c_msg *msg,
+ const int nmsgs)
+{
+ unsigned int op_cnt = 0;
+ int i;
+
+ for (i = nmsgs; i > 0; i--, msg++)
+ op_cnt += efi_i2c_msg_op_cnt(i2c_priv, msg);
+
+ return op_cnt;
+}
+
+static void i2c_msg_to_efi_op(
+ const struct efi_i2c_priv *i2c_priv,
+ const struct i2c_msg *msg,
+ struct efi_i2c_operation **op)
+{
+ unsigned int max_len = efi_i2c_max_len(i2c_priv, msg);
+ unsigned int remaining = msg->len;
+ u32 flags;
+
+ flags = (msg->flags & I2C_M_RD) ? EFI_I2C_FLAG_READ : 0;
+
+ do {
+ unsigned int len = min(remaining, max_len);
+
+ (*op)->Flags = flags;
+ (*op)->LengthInBytes = len;
+ (*op)->Buffer = msg->buf + (msg->len - remaining);
+ (*op)++;
+
+ remaining -= len;
+ } while (remaining > 0);
+}
+
+static int i2c_msgs_to_efi_transaction(struct i2c_adapter *adapter,
+ struct efi_i2c_operation *op,
+ const struct i2c_msg *msg,
+ const int nmsgs)
+{
+ struct efi_i2c_priv *i2c_priv = adapter_to_efi_i2c_priv(adapter);
+ const struct i2c_msg *msg_tmp;
+ int ret = 0;
+ int i;
+
+ msg_tmp = msg;
+ for (i = nmsgs; i > 0; i--, msg_tmp++) {
+ if (msg_tmp->flags & I2C_M_DATA_ONLY) {
+ ret = -ENOTSUPP;
+ break;
+ }
+
+ if (i > 0 && msg_tmp->addr != msg->addr) {
+ dev_err(&adapter->dev, "Different I2C addresses in one request not supported!\n");
+ ret = -ENOTSUPP;
+ break;
+ }
+
+ i2c_msg_to_efi_op(i2c_priv, msg_tmp, &op);
+ }
+
+ return ret;
+}
+
+static int efi_i2c_xfer(struct i2c_adapter *adapter,
+ struct i2c_msg *msg, int nmsgs)
+{
+ struct efi_i2c_priv *i2c_priv = adapter_to_efi_i2c_priv(adapter);
+ struct efi_i2c_request_packet *request_packet;
+ unsigned int slave_address;
+ efi_status_t efiret;
+ unsigned int op_cnt;
+ int ret = nmsgs;
+ int len;
+
+ op_cnt = efi_i2c_req_op_cnt(i2c_priv, msg, nmsgs);
+
+ len = sizeof(*request_packet) + op_cnt * sizeof(struct efi_i2c_operation);
+ request_packet = malloc(len);
+ if (!request_packet)
+ return -ENOMEM;
+
+ request_packet->OperationCount = op_cnt;
+ ret = i2c_msgs_to_efi_transaction(adapter, request_packet->Operation,
+ msg, nmsgs);
+ if (ret)
+ goto out_free;
+
+ slave_address = msg->addr;
+ if (msg->flags & I2C_M_TEN)
+ slave_address |= EFI_I2C_ADDRESSING_10_BIT;
+
+ efiret = efi_i2c_request(request_packet, i2c_priv, slave_address);
+ if (EFI_ERROR(efiret)) {
+ ret = -efi_errno(efiret);
+ goto out_free;
+ }
+
+ ret = nmsgs;
+
+out_free:
+ free(request_packet);
+
+ return ret;
+}
+
+static int efi_i2c_probe(struct efi_device *efidev)
+{
+ struct i2c_platform_data *pdata;
+ struct efi_i2c_priv *efi_i2c;
+ struct i2c_timings timings;
+ efi_status_t efiret;
+ int ret;
+
+ efi_i2c = xzalloc(sizeof(*efi_i2c));
+
+ efi_i2c->efi_protocol = efidev->protocol;
+
+ efi_i2c->adapter.master_xfer = efi_i2c_xfer;
+ efi_i2c->adapter.nr = efidev->dev.id;
+ efi_i2c->adapter.dev.parent = &efidev->dev;
+ efi_i2c->adapter.dev.of_node = efidev->dev.of_node;
+
+ i2c_parse_fw_timings(&efidev->dev, &timings, true);
+
+ pdata = efidev->dev.platform_data;
+ if (pdata && pdata->bitrate)
+ timings.bus_freq_hz = pdata->bitrate;
+
+ efiret = efi_i2c->efi_protocol->reset(efi_i2c->efi_protocol);
+ if (EFI_ERROR(efiret)) {
+ dev_err(&efidev->dev, "controller reset failed - %ld\n",
+ efiret);
+ ret = -efi_errno(efiret);
+ goto out_free;
+ }
+
+ bus_clock = timings.bus_freq_hz;
+ efiret = efi_i2c->efi_protocol->set_bus_frequency(
+ efi_i2c->efi_protocol,
+ &bus_clock);
+ if (EFI_ERROR(efiret)) {
+ dev_err(&efidev->dev, "I2C clock frequency %u update failed - %s (%lx)\n",
+ timings.bus_freq_hz, efi_strerror(efiret), -efiret);
+ ret = -efi_errno(efiret);
+ goto out_free;
+ }
+
+ dev_dbg(&efidev->dev, "I2C clock frequency %u\n", bus_clock);
+
+ ret = i2c_add_numbered_adapter(&efi_i2c->adapter);
+
+out_free:
+ if (ret < 0)
+ kfree(efi_i2c);
+
+ return ret;
+}
+
+static struct efi_driver efi_i2c_driver = {
+ .driver = {
+ .name = "efi-i2c",
+ },
+ .probe = efi_i2c_probe,
+ .guid = EFI_I2C_MASTER_PROTOCOL_GUID
+};
+device_efi_driver(efi_i2c_driver);
+
+MODULE_AUTHOR("Tomas Marek <tomas.marek@elrest.cz>");
+MODULE_DESCRIPTION("EFI I2C master driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index 52234c0ecc..01e0b722c2 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -12,6 +12,17 @@ config INPUT
config INPUT_MATRIXKMAP
bool
+config INPUT_EVBUG
+ bool "Event debugging"
+ help
+ Say Y here if you have a problem with the input subsystem and
+ want all events (keypresses), to be output to
+ the barebox log. While this is useful for debugging, it's also
+ a security threat - your keypresses include your passwords, of
+ course and could be visible to userspace if pstore is configured.
+
+ If unsure, say N.
+
config KEYBOARD_GPIO
bool "GPIO Buttons"
depends on GENERIC_GPIO
diff --git a/drivers/input/gpio_keys.c b/drivers/input/gpio_keys.c
index c23d20563c..c897acf3bd 100644
--- a/drivers/input/gpio_keys.c
+++ b/drivers/input/gpio_keys.c
@@ -31,7 +31,6 @@ struct gpio_keys {
struct poller_async poller;
struct input_device input;
- struct device *dev;
};
static void gpio_key_poller(void *data)
@@ -60,7 +59,7 @@ static void gpio_key_poller(void *data)
gb->debounce_start = get_time_ns();
input_report_key_event(&gk->input, gb->code, pressed);
- dev_dbg(gk->dev, "%s gpio(%d) as %d\n",
+ dev_dbg(gk->input.parent, "%s gpio(%d) as %d\n",
pressed ? "pressed" : "released", gb->gpio, gb->code);
gb->previous_state = val;
}
@@ -141,8 +140,6 @@ static int __init gpio_keys_probe(struct device *dev)
gk = xzalloc(sizeof(*gk));
- gk->dev = dev;
-
if (dev->of_node)
ret = gpio_keys_probe_dt(gk, dev);
else
@@ -162,6 +159,7 @@ static int __init gpio_keys_probe(struct device *dev)
gk->buttons[i].previous_state = gk->buttons[i].active_low;
}
+ gk->input.parent = dev;
ret = input_device_register(&gk->input);
if (ret)
return ret;
diff --git a/drivers/input/imx_keypad.c b/drivers/input/imx_keypad.c
index fc6b45b3cb..e57a884630 100644
--- a/drivers/input/imx_keypad.c
+++ b/drivers/input/imx_keypad.c
@@ -72,7 +72,6 @@
struct imx_keypad {
struct input_device input;
struct clk *clk;
- struct device *dev;
void __iomem *mmio_base;
struct poller_struct poller;
@@ -199,10 +198,6 @@ static void imx_keypad_fire_events(struct imx_keypad *keypad,
input_report_key_event(&keypad->input, keypad->keycodes[code],
matrix_volatile_state[col] & (1 << row));
-
- dev_dbg(keypad->dev, "Event code: %d, val: %d",
- keypad->keycodes[code],
- matrix_volatile_state[col] & (1 << row));
}
}
}
@@ -367,7 +362,6 @@ static int __init imx_keypad_probe(struct device *dev)
keypad = xzalloc(sizeof(struct imx_keypad));
- keypad->dev = dev;
iores = dev_request_mem_resource(dev, 0);
if (IS_ERR(iores))
return PTR_ERR(iores);
@@ -410,6 +404,7 @@ static int __init imx_keypad_probe(struct device *dev)
if (ret)
return ret;
+ keypad->input.parent = dev;
ret = input_device_register(&keypad->input);
if (ret)
return ret;
diff --git a/drivers/input/input.c b/drivers/input/input.c
index deef5ddd22..1a47929351 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
+#define pr_fmt(fmt) "input: " fmt
+
#include <common.h>
#include <init.h>
#include <kfifo.h>
@@ -33,6 +35,15 @@ void input_report_key_event(struct input_device *idev, unsigned int code, int va
if (code > KEY_MAX)
return;
+ /*
+ * We don't use pr_debug here as we want to output the message
+ * to the log, even if CONFIG_COMPILE_LOGLEVEL < MSG_DEBUG and
+ * the DEBUG mcro wasn't defined for the file.
+ */
+ if (IS_ENABLED(CONFIG_INPUT_EVBUG))
+ pr_print(MSG_DEBUG, "Event. Dev: %s, Type: %d, Code: %d, Value: %d\n",
+ dev_name(idev->parent), EV_KEY, code, value);
+
if (value)
set_bit(code, idev->keys);
else
diff --git a/drivers/input/usb_kbd.c b/drivers/input/usb_kbd.c
index 86b48db2a7..2e75aabf3d 100644
--- a/drivers/input/usb_kbd.c
+++ b/drivers/input/usb_kbd.c
@@ -188,6 +188,7 @@ static int usb_kbd_probe(struct usb_device *usbdev,
} else
dev_dbg(&usbdev->dev, "poll keyboard via int ep\n");
+ data->input.parent = &usbdev->dev;
ret = input_device_register(&data->input);
if (ret) {
dev_err(&usbdev->dev, "can't register input\n");
diff --git a/drivers/input/virtio_input.c b/drivers/input/virtio_input.c
index 5c6849b561..655a905172 100644
--- a/drivers/input/virtio_input.c
+++ b/drivers/input/virtio_input.c
@@ -216,6 +216,7 @@ static int virtinput_probe(struct virtio_device *vdev)
virtio_device_ready(vdev);
+ vi->idev.parent = &vdev->dev;
err = input_device_register(&vi->idev);
if (err)
goto err_input_register;
diff --git a/drivers/mci/arasan-sdhci.c b/drivers/mci/arasan-sdhci.c
index b7dd98049f..be13954541 100644
--- a/drivers/mci/arasan-sdhci.c
+++ b/drivers/mci/arasan-sdhci.c
@@ -65,6 +65,8 @@ struct arasan_sdhci_host {
struct mci_host mci;
struct sdhci sdhci;
unsigned int quirks; /* Arasan deviations from spec */
+ const struct clk_ops *sdcardclk_ops;
+ const struct clk_ops *sampleclk_ops;
struct sdhci_arasan_clk_data clk_data;
/* Controller does not have CD wired and will not function normally without */
#define SDHCI_ARASAN_QUIRK_FORCE_CDTEST BIT(0)
@@ -402,8 +404,8 @@ static int arasan_zynqmp_sampleclk_set_phase(struct clk_hw *hw, int degrees)
return ret;
}
-static unsigned long arasan_zynqmp_sampleclk_recalc_rate(struct clk_hw *hw,
- unsigned long parent_rate)
+static unsigned long arasan_sampleclk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
{
struct sdhci_arasan_clk_data *clk_data =
container_of(hw, struct sdhci_arasan_clk_data, sdcardclk_hw);
@@ -474,8 +476,8 @@ static int arasan_zynqmp_sdcardclk_set_phase(struct clk_hw *hw, int degrees)
return ret;
}
-static unsigned long arasan_zynqmp_sdcardclk_recalc_rate(struct clk_hw *hw,
- unsigned long parent_rate)
+static unsigned long arasan_sdcardclk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
{
struct sdhci_arasan_clk_data *clk_data =
container_of(hw, struct sdhci_arasan_clk_data, sdcardclk_hw);
@@ -486,13 +488,21 @@ static unsigned long arasan_zynqmp_sdcardclk_recalc_rate(struct clk_hw *hw,
return host->actual_clock;
};
-static const struct clk_ops clk_sampleclk_ops = {
- .recalc_rate = arasan_zynqmp_sampleclk_recalc_rate,
+static const struct clk_ops arasan_sampleclk_ops = {
+ .recalc_rate = arasan_sampleclk_recalc_rate,
+};
+
+static const struct clk_ops arasan_sdcardclk_ops = {
+ .recalc_rate = arasan_sdcardclk_recalc_rate,
+};
+
+static const struct clk_ops zynqmp_sampleclk_ops = {
+ .recalc_rate = arasan_sampleclk_recalc_rate,
.set_phase = arasan_zynqmp_sampleclk_set_phase,
};
-static const struct clk_ops clk_sdcardclk_ops = {
- .recalc_rate = arasan_zynqmp_sdcardclk_recalc_rate,
+static const struct clk_ops zynqmp_sdcardclk_ops = {
+ .recalc_rate = arasan_sdcardclk_recalc_rate,
.set_phase = arasan_zynqmp_sdcardclk_set_phase,
};
@@ -510,10 +520,11 @@ static const struct clk_ops clk_sdcardclk_ops = {
* Return: 0 on success and error value on error
*/
static int
-arasan_sdhci_register_sampleclk(struct sdhci_arasan_clk_data *clk_data,
+arasan_sdhci_register_sampleclk(struct arasan_sdhci_host *sdhci_arasan,
struct clk *clk_xin,
struct device *dev)
{
+ struct sdhci_arasan_clk_data *clk_data = &sdhci_arasan->clk_data;
struct device_node *np = dev->of_node;
struct clk_init_data sampleclk_init = {};
const char *clk_name;
@@ -529,7 +540,7 @@ arasan_sdhci_register_sampleclk(struct sdhci_arasan_clk_data *clk_data,
clk_name = __clk_get_name(clk_xin);
sampleclk_init.parent_names = &clk_name;
sampleclk_init.num_parents = 1;
- sampleclk_init.ops = &clk_sampleclk_ops;
+ sampleclk_init.ops = sdhci_arasan->sampleclk_ops;
clk_data->sampleclk_hw.init = &sampleclk_init;
clk_data->sampleclk = clk_register(dev, &clk_data->sampleclk_hw);
@@ -559,10 +570,11 @@ arasan_sdhci_register_sampleclk(struct sdhci_arasan_clk_data *clk_data,
* Return: 0 on success and error value on error
*/
static int
-arasan_sdhci_register_sdcardclk(struct sdhci_arasan_clk_data *clk_data,
+arasan_sdhci_register_sdcardclk(struct arasan_sdhci_host *sdhci_arasan,
struct clk *clk_xin,
struct device *dev)
{
+ struct sdhci_arasan_clk_data *clk_data = &sdhci_arasan->clk_data;
struct device_node *np = dev->of_node;
struct clk_init_data sdcardclk_init = {};
const char *clk_name;
@@ -577,7 +589,7 @@ arasan_sdhci_register_sdcardclk(struct sdhci_arasan_clk_data *clk_data,
clk_name = __clk_get_name(clk_xin);
sdcardclk_init.parent_names = &clk_name;
- sdcardclk_init.ops = &clk_sdcardclk_ops;
+ sdcardclk_init.ops = sdhci_arasan->sdcardclk_ops;
sdcardclk_init.num_parents = 1;
clk_data->sdcardclk_hw.init = &sdcardclk_init;
@@ -615,7 +627,7 @@ arasan_sdhci_register_sdcardclk(struct sdhci_arasan_clk_data *clk_data,
*
* Return: 0 on success and error value on error
*/
-static int arasan_sdhci_register_sdclk(struct sdhci_arasan_clk_data *sdhci_arasan,
+static int arasan_sdhci_register_sdclk(struct arasan_sdhci_host *sdhci_arasan,
struct clk *clk_xin,
struct device *dev)
{
@@ -772,8 +784,15 @@ static int arasan_sdhci_probe(struct device *dev)
mci->f_min = 50000000 / 256;
- if (IS_ENABLED(CONFIG_ARCH_ZYNQMP))
- arasan_sdhci_register_sdclk(&arasan_sdhci->clk_data, clk_xin, dev);
+ if (of_device_is_compatible(np, "xlnx,zynqmp-8.9a")) {
+ arasan_sdhci->sdcardclk_ops = &zynqmp_sdcardclk_ops;
+ arasan_sdhci->sampleclk_ops = &zynqmp_sampleclk_ops;
+ } else {
+ arasan_sdhci->sdcardclk_ops = &arasan_sdcardclk_ops;
+ arasan_sdhci->sampleclk_ops = &arasan_sampleclk_ops;
+ }
+
+ arasan_sdhci_register_sdclk(arasan_sdhci, clk_xin, dev);
arasan_dt_parse_clk_phases(dev, &arasan_sdhci->clk_data);
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index a3b25ea01a..6d4abe321b 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2058,8 +2058,8 @@ static void mci_info(struct device *dev)
mci->csd[2], mci->csd[3]);
printf(" Max. transfer speed: %u Hz\n", mci->tran_speed);
mci_print_caps(mci->card_caps);
- printf(" Manufacturer ID: %02X\n", extract_mid(mci));
- printf(" OEM/Application ID: %04X\n", extract_oid(mci));
+ printf(" Manufacturer ID: 0x%02X\n", extract_mid(mci));
+ printf(" OEM/Application ID: 0x%04X\n", extract_oid(mci));
printf(" Product name: '%c%c%c%c%c'\n", mci->cid[0] & 0xff,
(mci->cid[1] >> 24), (mci->cid[1] >> 16) & 0xff,
(mci->cid[1] >> 8) & 0xff, mci->cid[1] & 0xff);
diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index 8bba1e3bf9..ba1e07e966 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -484,10 +484,10 @@ void sdhci_setup_data_dma(struct sdhci *sdhci, struct mci_data *data,
nbytes = data->blocks * data->blocksize;
if (data->flags & MMC_DATA_READ)
- *dma = dma_map_single(dev, (void *)data->src, nbytes,
+ *dma = dma_map_single(dev, data->dest, nbytes,
DMA_FROM_DEVICE);
else
- *dma = dma_map_single(dev, data->dest, nbytes,
+ *dma = dma_map_single(dev, (void *)data->src, nbytes,
DMA_TO_DEVICE);
if (dma_mapping_error(dev, *dma)) {
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 1773db09a1..e0e72f8551 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -658,9 +658,6 @@ static const struct spi_device_id spi_nor_ids[] = {
{ "mr25h10", CAT25_INFO(128 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
{ "mr25h40", CAT25_INFO(512 * 1024, 1, 256, 3, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
- /* Fujitsu */
- { "mb85rs1mt", INFO(0x047f27, 0, 128 * 1024, 1, SPI_NOR_NO_ERASE) },
-
/* GigaDevice */
{ "gd25q16", INFO(0xc84015, 0, 64 * 1024, 32, SECT_4K) },
{ "gd25q32", INFO(0xc84016, 0, 64 * 1024, 64, SECT_4K) },
diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index ab52de35b5..b12f54ed38 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -27,6 +27,11 @@ static int phy_read_page(struct phy_device *phydev)
{
struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver);
+ if (!phydrv->read_page) {
+ dev_warn_once(&phydev->dev, "read_page callback not available, PHY driver not loaded?\n");
+ return -EOPNOTSUPP;
+ }
+
return phydrv->read_page(phydev);
}
@@ -34,6 +39,11 @@ static int phy_write_page(struct phy_device *phydev, int page)
{
struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver);
+ if (!phydrv->write_page) {
+ dev_warn_once(&phydev->dev, "write_page callback not available, PHY driver not loaded?\n");
+ return -EOPNOTSUPP;
+ }
+
return phydrv->write_page(phydev, page);
}
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index c6108c488b..067b0c2f9e 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -724,6 +724,10 @@ static const struct usb_device_id products[] = {
USB_DEVICE(0x0df6, 0x0072),
.driver_info = &sitecom_info,
}, {
+ /* Sitecom USB 3.0 to Gigabit Adapter */
+ USB_DEVICE(0x0df6, 0x0056),
+ .driver_info = &sitecom_info,
+}, {
/* Samsung USB Ethernet Adapter */
USB_DEVICE(0x04e8, 0xa100),
.driver_info = &samsung_info,
@@ -735,6 +739,10 @@ static const struct usb_device_id products[] = {
/* Belkin B2B128 USB 3.0 Hub + Gigabit Ethernet Adapter */
USB_DEVICE(0x050d, 0x0128),
.driver_info = &belkin_info,
+}, {
+ /* Belkin Gigabit Ethernet Adapter */
+ USB_DEVICE(0x050d, 0x5055),
+ .driver_info = &belkin_info,
},
{ },
};
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index c1e937ea2c..ca9939c9e9 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -2173,6 +2173,11 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank,
ret = 3;
}
+ if (ret < 0) {
+ dev_err(dev, "unsupported pull setting %d\n", pull);
+ return ret;
+ }
+
/* enable the write to the equivalent lower bits */
data = ((1 << RK3188_PULL_BITS_PER_PIN) - 1) << (bit + 16);
rmask = data | (data >> 16);
diff --git a/efi/guid.c b/efi/guid.c
index f6bd4a24e2..ef230a2b24 100644
--- a/efi/guid.c
+++ b/efi/guid.c
@@ -115,6 +115,7 @@ const char *efi_guid_string(efi_guid_t *g)
EFI_GUID_STRING(EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID_31, "Network Interface Identifier Protocol_31", "EFI1.1 Network Interface Identifier Protocol");
EFI_GUID_STRING(EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID, "Network Interface Identifier Protocol", "EFI Network Interface Identifier Protocol");
EFI_GUID_STRING(EFI_TIMESTAMP_PROTOCOL_GUID, "Timestamp", "Timestamp");
+ EFI_GUID_STRING(EFI_I2C_MASTER_PROTOCOL_GUID, "I2C Master Protocol", "EFI I2C Master Protocol");
/* TPM 1.2 */
EFI_GUID_STRING( EFI_TCG_PROTOCOL_GUID, "TcgService", "TCGServices Protocol");
diff --git a/images/Makefile.rockchip b/images/Makefile.rockchip
index ea32af4241..ceacfde10d 100644
--- a/images/Makefile.rockchip
+++ b/images/Makefile.rockchip
@@ -32,6 +32,7 @@ image-$(CONFIG_MACH_PHYTEC_SOM_RK3288) += barebox-rk3288-phycore-som.img
$(call build_rockchip_image, CONFIG_MACH_RK3568_EVB, start_rk3568_evb, rockchip-rk3568-evb/sdram-init.bin, rk3568-evb)
$(call build_rockchip_image, CONFIG_MACH_RK3568_BPI_R2PRO, start_rk3568_bpi_r2pro, rockchip-rk3568-bpi-r2pro/sdram-init.bin, rk3568-bpi-r2pro)
$(call build_rockchip_image, CONFIG_MACH_PINE64_QUARTZ64, start_quartz64a, pine64-quartz64/sdram-init.bin, quartz64a)
+$(call build_rockchip_image, CONFIG_MACH_PROTONIC_MECSBC, start_mecsbc, protonic-mecsbc/sdram-init.bin, mecsbc)
$(call build_rockchip_image, CONFIG_MACH_RADXA_ROCK3, start_rock3a, radxa-rock3/sdram-init.bin, rock3a)
$(call build_rockchip_image, CONFIG_MACH_RADXA_ROCK5, start_rock5b, radxa-rock5/sdram-init.bin, rock5b)
$(call build_rockchip_image, CONFIG_MACH_RADXA_CM3, start_radxa_cm3_io, radxa-cm3/sdram-init.bin, radxa-cm3-io)
diff --git a/include/aiodev.h b/include/aiodev.h
index 56bd2da9f5..fb0807ad42 100644
--- a/include/aiodev.h
+++ b/include/aiodev.h
@@ -47,4 +47,13 @@ static inline const char *aiochannel_get_unit(struct aiochannel *aiochan)
extern struct list_head aiodevices;
#define for_each_aiodevice(aiodevice) list_for_each_entry(aiodevice, &aiodevices, list)
+#ifdef CONFIG_AIODEV
+int aiochannel_name_get_value(const char *chname, int *value);
+#else
+static inline int aiochannel_name_get_value(const char *chname, int *value)
+{
+ return -EOPNOTSUPP;
+}
+#endif
+
#endif
diff --git a/include/bootm.h b/include/bootm.h
index ee2b574521..98ac5e5a93 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -34,6 +34,11 @@ struct bootm_data {
* value of global.machine_id to Kernel.
*/
bool provide_machine_id;
+ /*
+ * provide_hostname - if true, try to add systemd.hostname= with value
+ * of global.hostname to Kernel.
+ */
+ bool provide_hostname;
unsigned long initrd_address;
unsigned long os_address;
unsigned long os_entry;
@@ -147,6 +152,9 @@ int bootm_get_os_size(struct image_data *data);
enum bootm_verify bootm_get_verify_mode(void);
void bootm_set_verify_mode(enum bootm_verify mode);
+bool bootm_signed_images_are_forced(void);
+void bootm_force_signed_images(void);
+
#define UIMAGE_SOME_ADDRESS (UIMAGE_INVALID_ADDRESS - 1)
void *booti_load_image(struct image_data *data, phys_addr_t *oftree);
diff --git a/include/common.h b/include/common.h
index b7b4d9e350..d7b5261bc9 100644
--- a/include/common.h
+++ b/include/common.h
@@ -127,6 +127,7 @@ void barebox_set_model(const char *);
const char *barebox_get_hostname(void);
void barebox_set_hostname(const char *);
void barebox_set_hostname_no_overwrite(const char *);
+bool barebox_hostname_is_valid(const char *s);
const char *barebox_get_serial_number(void);
void barebox_set_serial_number(const char *);
diff --git a/include/console.h b/include/console.h
index 69c0ec144b..62d13d7aa0 100644
--- a/include/console.h
+++ b/include/console.h
@@ -102,6 +102,7 @@ int console_set_active(struct console_device *cdev, unsigned active);
unsigned console_get_active(struct console_device *cdev);
int console_set_baudrate(struct console_device *cdev, unsigned baudrate);
unsigned console_get_baudrate(struct console_device *cdev);
+void console_set_stdoutpath(struct console_device *cdev, unsigned baudrate);
struct console_device *of_console_by_stdout_path(void);
diff --git a/include/efi.h b/include/efi.h
index 6bb5f8cb0a..a27cbe1f49 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -562,6 +562,9 @@ extern struct efi_runtime_services *RT;
#define EFI_TIMESTAMP_PROTOCOL_GUID \
EFI_GUID(0xafbfde41, 0x2e6e, 0x4262, 0xba, 0x65, 0x62, 0xb9, 0x23, 0x6e, 0x54, 0x95)
+#define EFI_I2C_MASTER_PROTOCOL_GUID \
+ EFI_GUID(0xcd72881f, 0x45b5, 0x4feb, 0x98, 0xc8, 0x31, 0x3d, 0xa8, 0x11, 0x74, 0x62)
+
/* barebox specific GUIDs */
#define EFI_BAREBOX_VENDOR_GUID \
EFI_GUID(0x5b91f69c, 0x8b88, 0x4a2b, 0x92, 0x69, 0x5f, 0x1d, 0x80, 0x2b, 0x51, 0x75)
diff --git a/include/input/input.h b/include/input/input.h
index d169c647bd..9445d20e56 100644
--- a/include/input/input.h
+++ b/include/input/input.h
@@ -14,6 +14,7 @@ struct input_event {
struct input_device {
struct list_head list;
+ struct device *parent;
DECLARE_BITMAP(keys, KEY_CNT);
};
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 531ed14725..e04f516b31 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -45,6 +45,8 @@ struct gpio_descs {
DECLARE_FLEX_ARRAY(struct gpio_desc *, desc);
};
+bool gpiod_slice_acquired(struct gpio_desc *);
+
#if defined(CONFIG_OFDEVICE) && defined(CONFIG_GPIOLIB)
/* returned gpio descriptor can be passed to any normal gpio_* function */
diff --git a/include/mach/zynqmp/firmware-zynqmp.h b/include/mach/zynqmp/firmware-zynqmp.h
index 00c63058f4..9f833189d3 100644
--- a/include/mach/zynqmp/firmware-zynqmp.h
+++ b/include/mach/zynqmp/firmware-zynqmp.h
@@ -119,8 +119,19 @@ struct zynqmp_eemi_ops {
const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void);
+#if defined(CONFIG_ARCH_ZYNQMP)
int zynqmp_pm_set_sd_tapdelay(u32 node_id, u32 type, u32 value);
int zynqmp_pm_sd_dll_reset(u32 node_id, u32 type);
+#else
+static inline int zynqmp_pm_set_sd_tapdelay(u32 node_id, u32 type, u32 value)
+{
+ return -ENOSYS;
+}
+static inline int zynqmp_pm_sd_dll_reset(u32 node_id, u32 type)
+{
+ return -ENOSYS;
+}
+#endif
int zynqmp_pm_write_ggs(u32 index, u32 value);
int zynqmp_pm_read_ggs(u32 index, u32 *value);
diff --git a/include/mci.h b/include/mci.h
index 52bf84ecdb..2274ca8e97 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -559,15 +559,14 @@ struct mci {
struct mci_host *host; /**< the host for this card */
struct device dev; /**< the device for our disk (mcix) */
unsigned version;
- bool sdio; /**< card is a SDIO card */
- /** != 0 when a high capacity card is connected (OCR -> OCR_HCS) */
- int high_capacity;
unsigned card_caps; /**< Card's capabilities */
unsigned ocr; /**< card's "operation condition register" */
unsigned scr[2];
unsigned csd[4]; /**< card's "card specific data register" */
unsigned cid[4]; /**< card's "card identification register" */
- unsigned short rca; /* FIXME */
+ unsigned short rca; /**< relative card address */
+ bool sdio; /**< card is a SDIO card */
+ bool high_capacity; /**< high capacity card is connected (OCR -> OCR_HCS) */
unsigned tran_speed; /**< Maximum transfer speed */
/** currently used data block length for read accesses */
unsigned read_bl_len;
diff --git a/include/platform_data/gpio-intel.h b/include/platform_data/gpio-intel.h
new file mode 100644
index 0000000000..4da4764998
--- /dev/null
+++ b/include/platform_data/gpio-intel.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef __GPIO_INTEL_H
+#define __GPIO_INTEL_H
+
+#include <linux/types.h>
+
+struct gpio_intel_platform_data {
+ resource_size_t community_base;
+ resource_size_t community_size;
+ unsigned int ngpios;
+};
+
+static inline struct device *add_intel_gpio_device(
+ struct gpio_intel_platform_data *pdata
+)
+{
+ return add_generic_device("intel-gpio", DEVICE_ID_DYNAMIC, NULL,
+ pdata->community_base, pdata->community_size,
+ IORESOURCE_MEM, pdata);
+}
+
+#endif /* __GPIO_INTEL_H */
diff --git a/include/string.h b/include/string.h
index 2f2af85b55..4ee3be6d93 100644
--- a/include/string.h
+++ b/include/string.h
@@ -33,4 +33,6 @@ static inline bool streq_ptr(const char *a, const char *b)
return strcmp_ptr(a, b) == 0;
}
+bool isempty(const char *s);
+
#endif /* __STRING_H */
diff --git a/include/usb_dfu_trailer.h b/include/usb_dfu_trailer.h
deleted file mode 100644
index 64b8407275..0000000000
--- a/include/usb_dfu_trailer.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef _USB_DFU_TRAILER_H
-#define _USB_DFU_TRAILER_H
-
-/* trailer handling for DFU files */
-
-#define BAREBOX_DFU_TRAILER_V1 1
-#define BAREBOX_DFU_TRAILER_MAGIC 0x19731978
-struct barebox_dfu_trailer {
- u_int32_t magic;
- u_int16_t version;
- u_int16_t length;
- u_int16_t vendor;
- u_int16_t product;
- u_int32_t revision;
-} __attribute__((packed));
-
-/* we mirror the trailer because we want it to be longer in later versions
- * while keeping backwards compatibility */
-static inline void dfu_trailer_mirror(struct barebox_dfu_trailer *trailer,
- unsigned char *eof)
-{
- int i;
- int len = sizeof(struct barebox_dfu_trailer);
- unsigned char *src = eof - len;
- unsigned char *dst = (unsigned char *) trailer;
-
- for (i = 0; i < len; i++)
- dst[len-1-i] = src[i];
-}
-
-#endif /* _USB_DFU_TRAILER_H */
diff --git a/lib/bzlib_private.h b/lib/bzlib_private.h
deleted file mode 100644
index de10dd4215..0000000000
--- a/lib/bzlib_private.h
+++ /dev/null
@@ -1,521 +0,0 @@
-/*
- * This file is a modified version of bzlib_private.h from the bzip2-1.0.2
- * distribution which can be found at http://sources.redhat.com/bzip2/
- */
-
-/*-------------------------------------------------------------*/
-/*--- Private header file for the library. ---*/
-/*--- bzlib_private.h ---*/
-/*-------------------------------------------------------------*/
-
-/*--
- This file is a part of bzip2 and/or libbzip2, a program and
- library for lossless, block-sorting data compression.
-
- Copyright (C) 1996-2002 Julian R Seward. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- 2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
- 4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Julian Seward, Cambridge, UK.
- jseward@acm.org
- bzip2/libbzip2 version 1.0 of 21 March 2000
-
- This program is based on (at least) the work of:
- Mike Burrows
- David Wheeler
- Peter Fenwick
- Alistair Moffat
- Radford Neal
- Ian H. Witten
- Robert Sedgewick
- Jon L. Bentley
-
- For more information on these sources, see the manual.
---*/
-
-
-#ifndef _BZLIB_PRIVATE_H
-#define _BZLIB_PRIVATE_H
-
-#include <malloc.h>
-#include <linux/stddef.h>
-
-#include "bzlib.h"
-
-#ifndef BZ_NO_STDIO
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#endif
-
-
-/*-- General stuff. --*/
-
-#define BZ_VERSION "1.0.2, 30-Dec-2001"
-
-typedef char Char;
-typedef unsigned char Bool;
-typedef unsigned char UChar;
-typedef int Int32;
-typedef unsigned int UInt32;
-typedef short Int16;
-typedef unsigned short UInt16;
-
-#define True ((Bool)1)
-#define False ((Bool)0)
-
-#ifndef __GNUC__
-#define __inline__ /* */
-#endif
-
-#ifndef BZ_NO_STDIO
-extern void BZ2_bz__AssertH__fail ( int errcode );
-#define AssertH(cond,errcode) \
- { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
-#if BZ_DEBUG
-#define AssertD(cond,msg) \
- { if (!(cond)) { \
- fprintf ( stderr, \
- "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
- exit(1); \
- }}
-#else
-#define AssertD(cond,msg) /* */
-#endif
-#define VPrintf0(zf) \
- fprintf(stderr,zf)
-#define VPrintf1(zf,za1) \
- fprintf(stderr,zf,za1)
-#define VPrintf2(zf,za1,za2) \
- fprintf(stderr,zf,za1,za2)
-#define VPrintf3(zf,za1,za2,za3) \
- fprintf(stderr,zf,za1,za2,za3)
-#define VPrintf4(zf,za1,za2,za3,za4) \
- fprintf(stderr,zf,za1,za2,za3,za4)
-#define VPrintf5(zf,za1,za2,za3,za4,za5) \
- fprintf(stderr,zf,za1,za2,za3,za4,za5)
-#else
-extern void bz_internal_error ( int errcode );
-#define AssertH(cond,errcode) \
- { if (!(cond)) bz_internal_error ( errcode ); }
-#define AssertD(cond,msg) /* */
-#define VPrintf0(zf) /* */
-#define VPrintf1(zf,za1) /* */
-#define VPrintf2(zf,za1,za2) /* */
-#define VPrintf3(zf,za1,za2,za3) /* */
-#define VPrintf4(zf,za1,za2,za3,za4) /* */
-#define VPrintf5(zf,za1,za2,za3,za4,za5) /* */
-#endif
-
-
-#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
-#define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp))
-
-
-/*-- Header bytes. --*/
-
-#define BZ_HDR_B 0x42 /* 'B' */
-#define BZ_HDR_Z 0x5a /* 'Z' */
-#define BZ_HDR_h 0x68 /* 'h' */
-#define BZ_HDR_0 0x30 /* '0' */
-
-/*-- Constants for the back end. --*/
-
-#define BZ_MAX_ALPHA_SIZE 258
-#define BZ_MAX_CODE_LEN 23
-
-#define BZ_RUNA 0
-#define BZ_RUNB 1
-
-#define BZ_N_GROUPS 6
-#define BZ_G_SIZE 50
-#define BZ_N_ITERS 4
-
-#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
-
-
-/*-- Stuff for randomising repetitive blocks. --*/
-
-extern Int32 BZ2_rNums[512];
-
-#define BZ_RAND_DECLS \
- Int32 rNToGo; \
- Int32 rTPos \
-
-#define BZ_RAND_INIT_MASK \
- s->rNToGo = 0; \
- s->rTPos = 0 \
-
-#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0)
-
-#define BZ_RAND_UPD_MASK \
- if (s->rNToGo == 0) { \
- s->rNToGo = BZ2_rNums[s->rTPos]; \
- s->rTPos++; \
- if (s->rTPos == 512) s->rTPos = 0; \
- } \
- s->rNToGo--;
-
-
-/*-- Stuff for doing CRCs. --*/
-
-extern UInt32 BZ2_crc32Table[256];
-
-#define BZ_INITIALISE_CRC(crcVar) \
-{ \
- crcVar = 0xffffffffL; \
-}
-
-#define BZ_FINALISE_CRC(crcVar) \
-{ \
- crcVar = ~(crcVar); \
-}
-
-#define BZ_UPDATE_CRC(crcVar,cha) \
-{ \
- crcVar = (crcVar << 8) ^ \
- BZ2_crc32Table[(crcVar >> 24) ^ \
- ((UChar)cha)]; \
-}
-
-
-/*-- States and modes for compression. --*/
-
-#define BZ_M_IDLE 1
-#define BZ_M_RUNNING 2
-#define BZ_M_FLUSHING 3
-#define BZ_M_FINISHING 4
-
-#define BZ_S_OUTPUT 1
-#define BZ_S_INPUT 2
-
-#define BZ_N_RADIX 2
-#define BZ_N_QSORT 12
-#define BZ_N_SHELL 18
-#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
-
-
-/*-- Structure holding all the compression-side stuff. --*/
-
-typedef
- struct {
- /* pointer back to the struct bz_stream */
- bz_stream* strm;
-
- /* mode this stream is in, and whether inputting */
- /* or outputting data */
- Int32 mode;
- Int32 state;
-
- /* remembers avail_in when flush/finish requested */
- UInt32 avail_in_expect;
-
- /* for doing the block sorting */
- UInt32* arr1;
- UInt32* arr2;
- UInt32* ftab;
- Int32 origPtr;
-
- /* aliases for arr1 and arr2 */
- UInt32* ptr;
- UChar* block;
- UInt16* mtfv;
- UChar* zbits;
-
- /* for deciding when to use the fallback sorting algorithm */
- Int32 workFactor;
-
- /* run-length-encoding of the input */
- UInt32 state_in_ch;
- Int32 state_in_len;
- BZ_RAND_DECLS;
-
- /* input and output limits and current posns */
- Int32 nblock;
- Int32 nblockMAX;
- Int32 numZ;
- Int32 state_out_pos;
-
- /* map of bytes used in block */
- Int32 nInUse;
- Bool inUse[256];
- UChar unseqToSeq[256];
-
- /* the buffer for bit stream creation */
- UInt32 bsBuff;
- Int32 bsLive;
-
- /* block and combined CRCs */
- UInt32 blockCRC;
- UInt32 combinedCRC;
-
- /* misc administratium */
- Int32 verbosity;
- Int32 blockNo;
- Int32 blockSize100k;
-
- /* stuff for coding the MTF values */
- Int32 nMTF;
- Int32 mtfFreq [BZ_MAX_ALPHA_SIZE];
- UChar selector [BZ_MAX_SELECTORS];
- UChar selectorMtf[BZ_MAX_SELECTORS];
-
- UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- /* second dimension: only 3 needed; 4 makes index calculations faster */
- UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4];
-
- }
- EState;
-
-
-/*-- externs for compression. --*/
-
-extern void
-BZ2_blockSort ( EState* );
-
-extern void
-BZ2_compressBlock ( EState*, Bool );
-
-extern void
-BZ2_bsInitWrite ( EState* );
-
-extern void
-BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
-
-extern void
-BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
-
-
-/*-- states for decompression. --*/
-
-#define BZ_X_IDLE 1
-#define BZ_X_OUTPUT 2
-
-#define BZ_X_MAGIC_1 10
-#define BZ_X_MAGIC_2 11
-#define BZ_X_MAGIC_3 12
-#define BZ_X_MAGIC_4 13
-#define BZ_X_BLKHDR_1 14
-#define BZ_X_BLKHDR_2 15
-#define BZ_X_BLKHDR_3 16
-#define BZ_X_BLKHDR_4 17
-#define BZ_X_BLKHDR_5 18
-#define BZ_X_BLKHDR_6 19
-#define BZ_X_BCRC_1 20
-#define BZ_X_BCRC_2 21
-#define BZ_X_BCRC_3 22
-#define BZ_X_BCRC_4 23
-#define BZ_X_RANDBIT 24
-#define BZ_X_ORIGPTR_1 25
-#define BZ_X_ORIGPTR_2 26
-#define BZ_X_ORIGPTR_3 27
-#define BZ_X_MAPPING_1 28
-#define BZ_X_MAPPING_2 29
-#define BZ_X_SELECTOR_1 30
-#define BZ_X_SELECTOR_2 31
-#define BZ_X_SELECTOR_3 32
-#define BZ_X_CODING_1 33
-#define BZ_X_CODING_2 34
-#define BZ_X_CODING_3 35
-#define BZ_X_MTF_1 36
-#define BZ_X_MTF_2 37
-#define BZ_X_MTF_3 38
-#define BZ_X_MTF_4 39
-#define BZ_X_MTF_5 40
-#define BZ_X_MTF_6 41
-#define BZ_X_ENDHDR_2 42
-#define BZ_X_ENDHDR_3 43
-#define BZ_X_ENDHDR_4 44
-#define BZ_X_ENDHDR_5 45
-#define BZ_X_ENDHDR_6 46
-#define BZ_X_CCRC_1 47
-#define BZ_X_CCRC_2 48
-#define BZ_X_CCRC_3 49
-#define BZ_X_CCRC_4 50
-
-
-/*-- Constants for the fast MTF decoder. --*/
-
-#define MTFA_SIZE 4096
-#define MTFL_SIZE 16
-
-
-/*-- Structure holding all the decompression-side stuff. --*/
-
-typedef
- struct {
- /* pointer back to the struct bz_stream */
- bz_stream* strm;
-
- /* state indicator for this stream */
- Int32 state;
-
- /* for doing the final run-length decoding */
- UChar state_out_ch;
- Int32 state_out_len;
- Bool blockRandomised;
- BZ_RAND_DECLS;
-
- /* the buffer for bit stream reading */
- UInt32 bsBuff;
- Int32 bsLive;
-
- /* misc administratium */
- Int32 blockSize100k;
- Bool smallDecompress;
- Int32 currBlockNo;
- Int32 verbosity;
-
- /* for undoing the Burrows-Wheeler transform */
- Int32 origPtr;
- UInt32 tPos;
- Int32 k0;
- Int32 unzftab[256];
- Int32 nblock_used;
- Int32 cftab[257];
- Int32 cftabCopy[257];
-
- /* for undoing the Burrows-Wheeler transform (FAST) */
- UInt32 *tt;
-
- /* for undoing the Burrows-Wheeler transform (SMALL) */
- UInt16 *ll16;
- UChar *ll4;
-
- /* stored and calculated CRCs */
- UInt32 storedBlockCRC;
- UInt32 storedCombinedCRC;
- UInt32 calculatedBlockCRC;
- UInt32 calculatedCombinedCRC;
-
- /* map of bytes used in block */
- Int32 nInUse;
- Bool inUse[256];
- Bool inUse16[16];
- UChar seqToUnseq[256];
-
- /* for decoding the MTF values */
- UChar mtfa [MTFA_SIZE];
- Int32 mtfbase[256 / MTFL_SIZE];
- UChar selector [BZ_MAX_SELECTORS];
- UChar selectorMtf[BZ_MAX_SELECTORS];
- UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-
- Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 minLens[BZ_N_GROUPS];
-
- /* save area for scalars in the main decompress code */
- Int32 save_i;
- Int32 save_j;
- Int32 save_t;
- Int32 save_alphaSize;
- Int32 save_nGroups;
- Int32 save_nSelectors;
- Int32 save_EOB;
- Int32 save_groupNo;
- Int32 save_groupPos;
- Int32 save_nextSym;
- Int32 save_nblockMAX;
- Int32 save_nblock;
- Int32 save_es;
- Int32 save_N;
- Int32 save_curr;
- Int32 save_zt;
- Int32 save_zn;
- Int32 save_zvec;
- Int32 save_zj;
- Int32 save_gSel;
- Int32 save_gMinlen;
- Int32* save_gLimit;
- Int32* save_gBase;
- Int32* save_gPerm;
-
- }
- DState;
-
-
-/*-- Macros for decompression. --*/
-
-#define BZ_GET_FAST(cccc) \
- s->tPos = s->tt[s->tPos]; \
- cccc = (UChar)(s->tPos & 0xff); \
- s->tPos >>= 8;
-
-#define BZ_GET_FAST_C(cccc) \
- c_tPos = c_tt[c_tPos]; \
- cccc = (UChar)(c_tPos & 0xff); \
- c_tPos >>= 8;
-
-#define SET_LL4(i,n) \
- { if (((i) & 0x1) == 0) \
- s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \
- s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \
- }
-
-#define GET_LL4(i) \
- ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
-
-#define SET_LL(i,n) \
- { s->ll16[i] = (UInt16)(n & 0x0000ffff); \
- SET_LL4(i, n >> 16); \
- }
-
-#define GET_LL(i) \
- (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
-
-#define BZ_GET_SMALL(cccc) \
- cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
- s->tPos = GET_LL(s->tPos);
-
-
-/*-- externs for decompression. --*/
-
-extern Int32
-BZ2_indexIntoF ( Int32, Int32* );
-
-extern Int32
-BZ2_decompress ( DState* );
-
-extern void
-BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
- Int32, Int32, Int32 );
-
-
-#endif
-
-/*-------------------------------------------------------------*/
-/*--- end bzlib_private.h ---*/
-/*-------------------------------------------------------------*/
diff --git a/lib/string.c b/lib/string.c
index 374f326143..7e4bec2e99 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -1049,3 +1049,9 @@ char *strreplace(char *str, char old, char new)
return str;
}
EXPORT_SYMBOL(strreplace);
+
+bool isempty(const char *s)
+{
+ return !s || s[0] == '\0';
+}
+EXPORT_SYMBOL(isempty);
diff --git a/lib/zstd/zstd_opt.h b/lib/zstd/zstd_opt.h
deleted file mode 100644
index 55e1b4cba8..0000000000
--- a/lib/zstd/zstd_opt.h
+++ /dev/null
@@ -1,1014 +0,0 @@
-/**
- * Copyright (c) 2016-present, Przemyslaw Skibinski, Yann Collet, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of https://github.com/facebook/zstd.
- * An additional grant of patent rights can be found in the PATENTS file in the
- * same directory.
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License version 2 as published by the
- * Free Software Foundation. This program is dual-licensed; you may select
- * either version 2 of the GNU General Public License ("GPL") or BSD license
- * ("BSD").
- */
-
-/* Note : this file is intended to be included within zstd_compress.c */
-
-#ifndef ZSTD_OPT_H_91842398743
-#define ZSTD_OPT_H_91842398743
-
-#define ZSTD_LITFREQ_ADD 2
-#define ZSTD_FREQ_DIV 4
-#define ZSTD_MAX_PRICE (1 << 30)
-
-/*-*************************************
-* Price functions for optimal parser
-***************************************/
-FORCE_INLINE void ZSTD_setLog2Prices(seqStore_t *ssPtr)
-{
- ssPtr->log2matchLengthSum = ZSTD_highbit32(ssPtr->matchLengthSum + 1);
- ssPtr->log2litLengthSum = ZSTD_highbit32(ssPtr->litLengthSum + 1);
- ssPtr->log2litSum = ZSTD_highbit32(ssPtr->litSum + 1);
- ssPtr->log2offCodeSum = ZSTD_highbit32(ssPtr->offCodeSum + 1);
- ssPtr->factor = 1 + ((ssPtr->litSum >> 5) / ssPtr->litLengthSum) + ((ssPtr->litSum << 1) / (ssPtr->litSum + ssPtr->matchSum));
-}
-
-ZSTD_STATIC void ZSTD_rescaleFreqs(seqStore_t *ssPtr, const BYTE *src, size_t srcSize)
-{
- unsigned u;
-
- ssPtr->cachedLiterals = NULL;
- ssPtr->cachedPrice = ssPtr->cachedLitLength = 0;
- ssPtr->staticPrices = 0;
-
- if (ssPtr->litLengthSum == 0) {
- if (srcSize <= 1024)
- ssPtr->staticPrices = 1;
-
- for (u = 0; u <= MaxLit; u++)
- ssPtr->litFreq[u] = 0;
- for (u = 0; u < srcSize; u++)
- ssPtr->litFreq[src[u]]++;
-
- ssPtr->litSum = 0;
- ssPtr->litLengthSum = MaxLL + 1;
- ssPtr->matchLengthSum = MaxML + 1;
- ssPtr->offCodeSum = (MaxOff + 1);
- ssPtr->matchSum = (ZSTD_LITFREQ_ADD << Litbits);
-
- for (u = 0; u <= MaxLit; u++) {
- ssPtr->litFreq[u] = 1 + (ssPtr->litFreq[u] >> ZSTD_FREQ_DIV);
- ssPtr->litSum += ssPtr->litFreq[u];
- }
- for (u = 0; u <= MaxLL; u++)
- ssPtr->litLengthFreq[u] = 1;
- for (u = 0; u <= MaxML; u++)
- ssPtr->matchLengthFreq[u] = 1;
- for (u = 0; u <= MaxOff; u++)
- ssPtr->offCodeFreq[u] = 1;
- } else {
- ssPtr->matchLengthSum = 0;
- ssPtr->litLengthSum = 0;
- ssPtr->offCodeSum = 0;
- ssPtr->matchSum = 0;
- ssPtr->litSum = 0;
-
- for (u = 0; u <= MaxLit; u++) {
- ssPtr->litFreq[u] = 1 + (ssPtr->litFreq[u] >> (ZSTD_FREQ_DIV + 1));
- ssPtr->litSum += ssPtr->litFreq[u];
- }
- for (u = 0; u <= MaxLL; u++) {
- ssPtr->litLengthFreq[u] = 1 + (ssPtr->litLengthFreq[u] >> (ZSTD_FREQ_DIV + 1));
- ssPtr->litLengthSum += ssPtr->litLengthFreq[u];
- }
- for (u = 0; u <= MaxML; u++) {
- ssPtr->matchLengthFreq[u] = 1 + (ssPtr->matchLengthFreq[u] >> ZSTD_FREQ_DIV);
- ssPtr->matchLengthSum += ssPtr->matchLengthFreq[u];
- ssPtr->matchSum += ssPtr->matchLengthFreq[u] * (u + 3);
- }
- ssPtr->matchSum *= ZSTD_LITFREQ_ADD;
- for (u = 0; u <= MaxOff; u++) {
- ssPtr->offCodeFreq[u] = 1 + (ssPtr->offCodeFreq[u] >> ZSTD_FREQ_DIV);
- ssPtr->offCodeSum += ssPtr->offCodeFreq[u];
- }
- }
-
- ZSTD_setLog2Prices(ssPtr);
-}
-
-FORCE_INLINE U32 ZSTD_getLiteralPrice(seqStore_t *ssPtr, U32 litLength, const BYTE *literals)
-{
- U32 price, u;
-
- if (ssPtr->staticPrices)
- return ZSTD_highbit32((U32)litLength + 1) + (litLength * 6);
-
- if (litLength == 0)
- return ssPtr->log2litLengthSum - ZSTD_highbit32(ssPtr->litLengthFreq[0] + 1);
-
- /* literals */
- if (ssPtr->cachedLiterals == literals) {
- U32 const additional = litLength - ssPtr->cachedLitLength;
- const BYTE *literals2 = ssPtr->cachedLiterals + ssPtr->cachedLitLength;
- price = ssPtr->cachedPrice + additional * ssPtr->log2litSum;
- for (u = 0; u < additional; u++)
- price -= ZSTD_highbit32(ssPtr->litFreq[literals2[u]] + 1);
- ssPtr->cachedPrice = price;
- ssPtr->cachedLitLength = litLength;
- } else {
- price = litLength * ssPtr->log2litSum;
- for (u = 0; u < litLength; u++)
- price -= ZSTD_highbit32(ssPtr->litFreq[literals[u]] + 1);
-
- if (litLength >= 12) {
- ssPtr->cachedLiterals = literals;
- ssPtr->cachedPrice = price;
- ssPtr->cachedLitLength = litLength;
- }
- }
-
- /* literal Length */
- {
- const BYTE LL_deltaCode = 19;
- const BYTE llCode = (litLength > 63) ? (BYTE)ZSTD_highbit32(litLength) + LL_deltaCode : LL_Code[litLength];
- price += LL_bits[llCode] + ssPtr->log2litLengthSum - ZSTD_highbit32(ssPtr->litLengthFreq[llCode] + 1);
- }
-
- return price;
-}
-
-FORCE_INLINE U32 ZSTD_getPrice(seqStore_t *seqStorePtr, U32 litLength, const BYTE *literals, U32 offset, U32 matchLength, const int ultra)
-{
- /* offset */
- U32 price;
- BYTE const offCode = (BYTE)ZSTD_highbit32(offset + 1);
-
- if (seqStorePtr->staticPrices)
- return ZSTD_getLiteralPrice(seqStorePtr, litLength, literals) + ZSTD_highbit32((U32)matchLength + 1) + 16 + offCode;
-
- price = offCode + seqStorePtr->log2offCodeSum - ZSTD_highbit32(seqStorePtr->offCodeFreq[offCode] + 1);
- if (!ultra && offCode >= 20)
- price += (offCode - 19) * 2;
-
- /* match Length */
- {
- const BYTE ML_deltaCode = 36;
- const BYTE mlCode = (matchLength > 127) ? (BYTE)ZSTD_highbit32(matchLength) + ML_deltaCode : ML_Code[matchLength];
- price += ML_bits[mlCode] + seqStorePtr->log2matchLengthSum - ZSTD_highbit32(seqStorePtr->matchLengthFreq[mlCode] + 1);
- }
-
- return price + ZSTD_getLiteralPrice(seqStorePtr, litLength, literals) + seqStorePtr->factor;
-}
-
-ZSTD_STATIC void ZSTD_updatePrice(seqStore_t *seqStorePtr, U32 litLength, const BYTE *literals, U32 offset, U32 matchLength)
-{
- U32 u;
-
- /* literals */
- seqStorePtr->litSum += litLength * ZSTD_LITFREQ_ADD;
- for (u = 0; u < litLength; u++)
- seqStorePtr->litFreq[literals[u]] += ZSTD_LITFREQ_ADD;
-
- /* literal Length */
- {
- const BYTE LL_deltaCode = 19;
- const BYTE llCode = (litLength > 63) ? (BYTE)ZSTD_highbit32(litLength) + LL_deltaCode : LL_Code[litLength];
- seqStorePtr->litLengthFreq[llCode]++;
- seqStorePtr->litLengthSum++;
- }
-
- /* match offset */
- {
- BYTE const offCode = (BYTE)ZSTD_highbit32(offset + 1);
- seqStorePtr->offCodeSum++;
- seqStorePtr->offCodeFreq[offCode]++;
- }
-
- /* match Length */
- {
- const BYTE ML_deltaCode = 36;
- const BYTE mlCode = (matchLength > 127) ? (BYTE)ZSTD_highbit32(matchLength) + ML_deltaCode : ML_Code[matchLength];
- seqStorePtr->matchLengthFreq[mlCode]++;
- seqStorePtr->matchLengthSum++;
- }
-
- ZSTD_setLog2Prices(seqStorePtr);
-}
-
-#define SET_PRICE(pos, mlen_, offset_, litlen_, price_) \
- { \
- while (last_pos < pos) { \
- opt[last_pos + 1].price = ZSTD_MAX_PRICE; \
- last_pos++; \
- } \
- opt[pos].mlen = mlen_; \
- opt[pos].off = offset_; \
- opt[pos].litlen = litlen_; \
- opt[pos].price = price_; \
- }
-
-/* Update hashTable3 up to ip (excluded)
- Assumption : always within prefix (i.e. not within extDict) */
-FORCE_INLINE
-U32 ZSTD_insertAndFindFirstIndexHash3(ZSTD_CCtx *zc, const BYTE *ip)
-{
- U32 *const hashTable3 = zc->hashTable3;
- U32 const hashLog3 = zc->hashLog3;
- const BYTE *const base = zc->base;
- U32 idx = zc->nextToUpdate3;
- const U32 target = zc->nextToUpdate3 = (U32)(ip - base);
- const size_t hash3 = ZSTD_hash3Ptr(ip, hashLog3);
-
- while (idx < target) {
- hashTable3[ZSTD_hash3Ptr(base + idx, hashLog3)] = idx;
- idx++;
- }
-
- return hashTable3[hash3];
-}
-
-/*-*************************************
-* Binary Tree search
-***************************************/
-static U32 ZSTD_insertBtAndGetAllMatches(ZSTD_CCtx *zc, const BYTE *const ip, const BYTE *const iLimit, U32 nbCompares, const U32 mls, U32 extDict,
- ZSTD_match_t *matches, const U32 minMatchLen)
-{
- const BYTE *const base = zc->base;
- const U32 curr = (U32)(ip - base);
- const U32 hashLog = zc->params.cParams.hashLog;
- const size_t h = ZSTD_hashPtr(ip, hashLog, mls);
- U32 *const hashTable = zc->hashTable;
- U32 matchIndex = hashTable[h];
- U32 *const bt = zc->chainTable;
- const U32 btLog = zc->params.cParams.chainLog - 1;
- const U32 btMask = (1U << btLog) - 1;
- size_t commonLengthSmaller = 0, commonLengthLarger = 0;
- const BYTE *const dictBase = zc->dictBase;
- const U32 dictLimit = zc->dictLimit;
- const BYTE *const dictEnd = dictBase + dictLimit;
- const BYTE *const prefixStart = base + dictLimit;
- const U32 btLow = btMask >= curr ? 0 : curr - btMask;
- const U32 windowLow = zc->lowLimit;
- U32 *smallerPtr = bt + 2 * (curr & btMask);
- U32 *largerPtr = bt + 2 * (curr & btMask) + 1;
- U32 matchEndIdx = curr + 8;
- U32 dummy32; /* to be nullified at the end */
- U32 mnum = 0;
-
- const U32 minMatch = (mls == 3) ? 3 : 4;
- size_t bestLength = minMatchLen - 1;
-
- if (minMatch == 3) { /* HC3 match finder */
- U32 const matchIndex3 = ZSTD_insertAndFindFirstIndexHash3(zc, ip);
- if (matchIndex3 > windowLow && (curr - matchIndex3 < (1 << 18))) {
- const BYTE *match;
- size_t currMl = 0;
- if ((!extDict) || matchIndex3 >= dictLimit) {
- match = base + matchIndex3;
- if (match[bestLength] == ip[bestLength])
- currMl = ZSTD_count(ip, match, iLimit);
- } else {
- match = dictBase + matchIndex3;
- if (ZSTD_readMINMATCH(match, MINMATCH) ==
- ZSTD_readMINMATCH(ip, MINMATCH)) /* assumption : matchIndex3 <= dictLimit-4 (by table construction) */
- currMl = ZSTD_count_2segments(ip + MINMATCH, match + MINMATCH, iLimit, dictEnd, prefixStart) + MINMATCH;
- }
-
- /* save best solution */
- if (currMl > bestLength) {
- bestLength = currMl;
- matches[mnum].off = ZSTD_REP_MOVE_OPT + curr - matchIndex3;
- matches[mnum].len = (U32)currMl;
- mnum++;
- if (currMl > ZSTD_OPT_NUM)
- goto update;
- if (ip + currMl == iLimit)
- goto update; /* best possible, and avoid read overflow*/
- }
- }
- }
-
- hashTable[h] = curr; /* Update Hash Table */
-
- while (nbCompares-- && (matchIndex > windowLow)) {
- U32 *nextPtr = bt + 2 * (matchIndex & btMask);
- size_t matchLength = MIN(commonLengthSmaller, commonLengthLarger); /* guaranteed minimum nb of common bytes */
- const BYTE *match;
-
- if ((!extDict) || (matchIndex + matchLength >= dictLimit)) {
- match = base + matchIndex;
- if (match[matchLength] == ip[matchLength]) {
- matchLength += ZSTD_count(ip + matchLength + 1, match + matchLength + 1, iLimit) + 1;
- }
- } else {
- match = dictBase + matchIndex;
- matchLength += ZSTD_count_2segments(ip + matchLength, match + matchLength, iLimit, dictEnd, prefixStart);
- if (matchIndex + matchLength >= dictLimit)
- match = base + matchIndex; /* to prepare for next usage of match[matchLength] */
- }
-
- if (matchLength > bestLength) {
- if (matchLength > matchEndIdx - matchIndex)
- matchEndIdx = matchIndex + (U32)matchLength;
- bestLength = matchLength;
- matches[mnum].off = ZSTD_REP_MOVE_OPT + curr - matchIndex;
- matches[mnum].len = (U32)matchLength;
- mnum++;
- if (matchLength > ZSTD_OPT_NUM)
- break;
- if (ip + matchLength == iLimit) /* equal : no way to know if inf or sup */
- break; /* drop, to guarantee consistency (miss a little bit of compression) */
- }
-
- if (match[matchLength] < ip[matchLength]) {
- /* match is smaller than curr */
- *smallerPtr = matchIndex; /* update smaller idx */
- commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
- if (matchIndex <= btLow) {
- smallerPtr = &dummy32;
- break;
- } /* beyond tree size, stop the search */
- smallerPtr = nextPtr + 1; /* new "smaller" => larger of match */
- matchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to curr) */
- } else {
- /* match is larger than curr */
- *largerPtr = matchIndex;
- commonLengthLarger = matchLength;
- if (matchIndex <= btLow) {
- largerPtr = &dummy32;
- break;
- } /* beyond tree size, stop the search */
- largerPtr = nextPtr;
- matchIndex = nextPtr[0];
- }
- }
-
- *smallerPtr = *largerPtr = 0;
-
-update:
- zc->nextToUpdate = (matchEndIdx > curr + 8) ? matchEndIdx - 8 : curr + 1;
- return mnum;
-}
-
-/** Tree updater, providing best match */
-static U32 ZSTD_BtGetAllMatches(ZSTD_CCtx *zc, const BYTE *const ip, const BYTE *const iLimit, const U32 maxNbAttempts, const U32 mls, ZSTD_match_t *matches,
- const U32 minMatchLen)
-{
- if (ip < zc->base + zc->nextToUpdate)
- return 0; /* skipped area */
- ZSTD_updateTree(zc, ip, iLimit, maxNbAttempts, mls);
- return ZSTD_insertBtAndGetAllMatches(zc, ip, iLimit, maxNbAttempts, mls, 0, matches, minMatchLen);
-}
-
-static U32 ZSTD_BtGetAllMatches_selectMLS(ZSTD_CCtx *zc, /* Index table will be updated */
- const BYTE *ip, const BYTE *const iHighLimit, const U32 maxNbAttempts, const U32 matchLengthSearch,
- ZSTD_match_t *matches, const U32 minMatchLen)
-{
- switch (matchLengthSearch) {
- case 3: return ZSTD_BtGetAllMatches(zc, ip, iHighLimit, maxNbAttempts, 3, matches, minMatchLen);
- default:
- case 4: return ZSTD_BtGetAllMatches(zc, ip, iHighLimit, maxNbAttempts, 4, matches, minMatchLen);
- case 5: return ZSTD_BtGetAllMatches(zc, ip, iHighLimit, maxNbAttempts, 5, matches, minMatchLen);
- case 7:
- case 6: return ZSTD_BtGetAllMatches(zc, ip, iHighLimit, maxNbAttempts, 6, matches, minMatchLen);
- }
-}
-
-/** Tree updater, providing best match */
-static U32 ZSTD_BtGetAllMatches_extDict(ZSTD_CCtx *zc, const BYTE *const ip, const BYTE *const iLimit, const U32 maxNbAttempts, const U32 mls,
- ZSTD_match_t *matches, const U32 minMatchLen)
-{
- if (ip < zc->base + zc->nextToUpdate)
- return 0; /* skipped area */
- ZSTD_updateTree_extDict(zc, ip, iLimit, maxNbAttempts, mls);
- return ZSTD_insertBtAndGetAllMatches(zc, ip, iLimit, maxNbAttempts, mls, 1, matches, minMatchLen);
-}
-
-static U32 ZSTD_BtGetAllMatches_selectMLS_extDict(ZSTD_CCtx *zc, /* Index table will be updated */
- const BYTE *ip, const BYTE *const iHighLimit, const U32 maxNbAttempts, const U32 matchLengthSearch,
- ZSTD_match_t *matches, const U32 minMatchLen)
-{
- switch (matchLengthSearch) {
- case 3: return ZSTD_BtGetAllMatches_extDict(zc, ip, iHighLimit, maxNbAttempts, 3, matches, minMatchLen);
- default:
- case 4: return ZSTD_BtGetAllMatches_extDict(zc, ip, iHighLimit, maxNbAttempts, 4, matches, minMatchLen);
- case 5: return ZSTD_BtGetAllMatches_extDict(zc, ip, iHighLimit, maxNbAttempts, 5, matches, minMatchLen);
- case 7:
- case 6: return ZSTD_BtGetAllMatches_extDict(zc, ip, iHighLimit, maxNbAttempts, 6, matches, minMatchLen);
- }
-}
-
-/*-*******************************
-* Optimal parser
-*********************************/
-FORCE_INLINE
-void ZSTD_compressBlock_opt_generic(ZSTD_CCtx *ctx, const void *src, size_t srcSize, const int ultra)
-{
- seqStore_t *seqStorePtr = &(ctx->seqStore);
- const BYTE *const istart = (const BYTE *)src;
- const BYTE *ip = istart;
- const BYTE *anchor = istart;
- const BYTE *const iend = istart + srcSize;
- const BYTE *const ilimit = iend - 8;
- const BYTE *const base = ctx->base;
- const BYTE *const prefixStart = base + ctx->dictLimit;
-
- const U32 maxSearches = 1U << ctx->params.cParams.searchLog;
- const U32 sufficient_len = ctx->params.cParams.targetLength;
- const U32 mls = ctx->params.cParams.searchLength;
- const U32 minMatch = (ctx->params.cParams.searchLength == 3) ? 3 : 4;
-
- ZSTD_optimal_t *opt = seqStorePtr->priceTable;
- ZSTD_match_t *matches = seqStorePtr->matchTable;
- const BYTE *inr;
- U32 offset, rep[ZSTD_REP_NUM];
-
- /* init */
- ctx->nextToUpdate3 = ctx->nextToUpdate;
- ZSTD_rescaleFreqs(seqStorePtr, (const BYTE *)src, srcSize);
- ip += (ip == prefixStart);
- {
- U32 i;
- for (i = 0; i < ZSTD_REP_NUM; i++)
- rep[i] = ctx->rep[i];
- }
-
- /* Match Loop */
- while (ip < ilimit) {
- U32 cur, match_num, last_pos, litlen, price;
- U32 u, mlen, best_mlen, best_off, litLength;
- memset(opt, 0, sizeof(ZSTD_optimal_t));
- last_pos = 0;
- litlen = (U32)(ip - anchor);
-
- /* check repCode */
- {
- U32 i, last_i = ZSTD_REP_CHECK + (ip == anchor);
- for (i = (ip == anchor); i < last_i; i++) {
- const S32 repCur = (i == ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : rep[i];
- if ((repCur > 0) && (repCur < (S32)(ip - prefixStart)) &&
- (ZSTD_readMINMATCH(ip, minMatch) == ZSTD_readMINMATCH(ip - repCur, minMatch))) {
- mlen = (U32)ZSTD_count(ip + minMatch, ip + minMatch - repCur, iend) + minMatch;
- if (mlen > sufficient_len || mlen >= ZSTD_OPT_NUM) {
- best_mlen = mlen;
- best_off = i;
- cur = 0;
- last_pos = 1;
- goto _storeSequence;
- }
- best_off = i - (ip == anchor);
- do {
- price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra);
- if (mlen > last_pos || price < opt[mlen].price)
- SET_PRICE(mlen, mlen, i, litlen, price); /* note : macro modifies last_pos */
- mlen--;
- } while (mlen >= minMatch);
- }
- }
- }
-
- match_num = ZSTD_BtGetAllMatches_selectMLS(ctx, ip, iend, maxSearches, mls, matches, minMatch);
-
- if (!last_pos && !match_num) {
- ip++;
- continue;
- }
-
- if (match_num && (matches[match_num - 1].len > sufficient_len || matches[match_num - 1].len >= ZSTD_OPT_NUM)) {
- best_mlen = matches[match_num - 1].len;
- best_off = matches[match_num - 1].off;
- cur = 0;
- last_pos = 1;
- goto _storeSequence;
- }
-
- /* set prices using matches at position = 0 */
- best_mlen = (last_pos) ? last_pos : minMatch;
- for (u = 0; u < match_num; u++) {
- mlen = (u > 0) ? matches[u - 1].len + 1 : best_mlen;
- best_mlen = matches[u].len;
- while (mlen <= best_mlen) {
- price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off - 1, mlen - MINMATCH, ultra);
- if (mlen > last_pos || price < opt[mlen].price)
- SET_PRICE(mlen, mlen, matches[u].off, litlen, price); /* note : macro modifies last_pos */
- mlen++;
- }
- }
-
- if (last_pos < minMatch) {
- ip++;
- continue;
- }
-
- /* initialize opt[0] */
- {
- U32 i;
- for (i = 0; i < ZSTD_REP_NUM; i++)
- opt[0].rep[i] = rep[i];
- }
- opt[0].mlen = 1;
- opt[0].litlen = litlen;
-
- /* check further positions */
- for (cur = 1; cur <= last_pos; cur++) {
- inr = ip + cur;
-
- if (opt[cur - 1].mlen == 1) {
- litlen = opt[cur - 1].litlen + 1;
- if (cur > litlen) {
- price = opt[cur - litlen].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr - litlen);
- } else
- price = ZSTD_getLiteralPrice(seqStorePtr, litlen, anchor);
- } else {
- litlen = 1;
- price = opt[cur - 1].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr - 1);
- }
-
- if (cur > last_pos || price <= opt[cur].price)
- SET_PRICE(cur, 1, 0, litlen, price);
-
- if (cur == last_pos)
- break;
-
- if (inr > ilimit) /* last match must start at a minimum distance of 8 from oend */
- continue;
-
- mlen = opt[cur].mlen;
- if (opt[cur].off > ZSTD_REP_MOVE_OPT) {
- opt[cur].rep[2] = opt[cur - mlen].rep[1];
- opt[cur].rep[1] = opt[cur - mlen].rep[0];
- opt[cur].rep[0] = opt[cur].off - ZSTD_REP_MOVE_OPT;
- } else {
- opt[cur].rep[2] = (opt[cur].off > 1) ? opt[cur - mlen].rep[1] : opt[cur - mlen].rep[2];
- opt[cur].rep[1] = (opt[cur].off > 0) ? opt[cur - mlen].rep[0] : opt[cur - mlen].rep[1];
- opt[cur].rep[0] =
- ((opt[cur].off == ZSTD_REP_MOVE_OPT) && (mlen != 1)) ? (opt[cur - mlen].rep[0] - 1) : (opt[cur - mlen].rep[opt[cur].off]);
- }
-
- best_mlen = minMatch;
- {
- U32 i, last_i = ZSTD_REP_CHECK + (mlen != 1);
- for (i = (opt[cur].mlen != 1); i < last_i; i++) { /* check rep */
- const S32 repCur = (i == ZSTD_REP_MOVE_OPT) ? (opt[cur].rep[0] - 1) : opt[cur].rep[i];
- if ((repCur > 0) && (repCur < (S32)(inr - prefixStart)) &&
- (ZSTD_readMINMATCH(inr, minMatch) == ZSTD_readMINMATCH(inr - repCur, minMatch))) {
- mlen = (U32)ZSTD_count(inr + minMatch, inr + minMatch - repCur, iend) + minMatch;
-
- if (mlen > sufficient_len || cur + mlen >= ZSTD_OPT_NUM) {
- best_mlen = mlen;
- best_off = i;
- last_pos = cur + 1;
- goto _storeSequence;
- }
-
- best_off = i - (opt[cur].mlen != 1);
- if (mlen > best_mlen)
- best_mlen = mlen;
-
- do {
- if (opt[cur].mlen == 1) {
- litlen = opt[cur].litlen;
- if (cur > litlen) {
- price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, inr - litlen,
- best_off, mlen - MINMATCH, ultra);
- } else
- price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra);
- } else {
- litlen = 0;
- price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, best_off, mlen - MINMATCH, ultra);
- }
-
- if (cur + mlen > last_pos || price <= opt[cur + mlen].price)
- SET_PRICE(cur + mlen, mlen, i, litlen, price);
- mlen--;
- } while (mlen >= minMatch);
- }
- }
- }
-
- match_num = ZSTD_BtGetAllMatches_selectMLS(ctx, inr, iend, maxSearches, mls, matches, best_mlen);
-
- if (match_num > 0 && (matches[match_num - 1].len > sufficient_len || cur + matches[match_num - 1].len >= ZSTD_OPT_NUM)) {
- best_mlen = matches[match_num - 1].len;
- best_off = matches[match_num - 1].off;
- last_pos = cur + 1;
- goto _storeSequence;
- }
-
- /* set prices using matches at position = cur */
- for (u = 0; u < match_num; u++) {
- mlen = (u > 0) ? matches[u - 1].len + 1 : best_mlen;
- best_mlen = matches[u].len;
-
- while (mlen <= best_mlen) {
- if (opt[cur].mlen == 1) {
- litlen = opt[cur].litlen;
- if (cur > litlen)
- price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, ip + cur - litlen,
- matches[u].off - 1, mlen - MINMATCH, ultra);
- else
- price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off - 1, mlen - MINMATCH, ultra);
- } else {
- litlen = 0;
- price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, matches[u].off - 1, mlen - MINMATCH, ultra);
- }
-
- if (cur + mlen > last_pos || (price < opt[cur + mlen].price))
- SET_PRICE(cur + mlen, mlen, matches[u].off, litlen, price);
-
- mlen++;
- }
- }
- }
-
- best_mlen = opt[last_pos].mlen;
- best_off = opt[last_pos].off;
- cur = last_pos - best_mlen;
-
- /* store sequence */
-_storeSequence: /* cur, last_pos, best_mlen, best_off have to be set */
- opt[0].mlen = 1;
-
- while (1) {
- mlen = opt[cur].mlen;
- offset = opt[cur].off;
- opt[cur].mlen = best_mlen;
- opt[cur].off = best_off;
- best_mlen = mlen;
- best_off = offset;
- if (mlen > cur)
- break;
- cur -= mlen;
- }
-
- for (u = 0; u <= last_pos;) {
- u += opt[u].mlen;
- }
-
- for (cur = 0; cur < last_pos;) {
- mlen = opt[cur].mlen;
- if (mlen == 1) {
- ip++;
- cur++;
- continue;
- }
- offset = opt[cur].off;
- cur += mlen;
- litLength = (U32)(ip - anchor);
-
- if (offset > ZSTD_REP_MOVE_OPT) {
- rep[2] = rep[1];
- rep[1] = rep[0];
- rep[0] = offset - ZSTD_REP_MOVE_OPT;
- offset--;
- } else {
- if (offset != 0) {
- best_off = (offset == ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : (rep[offset]);
- if (offset != 1)
- rep[2] = rep[1];
- rep[1] = rep[0];
- rep[0] = best_off;
- }
- if (litLength == 0)
- offset--;
- }
-
- ZSTD_updatePrice(seqStorePtr, litLength, anchor, offset, mlen - MINMATCH);
- ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset, mlen - MINMATCH);
- anchor = ip = ip + mlen;
- }
- } /* for (cur=0; cur < last_pos; ) */
-
- /* Save reps for next block */
- {
- int i;
- for (i = 0; i < ZSTD_REP_NUM; i++)
- ctx->repToConfirm[i] = rep[i];
- }
-
- /* Last Literals */
- {
- size_t const lastLLSize = iend - anchor;
- memcpy(seqStorePtr->lit, anchor, lastLLSize);
- seqStorePtr->lit += lastLLSize;
- }
-}
-
-FORCE_INLINE
-void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx *ctx, const void *src, size_t srcSize, const int ultra)
-{
- seqStore_t *seqStorePtr = &(ctx->seqStore);
- const BYTE *const istart = (const BYTE *)src;
- const BYTE *ip = istart;
- const BYTE *anchor = istart;
- const BYTE *const iend = istart + srcSize;
- const BYTE *const ilimit = iend - 8;
- const BYTE *const base = ctx->base;
- const U32 lowestIndex = ctx->lowLimit;
- const U32 dictLimit = ctx->dictLimit;
- const BYTE *const prefixStart = base + dictLimit;
- const BYTE *const dictBase = ctx->dictBase;
- const BYTE *const dictEnd = dictBase + dictLimit;
-
- const U32 maxSearches = 1U << ctx->params.cParams.searchLog;
- const U32 sufficient_len = ctx->params.cParams.targetLength;
- const U32 mls = ctx->params.cParams.searchLength;
- const U32 minMatch = (ctx->params.cParams.searchLength == 3) ? 3 : 4;
-
- ZSTD_optimal_t *opt = seqStorePtr->priceTable;
- ZSTD_match_t *matches = seqStorePtr->matchTable;
- const BYTE *inr;
-
- /* init */
- U32 offset, rep[ZSTD_REP_NUM];
- {
- U32 i;
- for (i = 0; i < ZSTD_REP_NUM; i++)
- rep[i] = ctx->rep[i];
- }
-
- ctx->nextToUpdate3 = ctx->nextToUpdate;
- ZSTD_rescaleFreqs(seqStorePtr, (const BYTE *)src, srcSize);
- ip += (ip == prefixStart);
-
- /* Match Loop */
- while (ip < ilimit) {
- U32 cur, match_num, last_pos, litlen, price;
- U32 u, mlen, best_mlen, best_off, litLength;
- U32 curr = (U32)(ip - base);
- memset(opt, 0, sizeof(ZSTD_optimal_t));
- last_pos = 0;
- opt[0].litlen = (U32)(ip - anchor);
-
- /* check repCode */
- {
- U32 i, last_i = ZSTD_REP_CHECK + (ip == anchor);
- for (i = (ip == anchor); i < last_i; i++) {
- const S32 repCur = (i == ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : rep[i];
- const U32 repIndex = (U32)(curr - repCur);
- const BYTE *const repBase = repIndex < dictLimit ? dictBase : base;
- const BYTE *const repMatch = repBase + repIndex;
- if ((repCur > 0 && repCur <= (S32)curr) &&
- (((U32)((dictLimit - 1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
- && (ZSTD_readMINMATCH(ip, minMatch) == ZSTD_readMINMATCH(repMatch, minMatch))) {
- /* repcode detected we should take it */
- const BYTE *const repEnd = repIndex < dictLimit ? dictEnd : iend;
- mlen = (U32)ZSTD_count_2segments(ip + minMatch, repMatch + minMatch, iend, repEnd, prefixStart) + minMatch;
-
- if (mlen > sufficient_len || mlen >= ZSTD_OPT_NUM) {
- best_mlen = mlen;
- best_off = i;
- cur = 0;
- last_pos = 1;
- goto _storeSequence;
- }
-
- best_off = i - (ip == anchor);
- litlen = opt[0].litlen;
- do {
- price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra);
- if (mlen > last_pos || price < opt[mlen].price)
- SET_PRICE(mlen, mlen, i, litlen, price); /* note : macro modifies last_pos */
- mlen--;
- } while (mlen >= minMatch);
- }
- }
- }
-
- match_num = ZSTD_BtGetAllMatches_selectMLS_extDict(ctx, ip, iend, maxSearches, mls, matches, minMatch); /* first search (depth 0) */
-
- if (!last_pos && !match_num) {
- ip++;
- continue;
- }
-
- {
- U32 i;
- for (i = 0; i < ZSTD_REP_NUM; i++)
- opt[0].rep[i] = rep[i];
- }
- opt[0].mlen = 1;
-
- if (match_num && (matches[match_num - 1].len > sufficient_len || matches[match_num - 1].len >= ZSTD_OPT_NUM)) {
- best_mlen = matches[match_num - 1].len;
- best_off = matches[match_num - 1].off;
- cur = 0;
- last_pos = 1;
- goto _storeSequence;
- }
-
- best_mlen = (last_pos) ? last_pos : minMatch;
-
- /* set prices using matches at position = 0 */
- for (u = 0; u < match_num; u++) {
- mlen = (u > 0) ? matches[u - 1].len + 1 : best_mlen;
- best_mlen = matches[u].len;
- litlen = opt[0].litlen;
- while (mlen <= best_mlen) {
- price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off - 1, mlen - MINMATCH, ultra);
- if (mlen > last_pos || price < opt[mlen].price)
- SET_PRICE(mlen, mlen, matches[u].off, litlen, price);
- mlen++;
- }
- }
-
- if (last_pos < minMatch) {
- ip++;
- continue;
- }
-
- /* check further positions */
- for (cur = 1; cur <= last_pos; cur++) {
- inr = ip + cur;
-
- if (opt[cur - 1].mlen == 1) {
- litlen = opt[cur - 1].litlen + 1;
- if (cur > litlen) {
- price = opt[cur - litlen].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr - litlen);
- } else
- price = ZSTD_getLiteralPrice(seqStorePtr, litlen, anchor);
- } else {
- litlen = 1;
- price = opt[cur - 1].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr - 1);
- }
-
- if (cur > last_pos || price <= opt[cur].price)
- SET_PRICE(cur, 1, 0, litlen, price);
-
- if (cur == last_pos)
- break;
-
- if (inr > ilimit) /* last match must start at a minimum distance of 8 from oend */
- continue;
-
- mlen = opt[cur].mlen;
- if (opt[cur].off > ZSTD_REP_MOVE_OPT) {
- opt[cur].rep[2] = opt[cur - mlen].rep[1];
- opt[cur].rep[1] = opt[cur - mlen].rep[0];
- opt[cur].rep[0] = opt[cur].off - ZSTD_REP_MOVE_OPT;
- } else {
- opt[cur].rep[2] = (opt[cur].off > 1) ? opt[cur - mlen].rep[1] : opt[cur - mlen].rep[2];
- opt[cur].rep[1] = (opt[cur].off > 0) ? opt[cur - mlen].rep[0] : opt[cur - mlen].rep[1];
- opt[cur].rep[0] =
- ((opt[cur].off == ZSTD_REP_MOVE_OPT) && (mlen != 1)) ? (opt[cur - mlen].rep[0] - 1) : (opt[cur - mlen].rep[opt[cur].off]);
- }
-
- best_mlen = minMatch;
- {
- U32 i, last_i = ZSTD_REP_CHECK + (mlen != 1);
- for (i = (mlen != 1); i < last_i; i++) {
- const S32 repCur = (i == ZSTD_REP_MOVE_OPT) ? (opt[cur].rep[0] - 1) : opt[cur].rep[i];
- const U32 repIndex = (U32)(curr + cur - repCur);
- const BYTE *const repBase = repIndex < dictLimit ? dictBase : base;
- const BYTE *const repMatch = repBase + repIndex;
- if ((repCur > 0 && repCur <= (S32)(curr + cur)) &&
- (((U32)((dictLimit - 1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
- && (ZSTD_readMINMATCH(inr, minMatch) == ZSTD_readMINMATCH(repMatch, minMatch))) {
- /* repcode detected */
- const BYTE *const repEnd = repIndex < dictLimit ? dictEnd : iend;
- mlen = (U32)ZSTD_count_2segments(inr + minMatch, repMatch + minMatch, iend, repEnd, prefixStart) + minMatch;
-
- if (mlen > sufficient_len || cur + mlen >= ZSTD_OPT_NUM) {
- best_mlen = mlen;
- best_off = i;
- last_pos = cur + 1;
- goto _storeSequence;
- }
-
- best_off = i - (opt[cur].mlen != 1);
- if (mlen > best_mlen)
- best_mlen = mlen;
-
- do {
- if (opt[cur].mlen == 1) {
- litlen = opt[cur].litlen;
- if (cur > litlen) {
- price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, inr - litlen,
- best_off, mlen - MINMATCH, ultra);
- } else
- price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra);
- } else {
- litlen = 0;
- price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, best_off, mlen - MINMATCH, ultra);
- }
-
- if (cur + mlen > last_pos || price <= opt[cur + mlen].price)
- SET_PRICE(cur + mlen, mlen, i, litlen, price);
- mlen--;
- } while (mlen >= minMatch);
- }
- }
- }
-
- match_num = ZSTD_BtGetAllMatches_selectMLS_extDict(ctx, inr, iend, maxSearches, mls, matches, minMatch);
-
- if (match_num > 0 && (matches[match_num - 1].len > sufficient_len || cur + matches[match_num - 1].len >= ZSTD_OPT_NUM)) {
- best_mlen = matches[match_num - 1].len;
- best_off = matches[match_num - 1].off;
- last_pos = cur + 1;
- goto _storeSequence;
- }
-
- /* set prices using matches at position = cur */
- for (u = 0; u < match_num; u++) {
- mlen = (u > 0) ? matches[u - 1].len + 1 : best_mlen;
- best_mlen = matches[u].len;
-
- while (mlen <= best_mlen) {
- if (opt[cur].mlen == 1) {
- litlen = opt[cur].litlen;
- if (cur > litlen)
- price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, ip + cur - litlen,
- matches[u].off - 1, mlen - MINMATCH, ultra);
- else
- price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off - 1, mlen - MINMATCH, ultra);
- } else {
- litlen = 0;
- price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, matches[u].off - 1, mlen - MINMATCH, ultra);
- }
-
- if (cur + mlen > last_pos || (price < opt[cur + mlen].price))
- SET_PRICE(cur + mlen, mlen, matches[u].off, litlen, price);
-
- mlen++;
- }
- }
- } /* for (cur = 1; cur <= last_pos; cur++) */
-
- best_mlen = opt[last_pos].mlen;
- best_off = opt[last_pos].off;
- cur = last_pos - best_mlen;
-
- /* store sequence */
-_storeSequence: /* cur, last_pos, best_mlen, best_off have to be set */
- opt[0].mlen = 1;
-
- while (1) {
- mlen = opt[cur].mlen;
- offset = opt[cur].off;
- opt[cur].mlen = best_mlen;
- opt[cur].off = best_off;
- best_mlen = mlen;
- best_off = offset;
- if (mlen > cur)
- break;
- cur -= mlen;
- }
-
- for (u = 0; u <= last_pos;) {
- u += opt[u].mlen;
- }
-
- for (cur = 0; cur < last_pos;) {
- mlen = opt[cur].mlen;
- if (mlen == 1) {
- ip++;
- cur++;
- continue;
- }
- offset = opt[cur].off;
- cur += mlen;
- litLength = (U32)(ip - anchor);
-
- if (offset > ZSTD_REP_MOVE_OPT) {
- rep[2] = rep[1];
- rep[1] = rep[0];
- rep[0] = offset - ZSTD_REP_MOVE_OPT;
- offset--;
- } else {
- if (offset != 0) {
- best_off = (offset == ZSTD_REP_MOVE_OPT) ? (rep[0] - 1) : (rep[offset]);
- if (offset != 1)
- rep[2] = rep[1];
- rep[1] = rep[0];
- rep[0] = best_off;
- }
-
- if (litLength == 0)
- offset--;
- }
-
- ZSTD_updatePrice(seqStorePtr, litLength, anchor, offset, mlen - MINMATCH);
- ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset, mlen - MINMATCH);
- anchor = ip = ip + mlen;
- }
- } /* for (cur=0; cur < last_pos; ) */
-
- /* Save reps for next block */
- {
- int i;
- for (i = 0; i < ZSTD_REP_NUM; i++)
- ctx->repToConfirm[i] = rep[i];
- }
-
- /* Last Literals */
- {
- size_t lastLLSize = iend - anchor;
- memcpy(seqStorePtr->lit, anchor, lastLLSize);
- seqStorePtr->lit += lastLLSize;
- }
-}
-
-#endif /* ZSTD_OPT_H_91842398743 */
diff --git a/net/nfs.h b/net/nfs.h
deleted file mode 100644
index e9ac5f299a..0000000000
--- a/net/nfs.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2004 Masami Komiya <mkomiya@sonare.it> */
-
-#ifndef __NFS_H__
-#define __NFS_H__
-
-#define SUNRPC_PORT 111
-
-#define PROG_PORTMAP 100000
-#define PROG_NFS 100003
-#define PROG_MOUNT 100005
-
-#define MSG_CALL 0
-#define MSG_REPLY 1
-
-#define PORTMAP_GETPORT 3
-
-#define MOUNT_ADDENTRY 1
-#define MOUNT_UMOUNTALL 4
-
-#define NFS_LOOKUP 4
-#define NFS_READLINK 5
-#define NFS_READ 6
-
-#define NFS_FHSIZE 32
-
-#define NFSERR_PERM 1
-#define NFSERR_NOENT 2
-#define NFSERR_ACCES 13
-#define NFSERR_ISDIR 21
-#define NFSERR_INVAL 22
-
-/* Block size used for NFS read accesses. A RPC reply packet (including all
- * headers) must fit within a single Ethernet frame to avoid fragmentation.
- * Chosen to be a power of two, as most NFS servers are optimized for this. */
-#define NFS_READ_SIZE 1024
-
-#define NFS_MAXLINKDEPTH 16
-
-struct rpc_t {
- union {
- uint8_t data[2048];
- struct {
- uint32_t id;
- uint32_t type;
- uint32_t rpcvers;
- uint32_t prog;
- uint32_t vers;
- uint32_t proc;
- uint32_t data[1];
- } call;
- struct {
- uint32_t id;
- uint32_t type;
- uint32_t rstatus;
- uint32_t verifier;
- uint32_t v2;
- uint32_t astatus;
- uint32_t data[19];
- } reply;
- } u;
-};
-extern void NfsStart (char *); /* Begin NFS */
-
-
-/**********************************************************************/
-
-#endif /* __NFS_H__ */
diff --git a/scripts/config b/scripts/config
new file mode 100755
index 0000000000..ff88e2faef
--- /dev/null
+++ b/scripts/config
@@ -0,0 +1,230 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: GPL-2.0
+# Manipulate options in a .config file from the command line
+
+myname=${0##*/}
+
+# If no prefix forced, use the default CONFIG_
+CONFIG_="${CONFIG_-CONFIG_}"
+
+# We use an uncommon delimiter for sed substitutions
+SED_DELIM=$(echo -en "\001")
+
+usage() {
+ cat >&2 <<EOL
+Manipulate options in a .config file from the command line.
+Usage:
+$myname options command ...
+commands:
+ --enable|-e option Enable option
+ --disable|-d option Disable option
+ --module|-m option Turn option into a module
+ --set-str option string
+ Set option to "string"
+ --set-val option value
+ Set option to value
+ --undefine|-u option Undefine option
+ --state|-s option Print state of option (n,y,m,undef)
+
+ --enable-after|-E beforeopt option
+ Enable option directly after other option
+ --disable-after|-D beforeopt option
+ Disable option directly after other option
+ --module-after|-M beforeopt option
+ Turn option into module directly after other option
+
+ commands can be repeated multiple times
+
+options:
+ --file config-file .config file to change (default .config)
+ --keep-case|-k Keep next symbols' case (dont' upper-case it)
+
+$myname doesn't check the validity of the .config file. This is done at next
+make time.
+
+By default, $myname will upper-case the given symbol. Use --keep-case to keep
+the case of all following symbols unchanged.
+
+$myname uses 'CONFIG_' as the default symbol prefix. Set the environment
+variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" $myname ...
+EOL
+ exit 1
+}
+
+checkarg() {
+ ARG="$1"
+ if [ "$ARG" = "" ] ; then
+ usage
+ fi
+ case "$ARG" in
+ ${CONFIG_}*)
+ ARG="${ARG/${CONFIG_}/}"
+ ;;
+ esac
+ if [ "$MUNGE_CASE" = "yes" ] ; then
+ ARG="`echo $ARG | tr a-z A-Z`"
+ fi
+}
+
+txt_append() {
+ local anchor="$1"
+ local insert="$2"
+ local infile="$3"
+ local tmpfile="$infile.swp"
+
+ # sed append cmd: 'a\' + newline + text + newline
+ cmd="$(printf "a\\%b$insert" "\n")"
+
+ sed -e "/$anchor/$cmd" "$infile" >"$tmpfile"
+ # replace original file with the edited one
+ mv "$tmpfile" "$infile"
+}
+
+txt_subst() {
+ local before="$1"
+ local after="$2"
+ local infile="$3"
+ local tmpfile="$infile.swp"
+
+ sed -e "s$SED_DELIM$before$SED_DELIM$after$SED_DELIM" "$infile" >"$tmpfile"
+ # replace original file with the edited one
+ mv "$tmpfile" "$infile"
+}
+
+txt_delete() {
+ local text="$1"
+ local infile="$2"
+ local tmpfile="$infile.swp"
+
+ sed -e "/$text/d" "$infile" >"$tmpfile"
+ # replace original file with the edited one
+ mv "$tmpfile" "$infile"
+}
+
+set_var() {
+ local name=$1 new=$2 before=$3
+
+ name_re="^($name=|# $name is not set)"
+ before_re="^($before=|# $before is not set)"
+ if test -n "$before" && grep -Eq "$before_re" "$FN"; then
+ txt_append "^$before=" "$new" "$FN"
+ txt_append "^# $before is not set" "$new" "$FN"
+ elif grep -Eq "$name_re" "$FN"; then
+ txt_subst "^$name=.*" "$new" "$FN"
+ txt_subst "^# $name is not set" "$new" "$FN"
+ else
+ echo "$new" >>"$FN"
+ fi
+}
+
+undef_var() {
+ local name=$1
+
+ txt_delete "^$name=" "$FN"
+ txt_delete "^# $name is not set" "$FN"
+}
+
+if [ "$1" = "--file" ]; then
+ FN="$2"
+ if [ "$FN" = "" ] ; then
+ usage
+ fi
+ shift 2
+else
+ FN=.config
+fi
+
+if [ "$1" = "" ] ; then
+ usage
+fi
+
+MUNGE_CASE=yes
+while [ "$1" != "" ] ; do
+ CMD="$1"
+ shift
+ case "$CMD" in
+ --keep-case|-k)
+ MUNGE_CASE=no
+ continue
+ ;;
+ --refresh)
+ ;;
+ --*-after|-E|-D|-M)
+ checkarg "$1"
+ A=$ARG
+ checkarg "$2"
+ B=$ARG
+ shift 2
+ ;;
+ -*)
+ checkarg "$1"
+ shift
+ ;;
+ esac
+ case "$CMD" in
+ --enable|-e)
+ set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=y"
+ ;;
+
+ --disable|-d)
+ set_var "${CONFIG_}$ARG" "# ${CONFIG_}$ARG is not set"
+ ;;
+
+ --module|-m)
+ set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=m"
+ ;;
+
+ --set-str)
+ # sed swallows one level of escaping, so we need double-escaping
+ set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=\"${1//\"/\\\\\"}\""
+ shift
+ ;;
+
+ --set-val)
+ set_var "${CONFIG_}$ARG" "${CONFIG_}$ARG=$1"
+ shift
+ ;;
+ --undefine|-u)
+ undef_var "${CONFIG_}$ARG"
+ ;;
+
+ --state|-s)
+ if grep -q "# ${CONFIG_}$ARG is not set" $FN ; then
+ echo n
+ else
+ V="$(grep "^${CONFIG_}$ARG=" $FN)"
+ if [ $? != 0 ] ; then
+ echo undef
+ else
+ V="${V/#${CONFIG_}$ARG=/}"
+ V="${V/#\"/}"
+ V="${V/%\"/}"
+ V="${V//\\\"/\"}"
+ echo "${V}"
+ fi
+ fi
+ ;;
+
+ --enable-after|-E)
+ set_var "${CONFIG_}$B" "${CONFIG_}$B=y" "${CONFIG_}$A"
+ ;;
+
+ --disable-after|-D)
+ set_var "${CONFIG_}$B" "# ${CONFIG_}$B is not set" "${CONFIG_}$A"
+ ;;
+
+ --module-after|-M)
+ set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
+ ;;
+
+ # undocumented because it ignores --file (fixme)
+ --refresh)
+ yes "" | make oldconfig
+ ;;
+
+ *)
+ echo "bad command: $CMD" >&2
+ usage
+ ;;
+ esac
+done