From 0d9ca42bbedbac16b69d436e76144b61eb50a554 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Fri, 21 Aug 2020 11:55:00 +0100 Subject: [PATCH] sim: Expose the system's byte order as a param There are cases where a system's byte order isn't well-defined from an ISA. For example, Arm implementations can be either big or little endian, sometimes depending on a boot parameter. Decouple the CPU byte order from the System's default byte order by exposing the System's byte order as a parameter that defaults to big endian for SPARC and POWER and little endian for everything else. Change-Id: I24f87ea3a61b05042ede20dea6bb056af071d2c0 Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33175 Tested-by: kokoro Reviewed-by: Gabe Black --- src/sim/System.py | 8 ++++++++ src/sim/system.hh | 6 +----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/sim/System.py b/src/sim/System.py index dcef74be1..caf32fb56 100644 --- a/src/sim/System.py +++ b/src/sim/System.py @@ -48,6 +48,11 @@ from m5.objects.SimpleMemory import * class MemoryMode(Enum): vals = ['invalid', 'atomic', 'timing', 'atomic_noncaching'] +if buildEnv['TARGET_ISA'] in ('sparc', 'power'): + default_byte_order = 'big' +else: + default_byte_order = 'little' + class System(SimObject): type = 'System' cxx_header = "sim/system.hh" @@ -84,6 +89,9 @@ class System(SimObject): cache_line_size = Param.Unsigned(64, "Cache line size in bytes") + byte_order = Param.ByteOrder(default_byte_order, + "Default byte order of system components") + redirect_paths = VectorParam.RedirectPath([], "Path redirections") exit_on_work_items = Param.Bool(False, "Exit from the simulation loop when " diff --git a/src/sim/system.hh b/src/sim/system.hh index 8e2c47258..8b31b2fe6 100644 --- a/src/sim/system.hh +++ b/src/sim/system.hh @@ -386,11 +386,7 @@ class System : public SimObject, public PCEventScope ByteOrder getGuestByteOrder() const { -#if THE_ISA != NULL_ISA - return TheISA::GuestByteOrder; -#else - panic("The NULL ISA has no endianness."); -#endif + return _params->byte_order; } /** -- 2.30.2