1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.9 $
6 * Date: $Date: 1999/11/22 14:02:27 $
7 * Purpose: Defines and Macros for VPD handling
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998,1999 SysKonnect,
14 * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * The information in this file is provided "AS IS" without warranty.
23 ******************************************************************************/
25 /******************************************************************************
30 * Revision 1.9 1999/11/22 14:02:27 cgoos
31 * Changed license header to GPL.
33 * Revision 1.8 1999/03/11 14:26:40 malthoff
34 * Replace __STDC__ with SK_KR_PROTO.
36 * Revision 1.7 1998/10/28 07:27:17 gklug
38 * add: VPD_IN/OUT8 macros
39 * chg: interface definition
41 * Revision 1.6 1998/10/22 10:03:44 gklug
42 * fix: use SK_OUT16 instead of SK_OUTW
44 * Revision 1.5 1998/10/14 07:05:31 cgoos
45 * Changed constants in SK_SWAP_32 to UL.
47 * Revision 1.4 1998/08/19 08:14:09 gklug
48 * fix: remove struct keyword as much as possible from the c-code (see CCC)
50 * Revision 1.3 1998/08/18 08:18:56 malthoff
51 * Modify VPD in and out macros for SK_DIAG
53 * Revision 1.2 1998/07/03 14:49:08 malthoff
54 * Add VPD_INxx() and VPD_OUTxx() macros for the Diagnostics tool.
56 * Revision 1.1 1998/06/19 14:08:03 malthoff
60 ******************************************************************************/
63 * skvpd.h contains Diagnostic specific defines for VPD handling
66 #ifndef __INC_SKVPD_H_
67 #define __INC_SKVPD_H_
70 * Define Resource Type Identifiers and VPD keywords
72 #define RES_ID 0x82 /* Resource Type ID String (Product Name) */
73 #define RES_VPD_R 0x90 /* start of VPD read only area */
74 #define RES_VPD_W 0x91 /* start of VPD read/write area */
75 #define RES_END 0x78 /* Resource Type End Tag */
78 #define VPD_NAME "Name" /* Product Name, VPD name of RES_ID */
80 #define VPD_PN "PN" /* Adapter Part Number */
81 #define VPD_EC "EC" /* Adapter Engineering Level */
82 #define VPD_MN "MN" /* Manufacture ID */
83 #define VPD_SN "SN" /* Serial Number */
84 #define VPD_CP "CP" /* Extended Capability */
85 #define VPD_RV "RV" /* Checksum and Reserved */
86 #define VPD_YA "YA" /* Asset Tag Identifier */
87 #define VPD_VL "VL" /* First Error Log Message (SK specific) */
88 #define VPD_VF "VF" /* Second Error Log Message (SK specific) */
89 #define VPD_RW "RW" /* Remaining Read / Write Area */
91 /* 'type' values for vpd_setup_para() */
92 #define VPD_RO_KEY 1 /* RO keys are "PN", "EC", "MN", "SN", "RV" */
93 #define VPD_RW_KEY 2 /* RW keys are "Yx", "Vx", and "RW" */
95 /* 'op' values for vpd_setup_para() */
96 #define ADD_KEY 1 /* add the key at the pos "RV" or "RW" */
97 #define OWR_KEY 2 /* overwrite key if already exists */
100 * Define READ and WRITE Constants.
103 #define VPD_READ 0x0000
104 #define VPD_WRITE 0x8000
106 #define VPD_STOP(pAC,IoC) VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)
108 #define VPD_GET_RES_LEN(p) ((unsigned int) \
109 (* (SK_U8 *)&(p)[1]) |\
110 ((* (SK_U8 *)&(p)[2]) << 8))
111 #define VPD_GET_VPD_LEN(p) ((unsigned int)(* (SK_U8 *)&(p)[2]))
112 #define VPD_GET_VAL(p) ((char *)&(p)[3])
114 #define VPD_MAX_LEN 50
117 /* bit 7..1 reserved */
118 #define VPD_VALID (1<<0) /* VPD data buffer, vpd_free_ro, */
119 /* and vpd_free_rw valid */
124 typedef struct s_vpd_status {
125 unsigned short vpd_status ; /* VPD status, description see above */
126 int vpd_free_ro ; /* unused bytes in read only area */
127 int vpd_free_rw ; /* bytes available in read/write area */
130 typedef struct s_vpd {
131 SK_VPD_STATUS v ; /* VPD status structure */
132 char vpd_buf[VPD_SIZE] ; /* VPD buffer */
135 typedef struct s_vpd_para {
136 unsigned int p_len ; /* parameter length */
137 char *p_val ; /* points to the value */
141 * structure of Large Resource Type Identifiers
143 /* was removed, because of alignment problems */
146 * sturcture of VPD keywords
148 typedef struct s_vpd_key {
149 char p_key[2] ; /* 2 bytes ID string */
150 unsigned char p_len ; /* 1 byte length */
151 char p_val ; /* start of the value string */
156 * System specific VPD macros
160 #define VPD_OUT8(pAC,IoC,Addr,Val) (void)SkPciWriteCfgByte(pAC,Addr,Val)
161 #define VPD_OUT16(pAC,IoC,Addr,Val) (void)SkPciWriteCfgWord(pAC,Addr,Val)
162 #define VPD_OUT32(pAC,IoC,Addr,Val) (void)SkPciWriteCfgDWord(pAC,Addr,Val)
163 #define VPD_IN8(pAC,IoC,Addr,pVal) (void)SkPciReadCfgByte(pAC,Addr,pVal)
164 #define VPD_IN16(pAC,IoC,Addr,pVal) (void)SkPciReadCfgWord(pAC,Addr,pVal)
165 #define VPD_IN32(pAC,IoC,Addr,pVal) (void)SkPciReadCfgDWord(pAC,Addr,pVal)
166 #else /* VPD_DO_IO */
167 #define VPD_OUT8(pAC,IoC,Addr,Val) SK_OUT8(IoC,PCI_C(Addr),Val)
168 #define VPD_OUT16(pAC,IoC,Addr,Val) SK_OUT16(IoC,PCI_C(Addr),Val)
169 #define VPD_OUT32(pAC,IoC,Addr,Val) SK_OUT32(IoC,PCI_C(Addr),Val)
170 #define VPD_IN8(pAC,IoC,Addr,pVal) SK_IN8(IoC,PCI_C(Addr),pVal)
171 #define VPD_IN16(pAC,IoC,Addr,pVal) SK_IN16(IoC,PCI_C(Addr),pVal)
172 #define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(Addr),pVal)
173 #endif /* VPD_DO_IO */
175 #define VPD_OUT8(pAC,Ioc,Addr,Val) { \
176 if ((pAC)->DgT.DgUseCfgCycle) \
177 SkPciWriteCfgByte(pAC,Addr,Val) ; \
179 SK_OUT8(pAC,PCI_C(Addr),Val); \
181 #define VPD_OUT16(pAC,Ioc,Addr,Val) { \
182 if ((pAC)->DgT.DgUseCfgCycle) \
183 SkPciWriteCfgWord(pAC,Addr,Val) ; \
185 SK_OUT16(pAC,PCI_C(Addr),Val); \
187 #define VPD_OUT32(pAC,Ioc,Addr,Val) { \
188 if ((pAC)->DgT.DgUseCfgCycle) \
189 SkPciWriteCfgDWord(pAC,Addr,Val) ; \
191 SK_OUT32(pAC,PCI_C(Addr),Val); \
193 #define VPD_IN8(pAC,Ioc,Addr,pVal) { \
194 if ((pAC)->DgT.DgUseCfgCycle) \
195 SkPciReadCfgByte(pAC,Addr,pVal) ; \
197 SK_IN8(pAC,PCI_C(Addr),pVal); \
199 #define VPD_IN16(pAC,Ioc,Addr,pVal) { \
200 if ((pAC)->DgT.DgUseCfgCycle) \
201 SkPciReadCfgWord(pAC,Addr,pVal) ; \
203 SK_IN16(pAC,PCI_C(Addr),pVal); \
205 #define VPD_IN32(pAC,Ioc,Addr,pVal) { \
206 if ((pAC)->DgT.DgUseCfgCycle) \
207 SkPciReadCfgDWord(pAC,Addr,pVal) ; \
209 SK_IN32(pAC,PCI_C(Addr),pVal); \
213 /* function prototypes ********************************************************/
216 extern SK_U32 VpdReadDWord(
221 extern int VpdSetupPara(
229 extern SK_VPD_STATUS *VpdStat(
247 extern SK_BOOL VpdMayWrite(
256 extern int VpdDelete(
261 extern int VpdUpdate(
265 extern void VpdErrLog(
271 extern int VpdReadBlock(
278 extern int VpdWriteBlock(
285 #else /* SK_KR_PROTO */
286 extern SK_U32 VpdReadDWord() ;
287 extern int VpdSetupPara() ;
288 extern SK_VPD_STATUS *VpdStat() ;
289 extern int VpdKeys() ;
290 extern int VpdRead() ;
291 extern SK_BOOL VpdMayWrite() ;
292 extern int VpdWrite() ;
293 extern int VpdDelete() ;
294 extern int VpdUpdate() ;
295 extern void VpdErrLog() ;
296 #endif /* SK_KR_PROTO */
298 #endif /* __INC_SKVPD_H_ */