Skip to content

Commit a88edc5

Browse files
authored
Merge pull request #158 from jcreedon/add_slot
firehose: Add slot flag
2 parents bd656a5 + a3ec7fd commit a88edc5

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

firehose.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ static int firehose_erase(struct qdl_device *qdl, struct program *program)
417417
xml_setpropf(node, "num_partition_sectors", "%d", program->num_sectors);
418418
xml_setpropf(node, "physical_partition_number", "%d", program->partition);
419419
xml_setpropf(node, "start_sector", "%s", program->start_sector);
420+
if (qdl->slot != UINT_MAX) {
421+
xml_setpropf(node, "slot", "%u", qdl->slot);
422+
}
420423
if (program->is_nand) {
421424
xml_setpropf(node, "PAGES_PER_BLOCK", "%d", program->pages_per_block);
422425
}
@@ -496,6 +499,9 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int
496499
xml_setpropf(node, "num_partition_sectors", "%d", num_sectors);
497500
xml_setpropf(node, "physical_partition_number", "%d", program->partition);
498501
xml_setpropf(node, "start_sector", "%s", program->start_sector);
502+
if (qdl->slot != UINT_MAX) {
503+
xml_setpropf(node, "slot", "%u", qdl->slot);
504+
}
499505
if (program->filename)
500506
xml_setpropf(node, "filename", "%s", program->filename);
501507

