aboutsummaryrefslogtreecommitdiff
path: root/src/include/fit.h
blob: 1b2f975042482b6f5e2c0d93d639b9a04f329eb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * 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 __BOOT_FIT_H__
#define __BOOT_FIT_H__

#include <stddef.h>
#include <stdint.h>

#include "base/device_tree.h"
#include "base/list.h"

typedef enum CompressionType
{
	CompressionInvalid,
	CompressionNone,
	CompressionLzma,
	CompressionLz4,
} CompressionType;

typedef struct FitImageNode
{
	const char *name;
	void *data;
	uint32_t size;
	CompressionType compression;

	ListNode list_node;
} FitImageNode;

typedef struct FitConfigNode
{
	const char *name;
	const char *kernel;
	FitImageNode *kernel_node;
	const char *fdt;
	FitImageNode *fdt_node;
	const char *ramdisk;
	FitImageNode *ramdisk_node;
	FdtProperty compat;
	int compat_rank;
	int compat_pos;

	ListNode list_node;
} FitConfigNode;

/*
 * 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.
 */
FitImageNode *fit_load(void *fit, char *cmd_line, DeviceTree **dt);

/*
 * 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)!
 */
void fit_add_compat(const char *compat);

void fit_add_ramdisk(DeviceTree *tree, void *ramdisk_addr, size_t ramdisk_size);

#endif /* __BOOT_FIT_H__ */