diff options
62 files changed, 322 insertions, 2559 deletions
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 59e99b8894..35ab7f30b2 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -205,18 +205,6 @@ jobs: qemu_arm64: TEST_PY_BD: "qemu_arm64" TEST_PY_TEST_SPEC: "not sleep" - qemu_mips: - TEST_PY_BD: "qemu_mips" - TEST_PY_TEST_SPEC: "not sleep" - qemu_mipsel: - TEST_PY_BD: "qemu_mipsel" - TEST_PY_TEST_SPEC: "not sleep" - qemu_mips64: - TEST_PY_BD: "qemu_mips64" - TEST_PY_TEST_SPEC: "not sleep" - qemu_mips64el: - TEST_PY_BD: "qemu_mips64el" - TEST_PY_TEST_SPEC: "not sleep" qemu_malta: TEST_PY_BD: "malta" TEST_PY_ID: "--id qemu" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bff487404f..d072e833a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -189,7 +189,6 @@ sandbox_spl test.py: <<: *buildman_and_testpy_dfn sandbox_noinst_test.py: - tags: [ 'all' ] variables: TEST_PY_BD: "sandbox_noinst" TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl" @@ -225,30 +224,6 @@ qemu_arm64 test.py: TEST_PY_TEST_SPEC: "not sleep" <<: *buildman_and_testpy_dfn -qemu_mips test.py: - variables: - TEST_PY_BD: "qemu_mips" - TEST_PY_TEST_SPEC: "not sleep" - <<: *buildman_and_testpy_dfn - -qemu_mipsel test.py: - variables: - TEST_PY_BD: "qemu_mipsel" - TEST_PY_TEST_SPEC: "not sleep" - <<: *buildman_and_testpy_dfn - -qemu_mips64 test.py: - variables: - TEST_PY_BD: "qemu_mips64" - TEST_PY_TEST_SPEC: "not sleep" - <<: *buildman_and_testpy_dfn - -qemu_mips64el test.py: - variables: - TEST_PY_BD: "qemu_mips64el" - TEST_PY_TEST_SPEC: "not sleep" - <<: *buildman_and_testpy_dfn - qemu_malta test.py: variables: TEST_PY_BD: "malta" diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 77f563e98e..e54801673b 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -12,16 +12,6 @@ choice prompt "Target select" optional -config TARGET_QEMU_MIPS - bool "Support qemu-mips" - select ROM_EXCEPTION_VECTORS - select SUPPORTS_BIG_ENDIAN - select SUPPORTS_CPU_MIPS32_R1 - select SUPPORTS_CPU_MIPS32_R2 - select SUPPORTS_CPU_MIPS64_R1 - select SUPPORTS_CPU_MIPS64_R2 - select SUPPORTS_LITTLE_ENDIAN - config TARGET_MALTA bool "Support malta" select DM @@ -174,7 +164,6 @@ endchoice source "board/imgtec/boston/Kconfig" source "board/imgtec/malta/Kconfig" source "board/imgtec/xilfpga/Kconfig" -source "board/qemu-mips/Kconfig" source "arch/mips/mach-ath79/Kconfig" source "arch/mips/mach-mscc/Kconfig" source "arch/mips/mach-bmips/Kconfig" diff --git a/arch/powerpc/lib/traps.c b/arch/powerpc/lib/traps.c index c7bce82a44..ab8ca269a5 100644 --- a/arch/powerpc/lib/traps.c +++ b/arch/powerpc/lib/traps.c @@ -4,6 +4,7 @@ * Wolfgang Denk, DENX Software Engineering, wd@denx.de. */ +#include <common.h> #include <init.h> #include <asm/global_data.h> diff --git a/board/qemu-mips/Kconfig b/board/qemu-mips/Kconfig deleted file mode 100644 index e696a12192..0000000000 --- a/board/qemu-mips/Kconfig +++ /dev/null @@ -1,26 +0,0 @@ -if TARGET_QEMU_MIPS - -config SYS_BOARD - default "qemu-mips" - -config SYS_CONFIG_NAME - default "qemu-mips" if 32BIT - default "qemu-mips64" if 64BIT - -config SYS_TEXT_BASE - default 0xbfc00000 if 32BIT - default 0xffffffffbfc00000 if 64BIT - -config SYS_DCACHE_SIZE - default 16384 - -config SYS_DCACHE_LINE_SIZE - default 32 - -config SYS_ICACHE_SIZE - default 16384 - -config SYS_ICACHE_LINE_SIZE - default 32 - -endif diff --git a/board/qemu-mips/MAINTAINERS b/board/qemu-mips/MAINTAINERS deleted file mode 100644 index 334f9d8ee9..0000000000 --- a/board/qemu-mips/MAINTAINERS +++ /dev/null @@ -1,14 +0,0 @@ -QEMU-MIPS BOARD -M: Vlad Lungu <vlad.lungu@windriver.com> -S: Maintained -F: board/qemu-mips/ -F: include/configs/qemu-mips.h -F: configs/qemu_mips_defconfig - -QEMU_MIPSEL BOARD -#M: - -S: Maintained -F: configs/qemu_mipsel_defconfig -F: include/configs/qemu-mips64.h -F: configs/qemu_mips64_defconfig -F: configs/qemu_mips64el_defconfig diff --git a/board/qemu-mips/Makefile b/board/qemu-mips/Makefile deleted file mode 100644 index 98e3874090..0000000000 --- a/board/qemu-mips/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0+ -# -# (C) Copyright 2003-2006 -# Wolfgang Denk, DENX Software Engineering, wd@denx.de. - -obj-y = qemu-mips.o -obj-y += lowlevel_init.o diff --git a/board/qemu-mips/lowlevel_init.S b/board/qemu-mips/lowlevel_init.S deleted file mode 100644 index b0f7072701..0000000000 --- a/board/qemu-mips/lowlevel_init.S +++ /dev/null @@ -1,40 +0,0 @@ -/* Memory sub-system initialization code */ - -#include <config.h> -#include <asm/regdef.h> -#include <asm/mipsregs.h> - - .text - .set noreorder - .set mips32 - - .globl lowlevel_init -lowlevel_init: - - /* - * Step 2) Establish Status Register - * (set BEV, clear ERL, clear EXL, clear IE) - */ - li t1, 0x00400000 - mtc0 t1, CP0_STATUS - - /* - * Step 3) Establish CP0 Config0 - * (set K0=3) - */ - li t1, 0x00000003 - mtc0 t1, CP0_CONFIG - - /* - * Step 7) Establish Cause - * (set IV bit) - */ - li t1, 0x00800000 - mtc0 t1, CP0_CAUSE - - /* Establish Wired (and Random) */ - mtc0 zero, CP0_WIRED - nop - - jr ra - nop diff --git a/board/qemu-mips/qemu-mips.c b/board/qemu-mips/qemu-mips.c deleted file mode 100644 index f57091739e..0000000000 --- a/board/qemu-mips/qemu-mips.c +++ /dev/null @@ -1,85 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2007 - * Vlad Lungu vlad.lungu@windriver.com - */ - -#include <common.h> -#include <command.h> -#include <init.h> -#include <net.h> -#include <asm/global_data.h> -#include <asm/mipsregs.h> -#include <asm/io.h> -#include <netdev.h> - -DECLARE_GLOBAL_DATA_PTR; - -int dram_init(void) -{ - /* Sdram is setup by assembler code */ - /* If memory could be changed, we should return the true value here */ - gd->ram_size = MEM_SIZE * 1024 * 1024; - - return 0; -} - -int checkboard(void) -{ - u32 proc_id; - u32 config1; - - proc_id = read_c0_prid(); - printf("Board: Qemu -M mips CPU: "); - switch (proc_id) { - case 0x00018000: - printf("4Kc"); - break; - case 0x00018400: - printf("4KEcR1"); - break; - case 0x00019000: - printf("4KEc"); - break; - case 0x00019300: - config1 = read_c0_config1(); - if (config1 & 1) - printf("24Kf"); - else - printf("24Kc"); - break; - case 0x00019500: - printf("34Kf"); - break; - case 0x00000400: - printf("R4000"); - break; - case 0x00018100: - config1 = read_c0_config1(); - if (config1 & 1) - printf("5Kf"); - else - printf("5Kc"); - break; - case 0x000182a0: - printf("20Kc"); - break; - - default: - printf("unknown"); - } - printf(" proc_id=0x%x\n", proc_id); - - return 0; -} - -int misc_init_r(void) -{ - set_io_port_base(0); - return 0; -} - -int board_eth_init(struct bd_info *bis) -{ - return ne2k_register(); -} diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 0bf7b8856c..c6352719dd 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -12,6 +12,7 @@ #include <efi_load_initrd.h> #include <efi_loader.h> #include <efi_rng.h> +#include <efi_variable.h> #include <exports.h> #include <hexdump.h> #include <log.h> @@ -227,8 +228,7 @@ static int do_efi_capsule_res(struct cmd_tbl *cmdtp, int flag, { int capsule_id; char *endp; - char var_name[12]; - u16 var_name16[12], *p; + u16 var_name16[12]; efi_guid_t guid; struct efi_capsule_result_variable_header *result = NULL; efi_uintn_t size; @@ -240,8 +240,9 @@ static int do_efi_capsule_res(struct cmd_tbl *cmdtp, int flag, guid = efi_guid_capsule_report; if (argc == 1) { size = sizeof(var_name16); - ret = EFI_CALL(RT->get_variable(L"CapsuleLast", &guid, NULL, - &size, var_name16)); + ret = efi_get_variable_int(L"CapsuleLast", &guid, NULL, + &size, var_name16, NULL); + if (ret != EFI_SUCCESS) { if (ret == EFI_NOT_FOUND) printf("CapsuleLast doesn't exist\n"); @@ -259,19 +260,18 @@ static int do_efi_capsule_res(struct cmd_tbl *cmdtp, int flag, if (capsule_id < 0 || capsule_id > 0xffff) return CMD_RET_USAGE; - sprintf(var_name, "Capsule%04X", capsule_id); - p = var_name16; - utf8_utf16_strncpy(&p, var_name, 9); + efi_create_indexed_name(var_name16, sizeof(var_name16), + "Capsule", capsule_id); } size = 0; - ret = EFI_CALL(RT->get_variable(var_name16, &guid, NULL, &size, NULL)); + ret = efi_get_variable_int(var_name16, &guid, NULL, &size, NULL, NULL); if (ret == EFI_BUFFER_TOO_SMALL) { result = malloc(size); if (!result) return CMD_RET_FAILURE; - ret = EFI_CALL(RT->get_variable(var_name16, &guid, NULL, &size, - result)); + ret = efi_get_variable_int(var_name16, &guid, NULL, &size, + result, NULL); } if (ret != EFI_SUCCESS) { free(result); @@ -954,8 +954,7 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, { int id; char *endp; - char var_name[9]; - u16 var_name16[9], *p; + u16 var_name16[9]; efi_guid_t guid; size_t label_len, label_len16; u16 *label; @@ -988,9 +987,8 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, if (*endp != '\0' || id > 0xffff) return CMD_RET_USAGE; - sprintf(var_name, "Boot%04X", id); - p = var_name16; - utf8_utf16_strncpy(&p, var_name, 9); + efi_create_indexed_name(var_name16, sizeof(var_name16), + "Boot", id); /* label */ label_len = strlen(argv[2]); @@ -1066,11 +1064,11 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, goto out; } - ret = EFI_CALL(efi_set_variable(var_name16, &guid, - EFI_VARIABLE_NON_VOLATILE | - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS, - size, data)); + ret = efi_set_variable_int(var_name16, &guid, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + size, data, false); if (ret != EFI_SUCCESS) { printf("Cannot set %ls\n", var_name16); r = CMD_RET_FAILURE; @@ -1107,8 +1105,7 @@ static int do_efi_boot_rm(struct cmd_tbl *cmdtp, int flag, efi_guid_t guid; int id, i; char *endp; - char var_name[9]; - u16 var_name16[9], *p; + u16 var_name16[9]; efi_status_t ret; if (argc == 1) @@ -1120,11 +1117,10 @@ static int do_efi_boot_rm(struct cmd_tbl *cmdtp, int flag, if (*endp != '\0' || id > 0xffff) return CMD_RET_FAILURE; - sprintf(var_name, "Boot%04X", id); - p = var_name16; - utf8_utf16_strncpy(&p, var_name, 9); - - ret = EFI_CALL(efi_set_variable(var_name16, &guid, 0, 0, NULL)); + efi_create_indexed_name(var_name16, sizeof(var_name16), + "Boot", id); + ret = efi_set_variable_int(var_name16, &guid, 0, 0, NULL, + false); if (ret) { printf("Cannot remove %ls\n", var_name16); return CMD_RET_FAILURE; @@ -1147,8 +1143,6 @@ static void show_efi_boot_opt_data(u16 *varname16, void *data, size_t *size) { struct efi_device_path *initrd_path = NULL; struct efi_load_option lo; - char *label, *p; - size_t label_len16, label_len; u16 *dp_str; efi_status_t ret; efi_uintn_t initrd_dp_size; @@ -1160,14 +1154,6 @@ static void show_efi_boot_opt_data(u16 *varname16, void *data, size_t *size) return; } - label_len16 = u16_strlen(lo.label); - label_len = utf16_utf8_strnlen(lo.label, label_len16); - label = malloc(label_len + 1); - if (!label) - return; - p = label; - utf16_utf8_strncpy(&p, lo.label, label_len16); - printf("%ls:\nattributes: %c%c%c (0x%08x)\n", varname16, /* ACTIVE */ @@ -1177,7 +1163,7 @@ static void show_efi_boot_opt_data(u16 *varname16, void *data, size_t *size) /* HIDDEN */ lo.attributes & LOAD_OPTION_HIDDEN ? 'H' : '-', lo.attributes); - printf(" label: %s\n", label); + printf(" label: %ls\n", lo.label); dp_str = efi_dp_str(lo.file_path); printf(" file_path: %ls\n", dp_str); @@ -1194,7 +1180,6 @@ static void show_efi_boot_opt_data(u16 *varname16, void *data, size_t *size) printf(" data:\n"); print_hex_dump(" ", DUMP_PREFIX_OFFSET, 16, 1, lo.optional_data, *size, true); - free(label); } /** @@ -1324,12 +1309,9 @@ static int show_efi_boot_order(void) u16 *bootorder; efi_uintn_t size; int num, i; - char var_name[9]; - u16 var_name16[9], *p16; + u16 var_name16[9]; void *data; struct efi_load_option lo; - char *label, *p; - size_t label_len16, label_len; efi_status_t ret; size = 0; @@ -1357,16 +1339,15 @@ static int show_efi_boot_order(void) num = size / sizeof(u16); for (i = 0; i < num; i++) { - sprintf(var_name, "Boot%04X", bootorder[i]); - p16 = var_name16; - utf8_utf16_strncpy(&p16, var_name, 9); + efi_create_indexed_name(var_name16, sizeof(var_name16), + "Boot", i); size = 0; ret = EFI_CALL(efi_get_variable(var_name16, &efi_global_variable_guid, NULL, &size, NULL)); if (ret != EFI_BUFFER_TOO_SMALL) { - printf("%2d: %s: (not defined)\n", i + 1, var_name); + printf("%2d: %ls: (not defined)\n", i + 1, var_name16); continue; } @@ -1391,18 +1372,7 @@ static int show_efi_boot_order(void) goto out; } - label_len16 = u16_strlen(lo.label); - label_len = utf16_utf8_strnlen(lo.label, label_len16); - label = malloc(label_len + 1); - if (!label) { - free(data); - ret = CMD_RET_FAILURE; - goto out; - } - p = label; - utf16_utf8_strncpy(&p, lo.label, label_len16); - printf("%2d: %s: %s\n", i + 1, var_name, label); - free(label); + printf("%2d: %ls: %ls\n", i + 1, var_name16, lo.label); free(data); } @@ -1449,11 +1419,11 @@ static int do_efi_boot_next(struct cmd_tbl *cmdtp, int flag, guid = efi_global_variable_guid; size = sizeof(u16); - ret = EFI_CALL(efi_set_variable(L"BootNext", &guid, + ret = efi_set_variable_int(L"BootNext", &guid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - size, &bootnext)); + size, &bootnext, false); if (ret != EFI_SUCCESS) { printf("Cannot set BootNext\n"); r = CMD_RET_FAILURE; @@ -1510,11 +1480,11 @@ static int do_efi_boot_order(struct cmd_tbl *cmdtp, int flag, } guid = efi_global_variable_guid; - ret = EFI_CALL(efi_set_variable(L"BootOrder", &guid, + ret = efi_set_variable_int(L"BootOrder", &guid, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - size, bootorder)); + size, bootorder, true); if (ret != EFI_SUCCESS) { printf("Cannot set BootOrder\n"); r = CMD_RET_FAILURE; diff --git a/common/spl/Kconfig b/common/spl/Kconfig index df5468f1ac..b709a05a7b 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -165,7 +165,7 @@ config SPL_BOARD_INIT provided by the board. config SPL_BOOTROM_SUPPORT - bool "Support returning to the BOOTROM" + bool "Support returning to the BOOTROM" help Some platforms (e.g. the Rockchip RK3368) provide support in their ROM for loading the next boot-stage after performing basic setup @@ -707,7 +707,7 @@ config SYS_MMCSD_FS_BOOT_PARTITION default 1 help Partition on the MMC to load U-Boot from when the MMC is being - used in fs mode + used in fs mode config SPL_MMC_TINY bool "Tiny MMC framework in SPL" @@ -784,8 +784,8 @@ config SPL_NAND_SIMPLE config SPL_NAND_BASE depends on SPL_NAND_DRIVERS bool "Use Base NAND Driver" - help - Include nand_base.c in the SPL. + help + Include nand_base.c in the SPL. config SPL_NAND_IDENT depends on SPL_NAND_BASE @@ -1301,7 +1301,7 @@ config SPL_ATF_LOAD_IMAGE_V2 method, say Y. config SPL_ATF_NO_PLATFORM_PARAM - bool "Pass no platform parameter" + bool "Pass no platform parameter" depends on SPL_ATF help While we expect to call a pointer to a valid FDT (or NULL) @@ -1395,7 +1395,7 @@ config TPL_BOOTCOUNT_LIMIT For example, it may be useful to choose the device to boot. config TPL_LDSCRIPT - string "Linker script for the TPL stage" + string "Linker script for the TPL stage" depends on TPL default "arch/arm/cpu/armv8/u-boot-spl.lds" if ARM64 default "arch/\$(ARCH)/cpu/u-boot-spl.lds" @@ -1409,7 +1409,7 @@ config TPL_LDSCRIPT fall back to the linker-script used for the SPL stage. config TPL_NEEDS_SEPARATE_TEXT_BASE - bool "TPL needs a separate text-base" + bool "TPL needs a separate text-base" default n depends on TPL help @@ -1418,7 +1418,7 @@ config TPL_NEEDS_SEPARATE_TEXT_BASE .text sections of the TPL stage has to be set below. config TPL_NEEDS_SEPARATE_STACK - bool "TPL needs a separate initial stack-pointer" + bool "TPL needs a separate initial stack-pointer" default n depends on TPL help @@ -1426,20 +1426,20 @@ config TPL_NEEDS_SEPARATE_STACK stack-pointer from the settings for the SPL stage. config TPL_TEXT_BASE - hex "Base address for the .text section of the TPL stage" + hex "Base address for the .text section of the TPL stage" depends on TPL_NEEDS_SEPARATE_TEXT_BASE help The base address for the .text section of the TPL stage. config TPL_MAX_SIZE - int "Maximum size (in bytes) for the TPL stage" + int "Maximum size (in bytes) for the TPL stage" default 0 depends on TPL help The maximum size (in bytes) of the TPL stage. config TPL_STACK - hex "Address of the initial stack-pointer for the TPL stage" + hex "Address of the initial stack-pointer for the TPL stage" depends on TPL_NEEDS_SEPARATE_STACK help The address of the initial stack-pointer for the TPL stage. @@ -1457,7 +1457,7 @@ config TPL_READ_ONLY device-private data. config TPL_BOOTROM_SUPPORT - bool "Support returning to the BOOTROM (from TPL)" + bool "Support returning to the BOOTROM (from TPL)" help Some platforms (e.g. the Rockchip RK3368) provide support in their ROM for loading the next boot-stage after performing basic setup diff --git a/configs/ae350_rv32_spl_xip_defconfig b/configs/ae350_rv32_spl_xip_defconfig index 418170c904..494cb6527d 100644 --- a/configs/ae350_rv32_spl_xip_defconfig +++ b/configs/ae350_rv32_spl_xip_defconfig @@ -2,8 +2,8 @@ CONFIG_RISCV=y CONFIG_SYS_TEXT_BASE=0x01200000 CONFIG_NR_DRAM_BANKS=2 CONFIG_ENV_SECT_SIZE=0x1000 -CONFIG_SPL_SYS_MALLOC_F_LEN=0x100000 CONFIG_SPL_TEXT_BASE=0x80000000 +CONFIG_SPL_SYS_MALLOC_F_LEN=0x100000 CONFIG_SPL=y CONFIG_DEFAULT_DEVICE_TREE="ae350_32" CONFIG_TARGET_AX25_AE350=y diff --git a/configs/ae350_rv64_spl_xip_defconfig b/configs/ae350_rv64_spl_xip_defconfig index 7826ae49ed..adc9d669ea 100644 --- a/configs/ae350_rv64_spl_xip_defconfig +++ b/configs/ae350_rv64_spl_xip_defconfig @@ -2,8 +2,8 @@ CONFIG_RISCV=y CONFIG_SYS_TEXT_BASE=0x01200000 CONFIG_NR_DRAM_BANKS=2 CONFIG_ENV_SECT_SIZE=0x1000 -CONFIG_SPL_SYS_MALLOC_F_LEN=0x100000 CONFIG_SPL_TEXT_BASE=0x80000000 +CONFIG_SPL_SYS_MALLOC_F_LEN=0x100000 CONFIG_SPL=y CONFIG_DEFAULT_DEVICE_TREE="ae350_64" CONFIG_TARGET_AX25_AE350=y diff --git a/configs/am3517_evm_defconfig b/configs/am3517_evm_defconfig index d61eec94a4..0b9bd0e475 100644 --- a/configs/am3517_evm_defconfig +++ b/configs/am3517_evm_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y # CONFIG_SPL_USE_ARCH_MEMCPY is not set # CONFIG_SPL_USE_ARCH_MEMSET is not set @@ -13,6 +12,7 @@ CONFIG_EMIF4=y CONFIG_SPL_SYS_MALLOC_F_LEN=0x3000 CONFIG_SPL=y CONFIG_DEFAULT_DEVICE_TREE="am3517-evm" +CONFIG_LTO=y CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTDELAY=10 # CONFIG_USE_BOOTCOMMAND is not set diff --git a/configs/da850evm_defconfig b/configs/da850evm_defconfig index 8b93f33552..42db153c7f 100644 --- a/configs/da850evm_defconfig +++ b/configs/da850evm_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_SYS_THUMB_BUILD=y CONFIG_ARCH_DAVINCI=y @@ -20,6 +19,7 @@ CONFIG_SPL=y CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEFAULT_DEVICE_TREE="da850-evm" +CONFIG_LTO=y CONFIG_SYS_EXTRA_OPTIONS="MAC_ADDR_IN_SPIFLASH" CONFIG_BOOTDELAY=3 CONFIG_DEFAULT_FDT_FILE="da850-evm.dtb" diff --git a/configs/da850evm_direct_nor_defconfig b/configs/da850evm_direct_nor_defconfig index 2610a82f7a..b595acf400 100644 --- a/configs/da850evm_direct_nor_defconfig +++ b/configs/da850evm_direct_nor_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_ARCH_CPU_INIT=y CONFIG_ARCH_DAVINCI=y @@ -12,6 +11,7 @@ CONFIG_ENV_SIZE=0x2800 CONFIG_ENV_SECT_SIZE=0x20000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="da850-evm" +CONFIG_LTO=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="mem=32M console=ttyS2,115200n8 root=/dev/mtdblock2 rw noinitrd ip=dhcp" diff --git a/configs/da850evm_nand_defconfig b/configs/da850evm_nand_defconfig index b347c01283..7e48293014 100644 --- a/configs/da850evm_nand_defconfig +++ b/configs/da850evm_nand_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_SYS_THUMB_BUILD=y CONFIG_ARCH_DAVINCI=y @@ -17,6 +16,7 @@ CONFIG_SPL=y CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI_SUPPORT=y CONFIG_DEFAULT_DEVICE_TREE="da850-evm" +CONFIG_LTO=y CONFIG_SYS_EXTRA_OPTIONS="MAC_ADDR_IN_SPIFLASH" CONFIG_BOOTDELAY=3 CONFIG_DEFAULT_FDT_FILE="da850-evm.dtb" diff --git a/configs/imx6q_logic_defconfig b/configs/imx6q_logic_defconfig index 0f8aea6983..64c20b8523 100644 --- a/configs/imx6q_logic_defconfig +++ b/configs/imx6q_logic_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_ARCH_MX6=y CONFIG_SYS_TEXT_BASE=0x17800000 @@ -20,6 +19,7 @@ CONFIG_SPL=y CONFIG_SPL_FS_FAT=y CONFIG_SPL_PAYLOAD="u-boot.img" CONFIG_DEFAULT_DEVICE_TREE="imx6q-logicpd" +CONFIG_LTO=y CONFIG_DISTRO_DEFAULTS=y CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg" CONFIG_BOOTDELAY=3 diff --git a/configs/imx8mm-cl-iot-gate_defconfig b/configs/imx8mm-cl-iot-gate_defconfig index b42967c638..be98fa833b 100644 --- a/configs/imx8mm-cl-iot-gate_defconfig +++ b/configs/imx8mm-cl-iot-gate_defconfig @@ -138,9 +138,6 @@ CONFIG_USB_ETHER_ASIX88179=y CONFIG_IMX_WATCHDOG=y CONFIG_SPL_TINY_MEMSET=y CONFIG_TPM=y -CONFIG_SHA512_ALGO=y -CONFIG_SHA512=y -CONFIG_SHA384=y CONFIG_LZO=y CONFIG_BZIP2=y CONFIG_OF_LIBFDT_OVERLAY=y @@ -148,5 +145,4 @@ CONFIG_EFI_SET_TIME=y CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y CONFIG_EFI_CAPSULE_ON_DISK=y CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y -CONFIG_EFI_TCG2_PROTOCOL=y CONFIG_EFI_SECURE_BOOT=y diff --git a/configs/imx8mm_beacon_defconfig b/configs/imx8mm_beacon_defconfig index 6b2dc24b85..2248491ad4 100644 --- a/configs/imx8mm_beacon_defconfig +++ b/configs/imx8mm_beacon_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_ARCH_IMX8M=y CONFIG_SYS_TEXT_BASE=0x40200000 @@ -19,6 +18,7 @@ CONFIG_SPL_SERIAL_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y CONFIG_SPL=y CONFIG_DEFAULT_DEVICE_TREE="imx8mm-beacon-kit" +CONFIG_LTO=y CONFIG_FIT=y CONFIG_FIT_EXTERNAL_OFFSET=0x3000 CONFIG_SPL_LOAD_FIT=y diff --git a/configs/imx8mm_venice_defconfig b/configs/imx8mm_venice_defconfig index 4b0e5d04d8..07ddf37216 100644 --- a/configs/imx8mm_venice_defconfig +++ b/configs/imx8mm_venice_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_ARCH_IMX8M=y CONFIG_SYS_TEXT_BASE=0x40200000 @@ -22,6 +21,7 @@ CONFIG_SPL_DRIVERS_MISC_SUPPORT=y CONFIG_SPL=y CONFIG_ENV_OFFSET_REDUND=0xff8000 CONFIG_DEFAULT_DEVICE_TREE="imx8mm-venice" +CONFIG_LTO=y CONFIG_DISTRO_DEFAULTS=y CONFIG_FIT=y CONFIG_FIT_EXTERNAL_OFFSET=0x3000 diff --git a/configs/imx8mn_beacon_2g_defconfig b/configs/imx8mn_beacon_2g_defconfig index cc4c56c422..ecd7fabbb8 100644 --- a/configs/imx8mn_beacon_2g_defconfig +++ b/configs/imx8mn_beacon_2g_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_ARCH_IMX8M=y CONFIG_SYS_TEXT_BASE=0x40200000 @@ -24,6 +23,7 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000 CONFIG_SPL=y CONFIG_SPL_IMX_ROMAPI_LOADADDR=0x48000000 CONFIG_DEFAULT_DEVICE_TREE="imx8mn-beacon-kit" +CONFIG_LTO=y CONFIG_FIT=y CONFIG_FIT_EXTERNAL_OFFSET=0x3000 CONFIG_SPL_LOAD_FIT=y diff --git a/configs/imx8mn_beacon_defconfig b/configs/imx8mn_beacon_defconfig index 66fe9d34c0..9a77f22ce2 100644 --- a/configs/imx8mn_beacon_defconfig +++ b/configs/imx8mn_beacon_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_ARCH_IMX8M=y CONFIG_SYS_TEXT_BASE=0x40200000 @@ -23,6 +22,7 @@ CONFIG_SPL_SYS_MALLOC_F_LEN=0x2000 CONFIG_SPL=y CONFIG_SPL_IMX_ROMAPI_LOADADDR=0x48000000 CONFIG_DEFAULT_DEVICE_TREE="imx8mn-beacon-kit" +CONFIG_LTO=y CONFIG_FIT=y CONFIG_FIT_EXTERNAL_OFFSET=0x3000 CONFIG_SPL_LOAD_FIT=y diff --git a/configs/mvebu_db_armada8k_defconfig b/configs/mvebu_db_armada8k_defconfig index 76ab68b088..11d90692fe 100644 --- a/configs/mvebu_db_armada8k_defconfig +++ b/configs/mvebu_db_armada8k_defconfig @@ -32,7 +32,6 @@ CONFIG_CMD_TFTPPUT=y CONFIG_CMD_CACHE=y CONFIG_CMD_TIME=y CONFIG_CMD_MVEBU_BUBT=y -CONFIG_CMD_MVEBU_RX_TRAINING=y CONFIG_CMD_EXT4_WRITE=y CONFIG_MAC_PARTITION=y CONFIG_ENV_OVERWRITE=y diff --git a/configs/mvebu_db_cn9130_defconfig b/configs/mvebu_db_cn9130_defconfig index 57fe525b4b..2d8e8ef127 100644 --- a/configs/mvebu_db_cn9130_defconfig +++ b/configs/mvebu_db_cn9130_defconfig @@ -46,9 +46,7 @@ CONFIG_DM_GPIO_LOOKUP_LABEL=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_MVTWSI=y CONFIG_MISC=y -CONFIG_MVEBU_SAR=y CONFIG_MMC_BROKEN_CD=y -CONFIG_DM_MMC=y CONFIG_MMC_HS200_SUPPORT=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_XENON=y diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig index 802568aea7..3548aab0e1 100644 --- a/configs/nokia_rx51_defconfig +++ b/configs/nokia_rx51_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y # CONFIG_SYS_THUMB_BUILD is not set CONFIG_ARCH_OMAP2PLUS=y @@ -6,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x80008000 CONFIG_NR_DRAM_BANKS=2 CONFIG_TARGET_NOKIA_RX51=y CONFIG_OPTIMIZE_INLINING=y +CONFIG_LTO=y # CONFIG_SYS_MALLOC_F is not set # CONFIG_FIT is not set CONFIG_BOOTDELAY=30 diff --git a/configs/octeon_ebb7304_defconfig b/configs/octeon_ebb7304_defconfig index 253de23ca2..bf34ac8cbf 100644 --- a/configs/octeon_ebb7304_defconfig +++ b/configs/octeon_ebb7304_defconfig @@ -3,7 +3,7 @@ CONFIG_SYS_TEXT_BASE=0xffffffff80000000 CONFIG_SYS_MALLOC_F_LEN=0x4000 CONFIG_NR_DRAM_BANKS=2 CONFIG_ENV_SIZE=0x2000 -CONFIG_ENV_SECT_SIZE=0x10000 +CONFIG_ENV_SECT_SIZE=0x2000 CONFIG_DEBUG_UART_BASE=0x8001180000000800 CONFIG_DEBUG_UART_CLOCK=1200000000 CONFIG_ARCH_OCTEON=y @@ -33,7 +33,7 @@ CONFIG_AMIGA_PARTITION=y CONFIG_EFI_PARTITION=y CONFIG_PARTITION_TYPE_GUID=y CONFIG_ENV_IS_IN_FLASH=y -CONFIG_ENV_ADDR=0x1FBFE000 +CONFIG_ENV_ADDR=0x800000001FBFE000 CONFIG_CLK=y # CONFIG_INPUT is not set CONFIG_MISC=y @@ -46,6 +46,7 @@ CONFIG_FLASH_CFI_DRIVER=y CONFIG_CFI_FLASH=y CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y CONFIG_FLASH_CFI_MTD=y +CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_ATMEL=y diff --git a/configs/omap3_logic_defconfig b/configs/omap3_logic_defconfig index 7b17b28e6d..84f989de6b 100644 --- a/configs/omap3_logic_defconfig +++ b/configs/omap3_logic_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y # CONFIG_SPL_USE_ARCH_MEMCPY is not set # CONFIG_SPL_USE_ARCH_MEMSET is not set @@ -13,6 +12,7 @@ CONFIG_TARGET_OMAP3_LOGIC=y # CONFIG_SPL_OMAP3_ID_NAND is not set CONFIG_SPL=y CONFIG_DEFAULT_DEVICE_TREE="logicpd-torpedo-37xx-devkit" +CONFIG_LTO=y CONFIG_DISTRO_DEFAULTS=y CONFIG_ANDROID_BOOT_IMAGE=y # CONFIG_USE_BOOTCOMMAND is not set diff --git a/configs/qemu_mips64_defconfig b/configs/qemu_mips64_defconfig deleted file mode 100644 index 30d42ef3ee..0000000000 --- a/configs/qemu_mips64_defconfig +++ /dev/null @@ -1,29 +0,0 @@ -CONFIG_MIPS=y -CONFIG_SYS_TEXT_BASE=0xFFFFFFFFBFC00000 -CONFIG_ENV_SIZE=0x8000 -CONFIG_ENV_SECT_SIZE=0x8000 -CONFIG_TARGET_QEMU_MIPS=y -CONFIG_CPU_MIPS64_R1=y -CONFIG_BOOTDELAY=10 -CONFIG_MISC_INIT_R=y -CONFIG_HUSH_PARSER=y -CONFIG_SYS_PROMPT="qemu-mips64 # " -CONFIG_CMD_IMLS=y -CONFIG_CMD_IDE=y -# CONFIG_CMD_LOADB is not set -# CONFIG_CMD_LOADS is not set -# CONFIG_CMD_SETEXPR is not set -CONFIG_CMD_DHCP=y -CONFIG_CMD_RARP=y -CONFIG_CMD_EXT2=y -CONFIG_CMD_FAT=y -# CONFIG_ISO_PARTITION is not set -CONFIG_ENV_OVERWRITE=y -CONFIG_ENV_IS_IN_FLASH=y -CONFIG_ENV_ADDR=0xFFFFFFFFBFFF8000 -CONFIG_MTD_NOR_FLASH=y -CONFIG_FLASH_CFI_DRIVER=y -CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y -CONFIG_SYS_FLASH_CFI=y -CONFIG_SYS_NS16550=y -CONFIG_LZMA=y diff --git a/configs/qemu_mips64el_defconfig b/configs/qemu_mips64el_defconfig deleted file mode 100644 index 4a45d5e0fd..0000000000 --- a/configs/qemu_mips64el_defconfig +++ /dev/null @@ -1,30 +0,0 @@ -CONFIG_MIPS=y -CONFIG_SYS_TEXT_BASE=0xFFFFFFFFBFC00000 -CONFIG_ENV_SIZE=0x8000 -CONFIG_ENV_SECT_SIZE=0x8000 -CONFIG_TARGET_QEMU_MIPS=y -CONFIG_SYS_LITTLE_ENDIAN=y -CONFIG_CPU_MIPS64_R1=y -CONFIG_BOOTDELAY=10 -CONFIG_MISC_INIT_R=y -CONFIG_HUSH_PARSER=y -CONFIG_SYS_PROMPT="qemu-mips64el # " -CONFIG_CMD_IMLS=y -CONFIG_CMD_IDE=y -# CONFIG_CMD_LOADB is not set -# CONFIG_CMD_LOADS is not set -# CONFIG_CMD_SETEXPR is not set -CONFIG_CMD_DHCP=y -CONFIG_CMD_RARP=y -CONFIG_CMD_EXT2=y -CONFIG_CMD_FAT=y -# CONFIG_ISO_PARTITION is not set -CONFIG_ENV_OVERWRITE=y -CONFIG_ENV_IS_IN_FLASH=y -CONFIG_ENV_ADDR=0xFFFFFFFFBFFF8000 -CONFIG_MTD_NOR_FLASH=y -CONFIG_FLASH_CFI_DRIVER=y -CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y -CONFIG_SYS_FLASH_CFI=y -CONFIG_SYS_NS16550=y -CONFIG_LZMA=y diff --git a/configs/qemu_mips_defconfig b/configs/qemu_mips_defconfig deleted file mode 100644 index ebf7af0140..0000000000 --- a/configs/qemu_mips_defconfig +++ /dev/null @@ -1,27 +0,0 @@ -CONFIG_MIPS=y -CONFIG_SYS_TEXT_BASE=0xBFC00000 -CONFIG_ENV_SIZE=0x8000 -CONFIG_ENV_SECT_SIZE=0x8000 -CONFIG_TARGET_QEMU_MIPS=y -CONFIG_BOOTDELAY=10 -CONFIG_MISC_INIT_R=y -CONFIG_HUSH_PARSER=y -CONFIG_SYS_PROMPT="qemu-mips # " -CONFIG_CMD_IMLS=y -CONFIG_CMD_IDE=y -# CONFIG_CMD_LOADB is not set -# CONFIG_CMD_LOADS is not set -# CONFIG_CMD_SETEXPR is not set -CONFIG_CMD_DHCP=y -CONFIG_CMD_EXT2=y -CONFIG_CMD_FAT=y -# CONFIG_ISO_PARTITION is not set -CONFIG_ENV_OVERWRITE=y -CONFIG_ENV_IS_IN_FLASH=y -CONFIG_ENV_ADDR=0xBFFF8000 -CONFIG_MTD_NOR_FLASH=y -CONFIG_FLASH_CFI_DRIVER=y -CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y -CONFIG_SYS_FLASH_CFI=y -CONFIG_SYS_NS16550=y -CONFIG_LZMA=y diff --git a/configs/qemu_mipsel_defconfig b/configs/qemu_mipsel_defconfig deleted file mode 100644 index 03862f7c4f..0000000000 --- a/configs/qemu_mipsel_defconfig +++ /dev/null @@ -1,28 +0,0 @@ -CONFIG_MIPS=y -CONFIG_SYS_TEXT_BASE=0xBFC00000 -CONFIG_ENV_SIZE=0x8000 -CONFIG_ENV_SECT_SIZE=0x8000 -CONFIG_TARGET_QEMU_MIPS=y -CONFIG_SYS_LITTLE_ENDIAN=y -CONFIG_BOOTDELAY=10 -CONFIG_MISC_INIT_R=y -CONFIG_HUSH_PARSER=y -CONFIG_SYS_PROMPT="qemu-mipsel # " -CONFIG_CMD_IMLS=y -CONFIG_CMD_IDE=y -# CONFIG_CMD_LOADB is not set -# CONFIG_CMD_LOADS is not set -# CONFIG_CMD_SETEXPR is not set -CONFIG_CMD_DHCP=y -CONFIG_CMD_EXT2=y -CONFIG_CMD_FAT=y -# CONFIG_ISO_PARTITION is not set -CONFIG_ENV_OVERWRITE=y -CONFIG_ENV_IS_IN_FLASH=y -CONFIG_ENV_ADDR=0xBFFF8000 -CONFIG_MTD_NOR_FLASH=y -CONFIG_FLASH_CFI_DRIVER=y -CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y -CONFIG_SYS_FLASH_CFI=y -CONFIG_SYS_NS16550=y -CONFIG_LZMA=y diff --git a/configs/r8a774a1_beacon_defconfig b/configs/r8a774a1_beacon_defconfig index 8e65654318..4a87a9a31f 100644 --- a/configs/r8a774a1_beacon_defconfig +++ b/configs/r8a774a1_beacon_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_ARCH_RMOBILE=y CONFIG_SYS_TEXT_BASE=0x50000000 @@ -9,6 +8,7 @@ CONFIG_RCAR_GEN3=y CONFIG_TARGET_BEACON_RZG2M=y # CONFIG_SPL is not set CONFIG_DEFAULT_DEVICE_TREE="r8a774a1-beacon-rzg2m-kit" +CONFIG_LTO=y CONFIG_FIT=y CONFIG_SUPPORT_RAW_INITRD=y # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set diff --git a/configs/r8a774b1_beacon_defconfig b/configs/r8a774b1_beacon_defconfig index 37584db185..2c31222525 100644 --- a/configs/r8a774b1_beacon_defconfig +++ b/configs/r8a774b1_beacon_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_ARCH_RMOBILE=y CONFIG_SYS_TEXT_BASE=0x50000000 @@ -9,6 +8,7 @@ CONFIG_RCAR_GEN3=y CONFIG_TARGET_BEACON_RZG2N=y # CONFIG_SPL is not set CONFIG_DEFAULT_DEVICE_TREE="r8a774b1-beacon-rzg2n-kit" +CONFIG_LTO=y CONFIG_FIT=y CONFIG_SUPPORT_RAW_INITRD=y # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set diff --git a/configs/r8a774e1_beacon_defconfig b/configs/r8a774e1_beacon_defconfig index 8a65e86380..a814d6ad63 100644 --- a/configs/r8a774e1_beacon_defconfig +++ b/configs/r8a774e1_beacon_defconfig @@ -1,4 +1,3 @@ -CONFIG_LTO=y CONFIG_ARM=y CONFIG_ARCH_RMOBILE=y CONFIG_SYS_TEXT_BASE=0x50000000 @@ -9,6 +8,7 @@ CONFIG_RCAR_GEN3=y CONFIG_TARGET_BEACON_RZG2H=y # CONFIG_SPL is not set CONFIG_DEFAULT_DEVICE_TREE="r8a774e1-beacon-rzg2h-kit" +CONFIG_LTO=y CONFIG_FIT=y CONFIG_SUPPORT_RAW_INITRD=y # CONFIG_ARCH_FIXUP_FDT_MEMORY is not set diff --git a/disk/part.c b/disk/part.c index 5e7e59cf25..086da84b7f 100644 --- a/disk/part.c +++ b/disk/part.c @@ -714,7 +714,11 @@ static int part_get_info_by_dev_and_name(const char *dev_iface, int ret; /* Separate device and partition name specification */ - part_str = strchr(dev_part_str, '#'); + if (dev_part_str) + part_str = strchr(dev_part_str, '#'); + else + part_str = NULL; + if (part_str) { dup_str = strdup(dev_part_str); dup_str[part_str - dev_part_str] = 0; diff --git a/doc/README.ne2000 b/doc/README.ne2000 deleted file mode 100644 index 0f6a2e04ff..0000000000 --- a/doc/README.ne2000 +++ /dev/null @@ -1,27 +0,0 @@ -This driver supports NE2000 compatible cards (those based on DP8390, -DP83902 and similar). It can be used with PCMCIA/CF cards provided -that the CCR is correctly initialized. - -The code is based on sources from the Linux kernel (pcnet_cs.c, -8390.h) and eCOS(if_dp83902a.c, if_dp83902a.h). Both of these 2 -wonderful world are GPL, so this is, of course, GPL. - -I developed and tested this driver on a custom PXA255 based system and -with a billionton CF network card connected to the PCMCIA interface of -the micro (have a look at README.PXA_CF for the support of this port). - -The options you have to specify in the config file are (with the -value for my board as an example): - -#define CONFIG_DRIVER_NE2000 - -- Enables the driver - -#define CONFIG_DRIVER_NE2000_BASE (0x20000000+0x300) - -- Address where the board is mapped - - -Enjoy! - -Christian Pellegrin <chri@ascensit.com> diff --git a/doc/board/emulation/qemu-mips.rst b/doc/board/emulation/qemu-mips.rst index d35925126a..5fd8a0a23b 100644 --- a/doc/board/emulation/qemu-mips.rst +++ b/doc/board/emulation/qemu-mips.rst @@ -1,246 +1,129 @@ .. SPDX-License-Identifier: GPL-2.0+ -.. sectionauthor:: Vlad Lungu <vlad.lungu@windriver.com> +.. sectionauthor:: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> QEMU MIPS ========= -Qemu is a full system emulator. See http://www.nongnu.org/qemu/ +Qemu for MIPS is based on the MIPS Malta board. The built Malta U-Boot +images can be used for Qemu and on physical hardware. The Malta board +supports all combinations of Little and Big Endian as well as 32 bit +and 64 bit. Limitations & comments ---------------------- -Supports the "-M mips" configuration of qemu: serial,NE2000,IDE. -Supports little and big endian as well as 32 bit and 64 bit. -Derived from au1x00 with a lot of things cut out. - -Supports emulated flash (patch Jean-Christophe PLAGNIOL-VILLARD) with -recent qemu versions. When using emulated flash, launch with --pflash <filename> and erase mips_bios.bin. - - -Notes for the Qemu MIPS port ----------------------------- +The memory size for Qemu is hard-coded to 256 MiB. For Malta Little Endian +targets an extra endianness swapped image named *u-boot-swap.bin* is +generated and required for Qemu. Example usage -^^^^^^^^^^^^^ - -Using u-boot.bin as ROM (replaces Qemu monitor): +------------- -32 bit, big endian +Build for 32 bit, big endian: .. code-block:: bash - make qemu_mips_defconfig - qemu-system-mips -M mips -bios u-boot.bin -nographic + make malta_defconfig + make + UBOOT_BIN=u-boot.bin + QEMU_BIN=qemu-system-mips + QEMU_CPU=24Kc -32 bit, little endian +Build for 32 bit, little endian: .. code-block:: bash - make qemu_mipsel_defconfig - qemu-system-mipsel -M mips -bios u-boot.bin -nographic + make maltael_defconfig + make + UBOOT_BIN=u-boot-swap.bin + QEMU_BIN=qemu-system-mipsel + QEMU_CPU=24Kc -64 bit, big endian +Build for 64 bit, big endian: .. code-block:: bash - make qemu_mips64_defconfig - qemu-system-mips64 -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic + make malta64_defconfig + make + UBOOT_BIN=u-boot.bin + QEMU_BIN=qemu-system-mips64 + QEMU_CPU=MIPS64R2-generic -64 bit, little endian +Build for 64 bit, little endian: .. code-block:: bash - make qemu_mips64el_defconfig - qemu-system-mips64el -cpu MIPS64R2-generic -M mips -bios u-boot.bin -nographic + make malta64el_defconfig + make + UBOOT_BIN=u-boot-swap.bin + QEMU_BIN=qemu-system-mips64el + QEMU_CPU=MIPS64R2-generic -or using u-boot.bin from emulated flash: - -if you use a QEMU version after commit 4224 +Generate NOR flash image with U-Boot binary: .. code-block:: bash - # create image: - dd of=flash bs=1k count=4k if=/dev/zero - dd of=flash bs=1k conv=notrunc if=u-boot.bin - # start it (see above): - qemu-system-mips[64][el] [-cpu MIPS64R2-generic] -M mips -pflash flash -nographic - -Download kernel + initrd -^^^^^^^^^^^^^^^^^^^^^^^^ - -On ftp://ftp.denx.de/pub/contrib/Jean-Christophe_Plagniol-Villard/qemu_mips/ -you can downland:: + dd if=/dev/zero bs=1M count=4 | tr '\000' '\377' > pflash.img + dd if=${UBOOT_BIN} of=pflash.img conv=notrunc - #config to build the kernel - qemu_mips_defconfig - #patch to fix mips interrupt init on 2.6.24.y kernel - qemu_mips_kernel.patch - initrd.gz - vmlinux - vmlinux.bin - System.map - -Generate uImage -^^^^^^^^^^^^^^^ - -.. code-block:: bash - - tools/mkimage -A mips -O linux -T kernel -C gzip -a 0x80010000 -e 0x80245650 -n "Linux 2.6.24.y" -d vmlinux.bin.gz uImage - -Copy uImage to Flash -^^^^^^^^^^^^^^^^^^^^ +Start Qemu: .. code-block:: bash - dd if=uImage bs=1k conv=notrunc seek=224 of=flash - -Generate Ide Disk -^^^^^^^^^^^^^^^^^ + mkdir tftproot + ${QEMU_BIN} -nographic -cpu ${QEMU_CPU} -m 256 -drive if=pflash,file="$(pwd)/pflash.img",format=raw -netdev user,id=net0,tftp="$(pwd)/tftproot" -device pcnet,netdev=net0 .. code-block:: bash - dd of=ide bs=1k count=100k if=/dev/zero + U-Boot 2021.04-00963-g60279a2b1d (Apr 21 2021 - 19:54:32 +0200) - # Create partion table - sudo sfdisk ide << EOF - label: dos - label-id: 0x6fe3a999 - device: image - unit: sectors - image1 : start= 63, size= 32067, Id=83 - image2 : start= 32130, size= 32130, Id=83 - image3 : start= 64260, size= 4128705, Id=83 - EOF + Board: MIPS Malta CoreLV + DRAM: 256 MiB + Flash: 4 MiB + Loading Environment from Flash... *** Warning - bad CRC, using default environment -Copy to ide -^^^^^^^^^^^ + In: serial@3f8 + Out: serial@3f8 + Err: serial@3f8 + Net: pcnet#0 + IDE: Bus 0: not available + maltael # -.. code-block:: bash - - dd if=uImage bs=512 conv=notrunc seek=63 of=ide +How to debug U-Boot +------------------- -Generate ext2 on part 2 on Copy uImage and initrd.gz -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +In order to debug U-Boot you need to start qemu with gdb server support (-s) +and waiting the connection to start the CPU (-S). Start Qemu in the first console: .. code-block:: bash - # Attached as loop device ide offset = 32130 * 512 - sudo losetup -o 16450560 /dev/loop0 ide - # Format as ext2 ( arg2 : nb blocks) - sudo mkfs.ext2 /dev/loop0 16065 - sudo losetup -d /dev/loop0 - # Mount and copy uImage and initrd.gz to it - sudo mount -o loop,offset=16450560 -t ext2 ide /mnt - sudo mkdir /mnt/boot - cp {initrd.gz,uImage} /mnt/boot/ - # Umount it - sudo umount /mnt - -Set Environment -^^^^^^^^^^^^^^^ - -.. code-block:: bash + mkdir tftproot + ${QEMU_BIN} -s -S -nographic -cpu ${QEMU_CPU} -m 256 -drive if=pflash,file="$(pwd)/pflash.img",format=raw -netdev user,id=net0,tftp="$(pwd)/tftproot" -device pcnet,netdev=net0 - setenv rd_start 0x80800000 - setenv rd_size 2663940 - setenv kernel BFC38000 - setenv oad_addr 80500000 - setenv load_addr2 80F00000 - setenv kernel_flash BFC38000 - setenv load_addr_hello 80200000 - setenv bootargs 'root=/dev/ram0 init=/bin/sh' - setenv load_rd_ext2 'ide res; ext2load ide 0:2 ${rd_start} /boot/initrd.gz' - setenv load_rd_tftp 'tftp ${rd_start} /initrd.gz' - setenv load_kernel_hda 'ide res; diskboot ${load_addr} 0:2' - setenv load_kernel_ext2 'ide res; ext2load ide 0:2 ${load_addr} /boot/uImage' - setenv load_kernel_tftp 'tftp ${load_addr} /qemu_mips/uImage' - setenv boot_ext2_ext2 'run load_rd_ext2; run load_kernel_ext2; run addmisc; bootm ${load_addr}' - setenv boot_ext2_flash 'run load_rd_ext2; run addmisc; bootm ${kernel_flash}' - setenv boot_ext2_hda 'run load_rd_ext2; run load_kernel_hda; run addmisc; bootm ${load_addr}' - setenv boot_ext2_tftp 'run load_rd_ext2; run load_kernel_tftp; run addmisc; bootm ${load_addr}' - setenv boot_tftp_hda 'run load_rd_tftp; run load_kernel_hda; run addmisc; bootm ${load_addr}' - setenv boot_tftp_ext2 'run load_rd_tftp; run load_kernel_ext2; run addmisc; bootm ${load_addr}' - setenv boot_tftp_flash 'run load_rd_tftp; run addmisc; bootm ${kernel_flash}' - setenv boot_tftp_tftp 'run load_rd_tftp; run load_kernel_tftp; run addmisc; bootm ${load_addr}' - setenv load_hello_tftp 'tftp ${load_addr_hello} /examples/hello_world.bin' - setenv go_tftp 'run load_hello_tftp; go ${load_addr_hello}' - setenv addmisc 'setenv bootargs ${bootargs} console=ttyS0,${baudrate} rd_start=${rd_start} rd_size=${rd_size} ethaddr=${ethaddr}' - setenv bootcmd 'run boot_tftp_flash' - -Now you can boot from flash, ide, ide+ext2 and tfp +In the second console start gdb: .. code-block:: bash - qemu-system-mips -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide - - -How to debug U-Boot -------------------- - -In order to debug U-Boot you need to start qemu with gdb server support (-s) -and waiting the connection to start the CPU (-S) + gdb-multiarch --eval-command "target remote :1234" u-boot .. code-block:: bash - qemu-system-mips -S -s -M mips -pflash flash -monitor null -nographic -net nic -net user -tftp `pwd` -hda ide - -in an other console you start gdb - -Debugging of U-Boot Before Relocation -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Before relocation, the addresses in the ELF file can be used without any problems -by connecting to the gdb server localhost:1234 - -.. code-block:: none - - $ mipsel-unknown-linux-gnu-gdb u-boot - GNU gdb 6.6 - Copyright (C) 2006 Free Software Foundation, Inc. - GDB is free software, covered by the GNU General Public License, and you are - welcome to change it and/or distribute copies of it under certain conditions. - Type "show copying" to see the conditions. - There is absolutely no warranty for GDB. Type "show warranty" for details. - This GDB was configured as "--host=i486-linux-gnu --target=mipsel-unknown-linux-gnu"... - (gdb) target remote localhost:1234 - Remote debugging using localhost:1234 - _start () at start.S:64 - 64 RVECENT(reset,0) /* U-Boot entry point */ - Current language: auto; currently asm - (gdb) b board.c:289 - Breakpoint 1 at 0xbfc00cc8: file board.c, line 289. - (gdb) c - Continuing. - - Breakpoint 1, board_init_f (bootflag=<value optimized out>) at board.c:290 - 290 relocate_code (addr_sp, id, addr); - Current language: auto; currently c - (gdb) p/x addr - $1 = 0x87fa0000 - -Debugging of U-Boot After Relocation -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For debugging U-Boot after relocation we need to know the address to which -U-Boot relocates itself to 0x87fa0000 by default. -And replace the symbol table to this offset. - -.. code-block:: none - - (gdb) symbol-file - Discard symbol table from `/private/u-boot-arm/u-boot'? (y or n) y - Error in re-setting breakpoint 1: - No symbol table is loaded. Use the "file" command. - No symbol file now. - (gdb) add-symbol-file u-boot 0x87fa0000 - add symbol table from file "u-boot" at - .text_addr = 0x87fa0000 - (y or n) y - Reading symbols from /private/u-boot-arm/u-boot...done. - Breakpoint 1 at 0x87fa0cc8: file board.c, line 289. - (gdb) c - Continuing. - - Program received signal SIGINT, Interrupt. - 0xffffffff87fa0de4 in udelay (usec=<value optimized out>) at time.c:78 - 78 while ((tmo - read_c0_count()) < 0x7fffffff) + GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2 + Copyright (C) 2020 Free Software Foundation, Inc. + License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> + This is free software: you are free to change and redistribute it. + There is NO WARRANTY, to the extent permitted by law. + Type "show copying" and "show warranty" for details. + This GDB was configured as "x86_64-linux-gnu". + Type "show configuration" for configuration details. + For bug reporting instructions, please see: + <http://www.gnu.org/software/gdb/bugs/>. + Find the GDB manual and other documentation resources online at: + <http://www.gnu.org/software/gdb/documentation/>. + + For help, type "help". + Type "apropos word" to search for commands related to "word"... + Reading symbols from u-boot... + Remote debugging using :1234 + 0xbfc00000 in ?? () + (gdb) c + Continuing. diff --git a/doc/usage/mmc.rst b/doc/usage/mmc.rst index 57284ed674..458c7642c0 100644 --- a/doc/usage/mmc.rst +++ b/doc/usage/mmc.rst @@ -40,7 +40,7 @@ The 'mmc write' command writes raw data to MMC device from memory address with b cnt block count -The 'mmc erase' command erases MMC device from block offset until count. +The 'mmc erase' command erases *cnt* blocks on the MMC device starting at block *blk#*. blk# start block offset @@ -110,6 +110,7 @@ The 'mmc partconf' command shows or changes PARTITION_CONFIG field. partitions to access The 'mmc bootpart-resize' command changes sizes of boot and RPMB partitions. + dev device number boot part size MB diff --git a/drivers/net/8390.h b/drivers/net/8390.h deleted file mode 100644 index f087217ed0..0000000000 --- a/drivers/net/8390.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - -Ported to U-Boot by Christian Pellegrin <chri@ascensit.com> - -Based on sources from the Linux kernel (pcnet_cs.c, 8390.h) and -eCOS(if_dp83902a.c, if_dp83902a.h). Both of these 2 wonderful world -are GPL, so this is, of course, GPL. - -*/ - -/* Generic NS8390 register definitions. */ -/* This file is part of Donald Becker's 8390 drivers, and is distributed - under the same license. Auto-loading of 8390.o only in v2.2 - Paul G. - Some of these names and comments originated from the Crynwr - packet drivers, which are distributed under the GPL. */ - -#ifndef _8390_h -#define _8390_h - -/* Some generic ethernet register configurations. */ -#define E8390_TX_IRQ_MASK 0xa /* For register EN0_ISR */ -#define E8390_RX_IRQ_MASK 0x5 -#define E8390_RXCONFIG 0x4 /* EN0_RXCR: broadcasts, no multicast,errors */ -#define E8390_RXOFF 0x20 /* EN0_RXCR: Accept no packets */ -#define E8390_TXCONFIG 0x00 /* EN0_TXCR: Normal transmit mode */ -#define E8390_TXOFF 0x02 /* EN0_TXCR: Transmitter off */ - -/* Register accessed at EN_CMD, the 8390 base addr. */ -#define E8390_STOP 0x01 /* Stop and reset the chip */ -#define E8390_START 0x02 /* Start the chip, clear reset */ -#define E8390_TRANS 0x04 /* Transmit a frame */ -#define E8390_RREAD 0x08 /* Remote read */ -#define E8390_RWRITE 0x10 /* Remote write */ -#define E8390_NODMA 0x20 /* Remote DMA */ -#define E8390_PAGE0 0x00 /* Select page chip registers */ -#define E8390_PAGE1 0x40 /* using the two high-order bits */ -#define E8390_PAGE2 0x80 /* Page 3 is invalid. */ - -/* - * Only generate indirect loads given a machine that needs them. - * - removed AMIGA_PCMCIA from this list, handled as ISA io now - */ - -#define n2k_inb(port) (*((volatile unsigned char *)(port+CONFIG_DRIVER_NE2000_BASE))) -#define n2k_outb(val,port) (*((volatile unsigned char *)(port+CONFIG_DRIVER_NE2000_BASE)) = val) - -#define EI_SHIFT(x) (x) - -#define E8390_CMD EI_SHIFT(0x00) /* The command register (for all pages) */ -/* Page 0 register offsets. */ -#define EN0_CLDALO EI_SHIFT(0x01) /* Low byte of current local dma addr RD */ -#define EN0_STARTPG EI_SHIFT(0x01) /* Starting page of ring bfr WR */ -#define EN0_CLDAHI EI_SHIFT(0x02) /* High byte of current local dma addr RD */ -#define EN0_STOPPG EI_SHIFT(0x02) /* Ending page +1 of ring bfr WR */ -#define EN0_BOUNDARY EI_SHIFT(0x03) /* Boundary page of ring bfr RD WR */ -#define EN0_TSR EI_SHIFT(0x04) /* Transmit status reg RD */ -#define EN0_TPSR EI_SHIFT(0x04) /* Transmit starting page WR */ -#define EN0_NCR EI_SHIFT(0x05) /* Number of collision reg RD */ -#define EN0_TCNTLO EI_SHIFT(0x05) /* Low byte of tx byte count WR */ -#define EN0_FIFO EI_SHIFT(0x06) /* FIFO RD */ -#define EN0_TCNTHI EI_SHIFT(0x06) /* High byte of tx byte count WR */ -#define EN0_ISR EI_SHIFT(0x07) /* Interrupt status reg RD WR */ -#define EN0_CRDALO EI_SHIFT(0x08) /* low byte of current remote dma address RD */ -#define EN0_RSARLO EI_SHIFT(0x08) /* Remote start address reg 0 */ -#define EN0_CRDAHI EI_SHIFT(0x09) /* high byte, current remote dma address RD */ -#define EN0_RSARHI EI_SHIFT(0x09) /* Remote start address reg 1 */ -#define EN0_RCNTLO EI_SHIFT(0x0a) /* Remote byte count reg WR */ -#define EN0_RCNTHI EI_SHIFT(0x0b) /* Remote byte count reg WR */ -#define EN0_RSR EI_SHIFT(0x0c) /* rx status reg RD */ -#define EN0_RXCR EI_SHIFT(0x0c) /* RX configuration reg WR */ -#define EN0_TXCR EI_SHIFT(0x0d) /* TX configuration reg WR */ -#define EN0_COUNTER0 EI_SHIFT(0x0d) /* Rcv alignment error counter RD */ -#define EN0_DCFG EI_SHIFT(0x0e) /* Data configuration reg WR */ -#define EN0_COUNTER1 EI_SHIFT(0x0e) /* Rcv CRC error counter RD */ -#define EN0_IMR EI_SHIFT(0x0f) /* Interrupt mask reg WR */ -#define EN0_COUNTER2 EI_SHIFT(0x0f) /* Rcv missed frame error counter RD */ - -/* Bits in EN0_ISR - Interrupt status register */ -#define ENISR_RX 0x01 /* Receiver, no error */ -#define ENISR_TX 0x02 /* Transmitter, no error */ -#define ENISR_RX_ERR 0x04 /* Receiver, with error */ -#define ENISR_TX_ERR 0x08 /* Transmitter, with error */ -#define ENISR_OVER 0x10 /* Receiver overwrote the ring */ -#define ENISR_COUNTERS 0x20 /* Counters need emptying */ -#define ENISR_RDC 0x40 /* remote dma complete */ -#define ENISR_RESET 0x80 /* Reset completed */ -#define ENISR_ALL 0x3f /* Interrupts we will enable */ - -/* Bits in EN0_DCFG - Data config register */ -#define ENDCFG_WTS 0x01 /* word transfer mode selection */ -#define ENDCFG_BOS 0x02 /* byte order selection */ -#define ENDCFG_AUTO_INIT 0x10 /* Auto-init to remove packets from ring */ -#define ENDCFG_FIFO 0x40 /* 8 bytes */ - -/* Page 1 register offsets. */ -#define EN1_PHYS EI_SHIFT(0x01) /* This board's physical enet addr RD WR */ -#define EN1_PHYS_SHIFT(i) EI_SHIFT(i+1) /* Get and set mac address */ -#define EN1_CURPAG EI_SHIFT(0x07) /* Current memory page RD WR */ -#define EN1_MULT EI_SHIFT(0x08) /* Multicast filter mask array (8 bytes) RD WR */ -#define EN1_MULT_SHIFT(i) EI_SHIFT(8+i) /* Get and set multicast filter */ - -/* Bits in received packet status byte and EN0_RSR*/ -#define ENRSR_RXOK 0x01 /* Received a good packet */ -#define ENRSR_CRC 0x02 /* CRC error */ -#define ENRSR_FAE 0x04 /* frame alignment error */ -#define ENRSR_FO 0x08 /* FIFO overrun */ -#define ENRSR_MPA 0x10 /* missed pkt */ -#define ENRSR_PHY 0x20 /* physical/multicast address */ -#define ENRSR_DIS 0x40 /* receiver disable. set in monitor mode */ -#define ENRSR_DEF 0x80 /* deferring */ - -/* Transmitted packet status, EN0_TSR. */ -#define ENTSR_PTX 0x01 /* Packet transmitted without error */ -#define ENTSR_ND 0x02 /* The transmit wasn't deferred. */ -#define ENTSR_COL 0x04 /* The transmit collided at least once. */ -#define ENTSR_ABT 0x08 /* The transmit collided 16 times, and was deferred. */ -#define ENTSR_CRS 0x10 /* The carrier sense was lost. */ -#define ENTSR_FU 0x20 /* A "FIFO underrun" occurred during transmit. */ -#define ENTSR_CDH 0x40 /* The collision detect "heartbeat" signal was lost. */ -#define ENTSR_OWC 0x80 /* There was an out-of-window collision. */ - -#define NIC_RECEIVE_MONITOR_MODE 0x20 - -#endif /* _8390_h */ diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 2ce89f7e3c..a44a7d3f56 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -56,7 +56,6 @@ obj-$(CONFIG_MVMDIO) += mvmdio.o obj-$(CONFIG_MVNETA) += mvneta.o obj-$(CONFIG_MVPP2) += mvpp2.o obj-$(CONFIG_NATSEMI) += natsemi.o -obj-$(CONFIG_DRIVER_NE2000) += ne2000.o ne2000_base.o obj-$(CONFIG_NETCONSOLE) += netconsole.o obj-$(CONFIG_NS8382X) += ns8382x.o obj-$(CONFIG_PCH_GBE) += pch_gbe.o diff --git a/drivers/net/ne2000.c b/drivers/net/ne2000.c deleted file mode 100644 index 28a99bb8c4..0000000000 --- a/drivers/net/ne2000.c +++ /dev/null @@ -1,260 +0,0 @@ -/* -Ported to U-Boot by Christian Pellegrin <chri@ascensit.com> - -Based on sources from the Linux kernel (pcnet_cs.c, 8390.h) and -eCOS(if_dp83902a.c, if_dp83902a.h). Both of these 2 wonderful world -are GPL, so this is, of course, GPL. - -========================================================================== - -dev/if_dp83902a.c - -Ethernet device driver for NS DP83902a ethernet controller - -========================================================================== -####ECOSGPLCOPYRIGHTBEGIN#### -------------------------------------------- -This file is part of eCos, the Embedded Configurable Operating System. -Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. - -eCos is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2 or (at your option) any later version. - -eCos is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License along -with eCos; if not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - -As a special exception, if other files instantiate templates or use macros -or inline functions from this file, or you compile this file and link it -with other works to produce a work based on this file, this file does not -by itself cause the resulting work to be covered by the GNU General Public -License. However the source code for this file must still be made available -in accordance with section (3) of the GNU General Public License. - -This exception does not invalidate any other reasons why a work based on -this file might be covered by the GNU General Public License. - -Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. -at http://sources.redhat.com/ecos/ecos-license/ -------------------------------------------- -####ECOSGPLCOPYRIGHTEND#### -####BSDCOPYRIGHTBEGIN#### - -------------------------------------------- - -Portions of this software may have been derived from OpenBSD or other sources, -and are covered by the appropriate copyright disclaimers included herein. - -------------------------------------------- - -####BSDCOPYRIGHTEND#### -========================================================================== -#####DESCRIPTIONBEGIN#### - -Author(s): gthomas -Contributors: gthomas, jskov, rsandifo -Date: 2001-06-13 -Purpose: -Description: - -FIXME: Will fail if pinged with large packets (1520 bytes) -Add promisc config -Add SNMP - -####DESCRIPTIONEND#### - -========================================================================== -*/ - -#include <common.h> -#include <command.h> -#include <linux/delay.h> - -/* NE2000 base header file */ -#include "ne2000_base.h" - -/* find prom (taken from pc_net_cs.c from Linux) */ - -#include "8390.h" -/* -typedef struct hw_info_t { - u_int offset; - u_char a0, a1, a2; - u_int flags; -} hw_info_t; -*/ -#define DELAY_OUTPUT 0x01 -#define HAS_MISC_REG 0x02 -#define USE_BIG_BUF 0x04 -#define HAS_IBM_MISC 0x08 -#define IS_DL10019 0x10 -#define IS_DL10022 0x20 -#define HAS_MII 0x40 -#define USE_SHMEM 0x80 /* autodetected */ - -#define AM79C9XX_HOME_PHY 0x00006B90 /* HomePNA PHY */ -#define AM79C9XX_ETH_PHY 0x00006B70 /* 10baseT PHY */ -#define MII_PHYID_REV_MASK 0xfffffff0 -#define MII_PHYID_REG1 0x02 -#define MII_PHYID_REG2 0x03 - -static hw_info_t hw_info[] = { - { /* Accton EN2212 */ 0x0ff0, 0x00, 0x00, 0xe8, DELAY_OUTPUT }, - { /* Allied Telesis LA-PCM */ 0x0ff0, 0x00, 0x00, 0xf4, 0 }, - { /* APEX MultiCard */ 0x03f4, 0x00, 0x20, 0xe5, 0 }, - { /* ASANTE FriendlyNet */ 0x4910, 0x00, 0x00, 0x94, - DELAY_OUTPUT | HAS_IBM_MISC }, - { /* Danpex EN-6200P2 */ 0x0110, 0x00, 0x40, 0xc7, 0 }, - { /* DataTrek NetCard */ 0x0ff0, 0x00, 0x20, 0xe8, 0 }, - { /* Dayna CommuniCard E */ 0x0110, 0x00, 0x80, 0x19, 0 }, - { /* D-Link DE-650 */ 0x0040, 0x00, 0x80, 0xc8, 0 }, - { /* EP-210 Ethernet */ 0x0110, 0x00, 0x40, 0x33, 0 }, - { /* EP4000 Ethernet */ 0x01c0, 0x00, 0x00, 0xb4, 0 }, - { /* Epson EEN10B */ 0x0ff0, 0x00, 0x00, 0x48, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* ELECOM Laneed LD-CDWA */ 0xb8, 0x08, 0x00, 0x42, 0 }, - { /* Hypertec Ethernet */ 0x01c0, 0x00, 0x40, 0x4c, 0 }, - { /* IBM CCAE */ 0x0ff0, 0x08, 0x00, 0x5a, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* IBM CCAE */ 0x0ff0, 0x00, 0x04, 0xac, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* IBM CCAE */ 0x0ff0, 0x00, 0x06, 0x29, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* IBM FME */ 0x0374, 0x08, 0x00, 0x5a, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* IBM FME */ 0x0374, 0x00, 0x04, 0xac, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* Kansai KLA-PCM/T */ 0x0ff0, 0x00, 0x60, 0x87, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* NSC DP83903 */ 0x0374, 0x08, 0x00, 0x17, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* NSC DP83903 */ 0x0374, 0x00, 0xc0, 0xa8, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* NSC DP83903 */ 0x0374, 0x00, 0xa0, 0xb0, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* NSC DP83903 */ 0x0198, 0x00, 0x20, 0xe0, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* I-O DATA PCLA/T */ 0x0ff0, 0x00, 0xa0, 0xb0, 0 }, - { /* Katron PE-520 */ 0x0110, 0x00, 0x40, 0xf6, 0 }, - { /* Kingston KNE-PCM/x */ 0x0ff0, 0x00, 0xc0, 0xf0, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* Kingston KNE-PCM/x */ 0x0ff0, 0xe2, 0x0c, 0x0f, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* Kingston KNE-PC2 */ 0x0180, 0x00, 0xc0, 0xf0, 0 }, - { /* Maxtech PCN2000 */ 0x5000, 0x00, 0x00, 0xe8, 0 }, - { /* NDC Instant-Link */ 0x003a, 0x00, 0x80, 0xc6, 0 }, - { /* NE2000 Compatible */ 0x0ff0, 0x00, 0xa0, 0x0c, 0 }, - { /* Network General Sniffer */ 0x0ff0, 0x00, 0x00, 0x65, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* Panasonic VEL211 */ 0x0ff0, 0x00, 0x80, 0x45, - HAS_MISC_REG | HAS_IBM_MISC }, - { /* PreMax PE-200 */ 0x07f0, 0x00, 0x20, 0xe0, 0 }, - { /* RPTI EP400 */ 0x0110, 0x00, 0x40, 0x95, 0 }, - { /* SCM Ethernet */ 0x0ff0, 0x00, 0x20, 0xcb, 0 }, - { /* Socket EA */ 0x4000, 0x00, 0xc0, 0x1b, - DELAY_OUTPUT | HAS_MISC_REG | USE_BIG_BUF }, - { /* Socket LP-E CF+ */ 0x01c0, 0x00, 0xc0, 0x1b, 0 }, - { /* SuperSocket RE450T */ 0x0110, 0x00, 0xe0, 0x98, 0 }, - { /* Volktek NPL-402CT */ 0x0060, 0x00, 0x40, 0x05, 0 }, - { /* NEC PC-9801N-J12 */ 0x0ff0, 0x00, 0x00, 0x4c, 0 }, - { /* PCMCIA Technology OEM */ 0x01c8, 0x00, 0xa0, 0x0c, 0 }, - { /* Qemu */ 0x0, 0x52, 0x54, 0x00, 0 }, - { /* RTL8019AS */ 0x0, 0x0, 0x18, 0x5f, 0 } -}; - -#define NR_INFO (sizeof(hw_info)/sizeof(hw_info_t)) - -#define PCNET_CMD 0x00 -#define PCNET_DATAPORT 0x10 /* NatSemi-defined port window offset. */ -#define PCNET_RESET 0x1f /* Issue a read to reset, a write to clear. */ -#define PCNET_MISC 0x18 /* For IBM CCAE and Socket EA cards */ - -static void pcnet_reset_8390(u8* addr) -{ - int i, r; - - n2k_outb(E8390_NODMA + E8390_PAGE0+E8390_STOP, E8390_CMD); - PRINTK("cmd (at %lx) is %x\n", addr + E8390_CMD, n2k_inb(E8390_CMD)); - n2k_outb(E8390_NODMA+E8390_PAGE1+E8390_STOP, E8390_CMD); - PRINTK("cmd (at %lx) is %x\n", addr + E8390_CMD, n2k_inb(E8390_CMD)); - n2k_outb(E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD); - PRINTK("cmd (at %lx) is %x\n", addr + E8390_CMD, n2k_inb(E8390_CMD)); - n2k_outb(E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD); - - n2k_outb(n2k_inb(PCNET_RESET), PCNET_RESET); - - for (i = 0; i < 100; i++) { - if ((r = (n2k_inb(EN0_ISR) & ENISR_RESET)) != 0) - break; - PRINTK("got %x in reset\n", r); - udelay(100); - } - n2k_outb(ENISR_RESET, EN0_ISR); /* Ack intr. */ - - if (i == 100) - printf("pcnet_reset_8390() did not complete.\n"); -} /* pcnet_reset_8390 */ - -int get_prom(u8* mac_addr, u8* base_addr) -{ - u8 prom[32]; - int i, j; - struct { - u_char value, offset; - } program_seq[] = { - {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/ - {0x48, EN0_DCFG}, /* Set byte-wide (0x48) access. */ - {0x00, EN0_RCNTLO}, /* Clear the count regs. */ - {0x00, EN0_RCNTHI}, - {0x00, EN0_IMR}, /* Mask completion irq. */ - {0xFF, EN0_ISR}, - {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */ - {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */ - {32, EN0_RCNTLO}, - {0x00, EN0_RCNTHI}, - {0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */ - {0x00, EN0_RSARHI}, - {E8390_RREAD+E8390_START, E8390_CMD}, - }; - - PRINTK ("trying to get MAC via prom reading\n"); - - pcnet_reset_8390 (base_addr); - - mdelay (10); - - for (i = 0; i < ARRAY_SIZE(program_seq); i++) - n2k_outb (program_seq[i].value, program_seq[i].offset); - - PRINTK ("PROM:"); - for (i = 0; i < 32; i++) { - prom[i] = n2k_inb (PCNET_DATAPORT); - PRINTK (" %02x", prom[i]); - } - PRINTK ("\n"); - for (i = 0; i < NR_INFO; i++) { - if ((prom[0] == hw_info[i].a0) && - (prom[2] == hw_info[i].a1) && - (prom[4] == hw_info[i].a2)) { - PRINTK ("matched board %d\n", i); - break; - } - } - if ((i < NR_INFO) || ((prom[28] == 0x57) && (prom[30] == 0x57))) { - PRINTK ("on exit i is %d/%ld\n", i, NR_INFO); - PRINTK ("MAC address is "); - for (j = 0; j < 6; j++) { - mac_addr[j] = prom[j << 1]; - PRINTK ("%02x:", mac_addr[i]); - } - PRINTK ("\n"); - return (i < NR_INFO) ? i : 0; - } - return 0; -} diff --git a/drivers/net/ne2000.h b/drivers/net/ne2000.h deleted file mode 100644 index 2cde6be437..0000000000 --- a/drivers/net/ne2000.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -Ported to U-Boot by Christian Pellegrin <chri@ascensit.com> - -Based on sources from the Linux kernel (pcnet_cs.c, 8390.h) and -eCOS(if_dp83902a.c, if_dp83902a.h). Both of these 2 wonderful world -are GPL, so this is, of course, GPL. - -========================================================================== - - dev/dp83902a.h - - National Semiconductor DP83902a ethernet chip - -========================================================================== -####ECOSGPLCOPYRIGHTBEGIN#### - ------------------------------------------- - This file is part of eCos, the Embedded Configurable Operating System. - Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. - - eCos is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 or (at your option) any later version. - - eCos is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with eCos; if not, write to the Free Software Foundation, Inc., - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - - As a special exception, if other files instantiate templates or use macros - or inline functions from this file, or you compile this file and link it - with other works to produce a work based on this file, this file does not - by itself cause the resulting work to be covered by the GNU General Public - License. However the source code for this file must still be made available - in accordance with section (3) of the GNU General Public License. - - This exception does not invalidate any other reasons why a work based on - this file might be covered by the GNU General Public License. - - Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. - at http://sources.redhat.com/ecos/ecos-license/ - ------------------------------------------- -####ECOSGPLCOPYRIGHTEND#### -####BSDCOPYRIGHTBEGIN#### - - ------------------------------------------- - - Portions of this software may have been derived from OpenBSD or other sources, - and are covered by the appropriate copyright disclaimers included herein. - - ------------------------------------------- - -####BSDCOPYRIGHTEND#### -========================================================================== -#####DESCRIPTIONBEGIN#### - - Author(s): gthomas - Contributors: gthomas, jskov - Date: 2001-06-13 - Purpose: - Description: - -####DESCRIPTIONEND#### - -========================================================================== -*/ - -/* - * NE2000 support header file. - * Created by Nobuhiro Iwamatsu <iwamatsu@nigauri.org> - */ - -#ifndef __DRIVERS_NE2000_H__ -#define __DRIVERS_NE2000_H__ - -/* Enable NE2000 basic init function */ -#define NE2000_BASIC_INIT - -#define DP_DATA 0x10 -#define START_PG 0x50 /* First page of TX buffer */ -#define START_PG2 0x48 -#define STOP_PG 0x80 /* Last page +1 of RX ring */ - -#define RX_START 0x50 -#define RX_END 0x80 - -#define DP_IN(_b_, _o_, _d_) (_d_) = *( (vu_char *) ((_b_)+(_o_))) -#define DP_OUT(_b_, _o_, _d_) *( (vu_char *) ((_b_)+(_o_))) = (_d_) -#define DP_IN_DATA(_b_, _d_) (_d_) = *( (vu_char *) ((_b_))) -#define DP_OUT_DATA(_b_, _d_) *( (vu_char *) ((_b_))) = (_d_) -#endif /* __DRIVERS_NE2000_H__ */ diff --git a/drivers/net/ne2000_base.c b/drivers/net/ne2000_base.c deleted file mode 100644 index f6673f5e4c..0000000000 --- a/drivers/net/ne2000_base.c +++ /dev/null @@ -1,792 +0,0 @@ -/* -Ported to U-Boot by Christian Pellegrin <chri@ascensit.com> - -Based on sources from the Linux kernel (pcnet_cs.c, 8390.h) and -eCOS(if_dp83902a.c, if_dp83902a.h). Both of these 2 wonderful world -are GPL, so this is, of course, GPL. - -========================================================================== - -dev/if_dp83902a.c - -Ethernet device driver for NS DP83902a ethernet controller - -========================================================================== -####ECOSGPLCOPYRIGHTBEGIN#### -------------------------------------------- -This file is part of eCos, the Embedded Configurable Operating System. -Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. - -eCos is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2 or (at your option) any later version. - -eCos is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License along -with eCos; if not, write to the Free Software Foundation, Inc., -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - -As a special exception, if other files instantiate templates or use macros -or inline functions from this file, or you compile this file and link it -with other works to produce a work based on this file, this file does not -by itself cause the resulting work to be covered by the GNU General Public -License. However the source code for this file must still be made available -in accordance with section (3) of the GNU General Public License. - -This exception does not invalidate any other reasons why a work based on -this file might be covered by the GNU General Public License. - -Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. -at http://sources.redhat.com/ecos/ecos-license/ -------------------------------------------- -####ECOSGPLCOPYRIGHTEND#### -####BSDCOPYRIGHTBEGIN#### - -------------------------------------------- - -Portions of this software may have been derived from OpenBSD or other sources, -and are covered by the appropriate copyright disclaimers included herein. - -------------------------------------------- - -####BSDCOPYRIGHTEND#### -========================================================================== -#####DESCRIPTIONBEGIN#### - -Author(s): gthomas -Contributors: gthomas, jskov, rsandifo -Date: 2001-06-13 -Purpose: -Description: - -FIXME: Will fail if pinged with large packets (1520 bytes) -Add promisc config -Add SNMP - -####DESCRIPTIONEND#### - -========================================================================== -*/ - -#include <common.h> -#include <command.h> -#include <env.h> -#include <log.h> -#include <net.h> -#include <malloc.h> -#include <linux/compiler.h> - -/* forward definition of function used for the uboot interface */ -void uboot_push_packet_len(int len); -void uboot_push_tx_done(int key, int val); - -/* NE2000 base header file */ -#include "ne2000_base.h" - -#if defined(CONFIG_DRIVER_AX88796L) -/* AX88796L support */ -#include "ax88796.h" -#else -/* Basic NE2000 chip support */ -#include "ne2000.h" -#endif - -static dp83902a_priv_data_t nic; /* just one instance of the card supported */ - -/** - * This function reads the MAC address from the serial EEPROM, - * used if PROM read fails. Does nothing for ax88796 chips (sh boards) - */ -static bool -dp83902a_init(unsigned char *enetaddr) -{ - dp83902a_priv_data_t *dp = &nic; - u8* base; -#if defined(NE2000_BASIC_INIT) - int i; -#endif - - DEBUG_FUNCTION(); - - base = dp->base; - if (!base) - return false; /* No device found */ - - DEBUG_LINE(); - -#if defined(NE2000_BASIC_INIT) - /* AX88796L doesn't need */ - /* Prepare ESA */ - DP_OUT(base, DP_CR, DP_CR_NODMA | DP_CR_PAGE1); /* Select page 1 */ - /* Use the address from the serial EEPROM */ - for (i = 0; i < 6; i++) - DP_IN(base, DP_P1_PAR0+i, dp->esa[i]); - DP_OUT(base, DP_CR, DP_CR_NODMA | DP_CR_PAGE0); /* Select page 0 */ - - printf("NE2000 - %s ESA: %02x:%02x:%02x:%02x:%02x:%02x\n", - "eeprom", - dp->esa[0], - dp->esa[1], - dp->esa[2], - dp->esa[3], - dp->esa[4], - dp->esa[5] ); - - memcpy(enetaddr, dp->esa, 6); /* Use MAC from serial EEPROM */ -#endif /* NE2000_BASIC_INIT */ - return true; -} - -static void -dp83902a_stop(void) -{ - dp83902a_priv_data_t *dp = &nic; - u8 *base = dp->base; - - DEBUG_FUNCTION(); - - DP_OUT(base, DP_CR, DP_CR_PAGE0 | DP_CR_NODMA | DP_CR_STOP); /* Brutal */ - DP_OUT(base, DP_ISR, 0xFF); /* Clear any pending interrupts */ - DP_OUT(base, DP_IMR, 0x00); /* Disable all interrupts */ - - dp->running = false; -} - -/* - * This function is called to "start up" the interface. It may be called - * multiple times, even when the hardware is already running. It will be - * called whenever something "hardware oriented" changes and should leave - * the hardware ready to send/receive packets. - */ -static void -dp83902a_start(u8 * enaddr) -{ - dp83902a_priv_data_t *dp = &nic; - u8 *base = dp->base; - int i; - - debug("The MAC is %pM\n", enaddr); - - DEBUG_FUNCTION(); - - DP_OUT(base, DP_CR, DP_CR_PAGE0 | DP_CR_NODMA | DP_CR_STOP); /* Brutal */ - DP_OUT(base, DP_DCR, DP_DCR_INIT); - DP_OUT(base, DP_RBCH, 0); /* Remote byte count */ - DP_OUT(base, DP_RBCL, 0); - DP_OUT(base, DP_RCR, DP_RCR_MON); /* Accept no packets */ - DP_OUT(base, DP_TCR, DP_TCR_LOCAL); /* Transmitter [virtually] off */ - DP_OUT(base, DP_TPSR, dp->tx_buf1); /* Transmitter start page */ - dp->tx1 = dp->tx2 = 0; - dp->tx_next = dp->tx_buf1; - dp->tx_started = false; - dp->running = true; - DP_OUT(base, DP_PSTART, dp->rx_buf_start); /* Receive ring start page */ - DP_OUT(base, DP_BNDRY, dp->rx_buf_end - 1); /* Receive ring boundary */ - DP_OUT(base, DP_PSTOP, dp->rx_buf_end); /* Receive ring end page */ - dp->rx_next = dp->rx_buf_start - 1; - dp->running = true; - DP_OUT(base, DP_ISR, 0xFF); /* Clear any pending interrupts */ - DP_OUT(base, DP_IMR, DP_IMR_All); /* Enable all interrupts */ - DP_OUT(base, DP_CR, DP_CR_NODMA | DP_CR_PAGE1 | DP_CR_STOP); /* Select page 1 */ - DP_OUT(base, DP_P1_CURP, dp->rx_buf_start); /* Current page - next free page for Rx */ - dp->running = true; - for (i = 0; i < ETHER_ADDR_LEN; i++) { - /* FIXME */ - /*((vu_short*)( base + ((DP_P1_PAR0 + i) * 2) + - * 0x1400)) = enaddr[i];*/ - DP_OUT(base, DP_P1_PAR0+i, enaddr[i]); - } - /* Enable and start device */ - DP_OUT(base, DP_CR, DP_CR_PAGE0 | DP_CR_NODMA | DP_CR_START); - DP_OUT(base, DP_TCR, DP_TCR_NORMAL); /* Normal transmit operations */ - DP_OUT(base, DP_RCR, DP_RCR_AB); /* Accept broadcast, no errors, no multicast */ - dp->running = true; -} - -/* - * This routine is called to start the transmitter. It is split out from the - * data handling routine so it may be called either when data becomes first - * available or when an Tx interrupt occurs - */ - -static void -dp83902a_start_xmit(int start_page, int len) -{ - dp83902a_priv_data_t *dp = (dp83902a_priv_data_t *) &nic; - u8 *base = dp->base; - - DEBUG_FUNCTION(); - -#if DEBUG & 1 - printf("Tx pkt %d len %d\n", start_page, len); - if (dp->tx_started) - printf("TX already started?!?\n"); -#endif - - DP_OUT(base, DP_ISR, (DP_ISR_TxP | DP_ISR_TxE)); - DP_OUT(base, DP_CR, DP_CR_PAGE0 | DP_CR_NODMA | DP_CR_START); - DP_OUT(base, DP_TBCL, len & 0xFF); - DP_OUT(base, DP_TBCH, len >> 8); - DP_OUT(base, DP_TPSR, start_page); - DP_OUT(base, DP_CR, DP_CR_NODMA | DP_CR_TXPKT | DP_CR_START); - - dp->tx_started = true; -} - -/* - * This routine is called to send data to the hardware. It is known a-priori - * that there is free buffer space (dp->tx_next). - */ -static void -dp83902a_send(u8 *data, int total_len, u32 key) -{ - struct dp83902a_priv_data *dp = (struct dp83902a_priv_data *) &nic; - u8 *base = dp->base; - int len, start_page, pkt_len, i, isr; -#if DEBUG & 4 - int dx; -#endif - - DEBUG_FUNCTION(); - - len = pkt_len = total_len; - if (pkt_len < IEEE_8023_MIN_FRAME) - pkt_len = IEEE_8023_MIN_FRAME; - - start_page = dp->tx_next; - if (dp->tx_next == dp->tx_buf1) { - dp->tx1 = start_page; - dp->tx1_len = pkt_len; - dp->tx1_key = key; - dp->tx_next = dp->tx_buf2; - } else { - dp->tx2 = start_page; - dp->tx2_len = pkt_len; - dp->tx2_key = key; - dp->tx_next = dp->tx_buf1; - } - -#if DEBUG & 5 - printf("TX prep page %d len %d\n", start_page, pkt_len); -#endif - - DP_OUT(base, DP_ISR, DP_ISR_RDC); /* Clear end of DMA */ - { - /* - * Dummy read. The manual sez something slightly different, - * but the code is extended a bit to do what Hitachi's monitor - * does (i.e., also read data). - */ - - __maybe_unused u16 tmp; - int len = 1; - - DP_OUT(base, DP_RSAL, 0x100 - len); - DP_OUT(base, DP_RSAH, (start_page - 1) & 0xff); - DP_OUT(base, DP_RBCL, len); - DP_OUT(base, DP_RBCH, 0); - DP_OUT(base, DP_CR, DP_CR_PAGE0 | DP_CR_RDMA | DP_CR_START); - DP_IN_DATA(dp->data, tmp); - } - -#ifdef CYGHWR_NS_DP83902A_PLF_BROKEN_TX_DMA - /* - * Stall for a bit before continuing to work around random data - * corruption problems on some platforms. - */ - CYGACC_CALL_IF_DELAY_US(1); -#endif - - /* Send data to device buffer(s) */ - DP_OUT(base, DP_RSAL, 0); - DP_OUT(base, DP_RSAH, start_page); - DP_OUT(base, DP_RBCL, pkt_len & 0xFF); - DP_OUT(base, DP_RBCH, pkt_len >> 8); - DP_OUT(base, DP_CR, DP_CR_WDMA | DP_CR_START); - - /* Put data into buffer */ -#if DEBUG & 4 - printf(" sg buf %08lx len %08x\n ", (u32)data, len); - dx = 0; -#endif - while (len > 0) { -#if DEBUG & 4 - printf(" %02x", *data); - if (0 == (++dx % 16)) printf("\n "); -#endif - - DP_OUT_DATA(dp->data, *data++); - len--; - } -#if DEBUG & 4 - printf("\n"); -#endif - if (total_len < pkt_len) { -#if DEBUG & 4 - printf(" + %d bytes of padding\n", pkt_len - total_len); -#endif - /* Padding to 802.3 length was required */ - for (i = total_len; i < pkt_len;) { - i++; - DP_OUT_DATA(dp->data, 0); - } - } - -#ifdef CYGHWR_NS_DP83902A_PLF_BROKEN_TX_DMA - /* - * After last data write, delay for a bit before accessing the - * device again, or we may get random data corruption in the last - * datum (on some platforms). - */ - CYGACC_CALL_IF_DELAY_US(1); -#endif - - /* Wait for DMA to complete */ - do { - DP_IN(base, DP_ISR, isr); - } while ((isr & DP_ISR_RDC) == 0); - - /* Then disable DMA */ - DP_OUT(base, DP_CR, DP_CR_PAGE0 | DP_CR_NODMA | DP_CR_START); - - /* Start transmit if not already going */ - if (!dp->tx_started) { - if (start_page == dp->tx1) { - dp->tx_int = 1; /* Expecting interrupt from BUF1 */ - } else { - dp->tx_int = 2; /* Expecting interrupt from BUF2 */ - } - dp83902a_start_xmit(start_page, pkt_len); - } -} - -/* - * This function is called when a packet has been received. It's job is - * to prepare to unload the packet from the hardware. Once the length of - * the packet is known, the upper layer of the driver can be told. When - * the upper layer is ready to unload the packet, the internal function - * 'dp83902a_recv' will be called to actually fetch it from the hardware. - */ -static void -dp83902a_RxEvent(void) -{ - struct dp83902a_priv_data *dp = (struct dp83902a_priv_data *) &nic; - u8 *base = dp->base; - __maybe_unused u8 rsr; - u8 rcv_hdr[4]; - int i, len, pkt, cur; - - DEBUG_FUNCTION(); - - DP_IN(base, DP_RSR, rsr); - while (true) { - /* Read incoming packet header */ - DP_OUT(base, DP_CR, DP_CR_PAGE1 | DP_CR_NODMA | DP_CR_START); - DP_IN(base, DP_P1_CURP, cur); - DP_OUT(base, DP_P1_CR, DP_CR_PAGE0 | DP_CR_NODMA | DP_CR_START); - DP_IN(base, DP_BNDRY, pkt); - - pkt += 1; - if (pkt == dp->rx_buf_end) - pkt = dp->rx_buf_start; - - if (pkt == cur) { - break; - } - DP_OUT(base, DP_RBCL, sizeof(rcv_hdr)); - DP_OUT(base, DP_RBCH, 0); - DP_OUT(base, DP_RSAL, 0); - DP_OUT(base, DP_RSAH, pkt); - if (dp->rx_next == pkt) { - if (cur == dp->rx_buf_start) - DP_OUT(base, DP_BNDRY, dp->rx_buf_end - 1); - else - DP_OUT(base, DP_BNDRY, cur - 1); /* Update pointer */ - return; - } - dp->rx_next = pkt; - DP_OUT(base, DP_ISR, DP_ISR_RDC); /* Clear end of DMA */ - DP_OUT(base, DP_CR, DP_CR_RDMA | DP_CR_START); -#ifdef CYGHWR_NS_DP83902A_PLF_BROKEN_RX_DMA - CYGACC_CALL_IF_DELAY_US(10); -#endif - - /* read header (get data size)*/ - for (i = 0; i < sizeof(rcv_hdr);) { - DP_IN_DATA(dp->data, rcv_hdr[i++]); - } - -#if DEBUG & 5 - printf("rx hdr %02x %02x %02x %02x\n", - rcv_hdr[0], rcv_hdr[1], rcv_hdr[2], rcv_hdr[3]); -#endif - len = ((rcv_hdr[3] << 8) | rcv_hdr[2]) - sizeof(rcv_hdr); - - /* data read */ - uboot_push_packet_len(len); - - if (rcv_hdr[1] == dp->rx_buf_start) - DP_OUT(base, DP_BNDRY, dp->rx_buf_end - 1); - else - DP_OUT(base, DP_BNDRY, rcv_hdr[1] - 1); /* Update pointer */ - } -} - -/* - * This function is called as a result of the "eth_drv_recv()" call above. - * It's job is to actually fetch data for a packet from the hardware once - * memory buffers have been allocated for the packet. Note that the buffers - * may come in pieces, using a scatter-gather list. This allows for more - * efficient processing in the upper layers of the stack. - */ -static void -dp83902a_recv(u8 *data, int len) -{ - struct dp83902a_priv_data *dp = (struct dp83902a_priv_data *) &nic; - u8 *base = dp->base; - int i, mlen; - u8 saved_char = 0; - bool saved; -#if DEBUG & 4 - int dx; -#endif - - DEBUG_FUNCTION(); - -#if DEBUG & 5 - printf("Rx packet %d length %d\n", dp->rx_next, len); -#endif - - /* Read incoming packet data */ - DP_OUT(base, DP_CR, DP_CR_PAGE0 | DP_CR_NODMA | DP_CR_START); - DP_OUT(base, DP_RBCL, len & 0xFF); - DP_OUT(base, DP_RBCH, len >> 8); - DP_OUT(base, DP_RSAL, 4); /* Past header */ - DP_OUT(base, DP_RSAH, dp->rx_next); - DP_OUT(base, DP_ISR, DP_ISR_RDC); /* Clear end of DMA */ - DP_OUT(base, DP_CR, DP_CR_RDMA | DP_CR_START); -#ifdef CYGHWR_NS_DP83902A_PLF_BROKEN_RX_DMA - CYGACC_CALL_IF_DELAY_US(10); -#endif - - saved = false; - for (i = 0; i < 1; i++) { - if (data) { - mlen = len; -#if DEBUG & 4 - printf(" sg buf %08lx len %08x \n", (u32) data, mlen); - dx = 0; -#endif - while (0 < mlen) { - /* Saved byte from previous loop? */ - if (saved) { - *data++ = saved_char; - mlen--; - saved = false; - continue; - } - - { - u8 tmp; - DP_IN_DATA(dp->data, tmp); -#if DEBUG & 4 - printf(" %02x", tmp); - if (0 == (++dx % 16)) printf("\n "); -#endif - *data++ = tmp; - mlen--; - } - } -#if DEBUG & 4 - printf("\n"); -#endif - } - } -} - -static void -dp83902a_TxEvent(void) -{ - struct dp83902a_priv_data *dp = (struct dp83902a_priv_data *) &nic; - u8 *base = dp->base; - __maybe_unused u8 tsr; - u32 key; - - DEBUG_FUNCTION(); - - DP_IN(base, DP_TSR, tsr); - if (dp->tx_int == 1) { - key = dp->tx1_key; - dp->tx1 = 0; - } else { - key = dp->tx2_key; - dp->tx2 = 0; - } - /* Start next packet if one is ready */ - dp->tx_started = false; - if (dp->tx1) { - dp83902a_start_xmit(dp->tx1, dp->tx1_len); - dp->tx_int = 1; - } else if (dp->tx2) { - dp83902a_start_xmit(dp->tx2, dp->tx2_len); - dp->tx_int = 2; - } else { - dp->tx_int = 0; - } - /* Tell higher level we sent this packet */ - uboot_push_tx_done(key, 0); -} - -/* - * Read the tally counters to clear them. Called in response to a CNT - * interrupt. - */ -static void -dp83902a_ClearCounters(void) -{ - struct dp83902a_priv_data *dp = (struct dp83902a_priv_data *) &nic; - u8 *base = dp->base; - __maybe_unused u8 cnt1, cnt2, cnt3; - - DP_IN(base, DP_FER, cnt1); - DP_IN(base, DP_CER, cnt2); - DP_IN(base, DP_MISSED, cnt3); - DP_OUT(base, DP_ISR, DP_ISR_CNT); -} - -/* - * Deal with an overflow condition. This code follows the procedure set - * out in section 7.0 of the datasheet. - */ -static void -dp83902a_Overflow(void) -{ - struct dp83902a_priv_data *dp = (struct dp83902a_priv_data *)&nic; - u8 *base = dp->base; - u8 isr; - - /* Issue a stop command and wait 1.6ms for it to complete. */ - DP_OUT(base, DP_CR, DP_CR_STOP | DP_CR_NODMA); - CYGACC_CALL_IF_DELAY_US(1600); - - /* Clear the remote byte counter registers. */ - DP_OUT(base, DP_RBCL, 0); - DP_OUT(base, DP_RBCH, 0); - - /* Enter loopback mode while we clear the buffer. */ - DP_OUT(base, DP_TCR, DP_TCR_LOCAL); - DP_OUT(base, DP_CR, DP_CR_START | DP_CR_NODMA); - - /* - * Read in as many packets as we can and acknowledge any and receive - * interrupts. Since the buffer has overflowed, a receive event of - * some kind will have occurred. - */ - dp83902a_RxEvent(); - DP_OUT(base, DP_ISR, DP_ISR_RxP|DP_ISR_RxE); - - /* Clear the overflow condition and leave loopback mode. */ - DP_OUT(base, DP_ISR, DP_ISR_OFLW); - DP_OUT(base, DP_TCR, DP_TCR_NORMAL); - - /* - * If a transmit command was issued, but no transmit event has occurred, - * restart it here. - */ - DP_IN(base, DP_ISR, isr); - if (dp->tx_started && !(isr & (DP_ISR_TxP|DP_ISR_TxE))) { - DP_OUT(base, DP_CR, DP_CR_NODMA | DP_CR_TXPKT | DP_CR_START); - } -} - -static void -dp83902a_poll(void) -{ - struct dp83902a_priv_data *dp = (struct dp83902a_priv_data *) &nic; - u8 *base = dp->base; - u8 isr; - - DP_OUT(base, DP_CR, DP_CR_NODMA | DP_CR_PAGE0 | DP_CR_START); - DP_IN(base, DP_ISR, isr); - while (0 != isr) { - /* - * The CNT interrupt triggers when the MSB of one of the error - * counters is set. We don't much care about these counters, but - * we should read their values to reset them. - */ - if (isr & DP_ISR_CNT) { - dp83902a_ClearCounters(); - } - /* - * Check for overflow. It's a special case, since there's a - * particular procedure that must be followed to get back into - * a running state.a - */ - if (isr & DP_ISR_OFLW) { - dp83902a_Overflow(); - } else { - /* - * Other kinds of interrupts can be acknowledged simply by - * clearing the relevant bits of the ISR. Do that now, then - * handle the interrupts we care about. - */ - DP_OUT(base, DP_ISR, isr); /* Clear set bits */ - if (!dp->running) break; /* Is this necessary? */ - /* - * Check for tx_started on TX event since these may happen - * spuriously it seems. - */ - if (isr & (DP_ISR_TxP|DP_ISR_TxE) && dp->tx_started) { - dp83902a_TxEvent(); - } - if (isr & (DP_ISR_RxP|DP_ISR_RxE)) { - dp83902a_RxEvent(); - } - } - DP_IN(base, DP_ISR, isr); - } -} - - -/* U-Boot specific routines */ -static u8 *pbuf = NULL; - -static int pkey = -1; -static int initialized = 0; - -void uboot_push_packet_len(int len) { - PRINTK("pushed len = %d\n", len); - if (len >= 2000) { - printf("NE2000: packet too big\n"); - return; - } - dp83902a_recv(&pbuf[0], len); - - /*Just pass it to the upper layer*/ - net_process_received_packet(&pbuf[0], len); -} - -void uboot_push_tx_done(int key, int val) { - PRINTK("pushed key = %d\n", key); - pkey = key; -} - -/** - * Setup the driver and init MAC address according to doc/README.enetaddr - * Called by ne2k_register() before registering the driver @eth layer - * - * @param struct ethdevice of this instance of the driver for dev->enetaddr - * @return 0 on success, -1 on error (causing caller to print error msg) - */ -static int ne2k_setup_driver(struct eth_device *dev) -{ - PRINTK("### ne2k_setup_driver\n"); - - if (!pbuf) { - pbuf = malloc(2000); - if (!pbuf) { - printf("Cannot allocate rx buffer\n"); - return -1; - } - } - - nic.base = (u8 *) CONFIG_DRIVER_NE2000_BASE; - - nic.data = nic.base + DP_DATA; - nic.tx_buf1 = START_PG; - nic.tx_buf2 = START_PG2; - nic.rx_buf_start = RX_START; - nic.rx_buf_end = RX_END; - - /* - * According to doc/README.enetaddr, drivers shall give priority - * to the MAC address value in the environment, so we do not read - * it from the prom or eeprom if it is specified in the environment. - */ - if (!eth_env_get_enetaddr("ethaddr", dev->enetaddr)) { - /* If the MAC address is not in the environment, get it: */ - if (!get_prom(dev->enetaddr, nic.base)) /* get MAC from prom */ - dp83902a_init(dev->enetaddr); /* fallback: seeprom */ - /* And write it into the environment otherwise eth_write_hwaddr - * returns -1 due to eth_env_get_enetaddr_by_index() failing, - * and this causes "Warning: failed to set MAC address", and - * cmd_bdinfo has no ethaddr value which it can show: */ - eth_env_set_enetaddr("ethaddr", dev->enetaddr); - } - return 0; -} - -static int ne2k_init(struct eth_device *dev, struct bd_info *bd) -{ - dp83902a_start(dev->enetaddr); - initialized = 1; - return 0; -} - -static void ne2k_halt(struct eth_device *dev) -{ - debug("### ne2k_halt\n"); - if(initialized) - dp83902a_stop(); - initialized = 0; -} - -static int ne2k_recv(struct eth_device *dev) -{ - dp83902a_poll(); - return 1; -} - -static int ne2k_send(struct eth_device *dev, void *packet, int length) -{ - int tmo; - - debug("### ne2k_send\n"); - - pkey = -1; - - dp83902a_send((u8 *) packet, length, 666); - tmo = get_timer (0) + TOUT * CONFIG_SYS_HZ; - while(1) { - dp83902a_poll(); - if (pkey != -1) { - PRINTK("Packet sucesfully sent\n"); - return 0; - } - if (get_timer (0) >= tmo) { - printf("transmission error (timoeut)\n"); - return 0; - } - - } - return 0; -} - -/** - * Setup the driver for use and register it with the eth layer - * @return 0 on success, -1 on error (causing caller to print error msg) - */ -int ne2k_register(void) -{ - struct eth_device *dev; - - dev = calloc(sizeof(*dev), 1); - if (dev == NULL) - return -1; - - if (ne2k_setup_driver(dev)) - return -1; - - dev->init = ne2k_init; - dev->halt = ne2k_halt; - dev->send = ne2k_send; - dev->recv = ne2k_recv; - - strcpy(dev->name, "NE2000"); - - return eth_register(dev); -} diff --git a/drivers/net/ne2000_base.h b/drivers/net/ne2000_base.h deleted file mode 100644 index 2493608a5a..0000000000 --- a/drivers/net/ne2000_base.h +++ /dev/null @@ -1,305 +0,0 @@ -/* -Ported to U-Boot by Christian Pellegrin <chri@ascensit.com> - -Based on sources from the Linux kernel (pcnet_cs.c, 8390.h) and -eCOS(if_dp83902a.c, if_dp83902a.h). Both of these 2 wonderful world -are GPL, so this is, of course, GPL. - - -========================================================================== - - dev/dp83902a.h - - National Semiconductor DP83902a ethernet chip - -========================================================================== -####ECOSGPLCOPYRIGHTBEGIN#### - ------------------------------------------- - This file is part of eCos, the Embedded Configurable Operating System. - Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. - - eCos is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 or (at your option) any later version. - - eCos is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with eCos; if not, write to the Free Software Foundation, Inc., - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - - As a special exception, if other files instantiate templates or use macros - or inline functions from this file, or you compile this file and link it - with other works to produce a work based on this file, this file does not - by itself cause the resulting work to be covered by the GNU General Public - License. However the source code for this file must still be made available - in accordance with section (3) of the GNU General Public License. - - This exception does not invalidate any other reasons why a work based on - this file might be covered by the GNU General Public License. - - Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. - at http://sources.redhat.com/ecos/ecos-license/ - ------------------------------------------- -####ECOSGPLCOPYRIGHTEND#### -####BSDCOPYRIGHTBEGIN#### - - ------------------------------------------- - - Portions of this software may have been derived from OpenBSD or other sources, - and are covered by the appropriate copyright disclaimers included herein. - - ------------------------------------------- - -####BSDCOPYRIGHTEND#### -========================================================================== -#####DESCRIPTIONBEGIN#### - - Author(s): gthomas - Contributors: gthomas, jskov - Date: 2001-06-13 - Purpose: - Description: - -####DESCRIPTIONEND#### - -========================================================================== - -*/ - -/* - ------------------------------------------------------------------------ - Macros for accessing DP registers - These can be overridden by the platform header -*/ - -#ifndef __NE2000_BASE_H__ -#define __NE2000_BASE_H__ - -/* - * Debugging details - * - * Set to perms of: - * 0 disables all debug output - * 1 for process debug output - * 2 for added data IO output: get_reg, put_reg - * 4 for packet allocation/free output - * 8 for only startup status, so we can tell we're installed OK - */ -#if 0 -#define DEBUG 0xf -#else -#define DEBUG 0 -#endif - -#if DEBUG & 1 -#define DEBUG_FUNCTION() do { printf("%s\n", __FUNCTION__); } while (0) -#define DEBUG_LINE() do { printf("%d\n", __LINE__); } while (0) -#define PRINTK(args...) printf(args) -#else -#define DEBUG_FUNCTION() do {} while(0) -#define DEBUG_LINE() do {} while(0) -#define PRINTK(args...) -#endif - -/* timeout for tx/rx in s */ -#include <linux/delay.h> -#define TOUT 5 -/* Ether MAC address size */ -#define ETHER_ADDR_LEN 6 - - -#define CYGHWR_NS_DP83902A_PLF_BROKEN_TX_DMA 1 -#define CYGACC_CALL_IF_DELAY_US(X) udelay(X) - -/* H/W infomation struct */ -typedef struct hw_info_t { - u32 offset; - u8 a0, a1, a2; - u32 flags; -} hw_info_t; - -typedef struct dp83902a_priv_data { - u8* base; - u8* data; - u8* reset; - int tx_next; /* First free Tx page */ - int tx_int; /* Expecting interrupt from this buffer */ - int rx_next; /* First free Rx page */ - int tx1, tx2; /* Page numbers for Tx buffers */ - u32 tx1_key, tx2_key; /* Used to ack when packet sent */ - int tx1_len, tx2_len; - bool tx_started, running, hardwired_esa; - u8 esa[6]; - void* plf_priv; - - /* Buffer allocation */ - int tx_buf1, tx_buf2; - int rx_buf_start, rx_buf_end; -} dp83902a_priv_data_t; - -/* ------------------------------------------------------------------------ */ -/* Register offsets */ - -#define DP_CR 0x00 -#define DP_CLDA0 0x01 -#define DP_PSTART 0x01 /* write */ -#define DP_CLDA1 0x02 -#define DP_PSTOP 0x02 /* write */ -#define DP_BNDRY 0x03 -#define DP_TSR 0x04 -#define DP_TPSR 0x04 /* write */ -#define DP_NCR 0x05 -#define DP_TBCL 0x05 /* write */ -#define DP_FIFO 0x06 -#define DP_TBCH 0x06 /* write */ -#define DP_ISR 0x07 -#define DP_CRDA0 0x08 -#define DP_RSAL 0x08 /* write */ -#define DP_CRDA1 0x09 -#define DP_RSAH 0x09 /* write */ -#define DP_RBCL 0x0a /* write */ -#define DP_RBCH 0x0b /* write */ -#define DP_RSR 0x0c -#define DP_RCR 0x0c /* write */ -#define DP_FER 0x0d -#define DP_TCR 0x0d /* write */ -#define DP_CER 0x0e -#define DP_DCR 0x0e /* write */ -#define DP_MISSED 0x0f -#define DP_IMR 0x0f /* write */ -#define DP_DATAPORT 0x10 /* "eprom" data port */ - -#define DP_P1_CR 0x00 -#define DP_P1_PAR0 0x01 -#define DP_P1_PAR1 0x02 -#define DP_P1_PAR2 0x03 -#define DP_P1_PAR3 0x04 -#define DP_P1_PAR4 0x05 -#define DP_P1_PAR5 0x06 -#define DP_P1_CURP 0x07 -#define DP_P1_MAR0 0x08 -#define DP_P1_MAR1 0x09 -#define DP_P1_MAR2 0x0a -#define DP_P1_MAR3 0x0b -#define DP_P1_MAR4 0x0c -#define DP_P1_MAR5 0x0d -#define DP_P1_MAR6 0x0e -#define DP_P1_MAR7 0x0f - -#define DP_P2_CR 0x00 -#define DP_P2_PSTART 0x01 -#define DP_P2_CLDA0 0x01 /* write */ -#define DP_P2_PSTOP 0x02 -#define DP_P2_CLDA1 0x02 /* write */ -#define DP_P2_RNPP 0x03 -#define DP_P2_TPSR 0x04 -#define DP_P2_LNPP 0x05 -#define DP_P2_ACH 0x06 -#define DP_P2_ACL 0x07 -#define DP_P2_RCR 0x0c -#define DP_P2_TCR 0x0d -#define DP_P2_DCR 0x0e -#define DP_P2_IMR 0x0f - -/* Command register - common to all pages */ - -#define DP_CR_STOP 0x01 /* Stop: software reset */ -#define DP_CR_START 0x02 /* Start: initialize device */ -#define DP_CR_TXPKT 0x04 /* Transmit packet */ -#define DP_CR_RDMA 0x08 /* Read DMA (recv data from device) */ -#define DP_CR_WDMA 0x10 /* Write DMA (send data to device) */ -#define DP_CR_SEND 0x18 /* Send packet */ -#define DP_CR_NODMA 0x20 /* Remote (or no) DMA */ -#define DP_CR_PAGE0 0x00 /* Page select */ -#define DP_CR_PAGE1 0x40 -#define DP_CR_PAGE2 0x80 -#define DP_CR_PAGEMSK 0x3F /* Used to mask out page bits */ - -/* Data configuration register */ - -#define DP_DCR_WTS 0x01 /* 1=16 bit word transfers */ -#define DP_DCR_BOS 0x02 /* 1=Little Endian */ -#define DP_DCR_LAS 0x04 /* 1=Single 32 bit DMA mode */ -#define DP_DCR_LS 0x08 /* 1=normal mode, 0=loopback */ -#define DP_DCR_ARM 0x10 /* 0=no send command (program I/O) */ -#define DP_DCR_FIFO_1 0x00 /* FIFO threshold */ -#define DP_DCR_FIFO_2 0x20 -#define DP_DCR_FIFO_4 0x40 -#define DP_DCR_FIFO_6 0x60 - -#define DP_DCR_INIT (DP_DCR_LS|DP_DCR_FIFO_4) - -/* Interrupt status register */ - -#define DP_ISR_RxP 0x01 /* Packet received */ -#define DP_ISR_TxP 0x02 /* Packet transmitted */ -#define DP_ISR_RxE 0x04 /* Receive error */ -#define DP_ISR_TxE 0x08 /* Transmit error */ -#define DP_ISR_OFLW 0x10 /* Receive overflow */ -#define DP_ISR_CNT 0x20 /* Tally counters need emptying */ -#define DP_ISR_RDC 0x40 /* Remote DMA complete */ -#define DP_ISR_RESET 0x80 /* Device has reset (shutdown, error) */ - -/* Interrupt mask register */ - -#define DP_IMR_RxP 0x01 /* Packet received */ -#define DP_IMR_TxP 0x02 /* Packet transmitted */ -#define DP_IMR_RxE 0x04 /* Receive error */ -#define DP_IMR_TxE 0x08 /* Transmit error */ -#define DP_IMR_OFLW 0x10 /* Receive overflow */ -#define DP_IMR_CNT 0x20 /* Tall counters need emptying */ -#define DP_IMR_RDC 0x40 /* Remote DMA complete */ - -#define DP_IMR_All 0x3F /* Everything but remote DMA */ - -/* Receiver control register */ - -#define DP_RCR_SEP 0x01 /* Save bad(error) packets */ -#define DP_RCR_AR 0x02 /* Accept runt packets */ -#define DP_RCR_AB 0x04 /* Accept broadcast packets */ -#define DP_RCR_AM 0x08 /* Accept multicast packets */ -#define DP_RCR_PROM 0x10 /* Promiscuous mode */ -#define DP_RCR_MON 0x20 /* Monitor mode - 1=accept no packets */ - -/* Receiver status register */ - -#define DP_RSR_RxP 0x01 /* Packet received */ -#define DP_RSR_CRC 0x02 /* CRC error */ -#define DP_RSR_FRAME 0x04 /* Framing error */ -#define DP_RSR_FO 0x08 /* FIFO overrun */ -#define DP_RSR_MISS 0x10 /* Missed packet */ -#define DP_RSR_PHY 0x20 /* 0=pad match, 1=mad match */ -#define DP_RSR_DIS 0x40 /* Receiver disabled */ -#define DP_RSR_DFR 0x80 /* Receiver processing deferred */ - -/* Transmitter control register */ - -#define DP_TCR_NOCRC 0x01 /* 1=inhibit CRC */ -#define DP_TCR_NORMAL 0x00 /* Normal transmitter operation */ -#define DP_TCR_LOCAL 0x02 /* Internal NIC loopback */ -#define DP_TCR_INLOOP 0x04 /* Full internal loopback */ -#define DP_TCR_OUTLOOP 0x08 /* External loopback */ -#define DP_TCR_ATD 0x10 /* Auto transmit disable */ -#define DP_TCR_OFFSET 0x20 /* Collision offset adjust */ - -/* Transmit status register */ - -#define DP_TSR_TxP 0x01 /* Packet transmitted */ -#define DP_TSR_COL 0x04 /* Collision (at least one) */ -#define DP_TSR_ABT 0x08 /* Aborted because of too many collisions */ -#define DP_TSR_CRS 0x10 /* Lost carrier */ -#define DP_TSR_FU 0x20 /* FIFO underrun */ -#define DP_TSR_CDH 0x40 /* Collision Detect Heartbeat */ -#define DP_TSR_OWC 0x80 /* Collision outside normal window */ - -#define IEEE_8023_MAX_FRAME 1518 /* Largest possible ethernet frame */ -#define IEEE_8023_MIN_FRAME 64 /* Smallest possible ethernet frame */ - -/* Functions */ -int get_prom(u8* mac_addr, u8* base_addr); - -#endif /* __NE2000_BASE_H__ */ diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index ebb7602dde..7af6c5f0b0 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -509,19 +509,13 @@ static int single_of_to_plat(struct udevice *dev) return -EINVAL; } - addr = dev_read_addr_size(dev, "reg", &size); + addr = dev_read_addr_size_index(dev, 0, &size); if (addr == FDT_ADDR_T_NONE) { - dev_err(dev, "failed to get base register size\n"); + dev_err(dev, "failed to get base register address\n"); return -EINVAL; } pdata->offset = size - pdata->width / BITS_PER_BYTE; - - addr = dev_read_addr(dev); - if (addr == FDT_ADDR_T_NONE) { - dev_dbg(dev, "no valid base register address\n"); - return -EINVAL; - } pdata->base = addr; ret = dev_read_u32(dev, "pinctrl-single,function-mask", &pdata->mask); diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index c6fdec95c1..349411c3cc 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -291,7 +291,7 @@ error_out: int btrfs_read_dev_super(struct blk_desc *desc, struct disk_partition *part, struct btrfs_super_block *sb) { - char tmp[BTRFS_SUPER_INFO_SIZE]; + ALLOC_CACHE_ALIGN_BUFFER(char, tmp, BTRFS_SUPER_INFO_SIZE); struct btrfs_super_block *buf = (struct btrfs_super_block *)tmp; int ret; diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c index 29805c3c6f..997be2dcf4 100644 --- a/fs/squashfs/sqfs.c +++ b/fs/squashfs/sqfs.c @@ -876,7 +876,7 @@ int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp) char **token_list = NULL, *path = NULL; u32 *pos_list = NULL; - dirs = malloc(sizeof(*dirs)); + dirs = calloc(1, sizeof(*dirs)); if (!dirs) return -EINVAL; diff --git a/include/configs/qemu-mips.h b/include/configs/qemu-mips.h deleted file mode 100644 index 5e787d7209..0000000000 --- a/include/configs/qemu-mips.h +++ /dev/null @@ -1,89 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * (C) Copyright 2003 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - */ - -/* - * This file contains the configuration parameters for qemu-mips target. - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#define CONFIG_QEMU_MIPS - -#define CONFIG_TIMESTAMP /* Print image info with timestamp */ - -#define CONFIG_EXTRA_ENV_SETTINGS \ - "addmisc=setenv bootargs ${bootargs} " \ - "console=ttyS0,${baudrate} " \ - "panic=1\0" \ - "bootfile=/tftpboot/vmlinux\0" \ - "load=tftp 80500000 ${u-boot}\0" \ - "" - -#define CONFIG_BOOTCOMMAND "bootp;bootelf" - -/* - * BOOTP options - */ -#define CONFIG_BOOTP_BOOTFILESIZE - -#define CONFIG_DRIVER_NE2000 -#define CONFIG_DRIVER_NE2000_BASE 0xb4000300 - -#define CONFIG_SYS_NS16550_SERIAL -#define CONFIG_SYS_NS16550_REG_SIZE 1 -#define CONFIG_SYS_NS16550_CLK 115200 -#define CONFIG_SYS_NS16550_COM1 0xb40003f8 - -#ifdef CONFIG_SYS_BIG_ENDIAN -#define CONFIG_IDE_SWAP_IO -#endif - -#define CONFIG_SYS_IDE_MAXBUS 2 -#define CONFIG_SYS_ATA_IDE0_OFFSET 0x1f0 -#define CONFIG_SYS_ATA_IDE1_OFFSET 0x170 -#define CONFIG_SYS_ATA_DATA_OFFSET 0 -#define CONFIG_SYS_ATA_REG_OFFSET 0 -#define CONFIG_SYS_ATA_BASE_ADDR 0xb4000000 - -#define CONFIG_SYS_IDE_MAXDEVICE 4 - -/* - * Miscellaneous configurable options - */ - -#define CONFIG_SYS_MALLOC_LEN (256 << 10) - -#define CONFIG_SYS_BOOTPARAMS_LEN 128*1024 - -#define CONFIG_SYS_MHZ 132 - -#define CONFIG_SYS_MIPS_TIMER_FREQ (CONFIG_SYS_MHZ * 1000000) - -/* Cached addr */ -#define CONFIG_SYS_SDRAM_BASE 0x80000000 - -/* default load address */ -#define CONFIG_SYS_LOAD_ADDR 0x81000000 - -/*----------------------------------------------------------------------- - * FLASH and environment organization - */ -/* The following #defines are needed to get flash environment right */ -#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE - -#define CONFIG_SYS_INIT_SP_OFFSET 0x400000 - -/* We boot from this flash, selected with dip switch */ -#define CONFIG_SYS_FLASH_BASE 0xbfc00000 -#define CONFIG_SYS_MAX_FLASH_BANKS 1 -#define CONFIG_SYS_MAX_FLASH_SECT 128 - -/* Address and size of Primary Environment Sector */ - -#define MEM_SIZE 128 - -#endif /* __CONFIG_H */ diff --git a/include/configs/qemu-mips64.h b/include/configs/qemu-mips64.h deleted file mode 100644 index 0ed00bc88f..0000000000 --- a/include/configs/qemu-mips64.h +++ /dev/null @@ -1,89 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * (C) Copyright 2003 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - */ - -/* - * This file contains the configuration parameters for qemu-mips64 target. - */ - -#ifndef __CONFIG_H -#define __CONFIG_H - -#define CONFIG_QEMU_MIPS - -#define CONFIG_TIMESTAMP /* Print image info with timestamp */ - -#define CONFIG_EXTRA_ENV_SETTINGS \ - "addmisc=setenv bootargs ${bootargs} " \ - "console=ttyS0,${baudrate} " \ - "panic=1\0" \ - "bootfile=/tftpboot/vmlinux\0" \ - "load=tftp ffffffff80500000 ${u-boot}\0" \ - "" - -#define CONFIG_BOOTCOMMAND "bootp;bootelf" - -/* - * BOOTP options - */ -#define CONFIG_BOOTP_BOOTFILESIZE - -#define CONFIG_DRIVER_NE2000 -#define CONFIG_DRIVER_NE2000_BASE 0xffffffffb4000300 - -#define CONFIG_SYS_NS16550_SERIAL -#define CONFIG_SYS_NS16550_REG_SIZE 1 -#define CONFIG_SYS_NS16550_CLK 115200 -#define CONFIG_SYS_NS16550_COM1 0xffffffffb40003f8 - -#ifdef CONFIG_SYS_BIG_ENDIAN -#define CONFIG_IDE_SWAP_IO -#endif - -#define CONFIG_SYS_IDE_MAXBUS 2 -#define CONFIG_SYS_ATA_IDE0_OFFSET 0x1f0 -#define CONFIG_SYS_ATA_IDE1_OFFSET 0x170 -#define CONFIG_SYS_ATA_DATA_OFFSET 0 -#define CONFIG_SYS_ATA_REG_OFFSET 0 -#define CONFIG_SYS_ATA_BASE_ADDR 0xffffffffb4000000 - -#define CONFIG_SYS_IDE_MAXDEVICE 4 - -/* - * Miscellaneous configurable options - */ - -#define CONFIG_SYS_MALLOC_LEN (256 << 10) - -#define CONFIG_SYS_BOOTPARAMS_LEN 128*1024 - -#define CONFIG_SYS_MHZ 132 - -#define CONFIG_SYS_MIPS_TIMER_FREQ (CONFIG_SYS_MHZ * 1000000) - -/* Cached addr */ -#define CONFIG_SYS_SDRAM_BASE 0xffffffff80000000 - -/* default load address */ -#define CONFIG_SYS_LOAD_ADDR 0xffffffff81000000 - -/*----------------------------------------------------------------------- - * FLASH and environment organization - */ -/* The following #defines are needed to get flash environment right */ -#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE - -#define CONFIG_SYS_INIT_SP_OFFSET 0x400000 - -/* We boot from this flash, selected with dip switch */ -#define CONFIG_SYS_FLASH_BASE 0xffffffffbfc00000 -#define CONFIG_SYS_MAX_FLASH_BANKS 1 -#define CONFIG_SYS_MAX_FLASH_SECT 128 - -/* Address and size of Primary Environment Sector */ - -#define MEM_SIZE 128 - -#endif /* __CONFIG_H */ diff --git a/include/test/ut.h b/include/test/ut.h index fbbba286ee..656e25fe57 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -177,23 +177,6 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes); } \ } -/* - * Assert that two string expressions are equal, up to length of the - * first - */ -#define ut_asserteq_strn(expr1, expr2) { \ - const char *_val1 = (expr1), *_val2 = (expr2); \ - int _len = strlen(_val1); \ - \ - if (memcmp(_val1, _val2, _len)) { \ - ut_failf(uts, __FILE__, __LINE__, __func__, \ - #expr1 " = " #expr2, \ - "Expected \"%.*s\", got \"%.*s\"", \ - _len, _val1, _len, _val2); \ - return CMD_RET_FAILURE; \ - } \ -} - /* Assert that two memory areas are equal */ #define ut_asserteq_mem(expr1, expr2, len) { \ const u8 *_val1 = (u8 *)(expr1), *_val2 = (u8 *)(expr2); \ diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index eb5c4d6f29..98845b8ba3 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -175,6 +175,7 @@ config EFI_CAPSULE_AUTHENTICATE select PKCS7_VERIFY select IMAGE_SIGN_INFO select HASH_CALCULATE + select EFI_SIGNATURE_SUPPORT default n help Select this option if you want to enable capsule @@ -344,6 +345,7 @@ config EFI_SECURE_BOOT select PKCS7_MESSAGE_PARSER select PKCS7_VERIFY select HASH_CALCULATE + select EFI_SIGNATURE_SUPPORT default n help Select this option to enable EFI secure boot support. @@ -351,6 +353,9 @@ config EFI_SECURE_BOOT it is signed with a trusted key. To do that, you need to install, at least, PK, KEK and db. +config EFI_SIGNATURE_SUPPORT + bool + config EFI_ESRT bool "Enable the UEFI ESRT generation" depends on EFI_CAPSULE_FIRMWARE_MANAGEMENT diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 8bd343e258..fd344cea29 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -63,7 +63,7 @@ obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o obj-$(CONFIG_EFI_LOAD_FILE2_INITRD) += efi_load_initrd.o -obj-y += efi_signature.o +obj-$(CONFIG_EFI_SIGNATURE_SUPPORT) += efi_signature.o EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE)) $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index 6ee883d5b1..9ead0d2c78 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -208,16 +208,6 @@ skip: const efi_guid_t efi_guid_capsule_root_cert_guid = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID; -__weak int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len) -{ - /* The platform is supposed to provide - * a method for getting the public key - * stored in the form of efi signature - * list - */ - return 0; -} - efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_size, void **image, efi_uintn_t *image_size) { diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 4b20859b25..76c2f82fe6 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -1171,7 +1171,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr, struct blk_desc *desc = NULL; struct disk_partition fs_partition; int part = 0; - char filename[32] = { 0 }; /* dp->str is u16[32] long */ + char *filename; char *s; if (path && !file) @@ -1198,12 +1198,17 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr, if (!path) return EFI_SUCCESS; - snprintf(filename, sizeof(filename), "%s", path); + filename = calloc(1, strlen(path) + 1); + if (!filename) + return EFI_OUT_OF_RESOURCES; + + sprintf(filename, "%s", path); /* DOS style file path: */ s = filename; while ((s = strchr(s, '/'))) *s++ = '\\'; *file = efi_dp_from_file(desc, part, filename); + free(filename); if (!*file) return EFI_INVALID_PARAMETER; diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index f53ef367ec..fe1ee198e2 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -213,7 +213,68 @@ static void efi_set_code_and_data_type( } } -#ifdef CONFIG_EFI_SECURE_BOOT +/** + * efi_image_region_add() - add an entry of region + * @regs: Pointer to array of regions + * @start: Start address of region (included) + * @end: End address of region (excluded) + * @nocheck: flag against overlapped regions + * + * Take one entry of region [@start, @end[ and insert it into the list. + * + * * If @nocheck is false, the list will be sorted ascending by address. + * Overlapping entries will not be allowed. + * + * * If @nocheck is true, the list will be sorted ascending by sequence + * of adding the entries. Overlapping is allowed. + * + * Return: status code + */ +efi_status_t efi_image_region_add(struct efi_image_regions *regs, + const void *start, const void *end, + int nocheck) +{ + struct image_region *reg; + int i, j; + + if (regs->num >= regs->max) { + EFI_PRINT("%s: no more room for regions\n", __func__); + return EFI_OUT_OF_RESOURCES; + } + + if (end < start) + return EFI_INVALID_PARAMETER; + + for (i = 0; i < regs->num; i++) { + reg = ®s->reg[i]; + if (nocheck) + continue; + + /* new data after registered region */ + if (start >= reg->data + reg->size) + continue; + + /* new data preceding registered region */ + if (end <= reg->data) { + for (j = regs->num - 1; j >= i; j--) + memcpy(®s->reg[j + 1], ®s->reg[j], + sizeof(*reg)); + break; + } + + /* new data overlapping registered region */ + EFI_PRINT("%s: new region already part of another\n", __func__); + return EFI_INVALID_PARAMETER; + } + + reg = ®s->reg[i]; + reg->data = start; + reg->size = end - start; + regs->num++; + + return EFI_SUCCESS; +} + /** * cmp_pe_section() - compare virtual addresses of two PE image sections * @arg1: pointer to pointer to first section header @@ -422,6 +483,7 @@ err: return false; } +#ifdef CONFIG_EFI_SECURE_BOOT /** * efi_image_unsigned_authenticate() - authenticate unsigned image with * SHA256 hash diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c index c7ec275414..bdd09881fc 100644 --- a/lib/efi_loader/efi_signature.c +++ b/lib/efi_loader/efi_signature.c @@ -15,18 +15,16 @@ #include <crypto/public_key.h> #include <linux/compat.h> #include <linux/oid_registry.h> +#include <u-boot/hash-checksum.h> #include <u-boot/rsa.h> #include <u-boot/sha256.h> -const efi_guid_t efi_guid_image_security_database = - EFI_IMAGE_SECURITY_DATABASE_GUID; const efi_guid_t efi_guid_sha256 = EFI_CERT_SHA256_GUID; const efi_guid_t efi_guid_cert_rsa2048 = EFI_CERT_RSA2048_GUID; const efi_guid_t efi_guid_cert_x509 = EFI_CERT_X509_GUID; const efi_guid_t efi_guid_cert_x509_sha256 = EFI_CERT_X509_SHA256_GUID; const efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID; -#if defined(CONFIG_EFI_SECURE_BOOT) || defined(CONFIG_EFI_CAPSULE_AUTHENTICATE) static u8 pkcs7_hdr[] = { /* SEQUENCE */ 0x30, 0x82, 0x05, 0xc7, @@ -540,68 +538,6 @@ out: } /** - * efi_image_region_add() - add an entry of region - * @regs: Pointer to array of regions - * @start: Start address of region (included) - * @end: End address of region (excluded) - * @nocheck: flag against overlapped regions - * - * Take one entry of region [@start, @end[ and insert it into the list. - * - * * If @nocheck is false, the list will be sorted ascending by address. - * Overlapping entries will not be allowed. - * - * * If @nocheck is true, the list will be sorted ascending by sequence - * of adding the entries. Overlapping is allowed. - * - * Return: status code - */ -efi_status_t efi_image_region_add(struct efi_image_regions *regs, - const void *start, const void *end, - int nocheck) -{ - struct image_region *reg; - int i, j; - - if (regs->num >= regs->max) { - EFI_PRINT("%s: no more room for regions\n", __func__); - return EFI_OUT_OF_RESOURCES; - } - - if (end < start) - return EFI_INVALID_PARAMETER; - - for (i = 0; i < regs->num; i++) { - reg = ®s->reg[i]; - if (nocheck) - continue; - - /* new data after registered region */ - if (start >= reg->data + reg->size) - continue; - - /* new data preceding registered region */ - if (end <= reg->data) { - for (j = regs->num - 1; j >= i; j--) - memcpy(®s->reg[j + 1], ®s->reg[j], - sizeof(*reg)); - break; - } - - /* new data overlapping registered region */ - EFI_PRINT("%s: new region already part of another\n", __func__); - return EFI_INVALID_PARAMETER; - } - - reg = ®s->reg[i]; - reg->data = start; - reg->size = end - start; - regs->num++; - - return EFI_SUCCESS; -} - -/** * efi_sigstore_free - free signature store * @sigstore: Pointer to signature store structure * @@ -846,4 +782,3 @@ struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name) return efi_build_signature_store(db, db_size); } -#endif /* CONFIG_EFI_SECURE_BOOT || CONFIG_EFI_CAPSULE_AUTHENTICATE */ diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 39ef250bf9..39074f7547 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -53,7 +53,7 @@ struct digest_info { u16 hash_len; }; -const static struct digest_info hash_algo_list[] = { +static const struct digest_info hash_algo_list[] = { { TPM2_ALG_SHA1, EFI_TCG2_BOOT_HASH_ALG_SHA1, @@ -87,7 +87,7 @@ const static struct digest_info hash_algo_list[] = { */ static u32 alg_to_mask(u16 hash_alg) { - int i; + size_t i; for (i = 0; i < MAX_HASH_COUNT; i++) { if (hash_algo_list[i].hash_alg == hash_alg) @@ -106,7 +106,7 @@ static u32 alg_to_mask(u16 hash_alg) */ static u16 alg_to_len(u16 hash_alg) { - int i; + size_t i; for (i = 0; i < MAX_HASH_COUNT; i++) { if (hash_algo_list[i].hash_alg == hash_alg) @@ -119,7 +119,7 @@ static u16 alg_to_len(u16 hash_alg) static u32 tcg_event_final_size(struct tpml_digest_values *digest_list) { u32 len; - int i; + size_t i; len = offsetof(struct tcg_pcr_event2, digests); len += offsetof(struct tpml_digest_values, digests); @@ -145,7 +145,7 @@ static efi_status_t tcg2_pcr_extend(struct udevice *dev, u32 pcr_index, struct tpml_digest_values *digest_list) { u32 rc; - int i; + size_t i; for (i = 0; i < digest_list->count; i++) { u32 alg = digest_list->digests[i].hash_alg; @@ -178,7 +178,7 @@ static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type, { void *log = (void *)((uintptr_t)event_log.buffer + event_log.pos); size_t pos; - int i; + size_t i; u32 event_size; if (event_log.get_event_called) @@ -400,7 +400,8 @@ static int tpm2_get_pcr_info(struct udevice *dev, u32 *supported_pcr, u8 response[TPM2_RESPONSE_BUFFER_SIZE]; struct tpml_pcr_selection pcrs; u32 ret, num_pcr; - int i, tpm_ret; + size_t i; + int tpm_ret; memset(response, 0, sizeof(response)); ret = tpm2_get_capability(dev, TPM2_CAP_PCRS, 0, response, 1); @@ -518,7 +519,7 @@ static efi_status_t tcg2_create_digest(const u8 *input, u32 length, u8 final[TPM2_SHA512_DIGEST_SIZE]; efi_status_t ret; u32 active; - int i; + size_t i; ret = __get_active_pcr_banks(&active); if (ret != EFI_SUCCESS) @@ -749,8 +750,7 @@ efi_tcg2_hash_log_extend_event(struct efi_tcg2_protocol *this, u64 flags, goto out; } - if (efi_tcg_event->header.pcr_index < 0 || - efi_tcg_event->header.pcr_index > TPM2_MAX_PCRS) { + if (efi_tcg_event->header.pcr_index > TPM2_MAX_PCRS) { ret = EFI_INVALID_PARAMETER; goto out; } @@ -810,9 +810,11 @@ out: * Return: status code */ static efi_status_t EFIAPI -efi_tcg2_submit_command(struct efi_tcg2_protocol *this, - u32 input_param_block_size, u8 *input_param_block, - u32 output_param_block_size, u8 *output_param_block) +efi_tcg2_submit_command(__maybe_unused struct efi_tcg2_protocol *this, + u32 __maybe_unused input_param_block_size, + u8 __maybe_unused *input_param_block, + u32 __maybe_unused output_param_block_size, + u8 __maybe_unused *output_param_block) { return EFI_UNSUPPORTED; } @@ -847,8 +849,8 @@ efi_tcg2_get_active_pcr_banks(struct efi_tcg2_protocol *this, * Return: status code */ static efi_status_t EFIAPI -efi_tcg2_set_active_pcr_banks(struct efi_tcg2_protocol *this, - u32 active_pcr_banks) +efi_tcg2_set_active_pcr_banks(__maybe_unused struct efi_tcg2_protocol *this, + u32 __maybe_unused active_pcr_banks) { return EFI_UNSUPPORTED; } @@ -866,8 +868,9 @@ efi_tcg2_set_active_pcr_banks(struct efi_tcg2_protocol *this, * Return: status code */ static efi_status_t EFIAPI -efi_tcg2_get_result_of_set_active_pcr_banks(struct efi_tcg2_protocol *this, - u32 *operation_present, u32 *response) +efi_tcg2_get_result_of_set_active_pcr_banks(__maybe_unused struct efi_tcg2_protocol *this, + u32 __maybe_unused *operation_present, + u32 __maybe_unused *response) { return EFI_UNSUPPORTED; } @@ -898,7 +901,8 @@ static efi_status_t create_specid_event(struct udevice *dev, void *buffer, size_t spec_event_size; efi_status_t ret = EFI_DEVICE_ERROR; u32 active, supported; - int err, i; + int err; + size_t i; /* * Create Spec event. This needs to be the first event in the log diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c index b11ed91a74..83479dd142 100644 --- a/lib/efi_loader/efi_var_common.c +++ b/lib/efi_loader/efi_var_common.c @@ -24,6 +24,9 @@ struct efi_auth_var_name_type { const enum efi_auth_var_type type; }; +const efi_guid_t efi_guid_image_security_database = + EFI_IMAGE_SECURITY_DATABASE_GUID; + static const struct efi_auth_var_name_type name_type[] = { {u"PK", &efi_global_variable_guid, EFI_AUTH_VAR_PK}, {u"KEK", &efi_global_variable_guid, EFI_AUTH_VAR_KEK}, diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 465f89e52b..8f92b82719 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -300,8 +300,6 @@ CONFIG_DRIVER_AT91EMAC_PHYADDR CONFIG_DRIVER_AT91EMAC_QUIET CONFIG_DRIVER_DM9000 CONFIG_DRIVER_EP93XX_MAC -CONFIG_DRIVER_NE2000 -CONFIG_DRIVER_NE2000_BASE CONFIG_DSP_CLUSTER_START CONFIG_DWC2_DFLT_SPEED_FULL CONFIG_DWC2_DMA_BURST_SIZE @@ -1264,7 +1262,6 @@ CONFIG_PXA_STD_I2C CONFIG_PXA_VGA CONFIG_PXA_VIDEO CONFIG_QBMAN_CLK_DIV -CONFIG_QEMU_MIPS CONFIG_QIXIS_I2C_ACCESS CONFIG_QSPI CONFIG_QUOTA diff --git a/test/dm/part.c b/test/dm/part.c index 051e9010b6..78dd8472c2 100644 --- a/test/dm/part.c +++ b/test/dm/part.c @@ -11,11 +11,25 @@ #include <dm/test.h> #include <test/ut.h> +static inline int do_test(struct unit_test_state *uts, int expected, + const char *part_str, bool whole) +{ + struct blk_desc *mmc_dev_desc; + struct disk_partition part_info; + + ut_asserteq(expected, + part_get_info_by_dev_and_name_or_num("mmc", part_str, + &mmc_dev_desc, + &part_info, whole)); + return 0; +} + static int dm_test_part(struct unit_test_state *uts) { + char *oldbootdevice; char str_disk_guid[UUID_STR_LEN + 1]; + int ret; struct blk_desc *mmc_dev_desc; - struct disk_partition part_info; struct disk_partition parts[2] = { { .start = 48, /* GPT data takes up the first 34 blocks or so */ @@ -38,16 +52,22 @@ static int dm_test_part(struct unit_test_state *uts) ut_assertok(gpt_restore(mmc_dev_desc, str_disk_guid, parts, ARRAY_SIZE(parts))); -#define test(expected, part_str, whole) \ - ut_asserteq(expected, \ - part_get_info_by_dev_and_name_or_num("mmc", part_str, \ - &mmc_dev_desc, \ - &part_info, whole)) + oldbootdevice = env_get("bootdevice"); +#define test(expected, part_str, whole) do { \ + ret = do_test(uts, expected, part_str, whole); \ + if (ret) \ + goto out; \ +} while (0) + + env_set("bootdevice", NULL); + test(-ENODEV, NULL, true); test(-ENODEV, "", true); env_set("bootdevice", "0"); + test(0, NULL, true); test(0, "", true); env_set("bootdevice", "1"); + test(1, NULL, false); test(1, "", false); test(1, "-", false); env_set("bootdevice", ""); @@ -70,7 +90,10 @@ static int dm_test_part(struct unit_test_state *uts) test(-EINVAL, "1#bogus", false); test(1, "1#test1", false); test(2, "1#test2", false); + ret = 0; - return 0; +out: + env_set("bootdevice", oldbootdevice); + return ret; } DM_TEST(dm_test_part, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py index 50af9efcf7..410a675b97 100644 --- a/test/py/tests/test_fs/conftest.py +++ b/test/py/tests/test_fs/conftest.py @@ -278,14 +278,19 @@ def fs_obj_basic(request, u_boot_config): check_call('mkdir -p %s' % mount_dir, shell=True) except CalledProcessError as err: pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) - return - finally: call('rm -f %s' % fs_img, shell=True) + return try: # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) + except CalledProcessError as err: + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + call('rmdir %s' % mount_dir, shell=True) + call('rm -f %s' % fs_img, shell=True) + return + try: # Create a subdirectory. check_call('mkdir %s/SUBDIR' % mount_dir, shell=True) @@ -348,11 +353,12 @@ def fs_obj_basic(request, u_boot_config): except CalledProcessError as err: pytest.skip('Setup failed for filesystem: ' + fs_type + '. {}'.format(err)) + umount_fs(mount_dir) return else: + umount_fs(mount_dir) yield [fs_ubtype, fs_img, md5val] finally: - umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) call('rm -f %s' % fs_img, shell=True) @@ -394,14 +400,19 @@ def fs_obj_ext(request, u_boot_config): check_call('mkdir -p %s' % mount_dir, shell=True) except CalledProcessError as err: pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) - return - finally: call('rm -f %s' % fs_img, shell=True) + return try: # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) + except CalledProcessError as err: + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + call('rmdir %s' % mount_dir, shell=True) + call('rm -f %s' % fs_img, shell=True) + return + try: # Create a test directory check_call('mkdir %s/dir1' % mount_dir, shell=True) @@ -443,11 +454,12 @@ def fs_obj_ext(request, u_boot_config): check_call('rm %s' % tmp_file, shell=True) except CalledProcessError: pytest.skip('Setup failed for filesystem: ' + fs_type) + umount_fs(mount_dir) return else: + umount_fs(mount_dir) yield [fs_ubtype, fs_img, md5val] finally: - umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) call('rm -f %s' % fs_img, shell=True) @@ -517,14 +529,19 @@ def fs_obj_unlink(request, u_boot_config): check_call('mkdir -p %s' % mount_dir, shell=True) except CalledProcessError as err: pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) - return - finally: call('rm -f %s' % fs_img, shell=True) + return try: # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) + except CalledProcessError as err: + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + call('rmdir %s' % mount_dir, shell=True) + call('rm -f %s' % fs_img, shell=True) + return + try: # Test Case 1 & 3 check_call('mkdir %s/dir1' % mount_dir, shell=True) check_call('dd if=/dev/urandom of=%s/dir1/file1 bs=1K count=1' @@ -548,11 +565,12 @@ def fs_obj_unlink(request, u_boot_config): except CalledProcessError: pytest.skip('Setup failed for filesystem: ' + fs_type) + umount_fs(mount_dir) return else: + umount_fs(mount_dir) yield [fs_ubtype, fs_img] finally: - umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) call('rm -f %s' % fs_img, shell=True) @@ -594,14 +612,19 @@ def fs_obj_symlink(request, u_boot_config): check_call('mkdir -p %s' % mount_dir, shell=True) except CalledProcessError as err: pytest.skip('Preparing mount folder failed for filesystem: ' + fs_type + '. {}'.format(err)) - return - finally: call('rm -f %s' % fs_img, shell=True) + return try: # Mount the image so we can populate it. mount_fs(fs_type, fs_img, mount_dir) + except CalledProcessError as err: + pytest.skip('Mounting to folder failed for filesystem: ' + fs_type + '. {}'.format(err)) + call('rmdir %s' % mount_dir, shell=True) + call('rm -f %s' % fs_img, shell=True) + return + try: # Create a subdirectory. check_call('mkdir %s/SUBDIR' % mount_dir, shell=True) @@ -625,10 +648,11 @@ def fs_obj_symlink(request, u_boot_config): except CalledProcessError: pytest.skip('Setup failed for filesystem: ' + fs_type) + umount_fs(mount_dir) return else: + umount_fs(mount_dir) yield [fs_ubtype, fs_img, md5val] finally: - umount_fs(mount_dir) call('rmdir %s' % mount_dir, shell=True) call('rm -f %s' % fs_img, shell=True) |