Commit 7d48a0d5468dcb6966c338e1d5ac619cd5abd866

Authored by yang.tian
1 parent dac930e735

MA-13748 Pass BDADDR from uboot cmdline

Pass bt mac address from uboot cmdline to write
ro.boot.btmacaddr property for bluetooth hal to parse
BDADDR which is composed from ro.boot.serialno,
or it will fall back to persist property seted in init.rc.

Change-Id: If6886596c79c699b8530d3249b1cc98f19aad51f
Signed-off-by: yang.tian <yang.tian@nxp.com>

Showing 1 changed file with 11 additions and 0 deletions Inline Diff

common/image-android.c
1 /* 1 /*
2 * Copyright (c) 2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de> 2 * Copyright (c) 2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>
3 * 3 *
4 * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. 4 * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
5 * Copyright 2017 NXP 5 * Copyright 2017 NXP
6 * 6 *
7 * SPDX-License-Identifier: GPL-2.0+ 7 * SPDX-License-Identifier: GPL-2.0+
8 */ 8 */
9 9
10 #include <common.h> 10 #include <common.h>
11 #include <image.h> 11 #include <image.h>
12 #include <android_image.h> 12 #include <android_image.h>
13 #include <malloc.h> 13 #include <malloc.h>
14 #include <errno.h> 14 #include <errno.h>
15 #include <asm/bootm.h> 15 #include <asm/bootm.h>
16 #include <asm/mach-imx/boot_mode.h> 16 #include <asm/mach-imx/boot_mode.h>
17 #include <asm/arch/sys_proto.h> 17 #include <asm/arch/sys_proto.h>
18 #include <fsl_fastboot.h> 18 #include <fsl_fastboot.h>
19 #include <asm/setup.h> 19 #include <asm/setup.h>
20 #include <dm.h> 20 #include <dm.h>
21 21
22 #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000 22 #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000
23 23
24 static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1]; 24 static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
25 25
26 static ulong android_image_get_kernel_addr(const struct andr_img_hdr *hdr) 26 static ulong android_image_get_kernel_addr(const struct andr_img_hdr *hdr)
27 { 27 {
28 /* 28 /*
29 * All the Android tools that generate a boot.img use this 29 * All the Android tools that generate a boot.img use this
30 * address as the default. 30 * address as the default.
31 * 31 *
32 * Even though it doesn't really make a lot of sense, and it 32 * Even though it doesn't really make a lot of sense, and it
33 * might be valid on some platforms, we treat that adress as 33 * might be valid on some platforms, we treat that adress as
34 * the default value for this field, and try to execute the 34 * the default value for this field, and try to execute the
35 * kernel in place in such a case. 35 * kernel in place in such a case.
36 * 36 *
37 * Otherwise, we will return the actual value set by the user. 37 * Otherwise, we will return the actual value set by the user.
38 */ 38 */
39 if (hdr->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR) 39 if (hdr->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR)
40 return (ulong)hdr + hdr->page_size; 40 return (ulong)hdr + hdr->page_size;
41 41
42 return hdr->kernel_addr; 42 return hdr->kernel_addr;
43 } 43 }
44 44
45 /** 45 /**
46 * android_image_get_kernel() - processes kernel part of Android boot images 46 * android_image_get_kernel() - processes kernel part of Android boot images
47 * @hdr: Pointer to image header, which is at the start 47 * @hdr: Pointer to image header, which is at the start
48 * of the image. 48 * of the image.
49 * @verify: Checksum verification flag. Currently unimplemented. 49 * @verify: Checksum verification flag. Currently unimplemented.
50 * @os_data: Pointer to a ulong variable, will hold os data start 50 * @os_data: Pointer to a ulong variable, will hold os data start
51 * address. 51 * address.
52 * @os_len: Pointer to a ulong variable, will hold os data length. 52 * @os_len: Pointer to a ulong variable, will hold os data length.
53 * 53 *
54 * This function returns the os image's start address and length. Also, 54 * This function returns the os image's start address and length. Also,
55 * it appends the kernel command line to the bootargs env variable. 55 * it appends the kernel command line to the bootargs env variable.
56 * 56 *
57 * Return: Zero, os start address and length on success, 57 * Return: Zero, os start address and length on success,
58 * otherwise on failure. 58 * otherwise on failure.
59 */ 59 */
60 int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify, 60 int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
61 ulong *os_data, ulong *os_len) 61 ulong *os_data, ulong *os_len)
62 { 62 {
63 extern boot_metric metrics; 63 extern boot_metric metrics;
64 u32 kernel_addr = android_image_get_kernel_addr(hdr); 64 u32 kernel_addr = android_image_get_kernel_addr(hdr);
65 65
66 /* 66 /*
67 * Not all Android tools use the id field for signing the image with 67 * Not all Android tools use the id field for signing the image with
68 * sha1 (or anything) so we don't check it. It is not obvious that the 68 * sha1 (or anything) so we don't check it. It is not obvious that the
69 * string is null terminated so we take care of this. 69 * string is null terminated so we take care of this.
70 */ 70 */
71 strncpy(andr_tmp_str, hdr->name, ANDR_BOOT_NAME_SIZE); 71 strncpy(andr_tmp_str, hdr->name, ANDR_BOOT_NAME_SIZE);
72 andr_tmp_str[ANDR_BOOT_NAME_SIZE] = '\0'; 72 andr_tmp_str[ANDR_BOOT_NAME_SIZE] = '\0';
73 if (strlen(andr_tmp_str)) 73 if (strlen(andr_tmp_str))
74 printf("Android's image name: %s\n", andr_tmp_str); 74 printf("Android's image name: %s\n", andr_tmp_str);
75 75
76 printf("Kernel load addr 0x%08x size %u KiB\n", 76 printf("Kernel load addr 0x%08x size %u KiB\n",
77 kernel_addr, DIV_ROUND_UP(hdr->kernel_size, 1024)); 77 kernel_addr, DIV_ROUND_UP(hdr->kernel_size, 1024));
78 78
79 char newbootargs[512] = {0}; 79 char newbootargs[512] = {0};
80 char commandline[2048] = {0}; 80 char commandline[2048] = {0};
81 int offset; 81 int offset;
82 char *bootargs = env_get("bootargs"); 82 char *bootargs = env_get("bootargs");
83 83
84 if (bootargs) { 84 if (bootargs) {
85 if (strlen(bootargs) + 1 > sizeof(commandline)) { 85 if (strlen(bootargs) + 1 > sizeof(commandline)) {
86 printf("bootargs is too long!\n"); 86 printf("bootargs is too long!\n");
87 return -1; 87 return -1;
88 } 88 }
89 else 89 else
90 strncpy(commandline, bootargs, sizeof(commandline) - 1); 90 strncpy(commandline, bootargs, sizeof(commandline) - 1);
91 } else { 91 } else {
92 offset = fdt_path_offset(gd->fdt_blob, "/chosen"); 92 offset = fdt_path_offset(gd->fdt_blob, "/chosen");
93 if (offset > 0) { 93 if (offset > 0) {
94 bootargs = (char *)fdt_getprop(gd->fdt_blob, offset, 94 bootargs = (char *)fdt_getprop(gd->fdt_blob, offset,
95 "bootargs", NULL); 95 "bootargs", NULL);
96 if (bootargs) 96 if (bootargs)
97 sprintf(commandline, "%s ", bootargs); 97 sprintf(commandline, "%s ", bootargs);
98 } 98 }
99 99
100 if (*hdr->cmdline) { 100 if (*hdr->cmdline) {
101 if (strlen(hdr->cmdline) + 1 > 101 if (strlen(hdr->cmdline) + 1 >
102 sizeof(commandline) - strlen(commandline)) { 102 sizeof(commandline) - strlen(commandline)) {
103 printf("cmdline in bootimg is too long!\n"); 103 printf("cmdline in bootimg is too long!\n");
104 return -1; 104 return -1;
105 } 105 }
106 else 106 else
107 strncat(commandline, hdr->cmdline, sizeof(commandline) - strlen(commandline)); 107 strncat(commandline, hdr->cmdline, sizeof(commandline) - strlen(commandline));
108 } 108 }
109 } 109 }
110 110
111 /* Add 'bootargs_ram_capacity' to hold the parameters based on different ram capacity */ 111 /* Add 'bootargs_ram_capacity' to hold the parameters based on different ram capacity */
112 char *bootargs_ram_capacity = env_get("bootargs_ram_capacity"); 112 char *bootargs_ram_capacity = env_get("bootargs_ram_capacity");
113 if (bootargs_ram_capacity) { 113 if (bootargs_ram_capacity) {
114 strncat(commandline, " ", sizeof(commandline) - strlen(commandline)); 114 strncat(commandline, " ", sizeof(commandline) - strlen(commandline));
115 strncat(commandline, bootargs_ram_capacity, 115 strncat(commandline, bootargs_ram_capacity,
116 sizeof(commandline) - strlen(commandline)); 116 sizeof(commandline) - strlen(commandline));
117 } 117 }
118 118
119 #ifdef CONFIG_SERIAL_TAG 119 #ifdef CONFIG_SERIAL_TAG
120 struct tag_serialnr serialnr; 120 struct tag_serialnr serialnr;
121 get_board_serial(&serialnr); 121 get_board_serial(&serialnr);
122 122
123 sprintf(newbootargs, 123 sprintf(newbootargs,
124 " androidboot.serialno=%08x%08x", 124 " androidboot.serialno=%08x%08x",
125 serialnr.high, 125 serialnr.high,
126 serialnr.low); 126 serialnr.low);
127 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline)); 127 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline));
128
129 char bd_addr[16]={0};
130 sprintf(bd_addr,
131 "%08x%08x",
132 serialnr.high,
133 serialnr.low);
134 sprintf(newbootargs,
135 " androidboot.btmacaddr=%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
136 bd_addr[0],bd_addr[1],bd_addr[2],bd_addr[3],bd_addr[4],bd_addr[5],
137 bd_addr[6],bd_addr[7],bd_addr[8],bd_addr[9],bd_addr[10],bd_addr[11]);
138 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline));
128 #endif 139 #endif
129 140
130 /* append soc type into bootargs */ 141 /* append soc type into bootargs */
131 char *soc_type = env_get("soc_type"); 142 char *soc_type = env_get("soc_type");
132 if (soc_type) { 143 if (soc_type) {
133 sprintf(newbootargs, 144 sprintf(newbootargs,
134 " androidboot.soc_type=%s", 145 " androidboot.soc_type=%s",
135 soc_type); 146 soc_type);
136 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline)); 147 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline));
137 } 148 }
138 149
139 int bootdev = get_boot_device(); 150 int bootdev = get_boot_device();
140 if (bootdev == SD1_BOOT || bootdev == SD2_BOOT || 151 if (bootdev == SD1_BOOT || bootdev == SD2_BOOT ||
141 bootdev == SD3_BOOT || bootdev == SD4_BOOT) { 152 bootdev == SD3_BOOT || bootdev == SD4_BOOT) {
142 sprintf(newbootargs, 153 sprintf(newbootargs,
143 " androidboot.storage_type=sd"); 154 " androidboot.storage_type=sd");
144 } else if (bootdev == MMC1_BOOT || bootdev == MMC2_BOOT || 155 } else if (bootdev == MMC1_BOOT || bootdev == MMC2_BOOT ||
145 bootdev == MMC3_BOOT || bootdev == MMC4_BOOT) { 156 bootdev == MMC3_BOOT || bootdev == MMC4_BOOT) {
146 sprintf(newbootargs, 157 sprintf(newbootargs,
147 " androidboot.storage_type=emmc"); 158 " androidboot.storage_type=emmc");
148 } else if (bootdev == NAND_BOOT) { 159 } else if (bootdev == NAND_BOOT) {
149 sprintf(newbootargs, 160 sprintf(newbootargs,
150 " androidboot.storage_type=nand"); 161 " androidboot.storage_type=nand");
151 } else 162 } else
152 printf("boot device type is incorrect.\n"); 163 printf("boot device type is incorrect.\n");
153 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline)); 164 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline));
154 if (bootloader_gpt_overlay()) { 165 if (bootloader_gpt_overlay()) {
155 sprintf(newbootargs, " gpt"); 166 sprintf(newbootargs, " gpt");
156 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline)); 167 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline));
157 } 168 }
158 169
159 /* boot metric variables */ 170 /* boot metric variables */
160 metrics.ble_1 = get_timer(0); 171 metrics.ble_1 = get_timer(0);
161 sprintf(newbootargs, 172 sprintf(newbootargs,
162 " androidboot.boottime=1BLL:%d,1BLE:%d,KL:%d,KD:%d,AVB:%d,ODT:%d,SW:%d", 173 " androidboot.boottime=1BLL:%d,1BLE:%d,KL:%d,KD:%d,AVB:%d,ODT:%d,SW:%d",
163 metrics.bll_1, metrics.ble_1, metrics.kl, metrics.kd, metrics.avb, 174 metrics.bll_1, metrics.ble_1, metrics.kl, metrics.kd, metrics.avb,
164 metrics.odt, metrics.sw); 175 metrics.odt, metrics.sw);
165 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline)); 176 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline));
166 177
167 #if defined(CONFIG_ARCH_MX6) || defined(CONFIG_ARCH_MX7) || \ 178 #if defined(CONFIG_ARCH_MX6) || defined(CONFIG_ARCH_MX7) || \
168 defined(CONFIG_ARCH_MX7ULP) || defined(CONFIG_ARCH_IMX8M) 179 defined(CONFIG_ARCH_MX7ULP) || defined(CONFIG_ARCH_IMX8M)
169 char cause[18]; 180 char cause[18];
170 181
171 memset(cause, '\0', sizeof(cause)); 182 memset(cause, '\0', sizeof(cause));
172 get_reboot_reason(cause); 183 get_reboot_reason(cause);
173 if (strstr(cause, "POR")) 184 if (strstr(cause, "POR"))
174 sprintf(newbootargs," androidboot.bootreason=cold,powerkey"); 185 sprintf(newbootargs," androidboot.bootreason=cold,powerkey");
175 else if (strstr(cause, "WDOG") || strstr(cause, "WDG")) 186 else if (strstr(cause, "WDOG") || strstr(cause, "WDG"))
176 sprintf(newbootargs," androidboot.bootreason=watchdog"); 187 sprintf(newbootargs," androidboot.bootreason=watchdog");
177 else 188 else
178 sprintf(newbootargs," androidboot.bootreason=reboot"); 189 sprintf(newbootargs," androidboot.bootreason=reboot");
179 #else 190 #else
180 sprintf(newbootargs," androidboot.bootreason=reboot"); 191 sprintf(newbootargs," androidboot.bootreason=reboot");
181 #endif 192 #endif
182 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline)); 193 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline));
183 194
184 #ifdef CONFIG_AVB_SUPPORT 195 #ifdef CONFIG_AVB_SUPPORT
185 /* secondary cmdline added by avb */ 196 /* secondary cmdline added by avb */
186 char *bootargs_sec = env_get("bootargs_sec"); 197 char *bootargs_sec = env_get("bootargs_sec");
187 if (bootargs_sec) { 198 if (bootargs_sec) {
188 strncat(commandline, " ", sizeof(commandline) - strlen(commandline)); 199 strncat(commandline, " ", sizeof(commandline) - strlen(commandline));
189 strncat(commandline, bootargs_sec, sizeof(commandline) - strlen(commandline)); 200 strncat(commandline, bootargs_sec, sizeof(commandline) - strlen(commandline));
190 } 201 }
191 #endif 202 #endif
192 #ifdef CONFIG_SYSTEM_RAMDISK_SUPPORT 203 #ifdef CONFIG_SYSTEM_RAMDISK_SUPPORT
193 /* Normal boot: 204 /* Normal boot:
194 * cmdline to bypass ramdisk in boot.img, but use the system.img 205 * cmdline to bypass ramdisk in boot.img, but use the system.img
195 * Recovery boot: 206 * Recovery boot:
196 * Use the ramdisk in boot.img 207 * Use the ramdisk in boot.img
197 */ 208 */
198 char *bootargs_3rd = env_get("bootargs_3rd"); 209 char *bootargs_3rd = env_get("bootargs_3rd");
199 if (bootargs_3rd) { 210 if (bootargs_3rd) {
200 strncat(commandline, " ", sizeof(commandline) - strlen(commandline)); 211 strncat(commandline, " ", sizeof(commandline) - strlen(commandline));
201 strncat(commandline, bootargs_3rd, sizeof(commandline) - strlen(commandline)); 212 strncat(commandline, bootargs_3rd, sizeof(commandline) - strlen(commandline));
202 } 213 }
203 #endif 214 #endif
204 215
205 /* VTS need this commandline to verify fdt overlay. Pass the 216 /* VTS need this commandline to verify fdt overlay. Pass the
206 * dtb index as "0" here since we only have one dtb in dtbo 217 * dtb index as "0" here since we only have one dtb in dtbo
207 * partition and haven't enabled the dtb overlay. 218 * partition and haven't enabled the dtb overlay.
208 */ 219 */
209 #if defined(CONFIG_ANDROID_SUPPORT) || defined(CONFIG_ANDROID_AUTO_SUPPORT) 220 #if defined(CONFIG_ANDROID_SUPPORT) || defined(CONFIG_ANDROID_AUTO_SUPPORT)
210 sprintf(newbootargs," androidboot.dtbo_idx=0"); 221 sprintf(newbootargs," androidboot.dtbo_idx=0");
211 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline)); 222 strncat(commandline, newbootargs, sizeof(commandline) - strlen(commandline));
212 #endif 223 #endif
213 224
214 char *keystore = env_get("keystore"); 225 char *keystore = env_get("keystore");
215 if ((keystore == NULL) || strncmp(keystore, "trusty", sizeof("trusty"))) { 226 if ((keystore == NULL) || strncmp(keystore, "trusty", sizeof("trusty"))) {
216 char *bootargs_trusty = "androidboot.keystore=software"; 227 char *bootargs_trusty = "androidboot.keystore=software";
217 strncat(commandline, " ", sizeof(commandline) - strlen(commandline)); 228 strncat(commandline, " ", sizeof(commandline) - strlen(commandline));
218 strncat(commandline, bootargs_trusty, sizeof(commandline) - strlen(commandline)); 229 strncat(commandline, bootargs_trusty, sizeof(commandline) - strlen(commandline));
219 } else { 230 } else {
220 char *bootargs_trusty = "androidboot.keystore=trusty"; 231 char *bootargs_trusty = "androidboot.keystore=trusty";
221 strncat(commandline, " ", sizeof(commandline) - strlen(commandline)); 232 strncat(commandline, " ", sizeof(commandline) - strlen(commandline));
222 strncat(commandline, bootargs_trusty, sizeof(commandline) - strlen(commandline)); 233 strncat(commandline, bootargs_trusty, sizeof(commandline) - strlen(commandline));
223 } 234 }
224 235
225 /* Add 'append_bootargs' to hold some paramemters which need to be appended 236 /* Add 'append_bootargs' to hold some paramemters which need to be appended
226 * to bootargs */ 237 * to bootargs */
227 char *append_bootargs = env_get("append_bootargs"); 238 char *append_bootargs = env_get("append_bootargs");
228 if (append_bootargs) { 239 if (append_bootargs) {
229 if (strlen(append_bootargs) + 2 > 240 if (strlen(append_bootargs) + 2 >
230 (sizeof(commandline) - strlen(commandline))) { 241 (sizeof(commandline) - strlen(commandline))) {
231 printf("The 'append_bootargs' is too long to be appended to bootargs\n"); 242 printf("The 'append_bootargs' is too long to be appended to bootargs\n");
232 } else { 243 } else {
233 strncat(commandline, " ", sizeof(commandline) - strlen(commandline)); 244 strncat(commandline, " ", sizeof(commandline) - strlen(commandline));
234 strncat(commandline, append_bootargs, sizeof(commandline) - strlen(commandline)); 245 strncat(commandline, append_bootargs, sizeof(commandline) - strlen(commandline));
235 } 246 }
236 } 247 }
237 248
238 debug("Kernel command line: %s\n", commandline); 249 debug("Kernel command line: %s\n", commandline);
239 env_set("bootargs", commandline); 250 env_set("bootargs", commandline);
240 251
241 if (os_data) { 252 if (os_data) {
242 *os_data = (ulong)hdr; 253 *os_data = (ulong)hdr;
243 *os_data += hdr->page_size; 254 *os_data += hdr->page_size;
244 } 255 }
245 if (os_len) 256 if (os_len)
246 *os_len = hdr->kernel_size; 257 *os_len = hdr->kernel_size;
247 return 0; 258 return 0;
248 } 259 }
249 260
250 int android_image_check_header(const struct andr_img_hdr *hdr) 261 int android_image_check_header(const struct andr_img_hdr *hdr)
251 { 262 {
252 return memcmp(ANDR_BOOT_MAGIC, hdr->magic, ANDR_BOOT_MAGIC_SIZE); 263 return memcmp(ANDR_BOOT_MAGIC, hdr->magic, ANDR_BOOT_MAGIC_SIZE);
253 } 264 }
254 265
255 ulong android_image_get_end(const struct andr_img_hdr *hdr) 266 ulong android_image_get_end(const struct andr_img_hdr *hdr)
256 { 267 {
257 ulong end; 268 ulong end;
258 /* 269 /*
259 * The header takes a full page, the remaining components are aligned 270 * The header takes a full page, the remaining components are aligned
260 * on page boundary 271 * on page boundary
261 */ 272 */
262 end = (ulong)hdr; 273 end = (ulong)hdr;
263 end += hdr->page_size; 274 end += hdr->page_size;
264 end += ALIGN(hdr->kernel_size, hdr->page_size); 275 end += ALIGN(hdr->kernel_size, hdr->page_size);
265 end += ALIGN(hdr->ramdisk_size, hdr->page_size); 276 end += ALIGN(hdr->ramdisk_size, hdr->page_size);
266 end += ALIGN(hdr->second_size, hdr->page_size); 277 end += ALIGN(hdr->second_size, hdr->page_size);
267 278
268 return end; 279 return end;
269 } 280 }
270 281
271 ulong android_image_get_kload(const struct andr_img_hdr *hdr) 282 ulong android_image_get_kload(const struct andr_img_hdr *hdr)
272 { 283 {
273 return android_image_get_kernel_addr(hdr); 284 return android_image_get_kernel_addr(hdr);
274 } 285 }
275 286
276 int android_image_get_ramdisk(const struct andr_img_hdr *hdr, 287 int android_image_get_ramdisk(const struct andr_img_hdr *hdr,
277 ulong *rd_data, ulong *rd_len) 288 ulong *rd_data, ulong *rd_len)
278 { 289 {
279 if (!hdr->ramdisk_size) { 290 if (!hdr->ramdisk_size) {
280 *rd_data = *rd_len = 0; 291 *rd_data = *rd_len = 0;
281 return -1; 292 return -1;
282 } 293 }
283 294
284 printf("RAM disk load addr 0x%08x size %u KiB\n", 295 printf("RAM disk load addr 0x%08x size %u KiB\n",
285 hdr->ramdisk_addr, DIV_ROUND_UP(hdr->ramdisk_size, 1024)); 296 hdr->ramdisk_addr, DIV_ROUND_UP(hdr->ramdisk_size, 1024));
286 297
287 *rd_data = (unsigned long)hdr; 298 *rd_data = (unsigned long)hdr;
288 *rd_data += hdr->page_size; 299 *rd_data += hdr->page_size;
289 *rd_data += ALIGN(hdr->kernel_size, hdr->page_size); 300 *rd_data += ALIGN(hdr->kernel_size, hdr->page_size);
290 301
291 *rd_len = hdr->ramdisk_size; 302 *rd_len = hdr->ramdisk_size;
292 return 0; 303 return 0;
293 } 304 }
294 305
295 int android_image_get_second(const struct andr_img_hdr *hdr, 306 int android_image_get_second(const struct andr_img_hdr *hdr,
296 ulong *second_data, ulong *second_len) 307 ulong *second_data, ulong *second_len)
297 { 308 {
298 if (!hdr->second_size) { 309 if (!hdr->second_size) {
299 *second_data = *second_len = 0; 310 *second_data = *second_len = 0;
300 return -1; 311 return -1;
301 } 312 }
302 313
303 *second_data = (unsigned long)hdr; 314 *second_data = (unsigned long)hdr;
304 *second_data += hdr->page_size; 315 *second_data += hdr->page_size;
305 *second_data += ALIGN(hdr->kernel_size, hdr->page_size); 316 *second_data += ALIGN(hdr->kernel_size, hdr->page_size);
306 *second_data += ALIGN(hdr->ramdisk_size, hdr->page_size); 317 *second_data += ALIGN(hdr->ramdisk_size, hdr->page_size);
307 318
308 printf("second address is 0x%lx\n",*second_data); 319 printf("second address is 0x%lx\n",*second_data);
309 320
310 *second_len = hdr->second_size; 321 *second_len = hdr->second_size;
311 return 0; 322 return 0;
312 } 323 }
313 324
314 #if !defined(CONFIG_SPL_BUILD) 325 #if !defined(CONFIG_SPL_BUILD)
315 /** 326 /**
316 * android_print_contents - prints out the contents of the Android format image 327 * android_print_contents - prints out the contents of the Android format image
317 * @hdr: pointer to the Android format image header 328 * @hdr: pointer to the Android format image header
318 * 329 *
319 * android_print_contents() formats a multi line Android image contents 330 * android_print_contents() formats a multi line Android image contents
320 * description. 331 * description.
321 * The routine prints out Android image properties 332 * The routine prints out Android image properties
322 * 333 *
323 * returns: 334 * returns:
324 * no returned results 335 * no returned results
325 */ 336 */
326 void android_print_contents(const struct andr_img_hdr *hdr) 337 void android_print_contents(const struct andr_img_hdr *hdr)
327 { 338 {
328 const char * const p = IMAGE_INDENT_STRING; 339 const char * const p = IMAGE_INDENT_STRING;
329 /* os_version = ver << 11 | lvl */ 340 /* os_version = ver << 11 | lvl */
330 u32 os_ver = hdr->os_version >> 11; 341 u32 os_ver = hdr->os_version >> 11;
331 u32 os_lvl = hdr->os_version & ((1U << 11) - 1); 342 u32 os_lvl = hdr->os_version & ((1U << 11) - 1);
332 343
333 printf("%skernel size: %x\n", p, hdr->kernel_size); 344 printf("%skernel size: %x\n", p, hdr->kernel_size);
334 printf("%skernel address: %x\n", p, hdr->kernel_addr); 345 printf("%skernel address: %x\n", p, hdr->kernel_addr);
335 printf("%sramdisk size: %x\n", p, hdr->ramdisk_size); 346 printf("%sramdisk size: %x\n", p, hdr->ramdisk_size);
336 printf("%sramdisk addrress: %x\n", p, hdr->ramdisk_addr); 347 printf("%sramdisk addrress: %x\n", p, hdr->ramdisk_addr);
337 printf("%ssecond size: %x\n", p, hdr->second_size); 348 printf("%ssecond size: %x\n", p, hdr->second_size);
338 printf("%ssecond address: %x\n", p, hdr->second_addr); 349 printf("%ssecond address: %x\n", p, hdr->second_addr);
339 printf("%stags address: %x\n", p, hdr->tags_addr); 350 printf("%stags address: %x\n", p, hdr->tags_addr);
340 printf("%spage size: %x\n", p, hdr->page_size); 351 printf("%spage size: %x\n", p, hdr->page_size);
341 /* ver = A << 14 | B << 7 | C (7 bits for each of A, B, C) 352 /* ver = A << 14 | B << 7 | C (7 bits for each of A, B, C)
342 * lvl = ((Y - 2000) & 127) << 4 | M (7 bits for Y, 4 bits for M) */ 353 * lvl = ((Y - 2000) & 127) << 4 | M (7 bits for Y, 4 bits for M) */
343 printf("%sos_version: %x (ver: %u.%u.%u, level: %u.%u)\n", 354 printf("%sos_version: %x (ver: %u.%u.%u, level: %u.%u)\n",
344 p, hdr->os_version, 355 p, hdr->os_version,
345 (os_ver >> 7) & 0x7F, (os_ver >> 14) & 0x7F, os_ver & 0x7F, 356 (os_ver >> 7) & 0x7F, (os_ver >> 14) & 0x7F, os_ver & 0x7F,
346 (os_lvl >> 4) + 2000, os_lvl & 0x0F); 357 (os_lvl >> 4) + 2000, os_lvl & 0x0F);
347 printf("%sname: %s\n", p, hdr->name); 358 printf("%sname: %s\n", p, hdr->name);
348 printf("%scmdline: %s\n", p, hdr->cmdline); 359 printf("%scmdline: %s\n", p, hdr->cmdline);
349 } 360 }
350 #endif 361 #endif
351 362
352 #define ARM64_IMAGE_MAGIC 0x644d5241 363 #define ARM64_IMAGE_MAGIC 0x644d5241
353 bool image_arm64(void *images) 364 bool image_arm64(void *images)
354 { 365 {
355 struct header_image *ih; 366 struct header_image *ih;
356 367
357 ih = (struct header_image *)images; 368 ih = (struct header_image *)images;
358 debug("image magic: %x\n", ih->magic); 369 debug("image magic: %x\n", ih->magic);
359 if (ih->magic == le32_to_cpu(ARM64_IMAGE_MAGIC)) 370 if (ih->magic == le32_to_cpu(ARM64_IMAGE_MAGIC))
360 return true; 371 return true;
361 return false; 372 return false;
362 } 373 }
363 374