From cc53465cd5b48183936278cda617be68a4520ff5 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 11 Feb 2004 16:07:55 -0500 Subject: Add support for all devices to get requests from a timing memory bus. In the future, this can be used for actual data, but for now, it's so that devices can respond to timing accesses properly. This way, an uncached access on a bus further away will take longer to respond. dev/alpha_console.cc: dev/alpha_console.hh: suport the separate IO bus --HG-- extra : convert_revision : ececb70f5febfd00231f6e406f93b2a79be01261 --- dev/alpha_console.cc | 31 +++++++++++++++++++++++----- dev/alpha_console.hh | 10 ++++++--- dev/io_device.cc | 51 +++++++++++++++++++++++++++++++++++++++++++++ dev/io_device.hh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 8 deletions(-) create mode 100644 dev/io_device.cc create mode 100644 dev/io_device.hh (limited to 'dev') diff --git a/dev/alpha_console.cc b/dev/alpha_console.cc index 2dc939b97..85b4d57f2 100644 --- a/dev/alpha_console.cc +++ b/dev/alpha_console.cc @@ -43,6 +43,9 @@ #include "dev/console.hh" #include "dev/simple_disk.hh" #include "dev/tlaser_clock.hh" +#include "mem/bus/bus.hh" +#include "mem/bus/pio_interface.hh" +#include "mem/bus/pio_interface_impl.hh" #include "mem/functional_mem/memory_control.hh" #include "sim/builder.hh" #include "sim/system.hh" @@ -51,11 +54,18 @@ using namespace std; AlphaConsole::AlphaConsole(const string &name, SimConsole *cons, SimpleDisk *d, System *system, BaseCPU *cpu, TlaserClock *clock, - int num_cpus, MemoryController *mmu, Addr a) - : FunctionalMemory(name), disk(d), console(cons), addr(a) + int num_cpus, MemoryController *mmu, Addr a, + HierParams *hier, Bus *bus) + : PioDevice(name), disk(d), console(cons), addr(a) { mmu->add_child(this, Range(addr, addr + size)); + if (bus) { + pioInterface = newPioInterface(name, hier, bus, this, + &AlphaConsole::cacheAccess); + pioInterface->setAddrRange(addr, addr + size); + } + consoleData = new uint8_t[size]; memset(consoleData, 0, size); @@ -183,6 +193,12 @@ AlphaConsole::write(MemReqPtr &req, const uint8_t *data) return No_Fault; } +Tick +AlphaConsole::cacheAccess(MemReqPtr &req) +{ + return curTick + 1000; +} + void AlphaAccess::serialize(ostream &os) { @@ -251,6 +267,8 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(AlphaConsole) SimObjectParam system; SimObjectParam cpu; SimObjectParam clock; + SimObjectParam io_bus; + SimObjectParam hier; END_DECLARE_SIM_OBJECT_PARAMS(AlphaConsole) @@ -263,14 +281,17 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(AlphaConsole) INIT_PARAM(addr, "Device Address"), INIT_PARAM(system, "system object"), INIT_PARAM(cpu, "Processor"), - INIT_PARAM(clock, "Turbolaser Clock") + INIT_PARAM(clock, "Turbolaser Clock"), + INIT_PARAM_DFLT(io_bus, "The IO Bus to attach to", NULL), + INIT_PARAM_DFLT(hier, "Hierarchy global variables", &defaultHierParams) END_INIT_SIM_OBJECT_PARAMS(AlphaConsole) CREATE_SIM_OBJECT(AlphaConsole) { - return new AlphaConsole(getInstanceName(), sim_console, disk, - system, cpu, clock, num_cpus, mmu, addr); + return new AlphaConsole(getInstanceName(), sim_console, disk, + system, cpu, clock, num_cpus, mmu, + addr, hier, io_bus); } REGISTER_SIM_OBJECT("AlphaConsole", AlphaConsole) diff --git a/dev/alpha_console.hh b/dev/alpha_console.hh index 54a2af6d5..b617b64e7 100644 --- a/dev/alpha_console.hh +++ b/dev/alpha_console.hh @@ -35,7 +35,7 @@ #include "base/range.hh" #include "dev/alpha_access.h" -#include "mem/functional_mem/functional_memory.hh" +#include "dev/io_device.hh" #include "sim/host.hh" class BaseCPU; @@ -69,7 +69,7 @@ class SimpleDisk; * primarily used doing boot before the kernel has loaded its device * drivers. */ -class AlphaConsole : public FunctionalMemory +class AlphaConsole : public PioDevice { protected: union { @@ -90,7 +90,8 @@ class AlphaConsole : public FunctionalMemory /** Standard Constructor */ AlphaConsole(const std::string &name, SimConsole *cons, SimpleDisk *d, System *system, BaseCPU *cpu, TlaserClock *clock, - int num_cpus, MemoryController *mmu, Addr addr); + int num_cpus, MemoryController *mmu, Addr addr, + HierParams *hier, Bus *bus); /** * memory mapped reads and writes @@ -103,6 +104,9 @@ class AlphaConsole : public FunctionalMemory */ virtual void serialize(std::ostream &os); virtual void unserialize(Checkpoint *cp, const std::string §ion); + + public: + Tick cacheAccess(MemReqPtr &req); }; #endif // __ALPHA_CONSOLE_HH__ diff --git a/dev/io_device.cc b/dev/io_device.cc new file mode 100644 index 000000000..65a18aec6 --- /dev/null +++ b/dev/io_device.cc @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2003 The Regents of The University of Michigan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "dev/io_device.hh" +#include "mem/bus/base_interface.hh" + +PioDevice::PioDevice(const std::string &name) + : FunctionalMemory(name), pioInterface(NULL) +{} + +PioDevice::~PioDevice() +{ + if (pioInterface) + delete pioInterface; +} + +DmaDevice::DmaDevice(const std::string &name) + : PioDevice(name), dmaInterface(NULL) +{} + +DmaDevice::~DmaDevice() +{ + if (dmaInterface) + delete dmaInterface; +} + diff --git a/dev/io_device.hh b/dev/io_device.hh new file mode 100644 index 000000000..39e6fa4aa --- /dev/null +++ b/dev/io_device.hh @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2003 The Regents of The University of Michigan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __IO_DEVICE_HH__ +#define __IO_DEVICE_HH__ + +#include "mem/functional_mem/functional_memory.hh" + +class BaseInterface; +class Bus; +class HierParams; + +class PioDevice : public FunctionalMemory +{ + protected: + BaseInterface *pioInterface; + + public: + PioDevice(const std::string &name); + virtual ~PioDevice(); +}; + +class DmaDevice : public PioDevice +{ + protected: + BaseInterface *dmaInterface; + + public: + DmaDevice(const std::string &name); + virtual ~DmaDevice(); +}; + +#endif // __IO_DEVICE_HH__ -- cgit v1.2.3 From 373d70980eabb4598ee1fcc9429e38ef15950e04 Mon Sep 17 00:00:00 2001 From: Ron Dreslinski Date: Fri, 20 Feb 2004 12:44:41 -0500 Subject: Add serialization for packets on the ethernet link, and for link events --HG-- extra : convert_revision : 0054dbc4a42dd38ff8bbf64af303bc509dd5aa8a --- dev/etherlink.cc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ dev/etherlink.hh | 7 +++++++ 2 files changed, 58 insertions(+) (limited to 'dev') diff --git a/dev/etherlink.cc b/dev/etherlink.cc index 676b1da1c..7c70b82ce 100644 --- a/dev/etherlink.cc +++ b/dev/etherlink.cc @@ -42,6 +42,7 @@ #include "dev/etherpkt.hh" #include "sim/builder.hh" #include "sim/universe.hh" +#include "sim/system.hh" using namespace std; @@ -84,6 +85,20 @@ EtherLink::Link::Link(const std::string &name, double rate, EtherDump *d) dump(d), event(&mainEventQueue, this) {} +void +EtherLink::serialize(ostream &os) +{ + link1->serialize(os); + link2->serialize(os); +} + +void +EtherLink::unserialize(Checkpoint *cp, const string §ion) +{ + link1->unserialize(cp, section); + link2->unserialize(cp, section); +} + void EtherLink::Link::txDone() { @@ -121,6 +136,42 @@ EtherLink::Link::transmit(PacketPtr &pkt) return true; } +void +EtherLink::Link::serialize(ostream &os) +{ + bool packetExists = false; + if (packet) packetExists = true; + SERIALIZE_SCALAR(packetExists); + if (packetExists) { + nameOut(os, csprintf("%s.linkPacket", name())); + packet->serialize(os); + } + + bool event_scheduled = event.scheduled(); + SERIALIZE_SCALAR(event_scheduled); + if (event_scheduled) { + SERIALIZE_SCALAR(event.when()); + } +} + +void +EtherLink::Link::unserialize(Checkpoint *cp, const string §ion) +{ + bool event_scheduled, packetExists; + Tick eventTime; + UNSERIALIZE_SCALAR(packetExists); + if (packetExists) { + packet = new EtherPacket; + packet->unserialize(cp, csprintf("%s.linkPacket", section)); + } + + UNSERIALIZE_SCALAR(event_scheduled); + if (event_scheduled) { + UNSERIALIZE_SCALAR(eventTime); + event.schedule(eventTime); + } +} + BEGIN_DECLARE_SIM_OBJECT_PARAMS(EtherLink) SimObjectParam interface1; diff --git a/dev/etherlink.hh b/dev/etherlink.hh index e1a7957ee..8505570a6 100644 --- a/dev/etherlink.hh +++ b/dev/etherlink.hh @@ -96,6 +96,9 @@ class EtherLink : public SimObject void setTxInt(Interface *i) { assert(!txint); txint = i; } void setRxInt(Interface *i) { assert(!rxint); rxint = i; } + + virtual void serialize(std::ostream &os); + virtual void unserialize(Checkpoint *cp, const std::string §ion); }; /* @@ -122,6 +125,10 @@ class EtherLink : public SimObject EtherLink(const std::string &name, EtherInt *i1, EtherInt *i2, Tick speed, EtherDump *dump); virtual ~EtherLink(); + + virtual void serialize(std::ostream &os); + virtual void unserialize(Checkpoint *cp, const std::string §ion); + }; #endif // __ETHERLINK_HH__ -- cgit v1.2.3 From ee8c8cbcd89f70d50a770007c6bcaf428ac2f233 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 20 Feb 2004 15:19:19 -0500 Subject: make etherdump work again dev/etherdump.cc: now that init is automatically called by the framework, don't init twice. --HG-- extra : convert_revision : 16dcdef67aa193ed71ff546e7b255d60f39bf13d --- dev/etherdump.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'dev') diff --git a/dev/etherdump.cc b/dev/etherdump.cc index 6d86adc32..23b3d778e 100644 --- a/dev/etherdump.cc +++ b/dev/etherdump.cc @@ -43,11 +43,8 @@ using std::string; EtherDump::EtherDump(const string &name, const string &file) : SimObject(name) { - if (!file.empty()) { + if (!file.empty()) stream.open(file.c_str()); - if (stream.is_open()) - init(); - } } #define DLT_EN10MB 1 // Ethernet (10Mb) @@ -74,6 +71,9 @@ struct pcap_pkthdr { void EtherDump::init() { + if (!stream.is_open()) + return; + curtime = time(NULL); s_freq = ticksPerSecond; us_freq = ticksPerSecond / ULL(1000000); -- cgit v1.2.3 From ec06c63cc7a63111e9d21936a302901c552ad36b Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 20 Feb 2004 15:23:27 -0500 Subject: make the dma interface useable. make it so that pio devices must respond with some delay. dev/io_device.cc: don't forget to include dma_interface.hh so we could use it. dev/io_device.hh: the generic BusInterface isn't enough for doing DMA we need the actual DMAInterface --HG-- extra : convert_revision : 70298d33c8520a3f4ad11aa600825a8cec7e44bf --- dev/io_device.cc | 1 + dev/io_device.hh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'dev') diff --git a/dev/io_device.cc b/dev/io_device.cc index 65a18aec6..4f53ba48d 100644 --- a/dev/io_device.cc +++ b/dev/io_device.cc @@ -28,6 +28,7 @@ #include "dev/io_device.hh" #include "mem/bus/base_interface.hh" +#include "mem/bus/dma_interface.hh" PioDevice::PioDevice(const std::string &name) : FunctionalMemory(name), pioInterface(NULL) diff --git a/dev/io_device.hh b/dev/io_device.hh index 39e6fa4aa..9300d87e7 100644 --- a/dev/io_device.hh +++ b/dev/io_device.hh @@ -34,6 +34,7 @@ class BaseInterface; class Bus; class HierParams; +template class DMAInterface; class PioDevice : public FunctionalMemory { @@ -48,7 +49,7 @@ class PioDevice : public FunctionalMemory class DmaDevice : public PioDevice { protected: - BaseInterface *dmaInterface; + DMAInterface *dmaInterface; public: DmaDevice(const std::string &name); -- cgit v1.2.3 From 610081079cd02a620794fa1ac693822c191223ec Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Sat, 21 Feb 2004 10:43:37 -0500 Subject: New Ethernet device. Descriptors are now done via DMA instead of faking it. Renamed stuff to follow our style. Lots of general cleanup. dev/etherpkt.hh: fix up includes --HG-- extra : convert_revision : fb3a21466cdae00f8747d6e3027c9f2c63569c48 --- dev/etherpkt.cc | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ dev/etherpkt.hh | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 dev/etherpkt.cc (limited to 'dev') diff --git a/dev/etherpkt.cc b/dev/etherpkt.cc new file mode 100644 index 000000000..cb6087c89 --- /dev/null +++ b/dev/etherpkt.cc @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2004 The Regents of The University of Michigan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include "dev/etherpkt.hh" +#include "sim/serialize.hh" + +using namespace std; + +void +EtherPacket::serialize(ostream &os) +{ + SERIALIZE_SCALAR(length); + SERIALIZE_ARRAY(data, length); +} + +void +EtherPacket::unserialize(Checkpoint *cp, const std::string §ion) +{ + UNSERIALIZE_SCALAR(length); + data = new uint8_t[length]; + UNSERIALIZE_ARRAY(data, length); +} + diff --git a/dev/etherpkt.hh b/dev/etherpkt.hh index c91322526..27ac526d6 100644 --- a/dev/etherpkt.hh +++ b/dev/etherpkt.hh @@ -33,10 +33,10 @@ #ifndef __ETHERPKT_HH__ #define __ETHERPKT_HH__ +#include #include #include "sim/host.hh" - #include "base/refcnt.hh" class Checkpoint; -- cgit v1.2.3 From bc5ed80b32c703fb86ead2dbd525b7c6323e563f Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Sun, 22 Feb 2004 18:09:11 -0500 Subject: configurable latency for programmed IO fix serialization dev/etherlink.cc: fix serialization --HG-- extra : convert_revision : 6739001f3f97b745d9874bb4c5729cc4909625c2 --- dev/etherlink.cc | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'dev') diff --git a/dev/etherlink.cc b/dev/etherlink.cc index 7c70b82ce..6396d758d 100644 --- a/dev/etherlink.cc +++ b/dev/etherlink.cc @@ -88,15 +88,17 @@ EtherLink::Link::Link(const std::string &name, double rate, EtherDump *d) void EtherLink::serialize(ostream &os) { + nameOut(os, name() + ".link1"); link1->serialize(os); + nameOut(os, name() + ".link2"); link2->serialize(os); } void EtherLink::unserialize(Checkpoint *cp, const string §ion) { - link1->unserialize(cp, section); - link2->unserialize(cp, section); + link1->unserialize(cp, section + ".link1"); + link2->unserialize(cp, section + ".link2"); } void @@ -139,36 +141,38 @@ EtherLink::Link::transmit(PacketPtr &pkt) void EtherLink::Link::serialize(ostream &os) { - bool packetExists = false; - if (packet) packetExists = true; - SERIALIZE_SCALAR(packetExists); - if (packetExists) { - nameOut(os, csprintf("%s.linkPacket", name())); - packet->serialize(os); - } + bool packet_exists = packet; + SERIALIZE_SCALAR(packet_exists); bool event_scheduled = event.scheduled(); SERIALIZE_SCALAR(event_scheduled); if (event_scheduled) { - SERIALIZE_SCALAR(event.when()); + Tick event_time = event.when(); + SERIALIZE_SCALAR(event_time); + } + + if (packet_exists) { + nameOut(os, csprintf("%s.packet", name())); + packet->serialize(os); } } void EtherLink::Link::unserialize(Checkpoint *cp, const string §ion) { - bool event_scheduled, packetExists; - Tick eventTime; - UNSERIALIZE_SCALAR(packetExists); - if (packetExists) { + bool packet_exists; + UNSERIALIZE_SCALAR(packet_exists); + if (packet_exists) { packet = new EtherPacket; - packet->unserialize(cp, csprintf("%s.linkPacket", section)); + packet->unserialize(cp, csprintf("%s.packet", section)); } + bool event_scheduled; UNSERIALIZE_SCALAR(event_scheduled); if (event_scheduled) { - UNSERIALIZE_SCALAR(eventTime); - event.schedule(eventTime); + Tick event_time; + UNSERIALIZE_SCALAR(event_time); + event.schedule(event_time); } } -- cgit v1.2.3 From b491bda24145ffc9ce71a1d79b7b90926f910570 Mon Sep 17 00:00:00 2001 From: Erik Hallnor Date: Sun, 29 Feb 2004 16:18:49 -0500 Subject: Add support for multiple address ranges in memory interfaces. dev/alpha_console.cc: setAddrRange -> addAddrRange --HG-- extra : convert_revision : 9dc853b80bea443b54a130ca4c110a68077cb336 --- dev/alpha_console.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dev') diff --git a/dev/alpha_console.cc b/dev/alpha_console.cc index 85b4d57f2..04046557a 100644 --- a/dev/alpha_console.cc +++ b/dev/alpha_console.cc @@ -63,7 +63,7 @@ AlphaConsole::AlphaConsole(const string &name, SimConsole *cons, SimpleDisk *d, if (bus) { pioInterface = newPioInterface(name, hier, bus, this, &AlphaConsole::cacheAccess); - pioInterface->setAddrRange(addr, addr + size); + pioInterface->addAddrRange(addr, addr + size); } consoleData = new uint8_t[size]; -- cgit v1.2.3 From 2272164d6652c554fb3bab7bddfd0d53151e4115 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Sun, 29 Feb 2004 17:05:23 -0500 Subject: Fix dumping to work on the opteron. struct timeval can vary in size, so we're explicit about the fields. --HG-- extra : convert_revision : e5264849dafb878676b2bfd3a6e6f95f6f94ea48 --- dev/etherdump.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'dev') diff --git a/dev/etherdump.cc b/dev/etherdump.cc index 23b3d778e..b6d6bbe30 100644 --- a/dev/etherdump.cc +++ b/dev/etherdump.cc @@ -34,6 +34,7 @@ #include +#include "base/misc.hh" #include "dev/etherdump.hh" #include "sim/builder.hh" #include "sim/universe.hh" @@ -63,7 +64,8 @@ struct pcap_file_header { }; struct pcap_pkthdr { - struct timeval ts; // time stamp + uint32_t seconds; + uint32_t microseconds; uint32_t caplen; // length of portion present uint32_t len; // length this packet (off wire) }; @@ -96,8 +98,8 @@ EtherDump::init() * to sim_cycles. */ pcap_pkthdr pkthdr; - pkthdr.ts.tv_sec = curtime; - pkthdr.ts.tv_usec = 0; + pkthdr.seconds = curtime; + pkthdr.microseconds = 0; pkthdr.caplen = 0; pkthdr.len = 0; stream.write(reinterpret_cast(&pkthdr), sizeof(pkthdr)); @@ -109,8 +111,8 @@ void EtherDump::dumpPacket(PacketPtr &packet) { pcap_pkthdr pkthdr; - pkthdr.ts.tv_sec = curtime + (curTick / s_freq); - pkthdr.ts.tv_usec = (curTick / us_freq) % ULL(1000000); + pkthdr.seconds = curtime + (curTick / s_freq); + pkthdr.microseconds = (curTick / us_freq) % ULL(1000000); pkthdr.caplen = packet->length; pkthdr.len = packet->length; stream.write(reinterpret_cast(&pkthdr), sizeof(pkthdr)); -- cgit v1.2.3 From c74cb77fa40b09089a383fb961c5fb0ec030f3c7 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 5 Mar 2004 05:47:05 -0500 Subject: Add support for a propagation delay on the link. The electrical delay is more or less folded into the packet time, but an additional delay is possible representing crossing a long haul link, or some switches, etc. --HG-- extra : convert_revision : 8fd689c2a7e3051e77f47a4cd5f51c6999d92c8f --- dev/etherlink.cc | 131 +++++++++++++++++++++++++++++++++++++++++++++---------- dev/etherlink.hh | 31 +++++-------- 2 files changed, 121 insertions(+), 41 deletions(-) (limited to 'dev') diff --git a/dev/etherlink.cc b/dev/etherlink.cc index 6396d758d..25991f1a7 100644 --- a/dev/etherlink.cc +++ b/dev/etherlink.cc @@ -46,14 +46,15 @@ using namespace std; -EtherLink::EtherLink(const std::string &name, EtherInt *i1, EtherInt *i2, - Tick speed, EtherDump *dump) +EtherLink::EtherLink(const string &name, EtherInt *i1, EtherInt *i2, + Tick speed, Tick dly, EtherDump *dump) : SimObject(name) { double rate = ((double)ticksPerSecond * 8.0) / (double)speed; + Tick delay = US2Ticks(dly); - link1 = new Link(name + ".link1", rate, dump); - link2 = new Link(name + ".link2", rate, dump); + link1 = new Link(name + ".link1", rate, delay, dump); + link2 = new Link(name + ".link2", rate, delay, dump); int1 = new Interface(name + ".int1", link1, link2); int2 = new Interface(name + ".int2", link2, link1); @@ -73,16 +74,17 @@ EtherLink::~EtherLink() delete int2; } -EtherLink::Interface::Interface(const std::string &name, Link *tx, Link *rx) +EtherLink::Interface::Interface(const string &name, Link *tx, Link *rx) : EtherInt(name), txlink(tx) { tx->setTxInt(this); rx->setRxInt(this); } -EtherLink::Link::Link(const std::string &name, double rate, EtherDump *d) - : objName(name), txint(NULL), rxint(NULL), ticks_per_byte(rate), - dump(d), event(&mainEventQueue, this) +EtherLink::Link::Link(const string &name, double rate, Tick delay, + EtherDump *d) + : objName(name), txint(NULL), rxint(NULL), ticksPerByte(rate), + linkDelay(delay), dump(d), doneEvent(this) {} void @@ -101,16 +103,47 @@ EtherLink::unserialize(Checkpoint *cp, const string §ion) link2->unserialize(cp, section + ".link2"); } +void +EtherLink::Link::txComplete(PacketPtr &packet) +{ + DPRINTF(Ethernet, "packet received: len=%d\n", packet->length); + DDUMP(EthernetData, packet->data, packet->length); + rxint->sendPacket(packet); +} + +class LinkDelayEvent : public Event +{ + protected: + EtherLink::Link *link; + PacketPtr packet; + + // non-scheduling version for createForUnserialize() + LinkDelayEvent(EtherLink::Link *link); + + public: + LinkDelayEvent(EtherLink::Link *link, PacketPtr &pkt, Tick when); + + void process(); + + virtual void serialize(ostream &os); + virtual void unserialize(Checkpoint *cp, const string §ion); + static Serializable *createForUnserialize(Checkpoint *cp, + const string §ion); +}; + + void EtherLink::Link::txDone() { if (dump) dump->dump(packet); - DPRINTF(Ethernet, "EtherLink packet received: len=%d\n", packet->length); - DDUMP(EthernetData, packet->data, packet->length); - - rxint->sendPacket(packet); + if (linkDelay > 0) { + DPRINTF(Ethernet, "packet delayed: delay=%d\n", linkDelay); + new LinkDelayEvent(this, packet, curTick + linkDelay); + } else { + txComplete(packet); + } packet = 0; assert(!busy()); @@ -122,18 +155,18 @@ bool EtherLink::Link::transmit(PacketPtr &pkt) { if (busy()) { - DPRINTF(Ethernet, "EtherLink packet not sent, link busy\n"); + DPRINTF(Ethernet, "packet not sent, link busy\n"); return false; } - DPRINTF(Ethernet, "EtherLink packet sent: len=%d\n", pkt->length); + DPRINTF(Ethernet, "packet sent: len=%d\n", pkt->length); DDUMP(EthernetData, pkt->data, pkt->length); packet = pkt; - int delay = (int)ceil(((double)pkt->length * ticks_per_byte) + 1.0); - DPRINTF(Ethernet, "EtherLink scheduling packet: delay=%d, (rate=%f)\n", - delay, ticks_per_byte); - event.schedule(curTick + delay); + Tick delay = (Tick)ceil(((double)pkt->length * ticksPerByte) + 1.0); + DPRINTF(Ethernet, "scheduling packet: delay=%d, (rate=%f)\n", + delay, ticksPerByte); + doneEvent.schedule(curTick + delay); return true; } @@ -144,10 +177,10 @@ EtherLink::Link::serialize(ostream &os) bool packet_exists = packet; SERIALIZE_SCALAR(packet_exists); - bool event_scheduled = event.scheduled(); + bool event_scheduled = doneEvent.scheduled(); SERIALIZE_SCALAR(event_scheduled); if (event_scheduled) { - Tick event_time = event.when(); + Tick event_time = doneEvent.when(); SERIALIZE_SCALAR(event_time); } @@ -172,15 +205,68 @@ EtherLink::Link::unserialize(Checkpoint *cp, const string §ion) if (event_scheduled) { Tick event_time; UNSERIALIZE_SCALAR(event_time); - event.schedule(event_time); + doneEvent.schedule(event_time); } } +LinkDelayEvent::LinkDelayEvent(EtherLink::Link *l) + : Event(&mainEventQueue), link(l) +{ + setFlags(AutoSerialize); + setFlags(AutoDelete); +} + +LinkDelayEvent::LinkDelayEvent(EtherLink::Link *l, PacketPtr &p, Tick when) + : Event(&mainEventQueue), link(l), packet(p) +{ + setFlags(AutoSerialize); + setFlags(AutoDelete); + schedule(when); +} + +void +LinkDelayEvent::process() +{ + link->txComplete(packet); +} + +void +LinkDelayEvent::serialize(ostream &os) +{ + paramOut(os, "type", string("LinkDelayEvent")); + Event::serialize(os); + SERIALIZE_OBJPTR(link); + + nameOut(os, csprintf("%s.packet", name())); + packet->serialize(os); +} + + +void +LinkDelayEvent::unserialize(Checkpoint *cp, const string §ion) +{ + Event::unserialize(cp, section); + packet = new EtherPacket; + packet->unserialize(cp, csprintf("%s.packet", section)); +} + + +Serializable * +LinkDelayEvent::createForUnserialize(Checkpoint *cp, const string §ion) +{ + EtherLink::Link *link; + UNSERIALIZE_OBJPTR(link); + return new LinkDelayEvent(link); +} + +REGISTER_SERIALIZEABLE("LinkDelayEvent", LinkDelayEvent) + BEGIN_DECLARE_SIM_OBJECT_PARAMS(EtherLink) SimObjectParam interface1; SimObjectParam interface2; Param link_speed; + Param link_delay; SimObjectParam packet_dump; END_DECLARE_SIM_OBJECT_PARAMS(EtherLink) @@ -190,6 +276,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(EtherLink) INIT_PARAM(interface1, "interface 1"), INIT_PARAM(interface2, "interface 2"), INIT_PARAM_DFLT(link_speed, "link speed in bits per second", 100000000), + INIT_PARAM_DFLT(link_delay, "transmit delay of packets in us", 0), INIT_PARAM_DFLT(packet_dump, "object to dump network packets to", NULL) END_INIT_SIM_OBJECT_PARAMS(EtherLink) @@ -197,7 +284,7 @@ END_INIT_SIM_OBJECT_PARAMS(EtherLink) CREATE_SIM_OBJECT(EtherLink) { return new EtherLink(getInstanceName(), interface1, interface2, link_speed, - packet_dump); + link_delay, packet_dump); } REGISTER_SIM_OBJECT("EtherLink", EtherLink) diff --git a/dev/etherlink.hh b/dev/etherlink.hh index 8505570a6..3b1dd21bc 100644 --- a/dev/etherlink.hh +++ b/dev/etherlink.hh @@ -49,6 +49,7 @@ class EtherLink : public SimObject protected: class Interface; + friend class LinkDelayEvent; /* * Model for a single uni-directional link */ @@ -59,34 +60,26 @@ class EtherLink : public SimObject Interface *txint; Interface *rxint; - double ticks_per_byte; + double ticksPerByte; + Tick linkDelay; EtherDump *dump; protected: /* * Transfer is complete */ - class DoneEvent : public Event - { - protected: - Link *link; - - public: - DoneEvent(EventQueue *q, Link *l) - : Event(q), link(l) {} - virtual void process() { link->txDone(); } - virtual const char *description() - { return "ethernet link completion"; } - }; - - friend class DoneEvent; - DoneEvent event; PacketPtr packet; - void txDone(); + typedef EventWrapper DoneEvent; + friend class DoneEvent; + DoneEvent doneEvent; + + friend class LinkDelayEvent; + void txComplete(PacketPtr &packet); public: - Link(const std::string &name, double rate, EtherDump *dump); + Link(const std::string &name, double rate, Tick delay, + EtherDump *dump); ~Link() {} virtual const std::string name() const { return objName; } @@ -123,7 +116,7 @@ class EtherLink : public SimObject public: EtherLink(const std::string &name, EtherInt *i1, EtherInt *i2, - Tick speed, EtherDump *dump); + Tick speed, Tick delay, EtherDump *dump); virtual ~EtherLink(); virtual void serialize(std::ostream &os); -- cgit v1.2.3