FreeCalypso > hg > freecalypso-reveng
view miscprog/pirbattextr.c @ 265:d15f701b1434
dsample-fw-disasm: beginning to locate tpudrv10 code
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 18 Jan 2018 08:03:03 +0000 |
parents | 30804198d5d0 |
children |
line wrap: on
line source
/* * This program extracts the a_pwr_thresholds[] table from one of Pirelli's * fw images and converts the numbers to decimal. */ #include <sys/types.h> #include <sys/file.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> struct entry { u_char mvolt[2]; u_char percent; u_char pad; }; struct entry array[21]; read_array_from_image(filename, offset_arg) char *filename, *offset_arg; { int fd; fd = open(filename, O_RDONLY); if (fd < 0) { perror(filename); exit(1); } lseek(fd, strtoul(offset_arg, 0, 0), 0); read(fd, array, sizeof array); close(fd); } dump_array() { int i; unsigned mvolt; for (i = 0; i < 21; i++) { mvolt = array[i].mvolt[0] | (array[i].mvolt[1] << 8); printf("%4u\t%u\n", mvolt, array[i].percent); } } main(argc, argv) char **argv; { if (argc != 3) { fprintf(stderr, "usage: %s fw-image offset\n", argv[0]); exit(1); } read_array_from_image(argv[1], argv[2]); dump_array(); exit(0); }