Debian Codegraph @

common/cisco_eeprom.h

raw
1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2006 Christophe Fillot. All rights reserved.
4 *
5 * Cisco EEPROM manipulation functions.
6 */
7
8 #ifndef __CISCO_EEPROM_H__
9 #define __CISCO_EEPROM_H__
10
11 #include "utils.h"
12
13 /*
14 CISCO EEPROM format version 1 (size=0x20?)
15 0x00: 01(version)
16 0x01: XX(product id)
17 // TODO format might depend on the type or class of hardware
18 0x02: XX (.) XX(Hardware revision)
19 0x04: XX XX XX XX(Serial number)
20 0x08: XX (-) XX XX (-) XX(Part number)
21 0x0C: XX(Test history)
22 0x0D: XX (-) XX (-) XX(RMA number)
23 0x10: XX(Board Revision)
24 0x11: ...FF(padding?)
25 0x17: XX(Connector type)(0=PCI,1=Wan Module,other=PCI)
26 0x18: ...FF(padding?)
27 // 0x20+ is optional? ignored if FF FF...
28 0x26: XX XX XX XX(Version Identifier)(4 chars)
29 0x2A: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX(FRU Part Number)(18 chars)
30 0x3C: ...FF(padding?)
31 */
32
33 /*
34 CISCO EEPROM format version 4 (size=0x80?)
35 0x00: 04(version) FF(padding?)
36 0x02: {
37 // {00000000b}.* adds 0x100 to id?
38 // {LLDDDDDDb} has length=2^LLb(1,2,4) and id=DDDDDDb
39 // {11DDDDDDb TTLLLLLLb} has id=DDDDDDb, length=LLLLLLb and type=TTb(00b=hex,01b=number,10b=string,11b=hex or reserved?)
40 : 01 XX(Number of Slots)
41 : 02 XX(Fab Version)
42 : 03 XX(RMA Test History)
43 : 04 XX(RMA History)
44 : 05 XX(Connector Type)
45 : 06 XX(EHSA Preferred Master)
46 : 07 XX(Vendor ID)
47 : 09 XX(Processor type)
48 : 0B XX(Power Supply Type: 0=AC, !0=DC)
49 : 0C XX(ignored?)
50 : 40 XX XX(product id)
51 : 41 XX (.) XX (Hardware Revision)
52 : 42 XX XX(Board Revision)
53 : 43 XXXX(MAC Address block size)
54 : 44 XX XX(Capabilities)
55 : 45 XX XX(Self test result)
56 : 4A XX XX(Radio Country Code)
57 : 80 XXXX XXXX(Deviation Number)
58 : 81 XX (-) XX (-) XX (-) XX(RMA Number)
59 : 82 XX (-) XXXX (-) XX(Part Number)
60 : 83 XXXXXXXX(Hardware date code)
61 : 84 XX XX XX XX(Manufacturing Engineer)
62 : 85 XX (-) XXXX (-) XX(Fab Part Number)
63 : C0 46 XX XX (-) XX XX XX (-) XX(Part Number)(number)
64 : C1 8B XX XX XX XX XX XX XX XX XX XX XX(PCB Serial Number)(string)
65 : C2 8B XX XX XX XX XX XX XX XX XX XX XX(Chassis Serial Number)(string)
66 : C3 06 XX XX XX XX XX XX(Chassis MAC Address)
67 : C4 08 XX XX XX XX XX XX XX XX(Manufacturing Test Data)
68 : C5 08 XX XX XX XX XX XX XX XX(Field Diagnostics Data)
69 : C6 8A XX XX XX XX XX XX XX XX XX XX(CLEI Code)(string)
70 : C7 ?? XX?(ignored?)
71 : C8 09 XX[min dBmV] XX[max dBmV] XX[num_values=3] XXXX[value_0] XXXX[value_1] XXXX[value_2](Calibration Data)
72 : C9 ?? XX?(Platform features)(hex)
73 : CB 88 XX XX XX XX XX XX XX XX(Product (FRU) Number)(string)
74 : CF 06 XXXX (.) XXXX (.) XXXX(Base MAC Address)
75 }.*
76 0x??: ...FF(padding?)
77 */
78
79 /* Cisco EEPROM */
80 struct cisco_eeprom {
81 char *name;
82 m_uint16_t *data;
83 size_t len;
84 };
85
86 /* Find a NM EEPROM */
87 const struct cisco_eeprom *cisco_eeprom_find_nm(char *name);
88
89 /* Find a PA EEPROM */
90 const struct cisco_eeprom *cisco_eeprom_find_pa(char *name);
91
92 /* Find a WIC EEPROM */
93 const struct cisco_eeprom *cisco_eeprom_find_wic(char *name);
94
95 /* Find a C6k EEPROM */
96 const struct cisco_eeprom *cisco_eeprom_find_c6k(char *name);
97
98 /* Find an EEPROM in the specified EEPROM array */
99 const struct cisco_eeprom *
100 cisco_eeprom_find(const struct cisco_eeprom *eeproms,char *name);
101
102 /* Copy an EEPROM */
103 int cisco_eeprom_copy(struct cisco_eeprom *dst,const struct cisco_eeprom *src);
104
105 /* Free resources used by an EEPROM */
106 void cisco_eeprom_free(struct cisco_eeprom *eeprom);
107
108 /* Return TRUE if the specified EEPROM contains usable data */
109 int cisco_eeprom_valid(struct cisco_eeprom *eeprom);
110
111 /* Get a byte from an EEPROM */
112 int cisco_eeprom_get_byte(struct cisco_eeprom *eeprom,
113 size_t offset,m_uint8_t *val);
114
115 /* Set a byte to an EEPROM */
116 int cisco_eeprom_set_byte(struct cisco_eeprom *eeprom,
117 size_t offset,m_uint8_t val);
118
119 /* Get an EEPROM region */
120 int cisco_eeprom_get_region(struct cisco_eeprom *eeprom,size_t offset,
121 m_uint8_t *data,size_t data_len);
122
123 /* Set an EEPROM region */
124 int cisco_eeprom_set_region(struct cisco_eeprom *eeprom,size_t offset,
125 m_uint8_t *data,size_t data_len);
126
127 /* Get a field of a Cisco EEPROM v4 */
128 int cisco_eeprom_v4_get_field(struct cisco_eeprom *eeprom,m_uint8_t *type,
129 m_uint8_t *len,size_t *offset);
130
131 /* Dump a Cisco EEPROM with format version 4 */
132 void cisco_eeprom_v4_dump(struct cisco_eeprom *eeprom);
133
134 /* Dump a Cisco EEPROM with unformatted */
135 void cisco_eeprom_dump(struct cisco_eeprom *eeprom);
136
137 /* Returns the offset of the specified field */
138 int cisco_eeprom_v4_find_field(struct cisco_eeprom *eeprom,
139 m_uint8_t field_type,
140 size_t *field_offset);
141
142 #endif
143