system.cc revision 8232
15222Sksewell@umich.edu/* 25268Sksewell@umich.edu * Copyright (c) 2002-2005 The Regents of The University of Michigan 35254Sksewell@umich.edu * Copyright (c) 2007 MIPS Technologies, Inc. 45254Sksewell@umich.edu * All rights reserved. 55222Sksewell@umich.edu * 65254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 75254Sksewell@umich.edu * modification, are permitted provided that the following conditions are 85254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 95254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 105254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 115254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 125254Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 135254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 145254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 155254Sksewell@umich.edu * this software without specific prior written permission. 165222Sksewell@umich.edu * 175254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 185254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 195254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 205254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 215254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 225254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 235254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 245254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 275254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 285222Sksewell@umich.edu * 295254Sksewell@umich.edu * Authors: Ali Saidi 305254Sksewell@umich.edu * Nathan Binkert 315222Sksewell@umich.edu * Jaidev Patwardhan 325222Sksewell@umich.edu */ 335222Sksewell@umich.edu 345222Sksewell@umich.edu#include "arch/mips/system.hh" 355222Sksewell@umich.edu#include "arch/vtophys.hh" 368229Snate@binkert.org#include "base/loader/hex_file.hh" 375222Sksewell@umich.edu#include "base/loader/object_file.hh" 385222Sksewell@umich.edu#include "base/loader/symtab.hh" 395222Sksewell@umich.edu#include "base/trace.hh" 405222Sksewell@umich.edu#include "mem/physical.hh" 415222Sksewell@umich.edu#include "params/MipsSystem.hh" 425222Sksewell@umich.edu#include "sim/byteswap.hh" 435222Sksewell@umich.edu 445222Sksewell@umich.eduusing namespace LittleEndianGuest; 455222Sksewell@umich.edu 466378Sgblack@eecs.umich.eduMipsSystem::MipsSystem(Params *p) : System(p) 475222Sksewell@umich.edu{ 485222Sksewell@umich.edu 495222Sksewell@umich.edu#if FULL_SYSTEM 505222Sksewell@umich.edu if (p->bare_iron == true) { 515222Sksewell@umich.edu hexFile = new HexFile(params()->hex_file_name); 525222Sksewell@umich.edu if (!hexFile->loadSections(functionalPort)) 536378Sgblack@eecs.umich.edu panic("Could not load hex file\n"); 545222Sksewell@umich.edu } 555222Sksewell@umich.edu 565222Sksewell@umich.edu Addr addr = 0; 576378Sgblack@eecs.umich.edu 585222Sksewell@umich.edu consoleSymtab = new SymbolTable; 595222Sksewell@umich.edu 605222Sksewell@umich.edu 615222Sksewell@umich.edu /** 626378Sgblack@eecs.umich.edu * Load the console code into memory 635222Sksewell@umich.edu */ 645222Sksewell@umich.edu // Load Console Code 655222Sksewell@umich.edu console = createObjectFile(params()->console); 665222Sksewell@umich.edu 676378Sgblack@eecs.umich.edu warn("console code is located at: %s\n", params()->console); 685222Sksewell@umich.edu 695222Sksewell@umich.edu if (console == NULL) 705222Sksewell@umich.edu fatal("Could not load console file %s", params()->console); 715222Sksewell@umich.edu //Load program sections into memory 725222Sksewell@umich.edu console->loadSections(functionalPort, loadAddrMask); 735222Sksewell@umich.edu 745222Sksewell@umich.edu //load symbols 755222Sksewell@umich.edu if (!console->loadGlobalSymbols(consoleSymtab)) 76 panic("could not load console symbols\n"); 77 78 if (!console->loadGlobalSymbols(debugSymbolTable)) 79 panic("could not load console symbols\n"); 80 81 82#ifndef NDEBUG 83 consolePanicEvent = addConsoleFuncEvent<BreakPCEvent>("panic"); 84#endif 85 86 /** 87 * Copy the osflags (kernel arguments) into the consoles 88 * memory. (Presently Linux does not use the console service 89 * routine to get these command line arguments, but Tru64 and 90 * others do.) 91 */ 92 if (consoleSymtab->findAddress("env_booted_osflags", addr)) { 93 warn("writing addr starting from %#x", addr); 94 virtPort->writeBlob(addr, (uint8_t*)params()->boot_osflags.c_str(), 95 strlen(params()->boot_osflags.c_str())); 96 } 97 98 /** 99 * Set the hardware reset parameter block system type and revision 100 * information to Tsunami. 101 */ 102 if (consoleSymtab->findAddress("m5_rpb", addr)) { 103 uint64_t data; 104 data = htog(params()->system_type); 105 virtPort->write(addr + 0x50, data); 106 data = htog(params()->system_rev); 107 virtPort->write(addr + 0x58, data); 108 } else { 109 panic("could not find hwrpb\n"); 110 } 111#endif 112} 113 114MipsSystem::~MipsSystem() 115{ 116} 117 118#if FULL_SYSTEM 119Addr 120MipsSystem::fixFuncEventAddr(Addr addr) 121{ 122 return addr; 123} 124 125void 126MipsSystem::setMipsAccess(Addr access) 127{} 128 129#endif 130 131bool 132MipsSystem::breakpoint() 133{ 134 return 0; 135} 136 137void 138MipsSystem::serialize(std::ostream &os) 139{ 140 System::serialize(os); 141} 142 143 144void 145MipsSystem::unserialize(Checkpoint *cp, const std::string §ion) 146{ 147 System::unserialize(cp,section); 148} 149 150MipsSystem * 151MipsSystemParams::create() 152{ 153 return new MipsSystem(this); 154} 155 156