pc.cc revision 5643:2b1611137af4
112952Sgabeblack@google.com/*
212952Sgabeblack@google.com * Copyright (c) 2008 The Regents of The University of Michigan
312952Sgabeblack@google.com * All rights reserved.
412952Sgabeblack@google.com *
512952Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
612952Sgabeblack@google.com * modification, are permitted provided that the following conditions are
712952Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
812952Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
912952Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1012952Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1112952Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1212952Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1312952Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1412952Sgabeblack@google.com * this software without specific prior written permission.
1512952Sgabeblack@google.com *
1612952Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712952Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812952Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912952Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012952Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112952Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212952Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312952Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412952Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512952Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612952Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712952Sgabeblack@google.com *
2812952Sgabeblack@google.com * Authors: Gabe Black
2912952Sgabeblack@google.com */
3012952Sgabeblack@google.com
3112957Sgabeblack@google.com/** @file
3212957Sgabeblack@google.com * Implementation of PC platform.
3312957Sgabeblack@google.com */
3413288Sgabeblack@google.com
3512953Sgabeblack@google.com#include <deque>
3613317Sgabeblack@google.com#include <string>
3713196Sgabeblack@google.com#include <vector>
3813102Sgabeblack@google.com
3912998Sgabeblack@google.com#include "arch/x86/x86_traits.hh"
4012998Sgabeblack@google.com#include "cpu/intr_control.hh"
4112952Sgabeblack@google.com#include "dev/terminal.hh"
4212952Sgabeblack@google.com#include "dev/x86/i82094aa.hh"
4312952Sgabeblack@google.com#include "dev/x86/i8254.hh"
4412952Sgabeblack@google.com#include "dev/x86/pc.hh"
4512952Sgabeblack@google.com#include "dev/x86/south_bridge.hh"
4612952Sgabeblack@google.com#include "sim/system.hh"
4712952Sgabeblack@google.com
4812995Sgabeblack@google.comusing namespace std;
4912952Sgabeblack@google.comusing namespace TheISA;
5012952Sgabeblack@google.com
5112952Sgabeblack@google.comPc::Pc(const Params *p)
5212952Sgabeblack@google.com    : Platform(p), system(p->system)
5312952Sgabeblack@google.com{
5412995Sgabeblack@google.com    southBridge = NULL;
5512952Sgabeblack@google.com    // set the back pointer from the system to myself
5612952Sgabeblack@google.com    system->platform = this;
5712952Sgabeblack@google.com}
5812952Sgabeblack@google.com
5912952Sgabeblack@google.comvoid
6012952Sgabeblack@google.comPc::init()
6112952Sgabeblack@google.com{
6212952Sgabeblack@google.com    assert(southBridge);
6312952Sgabeblack@google.com
6412952Sgabeblack@google.com    /*
6512952Sgabeblack@google.com     * Initialize the timer.
6612952Sgabeblack@google.com     */
6712952Sgabeblack@google.com    I8254 & timer = *southBridge->pit;
6812952Sgabeblack@google.com    //Timer 0, mode 2, no bcd, 16 bit count
6912952Sgabeblack@google.com    timer.writeControl(0x34);
7012952Sgabeblack@google.com    //Timer 0, latch command
7112952Sgabeblack@google.com    timer.writeControl(0x00);
7212952Sgabeblack@google.com    //Write a 16 bit count of 0
7312952Sgabeblack@google.com    timer.writeCounter(0, 0);
7412952Sgabeblack@google.com    timer.writeCounter(0, 0);
7512952Sgabeblack@google.com
7612952Sgabeblack@google.com    /*
7712952Sgabeblack@google.com     * Initialize the I/O APIC.
7812952Sgabeblack@google.com     */
7912952Sgabeblack@google.com    I82094AA & ioApic = *southBridge->ioApic;
8012952Sgabeblack@google.com    I82094AA::RedirTableEntry entry = 0;
8112952Sgabeblack@google.com    entry.deliveryMode = 0x7;
8212952Sgabeblack@google.com    entry.vector = 0x20;
8312952Sgabeblack@google.com    ioApic.writeReg(0x10, entry.bottomDW);
8412952Sgabeblack@google.com    ioApic.writeReg(0x11, entry.topDW);
8512952Sgabeblack@google.com}
8612952Sgabeblack@google.com
8713133Sgabeblack@google.comTick
8812952Sgabeblack@google.comPc::intrFrequency()
8913133Sgabeblack@google.com{
9013133Sgabeblack@google.com    panic("Need implementation\n");
9113133Sgabeblack@google.com    M5_DUMMY_RETURN
9213133Sgabeblack@google.com}
9313133Sgabeblack@google.com
9413133Sgabeblack@google.comvoid
9513133Sgabeblack@google.comPc::postConsoleInt()
9613133Sgabeblack@google.com{
9712952Sgabeblack@google.com    warn_once("Don't know what interrupt to post for console.\n");
9812952Sgabeblack@google.com    //panic("Need implementation\n");
9912952Sgabeblack@google.com}
10012952Sgabeblack@google.com
10112952Sgabeblack@google.comvoid
10212952Sgabeblack@google.comPc::clearConsoleInt()
10312952Sgabeblack@google.com{
10412952Sgabeblack@google.com    warn_once("Don't know what interrupt to clear for console.\n");
10512952Sgabeblack@google.com    //panic("Need implementation\n");
10612952Sgabeblack@google.com}
10712952Sgabeblack@google.com
10812959Sgabeblack@google.comvoid
10913133Sgabeblack@google.comPc::postPciInt(int line)
11012959Sgabeblack@google.com{
11112952Sgabeblack@google.com    panic("Need implementation\n");
11212952Sgabeblack@google.com}
11312952Sgabeblack@google.com
11412952Sgabeblack@google.comvoid
11512952Sgabeblack@google.comPc::clearPciInt(int line)
11612952Sgabeblack@google.com{
11712952Sgabeblack@google.com    panic("Need implementation\n");
11812952Sgabeblack@google.com}
11912952Sgabeblack@google.com
12012999Sgabeblack@google.comAddr
12113206Sgabeblack@google.comPc::pciToDma(Addr pciAddr) const
12212999Sgabeblack@google.com{
12312999Sgabeblack@google.com    panic("Need implementation\n");
12413317Sgabeblack@google.com    M5_DUMMY_RETURN
12512999Sgabeblack@google.com}
12612999Sgabeblack@google.com
12712999Sgabeblack@google.com
12812952Sgabeblack@google.comAddr
12912952Sgabeblack@google.comPc::calcConfigAddr(int bus, int dev, int func)
13012952Sgabeblack@google.com{
13112952Sgabeblack@google.com    assert(func < 8);
13212952Sgabeblack@google.com    assert(dev < 32);
13312952Sgabeblack@google.com    assert(bus == 0);
13412952Sgabeblack@google.com    return (PhysAddrPrefixPciConfig | (func << 8) | (dev << 11));
13512952Sgabeblack@google.com}
13612952Sgabeblack@google.com
13712952Sgabeblack@google.comPc *
13812952Sgabeblack@google.comPcParams::create()
13912952Sgabeblack@google.com{
14012952Sgabeblack@google.com    return new Pc(this);
14112952Sgabeblack@google.com}
14212952Sgabeblack@google.com