zynos.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. *
  3. * Copyright (C) 2007-2008 OpenWrt.org
  4. * Copyright (C) 2007-2008 Gabor Juhos <juhosg at openwrt.org>
  5. *
  6. * This code was based on the information of the ZyXEL's firmware
  7. * image format written by Kolja Waschk, can be found at:
  8. * http://www.ixo.de/info/zyxel_uclinux
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published
  12. * by the Free Software Foundation.
  13. *
  14. */
  15. #ifndef _ZYNOS_H
  16. #define _ZYNOS_H
  17. #define BOOTBASE_NAME_LEN 32
  18. #define BOOTBASE_MAC_LEN 6
  19. #define BOOTBASE_FEAT_LEN 22
  20. #define BOOTEXT_DEF_SIZE 0x18000
  21. struct zyn_bootbase_info {
  22. char vendor[BOOTBASE_NAME_LEN]; /* Vendor name */
  23. char model[BOOTBASE_NAME_LEN]; /* Model name */
  24. uint32_t bootext_addr; /* absolute address of the Boot Extension */
  25. uint16_t res0; /* reserved/unknown */
  26. uint8_t sys_type; /* system type */
  27. uint8_t res1; /* reserved/unknown */
  28. uint16_t model_id; /* model id */
  29. uint8_t feat_other[BOOTBASE_FEAT_LEN]; /* other feature bits */
  30. uint8_t feat_main; /* main feature bits */
  31. uint8_t res2; /* reserved/unknown */
  32. uint8_t mac[BOOTBASE_MAC_LEN]; /* mac address */
  33. uint8_t country; /* default country code */
  34. uint8_t dbgflag; /* debug flag */
  35. } __attribute__((packed));
  36. #define ROMBIN_SIG_LEN 3
  37. #define ROMBIN_VER_LEN 15
  38. struct zyn_rombin_hdr {
  39. uint32_t addr; /* load address of the object */
  40. uint16_t res0; /* unknown/unused */
  41. char sig[ROMBIN_SIG_LEN]; /* magic, must be "SIG" */
  42. uint8_t type; /* type of the object */
  43. uint32_t osize; /* size of the uncompressed data */
  44. uint32_t csize; /* size of the compressed data */
  45. uint8_t flags; /* various flags */
  46. uint8_t res1; /* unknown/unused */
  47. uint16_t ocsum; /* csum of the uncompressed data */
  48. uint16_t ccsum; /* csum of the compressed data */
  49. char ver[ROMBIN_VER_LEN];
  50. uint32_t mmap_addr; /* address of the Memory Map Table*/
  51. uint32_t res2; /* unknown/unused*/
  52. uint8_t res3; /* unknown/unused*/
  53. } __attribute__((packed));
  54. #define ROMBIN_SIGNATURE "SIG"
  55. /* Rombin flag bits */
  56. #define ROMBIN_FLAG_01 0x01
  57. #define ROMBIN_FLAG_02 0x02
  58. #define ROMBIN_FLAG_04 0x04
  59. #define ROMBIN_FLAG_08 0x08
  60. #define ROMBIN_FLAG_10 0x10
  61. #define ROMBIN_FLAG_CCSUM 0x20 /* compressed checksum is valid */
  62. #define ROMBIN_FLAG_OCSUM 0x40 /* original checksum is valid */
  63. #define ROMBIN_FLAG_COMPRESSED 0x80 /* the binary is compressed */
  64. /* Object types */
  65. #define OBJECT_TYPE_ROMIMG 0x01
  66. #define OBJECT_TYPE_ROMBOOT 0x02
  67. #define OBJECT_TYPE_BOOTEXT 0x03
  68. #define OBJECT_TYPE_ROMBIN 0x04
  69. #define OBJECT_TYPE_ROMDIR 0x05
  70. #define OBJECT_TYPE_6 0x06
  71. #define OBJECT_TYPE_ROMMAP 0x07
  72. #define OBJECT_TYPE_RAM 0x80
  73. #define OBJECT_TYPE_RAMCODE 0x81
  74. #define OBJECT_TYPE_RAMBOOT 0x82
  75. /*
  76. * Memory Map Table header
  77. */
  78. struct zyn_mmt_hdr {
  79. uint16_t count;
  80. uint32_t user_start;
  81. uint32_t user_end;
  82. uint16_t csum;
  83. uint8_t res[12];
  84. } __attribute__((packed));
  85. #define OBJECT_NAME_LEN 8
  86. struct zyn_mmt_item {
  87. uint8_t type; /* type of the object */
  88. uint8_t name[OBJECT_NAME_LEN]; /* name of the object */
  89. uint8_t res0; /* unused/unknown */
  90. uint32_t addr;
  91. uint32_t size; /* size of the object */
  92. uint8_t res1[3]; /* unused/unknown */
  93. uint8_t type2;
  94. } __attribute__((packed));
  95. /*
  96. * Vendor IDs
  97. */
  98. #define ZYNOS_VENDOR_ID_ZYXEL 0
  99. #define ZYNOS_VENDOR_ID_NETGEAR 1
  100. #define ZYNOS_VENDOR_ID_DLINK 2
  101. #define ZYNOS_VENDOR_ID_03 3
  102. #define ZYNOS_VENDOR_ID_LUCENT 4
  103. #define ZYNOS_VENDOR_ID_O2 10
  104. /*
  105. * Model IDs (in big-endian format)
  106. */
  107. #define MID(x) (((x) & 0xFF) << 8) | (((x) & 0xFF00) >> 8)
  108. /*
  109. * Infineon/ADMtek ADM5120 based models
  110. */
  111. #define ZYNOS_MODEL_ES_2024A MID( 221)
  112. #define ZYNOS_MODEL_ES_2024PWR MID( 4097)
  113. #define ZYNOS_MODEL_ES_2108 MID(61952)
  114. #define ZYNOS_MODEL_ES_2108_F MID(44801)
  115. #define ZYNOS_MODEL_ES_2108_G MID(62208)
  116. #define ZYNOS_MODEL_ES_2108_LC MID(64512)
  117. #define ZYNOS_MODEL_ES_2108PWR MID(62464)
  118. #define ZYNOS_MODEL_HS_100 MID(61855)
  119. #define ZYNOS_MODEL_HS_100W ZYNOS_MODEL_HS_100
  120. #define ZYNOS_MODEL_P_334 MID(62879)
  121. #define ZYNOS_MODEL_P_334U MID(56735)
  122. #define ZYNOS_MODEL_P_334W MID(62367)
  123. #define ZYNOS_MODEL_P_334WH MID(57344)
  124. #define ZYNOS_MODEL_P_334WHD MID(57600)
  125. #define ZYNOS_MODEL_P_334WT MID(61343)
  126. #define ZYNOS_MODEL_P_335 MID(60831)
  127. #define ZYNOS_MODEL_P_335PLUS MID( 9472)
  128. #define ZYNOS_MODEL_P_335U MID(56479)
  129. #define ZYNOS_MODEL_P_335WT ZYNOS_MODEL_P_335
  130. /*
  131. * Texas Instruments AR7 based models
  132. */
  133. #define ZYNOS_MODEL_P_2602H_61C MID( 3229)
  134. #define ZYNOS_MODEL_P_2602H_63C MID( 3485)
  135. #define ZYNOS_MODEL_P_2602H_D1A /* n.a. */
  136. #define ZYNOS_MODEL_P_2602H_D3A /* n.a. */
  137. #define ZYNOS_MODEL_P_2602HW_61C /* n.a. */
  138. #define ZYNOS_MODEL_P_2602HW_63 /* n.a. */
  139. #define ZYNOS_MODEL_P_2602HW_63C ZYNOS_MODEL_P_2602H_63C
  140. #define ZYNOS_MODEL_P_2602HW_D1A MID( 6301)
  141. #define ZYNOS_MODEL_P_2602HW_D3A /* n.a. */
  142. #define ZYNOS_MODEL_P_2602HWL_61 MID( 1181)
  143. #define ZYNOS_MODEL_P_2602HWL_61C ZYNOS_MODEL_P_2602H_61C
  144. #define ZYNOS_MODEL_P_2602HWL_63C ZYNOS_MODEL_P_2602H_63C
  145. #define ZYNOS_MODEL_P_2602HWL_D1A ZYNOS_MODEL_P_2602HW_D1A
  146. #define ZYNOS_MODEL_P_2602HWL_D3A MID( 7581)
  147. #define ZYNOS_MODEL_P_2602HWN_D7A MID(30464)
  148. #define ZYNOS_MODEL_P_2602HWNLI_D7A MID( 6813)
  149. #define ZYNOS_MODEL_P_2602R_61 MID( 2205)
  150. #define ZYNOS_MODEL_P_2602R_63 MID( 3997)
  151. #define ZYNOS_MODEL_P_2602R_D1A /* n.a. */
  152. #define ZYNOS_MODEL_P_2602R_D3A /* n.a. */
  153. #define ZYNOS_MODEL_P_2602RL_D1A MID( 6045)
  154. #define ZYNOS_MODEL_P_2602RL_D3A MID( 7069)
  155. #define ZYNOS_MODEL_P_660H_61 MID(19346)
  156. #define ZYNOS_MODEL_P_660H_63 MID(22162)
  157. #define ZYNOS_MODEL_P_660H_67 /* n.a. */
  158. #define ZYNOS_MODEL_P_660H_D1 MID( 7066)
  159. #define ZYNOS_MODEL_P_660H_D3 MID(13210)
  160. #define ZYNOS_MODEL_P_660HW_61 ZYNOS_MODEL_P_660H_61
  161. #define ZYNOS_MODEL_P_660HW_63 ZYNOS_MODEL_P_660H_63
  162. #define ZYNOS_MODEL_P_660HW_67 ZYNOS_MODEL_P_660HW_63
  163. #define ZYNOS_MODEL_P_660HW_D1 MID( 9114)
  164. #define ZYNOS_MODEL_P_660HW_D3 MID(12698)
  165. #define ZYNOS_MODEL_P_660R_61 MID(20882)
  166. #define ZYNOS_MODEL_P_660R_61C MID( 1178)
  167. #define ZYNOS_MODEL_P_660R_63 MID(21138)
  168. #define ZYNOS_MODEL_P_660R_63C MID( 922)
  169. #define ZYNOS_MODEL_P_660R_67 ZYNOS_MODEL_P_660R_63
  170. #define ZYNOS_MODEL_P_660R_67C /* n.a. */
  171. #define ZYNOS_MODEL_P_660R_D1 MID( 7322)
  172. #define ZYNOS_MODEL_P_660R_D3 MID(10138)
  173. #define ZYNOS_MODEL_P_661H_61 MID(19346)
  174. #define ZYNOS_MODEL_P_661H_63 MID( 1946)
  175. #define ZYNOS_MODEL_P_661H_D1 MID(10650)
  176. #define ZYNOS_MODEL_P_661H_D3 MID(12442)
  177. #define ZYNOS_MODEL_P_661HW_61 ZYNOS_MODEL_P_661H_61
  178. #define ZYNOS_MODEL_P_661HW_63 ZYNOS_MODEL_P_661H_63
  179. #define ZYNOS_MODEL_P_661HW_D1 MID(10906)
  180. #define ZYNOS_MODEL_P_661HW_D3 MID(14746)
  181. #define ZYNOS_MODEL_P_662H_61 MID(22418)
  182. #define ZYNOS_MODEL_P_662H_63 /* n.a. */
  183. #define ZYNOS_MODEL_P_662H_67 /* n.a. */
  184. #define ZYNOS_MODEL_P_662H_D1 /* n.a. */
  185. #define ZYNOS_MODEL_P_662H_D3 /* n.a. */
  186. #define ZYNOS_MODEL_P_662HW_61 /* n.a. */
  187. #define ZYNOS_MODEL_P_662HW_63 MID(22674)
  188. #define ZYNOS_MODEL_P_662HW_67 /* n.a. */
  189. #define ZYNOS_MODEL_P_662HW_D1 MID(10394)
  190. #define ZYNOS_MODEL_P_662HW_D3 MID(12954)
  191. /* OEM boards */
  192. #define ZYNOS_MODEL_O2SURF ZYNOS_MODEL_P_2602HWN_D7A
  193. /* Atheros AR2318 based boards */
  194. #define ZYNOS_MODEL_NBG_318S MID(59392)
  195. /* Atheros AR71xx based boards */
  196. #define ZYNOS_MODEL_NBG_460N MID(61441)
  197. #endif /* _ZYNOS_H */