diff options
Diffstat (limited to 'src/dev/x86/south_bridge')
-rw-r--r-- | src/dev/x86/south_bridge/SConscript | 6 | ||||
-rw-r--r-- | src/dev/x86/south_bridge/SouthBridge.py | 38 | ||||
-rw-r--r-- | src/dev/x86/south_bridge/i8254.cc | 80 | ||||
-rw-r--r-- | src/dev/x86/south_bridge/i8254.hh | 66 | ||||
-rw-r--r-- | src/dev/x86/south_bridge/south_bridge.cc | 44 | ||||
-rw-r--r-- | src/dev/x86/south_bridge/south_bridge.hh | 41 | ||||
-rw-r--r-- | src/dev/x86/south_bridge/speaker.cc | 70 | ||||
-rw-r--r-- | src/dev/x86/south_bridge/speaker.hh | 74 | ||||
-rw-r--r-- | src/dev/x86/south_bridge/sub_device.hh | 79 |
9 files changed, 57 insertions, 441 deletions
diff --git a/src/dev/x86/south_bridge/SConscript b/src/dev/x86/south_bridge/SConscript index c4e31bb8c..639298ca1 100644 --- a/src/dev/x86/south_bridge/SConscript +++ b/src/dev/x86/south_bridge/SConscript @@ -34,9 +34,3 @@ if env['FULL_SYSTEM'] and env['TARGET_ISA'] == 'x86': # Main device SimObject('SouthBridge.py') Source('south_bridge.cc') - - # Sub devices - Source('i8254.cc') - Source('speaker.cc') - - TraceFlag('PCSpeaker') diff --git a/src/dev/x86/south_bridge/SouthBridge.py b/src/dev/x86/south_bridge/SouthBridge.py index bec3c4223..2f4b8438a 100644 --- a/src/dev/x86/south_bridge/SouthBridge.py +++ b/src/dev/x86/south_bridge/SouthBridge.py @@ -28,8 +28,42 @@ from m5.params import * from m5.proxy import * -from Device import PioDevice +from Cmos import Cmos +from I8254 import I8254 +from I8259 import I8259 +from PcSpeaker import PcSpeaker +from m5.SimObject import SimObject -class SouthBridge(PioDevice): +def x86IOAddress(port): + IO_address_space_base = 0x8000000000000000 + return IO_address_space_base + port; + +class SouthBridge(SimObject): type = 'SouthBridge' pio_latency = Param.Latency('1ns', "Programmed IO latency in simticks") + platform = Param.Platform(Parent.any, "Platform this device is part of") + + _pic1 = I8259(pio_addr=x86IOAddress(0x20), mode='I8259Master') + _pic2 = I8259(pio_addr=x86IOAddress(0xA0), mode='I8259Slave') + _cmos = Cmos(pio_addr=x86IOAddress(0x70)) + _pit = I8254(pio_addr=x86IOAddress(0x40)) + _speaker = PcSpeaker(pio_addr=x86IOAddress(0x61)) + + pic1 = Param.I8259(_pic1, "Master PIC") + pic2 = Param.I8259(_pic2, "Slave PIC") + cmos = Param.Cmos(_cmos, "CMOS memory and real time clock device") + pit = Param.I8254(_pit, "Programmable interval timer") + speaker = Param.PcSpeaker(_speaker, "PC speaker") + + def attachIO(self, bus): + # Make internal connections + self.pic2.output = self.pic1.pin(2) + self.cmos.int_pin = self.pic2.pin(0) + self.pit.int_pin = self.pic1.pin(0) + self.speaker.i8254 = self.pit + # Connect to the bus + self.cmos.pio = bus.port + self.pic1.pio = bus.port + self.pic2.pio = bus.port + self.pit.pio = bus.port + self.speaker.pio = bus.port diff --git a/src/dev/x86/south_bridge/i8254.cc b/src/dev/x86/south_bridge/i8254.cc deleted file mode 100644 index c9c0d625a..000000000 --- a/src/dev/x86/south_bridge/i8254.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2008 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. - * - * Authors: Gabe Black - */ - -#include "dev/x86/south_bridge/i8254.hh" -#include "mem/packet_access.hh" - -Tick -X86ISA::I8254::read(PacketPtr pkt) -{ - assert(pkt->getSize() == 1); - switch(pkt->getAddr() - addrRange.start) - { - case 0x0: - pkt->set(pit.readCounter(0)); - break; - case 0x1: - pkt->set(pit.readCounter(1)); - break; - case 0x2: - pkt->set(pit.readCounter(2)); - break; - case 0x3: - pkt->set(uint8_t(-1)); - break; - default: - panic("Read from undefined i8254 register.\n"); - } - return latency; -} - -Tick -X86ISA::I8254::write(PacketPtr pkt) -{ - assert(pkt->getSize() == 1); - switch(pkt->getAddr() - addrRange.start) - { - case 0x0: - pit.writeCounter(0, pkt->get<uint8_t>()); - break; - case 0x1: - pit.writeCounter(1, pkt->get<uint8_t>()); - break; - case 0x2: - pit.writeCounter(2, pkt->get<uint8_t>()); - break; - case 0x3: - pit.writeControl(pkt->get<uint8_t>()); - break; - default: - panic("Write to undefined i8254 register.\n"); - } - return latency; -} diff --git a/src/dev/x86/south_bridge/i8254.hh b/src/dev/x86/south_bridge/i8254.hh deleted file mode 100644 index b6dd388a7..000000000 --- a/src/dev/x86/south_bridge/i8254.hh +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2008 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. - * - * Authors: Gabe Black - */ - -#ifndef __DEV_X86_SOUTH_BRIDGE_I8254_HH__ -#define __DEV_X86_SOUTH_BRIDGE_I8254_HH__ - -#include "arch/x86/x86_traits.hh" -#include "base/range.hh" -#include "dev/intel_8254_timer.hh" -#include "dev/x86/south_bridge/sub_device.hh" - -#include <string> - -namespace X86ISA -{ - -class I8254 : public SubDevice -{ - public: - Intel8254Timer pit; - - I8254(EventManager *em, const std::string &name) : pit(em, name) - {} - I8254(EventManager *em, const std::string &name, Tick _latency) : - SubDevice(_latency), pit(em, name) - {} - I8254(EventManager *em, const std::string &name, - Addr start, Addr size, Tick _latency) : - SubDevice(start, size, _latency), pit(em, name) - {} - - Tick read(PacketPtr pkt); - - Tick write(PacketPtr pkt); -}; - -}; // namespace X86ISA - -#endif //__DEV_X86_SOUTH_BRIDGE_I8254_HH__ diff --git a/src/dev/x86/south_bridge/south_bridge.cc b/src/dev/x86/south_bridge/south_bridge.cc index 0e9a63a74..12f4657b0 100644 --- a/src/dev/x86/south_bridge/south_bridge.cc +++ b/src/dev/x86/south_bridge/south_bridge.cc @@ -28,51 +28,17 @@ * Authors: Gabe Black */ -#include "arch/x86/x86_traits.hh" -#include "base/range.hh" +#include <assert.h> + #include "dev/x86/pc.hh" #include "dev/x86/south_bridge/south_bridge.hh" using namespace X86ISA; -void -SouthBridge::addDevice(X86ISA::SubDevice & sub) -{ - rangeList.push_back(sub.addrRange); - rangeMap.insert(sub.addrRange, &sub); -} - -void -SouthBridge::addressRanges(AddrRangeList &range_list) -{ - range_list = rangeList; -} - -Tick -SouthBridge::read(PacketPtr pkt) +SouthBridge::SouthBridge(const Params *p) : SimObject(p), + platform(p->platform), pit(p->pit), pic1(p->pic1), pic2(p->pic2), + cmos(p->cmos), speaker(p->speaker) { - RangeMapIt sub = - rangeMap.find(RangeSize(pkt->getAddr(), 1)); - assert(sub != rangeMap.end()); - return sub->second->read(pkt); -} - -Tick -SouthBridge::write(PacketPtr pkt) -{ - RangeMapIt sub = - rangeMap.find(RangeSize(pkt->getAddr(), 1)); - assert(sub != rangeMap.end()); - return sub->second->write(pkt); -} - -SouthBridge::SouthBridge(const Params *p) : PioDevice(p), - pit(this, p->name + ".pit", 0x40, 4, p->pio_latency), - speaker(&pit, 0x61, 1, p->pio_latency) -{ - addDevice(pit); - addDevice(speaker); - // Let the platform know where we are PC * pc = dynamic_cast<PC *>(platform); assert(pc); diff --git a/src/dev/x86/south_bridge/south_bridge.hh b/src/dev/x86/south_bridge/south_bridge.hh index 171589cf3..9e7963a7b 100644 --- a/src/dev/x86/south_bridge/south_bridge.hh +++ b/src/dev/x86/south_bridge/south_bridge.hh @@ -31,39 +31,30 @@ #ifndef __DEV_X86_SOUTH_BRIDGE_SOUTH_BRIDGE_HH__ #define __DEV_X86_SOUTH_BRIDGE_SOUTH_BRIDGE_HH__ -#include "base/range_map.hh" -#include "dev/io_device.hh" -#include "dev/x86/south_bridge/i8254.hh" -#include "dev/x86/south_bridge/speaker.hh" -#include "dev/x86/south_bridge/sub_device.hh" +#include "sim/sim_object.hh" #include "params/SouthBridge.hh" -class SouthBridge : public PioDevice +namespace X86ISA { - protected: - AddrRangeList rangeList; - - typedef range_map<Addr, X86ISA::SubDevice *> RangeMap; - typedef RangeMap::iterator RangeMapIt; - RangeMap rangeMap; - + class I8254; + class I8259; + class Cmos; + class Speaker; +} - void addDevice(X86ISA::SubDevice &); +class SouthBridge : public SimObject +{ + protected: + Platform * platform; public: - // I8254 Programmable Interval Timer - X86ISA::I8254 pit; - - // PC speaker - X86ISA::Speaker speaker; + X86ISA::I8254 * pit; + X86ISA::I8259 * pic1; + X86ISA::I8259 * pic2; + X86ISA::Cmos * cmos; + X86ISA::Speaker * speaker; public: - - void addressRanges(AddrRangeList &range_list); - - Tick read(PacketPtr pkt); - Tick write(PacketPtr pkt); - typedef SouthBridgeParams Params; SouthBridge(const Params *p); diff --git a/src/dev/x86/south_bridge/speaker.cc b/src/dev/x86/south_bridge/speaker.cc deleted file mode 100644 index 59a86c634..000000000 --- a/src/dev/x86/south_bridge/speaker.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2008 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. - * - * Authors: Gabe Black - */ - -#include "base/bitunion.hh" -#include "base/trace.hh" -#include "dev/x86/south_bridge/i8254.hh" -#include "dev/x86/south_bridge/speaker.hh" -#include "mem/packet_access.hh" - -Tick -X86ISA::Speaker::read(PacketPtr pkt) -{ - assert(pkt->getAddr() == addrRange.start); - assert(pkt->getSize() == 1); - controlVal.timer = timer->pit.outputHigh(2) ? 1 : 0; - DPRINTF(PCSpeaker, - "Reading from speaker device: gate %s, speaker %s, output %s.\n", - controlVal.gate ? "on" : "off", - controlVal.speaker ? "on" : "off", - controlVal.timer ? "on" : "off"); - pkt->set((uint8_t)controlVal); - return latency; -} - -Tick -X86ISA::Speaker::write(PacketPtr pkt) -{ - assert(pkt->getAddr() == addrRange.start); - assert(pkt->getSize() == 1); - SpeakerControl val = pkt->get<uint8_t>(); - controlVal.gate = val.gate; - //Change the gate value in the timer. - if (!val.gate) - warn("The gate bit of the pc speaker isn't implemented and " - "is always on.\n"); - //This would control whether the timer output is hooked up to a physical - //speaker. Since M5 can't make noise, it's value doesn't actually do - //anything. - controlVal.speaker = val.speaker; - DPRINTF(PCSpeaker, "Writing to speaker device: gate %s, speaker %s.\n", - controlVal.gate ? "on" : "off", controlVal.speaker ? "on" : "off"); - return latency; -} diff --git a/src/dev/x86/south_bridge/speaker.hh b/src/dev/x86/south_bridge/speaker.hh deleted file mode 100644 index 2385b80cc..000000000 --- a/src/dev/x86/south_bridge/speaker.hh +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2008 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. - * - * Authors: Gabe Black - */ - -#ifndef __DEV_X86_SOUTH_BRIDGE_SPEAKER_HH__ -#define __DEV_X86_SOUTH_BRIDGE_SPEAKER_HH__ - -#include "arch/x86/x86_traits.hh" -#include "base/range.hh" -#include "dev/x86/south_bridge/sub_device.hh" - -namespace X86ISA -{ - -class I8254; - -class Speaker : public SubDevice -{ - protected: - BitUnion8(SpeakerControl) - Bitfield<0> gate; - Bitfield<1> speaker; - Bitfield<5> timer; - EndBitUnion(SpeakerControl) - - SpeakerControl controlVal; - - I8254 * timer; - - public: - - Speaker(I8254 * _timer) : timer(_timer) - {} - Speaker(I8254 * _timer, Tick _latency) : - SubDevice(_latency), timer(_timer) - {} - Speaker(I8254 * _timer, Addr start, Addr size, Tick _latency) : - SubDevice(start, size, _latency), timer(_timer) - {} - - Tick read(PacketPtr pkt); - - Tick write(PacketPtr pkt); -}; - -}; // namespace X86ISA - -#endif //__DEV_X86_SOUTH_BRIDGE_SPEAKER_HH__ diff --git a/src/dev/x86/south_bridge/sub_device.hh b/src/dev/x86/south_bridge/sub_device.hh deleted file mode 100644 index 3cc51bdd9..000000000 --- a/src/dev/x86/south_bridge/sub_device.hh +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2004-2005 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. - * - * Authors: Gabe Black - */ - -#ifndef __DEV_X86_SOUTH_BRIDGE_SUB_DEVICE_HH__ -#define __DEV_X86_SOUTH_BRIDGE_SUB_DEVICE_HH__ - -#include "arch/x86/x86_traits.hh" -#include "base/range.hh" -#include "mem/packet.hh" - -namespace X86ISA -{ - -class SubDevice -{ - public: - - Range<Addr> addrRange; - Tick latency; - - virtual - ~SubDevice() - {} - - SubDevice() - {} - SubDevice(Tick _latency) : latency(_latency) - {} - SubDevice(Addr start, Addr size, Tick _latency) : - addrRange(RangeSize(x86IOAddress(start), size)), latency(_latency) - {} - - virtual Tick - read(PacketPtr pkt) - { - assert(pkt->getSize() <= 4); - pkt->allocate(); - const uint32_t neg1 = -1; - pkt->setData((uint8_t *)(&neg1)); - return latency; - } - - virtual Tick - write(PacketPtr pkt) - { - return latency; - } -}; - -}; // namespace X86ISA - -#endif //__DEV_X86_SOUTH_BRIDGE_SUB_DEVICE_HH__ |