gem5  v20.1.0.0
intelmp.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 The Hewlett-Packard Development Company
3  * All rights reserved.
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #include "arch/x86/bios/intelmp.hh"
39 
40 #include "arch/x86/isa_traits.hh"
41 #include "base/logging.hh"
42 #include "base/types.hh"
43 #include "mem/port_proxy.hh"
44 #include "sim/byteswap.hh"
45 
46 // Config entry types
47 #include "params/X86IntelMPBaseConfigEntry.hh"
48 #include "params/X86IntelMPExtConfigEntry.hh"
49 
50 // General table structures
51 #include "params/X86IntelMPConfigTable.hh"
52 #include "params/X86IntelMPFloatingPointer.hh"
53 
54 // Base entry types
55 #include "params/X86IntelMPBus.hh"
56 #include "params/X86IntelMPIOAPIC.hh"
57 #include "params/X86IntelMPIOIntAssignment.hh"
58 #include "params/X86IntelMPLocalIntAssignment.hh"
59 #include "params/X86IntelMPProcessor.hh"
60 
61 // Extended entry types
62 #include "params/X86IntelMPAddrSpaceMapping.hh"
63 #include "params/X86IntelMPBusHierarchy.hh"
64 #include "params/X86IntelMPCompatAddrSpaceMod.hh"
65 
66 using namespace std;
67 
69 
70 template<class T>
71 uint8_t
73 {
74  uint64_t guestVal = htole(val);
75  proxy.writeBlob(addr, &guestVal, sizeof(T));
76 
77  uint8_t checkSum = 0;
78  while (guestVal) {
79  checkSum += guestVal;
80  guestVal >>= 8;
81  }
82  return checkSum;
83 }
84 
85 uint8_t
86 writeOutString(PortProxy& proxy, Addr addr, string str, int length)
87 {
88  char cleanedString[length + 1];
89  cleanedString[length] = 0;
90 
91  if (str.length() > length) {
92  memcpy(cleanedString, str.c_str(), length);
93  warn("Intel MP configuration table string \"%s\" "
94  "will be truncated to \"%s\".\n", str, (char *)&cleanedString);
95  } else {
96  memcpy(cleanedString, str.c_str(), str.length());
97  memset(cleanedString + str.length(), 0, length - str.length());
98  }
99  proxy.writeBlob(addr, &cleanedString, length);
100 
101  uint8_t checkSum = 0;
102  for (int i = 0; i < length; i++)
103  checkSum += cleanedString[i];
104 
105  return checkSum;
106 }
107 
108 Addr
110 {
111  // Make sure that either a config table is present or a default
112  // configuration was found but not both.
113  if (!tableAddr && !defaultConfig)
114  fatal("Either an MP configuration table or a default configuration "
115  "must be used.");
116  if (tableAddr && defaultConfig)
117  fatal("Both an MP configuration table and a default configuration "
118  "were set.");
119 
120  uint8_t checkSum = 0;
121 
122  proxy.writeBlob(addr, signature, 4);
123  for (int i = 0; i < 4; i++)
124  checkSum += signature[i];
125 
126  checkSum += writeOutField(proxy, addr + 4, tableAddr);
127 
128  // The length of the structure in paragraphs, aka 16 byte chunks.
129  uint8_t length = 1;
130  proxy.writeBlob(addr + 8, &length, 1);
131  checkSum += length;
132 
133  proxy.writeBlob(addr + 9, &specRev, 1);
134  checkSum += specRev;
135 
136  proxy.writeBlob(addr + 11, &defaultConfig, 1);
137  checkSum += defaultConfig;
138 
139  uint32_t features2_5 = imcrPresent ? (1 << 7) : 0;
140  checkSum += writeOutField(proxy, addr + 12, features2_5);
141 
142  checkSum = -checkSum;
143  proxy.writeBlob(addr + 10, &checkSum, 1);
144 
145  return 16;
146 }
147 
149  SimObject(p), tableAddr(0), specRev(p->spec_rev),
150  defaultConfig(p->default_config), imcrPresent(p->imcr_present)
151 {}
152 
154 X86IntelMPFloatingPointerParams::create()
155 {
156  return new X86ISA::IntelMP::FloatingPointer(this);
157 }
158 
159 Addr
161  Addr addr, uint8_t &checkSum)
162 {
163  proxy.writeBlob(addr, &type, 1);
164  checkSum += type;
165  return 1;
166 }
167 
169  SimObject(p), type(_type)
170 {}
171 
172 Addr
174  Addr addr, uint8_t &checkSum)
175 {
176  proxy.writeBlob(addr, &type, 1);
177  checkSum += type;
178  proxy.writeBlob(addr + 1, &length, 1);
179  checkSum += length;
180  return 1;
181 }
182 
184  uint8_t _type, uint8_t _length) :
185  SimObject(p), type(_type), length(_length)
186 {}
187 
188 const char X86ISA::IntelMP::ConfigTable::signature[] = "PCMP";
189 
190 Addr
192 {
193  uint8_t checkSum = 0;
194 
195  proxy.writeBlob(addr, signature, 4);
196  for (int i = 0; i < 4; i++)
197  checkSum += signature[i];
198 
199  // Base table length goes here but will be calculated later.
200 
201  proxy.writeBlob(addr + 6, &specRev, 1);
202  checkSum += specRev;
203 
204  // The checksum goes here but is still being calculated.
205 
206  checkSum += writeOutString(proxy, addr + 8, oemID, 8);
207  checkSum += writeOutString(proxy, addr + 16, productID, 12);
208 
209  checkSum += writeOutField(proxy, addr + 28, oemTableAddr);
210  checkSum += writeOutField(proxy, addr + 32, oemTableSize);
211  checkSum += writeOutField(proxy, addr + 34, (uint16_t)baseEntries.size());
212  checkSum += writeOutField(proxy, addr + 36, localApic);
213 
214  uint8_t reserved = 0;
215  proxy.writeBlob(addr + 43, &reserved, 1);
216  checkSum += reserved;
217 
219  uint16_t offset = 44;
220  for (baseEnt = baseEntries.begin();
221  baseEnt != baseEntries.end(); baseEnt++) {
222  offset += (*baseEnt)->writeOut(proxy, addr + offset, checkSum);
223  }
224 
225  // We've found the end of the base table this point.
226  checkSum += writeOutField(proxy, addr + 4, offset);
227 
229  uint16_t extOffset = 0;
230  uint8_t extCheckSum = 0;
231  for (extEnt = extEntries.begin();
232  extEnt != extEntries.end(); extEnt++) {
233  extOffset += (*extEnt)->writeOut(proxy,
234  addr + offset + extOffset, extCheckSum);
235  }
236 
237  checkSum += writeOutField(proxy, addr + 40, extOffset);
238  extCheckSum = -extCheckSum;
239  checkSum += writeOutField(proxy, addr + 42, extCheckSum);
240 
241  // And now, we finally have the whole check sum completed.
242  checkSum = -checkSum;
243  writeOutField(proxy, addr + 7, checkSum);
244 
245  return offset + extOffset;
246 };
247 
249  specRev(p->spec_rev), oemID(p->oem_id), productID(p->product_id),
250  oemTableAddr(p->oem_table_addr), oemTableSize(p->oem_table_size),
251  localApic(p->local_apic),
252  baseEntries(p->base_entries), extEntries(p->ext_entries)
253 {}
254 
256 X86IntelMPConfigTableParams::create()
257 {
258  return new X86ISA::IntelMP::ConfigTable(this);
259 }
260 
261 Addr
263  PortProxy& proxy, Addr addr, uint8_t &checkSum)
264 {
265  BaseConfigEntry::writeOut(proxy, addr, checkSum);
266  checkSum += writeOutField(proxy, addr + 1, localApicID);
267  checkSum += writeOutField(proxy, addr + 2, localApicVersion);
268  checkSum += writeOutField(proxy, addr + 3, cpuFlags);
269  checkSum += writeOutField(proxy, addr + 4, cpuSignature);
270  checkSum += writeOutField(proxy, addr + 8, featureFlags);
271 
272  uint32_t reserved = 0;
273  proxy.writeBlob(addr + 12, &reserved, 4);
274  proxy.writeBlob(addr + 16, &reserved, 4);
275  return 20;
276 }
277 
279  localApicID(p->local_apic_id), localApicVersion(p->local_apic_version),
280  cpuFlags(0), cpuSignature(0), featureFlags(p->feature_flags)
281 {
282  if (p->enable)
283  cpuFlags |= (1 << 0);
284  if (p->bootstrap)
285  cpuFlags |= (1 << 1);
286 
287  replaceBits(cpuSignature, 3, 0, p->stepping);
288  replaceBits(cpuSignature, 7, 4, p->model);
289  replaceBits(cpuSignature, 11, 8, p->family);
290 }
291 
293 X86IntelMPProcessorParams::create()
294 {
295  return new X86ISA::IntelMP::Processor(this);
296 }
297 
298 Addr
300  PortProxy& proxy, Addr addr, uint8_t &checkSum)
301 {
302  BaseConfigEntry::writeOut(proxy, addr, checkSum);
303  checkSum += writeOutField(proxy, addr + 1, busID);
304  checkSum += writeOutString(proxy, addr + 2, busType, 6);
305  return 8;
306 }
307 
309  busID(p->bus_id), busType(p->bus_type)
310 {}
311 
313 X86IntelMPBusParams::create()
314 {
315  return new X86ISA::IntelMP::Bus(this);
316 }
317 
318 Addr
320  PortProxy& proxy, Addr addr, uint8_t &checkSum)
321 {
322  BaseConfigEntry::writeOut(proxy, addr, checkSum);
323  checkSum += writeOutField(proxy, addr + 1, id);
324  checkSum += writeOutField(proxy, addr + 2, version);
325  checkSum += writeOutField(proxy, addr + 3, flags);
326  checkSum += writeOutField(proxy, addr + 4, address);
327  return 8;
328 }
329 
331  id(p->id), version(p->version), flags(0), address(p->address)
332 {
333  if (p->enable)
334  flags |= 1;
335 }
336 
338 X86IntelMPIOAPICParams::create()
339 {
340  return new X86ISA::IntelMP::IOAPIC(this);
341 }
342 
343 Addr
345  PortProxy& proxy, Addr addr, uint8_t &checkSum)
346 {
347  BaseConfigEntry::writeOut(proxy, addr, checkSum);
348  checkSum += writeOutField(proxy, addr + 1, interruptType);
349  checkSum += writeOutField(proxy, addr + 2, flags);
350  checkSum += writeOutField(proxy, addr + 4, sourceBusID);
351  checkSum += writeOutField(proxy, addr + 5, sourceBusIRQ);
352  checkSum += writeOutField(proxy, addr + 6, destApicID);
353  checkSum += writeOutField(proxy, addr + 7, destApicIntIn);
354  return 8;
355 }
356 
358  IntAssignment(p, p->interrupt_type, p->polarity, p->trigger, 3,
359  p->source_bus_id, p->source_bus_irq,
360  p->dest_io_apic_id, p->dest_io_apic_intin)
361 {}
362 
364 X86IntelMPIOIntAssignmentParams::create()
365 {
366  return new X86ISA::IntelMP::IOIntAssignment(this);
367 }
368 
370  IntAssignment(p, p->interrupt_type, p->polarity, p->trigger, 4,
371  p->source_bus_id, p->source_bus_irq,
372  p->dest_local_apic_id, p->dest_local_apic_intin)
373 {}
374 
376 X86IntelMPLocalIntAssignmentParams::create()
377 {
378  return new X86ISA::IntelMP::LocalIntAssignment(this);
379 }
380 
381 Addr
383  PortProxy& proxy, Addr addr, uint8_t &checkSum)
384 {
385  ExtConfigEntry::writeOut(proxy, addr, checkSum);
386  checkSum += writeOutField(proxy, addr + 2, busID);
387  checkSum += writeOutField(proxy, addr + 3, addrType);
388  checkSum += writeOutField(proxy, addr + 4, addr);
389  checkSum += writeOutField(proxy, addr + 12, addrLength);
390  return length;
391 }
392 
394  ExtConfigEntry(p, 128, 20),
395  busID(p->bus_id), addrType(p->address_type),
396  addr(p->address), addrLength(p->length)
397 {}
398 
400 X86IntelMPAddrSpaceMappingParams::create()
401 {
402  return new X86ISA::IntelMP::AddrSpaceMapping(this);
403 }
404 
405 Addr
407  PortProxy& proxy, Addr addr, uint8_t &checkSum)
408 {
409  ExtConfigEntry::writeOut(proxy, addr, checkSum);
410  checkSum += writeOutField(proxy, addr + 2, busID);
411  checkSum += writeOutField(proxy, addr + 3, info);
412  checkSum += writeOutField(proxy, addr + 4, parentBus);
413 
414  uint32_t reserved = 0;
415  proxy.writeBlob(addr + 5, &reserved, 3);
416 
417  return length;
418 }
419 
421  ExtConfigEntry(p, 129, 8),
422  busID(p->bus_id), info(0), parentBus(p->parent_bus)
423 {
424  if (p->subtractive_decode)
425  info |= 1;
426 }
427 
429 X86IntelMPBusHierarchyParams::create()
430 {
431  return new X86ISA::IntelMP::BusHierarchy(this);
432 }
433 
434 Addr
436  PortProxy& proxy, Addr addr, uint8_t &checkSum)
437 {
438  ExtConfigEntry::writeOut(proxy, addr, checkSum);
439  checkSum += writeOutField(proxy, addr + 2, busID);
440  checkSum += writeOutField(proxy, addr + 3, mod);
441  checkSum += writeOutField(proxy, addr + 4, rangeList);
442  return length;
443 }
444 
446  ExtConfigEntry(p, 130, 8),
447  busID(p->bus_id), mod(0), rangeList(p->range_list)
448 {
449  if (p->add)
450  mod |= 1;
451 }
452 
454 X86IntelMPCompatAddrSpaceModParams::create()
455 {
456  return new X86ISA::IntelMP::CompatAddrSpaceMod(this);
457 }
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:183
X86ISA::IntelMP::FloatingPointer::writeOut
Addr writeOut(PortProxy &proxy, Addr addr)
Definition: intelmp.cc:109
X86ISA::IntelMP::FloatingPointer
Definition: intelmp.hh:86
X86ISA::IntelMP::BaseConfigEntry
Definition: intelmp.hh:115
warn
#define warn(...)
Definition: logging.hh:239
length
uint8_t length
Definition: inet.hh:422
replaceBits
void replaceBits(T &val, int first, int last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
Definition: bitfield.hh:179
X86ISA::IntelMP::Processor::cpuFlags
uint8_t cpuFlags
Definition: intelmp.hh:174
X86ISA::IntelMP::LocalIntAssignment::LocalIntAssignment
LocalIntAssignment(Params *p)
Definition: intelmp.cc:369
X86ISA::IntelMP::BusHierarchy::writeOut
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition: intelmp.cc:406
X86ISA::IntelMP::ConfigTable::signature
static const char signature[]
Definition: intelmp.hh:149
X86ISA::IntelMP::BaseConfigEntry::Params
X86IntelMPBaseConfigEntryParams Params
Definition: intelmp.hh:118
writeOutField
uint8_t writeOutField(PortProxy &proxy, Addr addr, T val)
Definition: intelmp.cc:72
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
X86ISA::IntelMP::Processor
Definition: intelmp.hh:167
intelmp.hh
htole
T htole(T value)
Definition: byteswap.hh:140
X86ISA::IntelMP::ConfigTable::ConfigTable
ConfigTable(Params *p)
Definition: intelmp.cc:248
X86ISA::IntelMP::ExtConfigEntry::ExtConfigEntry
ExtConfigEntry(Params *p, uint8_t _type, uint8_t _length)
Definition: intelmp.cc:183
X86ISA::IntelMP::Processor::cpuSignature
uint32_t cpuSignature
Definition: intelmp.hh:175
X86ISA::IntelMP::IOIntAssignment::IOIntAssignment
IOIntAssignment(Params *p)
Definition: intelmp.cc:357
X86ISA::IntelMP::CompatAddrSpaceMod
Definition: intelmp.hh:296
X86ISA::IntelMP::Bus::Bus
Bus(Params *p)
Definition: intelmp.cc:308
std::vector
STL vector class.
Definition: stl.hh:37
X86ISA::IntelMP::AddrSpaceMapping
Definition: intelmp.hh:265
X86ISA::IntelMP::ConfigTable::writeOut
Addr writeOut(PortProxy &proxy, Addr addr)
Definition: intelmp.cc:191
writeOutString
uint8_t writeOutString(PortProxy &proxy, Addr addr, string str, int length)
Definition: intelmp.cc:86
X86ISA::IntelMP::IOIntAssignment
Definition: intelmp.hh:247
X86ISA::IntelMP::IOAPIC::IOAPIC
IOAPIC(Params *p)
Definition: intelmp.cc:330
X86ISA::IntelMP::LocalIntAssignment
Definition: intelmp.hh:256
PortProxy::writeBlob
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
Definition: port_proxy.hh:187
X86ISA::IntelMP::IntAssignment::writeOut
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition: intelmp.cc:344
X86ISA::IntelMP::BaseConfigEntry::writeOut
virtual Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition: intelmp.cc:160
X86ISA::IntelMP::ConfigTable::Params
X86IntelMPConfigTableParams Params
Definition: intelmp.hh:147
X86ISA::IntelMP::ConfigTable
Definition: intelmp.hh:144
X86ISA::IntelMP::CompatAddrSpaceMod::writeOut
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition: intelmp.cc:435
X86ISA::IntelMP::BusHierarchy
Definition: intelmp.hh:281
X86ISA::IntelMP::AddrSpaceMapping::AddrSpaceMapping
AddrSpaceMapping(Params *p)
Definition: intelmp.cc:393
X86ISA::IntelMP::ExtConfigEntry::writeOut
virtual Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition: intelmp.cc:173
X86ISA::IntelMP::IOAPIC
Definition: intelmp.hh:198
port_proxy.hh
isa_traits.hh
X86ISA::IntelMP::BusHierarchy::info
uint8_t info
Definition: intelmp.hh:287
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
X86ISA::IntelMP::ExtConfigEntry::Params
X86IntelMPExtConfigEntryParams Params
Definition: intelmp.hh:132
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
X86ISA::IntelMP::Bus
Definition: intelmp.hh:184
X86ISA::IntelMP::ExtConfigEntry
Definition: intelmp.hh:129
X86ISA::offset
offset
Definition: misc.hh:1024
X86ISA::IntelMP::AddrSpaceMapping::writeOut
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition: intelmp.cc:382
X86ISA::IntelMP::Processor::Processor
Processor(Params *p)
Definition: intelmp.cc:278
X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:79
X86ISA::IntelMP::Processor::writeOut
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition: intelmp.cc:262
PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:80
X86ISA::mod
mod
Definition: types.hh:86
X86ISA::p
Bitfield< 0 > p
Definition: pagetable.hh:151
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
types.hh
X86ISA::IntelMP::IOAPIC::writeOut
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition: intelmp.cc:319
addr
ip6_addr_t addr
Definition: inet.hh:423
X86ISA::IntelMP::BaseConfigEntry::BaseConfigEntry
BaseConfigEntry(Params *p, uint8_t _type)
Definition: intelmp.cc:168
logging.hh
X86ISA::type
type
Definition: misc.hh:727
X86ISA::IntelMP::Bus::writeOut
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition: intelmp.cc:299
X86ISA::IntelMP::IOAPIC::flags
uint8_t flags
Definition: intelmp.hh:205
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
X86ISA::IntelMP::CompatAddrSpaceMod::mod
uint8_t mod
Definition: intelmp.hh:302
X86ISA::IntelMP::FloatingPointer::Params
X86IntelMPFloatingPointerParams Params
Definition: intelmp.hh:89
X86ISA::trigger
Bitfield< 21 > trigger
Definition: intmessage.hh:48
X86ISA::IntelMP::IntAssignment
Definition: intelmp.hh:214
X86ISA::IntelMP::FloatingPointer::signature
static const char signature[]
Definition: intelmp.hh:96
X86ISA::IntelMP::BusHierarchy::BusHierarchy
BusHierarchy(Params *p)
Definition: intelmp.cc:420
X86ISA::IntelMP::CompatAddrSpaceMod::CompatAddrSpaceMod
CompatAddrSpaceMod(Params *p)
Definition: intelmp.cc:445
X86ISA::IntelMP::FloatingPointer::FloatingPointer
FloatingPointer(Params *p)
Definition: intelmp.cc:148
ArmISA::id
Bitfield< 33 > id
Definition: miscregs_types.hh:247
byteswap.hh
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17