skvpd.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. * skvpd.h contains Diagnostic specific defines for VPD handling
  24. */
  25. #ifndef __INC_SKVPD_H_
  26. #define __INC_SKVPD_H_
  27. /*
  28. * Define Resource Type Identifiers and VPD keywords
  29. */
  30. #define RES_ID 0x82 /* Resource Type ID String (Product Name) */
  31. #define RES_VPD_R 0x90 /* start of VPD read only area */
  32. #define RES_VPD_W 0x91 /* start of VPD read/write area */
  33. #define RES_END 0x78 /* Resource Type End Tag */
  34. #ifndef VPD_NAME
  35. #define VPD_NAME "Name" /* Product Name, VPD name of RES_ID */
  36. #endif /* VPD_NAME */
  37. #define VPD_PN "PN" /* Adapter Part Number */
  38. #define VPD_EC "EC" /* Adapter Engineering Level */
  39. #define VPD_MN "MN" /* Manufacture ID */
  40. #define VPD_SN "SN" /* Serial Number */
  41. #define VPD_CP "CP" /* Extended Capability */
  42. #define VPD_RV "RV" /* Checksum and Reserved */
  43. #define VPD_YA "YA" /* Asset Tag Identifier */
  44. #define VPD_VL "VL" /* First Error Log Message (SK specific) */
  45. #define VPD_VF "VF" /* Second Error Log Message (SK specific) */
  46. #define VPD_RW "RW" /* Remaining Read / Write Area */
  47. /* 'type' values for vpd_setup_para() */
  48. #define VPD_RO_KEY 1 /* RO keys are "PN", "EC", "MN", "SN", "RV" */
  49. #define VPD_RW_KEY 2 /* RW keys are "Yx", "Vx", and "RW" */
  50. /* 'op' values for vpd_setup_para() */
  51. #define ADD_KEY 1 /* add the key at the pos "RV" or "RW" */
  52. #define OWR_KEY 2 /* overwrite key if already exists */
  53. /*
  54. * Define READ and WRITE Constants.
  55. */
  56. #define VPD_DEV_ID_GENESIS 0x4300
  57. #define VPD_SIZE_YUKON 256
  58. #define VPD_SIZE_GENESIS 512
  59. #define VPD_SIZE 512
  60. #define VPD_READ 0x0000
  61. #define VPD_WRITE 0x8000
  62. #define VPD_STOP(pAC,IoC) VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)
  63. #define VPD_GET_RES_LEN(p) ((unsigned int) \
  64. (* (SK_U8 *)&(p)[1]) |\
  65. ((* (SK_U8 *)&(p)[2]) << 8))
  66. #define VPD_GET_VPD_LEN(p) ((unsigned int)(* (SK_U8 *)&(p)[2]))
  67. #define VPD_GET_VAL(p) ((char *)&(p)[3])
  68. #define VPD_MAX_LEN 50
  69. /* VPD status */
  70. /* bit 7..1 reserved */
  71. #define VPD_VALID (1<<0) /* VPD data buffer, vpd_free_ro, */
  72. /* and vpd_free_rw valid */
  73. /*
  74. * VPD structs
  75. */
  76. typedef struct s_vpd_status {
  77. unsigned short Align01; /* Alignment */
  78. unsigned short vpd_status; /* VPD status, description see above */
  79. int vpd_free_ro; /* unused bytes in read only area */
  80. int vpd_free_rw; /* bytes available in read/write area */
  81. } SK_VPD_STATUS;
  82. typedef struct s_vpd {
  83. SK_VPD_STATUS v; /* VPD status structure */
  84. char vpd_buf[VPD_SIZE]; /* VPD buffer */
  85. int rom_size; /* VPD ROM Size from PCI_OUR_REG_2 */
  86. int vpd_size; /* saved VPD-size */
  87. } SK_VPD;
  88. typedef struct s_vpd_para {
  89. unsigned int p_len; /* parameter length */
  90. char *p_val; /* points to the value */
  91. } SK_VPD_PARA;
  92. /*
  93. * structure of Large Resource Type Identifiers
  94. */
  95. /* was removed because of alignment problems */
  96. /*
  97. * structure of VPD keywords
  98. */
  99. typedef struct s_vpd_key {
  100. char p_key[2]; /* 2 bytes ID string */
  101. unsigned char p_len; /* 1 byte length */
  102. char p_val; /* start of the value string */
  103. } SK_VPD_KEY;
  104. /*
  105. * System specific VPD macros
  106. */
  107. #ifndef SKDIAG
  108. #ifndef VPD_DO_IO
  109. #define VPD_OUT8(pAC,IoC,Addr,Val) (void)SkPciWriteCfgByte(pAC,Addr,Val)
  110. #define VPD_OUT16(pAC,IoC,Addr,Val) (void)SkPciWriteCfgWord(pAC,Addr,Val)
  111. #define VPD_IN8(pAC,IoC,Addr,pVal) (void)SkPciReadCfgByte(pAC,Addr,pVal)
  112. #define VPD_IN16(pAC,IoC,Addr,pVal) (void)SkPciReadCfgWord(pAC,Addr,pVal)
  113. #define VPD_IN32(pAC,IoC,Addr,pVal) (void)SkPciReadCfgDWord(pAC,Addr,pVal)
  114. #else /* VPD_DO_IO */
  115. #define VPD_OUT8(pAC,IoC,Addr,Val) SK_OUT8(IoC,PCI_C(Addr),Val)
  116. #define VPD_OUT16(pAC,IoC,Addr,Val) SK_OUT16(IoC,PCI_C(Addr),Val)
  117. #define VPD_IN8(pAC,IoC,Addr,pVal) SK_IN8(IoC,PCI_C(Addr),pVal)
  118. #define VPD_IN16(pAC,IoC,Addr,pVal) SK_IN16(IoC,PCI_C(Addr),pVal)
  119. #define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(Addr),pVal)
  120. #endif /* VPD_DO_IO */
  121. #else /* SKDIAG */
  122. #define VPD_OUT8(pAC,Ioc,Addr,Val) { \
  123. if ((pAC)->DgT.DgUseCfgCycle) \
  124. SkPciWriteCfgByte(pAC,Addr,Val); \
  125. else \
  126. SK_OUT8(pAC,PCI_C(Addr),Val); \
  127. }
  128. #define VPD_OUT16(pAC,Ioc,Addr,Val) { \
  129. if ((pAC)->DgT.DgUseCfgCycle) \
  130. SkPciWriteCfgWord(pAC,Addr,Val); \
  131. else \
  132. SK_OUT16(pAC,PCI_C(Addr),Val); \
  133. }
  134. #define VPD_IN8(pAC,Ioc,Addr,pVal) { \
  135. if ((pAC)->DgT.DgUseCfgCycle) \
  136. SkPciReadCfgByte(pAC,Addr,pVal); \
  137. else \
  138. SK_IN8(pAC,PCI_C(Addr),pVal); \
  139. }
  140. #define VPD_IN16(pAC,Ioc,Addr,pVal) { \
  141. if ((pAC)->DgT.DgUseCfgCycle) \
  142. SkPciReadCfgWord(pAC,Addr,pVal); \
  143. else \
  144. SK_IN16(pAC,PCI_C(Addr),pVal); \
  145. }
  146. #define VPD_IN32(pAC,Ioc,Addr,pVal) { \
  147. if ((pAC)->DgT.DgUseCfgCycle) \
  148. SkPciReadCfgDWord(pAC,Addr,pVal); \
  149. else \
  150. SK_IN32(pAC,PCI_C(Addr),pVal); \
  151. }
  152. #endif /* nSKDIAG */
  153. /* function prototypes ********************************************************/
  154. #ifndef SK_KR_PROTO
  155. #ifdef SKDIAG
  156. extern SK_U32 VpdReadDWord(
  157. SK_AC *pAC,
  158. SK_IOC IoC,
  159. int addr);
  160. #endif /* SKDIAG */
  161. extern SK_VPD_STATUS *VpdStat(
  162. SK_AC *pAC,
  163. SK_IOC IoC);
  164. extern int VpdKeys(
  165. SK_AC *pAC,
  166. SK_IOC IoC,
  167. char *buf,
  168. int *len,
  169. int *elements);
  170. extern int VpdRead(
  171. SK_AC *pAC,
  172. SK_IOC IoC,
  173. const char *key,
  174. char *buf,
  175. int *len);
  176. extern SK_BOOL VpdMayWrite(
  177. char *key);
  178. extern int VpdWrite(
  179. SK_AC *pAC,
  180. SK_IOC IoC,
  181. const char *key,
  182. const char *buf);
  183. extern int VpdDelete(
  184. SK_AC *pAC,
  185. SK_IOC IoC,
  186. char *key);
  187. extern int VpdUpdate(
  188. SK_AC *pAC,
  189. SK_IOC IoC);
  190. #ifdef SKDIAG
  191. extern int VpdReadBlock(
  192. SK_AC *pAC,
  193. SK_IOC IoC,
  194. char *buf,
  195. int addr,
  196. int len);
  197. extern int VpdWriteBlock(
  198. SK_AC *pAC,
  199. SK_IOC IoC,
  200. char *buf,
  201. int addr,
  202. int len);
  203. #endif /* SKDIAG */
  204. #else /* SK_KR_PROTO */
  205. extern SK_U32 VpdReadDWord();
  206. extern SK_VPD_STATUS *VpdStat();
  207. extern int VpdKeys();
  208. extern int VpdRead();
  209. extern SK_BOOL VpdMayWrite();
  210. extern int VpdWrite();
  211. extern int VpdDelete();
  212. extern int VpdUpdate();
  213. #endif /* SK_KR_PROTO */
  214. #endif /* __INC_SKVPD_H_ */