00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 00002 * vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:cindent:textwidth=0: 00003 * 00004 * Copyright (C) 2005 Dell Inc. 00005 * by Michael Brown <Michael_E_Brown@dell.com> 00006 * Licensed under the Open Software License version 2.1 00007 * 00008 * Alternatively, you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published 00010 * by the Free Software Foundation; either version 2 of the License, 00011 * or (at your option) any later version. 00012 00013 * This program is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 * See the GNU General Public License for more details. 00017 */ 00018 00019 #ifndef RBUIMPL_H 00020 #define RBUIMPL_H 00021 00022 // compat header should always be first header if including system headers 00023 #include "smbios/compat.h" 00024 00025 #include "smbios/DellRbu.h" 00026 #include "../common/ExceptionImpl.h" 00027 00028 # if defined(DEBUG_RBU) 00029 # define DCOUT(line) do { cout << line; } while(0) 00030 # define DCERR(line) do { cerr << line; } while(0) 00031 # else 00032 # define DCOUT(line) do {} while(0) 00033 # define DCERR(line) do {} while(0) 00034 # endif 00035 00036 # define RBU_SMBIOS_STRUCT (0xDE) 00037 # define RBU_ACTIVATE (0x005c) 00038 # define RBU_CANCEL (0x005d) 00039 00040 namespace rbu 00041 { 00042 DEFINE_EXCEPTION_EX( RbuNotSupportedImpl, rbu, RbuNotSupported ); 00043 DEFINE_EXCEPTION_EX( InvalidHdrFileImpl, rbu, InvalidHdrFile ); 00044 DEFINE_EXCEPTION_EX( UnsupportedSystemForHdrFileImpl, rbu, UnsupportedSystemForHdrFile ); 00045 DEFINE_EXCEPTION_EX( HdrFileIOErrorImpl, rbu, HdrFileIOError ); 00046 DEFINE_EXCEPTION_EX( RbuDriverIOErrorImpl, rbu, RbuDriverIOError ); 00047 00048 00049 # if defined(_MSC_VER) 00050 # pragma pack(push,1) 00051 # endif 00052 00053 /* RBU packets are 4 KB-aligned and consist of a header and data. The packet header contains the necessary information for BIOS to find the packets in memory, and assemble them in proper order. */ 00054 00055 struct rbu_packet 00056 { 00057 u32 pktId; // must be '$RPK' 00058 u16 pktSize; // size of packet in KB 00059 u16 reserved1; // 00060 u16 hdrSize; // size of packet header in paragraphs (16 byte chunks) 00061 u16 reserved2; // 00062 u32 pktSetId; // unique id for packet set, can be anything 00063 u16 pktNum; // sequential pkt number (only thing that changes) 00064 u16 totPkts; // total number of packets 00065 u8 pktVer; // version == 1 for now 00066 u8 reserved[9]; 00067 u16 pktChksum; // sum all bytes in pkt must be zero 00068 u8 pktData[]; 00069 } 00070 LIBSMBIOS_PACKED_ATTR; 00071 00072 00073 /* RBU Packet Requirements 00074 00075 1.All values in the packet header except PktNum must be the same for all packets in a set with the following exception: 00076 -- Packet 0 may have a different packet size (PktSize). 00077 -- checksums 00078 2.Packet 0 data does not contain RBU data. Packet 1 contains the first chunk of RBU data. 00079 3.Packet data begins immediately after the header. Packet data size and offset can be calculated from PktSize and HdrSize. 00080 4.Reserved fields are 0. 00081 5.If multiple packets sets are written to memory, all packet sets must be identical. 00082 6.All packets must start on 4 KB boundaries. 00083 7.All packets must be placed in non-paged memory. 00084 8.The maximum size of a packet is 64 MB. 00085 9.The maximum size of a packet header is 4 KB. 00086 10.The maximum number of packets is 64 KB - 1. 00087 11.CPU INIT# must be immediately asserted (e.g. via OS shutdown/restart) after the RBU packet set is placed in memory. 00088 12.PktChk is the value resulting in a zero sum of all packet words (header and data). 00089 13.PktSetId uniquely identifies a packet set. BIOS aborts the packet search if all packets do not have the same PkSetId. Example identifiers: a 4-character ASCII ID string (e.g. “_A00”), a 4-byte hash value (e.g. CRC). 00090 */ 00091 00092 /* RBU Packet 0 */ 00093 00094 struct rbu_packet_0 00095 { 00096 rbu_packet header; 00097 u8 passwordCheckInfo; // bit 7: passwordCheck is present bits 0-6: reserved 00098 u32 passwordCheck; // crc-32 of admin/setup password 00099 // the rest is reserved for future expansion. 00100 } 00101 LIBSMBIOS_PACKED_ATTR; 00102 00103 /* RBU Packet 0 Definition 00104 00105 Packet 0 is reserved for packet set information. Packet 0 data consists of data items -- each item consists of an info byte followed by the actual data item. If bit 0 of the info byte is 1, the actual data starting at the next byte is present. If bit 0 is 0, the data is not present. 00106 00107 The system flash password is currently defined as the admin or setup password. 00108 00109 BIOS reject the packet set when: 00110 1.The packet set flash password CRC and the system flash password CRC do not match. 00111 2.The packet set flash password CRC is not present but the system flash password is present. 00112 00113 */ 00114 00115 00116 /* 00117 RBU BIOS UPDATE HEADER FILE (.HDR) structure 00118 */ 00119 00120 struct rbu_hdr_file_header 00121 { 00122 char headerId[4]; 00123 u8 headerLength; 00124 u8 headerMajorVer; 00125 u8 headerMinorVer; 00126 u8 numSystems; 00127 char quickCheck[40]; 00128 char biosVersion[3]; 00129 u8 miscFlags; 00130 u8 biosInternalUse; 00131 u8 reserved[5]; 00132 u16 compatFlags; 00133 u16 systemIdList[12]; /* 00134 Contains the list of NumSystems Dell System ID and Hardware Revision 00135 ID pairs for which the Image Data is valid, in the following format: 00136 Bit Range Description 00137 15:11 Dell System ID, bits 12:8. 00138 This range is set to 00000b if the Dell System ID 00139 is a 1-byte value. 00140 10:8 Hardware Revision ID 00141 7:0 Dell System ID, bits 7:0. */ 00142 } 00143 LIBSMBIOS_PACKED_ATTR; 00144 00145 # if defined(_MSC_VER) 00146 # pragma pack(pop) 00147 # endif 00148 00149 } 00150 00151 #endif /* RBUIMPL_H */