flashmap.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. * system header files;
  10. *--------------------------------------------------------------------*/
  11. #include <stdio.h>
  12. #include <unistd.h>
  13. /*====================================================================*
  14. * custom header files;
  15. *--------------------------------------------------------------------*/
  16. #include "../tools/getoptv.h"
  17. #include "../tools/putoptv.h"
  18. #include "../tools/version.h"
  19. #include "../tools/error.h"
  20. #include "../tools/endian.h"
  21. /*====================================================================*
  22. * custom source files;
  23. *--------------------------------------------------------------------*/
  24. #ifndef MAKEFILE
  25. #include "../tools/getoptv.c"
  26. #include "../tools/putoptv.c"
  27. #include "../tools/version.c"
  28. #include "../tools/error.c"
  29. #endif
  30. /*====================================================================*
  31. * program variables;
  32. *--------------------------------------------------------------------*/
  33. typedef struct queue
  34. {
  35. struct queue * prev;
  36. struct queue * next;
  37. byte * frame;
  38. }
  39. QUEUE;
  40. /*====================================================================*
  41. *
  42. * void function (void);
  43. *
  44. *--------------------------------------------------------------------*/
  45. void function (void)
  46. {
  47. uint32_t byte = 0;
  48. uint32_t word;
  49. while (read (STDIN_FILENO, & word, sizeof (word)) == sizeof (word))
  50. {
  51. if (word == 0x00010001)
  52. {
  53. printf ("%08X ", byte);
  54. while (read (STDIN_FILENO, & word, sizeof (word)) == sizeof (word))
  55. {
  56. if (word == 0xFFFFFFFF)
  57. {
  58. printf ("%08X\n", byte);
  59. break;
  60. }
  61. byte += sizeof (word);
  62. }
  63. }
  64. byte += sizeof (word);
  65. }
  66. return;
  67. }
  68. /*====================================================================*
  69. *
  70. * int main (int argc, char const * argv []);
  71. *
  72. *--------------------------------------------------------------------*/
  73. int main (int argc, char const * argv [])
  74. {
  75. static char const * optv [] =
  76. {
  77. "",
  78. "",
  79. "Template Program",
  80. (char const *) (0)
  81. };
  82. signed c;
  83. while (~ (c = getoptv (argc, argv, optv)))
  84. {
  85. switch (c)
  86. {
  87. default:
  88. break;
  89. }
  90. }
  91. argc -= optind;
  92. argv += optind;
  93. if (! argc)
  94. {
  95. function ();
  96. }
  97. while ((argc) && (* argv))
  98. {
  99. function ();
  100. argc--;
  101. argv++;
  102. }
  103. exit (0);
  104. }