gem5 v24.0.0.0
Loading...
Searching...
No Matches
acpi.hh
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#ifndef __ARCH_X86_BIOS_ACPI_HH__
39#define __ARCH_X86_BIOS_ACPI_HH__
40
41#include <string>
42#include <tuple>
43#include <type_traits>
44#include <vector>
45
46#include "base/compiler.hh"
47#include "base/types.hh"
48#include "debug/ACPI.hh"
49#include "params/X86ACPIMadt.hh"
50#include "params/X86ACPIMadtIOAPIC.hh"
51#include "params/X86ACPIMadtIntSourceOverride.hh"
52#include "params/X86ACPIMadtLAPIC.hh"
53#include "params/X86ACPIMadtLAPICOverride.hh"
54#include "params/X86ACPIMadtNMI.hh"
55#include "params/X86ACPIMadtRecord.hh"
56#include "params/X86ACPIRSDP.hh"
57#include "params/X86ACPIRSDT.hh"
58#include "params/X86ACPISysDescTable.hh"
59#include "params/X86ACPIXSDT.hh"
60#include "sim/sim_object.hh"
61
62namespace gem5
63{
64
65class PortProxy;
66
67namespace X86ISA
68{
69
70namespace ACPI
71{
72
73class RSDT;
74class XSDT;
75
77{
78 virtual Addr alloc(std::size_t size, unsigned align=1) = 0;
79};
81{
83 next(begin),
84 end(end)
85 {}
86
87 Addr alloc(std::size_t size, unsigned align) override;
88
89 protected:
91 Addr const end;
92};
93
94class RSDP : public SimObject
95{
96 protected:
97 PARAMS(X86ACPIRSDP);
98
99 static const char signature[];
100
102 {
103 // src: https://wiki.osdev.org/RSDP
104 char signature[8] = {};
105 uint8_t checksum = 0;
106 char oemID[6] = {};
107 uint8_t revision = 0;
108 uint32_t rsdtAddress = 0;
109 };
110 static_assert(std::is_trivially_copyable_v<MemR0>,
111 "Type not suitable for memcpy.");
112
113 struct GEM5_PACKED Mem : public MemR0
114 {
115 // since version 2
116 uint32_t length = 0;
117 uint64_t xsdtAddress = 0;
118 uint8_t extendedChecksum = 0;
119 uint8_t _reserved[3] = {};
120 };
121 static_assert(std::is_trivially_copyable_v<Mem>,
122 "Type not suitable for memcpy,");
123
126
127 public:
128 RSDP(const Params &p);
129
130 Addr write(PortProxy& phys_proxy, Allocator& alloc) const;
131};
132
134{
135 protected:
136 PARAMS(X86ACPISysDescTable);
137
139 {
140 // src: https://wiki.osdev.org/RSDT
141 char signature[4] = {};
142 uint32_t length = 0;
143 uint8_t revision = 0;
144 uint8_t checksum = 0;
145 char oemID[6] = {};
146 char oemTableID[8] = {};
147 uint32_t oemRevision = 0;
148 uint32_t creatorID = 0;
149 uint32_t creatorRevision = 0;
150 };
151 static_assert(std::is_trivially_copyable_v<Mem>,
152 "Type not suitable for memcpy.");
153
154 virtual Addr writeBuf(PortProxy& phys_proxy, Allocator& alloc,
155 std::vector<uint8_t>& mem) const = 0;
156
157 const char* signature;
158 uint8_t revision;
159
160 SysDescTable(const Params& p, const char* _signature, uint8_t _revision) :
161 SimObject(p), signature(_signature), revision(_revision)
162 {}
163
164 public:
165 Addr
166 write(PortProxy& phys_proxy, Allocator& alloc) const
167 {
169 return writeBuf(phys_proxy, alloc, mem);
170 }
171};
172
173template<class T>
174class RXSDT : public SysDescTable
175{
176 protected:
177 using Ptr = T;
178
180
181 Addr writeBuf(PortProxy& phys_proxy, Allocator& alloc,
182 std::vector<uint8_t>& mem) const override;
183
184 protected:
185 RXSDT(const Params& p, const char* _signature, uint8_t _revision);
186};
187
188class RSDT : public RXSDT<uint32_t>
189{
190 protected:
191 PARAMS(X86ACPIRSDT);
192
193 public:
194 RSDT(const Params &p);
195};
196
197class XSDT : public RXSDT<uint64_t>
198{
199 protected:
200 PARAMS(X86ACPIXSDT);
201
202 public:
203 XSDT(const Params &p);
204};
205
206namespace MADT
207{
208class Record : public SimObject
209{
210 protected:
211 PARAMS(X86ACPIMadtRecord);
212
214 {
215 uint8_t type = 0;
216 uint8_t length = 0;
217 };
218 static_assert(std::is_trivially_copyable_v<Mem>,
219 "Type not suitable for memcpy.");
220
221 uint8_t type;
222
223 virtual void prepareBuf(std::vector<uint8_t>& mem) const = 0;
224
225 public:
226 Record(const Params& p, uint8_t _type) : SimObject(p), type(_type) {}
227
229 prepare() const
230 {
233 return mem;
234 }
235};
236
237class LAPIC : public Record
238{
239 protected:
240 PARAMS(X86ACPIMadtLAPIC);
241
243 {
244 uint8_t acpiProcessorId = 0;
245 uint8_t apicId = 0;
246 uint32_t flags = 0;
247 };
248 static_assert(std::is_trivially_copyable_v<Mem>,
249 "Type not suitable for memcpy.");
250
251 void prepareBuf(std::vector<uint8_t>& mem) const override;
252
253 public:
254 LAPIC(const Params& p) : Record(p, 0) {}
255};
256
257class IOAPIC : public Record
258{
259 protected:
260 PARAMS(X86ACPIMadtIOAPIC);
261
263 {
264 uint8_t ioApicId = 0;
265 uint8_t _reserved = 0;
266 uint32_t ioApicAddress = 0;
267 uint32_t intBase = 0;
268 };
269 static_assert(std::is_trivially_copyable_v<Mem>,
270 "Type not suitable for memcpy.");
271
272 void prepareBuf(std::vector<uint8_t>& mem) const override;
273
274 public:
275 IOAPIC(const Params& p) : Record(p, 1) {}
276};
277
279{
280 protected:
281 PARAMS(X86ACPIMadtIntSourceOverride);
282
284 {
285 uint8_t busSource = 0;
286 uint8_t irqSource = 0;
287 uint32_t globalSystemInterrupt = 0;
288 uint16_t flags = 0;
289 };
290 static_assert(std::is_trivially_copyable_v<Mem>,
291 "Type not suitable for memcpy.");
292
293 void prepareBuf(std::vector<uint8_t>& mem) const override;
294
295 public:
297};
298
299class NMI : public Record
300{
301 protected:
302 PARAMS(X86ACPIMadtNMI);
303
305 {
306 uint8_t acpiProcessorId = 0;
307 uint16_t flags = 0;
308 uint8_t lintNo = 0;
309 };
310 static_assert(std::is_trivially_copyable_v<Mem>,
311 "Type not suitable for memcpy.");
312
313 void prepareBuf(std::vector<uint8_t>& mem) const override;
314
315 public:
316 NMI(const Params& p) : Record(p, 3) {}
317};
318
319class LAPICOverride : public Record
320{
321 protected:
322 PARAMS(X86ACPIMadtLAPICOverride);
323
325 {
326 uint16_t _reserved = 0;
327 uint64_t localAPICAddress = 0;
328 };
329 static_assert(std::is_trivially_copyable_v<Mem>,
330 "Type not suitable for memcpy.");
331
332 void prepareBuf(std::vector<uint8_t>& mem) const override;
333
334 public:
335 LAPICOverride(const Params& p) : Record(p, 5) {}
336};
337
338class MADT : public SysDescTable
339{
340 protected:
341 PARAMS(X86ACPIMadt);
342
344 {
345 uint32_t localAPICAddress = 0;
346 uint32_t flags = 0;
347 };
348 static_assert(std::is_trivially_copyable_v<Mem>,
349 "Type not suitable for memcpy.");
350
352
353 Addr writeBuf(PortProxy& phys_proxy, Allocator& alloc,
354 std::vector<uint8_t>& mem) const override;
355
356 public:
357 MADT(const Params &p);
358};
359
360} // namespace MADT
361
362} // namespace ACPI
363
364} // namespace X86ISA
365} // namespace gem5
366
367#endif // __ARCH_X86_BIOS_E820_HH__
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
Abstract superclass for simulation objects.
SimObjectParams Params
IOAPIC(const Params &p)
Definition acpi.hh:275
void prepareBuf(std::vector< uint8_t > &mem) const override
Definition acpi.cc:279
void prepareBuf(std::vector< uint8_t > &mem) const override
Definition acpi.cc:293
PARAMS(X86ACPIMadtIntSourceOverride)
PARAMS(X86ACPIMadtLAPICOverride)
void prepareBuf(std::vector< uint8_t > &mem) const override
Definition acpi.cc:323
void prepareBuf(std::vector< uint8_t > &mem) const override
Definition acpi.cc:265
LAPIC(const Params &p)
Definition acpi.hh:254
std::vector< Record * > records
Definition acpi.hh:351
Addr writeBuf(PortProxy &phys_proxy, Allocator &alloc, std::vector< uint8_t > &mem) const override
Definition acpi.cc:229
NMI(const Params &p)
Definition acpi.hh:316
void prepareBuf(std::vector< uint8_t > &mem) const override
Definition acpi.cc:308
virtual void prepareBuf(std::vector< uint8_t > &mem) const =0
Definition acpi.cc:253
std::vector< uint8_t > prepare() const
Definition acpi.hh:229
Record(const Params &p, uint8_t _type)
Definition acpi.hh:226
static const char signature[]
Definition acpi.hh:99
RSDP(const Params &p)
Definition acpi.cc:104
Addr write(PortProxy &phys_proxy, Allocator &alloc) const
Definition acpi.cc:111
RSDT(const Params &p)
Definition acpi.cc:211
std::vector< SysDescTable * > entries
Definition acpi.hh:179
Addr writeBuf(PortProxy &phys_proxy, Allocator &alloc, std::vector< uint8_t > &mem) const override
Definition acpi.cc:186
RXSDT(const Params &p, const char *_signature, uint8_t _revision)
Definition acpi.cc:180
virtual Addr writeBuf(PortProxy &phys_proxy, Allocator &alloc, std::vector< uint8_t > &mem) const =0
Definition acpi.cc:144
PARAMS(X86ACPISysDescTable)
SysDescTable(const Params &p, const char *_signature, uint8_t _revision)
Definition acpi.hh:160
Addr write(PortProxy &phys_proxy, Allocator &alloc) const
Definition acpi.hh:166
XSDT(const Params &p)
Definition acpi.cc:216
STL vector class.
Definition stl.hh:37
uint8_t flags
Definition helpers.cc:87
Bitfield< 23, 16 > revision
Bitfield< 0 > p
Definition pagetable.hh:151
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria 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
PM4 packets.
virtual Addr alloc(std::size_t size, unsigned align=1)=0
LinearAllocator(Addr begin, Addr end=0)
Definition acpi.hh:82
Addr alloc(std::size_t size, unsigned align) override
Definition acpi.cc:91
bool_vector8 mem[]
Definition reset_stim.h:43

Generated on Tue Jun 18 2024 16:24:00 for gem5 by doxygen 1.11.0