Maximilian Stein has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/42823 )
Change subject: arch-x86: Add allocator for ACPI tables
......................................................................
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 <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/42823
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
---
M src/arch/x86/bios/acpi.cc
M src/arch/x86/bios/acpi.hh
2 files changed, 32 insertions(+), 0 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/x86/bios/acpi.cc b/src/arch/x86/bios/acpi.cc
index 20cf088..8cdcdac 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 bc6e2cd..6fe0f6e 100644
--- a/src/arch/x86/bios/acpi.hh
+++ b/src/arch/x86/bios/acpi.hh
@@ -62,6 +62,24 @@
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:
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/42823
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I43c71d2b8e676f8ac0fd08b9468b00b6212d85b6
Gerrit-Change-Number: 42823
Gerrit-PatchSet: 4
Gerrit-Owner: Maximilian Stein <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Maximilian Stein <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-CC: Jason Lowe-Power <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s