1/* 2 * Copyright (c) 2008 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Gabe Black 29 */ 30 31/* 32 * Copyright (c) 2008 The Hewlett-Packard Development Company 33 * All rights reserved. 34 * 35 * Redistribution and use of this software in source and binary forms, 36 * with or without modification, are permitted provided that the 37 * following conditions are met: 38 * 39 * The software must be used only for Non-Commercial Use which means any 40 * use which is NOT directed to receiving any direct monetary 41 * compensation for, or commercial advantage from such use. Illustrative 42 * examples of non-commercial use are academic research, personal study, 43 * teaching, education and corporate research & development. 44 * Illustrative examples of commercial use are distributing products for 45 * commercial advantage and providing services using the software for 46 * commercial advantage. 47 * 48 * If you wish to use this software or functionality therein that may be 49 * covered by patents for commercial use, please contact: 50 * Director of Intellectual Property Licensing 51 * Office of Strategy and Technology 52 * Hewlett-Packard Company 53 * 1501 Page Mill Road 54 * Palo Alto, California 94304 55 * 56 * Redistributions of source code must retain the above copyright notice, 57 * this list of conditions and the following disclaimer. Redistributions 58 * in binary form must reproduce the above copyright notice, this list of 59 * conditions and the following disclaimer in the documentation and/or 60 * other materials provided with the distribution. Neither the name of 61 * the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 62 * contributors may be used to endorse or promote products derived from 63 * this software without specific prior written permission. No right of 64 * sublicense is granted herewith. Derivatives of the software and 65 * output created using the software may be prepared, but only for 66 * Non-Commercial Uses. Derivatives of the software may be shared with 67 * others provided: (i) the others agree to abide by the list of 68 * conditions herein which includes the Non-Commercial Use restrictions; 69 * and (ii) such Derivatives of the software include the above copyright 70 * notice to acknowledge the contribution from this software where 71 * applicable, this list of conditions and the disclaimer below. 72 * 73 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 74 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 75 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 76 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 77 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 78 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 79 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 80 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 81 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 82 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 83 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 84 * 85 * Authors: Gabe Black 86 */ 87 88#ifndef __ARCH_X86_BIOS_SMBIOS_HH__ 89#define __ARCH_X86_BIOS_SMBIOS_HH__ 90 91#include <string> 92#include <vector> 93
| 1/* 2 * Copyright (c) 2008 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Gabe Black 29 */ 30 31/* 32 * Copyright (c) 2008 The Hewlett-Packard Development Company 33 * All rights reserved. 34 * 35 * Redistribution and use of this software in source and binary forms, 36 * with or without modification, are permitted provided that the 37 * following conditions are met: 38 * 39 * The software must be used only for Non-Commercial Use which means any 40 * use which is NOT directed to receiving any direct monetary 41 * compensation for, or commercial advantage from such use. Illustrative 42 * examples of non-commercial use are academic research, personal study, 43 * teaching, education and corporate research & development. 44 * Illustrative examples of commercial use are distributing products for 45 * commercial advantage and providing services using the software for 46 * commercial advantage. 47 * 48 * If you wish to use this software or functionality therein that may be 49 * covered by patents for commercial use, please contact: 50 * Director of Intellectual Property Licensing 51 * Office of Strategy and Technology 52 * Hewlett-Packard Company 53 * 1501 Page Mill Road 54 * Palo Alto, California 94304 55 * 56 * Redistributions of source code must retain the above copyright notice, 57 * this list of conditions and the following disclaimer. Redistributions 58 * in binary form must reproduce the above copyright notice, this list of 59 * conditions and the following disclaimer in the documentation and/or 60 * other materials provided with the distribution. Neither the name of 61 * the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 62 * contributors may be used to endorse or promote products derived from 63 * this software without specific prior written permission. No right of 64 * sublicense is granted herewith. Derivatives of the software and 65 * output created using the software may be prepared, but only for 66 * Non-Commercial Uses. Derivatives of the software may be shared with 67 * others provided: (i) the others agree to abide by the list of 68 * conditions herein which includes the Non-Commercial Use restrictions; 69 * and (ii) such Derivatives of the software include the above copyright 70 * notice to acknowledge the contribution from this software where 71 * applicable, this list of conditions and the disclaimer below. 72 * 73 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 74 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 75 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 76 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 77 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 78 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 79 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 80 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 81 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 82 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 83 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 84 * 85 * Authors: Gabe Black 86 */ 87 88#ifndef __ARCH_X86_BIOS_SMBIOS_HH__ 89#define __ARCH_X86_BIOS_SMBIOS_HH__ 90 91#include <string> 92#include <vector> 93
|
94#include "arch/x86/isa_traits.hh" 95#include "mem/port.hh" 96#include "sim/byteswap.hh"
| 94#include "enums/Characteristic.hh" 95#include "enums/ExtCharacteristic.hh"
|
97#include "sim/host.hh"
| 96#include "sim/host.hh"
|
| 97#include "sim/sim_object.hh"
|
98
| 98
|
| 99class FunctionalPort; 100class X86SMBiosBiosInformationParams; 101class X86SMBiosSMBiosStructureParams; 102class X86SMBiosSMBiosTableParams; 103
|
99namespace X86ISA 100{ 101 102namespace SMBios 103{ 104
| 104namespace X86ISA 105{ 106 107namespace SMBios 108{ 109
|
105class SMBiosStructure
| 110class SMBiosStructure : public SimObject
|
106{
| 111{
|
| 112 protected: 113 typedef X86SMBiosSMBiosStructureParams Params; 114
|
107 public: 108 109 virtual 110 ~SMBiosStructure() 111 {} 112 113 // Offset 00h, 1 byte 114 uint8_t type; 115 116 // Offset 01h, 1 byte 117 //Length: computed when written to memory. 118 119 // Offset 02h, 2 bytes 120 uint16_t handle; 121 122 virtual uint8_t 123 getLength() 124 { 125 // This is the size of a structure with nothing but the header 126 return 4; 127 } 128
| 115 public: 116 117 virtual 118 ~SMBiosStructure() 119 {} 120 121 // Offset 00h, 1 byte 122 uint8_t type; 123 124 // Offset 01h, 1 byte 125 //Length: computed when written to memory. 126 127 // Offset 02h, 2 bytes 128 uint16_t handle; 129 130 virtual uint8_t 131 getLength() 132 { 133 // This is the size of a structure with nothing but the header 134 return 4; 135 } 136
|
129 virtual uint16_t 130 writeOut(FunctionalPort * port, Addr addr) 131 { 132 port->writeBlob(addr, (uint8_t *)(&type), 1);
| 137 virtual uint16_t writeOut(FunctionalPort * port, Addr addr);
|
133
| 138
|
134 uint8_t length = getLength(); 135 port->writeBlob(addr + 1, (uint8_t *)(&length), 1);
| 139 protected: 140 bool stringFields;
|
136
| 141
|
137 uint16_t handleGuest = X86ISA::htog(handle); 138 port->writeBlob(addr + 2, (uint8_t *)(&handleGuest), 2);
| 142 SMBiosStructure(Params * p, uint8_t _type);
|
139
| 143
|
140 return length + getStringLength(); 141 } 142 143 protected:
| |
144 std::vector<std::string> strings; 145
| 144 std::vector<std::string> strings; 145
|
146 void writeOutStrings(FunctionalPort * port, Addr addr) 147 { 148 std::vector<std::string>::iterator it; 149 Addr offset = 0;
| 146 void writeOutStrings(FunctionalPort * port, Addr addr);
|
150
| 147
|
151 for (it = strings.begin(); it != strings.end(); it++) { 152 port->writeBlob(addr + offset, 153 (uint8_t *)it->c_str(), it->length() + 1); 154 offset += it->length() + 1; 155 }
| 148 int getStringLength();
|
156
| 149
|
157 const uint8_t nullTerminator = 0; 158 port->writeBlob(addr + offset, (uint8_t *)(&nullTerminator), 1); 159 } 160 161 int getStringLength() 162 { 163 int size = 0; 164 std::vector<std::string>::iterator it; 165 166 for (it = strings.begin(); it != strings.end(); it++) { 167 size += it->length() + 1; 168 } 169 170 return size + 1; 171 } 172
| |
173 public: 174
| 150 public: 151
|
175 int addString(std::string & newString) 176 { 177 strings.push_back(newString); 178 return strings.size(); 179 } 180 181 std::string readString(int n) 182 { 183 assert(n > 0 && n <= strings.size()); 184 return strings[n - 1]; 185 } 186 187 void setString(int n, std::string & newString) 188 { 189 assert(n > 0 && n <= strings.size()); 190 strings[n - 1] = newString; 191 }
| 152 int addString(std::string & newString); 153 std::string readString(int n); 154 void setString(int n, std::string & newString);
|
192}; 193 194class BiosInformation : public SMBiosStructure 195{
| 155}; 156 157class BiosInformation : public SMBiosStructure 158{
|
| 159 protected: 160 const static uint8_t Type = 0; 161 162 typedef X86SMBiosBiosInformationParams Params; 163
|
196 public: 197 // Offset 04h, 1 byte 198 uint8_t vendor; 199 // Offset 05h, 1 byte 200 uint8_t version; 201 // Offset 06h, 2 bytes 202 uint16_t startingAddrSegment; 203 // Offset 08h, 1 byte 204 uint8_t releaseDate; 205 // Offset 09h, 1 byte 206 uint8_t romSize; 207 // Offset 0Ah, 8 bytes 208 //See tables in 3.3.1 in the SMBios 2.5 spec from the DMTF for 209 //bit definitions. 210 uint64_t characteristics; 211 // Offset 12h, 2 bytes 212 uint16_t characteristicExtBytes; 213 // Offset 14h, 1 byte
| 164 public: 165 // Offset 04h, 1 byte 166 uint8_t vendor; 167 // Offset 05h, 1 byte 168 uint8_t version; 169 // Offset 06h, 2 bytes 170 uint16_t startingAddrSegment; 171 // Offset 08h, 1 byte 172 uint8_t releaseDate; 173 // Offset 09h, 1 byte 174 uint8_t romSize; 175 // Offset 0Ah, 8 bytes 176 //See tables in 3.3.1 in the SMBios 2.5 spec from the DMTF for 177 //bit definitions. 178 uint64_t characteristics; 179 // Offset 12h, 2 bytes 180 uint16_t characteristicExtBytes; 181 // Offset 14h, 1 byte
|
214 uint8_t major;
| 182 uint8_t majorVer;
|
215 // Offset 15h, 1 byte
| 183 // Offset 15h, 1 byte
|
216 uint8_t minor;
| 184 uint8_t minorVer;
|
217 // Offset 16h, 1 byte 218 uint8_t embContFirmwareMajor; 219 // Offset 17h, 1 byte 220 uint8_t embContFirmwareMinor; 221
| 185 // Offset 16h, 1 byte 186 uint8_t embContFirmwareMajor; 187 // Offset 17h, 1 byte 188 uint8_t embContFirmwareMinor; 189
|
| 190 BiosInformation(Params * p); 191
|
222 uint8_t getLength() { return 0x18; } 223 uint16_t writeOut(FunctionalPort * port, Addr addr); 224}; 225
| 192 uint8_t getLength() { return 0x18; } 193 uint16_t writeOut(FunctionalPort * port, Addr addr); 194}; 195
|
226class SMBiosTable
| 196class SMBiosTable : public SimObject
|
227{
| 197{
|
228 public:
| 198 protected: 199 typedef X86SMBiosSMBiosTableParams Params; 200
|
229 struct SMBiosHeader 230 { 231 SMBiosHeader() 232 {} 233 234 // Offset 00h, 4 bytes 235 static const char anchorString[]; 236 237 // Offset 04h, 1 byte 238 //Checksum: computed when written to memory. 239 240 // Offset 05h, 1 byte 241 static const uint8_t entryPointLength; 242 243 // Offset 06h, 1 byte 244 uint8_t majorVersion; 245 246 // Offset 07h, 1 byte 247 uint8_t minorVersion; 248 249 // Offset 08h, 2 bytes 250 //Maximum structure size: computed when written to memory. 251 252 // Offset 0Ah, 1 byte 253 static const uint8_t entryPointRevision; 254 255 // Offset 0Bh, 5 bytes 256 static const uint8_t formattedArea[5]; 257 258 // Offset 10h, 15 bytes 259 struct IntermediateHeader 260 { 261 IntermediateHeader() : tableAddr(0) 262 {} 263 // Offset 10h, 5 bytes 264 static const char anchorString[]; 265 266 // Offset 15h, 1 byte 267 //Checksum: computed when written to memory. 268 269 // Offset 16h, 2 bytes 270 //Length of the structure table in bytes: computed when 271 //written to memory. 272 273 // Offset 18h, 4 bytes 274 uint32_t tableAddr; 275 276 // Offset 1Ch, 2 bytes 277 //Number of structures: computed when written to memory 278 279 // Offset 1Eh, 1 byte 280 uint8_t smbiosBCDRevision; 281 } intermediateHeader; 282 } smbiosHeader; 283
| 201 struct SMBiosHeader 202 { 203 SMBiosHeader() 204 {} 205 206 // Offset 00h, 4 bytes 207 static const char anchorString[]; 208 209 // Offset 04h, 1 byte 210 //Checksum: computed when written to memory. 211 212 // Offset 05h, 1 byte 213 static const uint8_t entryPointLength; 214 215 // Offset 06h, 1 byte 216 uint8_t majorVersion; 217 218 // Offset 07h, 1 byte 219 uint8_t minorVersion; 220 221 // Offset 08h, 2 bytes 222 //Maximum structure size: computed when written to memory. 223 224 // Offset 0Ah, 1 byte 225 static const uint8_t entryPointRevision; 226 227 // Offset 0Bh, 5 bytes 228 static const uint8_t formattedArea[5]; 229 230 // Offset 10h, 15 bytes 231 struct IntermediateHeader 232 { 233 IntermediateHeader() : tableAddr(0) 234 {} 235 // Offset 10h, 5 bytes 236 static const char anchorString[]; 237 238 // Offset 15h, 1 byte 239 //Checksum: computed when written to memory. 240 241 // Offset 16h, 2 bytes 242 //Length of the structure table in bytes: computed when 243 //written to memory. 244 245 // Offset 18h, 4 bytes 246 uint32_t tableAddr; 247 248 // Offset 1Ch, 2 bytes 249 //Number of structures: computed when written to memory 250 251 // Offset 1Eh, 1 byte 252 uint8_t smbiosBCDRevision; 253 } intermediateHeader; 254 } smbiosHeader; 255
|
284 void writeOut(FunctionalPort * port, Addr addr);
| 256 std::vector<SMBiosStructure *> structures;
|
285
| 257
|
286 std::vector<SMBiosStructure> structures;
| 258 public: 259 SMBiosTable(Params * p); 260 261 Addr getTableAddr() 262 { 263 return smbiosHeader.intermediateHeader.tableAddr; 264 } 265 266 void setTableAddr(Addr addr) 267 { 268 smbiosHeader.intermediateHeader.tableAddr = addr; 269 } 270 271 void writeOut(FunctionalPort * port, Addr addr, 272 Addr &headerSize, Addr &structSize);
|
287}; 288 289} //SMBios 290} //X86ISA 291 292#endif
| 273}; 274 275} //SMBios 276} //X86ISA 277 278#endif
|