system.cc revision 8870:f95c4042f2d0
12155SN/A/*
22155SN/A * Copyright (c) 2010 ARM Limited
32155SN/A * All rights reserved
42155SN/A *
52155SN/A * The license below extends only to copyright in the software and shall
62155SN/A * not be construed as granting a license to any other intellectual
72155SN/A * property including but not limited to intellectual property relating
82155SN/A * to a hardware implementation of the functionality of the software
92155SN/A * licensed hereunder.  You may use the software subject to the license
102155SN/A * terms below provided that you ensure that this notice is replicated
112155SN/A * unmodified and in its entirety in all distributions of the software,
122155SN/A * modified or unmodified, in source code or in binary form.
132155SN/A *
142155SN/A * Copyright (c) 2002-2006 The Regents of The University of Michigan
152155SN/A * All rights reserved.
162155SN/A *
172155SN/A * Redistribution and use in source and binary forms, with or without
182155SN/A * modification, are permitted provided that the following conditions are
192155SN/A * met: redistributions of source code must retain the above copyright
202155SN/A * notice, this list of conditions and the following disclaimer;
212155SN/A * redistributions in binary form must reproduce the above copyright
222155SN/A * notice, this list of conditions and the following disclaimer in the
232155SN/A * documentation and/or other materials provided with the distribution;
242155SN/A * neither the name of the copyright holders nor the names of its
252155SN/A * contributors may be used to endorse or promote products derived from
262155SN/A * this software without specific prior written permission.
272155SN/A *
282665Ssaidi@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292665Ssaidi@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302155SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
314202Sbinkertn@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
322155SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
337768SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
347768SAli.Saidi@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
357768SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362178SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372178SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
382178SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392178SN/A *
402178SN/A * Authors: Ali Saidi
412178SN/A */
422178SN/A
432178SN/A#include "arch/arm/linux/atag.hh"
442178SN/A#include "arch/arm/linux/system.hh"
452178SN/A#include "arch/arm/isa_traits.hh"
462178SN/A#include "arch/arm/utility.hh"
472155SN/A#include "base/loader/object_file.hh"
485865Sksewell@umich.edu#include "base/loader/symtab.hh"
496181Sksewell@umich.edu#include "cpu/thread_context.hh"
506181Sksewell@umich.edu#include "debug/Loader.hh"
515865Sksewell@umich.edu#include "kern/linux/events.hh"
523918Ssaidi@eecs.umich.edu#include "mem/fs_translating_port_proxy.hh"
535865Sksewell@umich.edu#include "mem/physical.hh"
542623SN/A
553918Ssaidi@eecs.umich.eduusing namespace ArmISA;
562155SN/Ausing namespace Linux;
572155SN/A
582292SN/ALinuxArmSystem::LinuxArmSystem(Params *p)
596181Sksewell@umich.edu    : ArmSystem(p)
606181Sksewell@umich.edu{
613918Ssaidi@eecs.umich.edu}
622292SN/A
632292SN/Abool
642292SN/ALinuxArmSystem::adderBootUncacheable(Addr a)
653918Ssaidi@eecs.umich.edu{
662292SN/A    Addr block = a & ~ULL(0x7F);
672292SN/A    if (block == secDataPtrAddr || block == secDataAddr ||
682766Sktlim@umich.edu            block == penReleaseAddr)
692766Sktlim@umich.edu        return true;
702766Sktlim@umich.edu    return false;
712921Sktlim@umich.edu}
722921Sktlim@umich.edu
732766Sktlim@umich.eduvoid
742766Sktlim@umich.eduLinuxArmSystem::initState()
755529Snate@binkert.org{
762766Sktlim@umich.edu    // Moved from the constructor to here since it relies on the
774762Snate@binkert.org    // address map being resolved in the interconnect
782155SN/A
792155SN/A    // Call the initialisation of the super class
802155SN/A    ArmSystem::initState();
812155SN/A
822155SN/A    // Load symbols at physical address, we might not want
832155SN/A    // to do this perminately, for but early bootup work
842766Sktlim@umich.edu    // it is helpfulp.
852155SN/A    kernel->loadGlobalSymbols(kernelSymtab, loadAddrMask);
865865Sksewell@umich.edu    kernel->loadGlobalSymbols(debugSymbolTable, loadAddrMask);
872155SN/A
882155SN/A    // Setup boot data structure
892155SN/A    AtagCore *ac = new AtagCore;
902155SN/A    ac->flags(1); // read-only
912178SN/A    ac->pagesize(8192);
922178SN/A    ac->rootdev(0);
937756SAli.Saidi@ARM.com
942766Sktlim@umich.edu    AtagMem *am = new AtagMem;
952178SN/A    am->memSize(params()->physmem->size());
962178SN/A    am->memStart(params()->physmem->start());
976994Snate@binkert.org
982178SN/A    AtagCmdline *ad = new AtagCmdline;
992766Sktlim@umich.edu    ad->cmdline(params()->boot_osflags);
1002766Sktlim@umich.edu
1012766Sktlim@umich.edu    DPRINTF(Loader, "boot command line %d bytes: %s\n", ad->size() <<2, params()->boot_osflags.c_str());
1022788Sktlim@umich.edu
1032178SN/A    AtagNone *an = new AtagNone;
1042733Sktlim@umich.edu
1052733Sktlim@umich.edu    uint32_t size = ac->size() + am->size() + ad->size() + an->size();
1062817Sksewell@umich.edu    uint32_t offset = 0;
1072733Sktlim@umich.edu    uint8_t *boot_data = new uint8_t[size << 2];
1084486Sbinkertn@umich.edu
1094486Sbinkertn@umich.edu    offset += ac->copyOut(boot_data + offset);
1104776Sgblack@eecs.umich.edu    offset += am->copyOut(boot_data + offset);
1114776Sgblack@eecs.umich.edu    offset += ad->copyOut(boot_data + offset);
1126365Sgblack@eecs.umich.edu    offset += an->copyOut(boot_data + offset);
1134486Sbinkertn@umich.edu
1144202Sbinkertn@umich.edu    DPRINTF(Loader, "Boot atags was %d bytes in total\n", size << 2);
1154202Sbinkertn@umich.edu    DDUMP(Loader, boot_data, size << 2);
1164202Sbinkertn@umich.edu
1178541Sgblack@eecs.umich.edu    physProxy.writeBlob(params()->atags_addr, boot_data, size << 2);
1184202Sbinkertn@umich.edu
1194202Sbinkertn@umich.edu#ifndef NDEBUG
1204776Sgblack@eecs.umich.edu    kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic");
1216365Sgblack@eecs.umich.edu    if (!kernelPanicEvent)
1224202Sbinkertn@umich.edu        panic("could not find kernel symbol \'panic\'");
1234202Sbinkertn@umich.edu#endif
1244202Sbinkertn@umich.edu
1254202Sbinkertn@umich.edu    // With ARM udelay() is #defined to __udelay
1265217Ssaidi@eecs.umich.edu    Addr addr = 0;
1274202Sbinkertn@umich.edu    if (kernelSymtab->findAddress("__udelay", addr)) {
1282155SN/A        uDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__udelay",
1294202Sbinkertn@umich.edu                fixFuncEventAddr(addr), 1000, 0);
1304486Sbinkertn@umich.edu    } else {
1314486Sbinkertn@umich.edu        panic("couldn't find kernel symbol \'udelay\'");
1324202Sbinkertn@umich.edu    }
1334202Sbinkertn@umich.edu
1342821Sktlim@umich.edu    // constant arguments to udelay() have some precomputation done ahead of
1354776Sgblack@eecs.umich.edu    // time. Constant comes from code.
1364776Sgblack@eecs.umich.edu    if (kernelSymtab->findAddress("__const_udelay", addr)) {
1374776Sgblack@eecs.umich.edu        constUDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__const_udelay",
1384776Sgblack@eecs.umich.edu                fixFuncEventAddr(addr), 1000, 107374);
1392766Sktlim@umich.edu    } else {
1404202Sbinkertn@umich.edu        panic("couldn't find kernel symbol \'udelay\'");
1418335Snate@binkert.org    }
1422733Sktlim@umich.edu
1432733Sktlim@umich.edu    secDataPtrAddr = 0;
1442733Sktlim@umich.edu    secDataAddr = 0;
1452733Sktlim@umich.edu    penReleaseAddr = 0;
1462733Sktlim@umich.edu    kernelSymtab->findAddress("__secondary_data", secDataPtrAddr);
1472874Sktlim@umich.edu    kernelSymtab->findAddress("secondary_data", secDataAddr);
1482874Sktlim@umich.edu    kernelSymtab->findAddress("pen_release", penReleaseAddr);
1492874Sktlim@umich.edu
1504202Sbinkertn@umich.edu    secDataPtrAddr &= ~ULL(0x7F);
1512733Sktlim@umich.edu    secDataAddr &= ~ULL(0x7F);
1525192Ssaidi@eecs.umich.edu    penReleaseAddr &= ~ULL(0x7F);
1538335Snate@binkert.org
1548335Snate@binkert.org    for (int i = 0; i < threadContexts.size(); i++) {
1558335Snate@binkert.org        threadContexts[i]->setIntReg(0, 0);
1568335Snate@binkert.org        threadContexts[i]->setIntReg(1, params()->machine_type);
1578335Snate@binkert.org        threadContexts[i]->setIntReg(2, params()->atags_addr);
1588335Snate@binkert.org    }
1598335Snate@binkert.org}
1608335Snate@binkert.org
1618335Snate@binkert.orgLinuxArmSystem::~LinuxArmSystem()
1628335Snate@binkert.org{
1638335Snate@binkert.org    if (uDelaySkipEvent)
1648335Snate@binkert.org        delete uDelaySkipEvent;
1658335Snate@binkert.org    if (constUDelaySkipEvent)
1668335Snate@binkert.org        delete constUDelaySkipEvent;
1678335Snate@binkert.org}
1688335Snate@binkert.org
1698335Snate@binkert.orgLinuxArmSystem *
1708335Snate@binkert.orgLinuxArmSystemParams::create()
1718335Snate@binkert.org{
1728335Snate@binkert.org    return new LinuxArmSystem(this);
1738335Snate@binkert.org}
1748335Snate@binkert.org