-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootimgtool.h
97 lines (79 loc) · 2.53 KB
/
bootimgtool.h
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* Copyright (C) 2015 Vianney le Clément de Saint-Marcq <[email protected]>
*
* 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; version 3 of the License.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BOOTIMGTOOL_H
#define BOOTIMGTOOL_H
#include "bootimg.h"
#include "io.h"
#define MAX_CMDLINE_SIZE (BOOT_ARGS_SIZE + BOOT_EXTRA_ARGS_SIZE)
#define ROUND_PAGE(size, pagesize) \
((((size) + (pagesize) - 1) / (pagesize)) * (pagesize))
enum action {
ACTION_UNDEFINED,
ACTION_INFO,
ACTION_EXTRACT,
ACTION_CREATE,
};
struct bootimg {
struct iomap image;
struct iomap params;
struct iomap kernel;
struct iomap ramdisk;
struct iomap second;
struct iomap dt;
unsigned kernel_addr;
unsigned ramdisk_addr;
unsigned second_addr;
unsigned dt_addr;
unsigned tags_addr;
unsigned page_size;
char name[BOOT_NAME_SIZE];
char cmdline[MAX_CMDLINE_SIZE];
};
struct variant {
/**
* Name of the variant as given in arguments.
*/
const char *name;
/**
* Short description for inclusion in the help message.
*/
const char *description;
/**
* Read img->image, interpret header, and fill relevant fields in img.
* In particular, img->{kernel,ramdisk,second,dt}.data should point to the
* corresponding part in img->image.data.
*
* @param img A boot image with img->image.name filled.
* @return 0 on success, -1 on error (an error message should have been
* written on stderr)
*/
int (*read)(struct bootimg *img);
/**
* Create a new image to img->image.name with the information from the
* other fields.
*
* @param img A complete boot image.
* @param fd File descriptor to write to.
* @return 0 on success, -1 on error (an error message should have been
* written on stderr)
*/
int (*write)(struct bootimg *img, int fd);
};
// Implemented variants
extern struct variant variant_standard;
extern struct variant variant_qcom;
extern struct variant variant_fsl;
#endif // BOOTIMGTOOL_H