1 /*
2  * Copyright (c) 2003 Sun Microsystems, Inc.  All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistribution of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistribution in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * Neither the name of Sun Microsystems, Inc. or the names of
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * This software is provided "AS IS," without a warranty of any kind.
20  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
21  * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
22  * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
23  * SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
24  * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
25  * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.  IN NO EVENT WILL
26  * SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
27  * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
28  * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
29  * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
30  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31  */
32 
33 #ifndef IPMI_HPMFWUPG_H
34 #define IPMI_HPMFWUPG_H
35 
36 #include <inttypes.h>
37 #include <ipmitool/ipmi.h>
38 
39 int ipmi_hpmfwupg_main(struct ipmi_intf *, int, char **);
40 
41 /* Agent version */
42 #define HPMFWUPG_VERSION_MAJOR    1
43 #define HPMFWUPG_VERSION_MINOR    0
44 #define HPMFWUPG_VERSION_SUBMINOR 9
45 
46 /* HPM.1 FIRMWARE UPGRADE COMMANDS (part of PICMG) */
47 #define HPMFWUPG_GET_TARGET_UPG_CAPABILITIES 0x2E
48 #define HPMFWUPG_GET_COMPONENT_PROPERTIES    0x2F
49 #define HPMFWUPG_ABORT_UPGRADE               0x30
50 #define HPMFWUPG_INITIATE_UPGRADE_ACTION     0x31
51 #define HPMFWUPG_UPLOAD_FIRMWARE_BLOCK       0x32
52 #define HPMFWUPG_FINISH_FIRMWARE_UPLOAD      0x33
53 #define HPMFWUPG_GET_UPGRADE_STATUS          0x34
54 #define HPMFWUPG_ACTIVATE_FIRMWARE           0x35
55 #define HPMFWUPG_QUERY_SELFTEST_RESULT       0x36
56 #define HPMFWUPG_QUERY_ROLLBACK_STATUS       0x37
57 #define HPMFWUPG_MANUAL_FIRMWARE_ROLLBACK    0x38
58 
59 /*  HPM.1 SPECIFIC COMPLETION CODES */
60 #define HPMFWUPG_ROLLBACK_COMPLETED   0x00
61 #define HPMFWUPG_COMMAND_IN_PROGRESS  0x80
62 #define HPMFWUPG_NOT_SUPPORTED        0x81
63 #define HPMFWUPG_SIZE_MISMATCH        0x81
64 #define HPMFWUPG_ROLLBACK_FAILURE     0x81
65 #define HPMFWUPG_INV_COMP_MASK        0x81
66 #define HPMFWUPG__ABORT_FAILURE       0x81
67 #define HPMFWUPG_INV_COMP_ID          0x82
68 #define HPMFWUPG_INT_CHECKSUM_ERROR   0x82
69 #define HPMFWUPG_INV_UPLOAD_MODE      0x82
70 #define HPMFWUPG_ROLLBACK_OVERRIDE    0x82
71 #define HPMFWUPG_INV_COMP_PROP        0x83
72 #define HPMFWUPG_FW_MISMATCH          0x83
73 #define HPMFWUPG_ROLLBACK_DENIED      0x83
74 
75 /*
76  * This error code is used as a temporary PATCH to
77  * the latest Open ipmi driver.  This PATCH
78  * will be removed once a new Open IPMI driver is released.
79  * (Buggy version = 39)
80  */
81 #define ENABLE_OPENIPMI_V39_PATCH
82 
83 #ifdef ENABLE_OPENIPMI_V39_PATCH
84 # define RETRY_COUNT_MAX 3
85 static int errorCount;
86 # define HPMFWUPG_IS_RETRYABLE(error)                                          \
87  ((((error==0x83)||(error==0x82)||(error==0x80)) && (errorCount++<RETRY_COUNT_MAX))?TRUE:FALSE)
88 #else
89 # define HPMFWUPG_IS_RETRYABLE(error) FALSE
90 #endif
91 
92 /* HPM FIRMWARE UPGRADE GENERAL DEFINITIONS */
93 #define HPMFWUPG_PICMG_IDENTIFIER         0
94 #define HPMFWUPG_VERSION_SIZE             6
95 #define HPMFWUPG_DESC_STRING_LENGTH       12
96 #define HPMFWUPG_DEFAULT_INACCESS_TIMEOUT 60 /* sec */
97 #define HPMFWUPG_DEFAULT_UPGRADE_TIMEOUT  60 /* sec */
98 #define HPMFWUPG_MD5_SIGNATURE_LENGTH     16
99 
100 /* Component IDs */
101 typedef enum eHpmfwupgComponentId {
102 	HPMFWUPG_COMPONENT_ID_0 = 0,
103 	HPMFWUPG_COMPONENT_ID_1,
104 	HPMFWUPG_COMPONENT_ID_2,
105 	HPMFWUPG_COMPONENT_ID_3,
106 	HPMFWUPG_COMPONENT_ID_4,
107 	HPMFWUPG_COMPONENT_ID_5,
108 	HPMFWUPG_COMPONENT_ID_6,
109 	HPMFWUPG_COMPONENT_ID_7,
110 	HPMFWUPG_COMPONENT_ID_MAX
111 } tHpmfwupgComponentId;
112 
113 #ifdef HAVE_PRAGMA_PACK
114 # pragma pack(1)
115 #endif
116 struct HpmfwupgComponentBitMask {
117 	union {
118 		unsigned char byte;
119 		struct {
120 #ifdef WORDS_BIGENDIAN
121 			unsigned char component7 : 1;
122 			unsigned char component6 : 1;
123 			unsigned char component5 : 1;
124 			unsigned char component4 : 1;
125 			unsigned char component3 : 1;
126 			unsigned char component2 : 1;
127 			unsigned char component1 : 1;
128 			unsigned char component0 : 1;
129 #else
130 			unsigned char component0 : 1;
131 			unsigned char component1 : 1;
132 			unsigned char component2 : 1;
133 			unsigned char component3 : 1;
134 			unsigned char component4 : 1;
135 			unsigned char component5 : 1;
136 			unsigned char component6 : 1;
137 			unsigned char component7 : 1;
138 #endif
139 		} ATTRIBUTE_PACKING bitField;
140 	} ATTRIBUTE_PACKING ComponentBits;
141 } ATTRIBUTE_PACKING;
142 #ifdef HAVE_PRAGMA_PACK
143 # pragma pack(0)
144 #endif
145 
146 
147 static const int HPMFWUPG_SUCCESS = 0;
148 static const int HPMFWUPG_ERROR = -1;
149 /* Upload firmware specific error codes */
150 static const int HPMFWUPG_UPLOAD_BLOCK_LENGTH = 1;
151 static const int HPMFWUPG_UPLOAD_RETRY = 2;
152 
153 
154 /* TARGET UPGRADE CAPABILITIES DEFINITIONS */
155 #ifdef HAVE_PRAGMA_PACK
156 # pragma pack(1)
157 #endif
158 struct HpmfwupgGetTargetUpgCapabilitiesReq {
159 	unsigned char picmgId;
160 } ATTRIBUTE_PACKING;
161 #ifdef HAVE_PRAGMA_PACK
162 # pragma pack(0)
163 #endif
164 
165 #ifdef HAVE_PRAGMA_PACK
166 # pragma pack(1)
167 #endif
168 struct HpmfwupgGetTargetUpgCapabilitiesResp {
169 	unsigned char picmgId;
170 	unsigned char hpmVersion;
171 	union {
172 		unsigned char byte;
173 		struct {
174 #if WORDS_BIGENDIAN
175 			unsigned char fwUpgUndesirable    : 1;
176 			unsigned char autRollbackOverride : 1;
177 			unsigned char ipmcDegradedDurinUpg: 1;
178 			unsigned char deferActivation     : 1;
179 			unsigned char servAffectDuringUpg : 1;
180 			unsigned char manualRollback      : 1;
181 			unsigned char autRollback         : 1;
182 			unsigned char ipmcSelftestCap     : 1;
183 #else
184 			unsigned char ipmcSelftestCap     : 1;
185 			unsigned char autRollback         : 1;
186 			unsigned char manualRollback      : 1;
187 			unsigned char servAffectDuringUpg : 1;
188 			unsigned char deferActivation     : 1;
189 			unsigned char ipmcDegradedDurinUpg: 1;
190 			unsigned char autRollbackOverride : 1;
191 			unsigned char fwUpgUndesirable    : 1;
192 #endif
193 		} ATTRIBUTE_PACKING bitField;
194 	} ATTRIBUTE_PACKING GlobalCapabilities;
195 	unsigned char upgradeTimeout;
196 	unsigned char selftestTimeout;
197 	unsigned char rollbackTimeout;
198 	unsigned char inaccessTimeout;
199 	struct HpmfwupgComponentBitMask componentsPresent;
200 } ATTRIBUTE_PACKING;
201 #ifdef HAVE_PRAGMA_PACK
202 # pragma pack(0)
203 #endif
204 
205 #ifdef HAVE_PRAGMA_PACK
206 # pragma pack(1)
207 #endif
208 struct HpmfwupgGetTargetUpgCapabilitiesCtx {
209 	struct HpmfwupgGetTargetUpgCapabilitiesReq req;
210 	struct HpmfwupgGetTargetUpgCapabilitiesResp resp;
211 } ATTRIBUTE_PACKING;
212 #ifdef HAVE_PRAGMA_PACK
213 # pragma pack(0)
214 #endif
215 
216 /* COMPONENT PROPERTIES DEFINITIONS */
217 typedef enum eHpmfwupgCompPropertiesSelect {
218 	HPMFWUPG_COMP_GEN_PROPERTIES = 0,
219 	HPMFWUPG_COMP_CURRENT_VERSION,
220 	HPMFWUPG_COMP_DESCRIPTION_STRING,
221 	HPMFWUPG_COMP_ROLLBACK_FIRMWARE_VERSION,
222 	HPMFWUPG_COMP_DEFERRED_FIRMWARE_VERSION,
223 	HPMFWUPG_COMP_RESERVED,
224 	HPMFWUPG_COMP_OEM_PROPERTIES = 192
225 } tHpmfwupgCompPropertiesSelect;
226 
227 #ifdef HAVE_PRAGMA_PACK
228 # pragma pack(1)
229 #endif
230 struct HpmfwupgGetComponentPropertiesReq {
231 	unsigned char picmgId;
232 	unsigned char componentId;
233 	unsigned char selector;
234 } ATTRIBUTE_PACKING;
235 #ifdef HAVE_PRAGMA_PACK
236 # pragma pack(0)
237 #endif
238 
239 #ifdef HAVE_PRAGMA_PACK
240 # pragma pack(1)
241 #endif
242 struct HpmfwupgGetGeneralPropResp {
243 	unsigned char picmgId;
244 	union {
245 		unsigned char byte;
246 		struct {
247 #if WORDS_BIGENDIAN
248 			unsigned char reserved           : 2;
249 			unsigned char payloadColdReset   : 1;
250 			unsigned char deferredActivation : 1;
251 			unsigned char comparisonSupport  : 1;
252 			unsigned char preparationSupport : 1;
253 			unsigned char rollbackBackup     : 2;
254 #else
255 			unsigned char rollbackBackup     : 2;
256 			unsigned char preparationSupport : 1;
257 			unsigned char comparisonSupport  : 1;
258 			unsigned char deferredActivation : 1;
259 			unsigned char payloadColdReset   : 1;
260 			unsigned char reserved           : 2;
261 #endif
262 		} ATTRIBUTE_PACKING bitfield;
263 	} ATTRIBUTE_PACKING GeneralCompProperties;
264 } ATTRIBUTE_PACKING;
265 #ifdef HAVE_PRAGMA_PACK
266 # pragma pack(0)
267 #endif
268 
269 #ifdef HAVE_PRAGMA_PACK
270 # pragma pack(1)
271 #endif
272 struct HpmfwupgGetCurrentVersionResp {
273 	unsigned char picmgId;
274 	unsigned char currentVersion[HPMFWUPG_VERSION_SIZE];
275 } ATTRIBUTE_PACKING;
276 #ifdef HAVE_PRAGMA_PACK
277 # pragma pack(0)
278 #endif
279 
280 #ifdef HAVE_PRAGMA_PACK
281 # pragma pack(1)
282 #endif
283 struct HpmfwupgGetDescStringResp {
284 	unsigned char picmgId;
285 	char descString[HPMFWUPG_DESC_STRING_LENGTH];
286 } ATTRIBUTE_PACKING;
287 #ifdef HAVE_PRAGMA_PACK
288 # pragma pack(0)
289 #endif
290 
291 #ifdef HAVE_PRAGMA_PACK
292 # pragma pack(1)
293 #endif
294 struct HpmfwupgGetRollbackFwVersionResp {
295 	unsigned char picmgId;
296 	unsigned char rollbackFwVersion[HPMFWUPG_VERSION_SIZE];
297 } ATTRIBUTE_PACKING;
298 #ifdef HAVE_PRAGMA_PACK
299 # pragma pack(0)
300 #endif
301 
302 #ifdef HAVE_PRAGMA_PACK
303 # pragma pack(1)
304 #endif
305 struct HpmfwupgGetDeferredFwVersionResp {
306 	unsigned char picmgId;
307 	unsigned char deferredFwVersion[HPMFWUPG_VERSION_SIZE];
308 } ATTRIBUTE_PACKING;
309 #ifdef HAVE_PRAGMA_PACK
310 # pragma pack(0)
311 #endif
312 
313 /* GetComponentProperties - OEM properties (192) */
314 #define HPMFWUPG_OEM_LENGTH 4
315 #ifdef HAVE_PRAGMA_PACK
316 # pragma pack(1)
317 #endif
318 struct HpmfwupgGetOemProperties {
319 	unsigned char picmgId;
320 	unsigned char oemRspData[HPMFWUPG_OEM_LENGTH];
321 } ATTRIBUTE_PACKING;
322 #ifdef HAVE_PRAGMA_PACK
323 # pragma pack(0)
324 #endif
325 
326 #ifdef HAVE_PRAGMA_PACK
327 # pragma pack(1)
328 #endif
329 struct HpmfwupgGetComponentPropertiesResp {
330 	union {
331 		struct HpmfwupgGetGeneralPropResp       generalPropResp;
332 		struct HpmfwupgGetCurrentVersionResp    currentVersionResp;
333 		struct HpmfwupgGetDescStringResp        descStringResp;
334 		struct HpmfwupgGetRollbackFwVersionResp rollbackFwVersionResp;
335 		struct HpmfwupgGetDeferredFwVersionResp deferredFwVersionResp;
336 		struct HpmfwupgGetOemProperties         oemProperties;
337 	} ATTRIBUTE_PACKING Response;
338 } ATTRIBUTE_PACKING;
339 #ifdef HAVE_PRAGMA_PACK
340 # pragma pack(0)
341 #endif
342 
343 #ifdef HAVE_PRAGMA_PACK
344 # pragma pack(1)
345 #endif
346 struct HpmfwupgGetComponentPropertiesCtx {
347 	struct HpmfwupgGetComponentPropertiesReq  req;
348 	struct HpmfwupgGetComponentPropertiesResp resp;
349 } ATTRIBUTE_PACKING;
350 #ifdef HAVE_PRAGMA_PACK
351 # pragma pack(0)
352 #endif
353 
354 /*  ABORT UPGRADE DEFINITIONS */
355 #ifdef HAVE_PRAGMA_PACK
356 # pragma pack(1)
357 #endif
358 struct HpmfwupgAbortUpgradeReq {
359 	unsigned char picmgId;
360 } ATTRIBUTE_PACKING;
361 #ifdef HAVE_PRAGMA_PACK
362 # pragma pack(0)
363 #endif
364 
365 #ifdef HAVE_PRAGMA_PACK
366 # pragma pack(1)
367 #endif
368 struct HpmfwupgAbortUpgradeResp {
369 	unsigned char picmgId;
370 } ATTRIBUTE_PACKING;
371 #ifdef HAVE_PRAGMA_PACK
372 # pragma pack(0)
373 #endif
374 
375 #ifdef HAVE_PRAGMA_PACK
376 # pragma pack(1)
377 #endif
378 struct HpmfwupgAbortUpgradeCtx {
379 	struct HpmfwupgAbortUpgradeReq  req;
380 	struct HpmfwupgAbortUpgradeResp resp;
381 } ATTRIBUTE_PACKING;
382 #ifdef HAVE_PRAGMA_PACK
383 # pragma pack(0)
384 #endif
385 
386 /* UPGRADE ACTIONS DEFINITIONS */
387 typedef enum eHpmfwupgUpgradeAction {
388 	HPMFWUPG_UPGRADE_ACTION_BACKUP = 0,
389 	HPMFWUPG_UPGRADE_ACTION_PREPARE,
390 	HPMFWUPG_UPGRADE_ACTION_UPGRADE,
391 	HPMFWUPG_UPGRADE_ACTION_COMPARE,
392 	HPMFWUPG_UPGRADE_ACTION_INVALID = 0xff
393 }  tHpmfwupgUpgradeAction;
394 
395 #ifdef HAVE_PRAGMA_PACK
396 # pragma pack(1)
397 #endif
398 struct HpmfwupgInitiateUpgradeActionReq {
399 	unsigned char picmgId;
400 	struct HpmfwupgComponentBitMask componentsMask;
401 	unsigned char upgradeAction;
402 } ATTRIBUTE_PACKING;
403 #ifdef HAVE_PRAGMA_PACK
404 # pragma pack(0)
405 #endif
406 
407 #ifdef HAVE_PRAGMA_PACK
408 # pragma pack(1)
409 #endif
410 struct HpmfwupgInitiateUpgradeActionResp {
411 	unsigned char picmgId;
412 } ATTRIBUTE_PACKING;
413 #ifdef HAVE_PRAGMA_PACK
414 # pragma pack(0)
415 #endif
416 
417 #ifdef HAVE_PRAGMA_PACK
418 # pragma pack(1)
419 #endif
420 struct HpmfwupgInitiateUpgradeActionCtx {
421 	struct HpmfwupgInitiateUpgradeActionReq  req;
422 	struct HpmfwupgInitiateUpgradeActionResp resp;
423 } ATTRIBUTE_PACKING;
424 #ifdef HAVE_PRAGMA_PACK
425 # pragma pack(0)
426 #endif
427 
428 /* UPLOAD FIRMWARE BLOCK DEFINITIONS */
429 #define HPMFWUPG_SEND_DATA_COUNT_KCS   30
430 #define HPMFWUPG_SEND_DATA_COUNT_LAN   25
431 #define HPMFWUPG_SEND_DATA_COUNT_IPMB  26
432 #define HPMFWUPG_SEND_DATA_COUNT_IPMBL 26
433 
434 #ifdef HAVE_PRAGMA_PACK
435 # pragma pack(1)
436 #endif
437 struct HpmfwupgUploadFirmwareBlockReq {
438 	unsigned char picmgId;
439 	unsigned char blockNumber;
440 	unsigned char data[0];
441 } ATTRIBUTE_PACKING;
442 #ifdef HAVE_PRAGMA_PACK
443 # pragma pack(0)
444 #endif
445 
446 
447 #ifdef HAVE_PRAGMA_PACK
448 # pragma pack(1)
449 #endif
450 struct HpmfwupgUploadFirmwareBlockResp {
451 	unsigned char picmgId;
452 } ATTRIBUTE_PACKING;
453 #ifdef HAVE_PRAGMA_PACK
454 # pragma pack(0)
455 #endif
456 
457 #ifdef HAVE_PRAGMA_PACK
458 # pragma pack(1)
459 #endif
460 struct HpmfwupgUploadFirmwareBlockCtx {
461 	struct HpmfwupgUploadFirmwareBlockReq * req;
462 	struct HpmfwupgUploadFirmwareBlockResp resp;
463 } ATTRIBUTE_PACKING;
464 #ifdef HAVE_PRAGMA_PACK
465 # pragma pack(0)
466 #endif
467 
468 /* FINISH FIRMWARE UPLOAD DEFINITIONS */
469 #define HPMFWUPG_IMAGE_SIZE_BYTE_COUNT 4
470 
471 #ifdef HAVE_PRAGMA_PACK
472 # pragma pack(1)
473 #endif
474 struct HpmfwupgFinishFirmwareUploadReq {
475 	unsigned char picmgId;
476 	unsigned char componentId;
477 	unsigned char imageLength[HPMFWUPG_IMAGE_SIZE_BYTE_COUNT];
478 } ATTRIBUTE_PACKING;
479 #ifdef HAVE_PRAGMA_PACK
480 # pragma pack(0)
481 #endif
482 
483 #ifdef HAVE_PRAGMA_PACK
484 # pragma pack(1)
485 #endif
486 struct HpmfwupgFinishFirmwareUploadResp {
487 	unsigned char picmgId;
488 } ATTRIBUTE_PACKING;
489 #ifdef HAVE_PRAGMA_PACK
490 # pragma pack(0)
491 #endif
492 
493 #ifdef HAVE_PRAGMA_PACK
494 # pragma pack(1)
495 #endif
496 struct HpmfwupgFinishFirmwareUploadCtx {
497 	struct HpmfwupgFinishFirmwareUploadReq  req;
498 	struct HpmfwupgFinishFirmwareUploadResp resp;
499 } ATTRIBUTE_PACKING;
500 #ifdef HAVE_PRAGMA_PACK
501 # pragma pack(0)
502 #endif
503 
504 /* ACTIVATE FW DEFINITIONS */
505 #ifdef HAVE_PRAGMA_PACK
506 # pragma pack(1)
507 #endif
508 struct HpmfwupgActivateFirmwareReq {
509 	unsigned char picmgId;
510 	unsigned char rollback_override;
511 } ATTRIBUTE_PACKING;
512 #ifdef HAVE_PRAGMA_PACK
513 # pragma pack(0)
514 #endif
515 
516 #ifdef HAVE_PRAGMA_PACK
517 # pragma pack(1)
518 #endif
519 struct HpmfwupgActivateFirmwareResp {
520 	unsigned char picmgId;
521 } ATTRIBUTE_PACKING;
522 #ifdef HAVE_PRAGMA_PACK
523 # pragma pack(0)
524 #endif
525 
526 #ifdef HAVE_PRAGMA_PACK
527 # pragma pack(1)
528 #endif
529 struct HpmfwupgActivateFirmwareCtx {
530 	struct HpmfwupgActivateFirmwareReq  req;
531 	struct HpmfwupgActivateFirmwareResp resp;
532 } ATTRIBUTE_PACKING;
533 #ifdef HAVE_PRAGMA_PACK
534 # pragma pack(0)
535 #endif
536 
537 /* GET UPGRADE STATUS DEFINITIONS */
538 #ifdef HAVE_PRAGMA_PACK
539 # pragma pack(1)
540 #endif
541 struct HpmfwupgGetUpgradeStatusReq {
542 	unsigned char picmgId;
543 } ATTRIBUTE_PACKING;
544 #ifdef HAVE_PRAGMA_PACK
545 # pragma pack(0)
546 #endif
547 
548 #ifdef HAVE_PRAGMA_PACK
549 # pragma pack(1)
550 #endif
551 struct HpmfwupgGetUpgradeStatusResp {
552 	unsigned char picmgId;
553 	unsigned char cmdInProcess;
554 	unsigned char lastCmdCompCode;
555 } ATTRIBUTE_PACKING;
556 #ifdef HAVE_PRAGMA_PACK
557 # pragma pack(0)
558 #endif
559 
560 #ifdef HAVE_PRAGMA_PACK
561 # pragma pack(1)
562 #endif
563 struct HpmfwupgGetUpgradeStatusCtx {
564 	struct HpmfwupgGetUpgradeStatusReq  req;
565 	struct HpmfwupgGetUpgradeStatusResp resp;
566 } ATTRIBUTE_PACKING;
567 #ifdef HAVE_PRAGMA_PACK
568 # pragma pack(0)
569 #endif
570 
571 /* MANUAL FW ROLLBACK DEFINITIONS */
572 #ifdef HAVE_PRAGMA_PACK
573 # pragma pack(1)
574 #endif
575 struct HpmfwupgManualFirmwareRollbackReq {
576 	unsigned char picmgId;
577 } ATTRIBUTE_PACKING;
578 #ifdef HAVE_PRAGMA_PACK
579 # pragma pack(0)
580 #endif
581 
582 #ifdef HAVE_PRAGMA_PACK
583 # pragma pack(1)
584 #endif
585 struct HpmfwupgManualFirmwareRollbackResp {
586 	unsigned char picmgId;
587 } ATTRIBUTE_PACKING;
588 #ifdef HAVE_PRAGMA_PACK
589 # pragma pack(0)
590 #endif
591 
592 #ifdef HAVE_PRAGMA_PACK
593 # pragma pack(0)
594 #endif
595 struct HpmfwupgManualFirmwareRollbackCtx {
596 	struct HpmfwupgManualFirmwareRollbackReq  req;
597 	struct HpmfwupgManualFirmwareRollbackResp resp;
598 } ATTRIBUTE_PACKING;
599 #ifdef HAVE_PRAGMA_PACK
600 # pragma pack(0)
601 #endif
602 
603 /* QUERY ROLLBACK STATUS DEFINITIONS */
604 #ifdef HAVE_PRAGMA_PACK
605 # pragma pack(1)
606 #endif
607 struct HpmfwupgQueryRollbackStatusReq {
608 	unsigned char picmgId;
609 } ATTRIBUTE_PACKING;
610 #ifdef HAVE_PRAGMA_PACK
611 # pragma pack(0)
612 #endif
613 
614 #ifdef HAVE_PRAGMA_PACK
615 # pragma pack(1)
616 #endif
617 struct HpmfwupgQueryRollbackStatusResp {
618 	unsigned char picmgId;
619 	struct HpmfwupgComponentBitMask rollbackComp;
620 } ATTRIBUTE_PACKING;
621 #ifdef HAVE_PRAGMA_PACK
622 # pragma pack(0)
623 #endif
624 
625 #ifdef HAVE_PRAGMA_PACK
626 # pragma pack(1)
627 #endif
628 struct HpmfwupgQueryRollbackStatusCtx {
629 	struct HpmfwupgQueryRollbackStatusReq  req;
630 	struct HpmfwupgQueryRollbackStatusResp resp;
631 } ATTRIBUTE_PACKING;
632 #ifdef HAVE_PRAGMA_PACK
633 # pragma pack(0)
634 #endif
635 
636 /* QUERY SELF TEST RESULT DEFINITIONS */
637 #ifdef HAVE_PRAGMA_PACK
638 # pragma pack(1)
639 #endif
640 struct  HpmfwupgQuerySelftestResultReq {
641 	unsigned char picmgId;
642 } ATTRIBUTE_PACKING;
643 #ifdef HAVE_PRAGMA_PACK
644 # pragma pack(0)
645 #endif
646 
647 #ifdef HAVE_PRAGMA_PACK
648 # pragma pack(1)
649 #endif
650 struct  HpmfwupgQuerySelftestResultResp {
651 	unsigned char picmgId;
652 	unsigned char result1;
653 	unsigned char result2;
654 } ATTRIBUTE_PACKING;
655 #ifdef HAVE_PRAGMA_PACK
656 # pragma pack(0)
657 #endif
658 
659 #ifdef HAVE_PRAGMA_PACK
660 # pragma pack(1)
661 #endif
662 struct HpmfwupgQuerySelftestResultCtx {
663 	struct HpmfwupgQuerySelftestResultReq  req;
664 	struct HpmfwupgQuerySelftestResultResp resp;
665 } ATTRIBUTE_PACKING;
666 #ifdef HAVE_PRAGMA_PACK
667 # pragma pack(0)
668 #endif
669 
670 /* HPM.1 IMAGE DEFINITIONS */
671 #define HPMFWUPG_HEADER_SIGNATURE_LENGTH 8
672 #define HPMFWUPG_MANUFATURER_ID_LENGTH   3
673 #define HPMFWUPG_PRODUCT_ID_LENGTH       2
674 #define HPMFWUPG_TIME_LENGTH             4
675 #define HPMFWUPG_TIMEOUT_LENGTH          1
676 #define HPMFWUPG_COMP_REVISION_LENGTH    2
677 #define HPMFWUPG_FIRM_REVISION_LENGTH    6
678 #define HPMFWUPG_IMAGE_HEADER_VERSION    0
679 #define HPMFWUPG_IMAGE_SIGNATURE "PICMGFWU"
680 
681 #ifdef HAVE_PRAGMA_PACK
682 #pragma pack(1)
683 #endif
684 struct HpmfwupgImageHeader {
685 	char           signature[HPMFWUPG_HEADER_SIGNATURE_LENGTH];
686 	unsigned char  formatVersion;
687 	unsigned char  deviceId;
688 	unsigned char  manId[HPMFWUPG_MANUFATURER_ID_LENGTH];
689 	unsigned char  prodId[HPMFWUPG_PRODUCT_ID_LENGTH];
690 	unsigned char  time[HPMFWUPG_TIME_LENGTH];
691 	union {
692 		struct {
693 #if WORDS_BIGENDIAN
694 			unsigned char imageSelfTest   : 1;
695 			unsigned char autRollback     : 1;
696 			unsigned char manRollback     : 1;
697 			unsigned char servAffected    : 1;
698 			unsigned char reserved        : 4;
699 #else
700 			unsigned char reserved        : 4;
701 			unsigned char servAffected    : 1;
702 			unsigned char manRollback     : 1;
703 			unsigned char autRollback     : 1;
704 			unsigned char imageSelfTest   : 1;
705 #endif
706 		} ATTRIBUTE_PACKING bitField;
707 		unsigned char byte;
708 	}ATTRIBUTE_PACKING imageCapabilities;
709 	struct HpmfwupgComponentBitMask components;
710 	unsigned char  selfTestTimeout;
711 	unsigned char  rollbackTimeout;
712 	unsigned char  inaccessTimeout;
713 	unsigned char  compRevision[HPMFWUPG_COMP_REVISION_LENGTH];
714 	unsigned char  firmRevision[HPMFWUPG_FIRM_REVISION_LENGTH];
715 	unsigned short oemDataLength;
716 } ATTRIBUTE_PACKING;
717 #ifdef HAVE_PRAGMA_PACK
718 # pragma pack(0)
719 #endif
720 
721 #define HPMFWUPG_DESCRIPTION_LENGTH   21
722 
723 #ifdef HAVE_PRAGMA_PACK
724 # pragma pack(1)
725 #endif
726 struct HpmfwupgActionRecord {
727 	unsigned char  actionType;
728 	struct HpmfwupgComponentBitMask components;
729 	unsigned char  checksum;
730 } ATTRIBUTE_PACKING;
731 #ifdef HAVE_PRAGMA_PACK
732 # pragma pack(0)
733 #endif
734 
735 #define HPMFWUPG_FIRMWARE_SIZE_LENGTH 4
736 
737 #ifdef HAVE_PRAGMA_PACK
738 # pragma pack(1)
739 #endif
740 struct HpmfwupgFirmwareImage {
741 	unsigned char version[HPMFWUPG_FIRM_REVISION_LENGTH];
742 	char          desc[HPMFWUPG_DESCRIPTION_LENGTH];
743 	unsigned char length[HPMFWUPG_FIRMWARE_SIZE_LENGTH];
744 } ATTRIBUTE_PACKING;
745 #ifdef HAVE_PRAGMA_PACK
746 # pragma pack(0)
747 #endif
748 
749 #ifdef HAVE_PRAGMA_PACK
750 # pragma pack(1)
751 #endif
752 struct HpmfwupgUpgradeCtx {
753 	struct HpmfwupgComponentBitMask compUpdateMask;
754 	unsigned int   imageSize;
755 	unsigned char* pImageData;
756 	unsigned char  componentId;
757 	struct HpmfwupgGetTargetUpgCapabilitiesResp targetCap;
758 	struct HpmfwupgGetGeneralPropResp genCompProp[HPMFWUPG_COMPONENT_ID_MAX];
759 	struct ipm_devid_rsp devId;
760 } ATTRIBUTE_PACKING;
761 #ifdef HAVE_PRAGMA_PACK
762 # pragma pack(0)
763 #endif
764 
765 typedef enum eHpmfwupgActionType {
766 	HPMFWUPG_ACTION_BACKUP_COMPONENTS = 0,
767 	HPMFWUPG_ACTION_PREPARE_COMPONENTS,
768 	HPMFWUPG_ACTION_UPLOAD_FIRMWARE,
769 	HPMFWUPG_ACTION_RESERVED = 0xFF
770 } tHpmfwupgActionType;
771 
772 /* FUNCTIONS PROTOTYPES */
773 #define HPMFWUPG_MAJORMINOR_VERSION_SIZE        2
774 
775 /* Options added for user to check the version and to view both the FILE and
776  * TARGET Version
777  */
778 #define VIEW_MODE                     0x01
779 #define DEBUG_MODE                    0x02
780 #define FORCE_MODE                    0x04
781 #define COMPARE_MODE                  0x08
782 
783 typedef struct _VERSIONINFO {
784 	unsigned char componentId;
785 	unsigned char targetMajor;
786 	unsigned char targetMinor;
787 	unsigned char targetAux[4];
788 	unsigned char rollbackMajor;
789 	unsigned char rollbackMinor;
790 	unsigned char rollbackAux[4];
791 	unsigned char deferredMajor;
792 	unsigned char deferredMinor;
793 	unsigned char deferredAux[4];
794 	unsigned char imageMajor;
795 	unsigned char imageMinor;
796 	unsigned char imageAux[4];
797 	unsigned char coldResetRequired;
798 	unsigned char rollbackSupported;
799 	unsigned char deferredActivationSupported;
800 	char descString[HPMFWUPG_DESC_STRING_LENGTH + 1];
801 }VERSIONINFO, *PVERSIONINFO;
802 
803 VERSIONINFO gVersionInfo[HPMFWUPG_COMPONENT_ID_MAX];
804 
805 #define TARGET_VER (0x01)
806 #define ROLLBACK_VER (0x02)
807 #define IMAGE_VER (0x04)
808 
809 #endif /* IPMI_KFWUM_H */
810