diff --git a/arch/arm/cpu/armv8/Kconfig b/arch/arm/cpu/armv8/Kconfig index 92a2b58ed46db202b2e156725423bdb759a16039..16c83e86149a752e4c539b9febef4b6da15e0ea4 100644 --- a/arch/arm/cpu/armv8/Kconfig +++ b/arch/arm/cpu/armv8/Kconfig @@ -65,7 +65,7 @@ config ARMV8_SEC_FIRMWARE_SUPPORT - Address of secure firmware. - Address to hold the return address from secure firmware. - Secure firmware FIT image related information. - Such as: SEC_FIRMWARE_FIT_IMAGE and SEC_FIRMEWARE_FIT_CNF_NAME + Such as: SEC_FIRMWARE_FIT_IMAGE and SEC_FIRMWARE_FIT_CNF_NAME - The target exception level that secure monitor firmware will return to. diff --git a/arch/arm/cpu/armv8/sec_firmware.c b/arch/arm/cpu/armv8/sec_firmware.c index 4dcda70b91425144a00d74d963503215fffde24a..95ea57d571b1494c1819004ad3ce124ec4034388 100644 --- a/arch/arm/cpu/armv8/sec_firmware.c +++ b/arch/arm/cpu/armv8/sec_firmware.c @@ -29,8 +29,8 @@ phys_addr_t sec_firmware_addr; #ifndef SEC_FIRMWARE_FIT_IMAGE #define SEC_FIRMWARE_FIT_IMAGE "firmware" #endif -#ifndef SEC_FIRMEWARE_FIT_CNF_NAME -#define SEC_FIRMEWARE_FIT_CNF_NAME "config-1" +#ifndef SEC_FIRMWARE_FIT_CNF_NAME +#define SEC_FIRMWARE_FIT_CNF_NAME "config-1" #endif #ifndef SEC_FIRMWARE_TARGET_EL #define SEC_FIRMWARE_TARGET_EL 2 @@ -44,7 +44,7 @@ static int sec_firmware_get_data(const void *sec_firmware_img, char *desc; int ret; - conf_node_name = SEC_FIRMEWARE_FIT_CNF_NAME; + conf_node_name = SEC_FIRMWARE_FIT_CNF_NAME; conf_node_off = fit_conf_get_node(sec_firmware_img, conf_node_name); if (conf_node_off < 0) { @@ -124,7 +124,7 @@ static int sec_firmware_check_copy_loadable(const void *sec_firmware_img, const char *name, *str, *type; int len; - conf_node_name = SEC_FIRMEWARE_FIT_CNF_NAME; + conf_node_name = SEC_FIRMWARE_FIT_CNF_NAME; conf_node_off = fit_conf_get_node(sec_firmware_img, conf_node_name); if (conf_node_off < 0) { diff --git a/cmd/bootm.c b/cmd/bootm.c index 8279f2b7cc632f14f7cf2155583dfb0710797cfa..62ee7c4b8a169bb202483109c5a9fbf78f1277af 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -19,6 +19,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -244,7 +245,7 @@ static int do_iminfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static int image_info(ulong addr) { - void *hdr = (void *)addr; + void *hdr = (void *)map_sysmem(addr, 0); printf("\n## Checking Image at %08lx ...\n", addr); @@ -254,11 +255,13 @@ static int image_info(ulong addr) puts(" Legacy image found\n"); if (!image_check_magic(hdr)) { puts(" Bad Magic Number\n"); + unmap_sysmem(hdr); return 1; } if (!image_check_hcrc(hdr)) { puts(" Bad Header Checksum\n"); + unmap_sysmem(hdr); return 1; } @@ -267,15 +270,18 @@ static int image_info(ulong addr) puts(" Verifying Checksum ... "); if (!image_check_dcrc(hdr)) { puts(" Bad Data CRC\n"); + unmap_sysmem(hdr); return 1; } puts("OK\n"); + unmap_sysmem(hdr); return 0; #endif #if defined(CONFIG_ANDROID_BOOT_IMAGE) case IMAGE_FORMAT_ANDROID: puts(" Android image found\n"); android_print_contents(hdr); + unmap_sysmem(hdr); return 0; #endif #if defined(CONFIG_FIT) @@ -284,6 +290,7 @@ static int image_info(ulong addr) if (!fit_check_format(hdr)) { puts("Bad FIT image format!\n"); + unmap_sysmem(hdr); return 1; } @@ -291,9 +298,11 @@ static int image_info(ulong addr) if (!fit_all_image_verify(hdr)) { puts("Bad hash in FIT image!\n"); + unmap_sysmem(hdr); return 1; } + unmap_sysmem(hdr); return 0; #endif default: @@ -301,6 +310,7 @@ static int image_info(ulong addr) break; } + unmap_sysmem(hdr); return 1; } diff --git a/cmd/mem.c b/cmd/mem.c index 545534b1fc7265fb8ca9e3ca833248bc1d86c9ee..4ec450b050248d14f6c77bfd08c0c8f818e12359 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -303,6 +303,7 @@ static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong addr, dest, count; + void *src, *dst; int size; if (argc != 4) @@ -326,25 +327,34 @@ static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } + src = map_sysmem(addr, count * size); + dst = map_sysmem(dest, count * size); + #ifdef CONFIG_MTD_NOR_FLASH /* check if we are copying to Flash */ - if (addr2info(dest) != NULL) { + if (addr2info((ulong)dst)) { int rc; puts ("Copy to Flash... "); - rc = flash_write ((char *)addr, dest, count*size); + rc = flash_write((char *)src, (ulong)dst, count * size); if (rc != 0) { flash_perror (rc); + unmap_sysmem(src); + unmap_sysmem(dst); return (1); } puts ("done\n"); + unmap_sysmem(src); + unmap_sysmem(dst); return 0; } #endif - memcpy((void *)dest, (void *)addr, count * size); + memcpy(dst, src, count * size); + unmap_sysmem(src); + unmap_sysmem(dst); return 0; } diff --git a/common/spl/Kconfig b/common/spl/Kconfig index e11faae9ee413dcb8bf9d2d6a16de6ef90829c1a..c8cb715c3a3ee6a79a8d08444e6ff4e3930814c8 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -485,6 +485,12 @@ config SPL_DMA_SUPPORT the CPU moving the data. Enable this option to build the drivers in drivers/dma as part of an SPL build. +config SPL_DM_GPIO + bool "Support Driver Model GPIO drivers" + depends on SPL_GPIO_SUPPORT && DM_GPIO + help + Enable support for Driver Model based GPIO drivers in SPL. + config SPL_DRIVERS_MISC_SUPPORT bool "Support misc drivers" help diff --git a/common/spl/spl.c b/common/spl/spl.c index d51dbe9942fc9f3be482ffd8d141d853bcb67d64..24da164b43889c896dce5bddb6bded16c8d2651b 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -264,9 +264,9 @@ int spl_parse_image_header(struct spl_image_info *spl_image, spl_image->entry_point = image_get_ep(header); spl_image->size = image_get_data_size(header); } else { - spl_image->entry_point = image_get_load(header); + spl_image->entry_point = image_get_ep(header); /* Load including the header */ - spl_image->load_addr = spl_image->entry_point - + spl_image->load_addr = image_get_load(header) - header_size; spl_image->size = image_get_data_size(header) + header_size; diff --git a/configs/da850evm_defconfig b/configs/da850evm_defconfig index 5ff2360a39eb73234979f748645cb4e8a056bbbf..b07c4b0d6da17e981879cb8397bedcdebef76d9d 100644 --- a/configs/da850evm_defconfig +++ b/configs/da850evm_defconfig @@ -26,6 +26,7 @@ CONFIG_VERSION_VARIABLE=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_SPL_SEPARATE_BSS=y +# CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR is not set CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x8000 CONFIG_HUSH_PARSER=y diff --git a/configs/da850evm_nand_defconfig b/configs/da850evm_nand_defconfig index 7d62e08d9485dde741303de0fe726c344f83cdd3..f78753194421a33bc21a5d94f485718559895b04 100644 --- a/configs/da850evm_nand_defconfig +++ b/configs/da850evm_nand_defconfig @@ -23,6 +23,7 @@ CONFIG_VERSION_VARIABLE=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_SPL_SEPARATE_BSS=y +# CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR is not set CONFIG_SPL_NAND_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x8000 diff --git a/configs/omapl138_lcdk_defconfig b/configs/omapl138_lcdk_defconfig index 624195c7b61de42027450ab90d9a2896c53ddf66..c021e8f564d2f97af89f02c3493e6fb3d7f00470 100644 --- a/configs/omapl138_lcdk_defconfig +++ b/configs/omapl138_lcdk_defconfig @@ -1,4 +1,5 @@ CONFIG_ARM=y +CONFIG_SYS_THUMB_BUILD=y CONFIG_ARCH_DAVINCI=y CONFIG_SYS_TEXT_BASE=0xc1080000 CONFIG_TARGET_OMAPL138_LCDK=y diff --git a/drivers/net/pfe_eth/pfe_firmware.c b/drivers/net/pfe_eth/pfe_firmware.c index adb2d06010ce3a75c364e8e4514985a47c8ae634..e4563f192bf21f2b53b042c8ba482a12cb6a319e 100644 --- a/drivers/net/pfe_eth/pfe_firmware.c +++ b/drivers/net/pfe_eth/pfe_firmware.c @@ -16,7 +16,7 @@ #include #endif -#define PFE_FIRMEWARE_FIT_CNF_NAME "config@1" +#define PFE_FIRMWARE_FIT_CNF_NAME "config@1" static const void *pfe_fit_addr = (void *)CONFIG_SYS_LS_PFE_FW_ADDR; @@ -99,7 +99,7 @@ static int pfe_get_fw(const void **data, char *desc; int ret = 0; - conf_node_name = PFE_FIRMEWARE_FIT_CNF_NAME; + conf_node_name = PFE_FIRMWARE_FIT_CNF_NAME; conf_node_off = fit_conf_get_node(pfe_fit_addr, conf_node_name); if (conf_node_off < 0) { diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 896cb6b23a1a23516fd5b6664b5bf62dd3654beb..fab20fc60e55bf9fcd3681f26be77735a8b37489 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -677,6 +677,11 @@ static int pci_find_and_bind_driver(struct udevice *parent, /* Determine optional OF node */ pci_dev_find_ofnode(parent, bdf, &node); + if (ofnode_valid(node) && !ofnode_is_available(node)) { + debug("%s: Ignoring disabled device\n", __func__); + return -EPERM; + } + start = ll_entry_start(struct pci_driver_entry, pci_driver_entry); n_ents = ll_entry_count(struct pci_driver_entry, pci_driver_entry); for (entry = start; entry != start + n_ents; entry++) { diff --git a/drivers/tee/optee/rpmb.c b/drivers/tee/optee/rpmb.c index 955155b3f8b1212b9b9fe3dcb6afba36e177b8f3..cf1ce77e6e19e68ea5fb2300fcfb48d4d32675e9 100644 --- a/drivers/tee/optee/rpmb.c +++ b/drivers/tee/optee/rpmb.c @@ -98,6 +98,7 @@ static struct mmc *get_mmc(struct optee_private *priv, int dev_id) static u32 rpmb_get_dev_info(u16 dev_id, struct rpmb_dev_info *info) { struct mmc *mmc = find_mmc_device(dev_id); + int i; if (!mmc) return TEE_ERROR_ITEM_NOT_FOUND; @@ -105,7 +106,9 @@ static u32 rpmb_get_dev_info(u16 dev_id, struct rpmb_dev_info *info) if (!mmc->ext_csd) return TEE_ERROR_GENERIC; - memcpy(info->cid, mmc->cid, sizeof(info->cid)); + for (i = 0; i < ARRAY_SIZE(mmc->cid); i++) + ((u32 *) info->cid)[i] = cpu_to_be32(mmc->cid[i]); + info->rel_wr_sec_c = mmc->ext_csd[222]; info->rpmb_size_mult = mmc->ext_csd[168]; info->ret_code = RPMB_CMD_GET_DEV_INFO_RET_OK; diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 9e1b842dac6b9802960b19bb180a90e894679159..68ce658386780af4494ff309c4cd0136080484b3 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -869,6 +869,14 @@ static dir_entry *extract_vfat_name(fat_itr *itr) return NULL; } + /* + * We are now at the short file name entry. + * If it is marked as deleted, just skip it. + */ + if (dent->name[0] == DELETED_FLAG || + dent->name[0] == aRING) + return NULL; + itr->l_name[n] = '\0'; chksum = mkcksum(dent->name, dent->ext); @@ -898,6 +906,16 @@ static int fat_itr_next(fat_itr *itr) itr->name = NULL; + /* + * One logical directory entry consist of following slots: + * name[0] Attributes + * dent[N - N]: LFN[N - 1] N|0x40 ATTR_VFAT + * ... + * dent[N - 2]: LFN[1] 2 ATTR_VFAT + * dent[N - 1]: LFN[0] 1 ATTR_VFAT + * dent[N]: SFN ATTR_ARCH + */ + while (1) { dent = next_dent(itr); if (!dent) @@ -910,7 +928,17 @@ static int fat_itr_next(fat_itr *itr) if (dent->attr & ATTR_VOLUME) { if ((dent->attr & ATTR_VFAT) == ATTR_VFAT && (dent->name[0] & LAST_LONG_ENTRY_MASK)) { + /* long file name */ dent = extract_vfat_name(itr); + /* + * If succeeded, dent has a valid short file + * name entry for the current entry. + * If failed, itr points to a current bogus + * entry. So after fetching a next one, + * it may have a short file name entry + * for this bogus entry so that we can still + * check for a short name. + */ if (!dent) continue; itr->name = itr->l_name; @@ -919,8 +947,11 @@ static int fat_itr_next(fat_itr *itr) /* Volume label or VFAT entry, skip */ continue; } - } + } else if (!(dent->attr & ATTR_ARCH) && + !(dent->attr & ATTR_DIR)) + continue; + /* short file name */ break; } diff --git a/test/py/tests/test_fs/test_ext.py b/test/py/tests/test_fs/test_ext.py index 2c47738b8df241eda4c0c079de0588b778026c74..6b7fc48701777d17ca2dabccbf60853c6c81e9b4 100644 --- a/test/py/tests/test_fs/test_ext.py +++ b/test/py/tests/test_fs/test_ext.py @@ -233,3 +233,87 @@ class TestFsExt(object): % (fs_type, ADDR, MIN_FILE)]) assert('Unable to write "/dir1' in ''.join(output)) assert_fs_integrity(fs_type, fs_img) + + def test_fs_ext10(self, u_boot_console, fs_obj_ext): + """ + 'Test Case 10 - create/delete as many directories under root directory + as amount of directory entries goes beyond one cluster size)' + """ + fs_type,fs_img,md5val = fs_obj_ext + with u_boot_console.log.section('Test Case 10 - create/delete (many)'): + # Test Case 10a - Create many files + # Please note that the size of directory entry is 32 bytes. + # So one typical cluster may holds 64 (2048/32) entries. + output = u_boot_console.run_command( + 'host bind 0 %s' % fs_img) + + for i in range(0, 66): + output = u_boot_console.run_command( + '%swrite host 0:0 %x /FILE0123456789_%02x 100' + % (fs_type, ADDR, i)) + output = u_boot_console.run_command('%sls host 0:0 /' % fs_type) + assert('FILE0123456789_00' in output) + assert('FILE0123456789_41' in output) + + # Test Case 10b - Delete many files + for i in range(0, 66): + output = u_boot_console.run_command( + '%srm host 0:0 /FILE0123456789_%02x' + % (fs_type, i)) + output = u_boot_console.run_command('%sls host 0:0 /' % fs_type) + assert(not 'FILE0123456789_00' in output) + assert(not 'FILE0123456789_41' in output) + + # Test Case 10c - Create many files again + # Please note no.64 and 65 are intentionally re-created + for i in range(64, 128): + output = u_boot_console.run_command( + '%swrite host 0:0 %x /FILE0123456789_%02x 100' + % (fs_type, ADDR, i)) + output = u_boot_console.run_command('%sls host 0:0 /' % fs_type) + assert('FILE0123456789_40' in output) + assert('FILE0123456789_79' in output) + + assert_fs_integrity(fs_type, fs_img) + + def test_fs_ext11(self, u_boot_console, fs_obj_ext): + """ + 'Test Case 11 - create/delete as many directories under non-root + directory as amount of directory entries goes beyond one cluster size)' + """ + fs_type,fs_img,md5val = fs_obj_ext + with u_boot_console.log.section('Test Case 11 - create/delete (many)'): + # Test Case 11a - Create many files + # Please note that the size of directory entry is 32 bytes. + # So one typical cluster may holds 64 (2048/32) entries. + output = u_boot_console.run_command( + 'host bind 0 %s' % fs_img) + + for i in range(0, 66): + output = u_boot_console.run_command( + '%swrite host 0:0 %x /dir1/FILE0123456789_%02x 100' + % (fs_type, ADDR, i)) + output = u_boot_console.run_command('%sls host 0:0 /dir1' % fs_type) + assert('FILE0123456789_00' in output) + assert('FILE0123456789_41' in output) + + # Test Case 11b - Delete many files + for i in range(0, 66): + output = u_boot_console.run_command( + '%srm host 0:0 /dir1/FILE0123456789_%02x' + % (fs_type, i)) + output = u_boot_console.run_command('%sls host 0:0 /dir1' % fs_type) + assert(not 'FILE0123456789_00' in output) + assert(not 'FILE0123456789_41' in output) + + # Test Case 11c - Create many files again + # Please note no.64 and 65 are intentionally re-created + for i in range(64, 128): + output = u_boot_console.run_command( + '%swrite host 0:0 %x /dir1/FILE0123456789_%02x 100' + % (fs_type, ADDR, i)) + output = u_boot_console.run_command('%sls host 0:0 /dir1' % fs_type) + assert('FILE0123456789_40' in output) + assert('FILE0123456789_79' in output) + + assert_fs_integrity(fs_type, fs_img)