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_KFWUM_H 34 # define IPMI_KFWUM_H 35 36 #include <inttypes.h> 37 #include <ipmitool/ipmi.h> 38 39 /* KFWUM Version */ 40 # define VER_MAJOR 1 41 # define VER_MINOR 3 42 /* Minimum size (IPMB/IOL/old protocol) */ 43 # define KFWUM_SMALL_BUFFER 32 44 /* Maximum size on KCS interface */ 45 # define KFWUM_BIG_BUFFER 32 46 # define MAX_BUFFER_SIZE 1024*16 47 48 /* 3 address + 1 size + 1 checksum + 1 command */ 49 # define KFWUM_OLD_CMD_OVERHEAD 6 50 /* 1 sequence + 1 size + 1 checksum + 1 command */ 51 # define KFWUM_NEW_CMD_OVERHEAD 4 52 # define KFWUM_PAGE_SIZE 256 53 54 # define FWUM_SAVE_FIRMWARE_NO_RESPONSE_LIMIT 6 55 # define FWUM_MAX_UPLOAD_RETRY 6 56 57 # define TRACE_LOG_CHUNK_COUNT 7 58 # define TRACE_LOG_CHUNK_SIZE 7 59 # define TRACE_LOG_ATT_COUNT 3 60 61 # define IN_FIRMWARE_INFO_OFFSET_LOCATION 0x5a0 62 # define IN_FIRMWARE_INFO_SIZE 20 63 # define IN_FIRMWARE_INFO_OFFSET_FILE_SIZE 0 64 # define IN_FIRMWARE_INFO_OFFSET_CHECKSUM 4 65 # define IN_FIRMWARE_INFO_OFFSET_BOARD_ID 6 66 # define IN_FIRMWARE_INFO_OFFSET_DEVICE_ID 8 67 # define IN_FIRMWARE_INFO_OFFSET_TABLE_VERSION 9 68 # define IN_FIRMWARE_INFO_OFFSET_IMPLEMENT_REV 10 69 # define IN_FIRMWARE_INFO_OFFSET_VER_MAJOROR 11 70 # define IN_FIRMWARE_INFO_OFFSET_VER_MINORSUB 12 71 # define IN_FIRMWARE_INFO_OFFSET_SDR_REV 13 72 # define IN_FIRMWARE_INFO_OFFSET_IANA0 14 73 # define IN_FIRMWARE_INFO_OFFSET_IANA1 15 74 # define IN_FIRMWARE_INFO_OFFSET_IANA2 16 75 76 # define KWUM_GET_BYTE_AT_OFFSET(pBuffer,os) pBuffer[os] 77 78 int ipmi_fwum_main(struct ipmi_intf *, int, char **); 79 80 typedef enum eKFWUM_BoardList 81 { 82 KFWUM_BOARD_KONTRON_UNKNOWN = 0, 83 KFWUM_BOARD_KONTRON_5002 = 5002, 84 } tKFWUM_BoardList; 85 86 typedef struct sKFWUM_BoardInfo 87 { 88 tKFWUM_BoardList boardId; 89 IPMI_OEM iana; 90 } tKFWUM_BoardInfo; 91 92 typedef enum eKFWUM_DownloadType 93 { 94 KFWUM_DOWNLOAD_TYPE_ADDRESS = 0, 95 KFWUM_DOWNLOAD_TYPE_SEQUENCE, 96 } tKFWUM_DownloadType; 97 98 typedef enum eKFWUM_DownloadBuffferType 99 { 100 KFWUM_SMALL_BUFFER_TYPE = 0, 101 KFUMW_BIG_BUFFER_TYPE 102 } tKFWUM_DownloadBuffferType; 103 104 typedef struct sKFWUM_InFirmwareInfo 105 { 106 unsigned long fileSize; 107 unsigned short checksum; 108 unsigned short sumToRemoveFromChecksum; 109 /* Since the checksum is added in the bin 110 * after the checksum is calculated, we 111 * need to remove the each byte value. This 112 * byte will contain the addition of both bytes 113 */ 114 tKFWUM_BoardList boardId; 115 unsigned char deviceId; 116 unsigned char tableVers; 117 unsigned char implRev; 118 unsigned char versMajor; 119 unsigned char versMinor; 120 unsigned char versSubMinor; 121 unsigned char sdrRev; 122 IPMI_OEM iana; 123 } tKFWUM_InFirmwareInfo; 124 125 typedef struct sKFWUM_SaveFirmwareInfo 126 { 127 tKFWUM_DownloadType downloadType; 128 unsigned char bufferSize; 129 unsigned char overheadSize; 130 } tKFWUM_SaveFirmwareInfo; 131 132 /* COMMANDS */ 133 # ifdef HAVE_PRAGMA_PACK 134 # pragma pack(1) 135 # endif 136 struct KfwumGetInfoResp { 137 unsigned char protocolRevision; 138 unsigned char controllerDeviceId; 139 struct { 140 unsigned char mode:1; 141 unsigned char seqAdd:1; 142 unsigned char res : 6; 143 } byte; 144 unsigned char firmRev1; 145 unsigned char firmRev2; 146 unsigned char numBank; 147 } ATTRIBUTE_PACKING; 148 # ifdef HAVE_PRAGMA_PACK 149 # pragma pack(0) 150 # endif 151 152 # ifdef HAVE_PRAGMA_PACK 153 # pragma pack(1) 154 # endif 155 struct KfwumGetStatusResp { 156 unsigned char bankState; 157 unsigned char firmLengthLSB; 158 unsigned char firmLengthMid; 159 unsigned char firmLengthMSB; 160 unsigned char firmRev1; 161 unsigned char firmRev2; 162 unsigned char firmRev3; 163 } ATTRIBUTE_PACKING; 164 # ifdef HAVE_PRAGMA_PACK 165 # pragma pack(0) 166 # endif 167 168 # ifdef HAVE_PRAGMA_PACK 169 # pragma pack(1) 170 # endif 171 struct KfwumManualRollbackReq { 172 unsigned char type; 173 } ATTRIBUTE_PACKING; 174 # ifdef HAVE_PRAGMA_PACK 175 # pragma pack(0) 176 # endif 177 178 # ifdef HAVE_PRAGMA_PACK 179 # pragma pack(1) 180 # endif 181 struct KfwumStartFirmwareDownloadReq { 182 unsigned char lengthLSB; 183 unsigned char lengthMid; 184 unsigned char lengthMSB; 185 unsigned char paddingLSB; 186 unsigned char paddingMSB; 187 unsigned char useSequence; 188 } ATTRIBUTE_PACKING; 189 # ifdef HAVE_PRAGMA_PACK 190 # pragma pack(0) 191 # endif 192 193 # ifdef HAVE_PRAGMA_PACK 194 # pragma pack(1) 195 # endif 196 struct KfwumStartFirmwareDownloadResp { 197 unsigned char bank; 198 } ATTRIBUTE_PACKING; 199 # ifdef HAVE_PRAGMA_PACK 200 # pragma pack(0) 201 # endif 202 203 # ifdef HAVE_PRAGMA_PACK 204 # pragma pack(1) 205 # endif 206 struct KfwumSaveFirmwareAddressReq 207 { 208 unsigned char addressLSB; 209 unsigned char addressMid; 210 unsigned char addressMSB; 211 unsigned char numBytes; 212 unsigned char txBuf[KFWUM_SMALL_BUFFER-KFWUM_OLD_CMD_OVERHEAD]; 213 } ATTRIBUTE_PACKING; 214 # ifdef HAVE_PRAGMA_PACK 215 # pragma pack(0) 216 # endif 217 218 # ifdef HAVE_PRAGMA_PACK 219 # pragma pack(1) 220 # endif 221 struct KfwumSaveFirmwareSequenceReq 222 { 223 unsigned char sequenceNumber; 224 unsigned char txBuf[KFWUM_BIG_BUFFER]; 225 } ATTRIBUTE_PACKING; 226 # ifdef HAVE_PRAGMA_PACK 227 # pragma pack(0) 228 # endif 229 230 # ifdef HAVE_PRAGMA_PACK 231 # pragma pack(1) 232 # endif 233 struct KfwumFinishFirmwareDownloadReq { 234 unsigned char versionMaj; 235 unsigned char versionMinSub; 236 unsigned char versionSdr; 237 unsigned char reserved; 238 } ATTRIBUTE_PACKING; 239 # ifdef HAVE_PRAGMA_PACK 240 # pragma pack(0) 241 # endif 242 243 #endif /* IPMI_KFWUM_H */ 244