ifwitool: Introduce a use the Second Logical Boot Partition option
The ApolloLake SoC allows two Logical Boot Partitions. This patch introduces a '-s' optional parameter to select the second Logical Boot Partition. Change-Id: If32ec11fc7291d52b821bf95c1e186690d06ba11 Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/37660 Reviewed-by: Furquan Shaikh <furquan@google.com> Reviewed-by: Werner Zeh <werner.zeh@siemens.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
d908916642
commit
31e2188c38
@ -34,9 +34,13 @@
|
|||||||
*/
|
*/
|
||||||
#define BPDT_SIGNATURE (0x000055AA)
|
#define BPDT_SIGNATURE (0x000055AA)
|
||||||
|
|
||||||
|
#define LBP1 (0)
|
||||||
|
#define LBP2 (1)
|
||||||
|
|
||||||
/* Parameters passed in by caller. */
|
/* Parameters passed in by caller. */
|
||||||
static struct param {
|
static struct param {
|
||||||
const char *file_name;
|
const char *file_name;
|
||||||
|
size_t logical_boot_partition;
|
||||||
const char *subpart_name;
|
const char *subpart_name;
|
||||||
const char *image_name;
|
const char *image_name;
|
||||||
bool dir_ops;
|
bool dir_ops;
|
||||||
@ -851,6 +855,18 @@ static void parse_subpart_dir(struct buffer *subpart_dir_buf,
|
|||||||
print_subpart_dir(subpart_dir);
|
print_subpart_dir(subpart_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Parse the bpdt entries to compute the size of the BPDT */
|
||||||
|
static size_t bpdt_size(void *data)
|
||||||
|
{
|
||||||
|
struct bpdt *b = (struct bpdt *)data;
|
||||||
|
size_t i, size = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < b->h.descriptor_count; i++)
|
||||||
|
size = MAX(size, b->e[i].offset + b->e[i].size);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse input image file to identify different sub-partitions. */
|
/* Parse input image file to identify different sub-partitions. */
|
||||||
static int ifwi_parse(void)
|
static int ifwi_parse(void)
|
||||||
{
|
{
|
||||||
@ -867,17 +883,22 @@ static int ifwi_parse(void)
|
|||||||
INFO("Buffer %p size 0x%zx\n", buff->data, buff->size);
|
INFO("Buffer %p size 0x%zx\n", buff->data, buff->size);
|
||||||
|
|
||||||
/* Look for BPDT signature at 4K intervals. */
|
/* Look for BPDT signature at 4K intervals. */
|
||||||
size_t offset = 0;
|
size_t offset = 0, lbp = LBP1;
|
||||||
void *data = buffer_get(buff);
|
void *data = buffer_get(buff);
|
||||||
|
|
||||||
while (offset < buffer_size(buff)) {
|
while (offset < buffer_size(buff)) {
|
||||||
if (read_at_le32(data, offset) == BPDT_SIGNATURE)
|
if (read_at_le32(data, offset) == BPDT_SIGNATURE) {
|
||||||
|
if (lbp == param.logical_boot_partition)
|
||||||
break;
|
break;
|
||||||
|
offset += bpdt_size((uint8_t *)data + offset);
|
||||||
|
lbp++;
|
||||||
|
} else
|
||||||
offset += 4 * KiB;
|
offset += 4 * KiB;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset >= buffer_size(buff)) {
|
if (offset >= buffer_size(buff)) {
|
||||||
ERROR("Image does not contain BPDT!!\n");
|
ERROR("Image does not contain BPDT for LBP=%zd!!\n",
|
||||||
|
param.logical_boot_partition);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1850,12 +1871,12 @@ struct command {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct command commands[] = {
|
static const struct command commands[] = {
|
||||||
{"add", "f:n:e:dvh?", ifwi_add},
|
{"add", "f:n:e:dsvh?", ifwi_add},
|
||||||
{"create", "f:vh?", ifwi_create},
|
{"create", "f:svh?", ifwi_create},
|
||||||
{"delete", "f:n:vh?", ifwi_delete},
|
{"delete", "f:n:svh?", ifwi_delete},
|
||||||
{"extract", "f:n:e:dvh?", ifwi_extract},
|
{"extract", "f:n:e:dsvh?", ifwi_extract},
|
||||||
{"print", "dh?", ifwi_print},
|
{"print", "dsh?", ifwi_print},
|
||||||
{"replace", "f:n:e:dvh?", ifwi_replace},
|
{"replace", "f:n:e:dsvh?", ifwi_replace},
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
@ -1865,6 +1886,7 @@ static struct option long_options[] = {
|
|||||||
{"name", required_argument, 0, 'n'},
|
{"name", required_argument, 0, 'n'},
|
||||||
{"dir_ops", no_argument, 0, 'd'},
|
{"dir_ops", no_argument, 0, 'd'},
|
||||||
{"verbose", no_argument, 0, 'v'},
|
{"verbose", no_argument, 0, 'v'},
|
||||||
|
{"second_lbp", no_argument, 0, 's'},
|
||||||
{NULL, 0, 0, 0 }
|
{NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1875,14 +1897,15 @@ static void usage(const char *name)
|
|||||||
" %s [-h]\n"
|
" %s [-h]\n"
|
||||||
" %s FILE COMMAND [PARAMETERS]\n\n"
|
" %s FILE COMMAND [PARAMETERS]\n\n"
|
||||||
"COMMANDs:\n"
|
"COMMANDs:\n"
|
||||||
" add -f FILE -n NAME [-d -e ENTRY]\n"
|
" add -f FILE -n NAME [-d -e ENTRY] [-s]\n"
|
||||||
" create -f FILE\n"
|
" create -f FILE [-s]\n"
|
||||||
" delete -n NAME\n"
|
" delete -n NAME [-s]\n"
|
||||||
" extract -f FILE -n NAME [-d -e ENTRY]\n"
|
" extract -f FILE -n NAME [-d -e ENTRY] [-s]\n"
|
||||||
" print [-d]\n"
|
" print [-d] [-s]\n"
|
||||||
" replace -f FILE -n NAME [-d -e ENTRY]\n"
|
" replace -f FILE -n NAME [-d -e ENTRY] [-s]\n"
|
||||||
"OPTIONs:\n"
|
"OPTIONs:\n"
|
||||||
" -f FILE : File to read/write/create/extract\n"
|
" -f FILE : File to read/write/create/extract\n"
|
||||||
|
" -s : Use the second Logical Boot Partition\n"
|
||||||
" -d : Perform directory operation\n"
|
" -d : Perform directory operation\n"
|
||||||
" -e ENTRY: Name of directory entry to operate on\n"
|
" -e ENTRY: Name of directory entry to operate on\n"
|
||||||
" -v : Verbose level\n"
|
" -v : Verbose level\n"
|
||||||
@ -1906,6 +1929,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
param.image_name = argv[1];
|
param.image_name = argv[1];
|
||||||
|
param.logical_boot_partition = LBP1;
|
||||||
char *cmd = argv[2];
|
char *cmd = argv[2];
|
||||||
optind += 2;
|
optind += 2;
|
||||||
|
|
||||||
@ -1937,6 +1961,9 @@ int main(int argc, char **argv)
|
|||||||
case 'n':
|
case 'n':
|
||||||
param.subpart_name = optarg;
|
param.subpart_name = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
param.logical_boot_partition = LBP2;
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
param.file_name = optarg;
|
param.file_name = optarg;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user