arch-x86: Add allocator for ACPI tables

This adds an allocator class to allocate memory linearly. It is intended
to be used by ACPI tables to dynamically request memory to write the
ACPI tables to.

Change-Id: I43c71d2b8e676f8ac0fd08b9468b00b6212d85b6
Signed-off-by: Maximilian Stein <m@steiny.biz>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/42823
Reviewed-by: Gabe Black <gabe.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Maximilian Stein
2021-03-11 19:04:37 +01:00
parent b22b7f2d66
commit e24d4b8659
2 changed files with 32 additions and 0 deletions

View File

@@ -45,6 +45,20 @@
#include "sim/byteswap.hh"
#include "sim/sim_object.hh"
Addr
X86ISA::ACPI::LinearAllocator::alloc(std::size_t size, unsigned align)
{
if (align) {
unsigned offset = next % align;
if (offset)
next += (align - offset);
}
Addr chunk = next;
next += size;
assert(0 == end || next <= end);
return chunk;
}
const char X86ISA::ACPI::RSDP::signature[] = "RSD PTR ";
X86ISA::ACPI::RSDP::RSDP(const Params &p) : SimObject(p), oemID(p.oem_id),

View File

@@ -62,6 +62,24 @@ class RSDT;
class XSDT;
class SysDescTable;
struct Allocator
{
virtual Addr alloc(std::size_t size, unsigned align=1) = 0;
};
struct LinearAllocator : public Allocator
{
LinearAllocator(Addr begin, Addr end=0) :
next(begin),
end(end)
{}
Addr alloc(std::size_t size, unsigned align) override;
protected:
Addr next;
Addr const end;
};
class RSDP : public SimObject
{
protected: