Deleted Added
sdiff udiff text old ( 5612:1bd333953e49 ) new ( 5615:1c4b9b1aa500 )
full compact
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;

--- 77 unchanged lines hidden (view full) ---

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"
97#include "sim/host.hh"
98
99namespace X86ISA
100{
101
102namespace SMBios
103{
104
105class SMBiosStructure
106{
107 public:
108
109 virtual
110 ~SMBiosStructure()
111 {}
112
113 // Offset 00h, 1 byte
114 uint8_t type;

--- 6 unchanged lines hidden (view full) ---

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
129 virtual uint16_t
130 writeOut(FunctionalPort * port, Addr addr)
131 {
132 port->writeBlob(addr, (uint8_t *)(&type), 1);
133
134 uint8_t length = getLength();
135 port->writeBlob(addr + 1, (uint8_t *)(&length), 1);
136
137 uint16_t handleGuest = X86ISA::htog(handle);
138 port->writeBlob(addr + 2, (uint8_t *)(&handleGuest), 2);
139
140 return length + getStringLength();
141 }
142
143 protected:
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;
150
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 }
156
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
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 }
192};
193
194class BiosInformation : public SMBiosStructure
195{
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
214 uint8_t major;
215 // Offset 15h, 1 byte
216 uint8_t minor;
217 // Offset 16h, 1 byte
218 uint8_t embContFirmwareMajor;
219 // Offset 17h, 1 byte
220 uint8_t embContFirmwareMinor;
221
222 uint8_t getLength() { return 0x18; }
223 uint16_t writeOut(FunctionalPort * port, Addr addr);
224};
225
226class SMBiosTable
227{
228 public:
229 struct SMBiosHeader
230 {
231 SMBiosHeader()
232 {}
233
234 // Offset 00h, 4 bytes
235 static const char anchorString[];
236

--- 39 unchanged lines hidden (view full) ---

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
284 void writeOut(FunctionalPort * port, Addr addr);
285
286 std::vector<SMBiosStructure> structures;
287};
288
289} //SMBios
290} //X86ISA
291
292#endif