blob: 032c00ec3ada67052f5b30cbdc94f91bce145087 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef __IMAGE_LOADER_H__
8#define __IMAGE_LOADER_H__
9
10#include <firmware_image_package.h>
11#include <stddef.h>
12#include <stdint.h>
13
14/* Generic function to get flash offset of an image */
15unsigned long get_image_offset(unsigned int image_id);
16
17/* Generic function to return the size of an image */
18unsigned long get_image_size(unsigned int image_id);
19
20/*
21 * Generic function to load an image at a specific address given an image id
22 * Returns 0 on success, a negative error code otherwise.
23 */
24int load_image(unsigned int image_id,
25 uintptr_t image_base);
26
27/*
28 * Generic function to load partial image at a specific address given
29 * an image id. The flag argument is used to indicate last block to be
30 * loaded in the partial loading scenario. If is_last_block == 0 then
31 * devices are closed else they are kept open for partial image loading.
32 * Returns 0 on success, a negative error code otherwise.
33 */
34int load_partial_image(unsigned int image_id,
35 uintptr_t image_base,
36 size_t image_size,
37 unsigned int is_last_block);
38
39/* This is to keep track of file related data. */
40typedef struct {
41 unsigned int file_pos;
42 fip_toc_entry_t entry;
43} fip_file_state_t;
44
45#endif /* __IMAGE_LOADER_H__ */