File hfwget.c changed (mode: 100644) (index b00e747..184aeb0) |
... |
... |
static char* find_fw_filename(const u8 *hostdriver, size_t flen, char hexchar) |
374 |
374 |
|
|
375 |
375 |
if (p != NULL) |
if (p != NULL) |
376 |
376 |
{ |
{ |
377 |
|
printf("Found firmware %s at file offset 0x%08x\n", |
|
|
377 |
|
printf("Found firmware %s at file offset 0x%08tx\n", |
378 |
378 |
p, (p - hostdriver)); |
p, (p - hostdriver)); |
379 |
379 |
} |
} |
380 |
380 |
else |
else |
|
... |
... |
static u8* find_fw(const u8 *hostdriver, size_t flen, |
396 |
396 |
bool found = false; |
bool found = false; |
397 |
397 |
size_t i; |
size_t i; |
398 |
398 |
|
|
399 |
|
printf("Searching for firmware from offset 0x%08x, start signature", |
|
|
399 |
|
printf("Searching for firmware from offset 0x%08tx, start signature", |
400 |
400 |
hint - hostdriver); |
hint - hostdriver); |
401 |
401 |
for (i = 0; i < slen; i++) |
for (i = 0; i < slen; i++) |
402 |
402 |
{ |
{ |
|
... |
... |
static u8* find_fw(const u8 *hostdriver, size_t flen, |
416 |
416 |
} |
} |
417 |
417 |
|
|
418 |
418 |
p++; |
p++; |
419 |
|
printf("Found signature at file offset 0x%08x\n", p - hostdriver); |
|
|
419 |
|
printf("Found signature at file offset 0x%08tx\n", p - hostdriver); |
420 |
420 |
|
|
421 |
421 |
return (u8*) p; |
return (u8*) p; |
422 |
422 |
} |
} |
|
... |
... |
static int macho_validate(const void *data) |
581 |
581 |
static u8* find_fwblock_entry(const u8 *data, const struct fw_layout *layout, |
static u8* find_fwblock_entry(const u8 *data, const struct fw_layout *layout, |
582 |
582 |
u32 addr) |
u32 addr) |
583 |
583 |
{ |
{ |
584 |
|
u32 *p = (u32*) ((unsigned int)(data + layout->max_offset) & 0xFFFFFFFCu); |
|
|
584 |
|
u32 *p = (u32*) (data + (layout->max_offset & 0xFFFFFFFCu)); |
585 |
585 |
bool found = false; |
bool found = false; |
586 |
586 |
|
|
587 |
587 |
printf("Now searching for driver's firmware block entry (0x%08x)...\n", |
printf("Now searching for driver's firmware block entry (0x%08x)...\n", |
|
... |
... |
static struct fwtable_drv* find_fwtable_entry(const u8 *data, |
613 |
613 |
const struct fw_layout *layout, |
const struct fw_layout *layout, |
614 |
614 |
u32 fwblock) |
u32 fwblock) |
615 |
615 |
{ |
{ |
616 |
|
u32 *p = (u32*) ((unsigned int)(data + layout->max_offset) & 0xFFFFFFFCu); |
|
|
616 |
|
u32 *p = (u32*) (data + (layout->max_offset & 0xFFFFFFFCu)); |
617 |
617 |
struct fwtable_drv *firmware; |
struct fwtable_drv *firmware; |
618 |
618 |
bool found = false; |
bool found = false; |
619 |
619 |
|
|
|
... |
... |
static struct fwtable_drv* find_fwtable_entry(const u8 *data, |
638 |
638 |
} |
} |
639 |
639 |
else |
else |
640 |
640 |
{ |
{ |
641 |
|
printf("Found at file offset 0x%08x\n", (u8*)p - data); |
|
|
641 |
|
printf("Found at file offset 0x%08tx\n", (u8*)p - data); |
642 |
642 |
} |
} |
643 |
643 |
return firmware; |
return firmware; |
644 |
644 |
} |
} |
|
... |
... |
static void copy_fw_data(struct fwtable *firmware, |
667 |
667 |
static struct plugarray pri_plug_data[64] = {{ 0, 0, 0 }}; |
static struct plugarray pri_plug_data[64] = {{ 0, 0, 0 }}; |
668 |
668 |
static struct ident_info ident_data = { 0, 0, 0, 0, 0, 0 }; |
static struct ident_info ident_data = { 0, 0, 0, 0, 0, 0 }; |
669 |
669 |
static struct compat_info compat_data[16] = {{ 0 }}; |
static struct compat_info compat_data[16] = {{ 0 }}; |
670 |
|
u32 delta = (u32)data - layout->addr_delta; |
|
|
670 |
|
size_t delta = (size_t)data - layout->addr_delta; |
671 |
671 |
size_t i; |
size_t i; |
672 |
672 |
|
|
673 |
673 |
/* Calculate valid pointers to driver data */ |
/* Calculate valid pointers to driver data */ |
|
... |
... |
static void copy_fw_data(struct fwtable *firmware, |
709 |
709 |
firmware->segarray[i].offset = offset; |
firmware->segarray[i].offset = offset; |
710 |
710 |
firmware->segarray[i].size = size; |
firmware->segarray[i].size = size; |
711 |
711 |
firmware->segarray[i].flags = flags; |
firmware->segarray[i].flags = flags; |
712 |
|
printf("Segment: %d File offs: 0x%08x Target mem: 0x%08x " |
|
|
712 |
|
printf("Segment: %zd File offs: 0x%08tx Target mem: 0x%08x " |
713 |
713 |
"Length 0x%04x%s\n", |
"Length 0x%04x%s\n", |
714 |
714 |
i, |
i, |
715 |
715 |
(void *)(&block.w[i]) - data, |
(void *)(&block.w[i]) - data, |
|
... |
... |
static void copy_fw_data(struct fwtable *firmware, |
727 |
727 |
} |
} |
728 |
728 |
} |
} |
729 |
729 |
|
|
730 |
|
printf("Production Data plugrecords at file offset 0x%08x\n", |
|
|
730 |
|
printf("Production Data plugrecords at file offset 0x%08tx\n", |
731 |
731 |
(void *)pdr - data); |
(void *)pdr - data); |
732 |
|
printf("Primary plugrecords at file offset 0x%08x\n", |
|
|
732 |
|
printf("Primary plugrecords at file offset 0x%08tx\n", |
733 |
733 |
(void *)pri - data); |
(void *)pri - data); |
734 |
|
printf("Compatibility info at file offset 0x%08x\n", |
|
|
734 |
|
printf("Compatibility info at file offset 0x%08tx\n", |
735 |
735 |
(void *)compat - data); |
(void *)compat - data); |
736 |
|
printf("Identity info at file offset 0x%08x\n", |
|
|
736 |
|
printf("Identity info at file offset 0x%08tx\n", |
737 |
737 |
(void *)ident - data); |
(void *)ident - data); |
738 |
738 |
|
|
739 |
739 |
/* Copy plugarray */ |
/* Copy plugarray */ |
|
... |
... |
static void print_fw_ident(const struct fwtable *firmware) |
805 |
805 |
} |
} |
806 |
806 |
} |
} |
807 |
807 |
|
|
|
808 |
|
#if 0 |
808 |
809 |
static int write_hermesap_fw(FILE *output, const struct fwtable *firmware) |
static int write_hermesap_fw(FILE *output, const struct fwtable *firmware) |
809 |
810 |
{ |
{ |
810 |
811 |
unsigned int i; |
unsigned int i; |
|
... |
... |
static int write_hermesap_fw(FILE *output, const struct fwtable *firmware) |
845 |
846 |
|
|
846 |
847 |
return 0; |
return 0; |
847 |
848 |
} |
} |
|
849 |
|
#endif |
848 |
850 |
|
|
849 |
851 |
static size_t count_blocks(const struct fwblock *first_block) |
static size_t count_blocks(const struct fwblock *first_block) |
850 |
852 |
{ |
{ |
|
... |
... |
static int dump_fw(const char *basename, char hexchar, |
1053 |
1055 |
else |
else |
1054 |
1056 |
{ |
{ |
1055 |
1057 |
printf("Found firmware block entry at virtual location 0x%08x, " |
printf("Found firmware block entry at virtual location 0x%08x, " |
1056 |
|
"file offset 0x%08x\n", vaddr, fwblock - data); |
|
|
1058 |
|
"file offset 0x%08tx\n", vaddr, fwblock - data); |
1057 |
1059 |
} |
} |
1058 |
1060 |
|
|
1059 |
1061 |
/* Got to the first fwblock. Static offset per arch */ |
/* Got to the first fwblock. Static offset per arch */ |
|
... |
... |
int main(int argc, char *argv[]) |
1208 |
1210 |
/* Get file length */ |
/* Get file length */ |
1209 |
1211 |
fseek(input, 0L, SEEK_END); |
fseek(input, 0L, SEEK_END); |
1210 |
1212 |
flen = ftell(input); |
flen = ftell(input); |
1211 |
|
printf("File %s length %u (0x%08x)\n", argv[1], flen, flen); |
|
|
1213 |
|
printf("File %s length %zu (0x%08zx)\n", argv[1], flen, flen); |
1212 |
1214 |
|
|
1213 |
1215 |
/* Rewind file pointer */ |
/* Rewind file pointer */ |
1214 |
1216 |
fseek(input, 0L, SEEK_SET); |
fseek(input, 0L, SEEK_SET); |
|
... |
... |
int main(int argc, char *argv[]) |
1235 |
1237 |
} |
} |
1236 |
1238 |
else |
else |
1237 |
1239 |
{ |
{ |
1238 |
|
printf("Only read %d out of %d bytes\n", read_bytes, flen); |
|
|
1240 |
|
printf("Only read %zd out of %zd bytes\n", read_bytes, flen); |
1239 |
1241 |
} |
} |
1240 |
1242 |
|
|
1241 |
1243 |
free(data); |
free(data); |