/[dynamips]/trunk/cisco_eeprom.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/cisco_eeprom.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations)
Sat Oct 6 16:45:40 2007 UTC (11 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 29828 byte(s)
make working copy

1 /*
2 * Cisco router simulation platform.
3 * Copyright (c) 2006 Christophe Fillot. All rights reserved.
4 *
5 * Cisco EEPROM manipulation functions.
6 */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <unistd.h>
12 #include <sys/types.h>
13 #include <sys/socket.h>
14
15 #include "utils.h"
16 #include "cisco_eeprom.h"
17
18 /* ====================================================================== */
19 /* NM-1E: 1 Ethernet Port Network Module EEPROM */
20 /* ====================================================================== */
21 static m_uint16_t eeprom_nm_1e_data[] = {
22 0x0143, 0x0100, 0x0075, 0xCD81, 0x500D, 0xA201, 0x0000, 0x0000,
23 0x5800, 0x0000, 0x9803, 0x2000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
24 };
25
26 /* ====================================================================== */
27 /* NM-4E: 4 Ethernet Port Network Module EEPROM */
28 /* ====================================================================== */
29 static m_uint16_t eeprom_nm_4e_data[] = {
30 0x0142, 0x0100, 0x0075, 0xCD81, 0x500D, 0xA201, 0x0000, 0x0000,
31 0x5800, 0x0000, 0x9803, 0x2000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
32 };
33
34 /* ====================================================================== */
35 /* NM-1FE-TX: 1 FastEthernet Port Network Module EEPROM */
36 /* ====================================================================== */
37 static m_uint16_t eeprom_nm_1fe_tx_data[] = {
38 0x0144, 0x0100, 0x0075, 0xCD81, 0x500D, 0xA201, 0x0000, 0x0000,
39 0x5800, 0x0000, 0x9803, 0x2000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
40 };
41
42 /* ====================================================================== */
43 /* NM-16ESW: 16 FastEthernet Port Switch Network Module EEPROM */
44 /* ====================================================================== */
45 static m_uint16_t eeprom_nm_16esw_data[] = {
46 0x04FF, 0x4002, 0xA941, 0x0100, 0xC046, 0x0320, 0x003B, 0x3401,
47 0x4245, 0x3080, 0x0000, 0x0000, 0x0203, 0xC18B, 0x3030, 0x3030,
48 0x3030, 0x3030, 0x3030, 0x3003, 0x0081, 0x0000, 0x0000, 0x0400,
49 0xCF06, 0x0013, 0x1A1D, 0x0BD1, 0x4300, 0x11FF, 0xFFFF, 0xFFFF,
50 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
51 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
52 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
53 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
54 };
55
56 /* ====================================================================== */
57 /* NM-4T: 4 Serial Network Module EEPROM */
58 /* ====================================================================== */
59 static m_uint16_t eeprom_nm_4t_data[] = {
60 0x0154, 0x0101, 0x009D, 0x2D64, 0x5009, 0x0A02, 0x0000, 0x0000,
61 0x5800, 0x0000, 0x9811, 0x0300, 0x0005, 0xFFFF, 0xFFFF, 0xFFFF,
62 };
63
64 /* ====================================================================== */
65 /* NM-2E2W: 2 Ethernet ports with 2 WIC slots Module EEPROM */
66 /* ====================================================================== */
67 static m_uint16_t eeprom_nm_2e2w_data[] = {
68 0x011E, 0x0102, 0x009A, 0xEBB1, 0x5004, 0x9305, 0x0000, 0x0000,
69 0x5000, 0x0000, 0x9808, 0x1217, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
70 };
71
72 /* ====================================================================== */
73 /* NM-2W: 2 WIC slots Module EEPROM */
74 /* ====================================================================== */
75 static m_uint16_t eeprom_nm_2w_data[] = {
76 0x04FF, 0x4000, 0xD641, 0x0100, 0xC046, 0x0320, 0x0012, 0xBF01,
77 0x4247, 0x3080, 0x0000, 0x0000, 0x0205, 0xC18B, 0x4A41, 0x4430,
78 0x3730, 0x3330, 0x375A, 0x3203, 0x0081, 0x0000, 0x0000, 0x0400,
79 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
80 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
81 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
82 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
83 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
84 };
85
86 /* ====================================================================== */
87 /* NM-1A-OC3MM: 1 ATM OC3 port Module EEPROM */
88 /* ====================================================================== */
89 static m_uint16_t eeprom_nm_1a_oc3mm_data[] = {
90 0x019A, 0x0100, 0x015B, 0x41D9, 0x500E, 0x7402, 0x0000, 0x0000,
91 0x7800, 0x0000, 0x0011, 0x2117, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
92 };
93
94 /* ====================================================================== */
95 /* NM-NAM: Network Analysis Module EEPROM */
96 /* ====================================================================== */
97 static m_uint16_t eeprom_nm_nam_data[] = {
98 0x04FF, 0x4004, 0x6A41, 0x0100, 0xC046, 0x0320, 0x004F, 0x9E01,
99 0x4241, 0x3080, 0x0000, 0x0000, 0x0202, 0xC18B, 0x4A41, 0x4230,
100 0x3630, 0x3630, 0x3543, 0x3403, 0x0081, 0x0000, 0x0000, 0x0400,
101 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
102 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
103 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
104 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
105 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
106 };
107
108 /* ====================================================================== */
109 /* NM-CIDS: Network Analysis Module EEPROM */
110 /* ====================================================================== */
111 static m_uint16_t eeprom_nm_cids_data[] = {
112 0x04FF, 0x4004, 0x2541, 0x0100, 0xC046, 0x0320, 0x004F, 0x9E01,
113 0x4241, 0x3080, 0x0000, 0x0000, 0x0202, 0xC18B, 0x4A41, 0x4230,
114 0x3630, 0x3630, 0x3543, 0x3403, 0x0081, 0x0000, 0x0000, 0x0400,
115 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
116 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
117 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
118 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
119 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
120 };
121
122 /* ====================================================================== */
123 /* NM EEPROMs */
124 /* ====================================================================== */
125
126 static const struct cisco_eeprom eeprom_nm_array[] = {
127 { "NM-1E", eeprom_nm_1e_data, sizeof(eeprom_nm_1e_data)/2 },
128 { "NM-4E", eeprom_nm_4e_data, sizeof(eeprom_nm_4e_data)/2 },
129 { "NM-1FE-TX", eeprom_nm_1fe_tx_data, sizeof(eeprom_nm_1fe_tx_data)/2 },
130 { "NM-16ESW", eeprom_nm_16esw_data, sizeof(eeprom_nm_16esw_data)/2 },
131 { "NM-4T", eeprom_nm_4t_data, sizeof(eeprom_nm_4t_data)/2 },
132 { "NM-2E2W", eeprom_nm_2e2w_data, sizeof(eeprom_nm_2e2w_data)/2 },
133 { "NM-2W", eeprom_nm_2w_data, sizeof(eeprom_nm_2w_data)/2 },
134 { "NM-1A-OC3MM", eeprom_nm_1a_oc3mm_data,
135 sizeof(eeprom_nm_1a_oc3mm_data)/2 },
136 { "NM-NAM", eeprom_nm_nam_data, sizeof(eeprom_nm_nam_data)/2 },
137 { "NM-CIDS", eeprom_nm_cids_data, sizeof(eeprom_nm_cids_data)/2 },
138 { NULL, NULL, 0 },
139 };
140
141 /* Find a NM EEPROM */
142 const struct cisco_eeprom *cisco_eeprom_find_nm(char *name)
143 {
144 return(cisco_eeprom_find(eeprom_nm_array,name));
145 }
146
147 /* ====================================================================== */
148 /* PA-FE-TX: 1 FastEthernet Port Adapter EEPROM */
149 /* ====================================================================== */
150 static m_uint16_t eeprom_pa_fe_tx_data[] = {
151 0x0111, 0x0102, 0xffff, 0xffff, 0x4906, 0x9804, 0x0000, 0x0000,
152 0x6000, 0x0000, 0x9812, 0x1700, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
153 };
154
155 /* ====================================================================== */
156 /* PA-2FE-TX: 2 FastEthernet Port Adapter EEPROM */
157 /* ====================================================================== */
158 static m_uint16_t eeprom_pa_2fe_tx_data[] = {
159 0x04FF, 0x4002, 0x2441, 0x0100, 0xC18B, 0x5858, 0x5830, 0x3030,
160 0x3030, 0x3030, 0x3082, 0x4915, 0x2C04, 0x4241, 0x3003, 0x0081,
161 0x0000, 0x0000, 0x0400, 0x8000, 0x0000, 0x00CB, 0x9450, 0x412D,
162 0x3246, 0x452D, 0x4658, 0x2020, 0x2020, 0x2020, 0x2020, 0x2020,
163 0x20C0, 0x4603, 0x2000, 0x20A0, 0x04FF, 0xFFFF, 0xFFFF, 0xFFFF,
164 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
165 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
166 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
167 };
168
169 /* ====================================================================== */
170 /* PA-GE: 1 GigabitEthernet Port Adapter EEPROM */
171 /* ====================================================================== */
172 static m_uint16_t eeprom_pa_ge_data[] = {
173 0x0198, 0x0100, 0x0000, 0x0000, 0x000C, 0x4803, 0x0000, 0x0000,
174 0x5000, 0x0000, 0x9906, 0x0300, 0x0001, 0xFFFF, 0xFFFF, 0xFFFF,
175 };
176
177 /* ====================================================================== */
178 /* PA-4E: 4 Ethernet Port Adapter EEPROM */
179 /* ====================================================================== */
180 static m_uint16_t eeprom_pa_4e_data[] = {
181 0x0102, 0x010E, 0xFFFF, 0xFFFF, 0x4906, 0x1404, 0x0000, 0x0000,
182 0x5000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
183 };
184
185 /* ====================================================================== */
186 /* PA-8E: 8 Ethernet Port Adapter EEPROM */
187 /* ====================================================================== */
188 static m_uint16_t eeprom_pa_8e_data[] = {
189 0x0101, 0x010E, 0xFFFF, 0xFFFF, 0x4906, 0x1404, 0x0000, 0x0000,
190 0x5000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
191 };
192
193 /* ====================================================================== */
194 /* PA-4T+: 4 Serial Port Adapter EEPROM */
195 /* ====================================================================== */
196 static m_uint16_t eeprom_pa_4t_data[] = {
197 0x010C, 0x010F, 0xffff, 0xffff, 0x4906, 0x2E07, 0x0000, 0x0000,
198 0x5000, 0x0000, 0x0010, 0x2400, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
199 };
200
201 /* ====================================================================== */
202 /* PA-8T: 8 Serial Port Adapter EEPROM */
203 /* ====================================================================== */
204 static m_uint16_t eeprom_pa_8t_data[] = {
205 0x010E, 0x010F, 0xffff, 0xffff, 0x4906, 0x2E07, 0x0000, 0x0000,
206 0x5000, 0x0000, 0x0010, 0x2400, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
207 };
208
209 /* ====================================================================== */
210 /* PA-A1: 1 ATM Port Adapter EEPROM */
211 /* ====================================================================== */
212 static m_uint16_t eeprom_pa_a1_data[] = {
213 0x0117, 0x010F, 0xffff, 0xffff, 0x4906, 0x2E07, 0x0000, 0x0000,
214 0x5000, 0x0000, 0x0010, 0x2400, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
215 };
216
217 /* ====================================================================== */
218 /* PA-POS-OC3: 1 POS Port Adapter EEPROM */
219 /* ====================================================================== */
220 static m_uint16_t eeprom_pa_pos_oc3_data[] = {
221 0x0196, 0x0202, 0xffff, 0xffff, 0x490C, 0x7806, 0x0000, 0x0000,
222 0x5000, 0x0000, 0x0208, 0x1900, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF,
223 };
224
225 /* ====================================================================== */
226 /* PA-4B: 4 BRI Port Adapter EEPROM */
227 /* ====================================================================== */
228 static m_uint16_t eeprom_pa_4b_data[] = {
229 0x013D, 0x0202, 0xffff, 0xffff, 0x490C, 0x7806, 0x0000, 0x0000,
230 0x5000, 0x0000, 0x0208, 0x1900, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF,
231 };
232
233 /* ====================================================================== */
234 /* PA-MC-8TE1 */
235 /* ====================================================================== */
236 static m_uint16_t eeprom_pa_mc8te1_data[] = {
237 0x04FF, 0x4003, 0x4E41, 0x0200, 0xC18B, 0x4A41, 0x4530, 0x3834,
238 0x3159, 0x3251, 0x3082, 0x491D, 0x7D02, 0x4241, 0x3003, 0x0081,
239 0x0000, 0x0000, 0x0400, 0x8000, 0x0127, 0x9BCB, 0x9450, 0x412D,
240 0x4D43, 0x2D38, 0x5445, 0x312B, 0x2020, 0x2020, 0x2020, 0x2020,
241 0x20C0, 0x4603, 0x2000, 0x4BBB, 0x02FF, 0xFFFF, 0xFFFF, 0xFFFF,
242 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
243 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
244 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
245 };
246
247 /* ====================================================================== */
248 /* PA EEPROMs */
249 /* ====================================================================== */
250
251 static const struct cisco_eeprom eeprom_pa_array[] = {
252 { "PA-FE-TX", eeprom_pa_fe_tx_data, sizeof(eeprom_pa_fe_tx_data)/2 },
253 { "PA-2FE-TX", eeprom_pa_2fe_tx_data, sizeof(eeprom_pa_2fe_tx_data)/2 },
254 { "PA-GE", eeprom_pa_ge_data, sizeof(eeprom_pa_ge_data)/2 },
255 { "PA-4E", eeprom_pa_4e_data, sizeof(eeprom_pa_4e_data)/2 },
256 { "PA-8E", eeprom_pa_8e_data, sizeof(eeprom_pa_8e_data)/2 },
257 { "PA-4T+", eeprom_pa_4t_data, sizeof(eeprom_pa_4t_data)/2 },
258 { "PA-8T", eeprom_pa_8t_data, sizeof(eeprom_pa_8t_data)/2 },
259 { "PA-A1", eeprom_pa_a1_data, sizeof(eeprom_pa_a1_data)/2 },
260 { "PA-POS-OC3", eeprom_pa_pos_oc3_data, sizeof(eeprom_pa_pos_oc3_data)/2 },
261 { "PA-4B", eeprom_pa_4b_data, sizeof(eeprom_pa_4b_data)/2 },
262 { "PA-MC-8TE1", eeprom_pa_mc8te1_data, sizeof(eeprom_pa_mc8te1_data)/2 },
263 { NULL, NULL, 0 },
264 };
265
266 /* Find a PA EEPROM */
267 const struct cisco_eeprom *cisco_eeprom_find_pa(char *name)
268 {
269 return(cisco_eeprom_find(eeprom_pa_array,name));
270 }
271
272 /* ====================================================================== */
273 /* WIC-1T: 1 Serial port Module EEPROM */
274 /* ====================================================================== */
275 static m_uint16_t eeprom_wic_1t_data[] = {
276 0x0102, 0x0100, 0x0000, 0x0000, 0x5005, 0xEA01, 0x0000, 0x0000,
277 0xB000, 0x0000, 0x0303, 0x0401, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
278 };
279
280 /* ====================================================================== */
281 /* WIC-2T: 2 Serial ports Module EEPROM */
282 /* ====================================================================== */
283 static m_uint16_t eeprom_wic_2t_data[] = {
284 0x0112, 0x0100, 0x0000, 0x0000, 0x5005, 0xEA01, 0x0000, 0x0000,
285 0xB000, 0x0000, 0x0303, 0x0401, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
286 };
287
288 /* ====================================================================== */
289 /* WIC-1B-S/T: 1 BRI port Module EEPROM */
290 /* ====================================================================== */
291 static m_uint16_t eeprom_wic_1b_st_data[] = {
292 0x0107, 0x0100, 0x0000, 0x0000, 0x5005, 0xEA01, 0x0000, 0x0000,
293 0xB000, 0x0000, 0x0303, 0x0401, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
294 };
295
296 /* ====================================================================== */
297 /* WIC-4ESW: 4 Ethernet port switch module EEPROM */
298 /* ====================================================================== */
299 static m_uint16_t eeprom_wic_4esw_data[] = {
300 0x04FF, 0x4000, 0x6441, 0x0100, 0x8249, 0x22FE, 0x0142, 0x4430,
301 0x8000, 0x0000, 0x0002, 0x01C1, 0x8B46, 0x4F43, 0x3039, 0x3435,
302 0x344C, 0x5345, 0x0300, 0x8100, 0x0000, 0x0004, 0x00C0, 0x4603,
303 0x2000, 0x60F1, 0x0105, 0x01CF, 0x0600, 0x1646, 0x37F4, 0x6843,
304 0x0014, 0xCB88, 0x5749, 0x432D, 0x3445, 0x5357, 0xC68A, 0x4950,
305 0x4D45, 0x4430, 0x3042, 0x5241, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
306 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
307 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
308 };
309
310 /* ====================================================================== */
311 /* WIC-1ENET: 1 Ethernet port module EEPROM */
312 /* ====================================================================== */
313 static m_uint16_t eeprom_wic_1enet_data[] = {
314 0x04FF, 0x4000, 0x3941, 0x0101, 0xC18B, 0x464F, 0x4330, 0x3830,
315 0x3832, 0x4330, 0x3682, 0x4923, 0x0901, 0x4242, 0x3002, 0x04CB,
316 0x8957, 0x4943, 0x2D31, 0x454E, 0x4554, 0x0700, 0x0300, 0x8100,
317 0x0000, 0x0005, 0x0104, 0x00CF, 0x0644, 0x5566, 0x7788, 0xAA43,
318 0x0001, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
319 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
320 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
321 };
322
323 /* ====================================================================== */
324 /* WIC EEPROMs */
325 /* ====================================================================== */
326
327 static const struct cisco_eeprom eeprom_wic_array[] = {
328 { "WIC-1T", eeprom_wic_1t_data, sizeof(eeprom_wic_1t_data)/2 },
329 { "WIC-2T", eeprom_wic_2t_data, sizeof(eeprom_wic_2t_data)/2 },
330 { "WIC-1B", eeprom_wic_1b_st_data, sizeof(eeprom_wic_1b_st_data)/2 },
331 { "WIC-4ESW", eeprom_wic_4esw_data, sizeof(eeprom_wic_4esw_data)/2 },
332 { "WIC-1ENET", eeprom_wic_1enet_data, sizeof(eeprom_wic_1enet_data)/2 },
333 { NULL, NULL, 0 },
334 };
335
336 /* Find a WIC EEPROM */
337 const struct cisco_eeprom *cisco_eeprom_find_wic(char *name)
338 {
339 return(cisco_eeprom_find(eeprom_wic_array,name));
340 }
341
342 /* ====================================================================== */
343 /* C6k EEPROMs */
344 /* ====================================================================== */
345
346 /* Chassis: 6509 */
347 static m_uint16_t eeprom_c6k_chassis_6509_data[] = {
348 0xABAB, 0x0190, 0x0F0D, 0x0100, 0x0002, 0x6001, 0x9002, 0x4369,
349 0x7363, 0x6F20, 0x5379, 0x7374, 0x656D, 0x7300, 0x0000, 0x0000,
350 0x0000, 0x5753, 0x2D43, 0x3635, 0x3039, 0x0000, 0x0000, 0x0000,
351 0x0000, 0x0000, 0x0000, 0x5343, 0x4130, 0x3333, 0x3730, 0x314A,
352 0x5500, 0x0000, 0x0000, 0x0000, 0x0000, 0x3733, 0x2D33, 0x3433,
353 0x382D, 0x3033, 0x0000, 0x0000, 0x0000, 0x4230, 0x0000, 0x0000,
354 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
355 0x0000, 0x0002, 0x0000, 0x0000, 0x0000, 0x0009, 0x0005, 0x0001,
356 0x0002, 0x0001, 0x0016, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
357 0x6001, 0x0124, 0x01AD, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
358 0x0000, 0x0000, 0x0000, 0x0016, 0x00D0, 0x000F, 0x2000, 0x0400,
359 0x0009, 0x0005, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
360 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
361 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
362 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
363 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
364 };
365
366 /* Supervisor: SUP1A-2GE */
367 static m_uint16_t eeprom_c6k_sup1a_2ge_data[] = {
368 0xABAB, 0x0190, 0x138F, 0x0100, 0x0002, 0x6003, 0x00DB, 0x4369,
369 0x7363, 0x6F20, 0x5379, 0x7374, 0x656D, 0x7300, 0x0000, 0x0000,
370 0x0000, 0x5753, 0x2D58, 0x364B, 0x2D53, 0x5550, 0x3141, 0x2D32,
371 0x4745, 0x0000, 0x0000, 0x5341, 0x4430, 0x3333, 0x3431, 0x3639,
372 0x3800, 0x0000, 0x0000, 0x0000, 0x0000, 0x3733, 0x2D34, 0x3336,
373 0x382D, 0x3031, 0x0000, 0x0000, 0x0000, 0x4130, 0x0000, 0x0000,
374 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
375 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0009, 0x0005, 0x0001,
376 0x0003, 0x0001, 0x0001, 0x0002, 0x00DB, 0xFF56, 0x0000, 0x0000,
377 0x6003, 0x0162, 0x0B56, 0x0000, 0x0000, 0x0000, 0x0005, 0x0000,
378 0x0000, 0x0000, 0x0000, 0x0014, 0x00D0, 0xBCEE, 0xB920, 0x0002,
379 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
380 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
381 0x1F02, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
382 0x0200, 0x4132, 0x8181, 0x8181, 0x4B3C, 0x8080, 0x8080, 0x8080,
383 0x8080, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
384 };
385
386 /* EARL: PFC1 (aka EARL5) */
387 static m_uint16_t eeprom_c6k_earl_pfc1_data[] = {
388 0xABAB, 0x0190, 0x117D, 0x0100, 0x0002, 0x6004, 0x0066, 0x4369,
389 0x7363, 0x6F20, 0x5379, 0x7374, 0x656D, 0x7300, 0x0000, 0x0000,
390 0x0000, 0x5753, 0x2D46, 0x364B, 0x2D50, 0x4643, 0x0000, 0x0000,
391 0x0000, 0x0000, 0x0000, 0x5341, 0x4430, 0x3334, 0x3333, 0x3637,
392 0x3800, 0x0000, 0x0000, 0x0000, 0x0000, 0x3733, 0x2D34, 0x3037,
393 0x352D, 0x3033, 0x0000, 0x0000, 0x0000, 0x4130, 0x0000, 0x0000,
394 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
395 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0009, 0x0005, 0x0001,
396 0x0003, 0x0001, 0x0001, 0x0010, 0x0066, 0xFFB0, 0x0000, 0x0000,
397 0x6004, 0x0148, 0x07B7, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
398 0x0000, 0x0000, 0x0000, 0x000E, 0x0001, 0x0001, 0x0000, 0x0000,
399 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
400 0x0000, 0x0000, 0x0000, 0x0000, 0x4B3C, 0x4132, 0x8080, 0x8080,
401 0x8080, 0x8080, 0x8080, 0x8080, 0x0000, 0x0000, 0x0000, 0x0000,
402 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
403 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
404 };
405
406 /* Power Supply: 1000W */
407 static m_uint16_t eeprom_c6k_power_1000w_data[] = {
408 0xABAB, 0x0190, 0x121C, 0x0100, 0x0002, 0xAB01, 0x0003, 0x4369,
409 0x7363, 0x6F20, 0x5379, 0x7374, 0x656D, 0x732C, 0x2049, 0x6E63,
410 0x2E00, 0x5753, 0x2D43, 0x4143, 0x2D31, 0x3030, 0x3057, 0x0000,
411 0x0000, 0x0000, 0x0000, 0x534F, 0x4E30, 0x3430, 0x3930, 0x3036,
412 0x3600, 0x0000, 0x0000, 0x0000, 0x0000, 0x3334, 0x2D30, 0x3932,
413 0x332D, 0x3031, 0x0000, 0x0000, 0x0000, 0x4230, 0x0000, 0x0000,
414 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
415 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0009, 0x000C, 0x0003,
416 0x0001, 0x0006, 0x0003, 0x0000, 0x0000, 0x07EE, 0x0000, 0x0000,
417 0xAB01, 0x0114, 0x02C0, 0x0000, 0x0000, 0x0000, 0x0000, 0x07EE,
418 0x07EE, 0x0015, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
419 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
420 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
421 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
422 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
423 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
424 };
425
426 /* VTT: Voltage Termination module */
427 static m_uint16_t eeprom_c6k_vtt_data[] = {
428 0xABAB, 0x0190, 0x0FC4, 0x0100, 0x0002, 0xAB02, 0x0001, 0x4369,
429 0X7363, 0x6F20, 0x5379, 0x7374, 0x656D, 0x7300, 0x0000, 0x0000,
430 0x0000, 0x5753, 0x2D43, 0x3630, 0x3030, 0x2D56, 0x5454, 0x0000,
431 0x0000, 0x0000, 0x0000, 0x534D, 0x5430, 0x3333, 0x3531, 0x3330,
432 0x3400, 0x0000, 0x0000, 0x0000, 0x0000, 0x3733, 0x2D33, 0x3230,
433 0x382D, 0x3034, 0x0000, 0x0000, 0x0000, 0x4130, 0x0000, 0x0000,
434 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
435 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0009, 0x0005, 0x0001,
436 0x0002, 0x0012, 0x0001, 0x0002, 0x0003, 0x0000, 0x0000, 0x0000,
437 0xAB02, 0x0118, 0x00C9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
438 0x0000, 0x0000, 0x0000, 0x0003, 0x6455, 0x0000, 0x0000, 0x0000,
439 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
440 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
441 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
442 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
443 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
444 };
445
446 /* Linecard: WS-X6248 */
447 static m_uint16_t eeprom_c6k_lc_wsx6248_data[] = {
448 0xABAB, 0x0190, 0x1339, 0x0100, 0x0002, 0x6003, 0x00CB, 0x4369,
449 0x7363, 0x6F20, 0x5379, 0x7374, 0x656D, 0x7300, 0x0000, 0x0000,
450 0x0000, 0x5753, 0x2D58, 0x3632, 0x3438, 0x2D52, 0x4A2D, 0x3435,
451 0x0000, 0x0000, 0x0000, 0x5341, 0x4430, 0x3333, 0x3436, 0x3834,
452 0x3200, 0x0000, 0x0000, 0x0000, 0x0000, 0x3733, 0x2D33, 0x3234,
453 0x342D, 0x3038, 0x0000, 0x0000, 0x0000, 0x4330, 0x0000, 0x0000,
454 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
455 0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0009, 0x0005, 0x0001,
456 0x0003, 0x0001, 0x0001, 0x0002, 0x00CB, 0xFEF3, 0x0000, 0x0000,
457 0x6003, 0x0162, 0x0B02, 0x0000, 0x0000, 0x0000, 0x0005, 0x0000,
458 0x0000, 0x0000, 0x0000, 0x0003, 0x0030, 0xB6CC, 0x3CC0, 0x0030,
459 0x0106, 0x0003, 0x0001, 0x0002, 0x0002, 0x0001, 0x0004, 0x0000,
460 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
461 0x1230, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
462 0x0200, 0x4B3C, 0x4132, 0x8181, 0x8181, 0x8080, 0x8080, 0x8080,
463 0x8080, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
464 };
465
466 static const struct cisco_eeprom eeprom_c6k_array[] = {
467 { "C6K-CHASSIS-6509",
468 eeprom_c6k_chassis_6509_data, sizeof(eeprom_c6k_chassis_6509_data)/2 } ,
469 { "C6K-SUP-SUP1A-2GE",
470 eeprom_c6k_sup1a_2ge_data, sizeof(eeprom_c6k_sup1a_2ge_data)/2 } ,
471 { "C6K-EARL-PFC1",
472 eeprom_c6k_earl_pfc1_data, sizeof(eeprom_c6k_earl_pfc1_data)/2 } ,
473 { "C6K-POWER-1000W",
474 eeprom_c6k_power_1000w_data, sizeof(eeprom_c6k_power_1000w_data)/2 } ,
475 { "C6K-VTT",
476 eeprom_c6k_vtt_data, sizeof(eeprom_c6k_vtt_data) },
477 { "C6K-LC-WS-X6248",
478 eeprom_c6k_lc_wsx6248_data, sizeof(eeprom_c6k_lc_wsx6248_data)/2 } ,
479 { NULL, NULL, 0 },
480 };
481
482 /* Find a C6k EEPROM */
483 const struct cisco_eeprom *cisco_eeprom_find_c6k(char *name)
484 {
485 return(cisco_eeprom_find(eeprom_c6k_array,name));
486 }
487
488 /* ====================================================================== */
489 /* Utility functions */
490 /* ====================================================================== */
491
492 /* Find an EEPROM in the specified EEPROM array */
493 const struct cisco_eeprom *
494 cisco_eeprom_find(const struct cisco_eeprom *eeproms,char *name)
495 {
496 int i;
497
498 for(i=0;eeproms[i].name;i++)
499 if (!strcmp(eeproms[i].name,name))
500 return(&eeproms[i]);
501
502 return NULL;
503 }
504
505 /* Copy an EEPROM */
506 int cisco_eeprom_copy(struct cisco_eeprom *dst,const struct cisco_eeprom *src)
507 {
508 m_uint16_t *data;
509
510 if (!src || !src)
511 return(-1);
512
513 cisco_eeprom_free(dst);
514
515 if (!(data = malloc(src->len << 1)))
516 return(-1);
517
518 memcpy(data,src->data,src->len << 1);
519 dst->name = src->name;
520 dst->data = data;
521 dst->len = src->len;
522 return(0);
523 }
524
525 /* Free resources used by an EEPROM */
526 void cisco_eeprom_free(struct cisco_eeprom *eeprom)
527 {
528 if (eeprom && eeprom->data) {
529 free(eeprom->data);
530 eeprom->data = NULL;
531 eeprom->len = 0;
532 }
533 }
534
535 /* Return TRUE if the specified EEPROM contains usable data */
536 int cisco_eeprom_valid(struct cisco_eeprom *eeprom)
537 {
538 return((eeprom && eeprom->data) ? TRUE : FALSE);
539 }
540
541 /* Get a byte from an EEPROM */
542 int cisco_eeprom_get_byte(struct cisco_eeprom *eeprom,
543 size_t offset,m_uint8_t *val)
544 {
545 m_uint16_t tmp;
546
547 if (offset >= (eeprom->len << 1)) {
548 *val = 0xFF;
549 return(-1);
550 }
551
552 tmp = eeprom->data[offset >> 1];
553
554 if (!(offset & 1))
555 tmp >>= 8;
556
557 *val = tmp & 0xFF;
558 return(0);
559 }
560
561 /* Set a byte to an EEPROM */
562 int cisco_eeprom_set_byte(struct cisco_eeprom *eeprom,
563 size_t offset,m_uint8_t val)
564 {
565 m_uint16_t tmp;
566
567 if (offset >= (eeprom->len << 1))
568 return(-1);
569
570 tmp = eeprom->data[offset >> 1];
571
572 if (offset & 1)
573 tmp = (tmp & 0xFF00) | val;
574 else
575 tmp = (tmp & 0x00FF) | (val << 8);
576
577 eeprom->data[offset >> 1] = tmp;
578 return(0);
579 }
580
581 /* Get an EEPROM region */
582 int cisco_eeprom_get_region(struct cisco_eeprom *eeprom,size_t offset,
583 m_uint8_t *data,size_t data_len)
584 {
585 size_t i;
586
587 for(i=0;i<data_len;i++) {
588 if (cisco_eeprom_get_byte(eeprom,offset+i,&data[i]) == -1)
589 return(-1);
590 }
591
592 return(0);
593 }
594
595 /* Set an EEPROM region */
596 int cisco_eeprom_set_region(struct cisco_eeprom *eeprom,size_t offset,
597 m_uint8_t *data,size_t data_len)
598 {
599 size_t i;
600
601 for(i=0;i<data_len;i++) {
602 if (cisco_eeprom_set_byte(eeprom,offset+i,data[i]) == -1)
603 return(-1);
604 }
605
606 return(0);
607 }
608
609 /* Get a field of a Cisco EEPROM v4 */
610 int cisco_eeprom_v4_get_field(struct cisco_eeprom *eeprom,m_uint8_t *type,
611 m_uint8_t *len,size_t *offset)
612 {
613 m_uint8_t tmp;
614
615 /* Read field type */
616 if (cisco_eeprom_get_byte(eeprom,(*offset)++,type) == -1)
617 return(-1);
618
619 /* No more field */
620 if (*type == 0xFF)
621 return(0);
622
623 /* Get field length */
624 tmp = (*type >> 6) & 0x03;
625
626 if (tmp == 0x03) {
627 /* Variable len */
628 if (cisco_eeprom_get_byte(eeprom,(*offset)++,&tmp) == -1)
629 return(-1);
630
631 *len = tmp & 0x0F;
632 } else {
633 /* Fixed len */
634 *len = 1 << tmp;
635 }
636
637 return(1);
638 }
639
640 /* Dump a Cisco EEPROM with format version 4 */
641 void cisco_eeprom_v4_dump(struct cisco_eeprom *eeprom)
642 {
643 m_uint8_t type,len,tmp;
644 size_t i,offset=2;
645
646 printf("Dumping EEPROM contents:\n");
647
648 do {
649 /* Read field */
650 if (cisco_eeprom_v4_get_field(eeprom,&type,&len,&offset) < 1)
651 break;
652
653 printf(" Field 0x%2.2x: ",type);
654
655 for(i=0;i<len;i++) {
656 if (cisco_eeprom_get_byte(eeprom,offset+i,&tmp) == -1)
657 break;
658
659 printf("%2.2x ",tmp);
660 }
661
662 printf("\n");
663
664 offset += len;
665 }while(offset < (eeprom->len << 1));
666 }
667
668 /* Returns the offset of the specified field */
669 int cisco_eeprom_v4_find_field(struct cisco_eeprom *eeprom,
670 m_uint8_t field_type,
671 size_t *field_offset)
672 {
673 m_uint8_t type,len;
674 size_t offset=2;
675
676 do {
677 /* Read field */
678 if (cisco_eeprom_v4_get_field(eeprom,&type,&len,&offset) < 1)
679 break;
680
681 if (type == field_type) {
682 *field_offset = offset;
683 return(0);
684 }
685
686 offset += len;
687 }while(offset < (eeprom->len << 1));
688
689 return(-1);
690 }

  ViewVC Help
Powered by ViewVC 1.1.26