SouthBridge.py revision 8323
15390SN/A# Copyright (c) 2008 The Regents of The University of Michigan 25390SN/A# All rights reserved. 35390SN/A# 45390SN/A# Redistribution and use in source and binary forms, with or without 55390SN/A# modification, are permitted provided that the following conditions are 65390SN/A# met: redistributions of source code must retain the above copyright 75390SN/A# notice, this list of conditions and the following disclaimer; 85390SN/A# redistributions in binary form must reproduce the above copyright 95390SN/A# notice, this list of conditions and the following disclaimer in the 105390SN/A# documentation and/or other materials provided with the distribution; 115390SN/A# neither the name of the copyright holders nor the names of its 125390SN/A# contributors may be used to endorse or promote products derived from 135390SN/A# this software without specific prior written permission. 145390SN/A# 155390SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 165390SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 175390SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 185390SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 195390SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205390SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 215390SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 225390SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 235390SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 245390SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 255390SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265390SN/A# 275390SN/A# Authors: Gabe Black 285390SN/A 295390SN/Afrom m5.params import * 305390SN/Afrom m5.proxy import * 315636SN/Afrom Cmos import Cmos 325831Sgblack@eecs.umich.edufrom I8042 import I8042 335643Sgblack@eecs.umich.edufrom I82094AA import I82094AA 345818Sgblack@eecs.umich.edufrom I8237 import I8237 355636SN/Afrom I8254 import I8254 365636SN/Afrom I8259 import I8259 375833Sgblack@eecs.umich.edufrom Ide import IdeController 385636SN/Afrom PcSpeaker import PcSpeaker 395827Sgblack@eecs.umich.edufrom X86IntPin import X86IntLine 405636SN/Afrom m5.SimObject import SimObject 415390SN/A 425636SN/Adef x86IOAddress(port): 435636SN/A IO_address_space_base = 0x8000000000000000 445636SN/A return IO_address_space_base + port; 455636SN/A 465636SN/Aclass SouthBridge(SimObject): 475390SN/A type = 'SouthBridge' 485390SN/A pio_latency = Param.Latency('1ns', "Programmed IO latency in simticks") 495636SN/A platform = Param.Platform(Parent.any, "Platform this device is part of") 505636SN/A 515636SN/A _pic1 = I8259(pio_addr=x86IOAddress(0x20), mode='I8259Master') 525636SN/A _pic2 = I8259(pio_addr=x86IOAddress(0xA0), mode='I8259Slave') 535636SN/A _cmos = Cmos(pio_addr=x86IOAddress(0x70)) 545818Sgblack@eecs.umich.edu _dma1 = I8237(pio_addr=x86IOAddress(0x0)) 555831Sgblack@eecs.umich.edu _keyboard = I8042(data_port=x86IOAddress(0x60), \ 565831Sgblack@eecs.umich.edu command_port=x86IOAddress(0x64)) 575636SN/A _pit = I8254(pio_addr=x86IOAddress(0x40)) 585636SN/A _speaker = PcSpeaker(pio_addr=x86IOAddress(0x61)) 595643Sgblack@eecs.umich.edu _io_apic = I82094AA(pio_addr=0xFEC00000) 605636SN/A 615636SN/A pic1 = Param.I8259(_pic1, "Master PIC") 625636SN/A pic2 = Param.I8259(_pic2, "Slave PIC") 635636SN/A cmos = Param.Cmos(_cmos, "CMOS memory and real time clock device") 645818Sgblack@eecs.umich.edu dma1 = Param.I8237(_dma1, "The first dma controller") 655831Sgblack@eecs.umich.edu keyboard = Param.I8042(_keyboard, "The keyboard controller") 665636SN/A pit = Param.I8254(_pit, "Programmable interval timer") 675636SN/A speaker = Param.PcSpeaker(_speaker, "PC speaker") 685643Sgblack@eecs.umich.edu io_apic = Param.I82094AA(_io_apic, "I/O APIC") 695636SN/A 705833Sgblack@eecs.umich.edu # IDE controller 715833Sgblack@eecs.umich.edu ide = IdeController(disks=[], pci_func=0, pci_dev=4, pci_bus=0) 725833Sgblack@eecs.umich.edu ide.BAR0 = 0x1f0 735833Sgblack@eecs.umich.edu ide.BAR0LegacyIO = True 745833Sgblack@eecs.umich.edu ide.BAR1 = 0x3f4 755833Sgblack@eecs.umich.edu ide.BAR1Size = '3B' 765833Sgblack@eecs.umich.edu ide.BAR1LegacyIO = True 775833Sgblack@eecs.umich.edu ide.BAR2 = 0x170 785833Sgblack@eecs.umich.edu ide.BAR2LegacyIO = True 795833Sgblack@eecs.umich.edu ide.BAR3 = 0x374 805833Sgblack@eecs.umich.edu ide.BAR3Size = '3B' 815833Sgblack@eecs.umich.edu ide.BAR3LegacyIO = True 825833Sgblack@eecs.umich.edu ide.BAR4 = 1 836432Sgblack@eecs.umich.edu ide.Command = 0 846432Sgblack@eecs.umich.edu ide.ProgIF = 0x80 855843Sgblack@eecs.umich.edu ide.InterruptLine = 14 865843Sgblack@eecs.umich.edu ide.InterruptPin = 1 875833Sgblack@eecs.umich.edu 885636SN/A def attachIO(self, bus): 895827Sgblack@eecs.umich.edu # Route interupt signals 908323Ssteve.reinhardt@amd.com self.int_lines = \ 918323Ssteve.reinhardt@amd.com [X86IntLine(source=self.pic1.output, sink=self.io_apic.pin(0)), 928323Ssteve.reinhardt@amd.com X86IntLine(source=self.pic2.output, sink=self.pic1.pin(2)), 938323Ssteve.reinhardt@amd.com X86IntLine(source=self.cmos.int_pin, sink=self.pic2.pin(0)), 948323Ssteve.reinhardt@amd.com X86IntLine(source=self.pit.int_pin, sink=self.pic1.pin(0)), 958323Ssteve.reinhardt@amd.com X86IntLine(source=self.pit.int_pin, sink=self.io_apic.pin(2)), 968323Ssteve.reinhardt@amd.com X86IntLine(source=self.keyboard.keyboard_int_pin, 978323Ssteve.reinhardt@amd.com sink=self.io_apic.pin(1)), 988323Ssteve.reinhardt@amd.com X86IntLine(source=self.keyboard.mouse_int_pin, 998323Ssteve.reinhardt@amd.com sink=self.io_apic.pin(12))] 1005827Sgblack@eecs.umich.edu # Tell the devices about each other 1015827Sgblack@eecs.umich.edu self.pic1.slave = self.pic2 1025636SN/A self.speaker.i8254 = self.pit 1035827Sgblack@eecs.umich.edu self.io_apic.external_int_pic = self.pic1 1045636SN/A # Connect to the bus 1055636SN/A self.cmos.pio = bus.port 1065818Sgblack@eecs.umich.edu self.dma1.pio = bus.port 1075833Sgblack@eecs.umich.edu self.ide.pio = bus.port 1085831Sgblack@eecs.umich.edu self.keyboard.pio = bus.port 1095636SN/A self.pic1.pio = bus.port 1105636SN/A self.pic2.pio = bus.port 1115636SN/A self.pit.pio = bus.port 1125636SN/A self.speaker.pio = bus.port 1135643Sgblack@eecs.umich.edu self.io_apic.pio = bus.port 1145651Sgblack@eecs.umich.edu self.io_apic.int_port = bus.port 115