system.cc revision 6378
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" 365222Sksewell@umich.edu#include "base/remote_gdb.hh" 375222Sksewell@umich.edu#include "base/loader/object_file.hh" 385222Sksewell@umich.edu#include "base/loader/hex_file.hh" 395222Sksewell@umich.edu#include "base/loader/symtab.hh" 405222Sksewell@umich.edu#include "base/trace.hh" 415222Sksewell@umich.edu#include "mem/physical.hh" 425222Sksewell@umich.edu#include "params/MipsSystem.hh" 435222Sksewell@umich.edu#include "sim/byteswap.hh" 445222Sksewell@umich.edu 455222Sksewell@umich.edu 465222Sksewell@umich.eduusing namespace LittleEndianGuest; 475222Sksewell@umich.edu 486378Sgblack@eecs.umich.eduMipsSystem::MipsSystem(Params *p) : System(p) 495222Sksewell@umich.edu{ 505222Sksewell@umich.edu 515222Sksewell@umich.edu#if FULL_SYSTEM 525222Sksewell@umich.edu if (p->bare_iron == true) { 535222Sksewell@umich.edu hexFile = new HexFile(params()->hex_file_name); 546378Sgblack@eecs.umich.edu if (!hexFile->loadSections(&functionalPort, MipsISA::LoadAddrMask)) 555222Sksewell@umich.edu panic("Could not load hex file\n"); 565222Sksewell@umich.edu } 575222Sksewell@umich.edu 585222Sksewell@umich.edu Addr addr = 0; 595222Sksewell@umich.edu 605222Sksewell@umich.edu consoleSymtab = new SymbolTable; 615222Sksewell@umich.edu 625222Sksewell@umich.edu 635222Sksewell@umich.edu /** 645222Sksewell@umich.edu * Load the console code into memory 655222Sksewell@umich.edu */ 665222Sksewell@umich.edu // Load Console Code 675222Sksewell@umich.edu console = createObjectFile(params()->console); 685222Sksewell@umich.edu 695222Sksewell@umich.edu warn("console code is located at: %s\n", params()->console); 705222Sksewell@umich.edu 715222Sksewell@umich.edu if (console == NULL) 725222Sksewell@umich.edu fatal("Could not load console file %s", params()->console); 735222Sksewell@umich.edu //Load program sections into memory 746378Sgblack@eecs.umich.edu console->loadSections(&functionalPort, MipsISA::LoadAddrMask); 755222Sksewell@umich.edu 765222Sksewell@umich.edu //load symbols 775222Sksewell@umich.edu if (!console->loadGlobalSymbols(consoleSymtab)) 785222Sksewell@umich.edu panic("could not load console symbols\n"); 795222Sksewell@umich.edu 805222Sksewell@umich.edu if (!console->loadGlobalSymbols(debugSymbolTable)) 815222Sksewell@umich.edu panic("could not load console symbols\n"); 825222Sksewell@umich.edu 835222Sksewell@umich.edu 845222Sksewell@umich.edu#ifndef NDEBUG 855222Sksewell@umich.edu consolePanicEvent = addConsoleFuncEvent<BreakPCEvent>("panic"); 865222Sksewell@umich.edu#endif 875222Sksewell@umich.edu 885222Sksewell@umich.edu /** 895222Sksewell@umich.edu * Copy the osflags (kernel arguments) into the consoles 905222Sksewell@umich.edu * memory. (Presently Linux does not use the console service 915222Sksewell@umich.edu * routine to get these command line arguments, but Tru64 and 925222Sksewell@umich.edu * others do.) 935222Sksewell@umich.edu */ 945222Sksewell@umich.edu if (consoleSymtab->findAddress("env_booted_osflags", addr)) { 955222Sksewell@umich.edu warn("writing addr starting from %#x", addr); 965222Sksewell@umich.edu cout << "-" << endl; 975222Sksewell@umich.edu virtPort.writeBlob(addr, (uint8_t*)params()->boot_osflags.c_str(), 985222Sksewell@umich.edu strlen(params()->boot_osflags.c_str())); 995222Sksewell@umich.edu } 1005222Sksewell@umich.edu 1015222Sksewell@umich.edu /** 1025222Sksewell@umich.edu * Set the hardware reset parameter block system type and revision 1035222Sksewell@umich.edu * information to Tsunami. 1045222Sksewell@umich.edu */ 1055222Sksewell@umich.edu if (consoleSymtab->findAddress("m5_rpb", addr)) { 1065222Sksewell@umich.edu uint64_t data; 1075222Sksewell@umich.edu data = htog(params()->system_type); 1086378Sgblack@eecs.umich.edu virtPort.write(addr + 0x50, data); 1095222Sksewell@umich.edu data = htog(params()->system_rev); 1106378Sgblack@eecs.umich.edu virtPort.write(addr + 0x58, data); 1116378Sgblack@eecs.umich.edu } else { 1125222Sksewell@umich.edu panic("could not find hwrpb\n"); 1136378Sgblack@eecs.umich.edu } 1145222Sksewell@umich.edu#endif 1155222Sksewell@umich.edu} 1165222Sksewell@umich.edu 1175222Sksewell@umich.eduMipsSystem::~MipsSystem() 1185222Sksewell@umich.edu{ 1195222Sksewell@umich.edu} 1206378Sgblack@eecs.umich.edu 1215222Sksewell@umich.edu#if FULL_SYSTEM 1225222Sksewell@umich.eduAddr 1235222Sksewell@umich.eduMipsSystem::fixFuncEventAddr(Addr addr) 1245222Sksewell@umich.edu{ 1256378Sgblack@eecs.umich.edu return addr; 1265222Sksewell@umich.edu} 1275222Sksewell@umich.edu 1285222Sksewell@umich.eduvoid 1295222Sksewell@umich.eduMipsSystem::setMipsAccess(Addr access) 1306378Sgblack@eecs.umich.edu{} 1315222Sksewell@umich.edu 1325222Sksewell@umich.edu#endif 1335222Sksewell@umich.edu 1345222Sksewell@umich.edubool 1355222Sksewell@umich.eduMipsSystem::breakpoint() 1365222Sksewell@umich.edu{ 1376378Sgblack@eecs.umich.edu return 0; 1385222Sksewell@umich.edu} 1395222Sksewell@umich.edu 1405222Sksewell@umich.eduvoid 1415222Sksewell@umich.eduMipsSystem::serialize(std::ostream &os) 1425222Sksewell@umich.edu{ 1435222Sksewell@umich.edu System::serialize(os); 1445222Sksewell@umich.edu} 1455222Sksewell@umich.edu 1465222Sksewell@umich.edu 1475222Sksewell@umich.eduvoid 1485222Sksewell@umich.eduMipsSystem::unserialize(Checkpoint *cp, const std::string §ion) 1495222Sksewell@umich.edu{ 1505222Sksewell@umich.edu System::unserialize(cp,section); 1515222Sksewell@umich.edu} 1525222Sksewell@umich.edu 1535222Sksewell@umich.eduMipsSystem * 1545222Sksewell@umich.eduMipsSystemParams::create() 1555222Sksewell@umich.edu{ 1565222Sksewell@umich.edu return new MipsSystem(this); 1575222Sksewell@umich.edu} 1585222Sksewell@umich.edu 159