Newer
Older
* @initrd_start: pointer to a ulong variable, will hold final init ramdisk
* start address (after possible relocation)
* @initrd_end: pointer to a ulong variable, will hold final init ramdisk
* end address (after possible relocation)
*
* boot_ramdisk_high() takes a relocation hint from "initrd_high" environement
* variable and if requested ramdisk data is moved to a specified location.
*
* Initrd_start and initrd_end are set to final (after relocation) ramdisk
* start/end addresses if ramdisk image start and len were provided,
* otherwise set initrd_start and initrd_end set to zeros.
*
* 0 - success
* -1 - failure
int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
ulong *initrd_start, ulong *initrd_end)
{
char *s;
ulong initrd_high;
int initrd_copy_to_ram = 1;
if ((s = getenv ("initrd_high")) != NULL) {
/* a value of "no" or a similar string will act like 0,
* turning the "load high" feature off. This is intentional.
*/
initrd_high = simple_strtoul (s, NULL, 16);
if (initrd_high == ~0)
initrd_copy_to_ram = 0;
} else {
/* not set, no restrictions to load high */
initrd_high = ~0;
}
#ifdef CONFIG_LOGBUFFER
/* Prevent initrd from overwriting logbuffer */
lmb_reserve(lmb, logbuffer_base() - LOGBUFF_OVERHEAD, LOGBUFF_RESERVE);
#endif
debug ("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
initrd_high, initrd_copy_to_ram);
if (rd_data) {
if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */
debug (" in-place initrd\n");
*initrd_start = rd_data;
*initrd_end = rd_data + rd_len;
lmb_reserve(lmb, rd_data, rd_len);
*initrd_start = (ulong)lmb_alloc_base (lmb, rd_len, 0x1000, initrd_high);
*initrd_start = (ulong)lmb_alloc (lmb, rd_len, 0x1000);
puts ("ramdisk - allocation error\n");
}
show_boot_progress (12);
*initrd_end = *initrd_start + rd_len;
printf (" Loading Ramdisk to %08lx, end %08lx ... ",
*initrd_start, *initrd_end);
memmove_wd ((void *)*initrd_start,
(void *)rd_data, rd_len, CHUNKSZ);
puts ("OK\n");
}
} else {
*initrd_start = 0;
*initrd_end = 0;
}
debug (" ramdisk load start = 0x%08lx, ramdisk load end = 0x%08lx\n",
*initrd_start, *initrd_end);
#endif /* CONFIG_SYS_BOOT_RAMDISK_HIGH */
#ifdef CONFIG_OF_LIBFDT
static void fdt_error (const char *msg)
{
puts ("ERROR: ");
puts (msg);
puts (" - must RESET the board to recover.\n");
}
static const image_header_t *image_get_fdt (ulong fdt_addr)
const image_header_t *fdt_hdr = (const image_header_t *)fdt_addr;
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
image_print_contents (fdt_hdr);
puts (" Verifying Checksum ... ");
if (!image_check_hcrc (fdt_hdr)) {
fdt_error ("fdt header checksum invalid");
return NULL;
}
if (!image_check_dcrc (fdt_hdr)) {
fdt_error ("fdt checksum invalid");
return NULL;
}
puts ("OK\n");
if (!image_check_type (fdt_hdr, IH_TYPE_FLATDT)) {
fdt_error ("uImage is not a fdt");
return NULL;
}
if (image_get_comp (fdt_hdr) != IH_COMP_NONE) {
fdt_error ("uImage is compressed");
return NULL;
}
if (fdt_check_header ((char *)image_get_data (fdt_hdr)) != 0) {
fdt_error ("uImage data is not a fdt");
return NULL;
}
return fdt_hdr;
}
/**
* fit_check_fdt - verify FIT format FDT subimage
* @fit_hdr: pointer to the FIT header
* fdt_noffset: FDT subimage node offset within FIT image
* @verify: data CRC verification flag
*
* fit_check_fdt() verifies integrity of the FDT subimage and from
* specified FIT image.
*
* returns:
* 1, on success
* 0, on failure
*/
#if defined(CONFIG_FIT)
static int fit_check_fdt (const void *fit, int fdt_noffset, int verify)
{
fit_image_print (fit, fdt_noffset, " ");
if (verify) {
puts (" Verifying Hash Integrity ... ");
if (!fit_image_check_hashes (fit, fdt_noffset)) {
fdt_error ("Bad Data Hash");
return 0;
}
puts ("OK\n");
}
if (!fit_image_check_type (fit, fdt_noffset, IH_TYPE_FLATDT)) {
fdt_error ("Not a FDT image");
return 0;
}
if (!fit_image_check_comp (fit, fdt_noffset, IH_COMP_NONE)) {
fdt_error ("FDT image is compressed");
return 0;
}
return 1;
}
#endif /* CONFIG_FIT */
#ifndef CONFIG_SYS_FDT_PAD
#define CONFIG_SYS_FDT_PAD 0x3000
#endif
/**
* boot_relocate_fdt - relocate flat device tree
* @lmb: pointer to lmb handle, will be used for memory mgmt
* @of_flat_tree: pointer to a char* variable, will hold fdt start address
* @of_size: pointer to a ulong variable, will hold fdt length
*
* boot_relocate_fdt() allocates a region of memory within the bootmap and
* relocates the of_flat_tree into that region, even if the fdt is already in
* the bootmap. It also expands the size of the fdt by CONFIG_SYS_FDT_PAD
* bytes.
*
* of_flat_tree and of_size are set to final (after relocation) values
*
* returns:
* 0 - success
* 1 - failure
*/
#if defined(CONFIG_SYS_BOOTMAPSZ)
int boot_relocate_fdt (struct lmb *lmb, char **of_flat_tree, ulong *of_size)
void *fdt_blob = *of_flat_tree;
void *of_start = 0;
/* nothing to do */
if (*of_size == 0)
return 0;
if (fdt_check_header (fdt_blob) != 0) {
fdt_error ("image is not a fdt");
goto error;
}
/* position on a 4K boundary before the alloc_current */
/* Pad the FDT by a specified amount */
of_len = *of_size + CONFIG_SYS_FDT_PAD;
of_start = (void *)(unsigned long)lmb_alloc_base(lmb, of_len, 0x1000,
CONFIG_SYS_BOOTMAPSZ + getenv_bootm_low());
if (of_start == 0) {
puts("device tree - allocation error\n");
goto error;
}
debug ("## device tree at %p ... %p (len=%ld [0x%lX])\n",
fdt_blob, fdt_blob + *of_size - 1, of_len, of_len);
printf (" Loading Device Tree to %p, end %p ... ",
of_start, of_start + of_len - 1);
err = fdt_open_into (fdt_blob, of_start, of_len);
if (err != 0) {
fdt_error ("fdt move failed");
goto error;
puts ("OK\n");
*of_flat_tree = of_start;
*of_size = of_len;
set_working_fdt_addr(*of_flat_tree);
return 0;
error:
return 1;
}
#endif /* CONFIG_SYS_BOOTMAPSZ */
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
/**
* boot_get_fdt - main fdt handling routine
* @argc: command argument count
* @argv: command argument list
* @images: pointer to the bootm images structure
* @of_flat_tree: pointer to a char* variable, will hold fdt start address
* @of_size: pointer to a ulong variable, will hold fdt length
*
* boot_get_fdt() is responsible for finding a valid flat device tree image.
* Curently supported are the following ramdisk sources:
* - multicomponent kernel/ramdisk image,
* - commandline provided address of decicated ramdisk image.
*
* returns:
* 0, if fdt image was found and valid, or skipped
* of_flat_tree and of_size are set to fdt start address and length if
* fdt image is found and valid
*
* 1, if fdt image is found but corrupted
* of_flat_tree and of_size are set to 0 if no fdt exists
*/
int boot_get_fdt (int flag, int argc, char * const argv[], bootm_headers_t *images,
char **of_flat_tree, ulong *of_size)
{
const image_header_t *fdt_hdr;
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
ulong fdt_addr;
char *fdt_blob = NULL;
ulong image_start, image_end;
ulong load_start, load_end;
#if defined(CONFIG_FIT)
void *fit_hdr;
const char *fit_uname_config = NULL;
const char *fit_uname_fdt = NULL;
ulong default_addr;
int cfg_noffset;
int fdt_noffset;
const void *data;
size_t size;
#endif
*of_flat_tree = NULL;
*of_size = 0;
if (argc > 3 || genimg_has_config (images)) {
#if defined(CONFIG_FIT)
if (argc > 3) {
/*
* If the FDT blob comes from the FIT image and the
* FIT image address is omitted in the command line
* argument, try to use ramdisk or os FIT image
* address or default load address.
*/
if (images->fit_uname_rd)
default_addr = (ulong)images->fit_hdr_rd;
else if (images->fit_uname_os)
default_addr = (ulong)images->fit_hdr_os;
else
default_addr = load_addr;
if (fit_parse_conf (argv[3], default_addr,
&fdt_addr, &fit_uname_config)) {
debug ("* fdt: config '%s' from image at 0x%08lx\n",
fit_uname_config, fdt_addr);
} else if (fit_parse_subimage (argv[3], default_addr,
&fdt_addr, &fit_uname_fdt)) {
debug ("* fdt: subimage '%s' from image at 0x%08lx\n",
fit_uname_fdt, fdt_addr);
} else
#endif
{
fdt_addr = simple_strtoul(argv[3], NULL, 16);
debug ("* fdt: cmdline image address = 0x%08lx\n",
fdt_addr);
}
#if defined(CONFIG_FIT)
} else {
/* use FIT configuration provided in first bootm
* command argument
*/
fdt_addr = (ulong)images->fit_hdr_os;
fit_uname_config = images->fit_uname_cfg;
debug ("* fdt: using config '%s' from image at 0x%08lx\n",
fit_uname_config, fdt_addr);
/*
* Check whether configuration has FDT blob defined,
* if not quit silently.
*/
fit_hdr = (void *)fdt_addr;
cfg_noffset = fit_conf_get_node (fit_hdr,
fit_uname_config);
if (cfg_noffset < 0) {
debug ("* fdt: no such config\n");
return 0;
}
fdt_noffset = fit_conf_get_fdt_node (fit_hdr,
cfg_noffset);
if (fdt_noffset < 0) {
debug ("* fdt: no fdt in config\n");
return 0;
}
}
#endif
debug ("## Checking for 'FDT'/'FDT Image' at %08lx\n",
fdt_addr);
/* copy from dataflash if needed */
fdt_addr = genimg_get_image (fdt_addr);
/*
* Check if there is an FDT image at the
* address provided in the second bootm argument
* check image type, for FIT images get a FIT node.
*/
switch (genimg_get_format ((void *)fdt_addr)) {
case IMAGE_FORMAT_LEGACY:
/* verify fdt_addr points to a valid image header */
printf ("## Flattened Device Tree from Legacy Image at %08lx\n",
fdt_addr);
fdt_hdr = image_get_fdt (fdt_addr);
if (!fdt_hdr)
goto error;
/*
* move image data to the load address,
* make sure we don't overwrite initial image
*/
image_start = (ulong)fdt_hdr;
image_end = image_get_image_end (fdt_hdr);
load_start = image_get_load (fdt_hdr);
load_end = load_start + image_get_data_size (fdt_hdr);
if ((load_start < image_end) && (load_end > image_start)) {
fdt_error ("fdt overwritten");
goto error;
}
debug (" Loading FDT from 0x%08lx to 0x%08lx\n",
image_get_data (fdt_hdr), load_start);
memmove ((void *)load_start,
(void *)image_get_data (fdt_hdr),
image_get_data_size (fdt_hdr));
fdt_blob = (char *)load_start;
break;
case IMAGE_FORMAT_FIT:
/*
* This case will catch both: new uImage format
* (libfdt based) and raw FDT blob (also libfdt
* based).
*/
#if defined(CONFIG_FIT)
/* check FDT blob vs FIT blob */
if (fit_check_format ((const void *)fdt_addr)) {
/*
* FIT image
*/
fit_hdr = (void *)fdt_addr;
printf ("## Flattened Device Tree from FIT Image at %08lx\n",
fdt_addr);
if (!fit_uname_fdt) {
/*
* no FDT blob image node unit name,
* try to get config node first. If
* config unit node name is NULL
* fit_conf_get_node() will try to
* find default config node
*/
cfg_noffset = fit_conf_get_node (fit_hdr,
fit_uname_config);
if (cfg_noffset < 0) {
fdt_error ("Could not find configuration node\n");
goto error;
}
fit_uname_config = fdt_get_name (fit_hdr,
cfg_noffset, NULL);
printf (" Using '%s' configuration\n",
fit_uname_config);
fdt_noffset = fit_conf_get_fdt_node (fit_hdr,
cfg_noffset);
fit_uname_fdt = fit_get_name (fit_hdr,
fdt_noffset, NULL);
} else {
/* get FDT component image node offset */
fdt_noffset = fit_image_get_node (fit_hdr,
fit_uname_fdt);
}
if (fdt_noffset < 0) {
fdt_error ("Could not find subimage node\n");
goto error;
}
printf (" Trying '%s' FDT blob subimage\n",
fit_uname_fdt);
if (!fit_check_fdt (fit_hdr, fdt_noffset,
images->verify))
goto error;
/* get ramdisk image data address and length */
if (fit_image_get_data (fit_hdr, fdt_noffset,
&data, &size)) {
fdt_error ("Could not find FDT subimage data");
goto error;
}
/* verift that image data is a proper FDT blob */
if (fdt_check_header ((char *)data) != 0) {
fdt_error ("Subimage data is not a FTD");
goto error;
}
/*
* move image data to the load address,
* make sure we don't overwrite initial image
*/
image_start = (ulong)fit_hdr;
image_end = fit_get_end (fit_hdr);
if (fit_image_get_load (fit_hdr, fdt_noffset,
&load_start) == 0) {
load_end = load_start + size;
if ((load_start < image_end) &&
(load_end > image_start)) {
fdt_error ("FDT overwritten");
goto error;
}
printf (" Loading FDT from 0x%08lx to 0x%08lx\n",
(ulong)data, load_start);
memmove ((void *)load_start,
(void *)data, size);
fdt_blob = (char *)load_start;
} else {
fdt_blob = (char *)data;
}
images->fit_hdr_fdt = fit_hdr;
images->fit_uname_fdt = fit_uname_fdt;
images->fit_noffset_fdt = fdt_noffset;
break;
} else
#endif
{
/*
* FDT blob
*/
fdt_blob = (char *)fdt_addr;
debug ("* fdt: raw FDT blob\n");
printf ("## Flattened Device Tree blob at %08lx\n", (long)fdt_blob);
}
break;
default:
puts ("ERROR: Did not find a cmdline Flattened Device Tree\n");
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
goto error;
}
printf (" Booting using the fdt blob at 0x%x\n", (int)fdt_blob);
} else if (images->legacy_hdr_valid &&
image_check_type (&images->legacy_hdr_os_copy, IH_TYPE_MULTI)) {
ulong fdt_data, fdt_len;
/*
* Now check if we have a legacy multi-component image,
* get second entry data start address and len.
*/
printf ("## Flattened Device Tree from multi "
"component Image at %08lX\n",
(ulong)images->legacy_hdr_os);
image_multi_getimg (images->legacy_hdr_os, 2, &fdt_data, &fdt_len);
if (fdt_len) {
fdt_blob = (char *)fdt_data;
printf (" Booting using the fdt at 0x%x\n", (int)fdt_blob);
if (fdt_check_header (fdt_blob) != 0) {
fdt_error ("image is not a fdt");
goto error;
}
if (fdt_totalsize(fdt_blob) != fdt_len) {
fdt_error ("fdt size != image size");
goto error;
}
} else {
debug ("## No Flattened Device Tree\n");
return 0;
}
} else {
debug ("## No Flattened Device Tree\n");
return 0;
}
*of_flat_tree = fdt_blob;
*of_size = fdt_totalsize(fdt_blob);
debug (" of_flat_tree at 0x%08lx size 0x%08lx\n",
return 0;
error:
*of_flat_tree = 0;
*of_size = 0;
return 1;
}
#endif /* CONFIG_OF_LIBFDT */
#ifdef CONFIG_SYS_BOOT_GET_CMDLINE
* boot_get_cmdline - allocate and initialize kernel cmdline
* @lmb: pointer to lmb handle, will be used for memory mgmt
* @cmd_start: pointer to a ulong variable, will hold cmdline start
* @cmd_end: pointer to a ulong variable, will hold cmdline end
*
* boot_get_cmdline() allocates space for kernel command line below
* BOOTMAPSZ + getenv_bootm_low() address. If "bootargs" U-boot environemnt
* variable is present its contents is copied to allocated kernel
* command line.
*
* returns:
* 0 - success
* -1 - failure
int boot_get_cmdline (struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
{
char *cmdline;
char *s;
cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf,
CONFIG_SYS_BOOTMAPSZ + getenv_bootm_low());
if (cmdline == NULL)
return -1;
if ((s = getenv("bootargs")) == NULL)
s = "";
strcpy(cmdline, s);
*cmd_start = (ulong) & cmdline[0];
*cmd_end = *cmd_start + strlen(cmdline);
debug ("## cmdline at 0x%08lx ... 0x%08lx\n", *cmd_start, *cmd_end);
#endif /* CONFIG_SYS_BOOT_GET_CMDLINE */
#ifdef CONFIG_SYS_BOOT_GET_KBD
* boot_get_kbd - allocate and initialize kernel copy of board info
* @lmb: pointer to lmb handle, will be used for memory mgmt
* @kbd: double pointer to board info data
*
* boot_get_kbd() allocates space for kernel copy of board info data below
* BOOTMAPSZ + getenv_bootm_low() address and kernel board info is initialized
* with the current u-boot board info data.
*
* returns:
* 0 - success
* -1 - failure
int boot_get_kbd (struct lmb *lmb, bd_t **kbd)
*kbd = (bd_t *)(ulong)lmb_alloc_base(lmb, sizeof(bd_t), 0xf,
CONFIG_SYS_BOOTMAPSZ + getenv_bootm_low());
if (*kbd == NULL)
return -1;
**kbd = *(gd->bd);
debug ("## kernel board info at 0x%08lx\n", (ulong)*kbd);
#if defined(DEBUG) && defined(CONFIG_CMD_BDI)
do_bdinfo(NULL, 0, 0, NULL);
#endif
#endif /* CONFIG_SYS_BOOT_GET_KBD */
#if defined(CONFIG_FIT)
/*****************************************************************************/
/* New uImage format routines */
/*****************************************************************************/
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
static int fit_parse_spec (const char *spec, char sepc, ulong addr_curr,
ulong *addr, const char **name)
{
const char *sep;
*addr = addr_curr;
*name = NULL;
sep = strchr (spec, sepc);
if (sep) {
if (sep - spec > 0)
*addr = simple_strtoul (spec, NULL, 16);
*name = sep + 1;
return 1;
}
return 0;
}
/**
* fit_parse_conf - parse FIT configuration spec
* @spec: input string, containing configuration spec
* @add_curr: current image address (to be used as a possible default)
* @addr: pointer to a ulong variable, will hold FIT image address of a given
* configuration
* @conf_name double pointer to a char, will hold pointer to a configuration
* unit name
*
* fit_parse_conf() expects configuration spec in the for of [<addr>]#<conf>,
* where <addr> is a FIT image address that contains configuration
* with a <conf> unit name.
*
* Address part is optional, and if omitted default add_curr will
* be used instead.
*
* returns:
* 1 if spec is a valid configuration string,
* addr and conf_name are set accordingly
* 0 otherwise
*/
inline int fit_parse_conf (const char *spec, ulong addr_curr,
ulong *addr, const char **conf_name)
{
return fit_parse_spec (spec, '#', addr_curr, addr, conf_name);
}
/**
* fit_parse_subimage - parse FIT subimage spec
* @spec: input string, containing subimage spec
* @add_curr: current image address (to be used as a possible default)
* @addr: pointer to a ulong variable, will hold FIT image address of a given
* subimage
* @image_name: double pointer to a char, will hold pointer to a subimage name
*
* fit_parse_subimage() expects subimage spec in the for of
* [<addr>]:<subimage>, where <addr> is a FIT image address that contains
* subimage with a <subimg> unit name.
*
* Address part is optional, and if omitted default add_curr will
* be used instead.
*
* returns:
* 1 if spec is a valid subimage string,
* addr and image_name are set accordingly
* 0 otherwise
*/
inline int fit_parse_subimage (const char *spec, ulong addr_curr,
ulong *addr, const char **image_name)
{
return fit_parse_spec (spec, ':', addr_curr, addr, image_name);
}
#endif /* !USE_HOSTCC */
static void fit_get_debug (const void *fit, int noffset,
char *prop_name, int err)
{
debug ("Can't get '%s' property from FIT 0x%08lx, "
"node: offset %d, name %s (%s)\n",
prop_name, (ulong)fit, noffset,
fit_get_name (fit, noffset, NULL),
fdt_strerror (err));
}
/**
* fit_print_contents - prints out the contents of the FIT format image
* @fit: pointer to the FIT format image header
* @p: pointer to prefix string
*
* fit_print_contents() formats a multi line FIT image contents description.
* The routine prints out FIT image properties (root node level) follwed by
* the details of each component image.
*
* returns:
* no returned results
*/
void fit_print_contents (const void *fit)
{
char *desc;
char *uname;
int images_noffset;
int confs_noffset;
int noffset;
int ndepth;
int count = 0;
int ret;
#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
time_t timestamp;
#endif
#ifdef USE_HOSTCC
p = "";
#else
p = " ";
#endif
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
/* Root node properties */
ret = fit_get_desc (fit, 0, &desc);
printf ("%sFIT description: ", p);
if (ret)
printf ("unavailable\n");
else
printf ("%s\n", desc);
#if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
ret = fit_get_timestamp (fit, 0, ×tamp);
printf ("%sCreated: ", p);
if (ret)
printf ("unavailable\n");
else
genimg_print_time (timestamp);
#endif
/* Find images parent node offset */
images_noffset = fdt_path_offset (fit, FIT_IMAGES_PATH);
if (images_noffset < 0) {
printf ("Can't find images parent node '%s' (%s)\n",
FIT_IMAGES_PATH, fdt_strerror (images_noffset));
return;
}
/* Process its subnodes, print out component images details */
for (ndepth = 0, count = 0, noffset = fdt_next_node (fit, images_noffset, &ndepth);
(noffset >= 0) && (ndepth > 0);
noffset = fdt_next_node (fit, noffset, &ndepth)) {
if (ndepth == 1) {
/*
* Direct child node of the images parent node,
* i.e. component image node.
*/
printf ("%s Image %u (%s)\n", p, count++,
fit_get_name(fit, noffset, NULL));
fit_image_print (fit, noffset, p);
}
}
/* Find configurations parent node offset */
confs_noffset = fdt_path_offset (fit, FIT_CONFS_PATH);
if (confs_noffset < 0) {
debug ("Can't get configurations parent node '%s' (%s)\n",
FIT_CONFS_PATH, fdt_strerror (confs_noffset));
return;
}
/* get default configuration unit name from default property */
uname = (char *)fdt_getprop (fit, noffset, FIT_DEFAULT_PROP, NULL);
if (uname)
printf ("%s Default Configuration: '%s'\n", p, uname);
/* Process its subnodes, print out configurations details */
for (ndepth = 0, count = 0, noffset = fdt_next_node (fit, confs_noffset, &ndepth);
(noffset >= 0) && (ndepth > 0);
noffset = fdt_next_node (fit, noffset, &ndepth)) {
if (ndepth == 1) {
/*
* Direct child node of the configurations parent node,
* i.e. configuration node.
*/
printf ("%s Configuration %u (%s)\n", p, count++,
fit_get_name(fit, noffset, NULL));
fit_conf_print (fit, noffset, p);
}
}
}
/**
* fit_image_print - prints out the FIT component image details
* @fit: pointer to the FIT format image header
* @image_noffset: offset of the component image node
* @p: pointer to prefix string
*
* fit_image_print() lists all mandatory properies for the processed component
Bartlomiej Sieka
committed
* image. If present, hash nodes are printed out as well. Load
* address for images of type firmware is also printed out. Since the load
* address is not mandatory for firmware images, it will be output as
* "unavailable" when not present.
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
*
* returns:
* no returned results
*/
void fit_image_print (const void *fit, int image_noffset, const char *p)
{
char *desc;
uint8_t type, arch, os, comp;
size_t size;
ulong load, entry;
const void *data;
int noffset;
int ndepth;
int ret;
/* Mandatory properties */
ret = fit_get_desc (fit, image_noffset, &desc);
printf ("%s Description: ", p);
if (ret)
printf ("unavailable\n");
else
printf ("%s\n", desc);
fit_image_get_type (fit, image_noffset, &type);
printf ("%s Type: %s\n", p, genimg_get_type_name (type));
fit_image_get_comp (fit, image_noffset, &comp);
printf ("%s Compression: %s\n", p, genimg_get_comp_name (comp));
ret = fit_image_get_data (fit, image_noffset, &data, &size);
#ifndef USE_HOSTCC
printf ("%s Data Start: ", p);
if (ret)
printf ("unavailable\n");
else
printf ("0x%08lx\n", (ulong)data);
#endif
printf ("%s Data Size: ", p);
if (ret)
printf ("unavailable\n");
else
genimg_print_size (size);
/* Remaining, type dependent properties */
if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE) ||
(type == IH_TYPE_RAMDISK) || (type == IH_TYPE_FIRMWARE) ||
(type == IH_TYPE_FLATDT)) {
fit_image_get_arch (fit, image_noffset, &arch);
printf ("%s Architecture: %s\n", p, genimg_get_arch_name (arch));
}
if (type == IH_TYPE_KERNEL) {
fit_image_get_os (fit, image_noffset, &os);
printf ("%s OS: %s\n", p, genimg_get_os_name (os));
}
Bartlomiej Sieka
committed
if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE) ||
(type == IH_TYPE_FIRMWARE)) {
ret = fit_image_get_load (fit, image_noffset, &load);
printf ("%s Load Address: ", p);
if (ret)
printf ("unavailable\n");
else
printf ("0x%08lx\n", load);
Bartlomiej Sieka
committed
}
Bartlomiej Sieka
committed
if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE)) {
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
fit_image_get_entry (fit, image_noffset, &entry);
printf ("%s Entry Point: ", p);
if (ret)
printf ("unavailable\n");
else
printf ("0x%08lx\n", entry);
}
/* Process all hash subnodes of the component image node */
for (ndepth = 0, noffset = fdt_next_node (fit, image_noffset, &ndepth);
(noffset >= 0) && (ndepth > 0);
noffset = fdt_next_node (fit, noffset, &ndepth)) {
if (ndepth == 1) {
/* Direct child node of the component image node */
fit_image_print_hash (fit, noffset, p);
}
}
}
/**
* fit_image_print_hash - prints out the hash node details
* @fit: pointer to the FIT format image header
* @noffset: offset of the hash node
* @p: pointer to prefix string
*
* fit_image_print_hash() lists properies for the processed hash node
*
* returns:
* no returned results
*/
void fit_image_print_hash (const void *fit, int noffset, const char *p)
{
char *algo;
uint8_t *value;
int value_len;
int i, ret;
/*
* Check subnode name, must be equal to "hash".
* Multiple hash nodes require unique unit node
* names, e.g. hash@1, hash@2, etc.
*/
if (strncmp (fit_get_name(fit, noffset, NULL),
FIT_HASH_NODENAME,
strlen(FIT_HASH_NODENAME)) != 0)
return;
debug ("%s Hash node: '%s'\n", p,
fit_get_name (fit, noffset, NULL));
printf ("%s Hash algo: ", p);
if (fit_image_hash_get_algo (fit, noffset, &algo)) {
printf ("invalid/unsupported\n");
return;
}
printf ("%s\n", algo);
ret = fit_image_hash_get_value (fit, noffset, &value,
&value_len);
printf ("%s Hash value: ", p);
if (ret) {
printf ("unavailable\n");
} else {
for (i = 0; i < value_len; i++)
printf ("%02x", value[i]);
printf ("\n");
}
debug ("%s Hash len: %d\n", p, value_len);
}
/**
* fit_get_desc - get node description property
* @fit: pointer to the FIT format image header
* @noffset: node offset
* @desc: double pointer to the char, will hold pointer to the descrption
*
* fit_get_desc() reads description property from a given node, if
* description is found pointer to it is returened in third call argument.
*
* returns:
* 0, on success
* -1, on failure
*/
int fit_get_desc (const void *fit, int noffset, char **desc)
{
int len;
*desc = (char *)fdt_getprop (fit, noffset, FIT_DESC_PROP, &len);
if (*desc == NULL) {
fit_get_debug (fit, noffset, FIT_DESC_PROP, len);