@@ -653,6 +659,9 @@ static int firehose_issue_read(struct qdl_device *qdl, struct read_op *read_op,
653659
xml_setpropf(node, "num_partition_sectors", "%d", read_op->num_sectors);
654660
xml_setpropf(node, "physical_partition_number", "%d", read_op->partition);
655661
xml_setpropf(node, "start_sector", "%s", read_op->start_sector);
662+
if (qdl->slot != UINT_MAX) {
663+
xml_setpropf(node, "slot", "%u", qdl->slot);
664+
}
656665
if (read_op->filename)
657666
xml_setpropf(node, "filename", "%s", read_op->filename);
658667

@@ -771,6 +780,9 @@ static int firehose_apply_patch(struct qdl_device *qdl, struct patch *patch)
771780
xml_setpropf(node, "size_in_bytes", "%d", patch->size_in_bytes);
772781
xml_setpropf(node, "start_sector", "%s", patch->start_sector);
773782
xml_setpropf(node, "value", "%s", patch->value);
783+
if (qdl->slot != UINT_MAX) {
784+
xml_setpropf(node, "slot", "%u", qdl->slot);
785+
}
774786

775787
ret = firehose_write(qdl, doc);
776788
if (ret < 0)
@@ -827,6 +839,9 @@ int firehose_apply_ufs_common(struct qdl_device *qdl, struct ufs_common *ufs)
827839
xml_setpropf(node_to_send, "bInitActiveICCLevel", "%d", ufs->bInitActiveICCLevel);
828840
xml_setpropf(node_to_send, "wPeriodicRTCUpdate", "%d", ufs->wPeriodicRTCUpdate);
829841
xml_setpropf(node_to_send, "bConfigDescrLock", "%d", ufs->bConfigDescrLock);
842+
if (qdl->slot != UINT_MAX) {
843+
xml_setpropf(node_to_send, "slot", "%u", qdl->slot);
844+
}
830845

831846
if (ufs->wb) {
832847
xml_setpropf(node_to_send, "bWriteBoosterBufferPreserveUserSpaceEn",
@@ -859,6 +874,9 @@ int firehose_apply_ufs_body(struct qdl_device *qdl, struct ufs_body *ufs)
859874
xml_setpropf(node_to_send, "bLogicalBlockSize", "%d", ufs->bLogicalBlockSize);
860875
xml_setpropf(node_to_send, "bProvisioningType", "%d", ufs->bProvisioningType);
861876
xml_setpropf(node_to_send, "wContextCapabilities", "%d", ufs->wContextCapabilities);
877+
if (qdl->slot != UINT_MAX) {
878+
xml_setpropf(node_to_send, "slot", "%u", qdl->slot);
879+
}
862880
if (ufs->desc)
863881
xml_setpropf(node_to_send, "desc", "%s", ufs->desc);
864882

@@ -879,6 +897,9 @@ int firehose_apply_ufs_epilogue(struct qdl_device *qdl, struct ufs_epilogue *ufs
879897

880898
xml_setpropf(node_to_send, "LUNtoGrow", "%d", ufs->LUNtoGrow);
881899
xml_setpropf(node_to_send, "commit", "%d", commit);
900+
if (qdl->slot != UINT_MAX) {
901+
xml_setpropf(node_to_send, "slot", "%u", qdl->slot);
902+
}
882903

883904
ret = firehose_send_single_tag(qdl, node_to_send);
884905
if (ret)

qdl.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ static void print_usage(FILE *out)
431431
fprintf(out, " -S, --serial=T\t\t\tSelect target by serial number T (e.g. <0AA94EFD>)\n");
432432
fprintf(out, " -u, --out-chunk-size=T\t\tOverride chunk size for transaction with T\n");
433433
fprintf(out, " -t, --create-digests=T\t\tGenerate table of digests in the T folder\n");
434+
fprintf(out, " -T, --slot=T\t\t\tSet slot number T for multiple storage devices\n");
434435
fprintf(out, " -D, --vip-table-path=T\t\tUse digest tables in the T folder for VIP\n");
435436
fprintf(out, " -h, --help\t\t\tPrint this usage info\n");
436437
fprintf(out, " <program-xml>\txml file containing <program> or <erase> directives\n");
@@ -459,6 +460,7 @@ int main(int argc, char **argv)
459460
bool allow_fusing = false;
460461
bool allow_missing = false;
461462
long out_chunk_size = 0;
463+
unsigned int slot = UINT_MAX;
462464
struct qdl_device *qdl = NULL;
463465
enum QDL_DEVICE_TYPE qdl_dev_type = QDL_DEVICE_USB;
464466

@@ -475,11 +477,12 @@ int main(int argc, char **argv)
475477
{"allow-fusing", no_argument, 0, 'c'},
476478
{"dry-run", no_argument, 0, 'n'},
477479
{"create-digests", required_argument, 0, 't'},
480+
{"slot", required_argument, 0, 'T'},
478481
{"help", no_argument, 0, 'h'},
479482
{0, 0, 0, 0}
480483
};
481484

482-
while ((opt = getopt_long(argc, argv, "dvi:lu:S:D:s:fcnt:h", options, NULL)) != -1) {
485+
while ((opt = getopt_long(argc, argv, "dvi:lu:S:D:s:fcnt:T:h", options, NULL)) != -1) {
483486
switch (opt) {
484487
case 'd':
485488
qdl_debug = true;
@@ -519,6 +522,9 @@ int main(int argc, char **argv)
519522
case 'D':
520523
vip_table_path = optarg;
521524
break;
525+
case 'T':
526+
slot = (unsigned int)strtoul(optarg, NULL, 10);
527+
break;
522528
case 'h':
523529
print_usage(stdout);
524530
return 0;
@@ -540,6 +546,8 @@ int main(int argc, char **argv)
540546
goto out_cleanup;
541547
}
542548

549+
qdl->slot = slot;
550+
543551
if (vip_table_path) {
544552
if (vip_generate_dir)
545553
errx(1, "VIP mode and VIP table generation can't be enabled together\n");

qdl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct qdl_device {
5656
size_t max_payload_size;
5757
size_t sector_size;
5858
enum qdl_storage_type storage_type;
59+
unsigned int slot;
5960

6061
int (*open)(struct qdl_device *qdl, const char *serial);
6162
int (*read)(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout);

0 commit comments

Comments
 (0)