diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile | 14 | ||||
-rw-r--r-- | lib/efi_loader/efi_boottime.c | 27 | ||||
-rw-r--r-- | lib/efi_loader/efi_disk.c | 11 | ||||
-rw-r--r-- | lib/efi_loader/efi_gop.c | 57 | ||||
-rw-r--r-- | lib/efi_loader/efi_memory.c | 57 | ||||
-rw-r--r-- | lib/efi_loader/efi_runtime.c | 14 | ||||
-rw-r--r-- | lib/fdtdec.c | 3 | ||||
-rw-r--r-- | lib/libfdt/Makefile | 12 | ||||
-rw-r--r-- | lib/libfdt/README | 16 | ||||
-rw-r--r-- | lib/libfdt/fdt.c | 2 | ||||
-rw-r--r-- | lib/libfdt/fdt_addresses.c | 2 | ||||
-rw-r--r-- | lib/libfdt/fdt_empty_tree.c | 3 | ||||
-rw-r--r-- | lib/libfdt/fdt_region.c | 144 | ||||
-rw-r--r-- | lib/libfdt/fdt_ro.c | 10 | ||||
-rw-r--r-- | lib/libfdt/fdt_rw.c | 6 | ||||
-rw-r--r-- | lib/libfdt/fdt_strerror.c | 2 | ||||
-rw-r--r-- | lib/libfdt/fdt_sw.c | 3 | ||||
-rw-r--r-- | lib/libfdt/fdt_wip.c | 6 | ||||
-rw-r--r-- | lib/rsa/Kconfig | 4 | ||||
-rw-r--r-- | lib/rsa/Makefile | 2 | ||||
-rw-r--r-- | lib/string.c | 24 | ||||
-rw-r--r-- | lib/tiny-printf.c | 4 | ||||
-rw-r--r-- | lib/tizen/tizen.c | 2 |
23 files changed, 246 insertions, 179 deletions
diff --git a/lib/Makefile b/lib/Makefile index 02dfa295073..f48d90103d2 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -9,7 +9,6 @@ ifndef CONFIG_SPL_BUILD obj-$(CONFIG_EFI) += efi/ obj-$(CONFIG_EFI_LOADER) += efi_loader/ -obj-$(CONFIG_RSA) += rsa/ obj-$(CONFIG_LZMA) += lzma/ obj-$(CONFIG_LZO) += lzo/ obj-$(CONFIG_ZLIB) += zlib/ @@ -25,8 +24,6 @@ obj-y += crc8.o obj-y += crc16.o obj-$(CONFIG_ERRNO_STR) += errno_str.o obj-$(CONFIG_FIT) += fdtdec_common.o -obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o -obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec.o obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o obj-$(CONFIG_GZIP) += gunzip.o obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o @@ -39,16 +36,17 @@ obj-y += net_utils.o obj-$(CONFIG_PHYSMEM) += physmem.o obj-y += qsort.o obj-y += rc4.o -obj-$(CONFIG_SHA1) += sha1.o obj-$(CONFIG_SUPPORT_EMMC_RPMB) += sha256.o -obj-$(CONFIG_SHA256) += sha256.o -obj-y += strmhz.o obj-$(CONFIG_TPM) += tpm.o obj-$(CONFIG_RBTREE) += rbtree.o obj-$(CONFIG_BITREVERSE) += bitrev.o obj-y += list_sort.o endif +obj-$(CONFIG_$(SPL_)RSA) += rsa/ +obj-$(CONFIG_$(SPL_)SHA1) += sha1.o +obj-$(CONFIG_$(SPL_)SHA256) += sha256.o + obj-$(CONFIG_$(SPL_)OF_LIBFDT) += libfdt/ ifdef CONFIG_SPL_OF_CONTROL obj-$(CONFIG_OF_LIBFDT) += libfdt/ @@ -85,11 +83,11 @@ ifdef CONFIG_SPL_BUILD ifdef CONFIG_USE_TINY_PRINTF obj-$(CONFIG_SPL_SERIAL_SUPPORT) += tiny-printf.o panic.o strto.o else -obj-$(CONFIG_SPL_SERIAL_SUPPORT) += vsprintf.o panic.o strto.o +obj-$(CONFIG_SPL_SERIAL_SUPPORT) += vsprintf.o panic.o strto.o strmhz.o endif else # Main U-Boot always uses the full printf support -obj-y += vsprintf.o panic.o strto.o +obj-y += vsprintf.o panic.o strto.o strmhz.o endif subdir-ccflags-$(CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED) += -O2 diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 9daca50a72f..be6f5e81124 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -6,8 +6,6 @@ * SPDX-License-Identifier: GPL-2.0+ */ -/* #define DEBUG_EFI */ - #include <common.h> #include <efi_loader.h> #include <malloc.h> @@ -76,9 +74,7 @@ efi_status_t efi_exit_func(efi_status_t ret) static efi_status_t efi_unsupported(const char *funcname) { -#ifdef DEBUG_EFI - printf("EFI: App called into unimplemented function %s\n", funcname); -#endif + debug("EFI: App called into unimplemented function %s\n", funcname); return EFI_EXIT(EFI_UNSUPPORTED); } @@ -458,19 +454,30 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle, efi_is_direct_boot = false; /* call the image! */ + if (setjmp(&info->exit_jmp)) { + /* We returned from the child image */ + return EFI_EXIT(info->exit_status); + } + entry(image_handle, &systab); /* Should usually never get here */ return EFI_EXIT(EFI_SUCCESS); } -static efi_status_t EFIAPI efi_exit(void *image_handle, long exit_status, - unsigned long exit_data_size, - uint16_t *exit_data) +static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle, + efi_status_t exit_status, unsigned long exit_data_size, + int16_t *exit_data) { + struct efi_loaded_image *loaded_image_info = (void*)image_handle; + EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status, exit_data_size, exit_data); - return EFI_EXIT(efi_unsupported(__func__)); + + loaded_image_info->exit_status = exit_status; + longjmp(&loaded_image_info->exit_jmp); + + panic("EFI application exited"); } static struct efi_object *efi_search_obj(void *handle) @@ -746,7 +753,7 @@ static const struct efi_boot_services efi_boot_services = { .install_configuration_table = efi_install_configuration_table, .load_image = efi_load_image, .start_image = efi_start_image, - .exit = (void*)efi_exit, + .exit = efi_exit, .unload_image = efi_unload_image, .exit_boot_services = efi_exit_boot_services, .get_next_monotonic_count = efi_get_next_monotonic_count, diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index f9ad6156b71..c434c92250a 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -84,10 +84,8 @@ static efi_status_t EFIAPI efi_disk_rw_blocks(struct efi_block_io *this, blocks = buffer_size / blksz; lba += diskobj->offset; -#ifdef DEBUG_EFI - printf("EFI: %s:%d blocks=%x lba=%"PRIx64" blksz=%x dir=%d\n", __func__, - __LINE__, blocks, lba, blksz, direction); -#endif + debug("EFI: %s:%d blocks=%x lba=%"PRIx64" blksz=%x dir=%d\n", __func__, + __LINE__, blocks, lba, blksz, direction); /* We only support full block access */ if (buffer_size & (blksz - 1)) @@ -101,9 +99,8 @@ static efi_status_t EFIAPI efi_disk_rw_blocks(struct efi_block_io *this, /* We don't do interrupts, so check for timers cooperatively */ efi_timer_check(); -#ifdef DEBUG_EFI - printf("EFI: %s:%d n=%lx blocks=%x\n", __func__, __LINE__, n, blocks); -#endif + debug("EFI: %s:%d n=%lx blocks=%x\n", __func__, __LINE__, n, blocks); + if (n != blocks) return EFI_EXIT(EFI_DEVICE_ERROR); diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c index dc6e2615ccc..33a3d717671 100644 --- a/lib/efi_loader/efi_gop.c +++ b/lib/efi_loader/efi_gop.c @@ -7,10 +7,12 @@ */ #include <common.h> +#include <dm.h> #include <efi_loader.h> #include <inttypes.h> #include <lcd.h> #include <malloc.h> +#include <video.h> DECLARE_GLOBAL_DATA_PTR; @@ -24,6 +26,8 @@ struct efi_gop_obj { /* The only mode we support */ struct efi_gop_mode_info info; struct efi_gop_mode mode; + /* Fields we only have acces to during init */ + u32 bpix; }; static efi_status_t EFIAPI gop_query_mode(struct efi_gop *this, u32 mode_number, @@ -57,6 +61,7 @@ static efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer, unsigned long dy, unsigned long width, unsigned long height, unsigned long delta) { + struct efi_gop_obj *gopobj = container_of(this, struct efi_gop_obj, ops); int i, j, line_len16, line_len32; void *fb; @@ -67,13 +72,17 @@ static efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer, return EFI_EXIT(EFI_INVALID_PARAMETER); fb = (void*)gd->fb_base; - line_len16 = panel_info.vl_col * sizeof(u16); - line_len32 = panel_info.vl_col * sizeof(u32); + line_len16 = gopobj->info.width * sizeof(u16); + line_len32 = gopobj->info.width * sizeof(u32); /* Copy the contents line by line */ - switch (panel_info.vl_bpix) { + switch (gopobj->bpix) { +#ifdef CONFIG_DM_VIDEO + case VIDEO_BPP32: +#else case LCD_COLOR32: +#endif for (i = 0; i < height; i++) { u32 *dest = fb + ((i + dy) * line_len32) + (dx * sizeof(u32)); @@ -84,7 +93,11 @@ static efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer, memcpy(dest, src, width * sizeof(u32)); } break; +#ifdef CONFIG_DM_VIDEO + case VIDEO_BPP16: +#else case LCD_COLOR16: +#endif for (i = 0; i < height; i++) { u16 *dest = fb + ((i + dy) * line_len16) + (dx * sizeof(u16)); @@ -102,7 +115,11 @@ static efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer, break; } +#ifdef CONFIG_DM_VIDEO + video_sync_all(); +#else lcd_sync(); +#endif return EFI_EXIT(EFI_SUCCESS); } @@ -111,10 +128,34 @@ static efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer, int efi_gop_register(void) { struct efi_gop_obj *gopobj; + u32 bpix, col, row; - switch (panel_info.vl_bpix) { +#ifdef CONFIG_DM_VIDEO + struct udevice *vdev; + + /* We only support a single video output device for now */ + if (uclass_first_device(UCLASS_VIDEO, &vdev)) + return -1; + + struct video_priv *priv = dev_get_uclass_priv(vdev); + bpix = priv->bpix; + col = video_get_xsize(vdev); + row = video_get_ysize(vdev); +#else + + bpix = panel_info.vl_bpix; + col = panel_info.vl_col; + row = panel_info.vl_row; +#endif + + switch (bpix) { +#ifdef CONFIG_DM_VIDEO + case VIDEO_BPP16: + case VIDEO_BPP32: +#else case LCD_COLOR32: case LCD_COLOR16: +#endif break; default: /* So far, we only work in 16 or 32 bit mode */ @@ -137,10 +178,12 @@ int efi_gop_register(void) gopobj->mode.info_size = sizeof(gopobj->info); gopobj->info.version = 0; - gopobj->info.width = panel_info.vl_col; - gopobj->info.height = panel_info.vl_row; + gopobj->info.width = col; + gopobj->info.height = row; gopobj->info.pixel_format = EFI_GOT_RGBA8; - gopobj->info.pixels_per_scanline = panel_info.vl_col; + gopobj->info.pixels_per_scanline = col; + + gopobj->bpix = bpix; /* Hook up to the device list */ list_add_tail(&gopobj->parent.link, &efi_obj_list); diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 9e669f51026..df2381e42c2 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -6,8 +6,6 @@ * SPDX-License-Identifier: GPL-2.0+ */ -/* #define DEBUG_EFI */ - #include <common.h> #include <efi_loader.h> #include <malloc.h> @@ -24,6 +22,10 @@ struct efi_mem_list { struct efi_mem_desc desc; }; +#define EFI_CARVE_NO_OVERLAP -1 +#define EFI_CARVE_LOOP_AGAIN -2 +#define EFI_CARVE_OVERLAPS_NONRAM -3 + /* This list contains all memory map items */ LIST_HEAD(efi_mem); @@ -78,11 +80,11 @@ static int efi_mem_carve_out(struct efi_mem_list *map, /* check whether we're overlapping */ if ((carve_end <= map_start) || (carve_start >= map_end)) - return 0; + return EFI_CARVE_NO_OVERLAP; /* We're overlapping with non-RAM, warn the caller if desired */ if (overlap_only_ram && (map_desc->type != EFI_CONVENTIONAL_MEMORY)) - return -1; + return EFI_CARVE_OVERLAPS_NONRAM; /* Sanitize carve_start and carve_end to lie within our bounds */ carve_start = max(carve_start, map_start); @@ -97,7 +99,7 @@ static int efi_mem_carve_out(struct efi_mem_list *map, map_desc->physical_start = carve_end; map_desc->num_pages = (map_end - carve_end) >> EFI_PAGE_SHIFT; - return 1; + return (carve_end - carve_start) >> EFI_PAGE_SHIFT; } /* @@ -117,7 +119,7 @@ static int efi_mem_carve_out(struct efi_mem_list *map, /* Shrink the map to [ map_start ... carve_start ] */ map_desc->num_pages = (carve_start - map_start) >> EFI_PAGE_SHIFT; - return 1; + return EFI_CARVE_LOOP_AGAIN; } uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, @@ -125,7 +127,8 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, { struct list_head *lhandle; struct efi_mem_list *newlist; - bool do_carving; + bool carve_again; + uint64_t carved_pages = 0; if (!pages) return start; @@ -152,7 +155,7 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, /* Add our new map */ do { - do_carving = false; + carve_again = false; list_for_each(lhandle, &efi_mem) { struct efi_mem_list *lmem; int r; @@ -160,14 +163,44 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, lmem = list_entry(lhandle, struct efi_mem_list, link); r = efi_mem_carve_out(lmem, &newlist->desc, overlap_only_ram); - if (r < 0) { + switch (r) { + case EFI_CARVE_OVERLAPS_NONRAM: + /* + * The user requested to only have RAM overlaps, + * but we hit a non-RAM region. Error out. + */ return 0; - } else if (r) { - do_carving = true; + case EFI_CARVE_NO_OVERLAP: + /* Just ignore this list entry */ + break; + case EFI_CARVE_LOOP_AGAIN: + /* + * We split an entry, but need to loop through + * the list again to actually carve it. + */ + carve_again = true; + break; + default: + /* We carved a number of pages */ + carved_pages += r; + carve_again = true; + break; + } + + if (carve_again) { + /* The list changed, we need to start over */ break; } } - } while (do_carving); + } while (carve_again); + + if (overlap_only_ram && (carved_pages != pages)) { + /* + * The payload wanted to have RAM overlaps, but we overlapped + * with an unallocated region. Error out. + */ + return 0; + } /* Add our new map */ list_add_tail(&newlist->link, &efi_mem); diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 11d01268d8c..99b5ef11c2e 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -165,9 +165,7 @@ static void efi_runtime_detach(ulong offset) ulong *p = efi_runtime_detach_list[i].ptr; ulong newaddr = patchto ? (patchto + patchoff) : 0; -#ifdef DEBUG_EFI - printf("%s: Setting %p to %lx\n", __func__, p, newaddr); -#endif + debug("%s: Setting %p to %lx\n", __func__, p, newaddr); *p = newaddr; } } @@ -182,10 +180,7 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map) static ulong lastoff = CONFIG_SYS_TEXT_BASE; #endif -#ifdef DEBUG_EFI - printf("%s: Relocating to offset=%lx\n", __func__, offset); -#endif - + debug("%s: Relocating to offset=%lx\n", __func__, offset); for (; (ulong)rel < (ulong)&__efi_runtime_rel_stop; rel++) { ulong base = CONFIG_SYS_TEXT_BASE; ulong *p; @@ -212,10 +207,7 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map) continue; } -#ifdef DEBUG_EFI - printf("%s: Setting %p to %lx\n", __func__, p, newaddr); -#endif - + debug("%s: Setting %p to %lx\n", __func__, p, newaddr); *p = newaddr; flush_dcache_range((ulong)p & ~(EFI_CACHELINE_SIZE - 1), ALIGN((ulong)&p[1], EFI_CACHELINE_SIZE)); diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 70acc29c924..686b89da385 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -30,6 +30,7 @@ static const char * const compat_names[COMPAT_COUNT] = { COMPAT(NVIDIA_TEGRA124_SOR, "nvidia,tegra124-sor"), COMPAT(NVIDIA_TEGRA124_PMC, "nvidia,tegra124-pmc"), COMPAT(NVIDIA_TEGRA20_DC, "nvidia,tegra20-dc"), + COMPAT(NVIDIA_TEGRA186_SDMMC, "nvidia,tegra186-sdhci"), COMPAT(NVIDIA_TEGRA210_SDMMC, "nvidia,tegra210-sdhci"), COMPAT(NVIDIA_TEGRA124_SDMMC, "nvidia,tegra124-sdhci"), COMPAT(NVIDIA_TEGRA30_SDMMC, "nvidia,tegra30-sdhci"), @@ -1169,7 +1170,7 @@ int fdtdec_decode_display_timing(const void *blob, int parent, int index, if (fdtdec_get_bool(blob, node, "doubleclk")) dt->flags |= DISPLAY_FLAGS_DOUBLECLK; - return 0; + return ret; } int fdtdec_setup(void) diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile index 934d6142c3e..8b86c15904c 100644 --- a/lib/libfdt/Makefile +++ b/lib/libfdt/Makefile @@ -5,5 +5,13 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += fdt.o fdt_ro.o fdt_rw.o fdt_strerror.o fdt_sw.o fdt_wip.o \ - fdt_empty_tree.o fdt_addresses.o fdt_region.o +obj-y += \ + fdt.o \ + fdt_ro.o \ + fdt_rw.o \ + fdt_strerror.o \ + fdt_sw.o \ + fdt_wip.o \ + fdt_empty_tree.o \ + fdt_addresses.o \ + fdt_region.o diff --git a/lib/libfdt/README b/lib/libfdt/README index e0598761f92..db40ab25e86 100644 --- a/lib/libfdt/README +++ b/lib/libfdt/README @@ -1,5 +1,5 @@ The libfdt functionality was written by David Gibson. The original -source came from the git repository: +source came from the Git repository: URL: git://ozlabs.org/home/dgibson/git/libfdt.git @@ -11,13 +11,15 @@ commit 857f54e79f74429af20c2b5ecc00ee98af6a3b8b tree 2f648f0f88225a51ded452968d28b4402df8ade0 parent 07a12a08005f3b5cd9337900a6551e450c07b515 -To adapt for u-boot usage, only the applicable files were copied and -imported into the u-boot git repository. +To adapt for U-Boot usage, only the applicable files were copied and +imported into the U-Boot Git repository. + Omitted: -* GPL - u-boot comes with a copy of the GPL license -* test subdirectory - not directly useful for u-boot -After importing, other customizations were performed. See the git log -for details. + * GPL - U-Boot comes with a copy of the GPL license + * test subdirectory - not directly useful for U-Boot + +After importing, other customizations were performed. See the +"git log" for details. Jerry Van Baren diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c index e146aba6eb7..96017a15a27 100644 --- a/lib/libfdt/fdt.c +++ b/lib/libfdt/fdt.c @@ -3,7 +3,7 @@ * Copyright (C) 2006 David Gibson, IBM Corporation. * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause */ -#include "libfdt_env.h" +#include <libfdt_env.h> #ifndef USE_HOSTCC #include <fdt.h> diff --git a/lib/libfdt/fdt_addresses.c b/lib/libfdt/fdt_addresses.c index 76054d98e5f..b6bc66ea323 100644 --- a/lib/libfdt/fdt_addresses.c +++ b/lib/libfdt/fdt_addresses.c @@ -3,7 +3,7 @@ * Copyright (C) 2014 David Gibson <david@gibson.dropbear.id.au> * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause */ -#include "libfdt_env.h" +#include <libfdt_env.h> #ifndef USE_HOSTCC #include <fdt.h> diff --git a/lib/libfdt/fdt_empty_tree.c b/lib/libfdt/fdt_empty_tree.c index 34f1c844313..6fde1eb9eda 100644 --- a/lib/libfdt/fdt_empty_tree.c +++ b/lib/libfdt/fdt_empty_tree.c @@ -3,8 +3,7 @@ * Copyright (C) 2012 David Gibson, IBM Corporation. * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause */ -#include "libfdt_env.h" - +#include <libfdt_env.h> #include <fdt.h> #include <libfdt.h> diff --git a/lib/libfdt/fdt_region.c b/lib/libfdt/fdt_region.c index 747d8bb86aa..d2ce4c1c537 100644 --- a/lib/libfdt/fdt_region.c +++ b/lib/libfdt/fdt_region.c @@ -5,7 +5,7 @@ * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause */ -#include "libfdt_env.h" +#include <libfdt_env.h> #ifndef USE_HOSTCC #include <fdt.h> @@ -18,14 +18,13 @@ /** * fdt_add_region() - Add a new region to our list + * @info: State information + * @offset: Start offset of region + * @size: Size of region * * The region is added if there is space, but in any case we increment the * count. If permitted, and the new region overlaps the last one, we merge * them. - * - * @info: State information - * @offset: Start offset of region - * @size: Size of region */ static int fdt_add_region(struct fdt_region_state *info, int offset, int size) { @@ -119,6 +118,8 @@ int fdt_add_alias_regions(const void *fdt, struct fdt_region *region, int count, /** * fdt_include_supernodes() - Include supernodes required by this node + * @info: State information + * @depth: Current stack depth * * When we decided to include a node or property which is not at the top * level, this function forces the inclusion of higher level nodes. For @@ -131,9 +132,6 @@ int fdt_add_alias_regions(const void *fdt, struct fdt_region *region, int count, * * If we decide to include testing then we need the root node to have a valid * tree. This function adds those regions. - * - * @info: State information - * @depth: Current stack depth */ static int fdt_include_supernodes(struct fdt_region_state *info, int depth) { @@ -203,72 +201,78 @@ int fdt_first_region(const void *fdt, path, path_len, flags, info); } -/* - * Theory of operation +/*********************************************************************** + * + * Theory of operation + * + * Note: in this description 'included' means that a node (or other part + * of the tree) should be included in the region list, i.e. it will have + * a region which covers its part of the tree. + * + * This function maintains some state from the last time it is called. + * It checks the next part of the tree that it is supposed to look at + * (p.nextoffset) to see if that should be included or not. When it + * finds something to include, it sets info->start to its offset. This + * marks the start of the region we want to include. + * + * Once info->start is set to the start (i.e. not -1), we continue + * scanning until we find something that we don't want included. This + * will be the end of a region. At this point we can close off the + * region and add it to the list. So we do so, and reset info->start + * to -1. + * + * One complication here is that we want to merge regions. So when we + * come to add another region later, we may in fact merge it with the + * previous one if one ends where the other starts. + * + * The function fdt_add_region() will return -1 if it fails to add the + * region, because we already have a region ready to be returned, and + * the new one cannot be merged in with it. In this case, we must return + * the region we found, and wait for another call to this function. + * When it comes, we will repeat the processing of the tag and again + * try to add a region. This time it will succeed. + * + * The current state of the pointers (stack, offset, etc.) is maintained + * in a ptrs member. At the start of every loop iteration we make a copy + * of it. The copy is then updated as the tag is processed. Only if we + * get to the end of the loop iteration (and successfully call + * fdt_add_region() if we need to) can we commit the changes we have + * made to these pointers. For example, if we see an FDT_END_NODE tag, + * we will decrement the depth value. But if we need to add a region + * for this tag (let's say because the previous tag is included and this + * FDT_END_NODE tag is not included) then we will only commit the result + * if we were able to add the region. That allows us to retry again next + * time. + * + * We keep track of a variable called 'want' which tells us what we want + * to include when there is no specific information provided by the + * h_include function for a particular property. This basically handles + * the inclusion of properties which are pulled in by virtue of the node + * they are in. So if you include a node, its properties are also + * included. In this case 'want' will be WANT_NODES_AND_PROPS. The + * FDT_REG_DIRECT_SUBNODES feature also makes use of 'want'. While we + * are inside the subnode, 'want' will be set to WANT_NODES_ONLY, so + * that only the subnode's FDT_BEGIN_NODE and FDT_END_NODE tags will be + * included, and properties will be skipped. If WANT_NOTHING is + * selected, then we will just rely on what the h_include() function + * tells us. * + * Using 'want' we work out 'include', which tells us whether this + * current tag should be included or not. As you can imagine, if the + * value of 'include' changes, that means we are on a boundary between + * nodes to include and nodes to exclude. At this point we either close + * off a previous region and add it to the list, or mark the start of a + * new region. * + * Apart from the nodes, we have mem_rsvmap, the FDT_END tag and the + * string list. Each of these dealt with as a whole (i.e. we create a + * region for each if it is to be included). For mem_rsvmap we don't + * allow it to merge with the first struct region. For the stringlist, + * we don't allow it to merge with the last struct region (which + * contains at minimum the FDT_END tag). * + *********************************************************************/ -Note: in this description 'included' means that a node (or other part of -the tree) should be included in the region list, i.e. it will have a region -which covers its part of the tree. - -This function maintains some state from the last time it is called. It -checks the next part of the tree that it is supposed to look at -(p.nextoffset) to see if that should be included or not. When it finds -something to include, it sets info->start to its offset. This marks the -start of the region we want to include. - -Once info->start is set to the start (i.e. not -1), we continue scanning -until we find something that we don't want included. This will be the end -of a region. At this point we can close off the region and add it to the -list. So we do so, and reset info->start to -1. - -One complication here is that we want to merge regions. So when we come to -add another region later, we may in fact merge it with the previous one if -one ends where the other starts. - -The function fdt_add_region() will return -1 if it fails to add the region, -because we already have a region ready to be returned, and the new one -cannot be merged in with it. In this case, we must return the region we -found, and wait for another call to this function. When it comes, we will -repeat the processing of the tag and again try to add a region. This time it -will succeed. - -The current state of the pointers (stack, offset, etc.) is maintained in -a ptrs member. At the start of every loop iteration we make a copy of it. -The copy is then updated as the tag is processed. Only if we get to the end -of the loop iteration (and successfully call fdt_add_region() if we need -to) can we commit the changes we have made to these pointers. For example, -if we see an FDT_END_NODE tag we will decrement the depth value. But if we -need to add a region for this tag (let's say because the previous tag is -included and this FDT_END_NODE tag is not included) then we will only commit -the result if we were able to add the region. That allows us to retry again -next time. - -We keep track of a variable called 'want' which tells us what we want to -include when there is no specific information provided by the h_include -function for a particular property. This basically handles the inclusion of -properties which are pulled in by virtue of the node they are in. So if you -include a node, its properties are also included. In this case 'want' will -be WANT_NODES_AND_PROPS. The FDT_REG_DIRECT_SUBNODES feature also makes use -of 'want'. While we are inside the subnode, 'want' will be set to -WANT_NODES_ONLY, so that only the subnode's FDT_BEGIN_NODE and FDT_END_NODE -tags will be included, and properties will be skipped. If WANT_NOTHING is -selected, then we will just rely on what the h_include() function tells us. - -Using 'want' we work out 'include', which tells us whether this current tag -should be included or not. As you can imagine, if the value of 'include' -changes, that means we are on a boundary between nodes to include and nodes -to exclude. At this point we either close off a previous region and add it -to the list, or mark the start of a new region. - -Apart from the nodes, we have mem_rsvmap, the FDT_END tag and the string -list. Each of these dealt with as a whole (i.e. we create a region for each -if it is to be included). For mem_rsvmap we don't allow it to merge with -the first struct region. For the stringlist we don't allow it to merge with -the last struct region (which contains at minimum the FDT_END tag). -*/ int fdt_next_region(const void *fdt, int (*h_include)(void *priv, const void *fdt, int offset, int type, const char *data, int size), diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c index 7b0777b67eb..12214c2dc2b 100644 --- a/lib/libfdt/fdt_ro.c +++ b/lib/libfdt/fdt_ro.c @@ -3,7 +3,7 @@ * Copyright (C) 2006 David Gibson, IBM Corporation. * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause */ -#include "libfdt_env.h" +#include <libfdt_env.h> #ifndef USE_HOSTCC #include <fdt.h> @@ -19,7 +19,7 @@ static int _fdt_nodename_eq(const void *fdt, int offset, { const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1); - if (! p) + if (!p) /* short match */ return 0; @@ -115,7 +115,7 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, /* * Find the next of path seperator, note we need to search for both '/' and ':' - * and then take the first one so that we do the rigth thing for e.g. + * and then take the first one so that we do the right thing for e.g. * "foo/bar:option" and "bar:option/otheroption", both of which happen, so * first searching for either ':' or '/' does not work. */ @@ -163,7 +163,7 @@ int fdt_path_offset(const void *fdt, const char *path) if (*p == '\0' || *p == ':') return offset; q = fdt_path_next_seperator(p); - if (! q) + if (!q) q = end; offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p); @@ -273,7 +273,7 @@ const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, const struct fdt_property *prop; prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp); - if (! prop) + if (!prop) return NULL; return prop->data; diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c index 1a358a8ca0a..e7321ccae47 100644 --- a/lib/libfdt/fdt_rw.c +++ b/lib/libfdt/fdt_rw.c @@ -3,7 +3,7 @@ * Copyright (C) 2006 David Gibson, IBM Corporation. * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause */ -#include "libfdt_env.h" +#include <libfdt_env.h> #ifndef USE_HOSTCC #include <fdt.h> @@ -168,7 +168,7 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name, int err; *prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); - if (! (*prop)) + if (!(*prop)) return oldlen; if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen), @@ -283,7 +283,7 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name) FDT_RW_CHECK_HEADER(fdt); prop = fdt_get_property_w(fdt, nodeoffset, name, &len); - if (! prop) + if (!prop) return len; proplen = sizeof(*prop) + FDT_TAGALIGN(len); diff --git a/lib/libfdt/fdt_strerror.c b/lib/libfdt/fdt_strerror.c index 2f3cc243dba..3b7e1683d0d 100644 --- a/lib/libfdt/fdt_strerror.c +++ b/lib/libfdt/fdt_strerror.c @@ -3,7 +3,7 @@ * Copyright (C) 2006 David Gibson, IBM Corporation. * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause */ -#include "libfdt_env.h" +#include <libfdt_env.h> #ifndef USE_HOSTCC #include <fdt.h> diff --git a/lib/libfdt/fdt_sw.c b/lib/libfdt/fdt_sw.c index 345a3acbf8e..70fd0265507 100644 --- a/lib/libfdt/fdt_sw.c +++ b/lib/libfdt/fdt_sw.c @@ -3,8 +3,7 @@ * Copyright (C) 2006 David Gibson, IBM Corporation. * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause */ -#include "libfdt_env.h" - +#include <libfdt_env.h> #include <fdt.h> #include <libfdt.h> diff --git a/lib/libfdt/fdt_wip.c b/lib/libfdt/fdt_wip.c index 3f2dfa573b6..9fe988655fe 100644 --- a/lib/libfdt/fdt_wip.c +++ b/lib/libfdt/fdt_wip.c @@ -3,7 +3,7 @@ * Copyright (C) 2006 David Gibson, IBM Corporation. * SPDX-License-Identifier: GPL-2.0+ BSD-2-Clause */ -#include "libfdt_env.h" +#include <libfdt_env.h> #ifndef USE_HOSTCC #include <fdt.h> @@ -21,7 +21,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, int proplen; propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen); - if (! propval) + if (!propval) return proplen; if (proplen != len) @@ -45,7 +45,7 @@ int fdt_nop_property(void *fdt, int nodeoffset, const char *name) int len; prop = fdt_get_property_w(fdt, nodeoffset, name, &len); - if (! prop) + if (!prop) return len; _fdt_nop_region(prop, len + sizeof(*prop)); diff --git a/lib/rsa/Kconfig b/lib/rsa/Kconfig index 86df0a0dd83..09ec3582423 100644 --- a/lib/rsa/Kconfig +++ b/lib/rsa/Kconfig @@ -13,6 +13,10 @@ config RSA option. The software based modular exponentiation is built into mkimage irrespective of this option. +config SPL_RSA + bool "Use RSA Library within SPL" + depends on RSA + if RSA config RSA_SOFTWARE_EXP bool "Enable driver for RSA Modular Exponentiation in software" diff --git a/lib/rsa/Makefile b/lib/rsa/Makefile index 6867e5054c0..4b2c1bae79b 100644 --- a/lib/rsa/Makefile +++ b/lib/rsa/Makefile @@ -7,5 +7,5 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-$(CONFIG_FIT_SIGNATURE) += rsa-verify.o rsa-checksum.o +obj-$(CONFIG_$(SPL_)FIT_SIGNATURE) += rsa-verify.o rsa-checksum.o obj-$(CONFIG_RSA_SOFTWARE_EXP) += rsa-mod-exp.o diff --git a/lib/string.c b/lib/string.c index 87c9a408e62..67d5f6a4213 100644 --- a/lib/string.c +++ b/lib/string.c @@ -461,30 +461,6 @@ void * memset(void * s,int c,size_t count) } #endif -#ifndef __HAVE_ARCH_BCOPY -/** - * bcopy - Copy one area of memory to another - * @src: Where to copy from - * @dest: Where to copy to - * @count: The size of the area. - * - * Note that this is the same as memcpy(), with the arguments reversed. - * memcpy() is the standard, bcopy() is a legacy BSD function. - * - * You should not use this function to access IO space, use memcpy_toio() - * or memcpy_fromio() instead. - */ -char * bcopy(const char * src, char * dest, int count) -{ - char *tmp = dest; - - while (count--) - *tmp++ = *src++; - - return dest; -} -#endif - #ifndef __HAVE_ARCH_MEMCPY /** * memcpy - Copy one area of memory to another diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index 5ea2555280b..3c65fc90bf2 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -168,8 +168,10 @@ int snprintf(char *buf, size_t size, const char *fmt, ...) int ret; va_start(va, fmt); - ret = sprintf(buf, fmt, va); + outstr = buf; + ret = _vprintf(fmt, va, putc_outstr); va_end(va); + *outstr = '\0'; return ret; } diff --git a/lib/tizen/tizen.c b/lib/tizen/tizen.c index 814ed18329e..d207f77d0b3 100644 --- a/lib/tizen/tizen.c +++ b/lib/tizen/tizen.c @@ -12,6 +12,7 @@ #include "tizen_logo_16bpp.h" #include "tizen_logo_16bpp_gzip.h" +#ifdef CONFIG_LCD void get_tizen_logo_info(vidinfo_t *vid) { switch (vid->vl_bpix) { @@ -31,3 +32,4 @@ void get_tizen_logo_info(vidinfo_t *vid) break; } } +#endif |