summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2018-04-05 18:12:47 -0500
committerElliott Hughes2018-04-09 13:37:39 -0500
commit577e8b44b6cfa8f44cb56dea35aa582820454d56 (patch)
tree1dcd0ecbc0593e86e3d342f988b9d22adc894288 /mkbootimg
parent0289f35b832824757f261775cc730f64a2bb7561 (diff)
downloadplatform-system-core-577e8b44b6cfa8f44cb56dea35aa582820454d56.tar.gz
platform-system-core-577e8b44b6cfa8f44cb56dea35aa582820454d56.tar.xz
platform-system-core-577e8b44b6cfa8f44cb56dea35aa582820454d56.zip
Add fastboot --os-version and --os-patch-level.
Also move -c to --cmdline to match the python mkbootimg tool. Remove the short options for these rarely-used options. Remove #if 0 cruft from <bootimg/bootimg.h>. Bug: http://b/77340848 Test: manual testing (need to fix http://b/77809061 for unit tests) Change-Id: Ieaa795566611bd89ba3fee39a1d9f6ad0713a587
Diffstat (limited to 'mkbootimg')
-rw-r--r--mkbootimg/include/bootimg/bootimg.h100
1 files changed, 42 insertions, 58 deletions
diff --git a/mkbootimg/include/bootimg/bootimg.h b/mkbootimg/include/bootimg/bootimg.h
index 4311b46f9..406e20832 100644
--- a/mkbootimg/include/bootimg/bootimg.h
+++ b/mkbootimg/include/bootimg/bootimg.h
@@ -1,24 +1,22 @@
1/* tools/mkbootimg/bootimg.h 1/*
2** 2 * Copyright (C) 2007 The Android Open Source Project
3** Copyright 2007, The Android Open Source Project 3 *
4** 4 * Licensed under the Apache License, Version 2.0 (the "License");
5** Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License.
6** you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at
7** You may obtain a copy of the License at 7 *
8** 8 * http://www.apache.org/licenses/LICENSE-2.0
9** http://www.apache.org/licenses/LICENSE-2.0 9 *
10** 10 * Unless required by applicable law or agreed to in writing, software
11** Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS,
12** distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and
14** See the License for the specific language governing permissions and 14 * limitations under the License.
15** limitations under the License. 15 */
16*/
17 16
18#include <stdint.h> 17#pragma once
19 18
20#ifndef _BOOT_IMAGE_H_ 19#include <stdint.h>
21#define _BOOT_IMAGE_H_
22 20
23#define BOOT_MAGIC "ANDROID!" 21#define BOOT_MAGIC "ANDROID!"
24#define BOOT_MAGIC_SIZE 8 22#define BOOT_MAGIC_SIZE 8
@@ -26,12 +24,10 @@
26#define BOOT_ARGS_SIZE 512 24#define BOOT_ARGS_SIZE 512
27#define BOOT_EXTRA_ARGS_SIZE 1024 25#define BOOT_EXTRA_ARGS_SIZE 1024
28 26
29#define BOOT_HEADER_VERSION_ZERO 0 27// The bootloader expects the structure of boot_img_hdr with header
30/* 28// version 0 to be as follows:
31 * Bootloader expects the structure of boot_img_hdr with header version
32 * BOOT_HEADER_VERSION_ZERO to be as follows:
33 */
34struct boot_img_hdr_v0 { 29struct boot_img_hdr_v0 {
30 // Must be BOOT_MAGIC.
35 uint8_t magic[BOOT_MAGIC_SIZE]; 31 uint8_t magic[BOOT_MAGIC_SIZE];
36 32
37 uint32_t kernel_size; /* size in bytes */ 33 uint32_t kernel_size; /* size in bytes */
@@ -45,26 +41,36 @@ struct boot_img_hdr_v0 {
45 41
46 uint32_t tags_addr; /* physical addr for kernel tags */ 42 uint32_t tags_addr; /* physical addr for kernel tags */
47 uint32_t page_size; /* flash page size we assume */ 43 uint32_t page_size; /* flash page size we assume */
48 /* 44
49 * version for the boot image header. 45 // Version of the boot image header.
50 */
51 uint32_t header_version; 46 uint32_t header_version;
52 47
53 /* operating system version and security patch level; for 48 // Operating system version and security patch level.
54 * version "A.B.C" and patch level "Y-M-D": 49 // For version "A.B.C" and patch level "Y-M-D":
55 * ver = A << 14 | B << 7 | C (7 bits for each of A, B, C) 50 // (7 bits for each of A, B, C; 7 bits for (Y-2000), 4 bits for M)
56 * lvl = ((Y - 2000) & 127) << 4 | M (7 bits for Y, 4 bits for M) 51 // os_version = A[31:25] B[24:18] C[17:11] (Y-2000)[10:4] M[3:0]
57 * os_version = ver << 11 | lvl */
58 uint32_t os_version; 52 uint32_t os_version;
59 53
54#if __cplusplus
55 void SetOsVersion(unsigned major, unsigned minor, unsigned patch) {
56 os_version &= ((1 << 11) - 1);
57 os_version |= (((major & 0x7f) << 25) | ((minor & 0x7f) << 18) | ((patch & 0x7f) << 11));
58 }
59
60 void SetOsPatchLevel(unsigned year, unsigned month) {
61 os_version &= ~((1 << 11) - 1);
62 os_version |= (((year - 2000) & 0x7f) << 4) | ((month & 0xf) << 0);
63 }
64#endif
65
60 uint8_t name[BOOT_NAME_SIZE]; /* asciiz product name */ 66 uint8_t name[BOOT_NAME_SIZE]; /* asciiz product name */
61 67
62 uint8_t cmdline[BOOT_ARGS_SIZE]; 68 uint8_t cmdline[BOOT_ARGS_SIZE];
63 69
64 uint32_t id[8]; /* timestamp / checksum / sha1 / etc */ 70 uint32_t id[8]; /* timestamp / checksum / sha1 / etc */
65 71
66 /* Supplemental command line data; kept here to maintain 72 // Supplemental command line data; kept here to maintain
67 * binary compatibility with older versions of mkbootimg */ 73 // binary compatibility with older versions of mkbootimg.
68 uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE]; 74 uint8_t extra_cmdline[BOOT_EXTRA_ARGS_SIZE];
69} __attribute__((packed)); 75} __attribute__((packed));
70 76
@@ -74,7 +80,7 @@ struct boot_img_hdr_v0 {
74 */ 80 */
75typedef struct boot_img_hdr_v0 boot_img_hdr; 81typedef struct boot_img_hdr_v0 boot_img_hdr;
76 82
77/* When a boot header is of version BOOT_HEADER_VERSION_ZERO, the structure of boot image is as 83/* When a boot header is of version 0, the structure of boot image is as
78 * follows: 84 * follows:
79 * 85 *
80 * +-----------------+ 86 * +-----------------+
@@ -103,15 +109,13 @@ typedef struct boot_img_hdr_v0 boot_img_hdr;
103 * else: jump to kernel_addr 109 * else: jump to kernel_addr
104 */ 110 */
105 111
106#define BOOT_HEADER_VERSION_ONE 1
107
108struct boot_img_hdr_v1 : public boot_img_hdr_v0 { 112struct boot_img_hdr_v1 : public boot_img_hdr_v0 {
109 uint32_t recovery_dtbo_size; /* size in bytes for recovery DTBO image */ 113 uint32_t recovery_dtbo_size; /* size in bytes for recovery DTBO image */
110 uint64_t recovery_dtbo_offset; /* physical load addr */ 114 uint64_t recovery_dtbo_offset; /* physical load addr */
111 uint32_t header_size; 115 uint32_t header_size;
112} __attribute__((packed)); 116} __attribute__((packed));
113 117
114/* When the boot image header has a version of BOOT_HEADER_VERSION_ONE, the structure of the boot 118/* When the boot image header has a version of 1, the structure of the boot
115 * image is as follows: 119 * image is as follows:
116 * 120 *
117 * +-----------------+ 121 * +-----------------+
@@ -142,23 +146,3 @@ struct boot_img_hdr_v1 : public boot_img_hdr_v0 {
142 * 7. if second_size != 0: jump to second_addr 146 * 7. if second_size != 0: jump to second_addr
143 * else: jump to kernel_addr 147 * else: jump to kernel_addr
144 */ 148 */
145
146#if 0
147typedef struct ptentry ptentry;
148
149struct ptentry {
150 char name[16]; /* asciiz partition name */
151 unsigned start; /* starting block number */
152 unsigned length; /* length in blocks */
153 unsigned flags; /* set to zero */
154};
155
156/* MSM Partition Table ATAG
157**
158** length: 2 + 7 * n
159** atag: 0x4d534d70
160** <ptentry> x n
161*/
162#endif
163
164#endif