gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
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
39
40#include "base/logging.hh"
41#include "base/types.hh"
42#include "mem/port_proxy.hh"
43#include "sim/byteswap.hh"
44
45// Config entry types
46#include "params/X86IntelMPBaseConfigEntry.hh"
47#include "params/X86IntelMPExtConfigEntry.hh"
48
49// General table structures
50#include "params/X86IntelMPConfigTable.hh"
51#include "params/X86IntelMPFloatingPointer.hh"
52
53// Base entry types
54#include "params/X86IntelMPBus.hh"
55#include "params/X86IntelMPIOAPIC.hh"
56#include "params/X86IntelMPIOIntAssignment.hh"
57#include "params/X86IntelMPLocalIntAssignment.hh"
58#include "params/X86IntelMPProcessor.hh"
59
60// Extended entry types
61#include "params/X86IntelMPAddrSpaceMapping.hh"
62#include "params/X86IntelMPBusHierarchy.hh"
63#include "params/X86IntelMPCompatAddrSpaceMod.hh"
64
65namespace gem5
66{
67
69
70template<class T>
71uint8_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
85uint8_t
86writeOutString(PortProxy& proxy, Addr addr, std::string str, int length)
87{
88 std::string nullPadded(length, '\0');
89 memcpy(nullPadded.data(), str.data(), std::min<int>(str.length(), length));
90 if (str.length() > length) {
91 warn("Intel MP configuration table string \"%s\" "
92 "will be truncated to \"%s\".\n", str, nullPadded);
93 }
94 proxy.writeBlob(addr, nullPadded.data(), length);
95
96 uint8_t checkSum = 0;
97 for (int i = 0; i < length; i++)
98 checkSum += nullPadded[i];
99
100 return checkSum;
101}
102
103Addr
105{
106 // Make sure that either a config table is present or a default
107 // configuration was found but not both.
108 if (!tableAddr && !defaultConfig)
109 fatal("Either an MP configuration table or a default configuration "
110 "must be used.");
112 fatal("Both an MP configuration table and a default configuration "
113 "were set.");
114
115 uint8_t checkSum = 0;
116
117 proxy.writeBlob(addr, signature, 4);
118 for (int i = 0; i < 4; i++)
119 checkSum += signature[i];
120
121 checkSum += writeOutField(proxy, addr + 4, tableAddr);
122
123 // The length of the structure in paragraphs, aka 16 byte chunks.
124 uint8_t length = 1;
125 proxy.writeBlob(addr + 8, &length, 1);
126 checkSum += length;
127
128 proxy.writeBlob(addr + 9, &specRev, 1);
129 checkSum += specRev;
130
131 proxy.writeBlob(addr + 11, &defaultConfig, 1);
132 checkSum += defaultConfig;
133
134 uint32_t features2_5 = imcrPresent ? (1 << 7) : 0;
135 checkSum += writeOutField(proxy, addr + 12, features2_5);
136
137 checkSum = -checkSum;
138 proxy.writeBlob(addr + 10, &checkSum, 1);
139
140 return 16;
141}
142
144 SimObject(p), tableAddr(0), specRev(p.spec_rev),
145 defaultConfig(p.default_config), imcrPresent(p.imcr_present)
146{}
147
148Addr
150 Addr addr, uint8_t &checkSum)
151{
152 proxy.writeBlob(addr, &type, 1);
153 checkSum += type;
154 return 1;
155}
156
158 const Params &p, uint8_t _type) :
159 SimObject(p), type(_type)
160{}
161
162Addr
164 Addr addr, uint8_t &checkSum)
165{
166 proxy.writeBlob(addr, &type, 1);
167 checkSum += type;
168 proxy.writeBlob(addr + 1, &length, 1);
169 checkSum += length;
170 return 1;
171}
172
174 uint8_t _type, uint8_t _length) :
175 SimObject(p), type(_type), length(_length)
176{}
177
178const char X86ISA::intelmp::ConfigTable::signature[] = "PCMP";
179
180Addr
182{
183 uint8_t checkSum = 0;
184
185 proxy.writeBlob(addr, signature, 4);
186 for (int i = 0; i < 4; i++)
187 checkSum += signature[i];
188
189 // Base table length goes here but will be calculated later.
190
191 proxy.writeBlob(addr + 6, &specRev, 1);
192 checkSum += specRev;
193
194 // The checksum goes here but is still being calculated.
195
196 checkSum += writeOutString(proxy, addr + 8, oemID, 8);
197 checkSum += writeOutString(proxy, addr + 16, productID, 12);
198
199 checkSum += writeOutField(proxy, addr + 28, oemTableAddr);
200 checkSum += writeOutField(proxy, addr + 32, oemTableSize);
201 checkSum += writeOutField(proxy, addr + 34, (uint16_t)baseEntries.size());
202 checkSum += writeOutField(proxy, addr + 36, localApic);
203
204 uint8_t reserved = 0;
205 proxy.writeBlob(addr + 43, &reserved, 1);
206 checkSum += reserved;
207
209 uint16_t offset = 44;
210 for (baseEnt = baseEntries.begin();
211 baseEnt != baseEntries.end(); baseEnt++) {
212 offset += (*baseEnt)->writeOut(proxy, addr + offset, checkSum);
213 }
214
215 // We've found the end of the base table this point.
216 checkSum += writeOutField(proxy, addr + 4, offset);
217
219 uint16_t extOffset = 0;
220 uint8_t extCheckSum = 0;
221 for (extEnt = extEntries.begin();
222 extEnt != extEntries.end(); extEnt++) {
223 extOffset += (*extEnt)->writeOut(proxy,
224 addr + offset + extOffset, extCheckSum);
225 }
226
227 checkSum += writeOutField(proxy, addr + 40, extOffset);
228 extCheckSum = -extCheckSum;
229 checkSum += writeOutField(proxy, addr + 42, extCheckSum);
230
231 // And now, we finally have the whole check sum completed.
232 checkSum = -checkSum;
233 writeOutField(proxy, addr + 7, checkSum);
234
235 return offset + extOffset;
236};
237
239 specRev(p.spec_rev), oemID(p.oem_id), productID(p.product_id),
240 oemTableAddr(p.oem_table_addr), oemTableSize(p.oem_table_size),
241 localApic(p.local_apic),
242 baseEntries(p.base_entries), extEntries(p.ext_entries)
243{}
244
245Addr
247 PortProxy& proxy, Addr addr, uint8_t &checkSum)
248{
249 BaseConfigEntry::writeOut(proxy, addr, checkSum);
250 checkSum += writeOutField(proxy, addr + 1, localApicID);
251 checkSum += writeOutField(proxy, addr + 2, localApicVersion);
252 checkSum += writeOutField(proxy, addr + 3, cpuFlags);
253 checkSum += writeOutField(proxy, addr + 4, cpuSignature);
254 checkSum += writeOutField(proxy, addr + 8, featureFlags);
255
256 uint32_t reserved = 0;
257 proxy.writeBlob(addr + 12, &reserved, 4);
258 proxy.writeBlob(addr + 16, &reserved, 4);
259 return 20;
260}
261
263 localApicID(p.local_apic_id), localApicVersion(p.local_apic_version),
264 cpuFlags(0), cpuSignature(0), featureFlags(p.feature_flags)
265{
266 if (p.enable)
267 cpuFlags |= (1 << 0);
268 if (p.bootstrap)
269 cpuFlags |= (1 << 1);
270
271 replaceBits(cpuSignature, 3, 0, p.stepping);
272 replaceBits(cpuSignature, 7, 4, p.model);
273 replaceBits(cpuSignature, 11, 8, p.family);
274}
275
276Addr
278 PortProxy& proxy, Addr addr, uint8_t &checkSum)
279{
280 BaseConfigEntry::writeOut(proxy, addr, checkSum);
281 checkSum += writeOutField(proxy, addr + 1, busID);
282 checkSum += writeOutString(proxy, addr + 2, busType, 6);
283 return 8;
284}
285
287 busID(p.bus_id), busType(p.bus_type)
288{}
289
290Addr
292 PortProxy& proxy, Addr addr, uint8_t &checkSum)
293{
294 BaseConfigEntry::writeOut(proxy, addr, checkSum);
295 checkSum += writeOutField(proxy, addr + 1, id);
296 checkSum += writeOutField(proxy, addr + 2, version);
297 checkSum += writeOutField(proxy, addr + 3, flags);
298 checkSum += writeOutField(proxy, addr + 4, address);
299 return 8;
300}
301
304{
305 if (p.enable)
306 flags |= 1;
307}
308
309Addr
311 PortProxy& proxy, Addr addr, uint8_t &checkSum)
312{
313 BaseConfigEntry::writeOut(proxy, addr, checkSum);
314 checkSum += writeOutField(proxy, addr + 1, interruptType);
315 checkSum += writeOutField(proxy, addr + 2, flags);
316 checkSum += writeOutField(proxy, addr + 4, sourceBusID);
317 checkSum += writeOutField(proxy, addr + 5, sourceBusIRQ);
318 checkSum += writeOutField(proxy, addr + 6, destApicID);
319 checkSum += writeOutField(proxy, addr + 7, destApicIntIn);
320 return 8;
321}
322
324 IntAssignment(p, p.interrupt_type, p.polarity, p.trigger, 3,
325 p.source_bus_id, p.source_bus_irq,
326 p.dest_io_apic_id, p.dest_io_apic_intin)
327{}
328
330 IntAssignment(p, p.interrupt_type, p.polarity, p.trigger, 4,
331 p.source_bus_id, p.source_bus_irq,
332 p.dest_local_apic_id, p.dest_local_apic_intin)
333{}
334
335Addr
337 PortProxy& proxy, Addr addr, uint8_t &checkSum)
338{
339 ExtConfigEntry::writeOut(proxy, addr, checkSum);
340 checkSum += writeOutField(proxy, addr + 2, busID);
341 checkSum += writeOutField(proxy, addr + 3, addrType);
342 checkSum += writeOutField(proxy, addr + 4, addr);
343 checkSum += writeOutField(proxy, addr + 12, addrLength);
344 return length;
345}
346
348 ExtConfigEntry(p, 128, 20),
349 busID(p.bus_id), addrType(p.address_type),
350 addr(p.address), addrLength(p.length)
351{}
352
353Addr
355 PortProxy& proxy, Addr addr, uint8_t &checkSum)
356{
357 ExtConfigEntry::writeOut(proxy, addr, checkSum);
358 checkSum += writeOutField(proxy, addr + 2, busID);
359 checkSum += writeOutField(proxy, addr + 3, info);
360 checkSum += writeOutField(proxy, addr + 4, parentBus);
361
362 uint32_t reserved = 0;
363 proxy.writeBlob(addr + 5, &reserved, 3);
364
365 return length;
366}
367
369 ExtConfigEntry(p, 129, 8),
370 busID(p.bus_id), info(0), parentBus(p.parent_bus)
371{
372 if (p.subtractive_decode)
373 info |= 1;
374}
375
376Addr
378 PortProxy& proxy, Addr addr, uint8_t &checkSum)
379{
380 ExtConfigEntry::writeOut(proxy, addr, checkSum);
381 checkSum += writeOutField(proxy, addr + 2, busID);
382 checkSum += writeOutField(proxy, addr + 3, mod);
383 checkSum += writeOutField(proxy, addr + 4, rangeList);
384 return length;
385}
386
388 ExtConfigEntry(p, 130, 8),
389 busID(p.bus_id), mod(0), rangeList(p.range_list)
390{
391 if (p.add)
392 mod |= 1;
393}
394
395} // namespace gem5
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition port_proxy.hh:87
void writeBlob(Addr addr, const void *p, uint64_t size) const
Same as tryWriteBlob, but insists on success.
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition intelmp.cc:336
X86IntelMPAddrSpaceMappingParams Params
Definition intelmp.hh:272
virtual Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition intelmp.cc:149
BaseConfigEntry(const Params &p, uint8_t _type)
Definition intelmp.cc:157
X86IntelMPBaseConfigEntryParams Params
Definition intelmp.hh:122
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition intelmp.cc:354
X86IntelMPBusHierarchyParams Params
Definition intelmp.hh:288
X86IntelMPBusParams Params
Definition intelmp.hh:191
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition intelmp.cc:277
Bus(const Params &p)
Definition intelmp.cc:286
X86IntelMPCompatAddrSpaceModParams Params
Definition intelmp.hh:303
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition intelmp.cc:377
std::vector< ExtConfigEntry * > extEntries
Definition intelmp.hh:163
std::vector< BaseConfigEntry * > baseEntries
Definition intelmp.hh:162
X86IntelMPConfigTableParams Params
Definition intelmp.hh:151
static const char signature[]
Definition intelmp.hh:153
Addr writeOut(PortProxy &proxy, Addr addr)
Definition intelmp.cc:181
virtual Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition intelmp.cc:163
ExtConfigEntry(const Params &p, uint8_t _type, uint8_t _length)
Definition intelmp.cc:173
X86IntelMPExtConfigEntryParams Params
Definition intelmp.hh:136
Addr writeOut(PortProxy &proxy, Addr addr)
Definition intelmp.cc:104
X86IntelMPFloatingPointerParams Params
Definition intelmp.hh:93
IOAPIC(const Params &p)
Definition intelmp.cc:302
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition intelmp.cc:291
X86IntelMPIOAPICParams Params
Definition intelmp.hh:205
X86IntelMPIOIntAssignmentParams Params
Definition intelmp.hh:254
IntAssignment(const X86IntelMPBaseConfigEntryParams &p, enums::X86IntelMPInterruptType _interruptType, enums::X86IntelMPPolarity polarity, enums::X86IntelMPTriggerMode trigger, uint8_t _type, uint8_t _sourceBusID, uint8_t _sourceBusIRQ, uint8_t _destApicID, uint8_t _destApicIntIn)
Definition intelmp.hh:234
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition intelmp.cc:310
X86IntelMPLocalIntAssignmentParams Params
Definition intelmp.hh:263
X86IntelMPProcessorParams Params
Definition intelmp.hh:174
Addr writeOut(PortProxy &proxy, Addr addr, uint8_t &checkSum)
Definition intelmp.cc:246
STL vector class.
Definition stl.hh:37
constexpr void replaceBits(T &val, unsigned first, unsigned last, B bit_val)
A convenience function to replace bits first to last of val with bit_val in place.
Definition bitfield.hh:216
#define fatal(...)
This implements a cprintf based fatal() function.
Definition logging.hh:232
SimObject(const Params &p)
Definition sim_object.cc:58
#define warn(...)
Definition logging.hh:288
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 62, 54 > reserved
Definition pagetable.hh:66
Bitfield< 63 > val
Definition misc.hh:804
Bitfield< 3 > addr
Definition types.hh:84
Bitfield< 0 > p
Definition pagetable.hh:151
Bitfield< 21 > trigger
Definition intmessage.hh:52
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint8_t writeOutField(PortProxy &proxy, Addr addr, T val)
Definition intelmp.cc:72
T htole(T value)
Definition byteswap.hh:172
uint8_t writeOutString(PortProxy &proxy, Addr addr, std::string str, int length)
Definition intelmp.cc:86
PortProxy Object Declaration.

Generated on Mon May 26 2025 09:19:06 for gem5 by doxygen 1.13.2