base, sim: Make ByteOrder into a ScopedEnum accessible to Python
authorAndreas Sandberg <andreas.sandberg@arm.com>
Fri, 21 Aug 2020 10:53:18 +0000 (11:53 +0100)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Tue, 8 Sep 2020 16:24:00 +0000 (16:24 +0000)
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>
43 files changed:
src/arch/arm/aapcs32.hh
src/arch/arm/freebsd/freebsd.hh
src/arch/arm/isa_traits.hh
src/arch/arm/linux/linux.hh
src/arch/arm/process.cc
src/arch/arm/utility.hh
src/arch/generic/memhelpers.hh
src/arch/mips/isa_traits.hh
src/arch/mips/linux/linux.hh
src/arch/mips/process.cc
src/arch/power/isa_traits.hh
src/arch/power/linux/linux.hh
src/arch/power/process.cc
src/arch/riscv/isa_traits.hh
src/arch/riscv/linux/linux.hh
src/arch/sparc/isa_traits.hh
src/arch/sparc/linux/linux.hh
src/arch/sparc/process.cc
src/arch/sparc/solaris/solaris.hh
src/arch/x86/isa_traits.hh
src/arch/x86/linux/linux.hh
src/arch/x86/process.cc
src/base/pixel.cc
src/base/pixel.hh
src/base/types.hh
src/base/vnc/vncserver.cc
src/dev/arm/amba_device.cc
src/dev/arm/fvp_base_pwr_ctrl.cc
src/dev/arm/generic_timer.cc
src/dev/arm/gic_v3.cc
src/dev/arm/gic_v3_its.cc
src/dev/arm/hdlcd.cc
src/dev/arm/kmi.cc
src/dev/arm/pl011.cc
src/dev/arm/pl111.cc
src/dev/arm/rtc_pl031.cc
src/dev/arm/watchdog_sp805.cc
src/dev/serial/simple.cc
src/mem/cache/prefetch/base.hh
src/mem/packet_access.hh
src/python/m5/params.py
src/sim/byteswap.hh
src/sim/byteswap.test.cc

