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
eed86c76
Commit
eed86c76
authored
Jan 28, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support to PXA devices
Close #340
parent
c471bb6f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
212 additions
and
140 deletions
+212
-140
bootimg.c
native/jni/magiskboot/bootimg.c
+116
-80
bootimg.h
native/jni/magiskboot/bootimg.h
+90
-55
magiskboot.h
native/jni/magiskboot/magiskboot.h
+1
-1
main.c
native/jni/magiskboot/main.c
+4
-3
types.c
native/jni/magiskboot/types.c
+1
-1
No files found.
native/jni/magiskboot/bootimg.c
View file @
eed86c76
This diff is collapsed.
Click to expand it.
native/jni/magiskboot/bootimg.h
View file @
eed86c76
...
...
@@ -21,48 +21,69 @@
#ifndef _BOOT_IMAGE_H_
#define _BOOT_IMAGE_H_
typedef
struct
boot_img_hdr
boot_img_hdr
;
#define BOOT_MAGIC "ANDROID!"
#define BOOT_MAGIC_SIZE 8
#define BOOT_NAME_SIZE 16
#define BOOT_ARGS_SIZE 512
#define BOOT_EXTRA_ARGS_SIZE 1024
struct
boot_img_hdr
{
uint8_t
magic
[
BOOT_MAGIC_SIZE
];
typedef
struct
boot_img_hdr
{
char
magic
[
8
];
uint32_t
kernel_size
;
/* size in bytes */
uint32_t
kernel_addr
;
/* physical load addr */
uint32_t
ramdisk_size
;
/* size in bytes */
uint32_t
ramdisk_addr
;
/* physical load addr */
uint32_t
second_size
;
/* size in bytes */
uint32_t
second_addr
;
/* physical load addr */
uint32_t
tags_addr
;
/* physical addr for kernel tags */
uint32_t
page_size
;
/* flash page size we assume */
uint32_t
extra_size
;
/* extra blob size in bytes */
/* operating system version and security patch level; for
* version "A.B.C" and patch level "Y-M-D":
* ver = A << 14 | B << 7 | C (7 bits for each of A, B, C)
* lvl = ((Y - 2000) & 127) << 4 | M (7 bits for Y, 4 bits for M)
* os_version = ver << 11 | lvl */
uint32_t
os_version
;
char
name
[
16
];
/* asciiz product name */
char
cmdline
[
512
];
uint32_t
id
[
8
];
/* timestamp / checksum / sha1 / etc */
/* Supplemental command line data; kept here to maintain
* binary compatibility with older versions of mkbootimg */
char
extra_cmdline
[
1024
];
}
__attribute__
((
packed
))
boot_img_hdr
;
uint32_t
kernel_size
;
/* size in bytes */
uint32_t
kernel_addr
;
/* physical load addr */
typedef
struct
pxa_boot_img_hdr
{
char
magic
[
8
];
uint32_t
ramdisk_size
;
/* size in bytes */
uint32_t
ramdisk_addr
;
/* physical load addr */
uint32_t
kernel_size
;
/* size in bytes */
uint32_t
kernel_addr
;
/* physical load addr */
uint32_t
second_size
;
/* size in bytes */
uint32_t
second_addr
;
/* physical load addr */
uint32_t
ramdisk_size
;
/* size in bytes */
uint32_t
ramdisk_addr
;
/* physical load addr */
uint32_t
tags_addr
;
/* physical addr for kernel tags */
uint32_t
page_size
;
/* flash page size we assume */
uint32_t
extra_size
;
/* extra blob size in bytes */
uint32_t
second_size
;
/* size in bytes */
uint32_t
second_addr
;
/* physical load addr */
/* operating system version and security patch level; for
* version "A.B.C" and patch level "Y-M-D":
* ver = A << 14 | B << 7 | C (7 bits for each of A, B, C)
* lvl = ((Y - 2000) & 127) << 4 | M (7 bits for Y, 4 bits for M)
* os_version = ver << 11 | lvl */
uint32_t
os_version
;
uint32_t
extra_size
;
/* extra blob size in bytes */
uint32_t
unknown
;
/* unknown value */
uint32_t
tags_addr
;
/* physical addr for kernel tags */
uint32_t
page_size
;
/* flash page size we assume */
uint8_t
name
[
BOOT_NAME_SIZE
];
/* asciiz product name */
char
name
[
24
];
/* asciiz product name */
uint8_t
cmdline
[
BOOT_ARGS_SIZE
];
char
cmdline
[
512
];
uint32_t
id
[
8
];
/* timestamp / checksum / sha1 / etc */
uint32_t
id
[
8
];
/* timestamp / checksum / sha1 / etc */
/* Supplemental command line data; kept here to maintain
* binary compatibility with older versions of mkbootimg */
uint8_t
extra_cmdline
[
BOOT_EXTRA_ARGS_SIZE
];
}
__attribute__
((
packed
));
/* Supplemental command line data; kept here to maintain
* binary compatibility with older versions of mkbootimg */
char
extra_cmdline
[
1024
];
}
__attribute__
((
packed
))
pxa_boot_img_hdr
;
/*
** +-----------------+
...
...
@@ -74,7 +95,7 @@ struct boot_img_hdr
** +-----------------+
** | second stage | o pages
** +-----------------+
** | extra blob
s
| p pages
** | extra blob
| p pages
** +-----------------+
**
** n = (kernel_size + page_size - 1) / page_size
...
...
@@ -95,33 +116,47 @@ struct boot_img_hdr
*/
typedef
struct
mtk_hdr
{
uint8_t
magic
[
4
];
/* MTK magic */
uint32_t
size
;
/* Size of the content */
uint8_t
name
[
32
];
/* The type of the header */
}
mtk_hdr
;
uint32_t
magic
;
/* MTK magic */
uint32_t
size
;
/* Size of the content */
char
name
[
32
];
/* The type of the header */
}
__attribute__
((
packed
))
mtk_hdr
;
// Flags
#define MTK_KERNEL 0x1
#define MTK_RAMDISK 0x2
#define CHROMEOS_FLAG 0x4
#define MTK_KERNEL 0x01
#define MTK_RAMDISK 0x02
#define CHROMEOS_FLAG 0x04
#define PXA_FLAG 0x08
typedef
struct
boot_img
{
size_t
map_size
;
uint32_t
dt_size
;
size_t
tail_size
;
uint8_t
flags
;
file_t
kernel_type
,
ramdisk_type
;
boot_img_hdr
hdr
;
mtk_hdr
mtk_kernel_hdr
,
mtk_ramdisk_hdr
;
void
*
map_addr
;
void
*
kernel
;
void
*
dtb
;
void
*
ramdisk
;
void
*
second
;
void
*
extra
;
void
*
tail
;
// Memory map of the whole image
void
*
map_addr
;
size_t
map_size
;
// Headers
void
*
hdr
;
/* Either boot_img_hdr or pxa_boot_img_hdr */
mtk_hdr
*
k_hdr
;
/* MTK kernel header */
mtk_hdr
*
r_hdr
;
/* MTK ramdisk header */
// Flags to indicate the state of current boot image
uint8_t
flags
;
// The format of kernel and ramdisk
file_t
kernel_type
;
file_t
ramdisk_type
;
// Pointer to dtb that is appended after kernel
void
*
dtb
;
uint32_t
dt_size
;
// Pointer to end of image
void
*
tail
;
size_t
tail_size
;
// Pointers to blocks defined in header
void
*
kernel
;
void
*
ramdisk
;
void
*
second
;
void
*
extra
;
}
boot_img
;
#endif
native/jni/magiskboot/magiskboot.h
View file @
eed86c76
...
...
@@ -14,7 +14,7 @@
#define NEW_BOOT "new-boot.img"
// Main entries
void
unpack
(
const
char
*
image
);
int
unpack
(
const
char
*
image
);
void
repack
(
const
char
*
orig_image
,
const
char
*
out_image
);
void
hexpatch
(
const
char
*
image
,
const
char
*
from
,
const
char
*
to
);
int
parse_img
(
const
char
*
image
,
boot_img
*
boot
);
...
...
native/jni/magiskboot/main.c
View file @
eed86c76
...
...
@@ -136,9 +136,9 @@ int main(int argc, char *argv[]) {
munmap
(
buf
,
size
);
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--parse"
)
==
0
)
{
boot_img
boot
;
exit
(
parse_img
(
argv
[
2
],
&
boot
)
);
return
parse_img
(
argv
[
2
],
&
boot
);
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--unpack"
)
==
0
)
{
unpack
(
argv
[
2
]);
return
unpack
(
argv
[
2
]);
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--repack"
)
==
0
)
{
repack
(
argv
[
2
],
argc
>
3
?
argv
[
3
]
:
NEW_BOOT
);
}
else
if
(
argc
>
2
&&
strcmp
(
argv
[
1
],
"--decompress"
)
==
0
)
{
...
...
@@ -157,7 +157,8 @@ int main(int argc, char *argv[]) {
char
*
cmd
=
argv
[
1
]
+
5
;
if
(
*
cmd
==
'\0'
)
usage
(
argv
[
0
]);
else
++
cmd
;
if
(
dtb_commands
(
cmd
,
argc
-
2
,
argv
+
2
))
usage
(
argv
[
0
]);
if
(
dtb_commands
(
cmd
,
argc
-
2
,
argv
+
2
))
usage
(
argv
[
0
]);
}
else
{
usage
(
argv
[
0
]);
}
...
...
native/jni/magiskboot/types.c
View file @
eed86c76
...
...
@@ -6,7 +6,7 @@
file_t
check_type
(
const
void
*
buf
)
{
if
(
memcmp
(
buf
,
CHROMEOS_MAGIC
,
8
)
==
0
)
{
return
CHROMEOS
;
}
else
if
(
memcmp
(
buf
,
BOOT_MAGIC
,
BOOT_MAGIC_SIZE
)
==
0
)
{
}
else
if
(
memcmp
(
buf
,
BOOT_MAGIC
,
8
)
==
0
)
{
return
AOSP
;
}
else
if
(
memcmp
(
buf
,
ELF32_MAGIC
,
5
)
==
0
)
{
return
ELF32
;
...
...
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