diff --git a/src/arch/x86/bios/acpi.cc b/src/arch/x86/bios/acpi.cc index 20cf088807..8cdcdac3f6 100644 --- a/src/arch/x86/bios/acpi.cc +++ b/src/arch/x86/bios/acpi.cc @@ -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), diff --git a/src/arch/x86/bios/acpi.hh b/src/arch/x86/bios/acpi.hh index bc6e2cd19e..6fe0f6e302 100644 --- a/src/arch/x86/bios/acpi.hh +++ b/src/arch/x86/bios/acpi.hh @@ -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: