2018-04-19 14:39:07 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
2018-04-19 14:39:07 +02:00
|
|
|
* Copyright 2018-present Facebook, Inc.
|
2018-04-19 14:39:07 +02:00
|
|
|
*
|
2018-04-19 14:39:07 +02:00
|
|
|
* Taken from depthcharge: src/boot/fit.h
|
2018-04-19 14:39:07 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2018-04-19 14:39:07 +02:00
|
|
|
#ifndef __LIB_FIT_H__
|
|
|
|
#define __LIB_FIT_H__
|
2018-04-19 14:39:07 +02:00
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
2018-04-19 14:39:07 +02:00
|
|
|
#include <device_tree.h>
|
|
|
|
#include <list.h>
|
|
|
|
#include <program_loading.h>
|
2018-04-19 14:39:07 +02:00
|
|
|
|
2019-05-17 01:12:04 +02:00
|
|
|
struct fit_image_node {
|
2018-04-19 14:39:07 +02:00
|
|
|
const char *name;
|
2019-05-14 01:34:16 +02:00
|
|
|
void *data;
|
2018-04-19 14:39:07 +02:00
|
|
|
uint32_t size;
|
2018-04-19 14:39:07 +02:00
|
|
|
int compression;
|
2018-04-19 14:39:07 +02:00
|
|
|
|
2018-04-19 14:39:07 +02:00
|
|
|
struct list_node list_node;
|
|
|
|
};
|
2018-04-19 14:39:07 +02:00
|
|
|
|
2019-05-17 01:12:04 +02:00
|
|
|
struct fit_config_node {
|
2018-04-19 14:39:07 +02:00
|
|
|
const char *name;
|
2019-05-14 01:34:16 +02:00
|
|
|
struct fit_image_node *kernel;
|
|
|
|
struct fit_image_node *fdt;
|
2019-05-17 01:12:04 +02:00
|
|
|
struct list_node overlays;
|
2019-05-14 01:34:16 +02:00
|
|
|
struct fit_image_node *ramdisk;
|
2018-04-19 14:39:07 +02:00
|
|
|
struct fdt_property compat;
|
2018-04-19 14:39:07 +02:00
|
|
|
int compat_rank;
|
|
|
|
int compat_pos;
|
2018-04-19 14:39:07 +02:00
|
|
|
const char *compat_string;
|
2018-04-19 14:39:07 +02:00
|
|
|
|
2018-04-19 14:39:07 +02:00
|
|
|
struct list_node list_node;
|
|
|
|
};
|
2018-04-19 14:39:07 +02:00
|
|
|
|
2019-05-17 01:12:04 +02:00
|
|
|
struct fit_overlay_chain {
|
|
|
|
struct fit_image_node *overlay;
|
|
|
|
struct list_node list_node;
|
|
|
|
};
|
|
|
|
|
2018-04-19 14:39:07 +02:00
|
|
|
/*
|
2018-04-19 14:39:07 +02:00
|
|
|
* Updates the cmdline in the devicetree.
|
|
|
|
*/
|
2018-08-22 09:55:15 +02:00
|
|
|
void fit_update_chosen(struct device_tree *tree, const char *cmd_line);
|
2018-04-19 14:39:07 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
2018-04-19 14:39:07 +02:00
|
|
|
*/
|
2018-04-19 14:39:07 +02:00
|
|
|
void fit_add_compat_string(const char *str);
|
2018-04-19 14:39:07 +02:00
|
|
|
|
|
|
|
/*
|
2018-04-19 14:39:07 +02:00
|
|
|
* 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.
|
2018-04-19 14:39:07 +02:00
|
|
|
*/
|
2018-04-19 14:39:07 +02:00
|
|
|
struct fit_config_node *fit_load(void *fit);
|
2018-04-19 14:39:07 +02:00
|
|
|
|
2018-04-19 14:39:07 +02:00
|
|
|
void fit_add_ramdisk(struct device_tree *tree, void *ramdisk_addr,
|
|
|
|
size_t ramdisk_size);
|
2018-04-19 14:39:07 +02:00
|
|
|
|
2018-04-19 14:39:07 +02:00
|
|
|
#endif /* __LIB_FIT_H__ */
|