skvpd.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. /******************************************************************************
  2. *
  3. * Name: skvpd.h
  4. * Project: GEnesis, PCI Gigabit Ethernet Adapter
  5. * Version: $Revision: 1.15 $
  6. * Date: $Date: 2003/01/13 10:39:38 $
  7. * Purpose: Defines and Macros for VPD handling
  8. *
  9. ******************************************************************************/
  10. /******************************************************************************
  11. *
  12. * (C)Copyright 1998-2003 SysKonnect GmbH.
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * The information in this file is provided "AS IS" without warranty.
  20. *
  21. ******************************************************************************/
  22. /******************************************************************************
  23. *
  24. * History:
  25. *
  26. * $Log: skvpd.h,v $
  27. * Revision 1.15 2003/01/13 10:39:38 rschmidt
  28. * Replaced define for PCI device Id for YUKON with GENESIS
  29. * Editorial changes
  30. *
  31. * Revision 1.14 2002/11/14 15:18:10 gheinig
  32. * Added const specifier to key and buf parameters for VpdPara,VpdRead
  33. * and VpdWrite. This is necessary for the Diag 7 GUI API
  34. *
  35. * Revision 1.13 2002/10/14 15:58:18 rschmidt
  36. * Added entry in rom_size struct s_vpd
  37. * Editorial changes
  38. *
  39. * Revision 1.12 2002/09/09 14:43:51 mkarl
  40. * added PCI Id of Yukon for reading VPD in diag before the adapter has
  41. * been initialized
  42. * editorial changes
  43. *
  44. * Revision 1.11 2002/07/26 13:19:16 mkarl
  45. * added support for Yukon
  46. * added vpd_size to VPD struct
  47. *
  48. * Revision 1.10 2000/08/10 11:29:07 rassmann
  49. * Editorial changes.
  50. * Preserving 32-bit alignment in structs for the adapter context.
  51. * Removed unused function VpdWriteDword() (#if 0).
  52. * Made VpdReadKeyword() available for SKDIAG only.
  53. *
  54. * Revision 1.9 1999/11/22 14:02:27 cgoos
  55. * Changed license header to GPL.
  56. *
  57. * Revision 1.8 1999/03/11 14:26:40 malthoff
  58. * Replace __STDC__ with SK_KR_PROTO.
  59. *
  60. * Revision 1.7 1998/10/28 07:27:17 gklug
  61. * rmv: SWAP macros
  62. * add: VPD_IN/OUT8 macros
  63. * chg: interface definition
  64. *
  65. * Revision 1.6 1998/10/22 10:03:44 gklug
  66. * fix: use SK_OUT16 instead of SK_OUTW
  67. *
  68. * Revision 1.5 1998/10/14 07:05:31 cgoos
  69. * Changed constants in SK_SWAP_32 to UL.
  70. *
  71. * Revision 1.4 1998/08/19 08:14:09 gklug
  72. * fix: remove struct keyword as much as possible from the C-code (see CCC)
  73. *
  74. * Revision 1.3 1998/08/18 08:18:56 malthoff
  75. * Modify VPD in and out macros for SK_DIAG
  76. *
  77. * Revision 1.2 1998/07/03 14:49:08 malthoff
  78. * Add VPD_INxx() and VPD_OUTxx() macros for the Diagnostics tool.
  79. *
  80. * Revision 1.1 1998/06/19 14:08:03 malthoff
  81. * Created.
  82. *
  83. *
  84. ******************************************************************************/
  85. /*
  86. * skvpd.h contains Diagnostic specific defines for VPD handling
  87. */
  88. #ifndef __INC_SKVPD_H_
  89. #define __INC_SKVPD_H_
  90. /*
  91. * Define Resource Type Identifiers and VPD keywords
  92. */
  93. #define RES_ID 0x82 /* Resource Type ID String (Product Name) */
  94. #define RES_VPD_R 0x90 /* start of VPD read only area */
  95. #define RES_VPD_W 0x91 /* start of VPD read/write area */
  96. #define RES_END 0x78 /* Resource Type End Tag */
  97. #ifndef VPD_NAME
  98. #define VPD_NAME "Name" /* Product Name, VPD name of RES_ID */
  99. #endif /* VPD_NAME */
  100. #define VPD_PN "PN" /* Adapter Part Number */
  101. #define VPD_EC "EC" /* Adapter Engineering Level */
  102. #define VPD_MN "MN" /* Manufacture ID */
  103. #define VPD_SN "SN" /* Serial Number */
  104. #define VPD_CP "CP" /* Extended Capability */
  105. #define VPD_RV "RV" /* Checksum and Reserved */
  106. #define VPD_YA "YA" /* Asset Tag Identifier */
  107. #define VPD_VL "VL" /* First Error Log Message (SK specific) */
  108. #define VPD_VF "VF" /* Second Error Log Message (SK specific) */
  109. #define VPD_RW "RW" /* Remaining Read / Write Area */
  110. /* 'type' values for vpd_setup_para() */
  111. #define VPD_RO_KEY 1 /* RO keys are "PN", "EC", "MN", "SN", "RV" */
  112. #define VPD_RW_KEY 2 /* RW keys are "Yx", "Vx", and "RW" */
  113. /* 'op' values for vpd_setup_para() */
  114. #define ADD_KEY 1 /* add the key at the pos "RV" or "RW" */
  115. #define OWR_KEY 2 /* overwrite key if already exists */
  116. /*
  117. * Define READ and WRITE Constants.
  118. */
  119. #define VPD_DEV_ID_GENESIS 0x4300
  120. #define VPD_SIZE_YUKON 256
  121. #define VPD_SIZE_GENESIS 512
  122. #define VPD_SIZE 512
  123. #define VPD_READ 0x0000
  124. #define VPD_WRITE 0x8000
  125. #define VPD_STOP(pAC,IoC) VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)
  126. #define VPD_GET_RES_LEN(p) ((unsigned int) \
  127. (* (SK_U8 *)&(p)[1]) |\
  128. ((* (SK_U8 *)&(p)[2]) << 8))
  129. #define VPD_GET_VPD_LEN(p) ((unsigned int)(* (SK_U8 *)&(p)[2]))
  130. #define VPD_GET_VAL(p) ((char *)&(p)[3])
  131. #define VPD_MAX_LEN 50
  132. /* VPD status */
  133. /* bit 7..1 reserved */
  134. #define VPD_VALID (1<<0) /* VPD data buffer, vpd_free_ro, */
  135. /* and vpd_free_rw valid */
  136. /*
  137. * VPD structs
  138. */
  139. typedef struct s_vpd_status {
  140. unsigned short Align01; /* Alignment */
  141. unsigned short vpd_status; /* VPD status, description see above */
  142. int vpd_free_ro; /* unused bytes in read only area */
  143. int vpd_free_rw; /* bytes available in read/write area */
  144. } SK_VPD_STATUS;
  145. typedef struct s_vpd {
  146. SK_VPD_STATUS v; /* VPD status structure */
  147. char vpd_buf[VPD_SIZE]; /* VPD buffer */
  148. int rom_size; /* VPD ROM Size from PCI_OUR_REG_2 */
  149. int vpd_size; /* saved VPD-size */
  150. } SK_VPD;
  151. typedef struct s_vpd_para {
  152. unsigned int p_len; /* parameter length */
  153. char *p_val; /* points to the value */
  154. } SK_VPD_PARA;
  155. /*
  156. * structure of Large Resource Type Identifiers
  157. */
  158. /* was removed because of alignment problems */
  159. /*
  160. * structure of VPD keywords
  161. */
  162. typedef struct s_vpd_key {
  163. char p_key[2]; /* 2 bytes ID string */
  164. unsigned char p_len; /* 1 byte length */
  165. char p_val; /* start of the value string */
  166. } SK_VPD_KEY;
  167. /*
  168. * System specific VPD macros
  169. */
  170. #ifndef SKDIAG
  171. #ifndef VPD_DO_IO
  172. #define VPD_OUT8(pAC,IoC,Addr,Val) (void)SkPciWriteCfgByte(pAC,Addr,Val)
  173. #define VPD_OUT16(pAC,IoC,Addr,Val) (void)SkPciWriteCfgWord(pAC,Addr,Val)
  174. #define VPD_OUT32(pAC,IoC,Addr,Val) (void)SkPciWriteCfgDWord(pAC,Addr,Val)
  175. #define VPD_IN8(pAC,IoC,Addr,pVal) (void)SkPciReadCfgByte(pAC,Addr,pVal)
  176. #define VPD_IN16(pAC,IoC,Addr,pVal) (void)SkPciReadCfgWord(pAC,Addr,pVal)
  177. #define VPD_IN32(pAC,IoC,Addr,pVal) (void)SkPciReadCfgDWord(pAC,Addr,pVal)
  178. #else /* VPD_DO_IO */
  179. #define VPD_OUT8(pAC,IoC,Addr,Val) SK_OUT8(IoC,PCI_C(Addr),Val)
  180. #define VPD_OUT16(pAC,IoC,Addr,Val) SK_OUT16(IoC,PCI_C(Addr),Val)
  181. #define VPD_OUT32(pAC,IoC,Addr,Val) SK_OUT32(IoC,PCI_C(Addr),Val)
  182. #define VPD_IN8(pAC,IoC,Addr,pVal) SK_IN8(IoC,PCI_C(Addr),pVal)
  183. #define VPD_IN16(pAC,IoC,Addr,pVal) SK_IN16(IoC,PCI_C(Addr),pVal)
  184. #define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(Addr),pVal)
  185. #endif /* VPD_DO_IO */
  186. #else /* SKDIAG */
  187. #define VPD_OUT8(pAC,Ioc,Addr,Val) { \
  188. if ((pAC)->DgT.DgUseCfgCycle) \
  189. SkPciWriteCfgByte(pAC,Addr,Val); \
  190. else \
  191. SK_OUT8(pAC,PCI_C(Addr),Val); \
  192. }
  193. #define VPD_OUT16(pAC,Ioc,Addr,Val) { \
  194. if ((pAC)->DgT.DgUseCfgCycle) \
  195. SkPciWriteCfgWord(pAC,Addr,Val); \
  196. else \
  197. SK_OUT16(pAC,PCI_C(Addr),Val); \
  198. }
  199. #define VPD_OUT32(pAC,Ioc,Addr,Val) { \
  200. if ((pAC)->DgT.DgUseCfgCycle) \
  201. SkPciWriteCfgDWord(pAC,Addr,Val); \
  202. else \
  203. SK_OUT32(pAC,PCI_C(Addr),Val); \
  204. }
  205. #define VPD_IN8(pAC,Ioc,Addr,pVal) { \
  206. if ((pAC)->DgT.DgUseCfgCycle) \
  207. SkPciReadCfgByte(pAC,Addr,pVal); \
  208. else \
  209. SK_IN8(pAC,PCI_C(Addr),pVal); \
  210. }
  211. #define VPD_IN16(pAC,Ioc,Addr,pVal) { \
  212. if ((pAC)->DgT.DgUseCfgCycle) \
  213. SkPciReadCfgWord(pAC,Addr,pVal); \
  214. else \
  215. SK_IN16(pAC,PCI_C(Addr),pVal); \
  216. }
  217. #define VPD_IN32(pAC,Ioc,Addr,pVal) { \
  218. if ((pAC)->DgT.DgUseCfgCycle) \
  219. SkPciReadCfgDWord(pAC,Addr,pVal); \
  220. else \
  221. SK_IN32(pAC,PCI_C(Addr),pVal); \
  222. }
  223. #endif /* nSKDIAG */
  224. /* function prototypes ********************************************************/
  225. #ifndef SK_KR_PROTO
  226. #ifdef SKDIAG
  227. extern SK_U32 VpdReadDWord(
  228. SK_AC *pAC,
  229. SK_IOC IoC,
  230. int addr);
  231. #endif /* SKDIAG */
  232. extern int VpdSetupPara(
  233. SK_AC *pAC,
  234. const char *key,
  235. const char *buf,
  236. int len,
  237. int type,
  238. int op);
  239. extern SK_VPD_STATUS *VpdStat(
  240. SK_AC *pAC,
  241. SK_IOC IoC);
  242. extern int VpdKeys(
  243. SK_AC *pAC,
  244. SK_IOC IoC,
  245. char *buf,
  246. int *len,
  247. int *elements);
  248. extern int VpdRead(
  249. SK_AC *pAC,
  250. SK_IOC IoC,
  251. const char *key,
  252. char *buf,
  253. int *len);
  254. extern SK_BOOL VpdMayWrite(
  255. char *key);
  256. extern int VpdWrite(
  257. SK_AC *pAC,
  258. SK_IOC IoC,
  259. const char *key,
  260. const char *buf);
  261. extern int VpdDelete(
  262. SK_AC *pAC,
  263. SK_IOC IoC,
  264. char *key);
  265. extern int VpdUpdate(
  266. SK_AC *pAC,
  267. SK_IOC IoC);
  268. extern void VpdErrLog(
  269. SK_AC *pAC,
  270. SK_IOC IoC,
  271. char *msg);
  272. #ifdef SKDIAG
  273. extern int VpdReadBlock(
  274. SK_AC *pAC,
  275. SK_IOC IoC,
  276. char *buf,
  277. int addr,
  278. int len);
  279. extern int VpdWriteBlock(
  280. SK_AC *pAC,
  281. SK_IOC IoC,
  282. char *buf,
  283. int addr,
  284. int len);
  285. #endif /* SKDIAG */
  286. #else /* SK_KR_PROTO */
  287. extern SK_U32 VpdReadDWord();
  288. extern int VpdSetupPara();
  289. extern SK_VPD_STATUS *VpdStat();
  290. extern int VpdKeys();
  291. extern int VpdRead();
  292. extern SK_BOOL VpdMayWrite();
  293. extern int VpdWrite();
  294. extern int VpdDelete();
  295. extern int VpdUpdate();
  296. extern void VpdErrLog();
  297. #endif /* SK_KR_PROTO */
  298. #endif /* __INC_SKVPD_H_ */