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
This commit is contained in:
Nathan Binkert 2004-02-11 16:07:55 -05:00
parent 5e82f8d84c
commit cc53465cd5
4 changed files with 142 additions and 8 deletions

View file

@ -43,6 +43,9 @@
#include "dev/console.hh" #include "dev/console.hh"
#include "dev/simple_disk.hh" #include "dev/simple_disk.hh"
#include "dev/tlaser_clock.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 "mem/functional_mem/memory_control.hh"
#include "sim/builder.hh" #include "sim/builder.hh"
#include "sim/system.hh" #include "sim/system.hh"
@ -51,11 +54,18 @@ using namespace std;
AlphaConsole::AlphaConsole(const string &name, SimConsole *cons, SimpleDisk *d, AlphaConsole::AlphaConsole(const string &name, SimConsole *cons, SimpleDisk *d,
System *system, BaseCPU *cpu, TlaserClock *clock, System *system, BaseCPU *cpu, TlaserClock *clock,
int num_cpus, MemoryController *mmu, Addr a) int num_cpus, MemoryController *mmu, Addr a,
: FunctionalMemory(name), disk(d), console(cons), addr(a) HierParams *hier, Bus *bus)
: PioDevice(name), disk(d), console(cons), addr(a)
{ {
mmu->add_child(this, Range<Addr>(addr, addr + size)); mmu->add_child(this, Range<Addr>(addr, addr + size));
if (bus) {
pioInterface = newPioInterface(name, hier, bus, this,
&AlphaConsole::cacheAccess);
pioInterface->setAddrRange(addr, addr + size);
}
consoleData = new uint8_t[size]; consoleData = new uint8_t[size];
memset(consoleData, 0, size); memset(consoleData, 0, size);
@ -183,6 +193,12 @@ AlphaConsole::write(MemReqPtr &req, const uint8_t *data)
return No_Fault; return No_Fault;
} }
Tick
AlphaConsole::cacheAccess(MemReqPtr &req)
{
return curTick + 1000;
}
void void
AlphaAccess::serialize(ostream &os) AlphaAccess::serialize(ostream &os)
{ {
@ -251,6 +267,8 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(AlphaConsole)
SimObjectParam<System *> system; SimObjectParam<System *> system;
SimObjectParam<BaseCPU *> cpu; SimObjectParam<BaseCPU *> cpu;
SimObjectParam<TlaserClock *> clock; SimObjectParam<TlaserClock *> clock;
SimObjectParam<Bus*> io_bus;
SimObjectParam<HierParams *> hier;
END_DECLARE_SIM_OBJECT_PARAMS(AlphaConsole) END_DECLARE_SIM_OBJECT_PARAMS(AlphaConsole)
@ -263,14 +281,17 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(AlphaConsole)
INIT_PARAM(addr, "Device Address"), INIT_PARAM(addr, "Device Address"),
INIT_PARAM(system, "system object"), INIT_PARAM(system, "system object"),
INIT_PARAM(cpu, "Processor"), 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) END_INIT_SIM_OBJECT_PARAMS(AlphaConsole)
CREATE_SIM_OBJECT(AlphaConsole) CREATE_SIM_OBJECT(AlphaConsole)
{ {
return new AlphaConsole(getInstanceName(), sim_console, disk, return new AlphaConsole(getInstanceName(), sim_console, disk,
system, cpu, clock, num_cpus, mmu, addr); system, cpu, clock, num_cpus, mmu,
addr, hier, io_bus);
} }
REGISTER_SIM_OBJECT("AlphaConsole", AlphaConsole) REGISTER_SIM_OBJECT("AlphaConsole", AlphaConsole)

View file

@ -35,7 +35,7 @@
#include "base/range.hh" #include "base/range.hh"
#include "dev/alpha_access.h" #include "dev/alpha_access.h"
#include "mem/functional_mem/functional_memory.hh" #include "dev/io_device.hh"
#include "sim/host.hh" #include "sim/host.hh"
class BaseCPU; class BaseCPU;
@ -69,7 +69,7 @@ class SimpleDisk;
* primarily used doing boot before the kernel has loaded its device * primarily used doing boot before the kernel has loaded its device
* drivers. * drivers.
*/ */
class AlphaConsole : public FunctionalMemory class AlphaConsole : public PioDevice
{ {
protected: protected:
union { union {
@ -90,7 +90,8 @@ class AlphaConsole : public FunctionalMemory
/** Standard Constructor */ /** Standard Constructor */
AlphaConsole(const std::string &name, SimConsole *cons, SimpleDisk *d, AlphaConsole(const std::string &name, SimConsole *cons, SimpleDisk *d,
System *system, BaseCPU *cpu, TlaserClock *clock, 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 * memory mapped reads and writes
@ -103,6 +104,9 @@ class AlphaConsole : public FunctionalMemory
*/ */
virtual void serialize(std::ostream &os); virtual void serialize(std::ostream &os);
virtual void unserialize(Checkpoint *cp, const std::string &section); virtual void unserialize(Checkpoint *cp, const std::string &section);
public:
Tick cacheAccess(MemReqPtr &req);
}; };
#endif // __ALPHA_CONSOLE_HH__ #endif // __ALPHA_CONSOLE_HH__

51
dev/io_device.cc Normal file
View file

@ -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;
}

58
dev/io_device.hh Normal file
View file

@ -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__