base, sim: Make ByteOrder into a ScopedEnum accessible to Python

There is currently no good way of passing a byte order as a Param
since the ByteOrder type is defined in C++. Make this into a generated
ScopedEnum that can be used in Params.

Change-Id: I990f402340c17c4e0799de57df19516ae61794d4
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33174
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gabe Black <gabeblack@google.com>
This commit is contained in:
Andreas Sandberg
2020-08-21 11:53:18 +01:00
parent 2ea459e6cd
commit 51992fa80a
43 changed files with 233 additions and 228 deletions

View File

@@ -43,10 +43,10 @@
const PixelConverter PixelConverter::rgba8888_le(4, 0, 8, 16, 8, 8, 8);
const PixelConverter PixelConverter::rgba8888_be(4, 0, 8, 16, 8, 8, 8,
BigEndianByteOrder);
ByteOrder::big);
const PixelConverter PixelConverter::rgb565_le(2, 0, 5, 11, 5, 6, 5);
const PixelConverter PixelConverter::rgb565_be(2, 0, 5, 11, 5, 6, 5,
BigEndianByteOrder);
ByteOrder::big);
PixelConverter::PixelConverter(unsigned _length,
unsigned ro, unsigned go, unsigned bo,
@@ -74,7 +74,7 @@ PixelConverter::readWord(const uint8_t *p) const
{
uint32_t word(0);
if (byte_order == LittleEndianByteOrder) {
if (byte_order == ByteOrder::little) {
for (int i = 0; i < length; ++i)
word |= p[i] << (8 * i);
} else {
@@ -88,7 +88,7 @@ PixelConverter::readWord(const uint8_t *p) const
void
PixelConverter::writeWord(uint8_t *p, uint32_t word) const
{
if (byte_order == LittleEndianByteOrder) {
if (byte_order == ByteOrder::little) {
for (int i = 0; i < length; ++i)
p[i] = (word >> (8 * i)) & 0xFF;
} else {

View File

@@ -127,7 +127,7 @@ class PixelConverter
PixelConverter(unsigned length,
unsigned ro, unsigned go, unsigned bo,
unsigned rw, unsigned gw, unsigned bw,
ByteOrder byte_order = LittleEndianByteOrder);
ByteOrder byte_order = ByteOrder::little);
/** Get the Pixel representation of a color word. */
Pixel toPixel(uint32_t word) const {

View File

@@ -43,6 +43,8 @@
#include <stdexcept>
#include "base/refcnt.hh"
/* Hide the fact that this enum is generated by Python */
#include "enums/ByteOrder.hh"
/** uint64_t constant */
#define ULL(N) ((uint64_t)N##ULL)
@@ -242,9 +244,4 @@ typedef std::shared_ptr<FaultBase> Fault;
// we just create an alias.
constexpr decltype(nullptr) NoFault = nullptr;
enum ByteOrder {
BigEndianByteOrder,
LittleEndianByteOrder
};
#endif // __BASE_TYPES_HH__

View File

@@ -75,7 +75,7 @@ const PixelConverter VncServer::pixelConverter(
4, // 4 bytes / pixel
16, 8, 0, // R in [23, 16], G in [15, 8], B in [7, 0]
8, 8, 8, // 8 bits / channel
LittleEndianByteOrder);
ByteOrder::little);
/** @file
* Implementiation of a VNC server
@@ -130,7 +130,7 @@ VncServer::VncServer(const Params *p)
// around for telling the client and making sure it cooperates
pixelFormat.bpp = 8 * pixelConverter.length;
pixelFormat.depth = pixelConverter.depth;
pixelFormat.bigendian = pixelConverter.byte_order == BigEndianByteOrder;
pixelFormat.bigendian = pixelConverter.byte_order == ByteOrder::big;
pixelFormat.truecolor = 1;
pixelFormat.redmax = pixelConverter.ch_r.mask;
pixelFormat.greenmax = pixelConverter.ch_g.mask;