system.cc (8286:abc8ab4ddd93) system.cc (8527:6bac5b04d588)
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/physical.hh"
53
54using namespace ArmISA;
55using namespace Linux;
56
57LinuxArmSystem::LinuxArmSystem(Params *p)
58 : ArmSystem(p)
59{
60 // Load symbols at physical address, we might not want
61 // to do this perminately, for but early bootup work
62 // it is helpfulp.
63 kernel->loadGlobalSymbols(kernelSymtab, loadAddrMask);
64 kernel->loadGlobalSymbols(debugSymbolTable, loadAddrMask);
65
66 // Setup boot data structure
67 AtagCore *ac = new AtagCore;
68 ac->flags(1); // read-only
69 ac->pagesize(8192);
70 ac->rootdev(0);
71
72 AtagMem *am = new AtagMem;
73 am->memSize(params()->physmem->size());
74 am->memStart(params()->physmem->start());
75
76 AtagCmdline *ad = new AtagCmdline;
77 ad->cmdline(params()->boot_osflags);
78
79 DPRINTF(Loader, "boot command line %d bytes: %s\n", ad->size() <<2, params()->boot_osflags.c_str());
80
81 AtagNone *an = new AtagNone;
82
83 uint32_t size = ac->size() + am->size() + ad->size() + an->size();
84 uint32_t offset = 0;
85 uint8_t *boot_data = new uint8_t[size << 2];
86
87 offset += ac->copyOut(boot_data + offset);
88 offset += am->copyOut(boot_data + offset);
89 offset += ad->copyOut(boot_data + offset);
90 offset += an->copyOut(boot_data + offset);
91
92 DPRINTF(Loader, "Boot atags was %d bytes in total\n", size << 2);
93 DDUMP(Loader, boot_data, size << 2);
94
95 functionalPort->writeBlob(ParamsList, boot_data, size << 2);
96
97#ifndef NDEBUG
98 kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic");
99 if (!kernelPanicEvent)
100 panic("could not find kernel symbol \'panic\'");
101#endif
102
103 // With ARM udelay() is #defined to __udelay
104 Addr addr = 0;
105 if (kernelSymtab->findAddress("__udelay", addr)) {
106 uDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__udelay",
107 fixFuncEventAddr(addr), 1000, 0);
108 } else {
109 panic("couldn't find kernel symbol \'udelay\'");
110 }
111
112 // constant arguments to udelay() have some precomputation done ahead of
113 // time. Constant comes from code.
114 if (kernelSymtab->findAddress("__const_udelay", addr)) {
115 constUDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__const_udelay",
116 fixFuncEventAddr(addr), 1000, 107374);
117 } else {
118 panic("couldn't find kernel symbol \'udelay\'");
119 }
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/physical.hh"
53
54using namespace ArmISA;
55using namespace Linux;
56
57LinuxArmSystem::LinuxArmSystem(Params *p)
58 : ArmSystem(p)
59{
60 // Load symbols at physical address, we might not want
61 // to do this perminately, for but early bootup work
62 // it is helpfulp.
63 kernel->loadGlobalSymbols(kernelSymtab, loadAddrMask);
64 kernel->loadGlobalSymbols(debugSymbolTable, loadAddrMask);
65
66 // Setup boot data structure
67 AtagCore *ac = new AtagCore;
68 ac->flags(1); // read-only
69 ac->pagesize(8192);
70 ac->rootdev(0);
71
72 AtagMem *am = new AtagMem;
73 am->memSize(params()->physmem->size());
74 am->memStart(params()->physmem->start());
75
76 AtagCmdline *ad = new AtagCmdline;
77 ad->cmdline(params()->boot_osflags);
78
79 DPRINTF(Loader, "boot command line %d bytes: %s\n", ad->size() <<2, params()->boot_osflags.c_str());
80
81 AtagNone *an = new AtagNone;
82
83 uint32_t size = ac->size() + am->size() + ad->size() + an->size();
84 uint32_t offset = 0;
85 uint8_t *boot_data = new uint8_t[size << 2];
86
87 offset += ac->copyOut(boot_data + offset);
88 offset += am->copyOut(boot_data + offset);
89 offset += ad->copyOut(boot_data + offset);
90 offset += an->copyOut(boot_data + offset);
91
92 DPRINTF(Loader, "Boot atags was %d bytes in total\n", size << 2);
93 DDUMP(Loader, boot_data, size << 2);
94
95 functionalPort->writeBlob(ParamsList, boot_data, size << 2);
96
97#ifndef NDEBUG
98 kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic");
99 if (!kernelPanicEvent)
100 panic("could not find kernel symbol \'panic\'");
101#endif
102
103 // With ARM udelay() is #defined to __udelay
104 Addr addr = 0;
105 if (kernelSymtab->findAddress("__udelay", addr)) {
106 uDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__udelay",
107 fixFuncEventAddr(addr), 1000, 0);
108 } else {
109 panic("couldn't find kernel symbol \'udelay\'");
110 }
111
112 // constant arguments to udelay() have some precomputation done ahead of
113 // time. Constant comes from code.
114 if (kernelSymtab->findAddress("__const_udelay", addr)) {
115 constUDelaySkipEvent = new UDelayEvent(&pcEventQueue, "__const_udelay",
116 fixFuncEventAddr(addr), 1000, 107374);
117 } else {
118 panic("couldn't find kernel symbol \'udelay\'");
119 }
120
121 secDataPtrAddr = 0;
122 secDataAddr = 0;
123 penReleaseAddr = 0;
124 kernelSymtab->findAddress("__secondary_data", secDataPtrAddr);
125 kernelSymtab->findAddress("secondary_data", secDataAddr);
126 kernelSymtab->findAddress("pen_release", penReleaseAddr);
127
128 secDataPtrAddr &= ~ULL(0x7F);
129 secDataAddr &= ~ULL(0x7F);
130 penReleaseAddr &= ~ULL(0x7F);
120}
121
131}
132
133bool
134LinuxArmSystem::adderBootUncacheable(Addr a)
135{
136 Addr block = a & ~ULL(0x7F);
137 if (block == secDataPtrAddr || block == secDataAddr ||
138 block == penReleaseAddr)
139 return true;
140 return false;
141}
142
122void
123LinuxArmSystem::initState()
124{
125 ArmSystem::initState();
126
127 for (int i = 0; i < threadContexts.size(); i++) {
128 threadContexts[i]->setIntReg(0, 0);
129 threadContexts[i]->setIntReg(1, params()->machine_type);
130 threadContexts[i]->setIntReg(2, ParamsList);
131 }
132}
133
134LinuxArmSystem::~LinuxArmSystem()
135{
136 if (uDelaySkipEvent)
137 delete uDelaySkipEvent;
138 if (constUDelaySkipEvent)
139 delete constUDelaySkipEvent;
140}
141
142LinuxArmSystem *
143LinuxArmSystemParams::create()
144{
145 return new LinuxArmSystem(this);
146}
143void
144LinuxArmSystem::initState()
145{
146 ArmSystem::initState();
147
148 for (int i = 0; i < threadContexts.size(); i++) {
149 threadContexts[i]->setIntReg(0, 0);
150 threadContexts[i]->setIntReg(1, params()->machine_type);
151 threadContexts[i]->setIntReg(2, ParamsList);
152 }
153}
154
155LinuxArmSystem::~LinuxArmSystem()
156{
157 if (uDelaySkipEvent)
158 delete uDelaySkipEvent;
159 if (constUDelaySkipEvent)
160 delete constUDelaySkipEvent;
161}
162
163LinuxArmSystem *
164LinuxArmSystemParams::create()
165{
166 return new LinuxArmSystem(this);
167}