gem5  v21.1.0.2
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 
62 namespace gem5
63 {
64 
65 class PortProxy;
66 
67 namespace X86ISA
68 {
69 
70 namespace ACPI
71 {
72 
73 class RSDT;
74 class XSDT;
75 
76 struct Allocator
77 {
78  virtual Addr alloc(std::size_t size, unsigned align=1) = 0;
79 };
80 struct LinearAllocator : public Allocator
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 
94 class RSDP : public SimObject
95 {
96  protected:
97  PARAMS(X86ACPIRSDP);
98 
99  static const char signature[];
100 
101  struct GEM5_PACKED MemR0
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<MemR0>::value,
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<Mem>::value,
122  "Type not suitable for memcpy,");
123 
124  RSDT* rsdt;
126 
127  public:
128  RSDP(const Params &p);
129 
130  Addr write(PortProxy& phys_proxy, Allocator& alloc) const;
131 };
132 
133 class SysDescTable : public SimObject
134 {
135  protected:
136  PARAMS(X86ACPISysDescTable);
137 
138  struct GEM5_PACKED Mem
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<Mem>::value,
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 
173 template<class T>
174 class 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 
188 class RSDT : public RXSDT<uint32_t>
189 {
190  protected:
191  PARAMS(X86ACPIRSDT);
192 
193  public:
194  RSDT(const Params &p);
195 };
196 
197 class XSDT : public RXSDT<uint64_t>
198 {
199  protected:
200  PARAMS(X86ACPIXSDT);
201 
202  public:
203  XSDT(const Params &p);
204 };
205 
206 namespace MADT
207 {
208 class Record : public SimObject
209 {
210  protected:
211  PARAMS(X86ACPIMadtRecord);
212 
213  struct GEM5_PACKED Mem
214  {
215  uint8_t type = 0;
216  uint8_t length = 0;
217  };
218  static_assert(std::is_trivially_copyable<Mem>::value,
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  {
232  prepareBuf(mem);
233  return mem;
234  }
235 };
236 
237 class LAPIC : public Record
238 {
239  protected:
240  PARAMS(X86ACPIMadtLAPIC);
241 
242  struct GEM5_PACKED Mem : public Record::Mem
243  {
244  uint8_t acpiProcessorId = 0;
245  uint8_t apicId = 0;
246  uint32_t flags = 0;
247  };
248  static_assert(std::is_trivially_copyable<Mem>::value,
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 
257 class IOAPIC : public Record
258 {
259  protected:
260  PARAMS(X86ACPIMadtIOAPIC);
261 
262  struct GEM5_PACKED Mem : public Record::Mem
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<Mem>::value,
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 
278 class IntSourceOverride : public Record
279 {
280  protected:
281  PARAMS(X86ACPIMadtIntSourceOverride);
282 
283  struct GEM5_PACKED Mem : public Record::Mem
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<Mem>::value,
291  "Type not suitable for memcpy.");
292 
293  void prepareBuf(std::vector<uint8_t>& mem) const override;
294 
295  public:
296  IntSourceOverride(const Params& p) : Record(p, 2) {}
297 };
298 
299 class NMI : public Record
300 {
301  protected:
302  PARAMS(X86ACPIMadtNMI);
303 
304  struct GEM5_PACKED Mem : public Record::Mem
305  {
306  uint8_t acpiProcessorId = 0;
307  uint16_t flags = 0;
308  uint8_t lintNo = 0;
309  };
310  static_assert(std::is_trivially_copyable<Mem>::value,
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 
319 class LAPICOverride : public Record
320 {
321  protected:
322  PARAMS(X86ACPIMadtLAPICOverride);
323 
324  struct GEM5_PACKED Mem : public Record::Mem
325  {
326  uint16_t _reserved = 0;
327  uint64_t localAPICAddress = 0;
328  };
329  static_assert(std::is_trivially_copyable<Mem>::value,
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 
338 class MADT : public SysDescTable
339 {
340  protected:
341  PARAMS(X86ACPIMadt);
342 
343  struct GEM5_PACKED Mem : public SysDescTable::Mem
344  {
345  uint32_t localAPICAddress = 0;
346  uint32_t flags = 0;
347  };
348  static_assert(std::is_trivially_copyable<Mem>::value,
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__
gem5::X86ISA::ACPI::MADT::IntSourceOverride::prepareBuf
void prepareBuf(std::vector< uint8_t > &mem) const override
Definition: acpi.cc:293
gem5::X86ISA::ACPI::RSDP
Definition: acpi.hh:94
gem5::X86ISA::ACPI::SysDescTable::SysDescTable
SysDescTable(const Params &p, const char *_signature, uint8_t _revision)
Definition: acpi.hh:160
gem5::X86ISA::ACPI::SysDescTable::Mem
Definition: acpi.hh:138
gem5::X86ISA::ACPI::LinearAllocator::LinearAllocator
LinearAllocator(Addr begin, Addr end=0)
Definition: acpi.hh:82
gem5::X86ISA::ACPI::MADT::MADT::PARAMS
PARAMS(X86ACPIMadt)
gem5::X86ISA::ACPI::MADT::Record::prepare
std::vector< uint8_t > prepare() const
Definition: acpi.hh:229
gem5::X86ISA::ACPI::MADT::LAPIC
Definition: acpi.hh:237
gem5::X86ISA::ACPI::LinearAllocator::alloc
Addr alloc(std::size_t size, unsigned align) override
Definition: acpi.cc:91
gem5::X86ISA::ACPI::MADT::MADT::writeBuf
Addr writeBuf(PortProxy &phys_proxy, Allocator &alloc, std::vector< uint8_t > &mem) const override
Definition: acpi.cc:229
gem5::X86ISA::ACPI::RSDP::xsdt
XSDT * xsdt
Definition: acpi.hh:125
gem5::X86ISA::ACPI::MADT::LAPIC::LAPIC
LAPIC(const Params &p)
Definition: acpi.hh:254
gem5::X86ISA::ACPI::MADT::MADT::records
std::vector< Record * > records
Definition: acpi.hh:349
gem5::X86ISA::ACPI::MADT::NMI::NMI
NMI(const Params &p)
Definition: acpi.hh:316
gem5::X86ISA::ACPI::RSDP::MemR0
Definition: acpi.hh:101
gem5::X86ISA::ACPI::SysDescTable
Definition: acpi.hh:133
gem5::X86ISA::ACPI::MADT::IOAPIC
Definition: acpi.hh:257
gem5::X86ISA::ACPI::MADT::IOAPIC::IOAPIC
IOAPIC(const Params &p)
Definition: acpi.hh:275
gem5::X86ISA::ACPI::MADT::Record::prepareBuf
virtual void prepareBuf(std::vector< uint8_t > &mem) const =0
Definition: acpi.cc:253
gem5::X86ISA::ACPI::RSDP::rsdt
RSDT * rsdt
Definition: acpi.hh:122
std::vector< uint8_t >
gem5::X86ISA::ACPI::MADT::IntSourceOverride
Definition: acpi.hh:278
gem5::X86ISA::ACPI::RSDP::signature
static const char signature[]
Definition: acpi.hh:99
gem5::X86ISA::ACPI::MADT::LAPICOverride::PARAMS
PARAMS(X86ACPIMadtLAPICOverride)
gem5::X86ISA::ACPI::MADT::IOAPIC::Mem
Definition: acpi.hh:262
gem5::X86ISA::ACPI::RXSDT::RXSDT
RXSDT(const Params &p, const char *_signature, uint8_t _revision)
Definition: acpi.cc:180
gem5::X86ISA::ACPI::MADT::NMI
Definition: acpi.hh:299
sc_dt::align
void align(const scfx_rep &lhs, const scfx_rep &rhs, int &new_wp, int &len_mant, scfx_mant_ref &lhs_mant, scfx_mant_ref &rhs_mant)
Definition: scfx_rep.cc:2083
gem5::X86ISA::ACPI::MADT::Record::PARAMS
PARAMS(X86ACPIMadtRecord)
gem5::SimObject::Params
SimObjectParams Params
Definition: sim_object.hh:170
gem5::X86ISA::ACPI::XSDT::PARAMS
PARAMS(X86ACPIXSDT)
gem5::X86ISA::ACPI::RSDP::write
Addr write(PortProxy &phys_proxy, Allocator &alloc) const
Definition: acpi.cc:111
gem5::X86ISA::ACPI::MADT::Record
Definition: acpi.hh:208
gem5::X86ISA::ACPI::RSDP::PARAMS
PARAMS(X86ACPIRSDP)
gem5::X86ISA::ACPI::SysDescTable::write
Addr write(PortProxy &phys_proxy, Allocator &alloc) const
Definition: acpi.hh:166
gem5::X86ISA::ACPI::MADT::Record::Mem
Definition: acpi.hh:213
gem5::X86ISA::ACPI::Allocator::alloc
virtual Addr alloc(std::size_t size, unsigned align=1)=0
sim_object.hh
gem5::X86ISA::ACPI::LinearAllocator::end
const Addr end
Definition: acpi.hh:91
gem5::X86ISA::ACPI::RSDT::RSDT
RSDT(const Params &p)
Definition: acpi.cc:211
gem5::X86ISA::ACPI::MADT::Record::type
uint8_t type
Definition: acpi.hh:219
gem5::X86ISA::ACPI::MADT::NMI::prepareBuf
void prepareBuf(std::vector< uint8_t > &mem) const override
Definition: acpi.cc:308
gem5::X86ISA::ACPI::MADT::LAPIC::PARAMS
PARAMS(X86ACPIMadtLAPIC)
gem5::X86ISA::ACPI::SysDescTable::PARAMS
PARAMS(X86ACPISysDescTable)
gem5::X86ISA::ACPI::RSDP::Mem
Definition: acpi.hh:113
gem5::X86ISA::ACPI::MADT::LAPICOverride::Mem
Definition: acpi.hh:324
gem5::PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:86
gem5::X86ISA::ACPI::RXSDT< uint64_t >::Ptr
uint64_t Ptr
Definition: acpi.hh:177
gem5::X86ISA::ACPI::RXSDT
Definition: acpi.hh:174
gem5::X86ISA::ACPI::LinearAllocator
Definition: acpi.hh:80
gem5::X86ISA::ACPI::MADT::NMI::PARAMS
PARAMS(X86ACPIMadtNMI)
compiler.hh
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::X86ISA::ACPI::XSDT::XSDT
XSDT(const Params &p)
Definition: acpi.cc:216
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::X86ISA::ACPI::SysDescTable::revision
uint8_t revision
Definition: acpi.hh:158
gem5::X86ISA::ACPI::MADT::LAPICOverride::prepareBuf
void prepareBuf(std::vector< uint8_t > &mem) const override
Definition: acpi.cc:323
gem5::X86ISA::ACPI::RSDT
Definition: acpi.hh:188
gem5::X86ISA::ACPI::MADT::MADT::MADT
MADT(const Params &p)
Definition: acpi.cc:223
gem5::X86ISA::ACPI::MADT::LAPICOverride::LAPICOverride
LAPICOverride(const Params &p)
Definition: acpi.hh:335
gem5::X86ISA::ACPI::MADT::MADT
Definition: acpi.hh:338
gem5::X86ISA::ACPI::Allocator
Definition: acpi.hh:76
gem5::X86ISA::ACPI::RXSDT::entries
std::vector< SysDescTable * > entries
Definition: acpi.hh:179
gem5::X86ISA::ACPI::MADT::LAPIC::Mem
Definition: acpi.hh:242
gem5::X86ISA::ACPI::LinearAllocator::next
Addr next
Definition: acpi.hh:90
types.hh
gem5::X86ISA::ACPI::MADT::LAPICOverride
Definition: acpi.hh:319
gem5::X86ISA::ACPI::MADT::MADT::Mem
Definition: acpi.hh:343
gem5::X86ISA::ACPI::XSDT
Definition: acpi.hh:197
gem5::X86ISA::ACPI::MADT::Record::Record
Record(const Params &p, uint8_t _type)
Definition: acpi.hh:226
gem5::X86ISA::ACPI::SysDescTable::signature
const char * signature
Definition: acpi.hh:157
gem5::X86ISA::ACPI::SysDescTable::writeBuf
virtual Addr writeBuf(PortProxy &phys_proxy, Allocator &alloc, std::vector< uint8_t > &mem) const =0
Definition: acpi.cc:144
gem5::X86ISA::ACPI::MADT::IntSourceOverride::Mem
Definition: acpi.hh:283
gem5::X86ISA::p
Bitfield< 0 > p
Definition: pagetable.hh:151
gem5::X86ISA::ACPI::MADT::LAPIC::prepareBuf
void prepareBuf(std::vector< uint8_t > &mem) const override
Definition: acpi.cc:265
mem
bool_vector8 mem[]
Definition: reset_stim.h:43
gem5::X86ISA::ACPI::RXSDT::writeBuf
Addr writeBuf(PortProxy &phys_proxy, Allocator &alloc, std::vector< uint8_t > &mem) const override
Definition: acpi.cc:186
gem5::X86ISA::ACPI::MADT::IntSourceOverride::IntSourceOverride
IntSourceOverride(const Params &p)
Definition: acpi.hh:296
gem5::X86ISA::ACPI::RSDP::RSDP
RSDP(const Params &p)
Definition: acpi.cc:104
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::X86ISA::ACPI::MADT::NMI::Mem
Definition: acpi.hh:304
gem5::X86ISA::ACPI::RSDT::PARAMS
PARAMS(X86ACPIRSDT)
gem5::X86ISA::ACPI::MADT::IntSourceOverride::PARAMS
PARAMS(X86ACPIMadtIntSourceOverride)
gem5::X86ISA::ACPI::MADT::IOAPIC::PARAMS
PARAMS(X86ACPIMadtIOAPIC)
gem5::X86ISA::ACPI::MADT::IOAPIC::prepareBuf
void prepareBuf(std::vector< uint8_t > &mem) const override
Definition: acpi.cc:279

Generated on Tue Sep 21 2021 12:24:51 for gem5 by doxygen 1.8.17