I'm sure we could. This is useful anywhere you need to get an endian converted value out of a packet without knowing the size ahead of time. Does that happen often? I think this was the first time I'd run into it, but I haven't messed with a lot of the device stuff.
Gabe Steve Reinhardt wrote: > Just looking at this code, can we put a more generic version of this > somewhere, like as a Packet method? I don't know how many other > places already do this, but other than the dataSize value none of that > code looks x86-specific, and I'm guessing there are other places that > do this kind of thing. It might be usable to clean up some of the > device code. > > Steve > > On Sat, Nov 8, 2008 at 12:08 AM, <[EMAIL PROTECTED]> wrote: > >> # HG changeset patch >> # User Gabe Black <[EMAIL PROTECTED]> >> # Date 1226042030 28800 >> # Node ID 2e61b60e6614e026ba055946a45c5f577d8d8ff8 >> # Parent 94ef4905a939b782105ce0ebb3c063451744fb3d >> X86: Fix completeAcc get call. >> >> diff --git a/src/arch/x86/insts/microldstop.hh >> b/src/arch/x86/insts/microldstop.hh >> --- a/src/arch/x86/insts/microldstop.hh >> +++ b/src/arch/x86/insts/microldstop.hh >> @@ -59,6 +59,7 @@ >> #define __ARCH_X86_INSTS_MICROLDSTOP_HH__ >> >> #include "arch/x86/insts/microop.hh" >> +#include "mem/packet.hh" >> >> namespace X86ISA >> { >> @@ -149,6 +150,25 @@ >> } >> return fault; >> } >> + >> + uint64_t >> + get(PacketPtr pkt) const >> + { >> + switch(dataSize) >> + { >> + case 1: >> + return pkt->get<uint8_t>(); >> + case 2: >> + return pkt->get<uint16_t>(); >> + case 4: >> + return pkt->get<uint32_t>(); >> + case 8: >> + return pkt->get<uint64_t>(); >> + default: >> + panic("Bad operand size %d for read at %#x.\n", >> + dataSize, pkt->getAddr()); >> + } >> + } >> }; >> } >> >> diff --git a/src/arch/x86/isa/microops/ldstop.isa >> b/src/arch/x86/isa/microops/ldstop.isa >> --- a/src/arch/x86/isa/microops/ldstop.isa >> +++ b/src/arch/x86/isa/microops/ldstop.isa >> @@ -194,7 +194,7 @@ >> %(op_decl)s; >> %(op_rd)s; >> >> - Mem = pkt->get<typeof(Mem)>(); >> + Mem = get(pkt); >> >> %(code)s; >> >> _______________________________________________ >> m5-dev mailing list >> m5-dev@m5sim.org >> http://m5sim.org/mailman/listinfo/m5-dev >> >> > _______________________________________________ > m5-dev mailing list > m5-dev@m5sim.org > http://m5sim.org/mailman/listinfo/m5-dev > _______________________________________________ m5-dev mailing list m5-dev@m5sim.org http://m5sim.org/mailman/listinfo/m5-dev