This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
android_img.ksy
120 lines (120 loc) · 2.67 KB
/
android_img.ksy
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
meta:
id: android_img
title: Android Boot Image
license: CC0-1.0
file-extension: img
endian: le
doc-ref: https://source.android.com/devices/bootloader/boot-image-header
seq:
- id: magic
contents: ANDROID!
- id: kernel
type: load
- id: ramdisk
type: load
- id: second
type: load
- id: tags_load
type: u4
- id: page_size
type: u4
- id: header_version
type: u4
- id: os_version
type: os_version
- id: name
type: strz
size: 16
encoding: ASCII
- id: cmdline
type: strz
size: 512
encoding: ASCII
- id: sha
size: 32
- id: extra_cmdline
type: strz
size: 1024
encoding: ASCII
- id: recovery_dtbo
type: size_offset
if: header_version > 0
- id: boot_header_size
type: u4
if: header_version > 0
- id: dtb
type: load_long
if: header_version > 1
instances:
base:
value: kernel.addr - 0x00008000
doc: base loading address
kernel_offset:
value: kernel.addr - base
doc: kernel offset from base
ramdisk_offset:
value: 'ramdisk.addr > 0 ? ramdisk.addr - base : 0'
doc: ramdisk offset from base
second_offset:
value: 'second.addr > 0 ? second.addr - base : 0'
doc: 2nd bootloader offset from base
tags_offset:
value: tags_load - base
doc: tags offset from base
dtb_offset:
value: 'dtb.addr > 0 ? dtb.addr - base : 0'
if: header_version > 1
doc: dtb offset from base
kernel_img:
pos: page_size
size: kernel.size
ramdisk_img:
pos: ((page_size + kernel.size + page_size - 1) / page_size) * page_size
size: ramdisk.size
if: ramdisk.size > 0
second_img:
pos: ((page_size + kernel.size + ramdisk.size + page_size - 1) / page_size) * page_size
size: second.size
if: second.size > 0
recovery_dtbo_img:
pos: recovery_dtbo.offset
size: recovery_dtbo.size
if: header_version > 0 and recovery_dtbo.size > 0
dtb_img:
pos: ((page_size + kernel.size + ramdisk.size + second.size + recovery_dtbo.size + page_size - 1) / page_size) * page_size
size: dtb.size
if: header_version > 1 and dtb.size > 0
types:
load:
seq:
- id: size
type: u4
- id: addr
type: u4
load_long:
seq:
- id: size
type: u4
- id: addr
type: u8
size_offset:
seq:
- id: size
type: u4
- id: offset
type: u8
os_version:
seq:
- id: version
type: u4
instances:
major:
value: (version >> 25) & 0x7f
minor:
value: (version >> 18) & 0x7f
patch:
value: (version >> 11) & 0x7f
year:
value: ((version >> 4) & 0x7f) + 2000
month:
value: version & 0xf