pc.cc revision 5446
15389Sgblack@eecs.umich.edu/* 25446Sgblack@eecs.umich.edu * Copyright (c) 2008 The Regents of The University of Michigan 35389Sgblack@eecs.umich.edu * All rights reserved. 45389Sgblack@eecs.umich.edu * 55389Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 65389Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 75389Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 85389Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 95389Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 105389Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 115389Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 125389Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 135389Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 145389Sgblack@eecs.umich.edu * this software without specific prior written permission. 155389Sgblack@eecs.umich.edu * 165389Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175389Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185389Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195389Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205389Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215389Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225389Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235389Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245389Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255389Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265389Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275389Sgblack@eecs.umich.edu * 285389Sgblack@eecs.umich.edu * Authors: Gabe Black 295389Sgblack@eecs.umich.edu */ 305389Sgblack@eecs.umich.edu 315389Sgblack@eecs.umich.edu/** @file 325389Sgblack@eecs.umich.edu * Implementation of PC platform. 335389Sgblack@eecs.umich.edu */ 345389Sgblack@eecs.umich.edu 355389Sgblack@eecs.umich.edu#include <deque> 365389Sgblack@eecs.umich.edu#include <string> 375389Sgblack@eecs.umich.edu#include <vector> 385389Sgblack@eecs.umich.edu 395389Sgblack@eecs.umich.edu#include "arch/x86/x86_traits.hh" 405446Sgblack@eecs.umich.edu#include "dev/intel_8254_timer.hh" 415389Sgblack@eecs.umich.edu#include "cpu/intr_control.hh" 425389Sgblack@eecs.umich.edu#include "dev/simconsole.hh" 435389Sgblack@eecs.umich.edu#include "dev/x86/pc.hh" 445389Sgblack@eecs.umich.edu#include "sim/system.hh" 455389Sgblack@eecs.umich.edu 465389Sgblack@eecs.umich.eduusing namespace std; 475389Sgblack@eecs.umich.eduusing namespace TheISA; 485389Sgblack@eecs.umich.edu 495389Sgblack@eecs.umich.eduPC::PC(const Params *p) 505389Sgblack@eecs.umich.edu : Platform(p), system(p->system) 515389Sgblack@eecs.umich.edu{ 525446Sgblack@eecs.umich.edu southBridge = NULL; 535389Sgblack@eecs.umich.edu // set the back pointer from the system to myself 545389Sgblack@eecs.umich.edu system->platform = this; 555389Sgblack@eecs.umich.edu} 565389Sgblack@eecs.umich.edu 575446Sgblack@eecs.umich.eduvoid 585446Sgblack@eecs.umich.eduPC::init() 595446Sgblack@eecs.umich.edu{ 605446Sgblack@eecs.umich.edu assert(southBridge); 615446Sgblack@eecs.umich.edu Intel8254Timer & timer = southBridge->pit.pit; 625446Sgblack@eecs.umich.edu //Timer 0, mode 2, no bcd, 16 bit count 635446Sgblack@eecs.umich.edu timer.writeControl(0x34); 645446Sgblack@eecs.umich.edu //Timer 0, latch command 655446Sgblack@eecs.umich.edu timer.writeControl(0x00); 665446Sgblack@eecs.umich.edu //Write a 16 bit count of 0 675446Sgblack@eecs.umich.edu timer.counter0.write(0); 685446Sgblack@eecs.umich.edu timer.counter0.write(0); 695446Sgblack@eecs.umich.edu} 705446Sgblack@eecs.umich.edu 715389Sgblack@eecs.umich.eduTick 725389Sgblack@eecs.umich.eduPC::intrFrequency() 735389Sgblack@eecs.umich.edu{ 745389Sgblack@eecs.umich.edu panic("Need implementation\n"); 755389Sgblack@eecs.umich.edu M5_DUMMY_RETURN 765389Sgblack@eecs.umich.edu} 775389Sgblack@eecs.umich.edu 785389Sgblack@eecs.umich.eduvoid 795389Sgblack@eecs.umich.eduPC::postConsoleInt() 805389Sgblack@eecs.umich.edu{ 815389Sgblack@eecs.umich.edu warn_once("Don't know what interrupt to post for console.\n"); 825389Sgblack@eecs.umich.edu //panic("Need implementation\n"); 835389Sgblack@eecs.umich.edu} 845389Sgblack@eecs.umich.edu 855389Sgblack@eecs.umich.eduvoid 865389Sgblack@eecs.umich.eduPC::clearConsoleInt() 875389Sgblack@eecs.umich.edu{ 885389Sgblack@eecs.umich.edu warn_once("Don't know what interrupt to clear for console.\n"); 895389Sgblack@eecs.umich.edu //panic("Need implementation\n"); 905389Sgblack@eecs.umich.edu} 915389Sgblack@eecs.umich.edu 925389Sgblack@eecs.umich.eduvoid 935389Sgblack@eecs.umich.eduPC::postPciInt(int line) 945389Sgblack@eecs.umich.edu{ 955389Sgblack@eecs.umich.edu panic("Need implementation\n"); 965389Sgblack@eecs.umich.edu} 975389Sgblack@eecs.umich.edu 985389Sgblack@eecs.umich.eduvoid 995389Sgblack@eecs.umich.eduPC::clearPciInt(int line) 1005389Sgblack@eecs.umich.edu{ 1015389Sgblack@eecs.umich.edu panic("Need implementation\n"); 1025389Sgblack@eecs.umich.edu} 1035389Sgblack@eecs.umich.edu 1045389Sgblack@eecs.umich.eduAddr 1055389Sgblack@eecs.umich.eduPC::pciToDma(Addr pciAddr) const 1065389Sgblack@eecs.umich.edu{ 1075389Sgblack@eecs.umich.edu panic("Need implementation\n"); 1085389Sgblack@eecs.umich.edu M5_DUMMY_RETURN 1095389Sgblack@eecs.umich.edu} 1105389Sgblack@eecs.umich.edu 1115389Sgblack@eecs.umich.edu 1125389Sgblack@eecs.umich.eduAddr 1135389Sgblack@eecs.umich.eduPC::calcConfigAddr(int bus, int dev, int func) 1145389Sgblack@eecs.umich.edu{ 1155389Sgblack@eecs.umich.edu assert(func < 8); 1165389Sgblack@eecs.umich.edu assert(dev < 32); 1175389Sgblack@eecs.umich.edu assert(bus == 0); 1185389Sgblack@eecs.umich.edu return (PhysAddrPrefixPciConfig | (func << 8) | (dev << 11)); 1195389Sgblack@eecs.umich.edu} 1205389Sgblack@eecs.umich.edu 1215389Sgblack@eecs.umich.eduPC * 1225389Sgblack@eecs.umich.eduPCParams::create() 1235389Sgblack@eecs.umich.edu{ 1245389Sgblack@eecs.umich.edu return new PC(this); 1255389Sgblack@eecs.umich.edu} 126