1
0

myloader.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (C) 2006-2008 Gabor Juhos <juhosg@openwrt.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. */
  10. #ifndef _MYLOADER_H_
  11. #define _MYLOADER_H_
  12. /*
  13. * Firmware file format:
  14. *
  15. * <header>
  16. * [<block descriptor 0>]
  17. * ...
  18. * [<block descriptor n>]
  19. * <null block descriptor>
  20. * [<block data 0>]
  21. * ...
  22. * [<block data n>]
  23. *
  24. *
  25. */
  26. /* Myloader specific magic numbers */
  27. #define MYLO_MAGIC_FIRMWARE 0x4C594D00
  28. #define MYLO_MAGIC_20021103 0x20021103
  29. #define MYLO_MAGIC_20021107 0x20021107
  30. #define MYLO_MAGIC_SYS_PARAMS MYLO_MAGIC_20021107
  31. #define MYLO_MAGIC_PARTITIONS MYLO_MAGIC_20021103
  32. #define MYLO_MAGIC_BOARD_PARAMS MYLO_MAGIC_20021103
  33. /*
  34. * Addresses of the data structures provided by MyLoader
  35. */
  36. #define MYLO_MIPS_SYS_PARAMS 0x80000800 /* System Parameters */
  37. #define MYLO_MIPS_BOARD_PARAMS 0x80000A00 /* Board Parameters */
  38. #define MYLO_MIPS_PARTITIONS 0x80000C00 /* Partition Table */
  39. #define MYLO_MIPS_BOOT_PARAMS 0x80000E00 /* Boot Parameters */
  40. /* Vendor ID's (seems to be same as the PCI vendor ID's) */
  41. #define VENID_COMPEX 0x11F6
  42. /* Devices based on the ADM5120 */
  43. #define DEVID_COMPEX_NP27G 0x0078
  44. #define DEVID_COMPEX_NP28G 0x044C
  45. #define DEVID_COMPEX_NP28GHS 0x044E
  46. #define DEVID_COMPEX_WP54Gv1C 0x0514
  47. #define DEVID_COMPEX_WP54G 0x0515
  48. #define DEVID_COMPEX_WP54AG 0x0546
  49. #define DEVID_COMPEX_WPP54AG 0x0550
  50. #define DEVID_COMPEX_WPP54G 0x0555
  51. /* Devices based on the Atheros AR2317 */
  52. #define DEVID_COMPEX_NP25G 0x05e6
  53. #define DEVID_COMPEX_WPE53G 0x05dc
  54. /* Devices based on the Atheros AR71xx */
  55. #define DEVID_COMPEX_WP543 0x0640
  56. #define DEVID_COMPEX_WPE72 0x0672
  57. /* Devices based on the IXP422 */
  58. #define DEVID_COMPEX_WP18 0x047E
  59. #define DEVID_COMPEX_NP18A 0x0489
  60. /* Other devices */
  61. #define DEVID_COMPEX_NP26G8M 0x03E8
  62. #define DEVID_COMPEX_NP26G16M 0x03E9
  63. struct mylo_fw_header {
  64. uint32_t magic; /* must be MYLO_MAGIC_FIRMWARE */
  65. uint32_t crc; /* CRC of the whole firmware */
  66. uint32_t res0; /* unknown/unused */
  67. uint32_t res1; /* unknown/unused */
  68. uint16_t vid; /* vendor ID */
  69. uint16_t did; /* device ID */
  70. uint16_t svid; /* sub vendor ID */
  71. uint16_t sdid; /* sub device ID */
  72. uint32_t rev; /* device revision */
  73. uint32_t fwhi; /* FIXME: firmware version high? */
  74. uint32_t fwlo; /* FIXME: firmware version low? */
  75. uint32_t flags; /* firmware flags */
  76. };
  77. #define FW_FLAG_BOARD_PARAMS_WP 0x01 /* board parameters are write protected */
  78. #define FW_FLAG_BOOT_SECTOR_WE 0x02 /* enable of write boot sectors (below 64K) */
  79. struct mylo_fw_blockdesc {
  80. uint32_t type; /* block type */
  81. uint32_t addr; /* relative address to flash start */
  82. uint32_t dlen; /* size of block data in bytes */
  83. uint32_t blen; /* total size of block in bytes */
  84. };
  85. #define FW_DESC_TYPE_UNUSED 0
  86. #define FW_DESC_TYPE_USED 1
  87. struct mylo_partition {
  88. uint16_t flags; /* partition flags */
  89. uint16_t type; /* type of the partition */
  90. uint32_t addr; /* relative address of the partition from the
  91. flash start */
  92. uint32_t size; /* size of the partition in bytes */
  93. uint32_t param; /* if this is the active partition, the
  94. MyLoader load code to this address */
  95. };
  96. #define PARTITION_FLAG_ACTIVE 0x8000 /* this is the active partition,
  97. * MyLoader loads firmware from here */
  98. #define PARTITION_FLAG_ISRAM 0x2000 /* FIXME: this is a RAM partition? */
  99. #define PARTIIION_FLAG_RAMLOAD 0x1000 /* FIXME: load this partition into the RAM? */
  100. #define PARTITION_FLAG_PRELOAD 0x0800 /* the partition data preloaded to RAM
  101. * before decompression */
  102. #define PARTITION_FLAG_LZMA 0x0100 /* the partition data compressed with LZMA */
  103. #define PARTITION_FLAG_HAVEHDR 0x0002 /* the partition data have a header */
  104. #define PARTITION_TYPE_FREE 0
  105. #define PARTITION_TYPE_USED 1
  106. #define MYLO_MAX_PARTITIONS 8 /* maximum number of partitions in the
  107. partition table */
  108. struct mylo_partition_table {
  109. uint32_t magic; /* must be MYLO_MAGIC_PARTITIONS */
  110. uint32_t res0; /* unknown/unused */
  111. uint32_t res1; /* unknown/unused */
  112. uint32_t res2; /* unknown/unused */
  113. struct mylo_partition partitions[MYLO_MAX_PARTITIONS];
  114. };
  115. struct mylo_partition_header {
  116. uint32_t len; /* length of the partition data */
  117. uint32_t crc; /* CRC value of the partition data */
  118. };
  119. struct mylo_system_params {
  120. uint32_t magic; /* must be MYLO_MAGIC_SYS_PARAMS */
  121. uint32_t res0;
  122. uint32_t res1;
  123. uint32_t mylo_ver;
  124. uint16_t vid; /* Vendor ID */
  125. uint16_t did; /* Device ID */
  126. uint16_t svid; /* Sub Vendor ID */
  127. uint16_t sdid; /* Sub Device ID */
  128. uint32_t rev; /* device revision */
  129. uint32_t fwhi;
  130. uint32_t fwlo;
  131. uint32_t tftp_addr;
  132. uint32_t prog_start;
  133. uint32_t flash_size; /* Size of boot FLASH in bytes */
  134. uint32_t dram_size; /* Size of onboard RAM in bytes */
  135. };
  136. struct mylo_eth_addr {
  137. uint8_t mac[6];
  138. uint8_t csum[2];
  139. };
  140. #define MYLO_ETHADDR_COUNT 8 /* maximum number of ethernet address
  141. in the board parameters */
  142. struct mylo_board_params {
  143. uint32_t magic; /* must be MYLO_MAGIC_BOARD_PARAMS */
  144. uint32_t res0;
  145. uint32_t res1;
  146. uint32_t res2;
  147. struct mylo_eth_addr addr[MYLO_ETHADDR_COUNT];
  148. };
  149. #endif /* _MYLOADER_H_*/