diff options
author | Patrick Rudolph <patrick.rudolph@9elements.com> | 2018-04-19 14:39:07 +0200 |
---|---|---|
committer | Philipp Deppenwiese <zaolin.daisuki@gmail.com> | 2018-06-19 18:10:05 +0000 |
commit | a892cde653d40e39d399b1bc4c438e3dc2d00cd6 (patch) | |
tree | 369d008d2cc9ec931925b75a2f2805ef4636d841 /src/include | |
parent | 8c986ab26358b40863f7404c97e8afbb118789f1 (diff) | |
download | coreboot-a892cde653d40e39d399b1bc4c438e3dc2d00cd6.tar.xz |
lib: Add FIT payload support
* Add support for parsing and booting FIT payloads.
* Build fit loader code from depthcharge.
* Fix coding style.
* Add Kconfig option to add compiletime support for FIT.
* Add support for initrd.
* Add default compat strings
* Apply optional devicetree fixups using dt_apply_fixups
Starting at this point the CBFS payload/ can be either SELF or FIT.
Tested on Cavium SoC: Parses and loads a Linux kernel 4.16.3.
Tested on Cavium SoC: Parses and loads a Linux kernel 4.15.0.
Tested on Cavium SoC: Parses and loads a Linux kernel 4.1.52.
Change-Id: I0f27b92a5e074966f893399eb401eb97d784850d
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/25019
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/fit.h | 95 | ||||
-rw-r--r-- | src/include/fit_payload.h | 26 |
2 files changed, 84 insertions, 37 deletions
diff --git a/src/include/fit.h b/src/include/fit.h index 1b2f975042..eb51b50edb 100644 --- a/src/include/fit.h +++ b/src/include/fit.h @@ -1,8 +1,8 @@ /* * Copyright 2013 Google Inc. + * Copyright 2018-present Facebook, Inc. * - * See file CREDITS for list of people who contributed to this - * project. + * Taken from depthcharge: src/boot/fit.h * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -15,64 +15,85 @@ * GNU General Public License for more details. */ -#ifndef __BOOT_FIT_H__ -#define __BOOT_FIT_H__ +#ifndef __LIB_FIT_H__ +#define __LIB_FIT_H__ #include <stddef.h> #include <stdint.h> +#include <device_tree.h> +#include <list.h> +#include <program_loading.h> -#include "base/device_tree.h" -#include "base/list.h" - -typedef enum CompressionType -{ - CompressionInvalid, - CompressionNone, - CompressionLzma, - CompressionLz4, -} CompressionType; - -typedef struct FitImageNode +struct fit_image_node { const char *name; void *data; uint32_t size; - CompressionType compression; + int compression; - ListNode list_node; -} FitImageNode; + struct list_node list_node; +}; -typedef struct FitConfigNode +struct fit_config_node { const char *name; const char *kernel; - FitImageNode *kernel_node; + struct fit_image_node *kernel_node; const char *fdt; - FitImageNode *fdt_node; + struct fit_image_node *fdt_node; const char *ramdisk; - FitImageNode *ramdisk_node; - FdtProperty compat; + struct fit_image_node *ramdisk_node; + struct fdt_property compat; int compat_rank; int compat_pos; + const char *compat_string; - ListNode list_node; -} FitConfigNode; + struct list_node list_node; +}; /* - * Unpack a FIT image into memory, choosing the right configuration through the - * compatible string set by fit_add_compat() and unflattening the corresponding - * kernel device tree. + * Updates the cmdline in the devicetree. + */ +void fit_update_chosen(struct device_tree *tree, char *cmd_line); + +/* + * Add a compat string to the list of supported board ids. + * Has to be called before fit_load(). + * The most common use-case would be to implement it on board level. + * Strings that were added first have a higher priority on finding a match. */ -FitImageNode *fit_load(void *fit, char *cmd_line, DeviceTree **dt); +void fit_add_compat_string(const char *str); /* - * Add a compatible string for the preferred kernel DT to the list for this - * platform. This should be called before the first fit_load() so it will be - * ranked as a better match than the default compatible strings. |compat| must - * stay accessible throughout depthcharge's runtime (i.e. not stack-allocated)! + * Updates the memory section in the devicetree. + */ +void fit_update_memory(struct device_tree *tree); + +/* + * Do architecture specific payload placements and fixups. + * Set entrypoint and first argument (if any). + * @param payload The payload, to set the entry point + * @param config The extracted FIT config + * @param kernel out-argument where to place the kernel + * @param fdt out-argument where to place the devicetree + * @param initrd out-argument where to place the initrd (optional) + * @return True if all config nodes could be placed, the corresponding + * regions have been updated and the entry point has been set. + * False on error. + */ +bool fit_payload_arch(struct prog *payload, struct fit_config_node *config, + struct region *kernel, + struct region *fdt, + struct region *initrd); + +/* + * Unpack a FIT image into memory, choosing the right configuration through the + * compatible string set by fit_add_compat() and return the selected config + * node. */ -void fit_add_compat(const char *compat); +struct fit_config_node *fit_load(void *fit); -void fit_add_ramdisk(DeviceTree *tree, void *ramdisk_addr, size_t ramdisk_size); +void fit_add_ramdisk(struct device_tree *tree, void *ramdisk_addr, + size_t ramdisk_size); -#endif /* __BOOT_FIT_H__ */ +#endif /* __LIB_FIT_H__ */ diff --git a/src/include/fit_payload.h b/src/include/fit_payload.h new file mode 100644 index 0000000000..dd66289853 --- /dev/null +++ b/src/include/fit_payload.h @@ -0,0 +1,26 @@ +/* + * Copyright 2013 Google Inc. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program 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 of + * the License, or (at your option) any later version. + * + * This program 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. + */ + +#ifndef __FIT_PAYLOAD_H_ +#define __FIT_PAYLOAD_H_ + +#include <program_loading.h> +#include <stdint.h> + +void fit_payload(struct prog *payload); + +#endif /* __FIT_PAYLOAD_H_ */ |