system.cc revision 8870
1/* 2 * Copyright (c) 2010 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Copyright (c) 2002-2006 The Regents of The University of Michigan 15 * All rights reserved. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions are 19 * met: redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer; 21 * redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the 23 * documentation and/or other materials provided with the distribution; 24 * neither the name of the copyright holders nor the names of its 25 * contributors may be used to endorse or promote products derived from 26 * this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * 40 * Authors: Ali Saidi 41 */ 42 43#include "arch/arm/linux/atag.hh" 44#include "arch/arm/linux/system.hh" 45#include "arch/arm/isa_traits.hh" 46#include "arch/arm/utility.hh" 47#include "base/loader/object_file.hh" 48#include "base/loader/symtab.hh" 49#include "cpu/thread_context.hh" 50#include "debug/Loader.hh" 51#include "kern/linux/events.hh" 52#include "mem/fs_translating_port_proxy.hh" 53#include "mem/physical.hh" 54 55using namespace ArmISA; 56using namespace Linux; 57 58LinuxArmSystem::LinuxArmSystem(Params *p) 59 : ArmSystem(p) 60{ 61} 62 63bool 64LinuxArmSystem::adderBootUncacheable(Addr a) 65{ 66 Addr block = a & ~ULL(0x7F); 67 if (block == secDataPtrAddr || block == secDataAddr || 68 block == penReleaseAddr) 69 return true; 70 return false; 71} 72 73void 74LinuxArmSystem::initState() 75{ 76 // Moved from the constructor to here since it relies on the 77 // address map being resolved in the interconnect 78 79 // Call the initialisation of the super class 80 ArmSystem::initState(); 81 82 // Load symbols at physical address, we might not want 83 // to do this perminately, for but early bootup work 84 // it is helpfulp. 85 kernel->loadGlobalSymbols(kernelSymtab, loadAddrMask); 86 kernel->loadGlobalSymbols(debugSymbolTable, loadAddrMask); 87 88 // Setup boot data structure 89 AtagCore *ac = new AtagCore; 90 ac->flags(1); // read-only 91 ac->pagesize(8192); 92 ac->rootdev(0); 93 94 AtagMem *am = new AtagMem; 95 am->memSize(params()->physmem->size()); 96 am->memStart(params()->physmem->start()); 97 98 AtagCmdline *ad = new AtagCmdline; 99 ad->cmdline(params()->boot_osflags); 100 101 DPRINTF(Loader, "boot command line %d bytes: %s\n", ad->size() <<2, params()->boot_osflags.c_str()); 102 103 AtagNone *an = new AtagNone; 104 105 uint32_t size = ac->size() + am->size() + ad->size() + an->size(); 106 uint32_t offset = 0; 107 uint8_t *boot_data = new uint8_t[size << 2]; 108 109 offset += ac->copyOut(boot_data + offset); 110 offset += am->copyOut(boot_data + offset); 111 offset += ad->copyOut(boot_data + offset); 112 offset += an->copyOut(boot_data + offset); 113 114 DPRINTF(Loader, "Boot atags was %d bytes in total\n", size << 2); 115 DDUMP(Loader, boot_data, size << 2); 116 117 physProxy.writeBlob(params()->atags_addr, boot_data, size << 2); 118 119#ifndef NDEBUG 120 kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic"); 121 if (!kernelPanicEvent) 122 panic("could not find kernel symbol \'panic\'"); 123#endif 124 125 // With ARM udelay() is #defined to __udelay 126 Addr addr = 0; 127 if (kernelSymtab->findAddress("__udelay", addr)) { 128 uDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__udelay", 129 fixFuncEventAddr(addr), 1000, 0); 130 } else { 131 panic("couldn't find kernel symbol \'udelay\'"); 132 } 133 134 // constant arguments to udelay() have some precomputation done ahead of 135 // time. Constant comes from code. 136 if (kernelSymtab->findAddress("__const_udelay", addr)) { 137 constUDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__const_udelay", 138 fixFuncEventAddr(addr), 1000, 107374); 139 } else { 140 panic("couldn't find kernel symbol \'udelay\'"); 141 } 142 143 secDataPtrAddr = 0; 144 secDataAddr = 0; 145 penReleaseAddr = 0; 146 kernelSymtab->findAddress("__secondary_data", secDataPtrAddr); 147 kernelSymtab->findAddress("secondary_data", secDataAddr); 148 kernelSymtab->findAddress("pen_release", penReleaseAddr); 149 150 secDataPtrAddr &= ~ULL(0x7F); 151 secDataAddr &= ~ULL(0x7F); 152 penReleaseAddr &= ~ULL(0x7F); 153 154 for (int i = 0; i < threadContexts.size(); i++) { 155 threadContexts[i]->setIntReg(0, 0); 156 threadContexts[i]->setIntReg(1, params()->machine_type); 157 threadContexts[i]->setIntReg(2, params()->atags_addr); 158 } 159} 160 161LinuxArmSystem::~LinuxArmSystem() 162{ 163 if (uDelaySkipEvent) 164 delete uDelaySkipEvent; 165 if (constUDelaySkipEvent) 166 delete constUDelaySkipEvent; 167} 168 169LinuxArmSystem * 170LinuxArmSystemParams::create() 171{ 172 return new LinuxArmSystem(this); 173} 174