panther_nvm_peek.c 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * void panther_nvm_peek (void const * memory);
  11. *
  12. * print a memory resident firmware image header on stdout;
  13. *
  14. * Contributor(s):
  15. * Charles Maier <cmaier@qca.qualcomm.com>
  16. *
  17. *--------------------------------------------------------------------*/
  18. #ifndef PANTHER_NVM_PEEK_SOURCE
  19. #define PANTHER_NVM_PEEK_SOURCE
  20. #include <stdio.h>
  21. #include "../tools/memory.h"
  22. #include "../tools/format.h"
  23. #include "../nvm/nvm.h"
  24. void panther_nvm_peek (void const * memory)
  25. {
  26. extern char const * nvm_imagetypes [];
  27. extern char const * nvm_platforms [];
  28. struct panther_nvm_header * header = (struct panther_nvm_header *) (memory);
  29. char const * string = "Unknown";
  30. char platform [100];
  31. printf ("\tHeader Version = 0x%04x-0x%04x\n", LE16TOH (header->MajorVersion), header->MinorVersion);
  32. printf ("\tHeader Checksum = 0x%08X\n", LE32TOH (header->HeaderChecksum));
  33. printf ("\tHeader Next = 0x%08X\n", LE32TOH (header->NextHeader));
  34. printf ("\tHeader Prev = 0x%08X\n", LE32TOH (header->PrevHeader));
  35. printf ("\tFlash Address = 0x%08X\n", LE32TOH (header->ImageNvmAddress));
  36. printf ("\tImage Address = 0x%08X\n", LE32TOH (header->ImageAddress));
  37. printf ("\tEntry Address = 0x%08X\n", LE32TOH (header->EntryPoint));
  38. printf ("\tEntry Version = 0x%04X\n", LE16TOH (header->AppletEntryVersion));
  39. printf ("\tImage Checksum = 0x%08X\n", LE32TOH (header->ImageChecksum));
  40. printf ("\tImage ModuleID = 0x%04X\n", LE32TOH (header->ModuleID));
  41. printf ("\tImage ModuleSubID = 0x%04X\n", LE32TOH (header->ModuleSubID));
  42. printf ("\tImage Size = 0x%08X (%d)\n", LE32TOH (header->ImageLength), LE32TOH (header->ImageLength));
  43. if (LE32TOH (header->ImageType) < NVM_IMAGETYPES)
  44. {
  45. string = nvm_imagetypes [LE32TOH (header->ImageType)];
  46. }
  47. printf ("\tImage Type = %s\n", string);
  48. strfbits (platform, sizeof (platform), nvm_platforms, "|", LE16TOH (header->ExecuteMask));
  49. printf ("\tImage Exec = %s\n", platform);
  50. #if 0
  51. printf ("\tReserved = 0x%04X\n", LE16TOH (header->Reserved0));
  52. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved1));
  53. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved2));
  54. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved3));
  55. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved4));
  56. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved5));
  57. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved6));
  58. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved7));
  59. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved8));
  60. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved9));
  61. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved10));
  62. printf ("\tReserved = 0x%08X\n", LE32TOH (header->Reserved11));
  63. #endif
  64. return;
  65. }
  66. #endif