aboutsummaryrefslogtreecommitdiff
path: root/include/spl_load.h
AgeCommit message (Collapse)Author
2023-11-16spl: Convert spi to spl_loadSean Anderson
This converts the spi load method to use spl_load. The address used for LOAD_FIT_FULL may be different, but there are no in-tree users of that config. Since payload_offs is only used without OS_BOOT, we defer its initialization. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert semihosting to spl_loadSean Anderson
This converts the semihosting load method to use spl_load. As a result, it also adds support for LOAD_FIT_FULL and IMX images. Signed-off-by: Sean Anderson <seanga2@gmail.com>
2023-11-16spl: Convert NVMe to spl_loadSean Anderson
This converts the blk load method (used exclusively by NVMe) to use spl_load. As a consequence, it also adds support for LOAD_FIT_FULL and IMX images. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert nor to spl_loadSean Anderson
This converts the nor load method to use spl_load. As a result it also adds support for LOAD_FIT_FULL. Since this is the last caller of spl_load_legacy_img, it has been removed. We can't load FITs with external data with SPL_LOAD_FIT_FULL, so disable the test in that case. No boards enable SPL_NOR_SUPPORT and SPL_LOAD_FIT_FULL, so this is not a regression. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert net to spl_loadSean Anderson
This converts the net load method to use spl_load. As a result, it also adds support for LOAD_FIT_FULL and IMX images. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert nand to spl_loadSean Anderson
This converts the nand load method to use spl_load. nand_page_size may not be valid until after nand_spl_load_image is called (see e.g. fsl_ifc_spl), so we set bl_len in spl_nand_read. Since spl_load reads the header for us, we can remove that argument from spl_nand_load_element. There are two possible regressions which could result from this commit. First, we ask for a negative address from spl_get_load_buffer. That is, instead of header = spl_get_load_buffer(0, sizeof(*header)); we do header = spl_get_load_buffer(-sizeof(*header), sizeof(*header)); this could cause a problem if spl_get_load_buffer does not return valid memory for negative offsets. Second, we now set bl_len for legacy images. This can cause memory up to a bl_len - 1 before the image load address to be written, which might not have been the case before. If this turns out to be a problem, we can add an option for a bounce buffer. We can't load FITs with external data with SPL_LOAD_FIT_FULL, so disable the test in that case. No boards enable SPL_NAND_SUPPORT and SPL_LOAD_FIT_FULL, so this is not a regression. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert mmc to spl_loadSean Anderson
This converts the mmc loader to spl_load. Legacy images are handled by spl_load (via spl_parse_image_header), so mmc_load_legacy can be omitted. To accurately determine whether mmc_load_image_raw_sector is used (which might not be the case if SYS_MMCSD_FS_BOOT is enabled), we introduce a helper config SYS_MMCSD_RAW_MODE. This ensures we can inline spl_load correctly when a board only boots from filesystems. We still need to check for SPL_MMC, since some boards enable configure raw mode even without MMC support. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert fat to spl_loadSean Anderson
This converts the fat loader to use spl_load. Some platforms are very tight on space, so we take care to only include the code we really need. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Convert ext to use spl_loadSean Anderson
This converts the ext load method to use spl_load. As a consequence, it also adds support for FIT and IMX images. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-11-16spl: Add generic spl_load functionSean Anderson
Implementers of SPL_LOAD_IMAGE_METHOD have to correctly determine what type of image is being loaded and then call the appropriate image load function correctly. This is tricky, because some image load functions expect the whole image to already be loaded (CONFIG_SPL_LOAD_FIT_FULL), some will load the image automatically using spl_load_info.read() (CONFIG_SPL_LOAD_FIT/CONFIG_SPL_LOAD_IMX_CONTAINER), and some just parse the header and expect the caller to do the actual loading afterwards (legacy/raw images). Load methods often only support a subset of the above methods, meaning that not all image types can be used with all load methods. Further, the code to invoke these functions is duplicated between different load functions. To address this problem, this commit introduces a "spl_load" function. It aims to handle image detection and correct invocation of each of the parse/load functions. Although this function generally results in a size reduction with several users, it tends to bloat boards with only a single user. This is generally because programmers open-coding the contents of this function can make optimizations based on the specific loader. For example, NOR flash is memory-mapped, so it never bothers calling load->read. The compiler can't really make these optimizations across translation units. LTO solves this, but it is only available on some arches. To address this, perform "pseudo-LTO" by inlining spl_load when there are one or fewer users. At the moment, there are no users, so define SPL_LOAD_USERS to be 0. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>