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