Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
7cee77f5
Commit
7cee77f5
authored
Feb 21, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some C++ magic to make code cleaner
parent
f28bd197
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
91 deletions
+126
-91
bootimg.cpp
native/jni/magiskboot/bootimg.cpp
+35
-36
bootimg.h
native/jni/magiskboot/bootimg.h
+91
-55
No files found.
native/jni/magiskboot/bootimg.cpp
View file @
7cee77f5
...
@@ -25,7 +25,7 @@ static size_t restore(const char *filename, int fd) {
...
@@ -25,7 +25,7 @@ static size_t restore(const char *filename, int fd) {
int
ifd
=
xopen
(
filename
,
O_RDONLY
);
int
ifd
=
xopen
(
filename
,
O_RDONLY
);
size_t
size
=
lseek
(
ifd
,
0
,
SEEK_END
);
size_t
size
=
lseek
(
ifd
,
0
,
SEEK_END
);
lseek
(
ifd
,
0
,
SEEK_SET
);
lseek
(
ifd
,
0
,
SEEK_SET
);
xsendfile
(
fd
,
ifd
,
NULL
,
size
);
xsendfile
(
fd
,
ifd
,
nullptr
,
size
);
close
(
ifd
);
close
(
ifd
);
return
size
;
return
size
;
}
}
...
@@ -36,7 +36,6 @@ static void restore_buf(int fd, const void *buf, size_t size) {
...
@@ -36,7 +36,6 @@ static void restore_buf(int fd, const void *buf, size_t size) {
boot_img
::~
boot_img
()
{
boot_img
::~
boot_img
()
{
munmap
(
map_addr
,
map_size
);
munmap
(
map_addr
,
map_size
);
delete
hdr
;
delete
k_hdr
;
delete
k_hdr
;
delete
r_hdr
;
delete
r_hdr
;
delete
b_hdr
;
delete
b_hdr
;
...
@@ -45,7 +44,7 @@ boot_img::~boot_img() {
...
@@ -45,7 +44,7 @@ boot_img::~boot_img() {
#define CHROMEOS_RET 2
#define CHROMEOS_RET 2
#define ELF32_RET 3
#define ELF32_RET 3
#define ELF64_RET 4
#define ELF64_RET 4
#define pos_align() pos = do_align(pos, page_size())
#define pos_align() pos = do_align(pos,
hdr.
page_size())
int
boot_img
::
parse_image
(
const
char
*
image
)
{
int
boot_img
::
parse_image
(
const
char
*
image
)
{
mmap_ro
(
image
,
(
void
**
)
&
map_addr
,
&
map_size
);
mmap_ro
(
image
,
(
void
**
)
&
map_addr
,
&
map_size
);
...
@@ -80,8 +79,8 @@ int boot_img::parse_image(const char * image) {
...
@@ -80,8 +79,8 @@ int boot_img::parse_image(const char * image) {
if
(((
boot_img_hdr
*
)
head
)
->
page_size
>=
0x02000000
)
{
if
(((
boot_img_hdr
*
)
head
)
->
page_size
>=
0x02000000
)
{
flags
|=
PXA_FLAG
;
flags
|=
PXA_FLAG
;
fprintf
(
stderr
,
"PXA_BOOT_HDR
\n
"
);
fprintf
(
stderr
,
"PXA_BOOT_HDR
\n
"
);
hdr
=
new
boot_img_hdr_pxa
(
);
hdr
.
set_hdr
(
new
boot_img_hdr_pxa
()
);
memcpy
(
hdr
,
head
,
sizeof
(
boot_img_hdr_pxa
));
memcpy
(
*
hdr
,
head
,
sizeof
(
boot_img_hdr_pxa
));
}
else
if
(
memcmp
(((
boot_img_hdr
*
)
head
)
->
cmdline
,
NOOKHD_MAGIC
,
12
)
==
0
}
else
if
(
memcmp
(((
boot_img_hdr
*
)
head
)
->
cmdline
,
NOOKHD_MAGIC
,
12
)
==
0
||
memcmp
(((
boot_img_hdr
*
)
head
)
->
cmdline
,
NOOKHD_NEW_MAGIC
,
26
)
==
0
)
{
||
memcmp
(((
boot_img_hdr
*
)
head
)
->
cmdline
,
NOOKHD_NEW_MAGIC
,
26
)
==
0
)
{
flags
|=
NOOKHD_FLAG
;
flags
|=
NOOKHD_FLAG
;
...
@@ -94,12 +93,12 @@ int boot_img::parse_image(const char * image) {
...
@@ -94,12 +93,12 @@ int boot_img::parse_image(const char * image) {
head
+=
ACCLAIM_PRE_HEADER_SZ
-
1
;
head
+=
ACCLAIM_PRE_HEADER_SZ
-
1
;
continue
;
continue
;
}
else
{
}
else
{
hdr
=
new
boot_img_hdr
(
);
hdr
.
set_hdr
(
new
boot_img_hdr
()
);
memcpy
(
hdr
,
head
,
sizeof
(
boot_img_hdr
));
memcpy
(
*
hdr
,
head
,
sizeof
(
boot_img_hdr
));
}
}
pos
+=
page_size
();
pos
+=
hdr
.
page_size
();
flags
|=
id
()[
SHA_DIGEST_SIZE
]
?
SHA256_FLAG
:
0
;
flags
|=
hdr
.
id
()[
SHA_DIGEST_SIZE
]
?
SHA256_FLAG
:
0
;
print_hdr
();
print_hdr
();
...
@@ -116,11 +115,11 @@ int boot_img::parse_image(const char * image) {
...
@@ -116,11 +115,11 @@ int boot_img::parse_image(const char * image) {
pos_align
();
pos_align
();
extra
=
head
+
pos
;
extra
=
head
+
pos
;
pos
+=
extra_size
();
pos
+=
hdr
.
extra_size
();
pos_align
();
pos_align
();
recov_dtbo
=
head
+
pos
;
recov_dtbo
=
head
+
pos
;
pos
+=
recovery_dtbo_size
();
pos
+=
hdr
.
recovery_dtbo_size
();
pos_align
();
pos_align
();
if
(
pos
<
map_size
)
{
if
(
pos
<
map_size
)
{
...
@@ -214,14 +213,14 @@ void boot_img::find_dtb() {
...
@@ -214,14 +213,14 @@ void boot_img::find_dtb() {
}
}
void
boot_img
::
print_hdr
()
{
void
boot_img
::
print_hdr
()
{
fprintf
(
stderr
,
"HEADER_VER [%u]
\n
"
,
header_version
());
fprintf
(
stderr
,
"HEADER_VER [%u]
\n
"
,
h
dr
.
h
eader_version
());
fprintf
(
stderr
,
"KERNEL_SZ [%u]
\n
"
,
hdr
->
kernel_size
);
fprintf
(
stderr
,
"KERNEL_SZ [%u]
\n
"
,
hdr
->
kernel_size
);
fprintf
(
stderr
,
"RAMDISK_SZ [%u]
\n
"
,
hdr
->
ramdisk_size
);
fprintf
(
stderr
,
"RAMDISK_SZ [%u]
\n
"
,
hdr
->
ramdisk_size
);
fprintf
(
stderr
,
"SECOND_SZ [%u]
\n
"
,
hdr
->
second_size
);
fprintf
(
stderr
,
"SECOND_SZ [%u]
\n
"
,
hdr
->
second_size
);
fprintf
(
stderr
,
"EXTRA_SZ [%u]
\n
"
,
extra_size
());
fprintf
(
stderr
,
"EXTRA_SZ [%u]
\n
"
,
hdr
.
extra_size
());
fprintf
(
stderr
,
"RECOV_DTBO_SZ [%u]
\n
"
,
recovery_dtbo_size
());
fprintf
(
stderr
,
"RECOV_DTBO_SZ [%u]
\n
"
,
hdr
.
recovery_dtbo_size
());
uint32_t
ver
=
os_version
();
uint32_t
ver
=
hdr
.
os_version
();
if
(
ver
)
{
if
(
ver
)
{
int
a
,
b
,
c
,
y
,
m
=
0
;
int
a
,
b
,
c
,
y
,
m
=
0
;
int
version
,
patch_level
;
int
version
,
patch_level
;
...
@@ -238,12 +237,12 @@ void boot_img::print_hdr() {
...
@@ -238,12 +237,12 @@ void boot_img::print_hdr() {
fprintf
(
stderr
,
"PATCH_LEVEL [%d-%02d]
\n
"
,
y
,
m
);
fprintf
(
stderr
,
"PATCH_LEVEL [%d-%02d]
\n
"
,
y
,
m
);
}
}
fprintf
(
stderr
,
"PAGESIZE [%u]
\n
"
,
page_size
());
fprintf
(
stderr
,
"PAGESIZE [%u]
\n
"
,
hdr
.
page_size
());
fprintf
(
stderr
,
"NAME [%s]
\n
"
,
name
());
fprintf
(
stderr
,
"NAME [%s]
\n
"
,
hdr
.
name
());
fprintf
(
stderr
,
"CMDLINE [%.512s%.1024s]
\n
"
,
cmdline
(),
extra_cmdline
());
fprintf
(
stderr
,
"CMDLINE [%.512s%.1024s]
\n
"
,
hdr
.
cmdline
(),
hdr
.
extra_cmdline
());
fprintf
(
stderr
,
"CHECKSUM ["
);
fprintf
(
stderr
,
"CHECKSUM ["
);
for
(
int
i
=
0
;
id
()[
i
];
++
i
)
for
(
int
i
=
0
;
hdr
.
id
()[
i
];
++
i
)
fprintf
(
stderr
,
"%02x"
,
id
()[
i
]);
fprintf
(
stderr
,
"%02x"
,
hdr
.
id
()[
i
]);
fprintf
(
stderr
,
"]
\n
"
);
fprintf
(
stderr
,
"]
\n
"
);
}
}
...
@@ -277,14 +276,14 @@ int unpack(const char *image) {
...
@@ -277,14 +276,14 @@ int unpack(const char *image) {
dump
(
boot
.
second
,
boot
.
hdr
->
second_size
,
SECOND_FILE
);
dump
(
boot
.
second
,
boot
.
hdr
->
second_size
,
SECOND_FILE
);
// Dump extra
// Dump extra
dump
(
boot
.
extra
,
boot
.
extra_size
(),
EXTRA_FILE
);
dump
(
boot
.
extra
,
boot
.
hdr
.
extra_size
(),
EXTRA_FILE
);
// Dump recovery_dtbo
// Dump recovery_dtbo
dump
(
boot
.
recov_dtbo
,
boot
.
recovery_dtbo_size
(),
RECV_DTBO_FILE
);
dump
(
boot
.
recov_dtbo
,
boot
.
hdr
.
recovery_dtbo_size
(),
RECV_DTBO_FILE
);
return
ret
;
return
ret
;
}
}
#define file_align() write_zero(fd, align_off(lseek(fd, 0, SEEK_CUR) - header_off, boot.page_size()))
#define file_align() write_zero(fd, align_off(lseek(fd, 0, SEEK_CUR) - header_off, boot.
hdr.
page_size()))
void
repack
(
const
char
*
orig_image
,
const
char
*
out_image
)
{
void
repack
(
const
char
*
orig_image
,
const
char
*
out_image
)
{
boot_img
boot
{};
boot_img
boot
{};
...
@@ -318,7 +317,7 @@ void repack(const char* orig_image, const char* out_image) {
...
@@ -318,7 +317,7 @@ void repack(const char* orig_image, const char* out_image) {
// Skip a page for header
// Skip a page for header
header_off
=
lseek
(
fd
,
0
,
SEEK_CUR
);
header_off
=
lseek
(
fd
,
0
,
SEEK_CUR
);
write_zero
(
fd
,
boot
.
page_size
());
write_zero
(
fd
,
boot
.
hdr
.
page_size
());
// kernel
// kernel
kernel_off
=
lseek
(
fd
,
0
,
SEEK_CUR
);
kernel_off
=
lseek
(
fd
,
0
,
SEEK_CUR
);
...
@@ -372,14 +371,14 @@ void repack(const char* orig_image, const char* out_image) {
...
@@ -372,14 +371,14 @@ void repack(const char* orig_image, const char* out_image) {
// extra
// extra
extra_off
=
lseek
(
fd
,
0
,
SEEK_CUR
);
extra_off
=
lseek
(
fd
,
0
,
SEEK_CUR
);
if
(
access
(
EXTRA_FILE
,
R_OK
)
==
0
)
{
if
(
access
(
EXTRA_FILE
,
R_OK
)
==
0
)
{
boot
.
extra_size
(
restore
(
EXTRA_FILE
,
fd
));
boot
.
hdr
.
extra_size
(
restore
(
EXTRA_FILE
,
fd
));
file_align
();
file_align
();
}
}
// recovery_dtbo
// recovery_dtbo
if
(
access
(
RECV_DTBO_FILE
,
R_OK
)
==
0
)
{
if
(
access
(
RECV_DTBO_FILE
,
R_OK
)
==
0
)
{
boot
.
recovery_dtbo_offset
(
lseek
(
fd
,
0
,
SEEK_CUR
));
boot
.
hdr
.
recovery_dtbo_offset
(
lseek
(
fd
,
0
,
SEEK_CUR
));
boot
.
recovery_dtbo_size
(
restore
(
RECV_DTBO_FILE
,
fd
));
boot
.
hdr
.
recovery_dtbo_size
(
restore
(
RECV_DTBO_FILE
,
fd
));
file_align
();
file_align
();
}
}
...
@@ -421,29 +420,29 @@ void repack(const char* orig_image, const char* out_image) {
...
@@ -421,29 +420,29 @@ void repack(const char* orig_image, const char* out_image) {
size
=
boot
.
hdr
->
second_size
;
size
=
boot
.
hdr
->
second_size
;
HASH_update
(
&
ctx
,
boot
.
map_addr
+
second_off
,
size
);
HASH_update
(
&
ctx
,
boot
.
map_addr
+
second_off
,
size
);
HASH_update
(
&
ctx
,
&
size
,
sizeof
(
size
));
HASH_update
(
&
ctx
,
&
size
,
sizeof
(
size
));
size
=
boot
.
extra_size
();
size
=
boot
.
hdr
.
extra_size
();
if
(
size
)
{
if
(
size
)
{
HASH_update
(
&
ctx
,
boot
.
map_addr
+
extra_off
,
size
);
HASH_update
(
&
ctx
,
boot
.
map_addr
+
extra_off
,
size
);
HASH_update
(
&
ctx
,
&
size
,
sizeof
(
size
));
HASH_update
(
&
ctx
,
&
size
,
sizeof
(
size
));
}
}
if
(
boot
.
header_version
())
{
if
(
boot
.
h
dr
.
h
eader_version
())
{
size
=
boot
.
recovery_dtbo_size
();
size
=
boot
.
hdr
.
recovery_dtbo_size
();
HASH_update
(
&
ctx
,
boot
.
map_addr
+
boot
.
recovery_dtbo_offset
(),
size
);
HASH_update
(
&
ctx
,
boot
.
map_addr
+
boot
.
hdr
.
recovery_dtbo_offset
(),
size
);
HASH_update
(
&
ctx
,
&
size
,
sizeof
(
size
));
HASH_update
(
&
ctx
,
&
size
,
sizeof
(
size
));
}
}
memset
(
boot
.
id
(),
0
,
32
);
memset
(
boot
.
hdr
.
id
(),
0
,
32
);
memcpy
(
boot
.
id
(),
HASH_final
(
&
ctx
),
memcpy
(
boot
.
hdr
.
id
(),
HASH_final
(
&
ctx
),
(
boot
.
flags
&
SHA256_FLAG
)
?
SHA256_DIGEST_SIZE
:
SHA_DIGEST_SIZE
);
(
boot
.
flags
&
SHA256_FLAG
)
?
SHA256_DIGEST_SIZE
:
SHA_DIGEST_SIZE
);
// Print new image info
// Print new image info
boot
.
print_hdr
();
boot
.
print_hdr
();
// Try to fix the header
// Try to fix the header
if
(
boot
.
h
eader_version
()
&&
boot
.
header_size
()
==
0
)
if
(
boot
.
h
dr
.
header_version
()
&&
boot
.
hdr
.
header_size
()
==
0
)
boot
.
header_size
(
sizeof
(
boot_img_hdr
));
boot
.
h
dr
.
h
eader_size
(
sizeof
(
boot_img_hdr
));
// Main header
// Main header
memcpy
(
boot
.
map_addr
+
header_off
,
boot
.
hdr
,
boot
.
hdr_size
());
memcpy
(
boot
.
map_addr
+
header_off
,
*
boot
.
hdr
,
boot
.
hdr
.
hdr_size
());
if
(
boot
.
flags
&
DHTB_FLAG
)
{
if
(
boot
.
flags
&
DHTB_FLAG
)
{
// DHTB header
// DHTB header
...
...
native/jni/magiskboot/bootimg.h
View file @
7cee77f5
...
@@ -104,15 +104,15 @@ struct boot_img_hdr_pxa : public boot_img_hdr_base {
...
@@ -104,15 +104,15 @@ struct boot_img_hdr_pxa : public boot_img_hdr_base {
*/
*/
struct
mtk_hdr
{
struct
mtk_hdr
{
uint32_t
magic
;
/* MTK magic */
uint32_t
magic
;
/* MTK magic */
uint32_t
size
;
/* Size of the content */
uint32_t
size
;
/* Size of the content */
char
name
[
32
];
/* The type of the header */
char
name
[
32
];
/* The type of the header */
}
__attribute__
((
packed
));
}
__attribute__
((
packed
));
struct
dhtb_hdr
{
struct
dhtb_hdr
{
char
magic
[
8
];
/* DHTB magic */
char
magic
[
8
];
/* DHTB magic */
uint8_t
checksum
[
40
];
/* Payload SHA256, whole image + SEANDROIDENFORCE + 0xFFFFFFFF */
uint8_t
checksum
[
40
];
/* Payload SHA256, whole image + SEANDROIDENFORCE + 0xFFFFFFFF */
uint32_t
size
;
/* Payload size, whole image + SEANDROIDENFORCE + 0xFFFFFFFF */
uint32_t
size
;
/* Payload size, whole image + SEANDROIDENFORCE + 0xFFFFFFFF */
}
__attribute__
((
packed
));
}
__attribute__
((
packed
));
struct
blob_hdr
{
struct
blob_hdr
{
...
@@ -144,16 +144,97 @@ struct blob_hdr {
...
@@ -144,16 +144,97 @@ struct blob_hdr {
#define NOOKHD_FLAG 0x0200
#define NOOKHD_FLAG 0x0200
#define ACCLAIM_FLAG 0x0400
#define ACCLAIM_FLAG 0x0400
struct
dyn_img_hdr
{
#define dyn_access(x) (pxa ? hdr_pxa->x : v1_hdr->x)
#define dyn_get(name, type) type name() const { return dyn_access(name); }
#define dyn_set(name, type) void name(type v) { dyn_access(name) = v; }
#define dyn_func(name, type) \
dyn_get(name, type) \
dyn_set(name, type)
#define v1_func(name, type) \
type name() const { return pxa ? 0 : v1_hdr->name; } \
void name(type v) { if (!pxa) v1_hdr->name = v; }
dyn_func
(
extra_size
,
uint32_t
);
dyn_func
(
page_size
,
uint32_t
);
dyn_get
(
name
,
char
*
);
dyn_get
(
cmdline
,
char
*
);
dyn_get
(
id
,
char
*
);
dyn_get
(
extra_cmdline
,
char
*
);
v1_func
(
os_version
,
uint32_t
);
v1_func
(
recovery_dtbo_size
,
uint32_t
);
v1_func
(
recovery_dtbo_offset
,
uint32_t
);
v1_func
(
header_size
,
uint32_t
);
dyn_img_hdr
()
:
pxa
(
false
),
img_hdr
(
nullptr
)
{}
~
dyn_img_hdr
()
{
if
(
pxa
)
delete
hdr_pxa
;
else
delete
v1_hdr
;
}
uint32_t
header_version
()
{
if
(
pxa
)
return
0
;
uint32_t
ver
=
v1_hdr
->
header_version
;
// There won't be v4 header any time soon...
// If larger than 4, assume this field will be treated as extra_size
return
ver
>
4
?
0
:
ver
;
}
uint32_t
extra_size
()
{
// If header version > 0, we should treat this field as header_version
return
header_version
()
?
0
:
dyn_access
(
extra_size
);
}
size_t
hdr_size
()
{
return
pxa
?
sizeof
(
boot_img_hdr_pxa
)
:
sizeof
(
boot_img_hdr
);
}
void
set_hdr
(
boot_img_hdr
*
h
)
{
v1_hdr
=
h
;
}
void
set_hdr
(
boot_img_hdr_pxa
*
h
)
{
hdr_pxa
=
h
;
pxa
=
true
;
}
boot_img_hdr_base
*
operator
->
()
const
{
return
img_hdr
;
};
boot_img_hdr_base
*
const
&
operator
*
()
const
{
return
img_hdr
;
}
private
:
bool
pxa
;
union
{
/* Main header is either AOSP or PXA
* but both of them is a base header
* Same address can be interpreted in 3 ways */
boot_img_hdr_base
*
img_hdr
;
/* Common base header */
boot_img_hdr
*
v1_hdr
;
/* AOSP v1 header */
boot_img_hdr_pxa
*
hdr_pxa
;
/* Samsung PXA header */
};
};
struct
boot_img
{
struct
boot_img
{
// Memory map of the whole image
// Memory map of the whole image
uint8_t
*
map_addr
;
uint8_t
*
map_addr
;
size_t
map_size
;
size_t
map_size
;
// Headers
// Headers
boot_img_hdr_base
*
hdr
;
/* Android boot
image header */
dyn_img_hdr
hdr
;
/* Android
image header */
mtk_hdr
*
k_hdr
;
/* MTK kernel header */
mtk_hdr
*
k_hdr
;
/* MTK kernel header */
mtk_hdr
*
r_hdr
;
/* MTK ramdisk header */
mtk_hdr
*
r_hdr
;
/* MTK ramdisk header */
blob_hdr
*
b_hdr
;
/* Tegra blob header */
blob_hdr
*
b_hdr
;
/* Tegra blob header */
// Flags to indicate the state of current boot image
// Flags to indicate the state of current boot image
uint16_t
flags
;
uint16_t
flags
;
...
@@ -182,51 +263,6 @@ struct boot_img {
...
@@ -182,51 +263,6 @@ struct boot_img {
int
parse_image
(
const
char
*
);
int
parse_image
(
const
char
*
);
void
find_dtb
();
void
find_dtb
();
void
print_hdr
();
void
print_hdr
();
/* Access elements in header */
#define IS_PXA (flags & PXA_FLAG)
#define dyn_access(x) (IS_PXA ? \
static_cast<boot_img_hdr_pxa *>(hdr)->x : \
static_cast<boot_img_hdr_v1 *>(hdr)->x)
#define dyn_get(x, t) t x() const { return dyn_access(x); }
#define dyn_set(x, t) void x(t v) { dyn_access(x) = v; }
#define hdr_get(x, t) t x() const { return IS_PXA ? 0 : static_cast<boot_img_hdr *>(hdr)->x; }
#define hdr_set(x, t) void x(t v) { if (!IS_PXA) static_cast<boot_img_hdr *>(hdr)->x = v; }
dyn_set
(
extra_size
,
uint32_t
);
dyn_get
(
page_size
,
uint32_t
);
dyn_get
(
name
,
char
*
);
dyn_get
(
cmdline
,
char
*
);
dyn_get
(
id
,
char
*
);
dyn_get
(
extra_cmdline
,
char
*
);
hdr_get
(
os_version
,
uint32_t
);
hdr_get
(
recovery_dtbo_size
,
uint32_t
);
hdr_set
(
recovery_dtbo_size
,
uint32_t
);
hdr_get
(
recovery_dtbo_offset
,
uint32_t
);
hdr_set
(
recovery_dtbo_offset
,
uint32_t
);
hdr_get
(
header_size
,
uint32_t
);
hdr_set
(
header_size
,
uint32_t
);
uint32_t
header_version
()
{
if
(
IS_PXA
)
return
0
;
uint32_t
ver
=
static_cast
<
boot_img_hdr
*>
(
hdr
)
->
header_version
;
// There won't be v4 header any time soon...
// If larger than 4, assume this field will be treated as extra_size
return
ver
>
4
?
0
:
ver
;
}
uint32_t
extra_size
()
{
// If header version > 0, we should treat this field as header_version
return
header_version
()
?
0
:
dyn_access
(
extra_size
);
}
size_t
hdr_size
()
{
return
IS_PXA
?
sizeof
(
boot_img_hdr_pxa
)
:
sizeof
(
boot_img_hdr
);
}
};
};
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment