south_bridge.cc revision 5446
12SN/A/*
21762SN/A * Copyright (c) 2008 The Regents of The University of Michigan
32SN/A * All rights reserved.
42SN/A *
52SN/A * Redistribution and use in source and binary forms, with or without
62SN/A * modification, are permitted provided that the following conditions are
72SN/A * met: redistributions of source code must retain the above copyright
82SN/A * notice, this list of conditions and the following disclaimer;
92SN/A * redistributions in binary form must reproduce the above copyright
102SN/A * notice, this list of conditions and the following disclaimer in the
112SN/A * documentation and/or other materials provided with the distribution;
122SN/A * neither the name of the copyright holders nor the names of its
132SN/A * contributors may be used to endorse or promote products derived from
142SN/A * this software without specific prior written permission.
152SN/A *
162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Gabe Black
292665Ssaidi@eecs.umich.edu */
302SN/A
312SN/A#include "arch/x86/x86_traits.hh"
322SN/A#include "base/range.hh"
332SN/A#include "dev/x86/pc.hh"
342SN/A#include "dev/x86/south_bridge/south_bridge.hh"
352SN/A
361354SN/Ausing namespace X86ISA;
371354SN/A
382SN/Avoid
392SN/ASouthBridge::addDevice(X86ISA::SubDevice & sub)
405501Snate@binkert.org{
415546Snate@binkert.org    rangeList.push_back(sub.addrRange);
422SN/A    rangeMap.insert(sub.addrRange, &sub);
432SN/A}
442SN/A
452SN/Avoid
4656SN/ASouthBridge::addressRanges(AddrRangeList &range_list)
472361SN/A{
481354SN/A    range_list = rangeList;
4956SN/A}
505501Snate@binkert.org
512SN/ATick
525543Ssaidi@eecs.umich.eduSouthBridge::read(PacketPtr pkt)
532SN/A{
541354SN/A    RangeMapIt sub =
551354SN/A        rangeMap.find(RangeSize(pkt->getAddr(), 1));
561354SN/A    assert(sub != rangeMap.end());
571354SN/A    return sub->second->read(pkt);
581354SN/A}
591354SN/A
601354SN/ATick
611354SN/ASouthBridge::write(PacketPtr pkt)
621354SN/A{
631354SN/A    RangeMapIt sub =
641354SN/A        rangeMap.find(RangeSize(pkt->getAddr(), 1));
651354SN/A    assert(sub != rangeMap.end());
662SN/A    return sub->second->write(pkt);
672SN/A}
682SN/A
692SN/ASouthBridge::SouthBridge(const Params *p) : PioDevice(p),
705501Snate@binkert.org    pic1(0x20, 2, p->pio_latency),
715501Snate@binkert.org    pic2(0xA0, 2, p->pio_latency),
722SN/A    pit(p->name + ".pit", 0x40, 4, p->pio_latency),
73395SN/A    cmos(0x70, 2, p->pio_latency),
742SN/A    speaker(&pit, 0x61, 1, p->pio_latency)
752SN/A{
762SN/A    addDevice(pic1);
772SN/A    addDevice(pic2);
785502Snate@binkert.org    addDevice(pit);
795502Snate@binkert.org    addDevice(cmos);
805502Snate@binkert.org    addDevice(speaker);
815503Snate@binkert.org
825503Snate@binkert.org    // Let the platform know where we are
835502Snate@binkert.org    PC * pc = dynamic_cast<PC *>(platform);
845502Snate@binkert.org    assert(pc);
855502Snate@binkert.org    pc->southBridge = this;
865502Snate@binkert.org}
875502Snate@binkert.org
885502Snate@binkert.orgSouthBridge *
895502Snate@binkert.orgSouthBridgeParams::create()
905602Snate@binkert.org{
915602Snate@binkert.org    return new SouthBridge(this);
925501Snate@binkert.org}
935501Snate@binkert.org