index 7f40bd39bedcae734b2469fef0bf986dc663c566..3cd2c50fda90cbf96beeef46172be808d5c0e760 100644 (file)
@@ -165,7 +165,7 @@ struct Result<Aapcs32, Integer, typename std::enable_if<
     {
         if (std::is_same<Integer, Addr>::value) {
             tc->setIntReg(ArmISA::INTREG_R0, (uint32_t)i);
-        } else if (ArmISA::byteOrder(tc) == LittleEndianByteOrder) {
+        } else if (ArmISA::byteOrder(tc) == ByteOrder::little) {
             tc->setIntReg(ArmISA::INTREG_R0, (uint32_t)(i >> 0));
             tc->setIntReg(ArmISA::INTREG_R1, (uint32_t)(i >> 32));
         } else {
@@ -213,7 +213,7 @@ struct Argument<Aapcs32, Integer, typename std::enable_if<
         if (sizeof(Integer) == sizeof(uint64_t) &&
                 state.ncrn + 1 <= state.MAX_CRN) {
             Integer low, high;
-            if (ArmISA::byteOrder(tc) == LittleEndianByteOrder) {
+            if (ArmISA::byteOrder(tc) == ByteOrder::little) {
                 low = tc->readIntReg(state.ncrn++) & mask(32);
                 high = tc->readIntReg(state.ncrn++) & mask(32);
             } else {
index b1360473e4d7e9661cfeb4d1587c2c4df5a2d93e..ef9da65fae3646abe34b8aa0282ac03102270bb4 100644 (file)
@@ -38,7 +38,7 @@
 class ArmFreebsd : public FreeBSD
 {
   public:
-    static const ByteOrder byteOrder = LittleEndianByteOrder;
+    static const ByteOrder byteOrder = ByteOrder::little;
 };
 
 class ArmFreebsd32 : public ArmFreebsd
index 4a7312c4ce18780f76cd8b22af7af4ae87e402eb..81d4b4f94266b4bbcc9d18ad28d7d4cf45071b89 100644 (file)
@@ -46,7 +46,7 @@
 
 namespace ArmISA
 {
-    const ByteOrder GuestByteOrder = LittleEndianByteOrder;
+    const ByteOrder GuestByteOrder = ByteOrder::little;
 
     const Addr PageShift = 12;
     const Addr PageBytes = ULL(1) << PageShift;
index 6aee4466d8398bb994b348166c89944097a6aab6..5fd6cdc0c0cdc6ffab5f87230be844e944d2e448 100644 (file)
@@ -48,7 +48,7 @@
 class ArmLinux : public Linux
 {
   public:
-    static const ByteOrder byteOrder = LittleEndianByteOrder;
+    static const ByteOrder byteOrder = ByteOrder::little;
 
     static void
     archClone(uint64_t flags,
index c5ef141e320675a45288b745f147c1760000d4fc..1734066cc839cffa8511066c1451c5672836b425 100644 (file)
@@ -435,9 +435,9 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex)
     auxv_array_end += sizeof(zero);
 
     copyStringArray(envp, envp_array_base, env_data_base,
-                    LittleEndianByteOrder, *initVirtMem);
+                    ByteOrder::little, *initVirtMem);
     copyStringArray(argv, argv_array_base, arg_data_base,
-                    LittleEndianByteOrder, *initVirtMem);
+                    ByteOrder::little, *initVirtMem);
 
     initVirtMem->writeBlob(argc_base, &guestArgc, intSize);
 
index f17ebc5f9d7a6f30f2bf6081e0a70209171f57ae..636625d8b76a007ef8b6d2159fbdce46f81adf49 100644 (file)
@@ -448,7 +448,7 @@ uint8_t encodePhysAddrRange64(int pa_size);
 
 inline ByteOrder byteOrder(const ThreadContext *tc)
 {
-    return isBigEndian64(tc) ? BigEndianByteOrder : LittleEndianByteOrder;
+    return isBigEndian64(tc) ? ByteOrder::big : ByteOrder::little;
 };
 
 bool isUnpriviledgeAccess(ThreadContext * tc);
index d08bea9146843c926e292b7c8d3c81037d532ec9..2a5a380e36567c1400c532770b427c9a9fcaf367 100644 (file)
@@ -72,14 +72,14 @@ template <class MemT>
 void
 getMemLE(PacketPtr pkt, MemT &mem, Trace::InstRecord *traceData)
 {
-    getMem<LittleEndianByteOrder>(pkt, mem, traceData);
+    getMem<ByteOrder::little>(pkt, mem, traceData);
 }
 
 template <class MemT>
 void
 getMemBE(PacketPtr pkt, MemT &mem, Trace::InstRecord *traceData)
 {
-    getMem<BigEndianByteOrder>(pkt, mem, traceData);
+    getMem<ByteOrder::big>(pkt, mem, traceData);
 }
 
 /// Read from memory in atomic mode.
@@ -103,7 +103,7 @@ Fault
 readMemAtomicLE(XC *xc, Trace::InstRecord *traceData, Addr addr, MemT &mem,
                 Request::Flags flags)
 {
-    return readMemAtomic<LittleEndianByteOrder>(
+    return readMemAtomic<ByteOrder::little>(
             xc, traceData, addr, mem, flags);
 }
 
@@ -112,7 +112,7 @@ Fault
 readMemAtomicBE(XC *xc, Trace::InstRecord *traceData, Addr addr, MemT &mem,
                 Request::Flags flags)
 {
-    return readMemAtomic<BigEndianByteOrder>(xc, traceData, addr, mem, flags);
+    return readMemAtomic<ByteOrder::big>(xc, traceData, addr, mem, flags);
 }
 
 /// Write to memory in timing mode.
@@ -133,7 +133,7 @@ Fault
 writeMemTimingLE(XC *xc, Trace::InstRecord *traceData, MemT mem, Addr addr,
                Request::Flags flags, uint64_t *res)
 {
-    return writeMemTiming<LittleEndianByteOrder>(
+    return writeMemTiming<ByteOrder::little>(
             xc, traceData, mem, addr, flags, res);
 }
 
@@ -142,7 +142,7 @@ Fault
 writeMemTimingBE(XC *xc, Trace::InstRecord *traceData, MemT mem, Addr addr,
                Request::Flags flags, uint64_t *res)
 {
-    return writeMemTiming<BigEndianByteOrder>(
+    return writeMemTiming<ByteOrder::big>(
             xc, traceData, mem, addr, flags, res);
 }
 
@@ -172,7 +172,7 @@ Fault
 writeMemAtomicLE(XC *xc, Trace::InstRecord *traceData, const MemT &mem,
                  Addr addr, Request::Flags flags, uint64_t *res)
 {
-    return writeMemAtomic<LittleEndianByteOrder>(
+    return writeMemAtomic<ByteOrder::little>(
             xc, traceData, mem, addr, flags, res);
 }
 
@@ -181,7 +181,7 @@ Fault
 writeMemAtomicBE(XC *xc, Trace::InstRecord *traceData, const MemT &mem,
                  Addr addr, Request::Flags flags, uint64_t *res)
 {
-    return writeMemAtomic<BigEndianByteOrder>(
+    return writeMemAtomic<ByteOrder::big>(
             xc, traceData, mem, addr, flags, res);
 }
 
@@ -213,7 +213,7 @@ Fault
 amoMemAtomicLE(XC *xc, Trace::InstRecord *traceData, MemT &mem, Addr addr,
                Request::Flags flags, AtomicOpFunctor *_amo_op)
 {
-    return amoMemAtomic<LittleEndianByteOrder>(
+    return amoMemAtomic<ByteOrder::little>(
             xc, traceData, mem, addr, flags, _amo_op);
 }
 
@@ -222,7 +222,7 @@ Fault
 amoMemAtomicBE(XC *xc, Trace::InstRecord *traceData, MemT &mem, Addr addr,
                Request::Flags flags, AtomicOpFunctor *_amo_op)
 {
-    return amoMemAtomic<BigEndianByteOrder>(
+    return amoMemAtomic<ByteOrder::big>(
             xc, traceData, mem, addr, flags, _amo_op);
 }
 
index 5aa167eb4baa88311b1ae5d3c9f5714bd0d3c7e4..aac595a2dff7f8e6d36c435dc8759704fdd33b03 100644 (file)
@@ -35,7 +35,7 @@
 namespace MipsISA
 {
 
-const ByteOrder GuestByteOrder = LittleEndianByteOrder;
+const ByteOrder GuestByteOrder = ByteOrder::little;
 
 const Addr PageShift = 13;
 const Addr PageBytes = ULL(1) << PageShift;
index 4fcc71072fe7dfa688c8f9521632b78b7bd02698..ca24c8999613ec0a8544de9cceeab304eaf7aa55 100644 (file)
@@ -35,7 +35,7 @@ class MipsLinux : public Linux
 {
   public:
 
-    static const ByteOrder byteOrder = LittleEndianByteOrder;
+    static const ByteOrder byteOrder = ByteOrder::little;
 
     static const int TGT_SIGHUP         = 0x000001;
     static const int TGT_SIGINT         = 0x000002;
index cdda2b2936049b43992eac2becda8a7e4edb8d0a..f8916af8b1d77c00ba53b066adc92d7f6c1a91f1 100644 (file)
@@ -170,10 +170,10 @@ MipsProcess::argsInit(int pageSize)
     initVirtMem->writeBlob(memState->getStackMin(), &argc, intSize);
 
     copyStringArray(argv, argv_array_base, arg_data_base,
-                    LittleEndianByteOrder, *initVirtMem);
+                    ByteOrder::little, *initVirtMem);
 
     copyStringArray(envp, envp_array_base, env_data_base,
-                    LittleEndianByteOrder, *initVirtMem);
+                    ByteOrder::little, *initVirtMem);
 
     // Fix up the aux vectors which point to data.
     for (auto &aux: auxv) {
index ba7b2f39001126cbbf4268dc8965f776c4c4fee8..4cf0c44301d76daf2d5522669d67eea6d71e5e1b 100644 (file)
@@ -36,7 +36,7 @@
 namespace PowerISA
 {
 
-const ByteOrder GuestByteOrder = BigEndianByteOrder;
+const ByteOrder GuestByteOrder = ByteOrder::big;
 
 const Addr PageShift = 12;
 const Addr PageBytes = ULL(1) << PageShift;
index 40dfbfbb16ae1ec67159cd4551d87964b6d099b7..86936cb2da247d807382fdaf7a333c1d0981beed 100644 (file)
@@ -40,7 +40,7 @@ class PowerLinux : public Linux
 {
   public:
 
-    static const ByteOrder byteOrder = BigEndianByteOrder;
+    static const ByteOrder byteOrder = ByteOrder::big;
 
     typedef int32_t time_t;
 
index 8168482c4e753657bb4aa9422da2b339eb779b1a..19834e9997bf4a7e0f3914fc6506ee832281bea8 100644 (file)
@@ -261,9 +261,9 @@ PowerProcess::argsInit(int intSize, int pageSize)
     auxv_array_end += sizeof(zero);
 
     copyStringArray(envp, envp_array_base, env_data_base,
-                    BigEndianByteOrder, *initVirtMem);
+                    ByteOrder::big, *initVirtMem);
     copyStringArray(argv, argv_array_base, arg_data_base,
-                    BigEndianByteOrder, *initVirtMem);
+                    ByteOrder::big, *initVirtMem);
 
     initVirtMem->writeBlob(argc_base, &guestArgc, intSize);
 
index 1bb2d264ef3f8c147fe4ccecaf7bd804ce18ab89..4cf455db8ff76a5b772581a1ae919b982ac258ab 100644 (file)
@@ -47,7 +47,7 @@
 namespace RiscvISA
 {
 
-const ByteOrder GuestByteOrder = LittleEndianByteOrder;
+const ByteOrder GuestByteOrder = ByteOrder::little;
 
 const Addr PageShift = 12;
 const Addr PageBytes = ULL(1) << PageShift;
index 89c114db83158ddc6c7baffa592f6a01ca958814..0b10b7a48c5d04320af824cc5de21eea6824779b 100644 (file)
@@ -35,7 +35,7 @@
 class RiscvLinux : public Linux
 {
   public:
-    static const ByteOrder byteOrder = LittleEndianByteOrder;
+    static const ByteOrder byteOrder = ByteOrder::little;
 };
 
 class RiscvLinux64 : public RiscvLinux
index e1917f910296c11b548454126a6bf9e112385733..3f7cdac0f36289dda3319b600ea512d2e4d5c2bc 100644 (file)
@@ -34,7 +34,7 @@
 namespace SparcISA
 {
 
-const ByteOrder GuestByteOrder = BigEndianByteOrder;
+const ByteOrder GuestByteOrder = ByteOrder::big;
 
 const Addr PageShift = 13;
 const Addr PageBytes = ULL(1) << PageShift;
index 89cd207fb4272d0a4eed29ddc8dcab279dae7bbc..ed50a30c30c112372b1ed1daed666bb4e4ab3f50 100644 (file)
@@ -36,7 +36,7 @@ class SparcLinux : public Linux
 {
   public:
 
-    static const ByteOrder byteOrder = BigEndianByteOrder;
+    static const ByteOrder byteOrder = ByteOrder::big;
 
     struct tgt_stat
     {
index d28189cdbc9bdec592b6f842fc4e64168f177d95..159f58237d6f4ea1ae92b9f3374902df8f578022 100644 (file)
@@ -381,9 +381,9 @@ SparcProcess::argsInit(int pageSize)
     auxv_array_end += sizeof(zero);
 
     copyStringArray(envp, envp_array_base, env_data_base,
-                    BigEndianByteOrder, *initVirtMem);
+                    ByteOrder::big, *initVirtMem);
     copyStringArray(argv, argv_array_base, arg_data_base,
-                    BigEndianByteOrder, *initVirtMem);
+                    ByteOrder::big, *initVirtMem);
 
     initVirtMem->writeBlob(argc_base, &guestArgc, intSize);
 
index 5ca811d25f6554b745725dce12010b1bd7e25de6..0462832c411758bbd554dc8eb8dc152695a69a77 100644 (file)
@@ -35,7 +35,7 @@ class SparcSolaris : public Solaris
 {
   public:
 
-    static const ByteOrder byteOrder = BigEndianByteOrder;
+    static const ByteOrder byteOrder = ByteOrder::big;
 
     static SyscallFlagTransTable openFlagTable[];
 
index ce90b4bbd526427c6e3595de222c536aeee36f1a..dee98dc3a10d6553717e00fda90c272927d49b57 100644 (file)
@@ -42,7 +42,7 @@
 
 namespace X86ISA
 {
-    const ByteOrder GuestByteOrder = LittleEndianByteOrder;
+    const ByteOrder GuestByteOrder = ByteOrder::little;
 
     const Addr PageShift = 12;
     const Addr PageBytes = ULL(1) << PageShift;
index 4705123219dc633f0bd552156c425972fc48f90a..de27a742b9033f4a5b87ef5e98d458c03e146ba7 100644 (file)
@@ -46,7 +46,7 @@
 class X86Linux : public Linux
 {
   public:
-    static const ByteOrder byteOrder = LittleEndianByteOrder;
+    static const ByteOrder byteOrder = ByteOrder::little;
 
     static void
     archClone(uint64_t flags,
index 0324e9420d060c4ac6af9c87ccbdd9607c226b00..7718fdcaa1eda583925a1b3d4e835d34a73ead93 100644 (file)
@@ -969,9 +969,9 @@ X86Process::argsInit(int pageSize,
     initVirtMem->writeString(aux_data_base, platform.c_str());
 
     copyStringArray(envp, envp_array_base, env_data_base,
-                    LittleEndianByteOrder, *initVirtMem);
+                    ByteOrder::little, *initVirtMem);
     copyStringArray(argv, argv_array_base, arg_data_base,
-                    LittleEndianByteOrder, *initVirtMem);
+                    ByteOrder::little, *initVirtMem);
 
     initVirtMem->writeBlob(argc_base, &guestArgc, intSize);
 
index 44cb2d1ccbac43b5d200a271d1498dabbdca04b5..c21d0f1928ddd64dc5ed26af3b663021edc4d7a2 100644 (file)
 
 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 {
index a1c2b9a9feca2359acb3f2494e280e3c61da0a55..7937e895672ecbeb24896112b269ff56e4238b1b 100644 (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 {
index 4f606cd26ff6cdd4c3916a0be11932a41f314954..7ae573dd73f7cfb68b6d220571c48a07d5de8847 100644 (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__
index c6b1fe661ed77096080591c715297dbcc9136c86..dbf4d9c16f5ee451f030159e90ab1df17a02337c 100644 (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;
index 76872b197390f97529457164ccccb814a7b50b4e..4daf943271cd8f8818e19585d41c81493a0cf4a1 100644 (file)
@@ -81,6 +81,6 @@ AmbaDevice::readId(PacketPtr pkt, uint64_t amba_id, Addr pio_addr)
             (amba_id >> byte) & 0xFF,
             pkt->getAddr() - pio_addr, byte);
 
-    pkt->setUintX((amba_id >> byte) & 0xFF, LittleEndianByteOrder);
+    pkt->setUintX((amba_id >> byte) & 0xFF, ByteOrder::little);
     return true;
 }
index 7ab4e4091cda52c35d1bb9d762988d0a2f7f876b..86275989bca9aea35cbcd5978aad878dae179110 100644 (file)
@@ -151,7 +151,7 @@ FVPBasePwrCtrl::read(PacketPtr pkt)
     DPRINTF(FVPBasePwrCtrl, "FVPBasePwrCtrl::read: 0x%x<-0x%x(%i)\n", resp,
             addr, size);
 
-    pkt->setUintX(resp, LittleEndianByteOrder);
+    pkt->setUintX(resp, ByteOrder::little);
     pkt->makeResponse();
     return pioDelay;
 }
@@ -163,7 +163,7 @@ FVPBasePwrCtrl::write(PacketPtr pkt)
     const size_t size = pkt->getSize();
     panic_if(size != 4, "FVPBasePwrCtrl::write: Invalid size %i\n", size);
 
-    uint64_t data = pkt->getUintX(LittleEndianByteOrder);
+    uint64_t data = pkt->getUintX(ByteOrder::little);
 
     // Software may use the power controller to check for core presence
     // If core is not present, return an invalid MPID as notification
index da8de08bd9b9860eb183422c2b95aa034c989570..254175a7ded984d1e699baaf3d5e046f58525201 100644 (file)
@@ -999,7 +999,7 @@ GenericTimerFrame::read(PacketPtr pkt)
     DPRINTF(Timer, "GenericTimerFrame::read: 0x%x<-0x%x(%i) [S = %u]\n", resp,
             addr, size, is_sec);
 
-    pkt->setUintX(resp, LittleEndianByteOrder);
+    pkt->setUintX(resp, ByteOrder::little);
     pkt->makeResponse();
     return 0;
 }
@@ -1014,7 +1014,7 @@ GenericTimerFrame::write(PacketPtr pkt)
              "GenericTimerFrame::write: Invalid size %i\n", size);
 
     bool to_el0 = false;
-    const uint64_t data = pkt->getUintX(LittleEndianByteOrder);
+    const uint64_t data = pkt->getUintX(ByteOrder::little);
     Addr offset = 0;
     if (timerRange.contains(addr)) {
         offset = addr - timerRange.start();
@@ -1313,7 +1313,7 @@ GenericTimerMem::read(PacketPtr pkt)
     DPRINTF(Timer, "GenericTimerMem::read: 0x%x<-0x%x(%i) [S = %u]\n", resp,
             addr, size, is_sec);
 
-    pkt->setUintX(resp, LittleEndianByteOrder);
+    pkt->setUintX(resp, ByteOrder::little);
     pkt->makeResponse();
     return 0;
 }
@@ -1327,7 +1327,7 @@ GenericTimerMem::write(PacketPtr pkt)
     panic_if(size != 4 && size != 8,
              "GenericTimerMem::write: Invalid size %i\n", size);
 
-    const uint64_t data = pkt->getUintX(LittleEndianByteOrder);
+    const uint64_t data = pkt->getUintX(ByteOrder::little);
     if (counterCtrlRange.contains(addr))
         counterCtrlWrite(addr - counterCtrlRange.start(), size, data, is_sec);
     else if (counterStatusRange.contains(addr))
index 83f2c83219281dd01361e692aeae41d6b1c31868..596f170f224b3b7b5a0e6fce9e38459cbbc8d9d0 100644 (file)
@@ -127,7 +127,7 @@ Gicv3::read(PacketPtr pkt)
         panic("Gicv3::read(): unknown address %#x\n", addr);
     }
 
-    pkt->setUintX(resp, LittleEndianByteOrder);
+    pkt->setUintX(resp, ByteOrder::little);
     pkt->makeAtomicResponse();
     return delay;
 }
@@ -136,7 +136,7 @@ Tick
 Gicv3::write(PacketPtr pkt)
 {
     const size_t size = pkt->getSize();
-    uint64_t data = pkt->getUintX(LittleEndianByteOrder);
+    uint64_t data = pkt->getUintX(ByteOrder::little);
     const Addr addr = pkt->getAddr();
     bool is_secure_access = pkt->isSecure();
     Tick delay = 0;
index 442008f51fa28f9d3057fd7c12bba0572be6621b..4ea721958098cce7cdc88de942a6b72384399b96 100644 (file)
@@ -882,7 +882,7 @@ Gicv3Its::read(PacketPtr pkt)
         }
     }
 
-    pkt->setUintX(value, LittleEndianByteOrder);
+    pkt->setUintX(value, ByteOrder::little);
     pkt->makeAtomicResponse();
     return pioDelay;
 }
index 347844950e4a8a796bbfa3e9ada2008ab852725a..cf5995a840dec103f048e51f30615d1a487eea67 100644 (file)
@@ -434,7 +434,7 @@ PixelConverter
 HDLcd::pixelConverter() const
 {
     ByteOrder byte_order(
-        pixel_format.big_endian ? BigEndianByteOrder : LittleEndianByteOrder);
+        pixel_format.big_endian ? ByteOrder::big : ByteOrder::little);
 
     /* Some Linux kernels have a broken driver that swaps the red and
      * blue color select registers. */
index 246fedb3905fd48d4d51dae41acbe25cd5d6f81e..517a79ffe9f15f2b32eced49d1f4178b4e7a29ba 100644 (file)
@@ -95,7 +95,7 @@ Pl050::read(PacketPtr pkt)
       default:
         if (readId(pkt, ambaId, pioAddr)) {
             // Hack for variable size accesses
-            data = pkt->getUintX(LittleEndianByteOrder);
+            data = pkt->getUintX(ByteOrder::little);
             break;
         }
 
@@ -103,7 +103,7 @@ Pl050::read(PacketPtr pkt)
         break;
     }
 
-    pkt->setUintX(data, LittleEndianByteOrder);
+    pkt->setUintX(data, ByteOrder::little);
     pkt->makeAtomicResponse();
     return pioDelay;
 }
@@ -115,7 +115,7 @@ Pl050::write(PacketPtr pkt)
     assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
 
     Addr daddr = pkt->getAddr() - pioAddr;
-    const uint32_t data = pkt->getUintX(LittleEndianByteOrder);
+    const uint32_t data = pkt->getUintX(ByteOrder::little);
 
     panic_if(pkt->getSize() != 1,
              "PL050: Unexpected write size "
index a60276d5cdd122d6f0ba2f6b21941c414972d805..9b83cf8c753aba0d73c40657da2edad01e152f4b 100755 (executable)
@@ -137,7 +137,7 @@ Pl011::read(PacketPtr pkt)
       default:
         if (readId(pkt, AMBA_ID, pioAddr)) {
             // Hack for variable size accesses
-            data = pkt->getUintX(LittleEndianByteOrder);
+            data = pkt->getUintX(ByteOrder::little);
             break;
         }
 
index 111de0358f60f4aa41ffc6e75acd66ddae71c689..f36b33f17f4b3682660ecdac425e8053eaa56200 100644 (file)
@@ -182,7 +182,7 @@ Pl111::read(PacketPtr pkt)
       default:
         if (readId(pkt, AMBA_ID, pioAddr)) {
             // Hack for variable size accesses
-            data = pkt->getUintX(LittleEndianByteOrder);
+            data = pkt->getUintX(ByteOrder::little);
             break;
         } else if (daddr >= CrsrImage && daddr <= 0xBFC) {
             // CURSOR IMAGE
@@ -203,7 +203,7 @@ Pl111::read(PacketPtr pkt)
         }
     }
 
-    pkt->setUintX(data, LittleEndianByteOrder);
+    pkt->setUintX(data, ByteOrder::little);
     pkt->makeAtomicResponse();
     return pioDelay;
 }
@@ -215,7 +215,7 @@ Pl111::write(PacketPtr pkt)
     // use a temporary data since the LCD registers are read/written with
     // different size operations
     //
-    const uint32_t data = pkt->getUintX(LittleEndianByteOrder);
+    const uint32_t data = pkt->getUintX(ByteOrder::little);
 
     assert(pkt->getAddr() >= pioAddr &&
            pkt->getAddr() < pioAddr + pioSize);
@@ -383,13 +383,13 @@ Pl111::pixelConverter() const
             bytesPerPixel,
             offsets[2], offsets[1], offsets[0],
             rw, gw, bw,
-            LittleEndianByteOrder);
+            ByteOrder::little);
     } else {
         return PixelConverter(
             bytesPerPixel,
             offsets[0], offsets[1], offsets[2],
             rw, gw, bw,
-            LittleEndianByteOrder);
+            ByteOrder::little);
     }
 }
 
index b2b232249811eb1f8bbfa4135ecd2e92b2c21baa..3ff478f731a0a836323772c3f23b9ea559f1a1f1 100644 (file)
@@ -90,7 +90,7 @@ PL031::read(PacketPtr pkt)
       default:
         if (readId(pkt, ambaId, pioAddr)) {
             // Hack for variable sized access
-            data = pkt->getUintX(LittleEndianByteOrder);
+            data = pkt->getUintX(ByteOrder::little);
             break;
         }
         panic("Tried to read PL031 at offset %#x that doesn't exist\n", daddr);
index 3fd7006ae492cb213e0ae9f76745f30f2ffe04ef..32417e02060f09e9af7ed3f4703491ea0e31eb90 100644 (file)
@@ -93,7 +93,7 @@ Sp805::read(PacketPtr pkt)
         break;
       default:
         if (readId(pkt, ambaId, pioAddr))
-            resp = pkt->getUintX(LittleEndianByteOrder);
+            resp = pkt->getUintX(ByteOrder::little);
         else
             warn("Sp805::read: Unexpected address (0x%x:%i), assuming RAZ\n",
                  addr, size);
@@ -101,7 +101,7 @@ Sp805::read(PacketPtr pkt)
 
     DPRINTF(Sp805, "Sp805::read: 0x%x<-0x%x(%i)\n", resp, addr, size);
 
-    pkt->setUintX(resp, LittleEndianByteOrder);
+    pkt->setUintX(resp, ByteOrder::little);
     pkt->makeResponse();
     return pioDelay;
 }
@@ -113,7 +113,7 @@ Sp805::write(PacketPtr pkt)
     const size_t size = pkt->getSize();
     panic_if(size != 4, "Sp805::write: Invalid size %i\n", size);
 
-    uint64_t data = pkt->getUintX(LittleEndianByteOrder);
+    uint64_t data = pkt->getUintX(ByteOrder::little);
     switch (addr) {
       case WDOGLOAD:
         if (writeAccessEnabled) {
index 9450b89bf1d3f2e03fc9f855726e8c64c72ba248..97018abbe32c240735e19aaff73bd33e13e06628 100644 (file)
@@ -44,7 +44,7 @@
 
 SimpleUart::SimpleUart(const SimpleUartParams *p)
     : Uart(p, p->pio_size),
-      byteOrder(p->big_endian ? BigEndianByteOrder : LittleEndianByteOrder),
+      byteOrder(p->big_endian ? ByteOrder::big : ByteOrder::little),
       endOnEOT(p->end_on_eot)
 {
 }
index cdd0f5bd410c33d3023a19709663c31b95935c05..4afacf0d76e90bc9b8c6d47a7c0ce514b22b9d0a 100644 (file)
@@ -206,10 +206,10 @@ class Base : public ClockedObject
                 panic("PrefetchInfo::get called with a request with no data.");
             }
             switch (endian) {
-                case BigEndianByteOrder:
+                case ByteOrder::big:
                     return betoh(*(T*)data);
 
-                case LittleEndianByteOrder:
+                case ByteOrder::little:
                     return letoh(*(T*)data);
 
                 default:
index 98f328332f53c79e027b1d7eed58879184ef42a2..2190840e6b2a89b4ab8483150bc3d327f26cc76b 100644 (file)
@@ -82,10 +82,10 @@ inline T
 Packet::get(ByteOrder endian) const
 {
     switch (endian) {
-      case BigEndianByteOrder:
+      case ByteOrder::big:
         return getBE<T>();
 
-      case LittleEndianByteOrder:
+      case ByteOrder::little:
         return getLE<T>();
 
       default:
@@ -112,10 +112,10 @@ inline void
 Packet::set(T v, ByteOrder endian)
 {
     switch (endian) {
-      case BigEndianByteOrder:
+      case ByteOrder::big:
         return setBE<T>(v);
 
-      case LittleEndianByteOrder:
+      case ByteOrder::little:
         return setLE<T>(v);
 
       default:
index c5d26d4eac992b90573230caf6e754c41f305c0e..4e586671f1e61e52a2bc7ababee22a158e4b63ba 100644 (file)
@@ -1513,6 +1513,14 @@ class ScopedEnum(Enum):
     # If not None, use this as the enum name rather than this class name
     enum_name = None
 
+class ByteOrder(ScopedEnum):
+    """Enum representing component's byte order (endianness)"""
+
+    vals = [
+        'big',
+        'little',
+    ]
+
 # how big does a rounding error need to be before we warn about it?
 frequency_tolerance = 0.001  # 0.1%
 
index 06205cd6e6040d8ff294b82d27f97a6138d41894..fbe0302f8bb73ebb813c579cd56821c44ca83fa8 100644 (file)
@@ -136,13 +136,13 @@ template <typename T> inline T letobe(T value) {return swap_byte(value);}
 //For conversions not involving the guest system, we can define the functions
 //conditionally based on the BYTE_ORDER macro and outside of the namespaces
 #if (defined(_BIG_ENDIAN) || !defined(_LITTLE_ENDIAN)) && BYTE_ORDER == BIG_ENDIAN
-const ByteOrder HostByteOrder = BigEndianByteOrder;
+const ByteOrder HostByteOrder = ByteOrder::big;
 template <typename T> inline T htole(T value) {return swap_byte(value);}
 template <typename T> inline T letoh(T value) {return swap_byte(value);}
 template <typename T> inline T htobe(T value) {return value;}
 template <typename T> inline T betoh(T value) {return value;}
 #elif defined(_LITTLE_ENDIAN) || BYTE_ORDER == LITTLE_ENDIAN
-const ByteOrder HostByteOrder = LittleEndianByteOrder;
+const ByteOrder HostByteOrder = ByteOrder::little;
 template <typename T> inline T htole(T value) {return value;}
 template <typename T> inline T letoh(T value) {return value;}
 template <typename T> inline T htobe(T value) {return swap_byte(value);}
@@ -154,14 +154,14 @@ template <typename T> inline T betoh(T value) {return swap_byte(value);}
 template <typename T>
 inline T htog(T value, ByteOrder guest_byte_order)
 {
-    return guest_byte_order == BigEndianByteOrder ?
+    return guest_byte_order == ByteOrder::big ?
         htobe(value) : htole(value);
 }
 
 template <typename T>
 inline T gtoh(T value, ByteOrder guest_byte_order)
 {
-    return guest_byte_order == BigEndianByteOrder ?
+    return guest_byte_order == ByteOrder::big ?
         betoh(value) : letoh(value);
 }
 
index 08c4dd3204df2f4a055613ca159c5ebb9f2224e3..27e1fc616798d660c74db61ad788a1277a8c3c5a 100644 (file)
@@ -86,102 +86,102 @@ TEST(ByteswapTest, htog)
 {
 #if (defined(_BIG_ENDIAN)||!defined(_LITTLE_ENDIAN)) && BYTE_ORDER==BIG_ENDIAN
     EXPECT_EQ(0xefcdab8967452301, htog((uint64_t)0xefcdab8967452301,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0x1032547698badcfe, htog((uint64_t)0x1032547698badcfe,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0xb14171b771b01c0b, htog((uint64_t)0xb14171b771b01c0b,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0xffffffff00000000, htog((uint64_t)0xffffffff00000000,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0x5555555555555555, htog((uint64_t)0x5555555555555555,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0xa0a0a0a0a0a0a0a0, htog((uint64_t)0xa0a0a0a0a0a0a0a0,
-                                BigEndianByteOrder));
-    EXPECT_EQ(0xefcd2301, htog((uint32_t)0xefcd2301, BigEndianByteOrder));
-    EXPECT_EQ(0x1032dcfe, htog((uint32_t)0x1032dcfe, BigEndianByteOrder));
-    EXPECT_EQ(0xb1411c0b, htog((uint32_t)0xb1411c0b, BigEndianByteOrder));
-    EXPECT_EQ(0xffff0000, htog((uint32_t)0xffff0000, BigEndianByteOrder));
-    EXPECT_EQ(0x55555555, htog((uint32_t)0x55555555, BigEndianByteOrder));
-    EXPECT_EQ(0xa0a0a0a0, htog((uint32_t)0xa0a0a0a0, BigEndianByteOrder));
-    EXPECT_EQ(0xef01, htog((uint16_t)0xef01, BigEndianByteOrder));
-    EXPECT_EQ(0x10fe, htog((uint16_t)0x10fe, BigEndianByteOrder));
-    EXPECT_EQ(0xb10b, htog((uint16_t)0xb10b, BigEndianByteOrder));
-    EXPECT_EQ(0xff00, htog((uint16_t)0xff00, BigEndianByteOrder));
-    EXPECT_EQ(0x5555, htog((uint16_t)0x5555, BigEndianByteOrder));
-    EXPECT_EQ(0xa0a0, htog((uint16_t)0xa0a0, BigEndianByteOrder));
+                                ByteOrder::big));
+    EXPECT_EQ(0xefcd2301, htog((uint32_t)0xefcd2301, ByteOrder::big));
+    EXPECT_EQ(0x1032dcfe, htog((uint32_t)0x1032dcfe, ByteOrder::big));
+    EXPECT_EQ(0xb1411c0b, htog((uint32_t)0xb1411c0b, ByteOrder::big));
+    EXPECT_EQ(0xffff0000, htog((uint32_t)0xffff0000, ByteOrder::big));
+    EXPECT_EQ(0x55555555, htog((uint32_t)0x55555555, ByteOrder::big));
+    EXPECT_EQ(0xa0a0a0a0, htog((uint32_t)0xa0a0a0a0, ByteOrder::big));
+    EXPECT_EQ(0xef01, htog((uint16_t)0xef01, ByteOrder::big));
+    EXPECT_EQ(0x10fe, htog((uint16_t)0x10fe, ByteOrder::big));
+    EXPECT_EQ(0xb10b, htog((uint16_t)0xb10b, ByteOrder::big));
+    EXPECT_EQ(0xff00, htog((uint16_t)0xff00, ByteOrder::big));
+    EXPECT_EQ(0x5555, htog((uint16_t)0x5555, ByteOrder::big));
+    EXPECT_EQ(0xa0a0, htog((uint16_t)0xa0a0, ByteOrder::big));
     EXPECT_EQ(0x0123456789abcdef, htog((uint64_t)0xefcdab8967452301,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0xfedcba9876543210, htog((uint64_t)0x1032547698badcfe,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0x0b1cb071b77141b1, htog((uint64_t)0xb14171b771b01c0b,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0x00000000ffffffff, htog((uint64_t)0xffffffff00000000,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0x5555555555555555, htog((uint64_t)0x5555555555555555,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0xa0a0a0a0a0a0a0a0, htog((uint64_t)0xa0a0a0a0a0a0a0a0,
-                                LittleEndianByteOrder));
-    EXPECT_EQ(0x0123cdef, htog((uint32_t)0xefcd2301, LittleEndianByteOrder));
-    EXPECT_EQ(0xfedc3210, htog((uint32_t)0x1032dcfe, LittleEndianByteOrder));
-    EXPECT_EQ(0x0b1c41b1, htog((uint32_t)0xb1411c0b, LittleEndianByteOrder));
-    EXPECT_EQ(0x0000ffff, htog((uint32_t)0xffff0000, LittleEndianByteOrder));
-    EXPECT_EQ(0x55555555, htog((uint32_t)0x55555555, LittleEndianByteOrder));
-    EXPECT_EQ(0xa0a0a0a0, htog((uint32_t)0xa0a0a0a0, LittleEndianByteOrder));
-    EXPECT_EQ(0x01ef, htog((uint16_t)0xef01, LittleEndianByteOrder));
-    EXPECT_EQ(0xfe10, htog((uint16_t)0x10fe, LittleEndianByteOrder));
-    EXPECT_EQ(0x0bb1, htog((uint16_t)0xb10b, LittleEndianByteOrder));
-    EXPECT_EQ(0x00ff, htog((uint16_t)0xff00, LittleEndianByteOrder));
-    EXPECT_EQ(0x5555, htog((uint16_t)0x5555, LittleEndianByteOrder));
-    EXPECT_EQ(0xa0a0, htog((uint16_t)0xa0a0, LittleEndianByteOrder));
+                                ByteOrder::little));
+    EXPECT_EQ(0x0123cdef, htog((uint32_t)0xefcd2301, ByteOrder::little));
+    EXPECT_EQ(0xfedc3210, htog((uint32_t)0x1032dcfe, ByteOrder::little));
+    EXPECT_EQ(0x0b1c41b1, htog((uint32_t)0xb1411c0b, ByteOrder::little));
+    EXPECT_EQ(0x0000ffff, htog((uint32_t)0xffff0000, ByteOrder::little));
+    EXPECT_EQ(0x55555555, htog((uint32_t)0x55555555, ByteOrder::little));
+    EXPECT_EQ(0xa0a0a0a0, htog((uint32_t)0xa0a0a0a0, ByteOrder::little));
+    EXPECT_EQ(0x01ef, htog((uint16_t)0xef01, ByteOrder::little));
+    EXPECT_EQ(0xfe10, htog((uint16_t)0x10fe, ByteOrder::little));
+    EXPECT_EQ(0x0bb1, htog((uint16_t)0xb10b, ByteOrder::little));
+    EXPECT_EQ(0x00ff, htog((uint16_t)0xff00, ByteOrder::little));
+    EXPECT_EQ(0x5555, htog((uint16_t)0x5555, ByteOrder::little));
+    EXPECT_EQ(0xa0a0, htog((uint16_t)0xa0a0, ByteOrder::little));
 #elif defined(_LITTLE_ENDIAN) || BYTE_ORDER==LITTLE_ENDIAN
     EXPECT_EQ(0x0123456789abcdef, htog((uint64_t)0xefcdab8967452301,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0xfedcba9876543210, htog((uint64_t)0x1032547698badcfe,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0x0b1cb071b77141b1, htog((uint64_t)0xb14171b771b01c0b,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0x00000000ffffffff, htog((uint64_t)0xffffffff00000000,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0x5555555555555555, htog((uint64_t)0x5555555555555555,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0xa0a0a0a0a0a0a0a0, htog((uint64_t)0xa0a0a0a0a0a0a0a0,
-                                BigEndianByteOrder));
-    EXPECT_EQ(0x0123cdef, htog((uint32_t)0xefcd2301, BigEndianByteOrder));
-    EXPECT_EQ(0xfedc3210, htog((uint32_t)0x1032dcfe, BigEndianByteOrder));
-    EXPECT_EQ(0x0b1c41b1, htog((uint32_t)0xb1411c0b, BigEndianByteOrder));
-    EXPECT_EQ(0x0000ffff, htog((uint32_t)0xffff0000, BigEndianByteOrder));
-    EXPECT_EQ(0x55555555, htog((uint32_t)0x55555555, BigEndianByteOrder));
-    EXPECT_EQ(0xa0a0a0a0, htog((uint32_t)0xa0a0a0a0, BigEndianByteOrder));
-    EXPECT_EQ(0x01ef, htog((uint16_t)0xef01, BigEndianByteOrder));
-    EXPECT_EQ(0xfe10, htog((uint16_t)0x10fe, BigEndianByteOrder));
-    EXPECT_EQ(0x0bb1, htog((uint16_t)0xb10b, BigEndianByteOrder));
-    EXPECT_EQ(0x00ff, htog((uint16_t)0xff00, BigEndianByteOrder));
-    EXPECT_EQ(0x5555, htog((uint16_t)0x5555, BigEndianByteOrder));
-    EXPECT_EQ(0xa0a0, htog((uint16_t)0xa0a0, BigEndianByteOrder));
+                                ByteOrder::big));
+    EXPECT_EQ(0x0123cdef, htog((uint32_t)0xefcd2301, ByteOrder::big));
+    EXPECT_EQ(0xfedc3210, htog((uint32_t)0x1032dcfe, ByteOrder::big));
+    EXPECT_EQ(0x0b1c41b1, htog((uint32_t)0xb1411c0b, ByteOrder::big));
+    EXPECT_EQ(0x0000ffff, htog((uint32_t)0xffff0000, ByteOrder::big));
+    EXPECT_EQ(0x55555555, htog((uint32_t)0x55555555, ByteOrder::big));
+    EXPECT_EQ(0xa0a0a0a0, htog((uint32_t)0xa0a0a0a0, ByteOrder::big));
+    EXPECT_EQ(0x01ef, htog((uint16_t)0xef01, ByteOrder::big));
+    EXPECT_EQ(0xfe10, htog((uint16_t)0x10fe, ByteOrder::big));
+    EXPECT_EQ(0x0bb1, htog((uint16_t)0xb10b, ByteOrder::big));
+    EXPECT_EQ(0x00ff, htog((uint16_t)0xff00, ByteOrder::big));
+    EXPECT_EQ(0x5555, htog((uint16_t)0x5555, ByteOrder::big));
+    EXPECT_EQ(0xa0a0, htog((uint16_t)0xa0a0, ByteOrder::big));
     EXPECT_EQ(0xefcdab8967452301, htog((uint64_t)0xefcdab8967452301,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0x1032547698badcfe, htog((uint64_t)0x1032547698badcfe,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0xb14171b771b01c0b, htog((uint64_t)0xb14171b771b01c0b,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0xffffffff00000000, htog((uint64_t)0xffffffff00000000,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0x5555555555555555, htog((uint64_t)0x5555555555555555,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0xa0a0a0a0a0a0a0a0, htog((uint64_t)0xa0a0a0a0a0a0a0a0,
-                                LittleEndianByteOrder));
-    EXPECT_EQ(0xefcd2301, htog((uint32_t)0xefcd2301, LittleEndianByteOrder));
-    EXPECT_EQ(0x1032dcfe, htog((uint32_t)0x1032dcfe, LittleEndianByteOrder));
-    EXPECT_EQ(0xb1411c0b, htog((uint32_t)0xb1411c0b, LittleEndianByteOrder));
-    EXPECT_EQ(0xffff0000, htog((uint32_t)0xffff0000, LittleEndianByteOrder));
-    EXPECT_EQ(0x55555555, htog((uint32_t)0x55555555, LittleEndianByteOrder));
-    EXPECT_EQ(0xa0a0a0a0, htog((uint32_t)0xa0a0a0a0, LittleEndianByteOrder));
-    EXPECT_EQ(0xef01, htog((uint16_t)0xef01, LittleEndianByteOrder));
-    EXPECT_EQ(0x10fe, htog((uint16_t)0x10fe, LittleEndianByteOrder));
-    EXPECT_EQ(0xb10b, htog((uint16_t)0xb10b, LittleEndianByteOrder));
-    EXPECT_EQ(0xff00, htog((uint16_t)0xff00, LittleEndianByteOrder));
-    EXPECT_EQ(0x5555, htog((uint16_t)0x5555, LittleEndianByteOrder));
-    EXPECT_EQ(0xa0a0, htog((uint16_t)0xa0a0, LittleEndianByteOrder));
+                                ByteOrder::little));
+    EXPECT_EQ(0xefcd2301, htog((uint32_t)0xefcd2301, ByteOrder::little));
+    EXPECT_EQ(0x1032dcfe, htog((uint32_t)0x1032dcfe, ByteOrder::little));
+    EXPECT_EQ(0xb1411c0b, htog((uint32_t)0xb1411c0b, ByteOrder::little));
+    EXPECT_EQ(0xffff0000, htog((uint32_t)0xffff0000, ByteOrder::little));
+    EXPECT_EQ(0x55555555, htog((uint32_t)0x55555555, ByteOrder::little));
+    EXPECT_EQ(0xa0a0a0a0, htog((uint32_t)0xa0a0a0a0, ByteOrder::little));
+    EXPECT_EQ(0xef01, htog((uint16_t)0xef01, ByteOrder::little));
+    EXPECT_EQ(0x10fe, htog((uint16_t)0x10fe, ByteOrder::little));
+    EXPECT_EQ(0xb10b, htog((uint16_t)0xb10b, ByteOrder::little));
+    EXPECT_EQ(0xff00, htog((uint16_t)0xff00, ByteOrder::little));
+    EXPECT_EQ(0x5555, htog((uint16_t)0x5555, ByteOrder::little));
+    EXPECT_EQ(0xa0a0, htog((uint16_t)0xa0a0, ByteOrder::little));
 #else
     #error Invalid Endianess
 #endif
@@ -191,102 +191,102 @@ TEST(ByteswapTest, gtoh)
 {
 #if (defined(_BIG_ENDIAN)||!defined(_LITTLE_ENDIAN)) && BYTE_ORDER==BIG_ENDIAN
     EXPECT_EQ(0xefcdab8967452301, gtoh((uint64_t)0xefcdab8967452301,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0x1032547698badcfe, gtoh((uint64_t)0x1032547698badcfe,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0xb14171b771b01c0b, gtoh((uint64_t)0xb14171b771b01c0b,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0xffffffff00000000, gtoh((uint64_t)0xffffffff00000000,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0x5555555555555555, gtoh((uint64_t)0x5555555555555555,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0xa0a0a0a0a0a0a0a0, gtoh((uint64_t)0xa0a0a0a0a0a0a0a0,
-                                BigEndianByteOrder));
-    EXPECT_EQ(0xefcd2301, gtoh((uint32_t)0xefcd2301, BigEndianByteOrder));
-    EXPECT_EQ(0x1032dcfe, gtoh((uint32_t)0x1032dcfe, BigEndianByteOrder));
-    EXPECT_EQ(0xb1411c0b, gtoh((uint32_t)0xb1411c0b, BigEndianByteOrder));
-    EXPECT_EQ(0xffff0000, gtoh((uint32_t)0xffff0000, BigEndianByteOrder));
-    EXPECT_EQ(0x55555555, gtoh((uint32_t)0x55555555, BigEndianByteOrder));
-    EXPECT_EQ(0xa0a0a0a0, gtoh((uint32_t)0xa0a0a0a0, BigEndianByteOrder));
-    EXPECT_EQ(0xef01, gtoh((uint16_t)0xef01, BigEndianByteOrder));
-    EXPECT_EQ(0x10fe, gtoh((uint16_t)0x10fe, BigEndianByteOrder));
-    EXPECT_EQ(0xb10b, gtoh((uint16_t)0xb10b, BigEndianByteOrder));
-    EXPECT_EQ(0xff00, gtoh((uint16_t)0xff00, BigEndianByteOrder));
-    EXPECT_EQ(0x5555, gtoh((uint16_t)0x5555, BigEndianByteOrder));
-    EXPECT_EQ(0xa0a0, gtoh((uint16_t)0xa0a0, BigEndianByteOrder));
+                                ByteOrder::big));
+    EXPECT_EQ(0xefcd2301, gtoh((uint32_t)0xefcd2301, ByteOrder::big));
+    EXPECT_EQ(0x1032dcfe, gtoh((uint32_t)0x1032dcfe, ByteOrder::big));
+    EXPECT_EQ(0xb1411c0b, gtoh((uint32_t)0xb1411c0b, ByteOrder::big));
+    EXPECT_EQ(0xffff0000, gtoh((uint32_t)0xffff0000, ByteOrder::big));
+    EXPECT_EQ(0x55555555, gtoh((uint32_t)0x55555555, ByteOrder::big));
+    EXPECT_EQ(0xa0a0a0a0, gtoh((uint32_t)0xa0a0a0a0, ByteOrder::big));
+    EXPECT_EQ(0xef01, gtoh((uint16_t)0xef01, ByteOrder::big));
+    EXPECT_EQ(0x10fe, gtoh((uint16_t)0x10fe, ByteOrder::big));
+    EXPECT_EQ(0xb10b, gtoh((uint16_t)0xb10b, ByteOrder::big));
+    EXPECT_EQ(0xff00, gtoh((uint16_t)0xff00, ByteOrder::big));
+    EXPECT_EQ(0x5555, gtoh((uint16_t)0x5555, ByteOrder::big));
+    EXPECT_EQ(0xa0a0, gtoh((uint16_t)0xa0a0, ByteOrder::big));
     EXPECT_EQ(0x0123456789abcdef, gtoh((uint64_t)0xefcdab8967452301,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0xfedcba9876543210, gtoh((uint64_t)0x1032547698badcfe,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0x0b1cb071b77141b1, gtoh((uint64_t)0xb14171b771b01c0b,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0x00000000ffffffff, gtoh((uint64_t)0xffffffff00000000,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0x5555555555555555, gtoh((uint64_t)0x5555555555555555,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0xa0a0a0a0a0a0a0a0, gtoh((uint64_t)0xa0a0a0a0a0a0a0a0,
-                                LittleEndianByteOrder));
-    EXPECT_EQ(0x0123cdef, gtoh((uint32_t)0xefcd2301, LittleEndianByteOrder));
-    EXPECT_EQ(0xfedc3210, gtoh((uint32_t)0x1032dcfe, LittleEndianByteOrder));
-    EXPECT_EQ(0x0b1c41b1, gtoh((uint32_t)0xb1411c0b, LittleEndianByteOrder));
-    EXPECT_EQ(0x0000ffff, gtoh((uint32_t)0xffff0000, LittleEndianByteOrder));
-    EXPECT_EQ(0x55555555, gtoh((uint32_t)0x55555555, LittleEndianByteOrder));
-    EXPECT_EQ(0xa0a0a0a0, gtoh((uint32_t)0xa0a0a0a0, LittleEndianByteOrder));
-    EXPECT_EQ(0x01ef, gtoh((uint16_t)0xef01, LittleEndianByteOrder));
-    EXPECT_EQ(0xfe10, gtoh((uint16_t)0x10fe, LittleEndianByteOrder));
-    EXPECT_EQ(0x0bb1, gtoh((uint16_t)0xb10b, LittleEndianByteOrder));
-    EXPECT_EQ(0x00ff, gtoh((uint16_t)0xff00, LittleEndianByteOrder));
-    EXPECT_EQ(0x5555, gtoh((uint16_t)0x5555, LittleEndianByteOrder));
-    EXPECT_EQ(0xa0a0, gtoh((uint16_t)0xa0a0, LittleEndianByteOrder));
+                                ByteOrder::little));
+    EXPECT_EQ(0x0123cdef, gtoh((uint32_t)0xefcd2301, ByteOrder::little));
+    EXPECT_EQ(0xfedc3210, gtoh((uint32_t)0x1032dcfe, ByteOrder::little));
+    EXPECT_EQ(0x0b1c41b1, gtoh((uint32_t)0xb1411c0b, ByteOrder::little));
+    EXPECT_EQ(0x0000ffff, gtoh((uint32_t)0xffff0000, ByteOrder::little));
+    EXPECT_EQ(0x55555555, gtoh((uint32_t)0x55555555, ByteOrder::little));
+    EXPECT_EQ(0xa0a0a0a0, gtoh((uint32_t)0xa0a0a0a0, ByteOrder::little));
+    EXPECT_EQ(0x01ef, gtoh((uint16_t)0xef01, ByteOrder::little));
+    EXPECT_EQ(0xfe10, gtoh((uint16_t)0x10fe, ByteOrder::little));
+    EXPECT_EQ(0x0bb1, gtoh((uint16_t)0xb10b, ByteOrder::little));
+    EXPECT_EQ(0x00ff, gtoh((uint16_t)0xff00, ByteOrder::little));
+    EXPECT_EQ(0x5555, gtoh((uint16_t)0x5555, ByteOrder::little));
+    EXPECT_EQ(0xa0a0, gtoh((uint16_t)0xa0a0, ByteOrder::little));
 #elif defined(_LITTLE_ENDIAN) || BYTE_ORDER==LITTLE_ENDIAN
     EXPECT_EQ(0x0123456789abcdef, gtoh((uint64_t)0xefcdab8967452301,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0xfedcba9876543210, gtoh((uint64_t)0x1032547698badcfe,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0x0b1cb071b77141b1, gtoh((uint64_t)0xb14171b771b01c0b,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0x00000000ffffffff, gtoh((uint64_t)0xffffffff00000000,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0x5555555555555555, gtoh((uint64_t)0x5555555555555555,
-                                BigEndianByteOrder));
+                                ByteOrder::big));
     EXPECT_EQ(0xa0a0a0a0a0a0a0a0, gtoh((uint64_t)0xa0a0a0a0a0a0a0a0,
-                                BigEndianByteOrder));
-    EXPECT_EQ(0x0123cdef, gtoh((uint32_t)0xefcd2301, BigEndianByteOrder));
-    EXPECT_EQ(0xfedc3210, gtoh((uint32_t)0x1032dcfe, BigEndianByteOrder));
-    EXPECT_EQ(0x0b1c41b1, gtoh((uint32_t)0xb1411c0b, BigEndianByteOrder));
-    EXPECT_EQ(0x0000ffff, gtoh((uint32_t)0xffff0000, BigEndianByteOrder));
-    EXPECT_EQ(0x55555555, gtoh((uint32_t)0x55555555, BigEndianByteOrder));
-    EXPECT_EQ(0xa0a0a0a0, gtoh((uint32_t)0xa0a0a0a0, BigEndianByteOrder));
-    EXPECT_EQ(0x01ef, gtoh((uint16_t)0xef01, BigEndianByteOrder));
-    EXPECT_EQ(0xfe10, gtoh((uint16_t)0x10fe, BigEndianByteOrder));
-    EXPECT_EQ(0x0bb1, gtoh((uint16_t)0xb10b, BigEndianByteOrder));
-    EXPECT_EQ(0x00ff, gtoh((uint16_t)0xff00, BigEndianByteOrder));
-    EXPECT_EQ(0x5555, gtoh((uint16_t)0x5555, BigEndianByteOrder));
-    EXPECT_EQ(0xa0a0, gtoh((uint16_t)0xa0a0, BigEndianByteOrder));
+                                ByteOrder::big));
+    EXPECT_EQ(0x0123cdef, gtoh((uint32_t)0xefcd2301, ByteOrder::big));
+    EXPECT_EQ(0xfedc3210, gtoh((uint32_t)0x1032dcfe, ByteOrder::big));
+    EXPECT_EQ(0x0b1c41b1, gtoh((uint32_t)0xb1411c0b, ByteOrder::big));
+    EXPECT_EQ(0x0000ffff, gtoh((uint32_t)0xffff0000, ByteOrder::big));
+    EXPECT_EQ(0x55555555, gtoh((uint32_t)0x55555555, ByteOrder::big));
+    EXPECT_EQ(0xa0a0a0a0, gtoh((uint32_t)0xa0a0a0a0, ByteOrder::big));
+    EXPECT_EQ(0x01ef, gtoh((uint16_t)0xef01, ByteOrder::big));
+    EXPECT_EQ(0xfe10, gtoh((uint16_t)0x10fe, ByteOrder::big));
+    EXPECT_EQ(0x0bb1, gtoh((uint16_t)0xb10b, ByteOrder::big));
+    EXPECT_EQ(0x00ff, gtoh((uint16_t)0xff00, ByteOrder::big));
+    EXPECT_EQ(0x5555, gtoh((uint16_t)0x5555, ByteOrder::big));
+    EXPECT_EQ(0xa0a0, gtoh((uint16_t)0xa0a0, ByteOrder::big));
     EXPECT_EQ(0xefcdab8967452301, gtoh((uint64_t)0xefcdab8967452301,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0x1032547698badcfe, gtoh((uint64_t)0x1032547698badcfe,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0xb14171b771b01c0b, gtoh((uint64_t)0xb14171b771b01c0b,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0xffffffff00000000, gtoh((uint64_t)0xffffffff00000000,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0x5555555555555555, gtoh((uint64_t)0x5555555555555555,
-                                LittleEndianByteOrder));
+                                ByteOrder::little));
     EXPECT_EQ(0xa0a0a0a0a0a0a0a0, gtoh((uint64_t)0xa0a0a0a0a0a0a0a0,
-                                LittleEndianByteOrder));
-    EXPECT_EQ(0xefcd2301, gtoh((uint32_t)0xefcd2301, LittleEndianByteOrder));
-    EXPECT_EQ(0x1032dcfe, gtoh((uint32_t)0x1032dcfe, LittleEndianByteOrder));
-    EXPECT_EQ(0xb1411c0b, gtoh((uint32_t)0xb1411c0b, LittleEndianByteOrder));
-    EXPECT_EQ(0xffff0000, gtoh((uint32_t)0xffff0000, LittleEndianByteOrder));
-    EXPECT_EQ(0x55555555, gtoh((uint32_t)0x55555555, LittleEndianByteOrder));
-    EXPECT_EQ(0xa0a0a0a0, gtoh((uint32_t)0xa0a0a0a0, LittleEndianByteOrder));
-    EXPECT_EQ(0xef01, gtoh((uint16_t)0xef01, LittleEndianByteOrder));
-    EXPECT_EQ(0x10fe, gtoh((uint16_t)0x10fe, LittleEndianByteOrder));
-    EXPECT_EQ(0xb10b, gtoh((uint16_t)0xb10b, LittleEndianByteOrder));
-    EXPECT_EQ(0xff00, gtoh((uint16_t)0xff00, LittleEndianByteOrder));
-    EXPECT_EQ(0x5555, gtoh((uint16_t)0x5555, LittleEndianByteOrder));
-    EXPECT_EQ(0xa0a0, gtoh((uint16_t)0xa0a0, LittleEndianByteOrder));
+                                ByteOrder::little));
+    EXPECT_EQ(0xefcd2301, gtoh((uint32_t)0xefcd2301, ByteOrder::little));
+    EXPECT_EQ(0x1032dcfe, gtoh((uint32_t)0x1032dcfe, ByteOrder::little));
+    EXPECT_EQ(0xb1411c0b, gtoh((uint32_t)0xb1411c0b, ByteOrder::little));
+    EXPECT_EQ(0xffff0000, gtoh((uint32_t)0xffff0000, ByteOrder::little));
+    EXPECT_EQ(0x55555555, gtoh((uint32_t)0x55555555, ByteOrder::little));
+    EXPECT_EQ(0xa0a0a0a0, gtoh((uint32_t)0xa0a0a0a0, ByteOrder::little));
+    EXPECT_EQ(0xef01, gtoh((uint16_t)0xef01, ByteOrder::little));
+    EXPECT_EQ(0x10fe, gtoh((uint16_t)0x10fe, ByteOrder::little));
+    EXPECT_EQ(0xb10b, gtoh((uint16_t)0xb10b, ByteOrder::little));
+    EXPECT_EQ(0xff00, gtoh((uint16_t)0xff00, ByteOrder::little));
+    EXPECT_EQ(0x5555, gtoh((uint16_t)0x5555, ByteOrder::little));
+    EXPECT_EQ(0xa0a0, gtoh((uint16_t)0xa0a0, ByteOrder::little));
 #else
     #error Invalid Endianess
 #endif