system.cc revision 8870:f95c4042f2d0
12SN/A/* 22188SN/A * Copyright (c) 2010 ARM Limited 32SN/A * All rights reserved 42SN/A * 52SN/A * The license below extends only to copyright in the software and shall 62SN/A * not be construed as granting a license to any other intellectual 72SN/A * property including but not limited to intellectual property relating 82SN/A * to a hardware implementation of the functionality of the software 92SN/A * licensed hereunder. You may use the software subject to the license 102SN/A * terms below provided that you ensure that this notice is replicated 112SN/A * unmodified and in its entirety in all distributions of the software, 122SN/A * modified or unmodified, in source code or in binary form. 132SN/A * 142SN/A * Copyright (c) 2002-2006 The Regents of The University of Michigan 152SN/A * All rights reserved. 162SN/A * 172SN/A * Redistribution and use in source and binary forms, with or without 182SN/A * modification, are permitted provided that the following conditions are 192SN/A * met: redistributions of source code must retain the above copyright 202SN/A * notice, this list of conditions and the following disclaimer; 212SN/A * redistributions in binary form must reproduce the above copyright 222SN/A * notice, this list of conditions and the following disclaimer in the 232SN/A * documentation and/or other materials provided with the distribution; 242SN/A * neither the name of the copyright holders nor the names of its 252SN/A * contributors may be used to endorse or promote products derived from 262SN/A * this software without specific prior written permission. 272665SN/A * 282665SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 292665SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322683Sktlim@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 332683Sktlim@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 342SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 356313Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362190SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 376329Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 384997Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 396316Sgblack@eecs.umich.edu * 406216Snate@binkert.org * Authors: Ali Saidi 411858SN/A */ 426658Snate@binkert.org 438541Sgblack@eecs.umich.edu#include "arch/arm/linux/atag.hh" 442680SN/A#include "arch/arm/linux/system.hh" 452683Sktlim@umich.edu#include "arch/arm/isa_traits.hh" 468232Snate@binkert.org#include "arch/arm/utility.hh" 478232Snate@binkert.org#include "base/loader/object_file.hh" 488777Sgblack@eecs.umich.edu#include "base/loader/symtab.hh" 492395SN/A#include "cpu/thread_context.hh" 502190SN/A#include "debug/Loader.hh" 512188SN/A#include "kern/linux/events.hh" 528777Sgblack@eecs.umich.edu#include "mem/fs_translating_port_proxy.hh" 53217SN/A#include "mem/physical.hh" 548777Sgblack@eecs.umich.edu 552SN/Ausing namespace ArmISA; 562SN/Ausing namespace Linux; 572SN/A 581070SN/ALinuxArmSystem::LinuxArmSystem(Params *p) 591917SN/A : ArmSystem(p) 601917SN/A{ 612521SN/A} 622521SN/A 638777Sgblack@eecs.umich.edubool 642521SN/ALinuxArmSystem::adderBootUncacheable(Addr a) 653548Sgblack@eecs.umich.edu{ 663548Sgblack@eecs.umich.edu Addr block = a & ~ULL(0x7F); 673548Sgblack@eecs.umich.edu if (block == secDataPtrAddr || block == secDataAddr || 683548Sgblack@eecs.umich.edu block == penReleaseAddr) 692330SN/A return true; 702330SN/A return false; 712683Sktlim@umich.edu} 722683Sktlim@umich.edu 732683Sktlim@umich.eduvoid 742683Sktlim@umich.eduLinuxArmSystem::initState() 752683Sktlim@umich.edu{ 762683Sktlim@umich.edu // Moved from the constructor to here since it relies on the 772683Sktlim@umich.edu // address map being resolved in the interconnect 782683Sktlim@umich.edu 792683Sktlim@umich.edu // Call the initialisation of the super class 802683Sktlim@umich.edu ArmSystem::initState(); 812683Sktlim@umich.edu 822683Sktlim@umich.edu // Load symbols at physical address, we might not want 832683Sktlim@umich.edu // to do this perminately, for but early bootup work 842683Sktlim@umich.edu // it is helpfulp. 852683Sktlim@umich.edu kernel->loadGlobalSymbols(kernelSymtab, loadAddrMask); 862SN/A kernel->loadGlobalSymbols(debugSymbolTable, loadAddrMask); 872683Sktlim@umich.edu 882SN/A // Setup boot data structure 892107SN/A AtagCore *ac = new AtagCore; 902107SN/A ac->flags(1); // read-only 912159SN/A ac->pagesize(8192); 922455SN/A ac->rootdev(0); 932455SN/A 942SN/A AtagMem *am = new AtagMem; 952680SN/A am->memSize(params()->physmem->size()); 962SN/A am->memStart(params()->physmem->start()); 972190SN/A 986315Sgblack@eecs.umich.edu AtagCmdline *ad = new AtagCmdline; 996315Sgblack@eecs.umich.edu ad->cmdline(params()->boot_osflags); 1006315Sgblack@eecs.umich.edu 1016315Sgblack@eecs.umich.edu DPRINTF(Loader, "boot command line %d bytes: %s\n", ad->size() <<2, params()->boot_osflags.c_str()); 1026316Sgblack@eecs.umich.edu 1036313Sgblack@eecs.umich.edu AtagNone *an = new AtagNone; 1042SN/A 1057720Sgblack@eecs.umich.edu uint32_t size = ac->size() + am->size() + ad->size() + an->size(); 1066324Sgblack@eecs.umich.edu uint32_t offset = 0; 1077597Sminkyu.jeong@arm.com uint8_t *boot_data = new uint8_t[size << 2]; 1087597Sminkyu.jeong@arm.com 1097597Sminkyu.jeong@arm.com offset += ac->copyOut(boot_data + offset); 1102190SN/A offset += am->copyOut(boot_data + offset); 1118357Sksewell@umich.edu offset += ad->copyOut(boot_data + offset); 1128357Sksewell@umich.edu offset += an->copyOut(boot_data + offset); 1138357Sksewell@umich.edu 1148357Sksewell@umich.edu DPRINTF(Loader, "Boot atags was %d bytes in total\n", size << 2); 1158357Sksewell@umich.edu DDUMP(Loader, boot_data, size << 2); 1162683Sktlim@umich.edu 1172SN/A physProxy.writeBlob(params()->atags_addr, boot_data, size << 2); 1182SN/A 1192683Sktlim@umich.edu#ifndef NDEBUG 1202188SN/A kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic"); 1212378SN/A if (!kernelPanicEvent) 1222400SN/A panic("could not find kernel symbol \'panic\'"); 1236022Sgblack@eecs.umich.edu#endif 1246022Sgblack@eecs.umich.edu 1252SN/A // With ARM udelay() is #defined to __udelay 1268541Sgblack@eecs.umich.edu Addr addr = 0; 1278541Sgblack@eecs.umich.edu if (kernelSymtab->findAddress("__udelay", addr)) { 1282683Sktlim@umich.edu uDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__udelay", 1298793Sgblack@eecs.umich.edu fixFuncEventAddr(addr), 1000, 0); 1302683Sktlim@umich.edu } else { 1316022Sgblack@eecs.umich.edu panic("couldn't find kernel symbol \'udelay\'"); 1322683Sktlim@umich.edu } 1338793Sgblack@eecs.umich.edu 1344997Sgblack@eecs.umich.edu // constant arguments to udelay() have some precomputation done ahead of 1356331Sgblack@eecs.umich.edu // time. Constant comes from code. 1362862Sktlim@umich.edu if (kernelSymtab->findAddress("__const_udelay", addr)) { 1372864Sktlim@umich.edu constUDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__const_udelay", 1382862Sktlim@umich.edu fixFuncEventAddr(addr), 1000, 107374); 1392683Sktlim@umich.edu } else { 1402SN/A panic("couldn't find kernel symbol \'udelay\'"); 1412680SN/A } 142180SN/A 1432SN/A secDataPtrAddr = 0; 1442SN/A secDataAddr = 0; 1452864Sktlim@umich.edu penReleaseAddr = 0; 1462864Sktlim@umich.edu kernelSymtab->findAddress("__secondary_data", secDataPtrAddr); 1472862Sktlim@umich.edu kernelSymtab->findAddress("secondary_data", secDataAddr); 1482862Sktlim@umich.edu kernelSymtab->findAddress("pen_release", penReleaseAddr); 149217SN/A 150237SN/A secDataPtrAddr &= ~ULL(0x7F); 151217SN/A secDataAddr &= ~ULL(0x7F); 1522683Sktlim@umich.edu penReleaseAddr &= ~ULL(0x7F); 1532683Sktlim@umich.edu 1545891Sgblack@eecs.umich.edu for (int i = 0; i < threadContexts.size(); i++) { 1552683Sktlim@umich.edu threadContexts[i]->setIntReg(0, 0); 1562190SN/A threadContexts[i]->setIntReg(1, params()->machine_type); 1572683Sktlim@umich.edu threadContexts[i]->setIntReg(2, params()->atags_addr); 1582683Sktlim@umich.edu } 1592683Sktlim@umich.edu} 1602683Sktlim@umich.edu 1612680SN/ALinuxArmSystem::~LinuxArmSystem() 1622190SN/A{ 1635358Sgblack@eecs.umich.edu if (uDelaySkipEvent) 1645358Sgblack@eecs.umich.edu delete uDelaySkipEvent; 1655358Sgblack@eecs.umich.edu if (constUDelaySkipEvent) 1665358Sgblack@eecs.umich.edu delete constUDelaySkipEvent; 1675358Sgblack@eecs.umich.edu} 1685358Sgblack@eecs.umich.edu 1695358Sgblack@eecs.umich.eduLinuxArmSystem * 1705358Sgblack@eecs.umich.eduLinuxArmSystemParams::create() 1715358Sgblack@eecs.umich.edu{ 1725358Sgblack@eecs.umich.edu return new LinuxArmSystem(this); 1735358Sgblack@eecs.umich.edu} 1745358Sgblack@eecs.umich.edu