system.cc revision 7585:afbc40280b56
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/isa_traits.hh" 44#include "arch/arm/linux/atag.hh" 45#include "arch/arm/linux/system.hh" 46#include "base/loader/object_file.hh" 47#include "base/loader/symtab.hh" 48#include "mem/physical.hh" 49 50using namespace ArmISA; 51 52LinuxArmSystem::LinuxArmSystem(Params *p) 53 : ArmSystem(p) 54{ 55 // Load symbols at physical address, we might not want 56 // to do this perminately, for but early bootup work 57 // it is helpfulp. 58 kernel->loadGlobalSymbols(kernelSymtab, loadAddrMask); 59 kernel->loadGlobalSymbols(debugSymbolTable, loadAddrMask); 60 61 // Setup boot data structure 62 AtagCore *ac = new AtagCore; 63 ac->flags(1); // read-only 64 ac->pagesize(8192); 65 ac->rootdev(0); 66 67 AtagMem *am = new AtagMem; 68 am->memSize(params()->physmem->size()); 69 am->memStart(params()->physmem->start()); 70 71 AtagCmdline *ad = new AtagCmdline; 72 ad->cmdline(params()->boot_osflags); 73 74 DPRINTF(Loader, "boot command line %d bytes: %s\n", ad->size() <<2, params()->boot_osflags.c_str()); 75 76 AtagNone *an = new AtagNone; 77 78 uint32_t size = ac->size() + am->size() + ad->size() + an->size(); 79 uint32_t offset = 0; 80 uint8_t *boot_data = new uint8_t[size << 2]; 81 82 offset += ac->copyOut(boot_data + offset); 83 offset += am->copyOut(boot_data + offset); 84 offset += ad->copyOut(boot_data + offset); 85 offset += an->copyOut(boot_data + offset); 86 87 DPRINTF(Loader, "Boot atags was %d bytes in total\n", size << 2); 88 DDUMP(Loader, boot_data, size << 2); 89 90 functionalPort.writeBlob(ParamsList, boot_data, size << 2); 91 92#ifndef NDEBUG 93 kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic"); 94 if (!kernelPanicEvent) 95 panic("could not find kernel symbol \'panic\'"); 96#endif 97} 98 99void 100LinuxArmSystem::startup() 101{ 102 ArmSystem::startup(); 103 ThreadContext *tc = threadContexts[0]; 104 105 // Set the initial PC to be at start of the kernel code 106 tc->setPC(tc->getSystemPtr()->kernelEntry & loadAddrMask); 107 tc->setNextPC(tc->readPC() + sizeof(MachInst)); 108 109 // Setup the machine type 110 tc->setIntReg(0, 0); 111 tc->setIntReg(1, params()->machine_type); 112 tc->setIntReg(2, ParamsList); 113} 114 115LinuxArmSystem::~LinuxArmSystem() 116{ 117} 118 119 120LinuxArmSystem * 121LinuxArmSystemParams::create() 122{ 123 return new LinuxArmSystem(this); 124} 125