system.cc revision 8143:b0b94a7b7c1f
111723Sar4jc@virginia.edu/* 211723Sar4jc@virginia.edu * Copyright (c) 2010 ARM Limited 311723Sar4jc@virginia.edu * All rights reserved 411723Sar4jc@virginia.edu * 511723Sar4jc@virginia.edu * The license below extends only to copyright in the software and shall 611723Sar4jc@virginia.edu * not be construed as granting a license to any other intellectual 711723Sar4jc@virginia.edu * property including but not limited to intellectual property relating 811723Sar4jc@virginia.edu * to a hardware implementation of the functionality of the software 911723Sar4jc@virginia.edu * licensed hereunder. You may use the software subject to the license 1011723Sar4jc@virginia.edu * terms below provided that you ensure that this notice is replicated 1111723Sar4jc@virginia.edu * unmodified and in its entirety in all distributions of the software, 1211723Sar4jc@virginia.edu * modified or unmodified, in source code or in binary form. 1311723Sar4jc@virginia.edu * 1411723Sar4jc@virginia.edu * Copyright (c) 2002-2006 The Regents of The University of Michigan 1511723Sar4jc@virginia.edu * All rights reserved. 1611723Sar4jc@virginia.edu * 1711723Sar4jc@virginia.edu * Redistribution and use in source and binary forms, with or without 1811723Sar4jc@virginia.edu * modification, are permitted provided that the following conditions are 1911723Sar4jc@virginia.edu * met: redistributions of source code must retain the above copyright 2011723Sar4jc@virginia.edu * notice, this list of conditions and the following disclaimer; 2111723Sar4jc@virginia.edu * redistributions in binary form must reproduce the above copyright 2211723Sar4jc@virginia.edu * notice, this list of conditions and the following disclaimer in the 2311723Sar4jc@virginia.edu * documentation and/or other materials provided with the distribution; 2411723Sar4jc@virginia.edu * neither the name of the copyright holders nor the names of its 2511723Sar4jc@virginia.edu * contributors may be used to endorse or promote products derived from 2611723Sar4jc@virginia.edu * this software without specific prior written permission. 2711723Sar4jc@virginia.edu * 2811723Sar4jc@virginia.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2911723Sar4jc@virginia.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3011723Sar4jc@virginia.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3111723Sar4jc@virginia.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3211723Sar4jc@virginia.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3311723Sar4jc@virginia.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3411723Sar4jc@virginia.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3511723Sar4jc@virginia.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3611723Sar4jc@virginia.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3711723Sar4jc@virginia.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3811723Sar4jc@virginia.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3911723Sar4jc@virginia.edu * 4011723Sar4jc@virginia.edu * Authors: Ali Saidi 4111723Sar4jc@virginia.edu */ 4211723Sar4jc@virginia.edu 4311723Sar4jc@virginia.edu#include "arch/arm/isa_traits.hh" 4411723Sar4jc@virginia.edu#include "arch/arm/linux/atag.hh" 45#include "arch/arm/linux/system.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 "kern/linux/events.hh" 51#include "mem/physical.hh" 52 53using namespace ArmISA; 54using namespace Linux; 55 56LinuxArmSystem::LinuxArmSystem(Params *p) 57 : ArmSystem(p) 58{ 59 // Load symbols at physical address, we might not want 60 // to do this perminately, for but early bootup work 61 // it is helpfulp. 62 kernel->loadGlobalSymbols(kernelSymtab, loadAddrMask); 63 kernel->loadGlobalSymbols(debugSymbolTable, loadAddrMask); 64 65 // Setup boot data structure 66 AtagCore *ac = new AtagCore; 67 ac->flags(1); // read-only 68 ac->pagesize(8192); 69 ac->rootdev(0); 70 71 AtagMem *am = new AtagMem; 72 am->memSize(params()->physmem->size()); 73 am->memStart(params()->physmem->start()); 74 75 AtagCmdline *ad = new AtagCmdline; 76 ad->cmdline(params()->boot_osflags); 77 78 DPRINTF(Loader, "boot command line %d bytes: %s\n", ad->size() <<2, params()->boot_osflags.c_str()); 79 80 AtagNone *an = new AtagNone; 81 82 uint32_t size = ac->size() + am->size() + ad->size() + an->size(); 83 uint32_t offset = 0; 84 uint8_t *boot_data = new uint8_t[size << 2]; 85 86 offset += ac->copyOut(boot_data + offset); 87 offset += am->copyOut(boot_data + offset); 88 offset += ad->copyOut(boot_data + offset); 89 offset += an->copyOut(boot_data + offset); 90 91 DPRINTF(Loader, "Boot atags was %d bytes in total\n", size << 2); 92 DDUMP(Loader, boot_data, size << 2); 93 94 functionalPort->writeBlob(ParamsList, boot_data, size << 2); 95 96#ifndef NDEBUG 97 kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic"); 98 if (!kernelPanicEvent) 99 panic("could not find kernel symbol \'panic\'"); 100#endif 101 102 // With ARM udelay() is #defined to __udelay 103 Addr addr = 0; 104 if (kernelSymtab->findAddress("__udelay", addr)) { 105 uDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__udelay", 106 fixFuncEventAddr(addr), 1000, 0); 107 } else { 108 panic("couldn't find kernel symbol \'udelay\'"); 109 } 110 111 // constant arguments to udelay() have some precomputation done ahead of 112 // time. Constant comes from code. 113 if (kernelSymtab->findAddress("__const_udelay", addr)) { 114 constUDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__const_udelay", 115 fixFuncEventAddr(addr), 1000, 107374); 116 } else { 117 panic("couldn't find kernel symbol \'udelay\'"); 118 } 119} 120 121void 122LinuxArmSystem::initState() 123{ 124 ArmSystem::initState(); 125 ThreadContext *tc = threadContexts[0]; 126 127 // Set the initial PC to be at start of the kernel code 128 tc->pcState(tc->getSystemPtr()->kernelEntry & loadAddrMask); 129 130 // Setup the machine type 131 tc->setIntReg(0, 0); 132 tc->setIntReg(1, params()->machine_type); 133 tc->setIntReg(2, ParamsList); 134} 135 136LinuxArmSystem::~LinuxArmSystem() 137{ 138 if (uDelaySkipEvent) 139 delete uDelaySkipEvent; 140 if (constUDelaySkipEvent) 141 delete constUDelaySkipEvent; 142} 143 144LinuxArmSystem * 145LinuxArmSystemParams::create() 146{ 147 return new LinuxArmSystem(this); 148} 149