SouthBridge.py revision 8839
16899SN/A# Copyright (c) 2008 The Regents of The University of Michigan
29542Sandreas.hansson@arm.com# All rights reserved.
39542Sandreas.hansson@arm.com#
49542Sandreas.hansson@arm.com# Redistribution and use in source and binary forms, with or without
59542Sandreas.hansson@arm.com# modification, are permitted provided that the following conditions are
69542Sandreas.hansson@arm.com# met: redistributions of source code must retain the above copyright
79542Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer;
89542Sandreas.hansson@arm.com# redistributions in binary form must reproduce the above copyright
99542Sandreas.hansson@arm.com# notice, this list of conditions and the following disclaimer in the
109542Sandreas.hansson@arm.com# documentation and/or other materials provided with the distribution;
119542Sandreas.hansson@arm.com# neither the name of the copyright holders nor the names of its
129542Sandreas.hansson@arm.com# contributors may be used to endorse or promote products derived from
139542Sandreas.hansson@arm.com# this software without specific prior written permission.
146899SN/A#
156899SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
166899SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
176899SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
186899SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
196899SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
206899SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
216899SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
226899SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
236899SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
246899SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
256899SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
266899SN/A#
276899SN/A# Authors: Gabe Black
286899SN/A
296899SN/Afrom m5.params import *
306899SN/Afrom m5.proxy import *
316899SN/Afrom Cmos import Cmos
326899SN/Afrom I8042 import I8042
336899SN/Afrom I82094AA import I82094AA
346899SN/Afrom I8237 import I8237
356899SN/Afrom I8254 import I8254
366899SN/Afrom I8259 import I8259
376899SN/Afrom Ide import IdeController
386899SN/Afrom PcSpeaker import PcSpeaker
396899SN/Afrom X86IntPin import X86IntLine
406899SN/Afrom m5.SimObject import SimObject
416899SN/A
427053SN/Adef x86IOAddress(port):
437053SN/A    IO_address_space_base = 0x8000000000000000
446899SN/A    return IO_address_space_base + port;
457055SN/A
468229Snate@binkert.orgclass SouthBridge(SimObject):
477454SN/A    type = 'SouthBridge'
487055SN/A    pio_latency = Param.Latency('1ns', "Programmed IO latency in simticks")
497632SBrad.Beckmann@amd.com    platform = Param.Platform(Parent.any, "Platform this device is part of")
508229Snate@binkert.org
518229Snate@binkert.org    _pic1 = I8259(pio_addr=x86IOAddress(0x20), mode='I8259Master')
5211017Snilay@cs.wisc.edu    _pic2 = I8259(pio_addr=x86IOAddress(0xA0), mode='I8259Slave')
5311017Snilay@cs.wisc.edu    _cmos = Cmos(pio_addr=x86IOAddress(0x70))
546899SN/A    _dma1 = I8237(pio_addr=x86IOAddress(0x0))
556899SN/A    _keyboard = I8042(data_port=x86IOAddress(0x60), \
567053SN/A            command_port=x86IOAddress(0x64))
576899SN/A    _pit = I8254(pio_addr=x86IOAddress(0x40))
587053SN/A    _speaker = PcSpeaker(pio_addr=x86IOAddress(0x61))
598922Swilliam.wang@arm.com    _io_apic = I82094AA(pio_addr=0xFEC00000)
607053SN/A
617053SN/A    pic1 = Param.I8259(_pic1, "Master PIC")
627053SN/A    pic2 = Param.I8259(_pic2, "Slave PIC")
6311266SBrad.Beckmann@amd.com    cmos = Param.Cmos(_cmos, "CMOS memory and real time clock device")
6411266SBrad.Beckmann@amd.com    dma1 = Param.I8237(_dma1, "The first dma controller")
656899SN/A    keyboard = Param.I8042(_keyboard, "The keyboard controller")
667053SN/A    pit = Param.I8254(_pit, "Programmable interval timer")
678932SBrad.Beckmann@amd.com    speaker = Param.PcSpeaker(_speaker, "PC speaker")
688932SBrad.Beckmann@amd.com    io_apic = Param.I82094AA(_io_apic, "I/O APIC")
698932SBrad.Beckmann@amd.com
708932SBrad.Beckmann@amd.com    # IDE controller
718932SBrad.Beckmann@amd.com    ide = IdeController(disks=[], pci_func=0, pci_dev=4, pci_bus=0)
728932SBrad.Beckmann@amd.com    ide.BAR0 = 0x1f0
7311266SBrad.Beckmann@amd.com    ide.BAR0LegacyIO = True
7411266SBrad.Beckmann@amd.com    ide.BAR1 = 0x3f4
7511266SBrad.Beckmann@amd.com    ide.BAR1Size = '3B'
7611266SBrad.Beckmann@amd.com    ide.BAR1LegacyIO = True
777053SN/A    ide.BAR2 = 0x170
786899SN/A    ide.BAR2LegacyIO = True
797053SN/A    ide.BAR3 = 0x374
808975Sandreas.hansson@arm.com    ide.BAR3Size = '3B'
8110713Sandreas.hansson@arm.com    ide.BAR3LegacyIO = True
828922Swilliam.wang@arm.com    ide.BAR4 = 1
837053SN/A    ide.Command = 0
846899SN/A    ide.ProgIF = 0x80
857053SN/A    ide.InterruptLine = 14
867053SN/A    ide.InterruptPin = 1
879542Sandreas.hansson@arm.com
886899SN/A    def attachIO(self, bus):
8911025Snilay@cs.wisc.edu        # Route interupt signals
906899SN/A        self.int_lines = \
917053SN/A          [X86IntLine(source=self.pic1.output, sink=self.io_apic.pin(0)),
926899SN/A           X86IntLine(source=self.pic2.output, sink=self.pic1.pin(2)),
937053SN/A           X86IntLine(source=self.cmos.int_pin, sink=self.pic2.pin(0)),
947053SN/A           X86IntLine(source=self.pit.int_pin, sink=self.pic1.pin(0)),
957053SN/A           X86IntLine(source=self.pit.int_pin, sink=self.io_apic.pin(2)),
966899SN/A           X86IntLine(source=self.keyboard.keyboard_int_pin,
9713784Sgabeblack@google.com                      sink=self.io_apic.pin(1)),
9813784Sgabeblack@google.com           X86IntLine(source=self.keyboard.mouse_int_pin,
996899SN/A                      sink=self.io_apic.pin(12))]
10011266SBrad.Beckmann@amd.com        # Tell the devices about each other
10111266SBrad.Beckmann@amd.com        self.pic1.slave = self.pic2
1028950Sandreas.hansson@arm.com        self.speaker.i8254 = self.pit
1038932SBrad.Beckmann@amd.com        self.io_apic.external_int_pic = self.pic1
1048932SBrad.Beckmann@amd.com        # Connect to the bus
1056899SN/A        self.cmos.pio = bus.master
10613799SAndrea.Mondelli@ucf.edu        self.dma1.pio = bus.master
1076899SN/A        self.ide.pio = bus.master
1087053SN/A        self.ide.config = bus.master
1096899SN/A        self.ide.dma = bus.slave
1107053SN/A        self.keyboard.pio = bus.master
1116899SN/A        self.pic1.pio = bus.master
1127055SN/A        self.pic2.pio = bus.master
1137053SN/A        self.pit.pio = bus.master
1147055SN/A        self.speaker.pio = bus.master
1156899SN/A        self.io_apic.pio = bus.master
1167055SN/A        self.io_apic.int_master = bus.slave
1178184Ssomayeh@cs.wisc.edu