system.cc (8798:adaa92be9037) | system.cc (8799:dac1e33e07b0) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2011 ARM Limited | 2 * Copyright (c) 2011-2012 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 --- 41 unchanged lines hidden (view full) --- 52#include "base/loader/object_file.hh" 53#include "base/loader/symtab.hh" 54#include "base/trace.hh" 55#include "config/the_isa.hh" 56#include "cpu/thread_context.hh" 57#include "debug/Loader.hh" 58#include "debug/WorkItems.hh" 59#include "kern/kernel_stats.hh" | 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 --- 41 unchanged lines hidden (view full) --- 52#include "base/loader/object_file.hh" 53#include "base/loader/symtab.hh" 54#include "base/trace.hh" 55#include "config/the_isa.hh" 56#include "cpu/thread_context.hh" 57#include "debug/Loader.hh" 58#include "debug/WorkItems.hh" 59#include "kern/kernel_stats.hh" |
60#include "mem/fs_translating_port_proxy.hh" |
|
60#include "mem/mem_object.hh" 61#include "mem/physical.hh" | 61#include "mem/mem_object.hh" 62#include "mem/physical.hh" |
62#include "mem/vport.hh" | |
63#include "params/System.hh" 64#include "sim/byteswap.hh" 65#include "sim/debug.hh" 66#include "sim/full_system.hh" 67#include "sim/system.hh" 68 69using namespace std; 70using namespace TheISA; 71 72vector<System *> System::systemList; 73 74int System::numSystemsRunning = 0; 75 76System::System(Params *p) | 63#include "params/System.hh" 64#include "sim/byteswap.hh" 65#include "sim/debug.hh" 66#include "sim/full_system.hh" 67#include "sim/system.hh" 68 69using namespace std; 70using namespace TheISA; 71 72vector<System *> System::systemList; 73 74int System::numSystemsRunning = 0; 75 76System::System(Params *p) |
77 : SimObject(p), physmem(p->physmem), _numContexts(0), pagePtr(0), | 77 : MemObject(p), _systemPort("system_port", this), 78 physmem(p->physmem), 79 _numContexts(0), |
78 init_param(p->init_param), 79 loadAddrMask(p->load_addr_mask), 80 nextPID(0), 81 memoryMode(p->mem_mode), 82 workItemsBegin(0), 83 workItemsEnd(0), 84 numWorkIds(p->num_work_ids), 85 _params(p), --- 13 unchanged lines hidden (view full) --- 99 p->memories[x]->size())); 100 } 101 102 if (FullSystem) { 103 kernelSymtab = new SymbolTable; 104 if (!debugSymbolTable) 105 debugSymbolTable = new SymbolTable; 106 | 80 init_param(p->init_param), 81 loadAddrMask(p->load_addr_mask), 82 nextPID(0), 83 memoryMode(p->mem_mode), 84 workItemsBegin(0), 85 workItemsEnd(0), 86 numWorkIds(p->num_work_ids), 87 _params(p), --- 13 unchanged lines hidden (view full) --- 101 p->memories[x]->size())); 102 } 103 104 if (FullSystem) { 105 kernelSymtab = new SymbolTable; 106 if (!debugSymbolTable) 107 debugSymbolTable = new SymbolTable; 108 |
107 | |
108 /** | 109 /** |
109 * Get a functional port to memory | 110 * Get a port proxy to memory |
110 */ | 111 */ |
111 Port *mem_port; 112 functionalPort = new FunctionalPort(name() + "-fport"); 113 mem_port = physmem->getPort("functional"); 114 functionalPort->setPeer(mem_port); 115 mem_port->setPeer(functionalPort); 116 117 virtPort = new VirtualPort(name() + "-fport"); 118 mem_port = physmem->getPort("functional"); 119 virtPort->setPeer(mem_port); 120 mem_port->setPeer(virtPort); 121 122 123 /** 124 * Load the kernel code into memory 125 */ 126 if (params()->kernel == "") { 127 inform("No kernel set for full system simulation. " 128 "Assuming you know what you're doing...\n"); 129 } else { 130 // Load kernel code 131 kernel = createObjectFile(params()->kernel); 132 inform("kernel located at: %s", params()->kernel); 133 134 if (kernel == NULL) 135 fatal("Could not load kernel file %s", params()->kernel); 136 137 // Load program sections into memory 138 kernel->loadSections(functionalPort, loadAddrMask); 139 140 // setup entry points 141 kernelStart = kernel->textBase(); 142 kernelEnd = kernel->bssBase() + kernel->bssSize(); 143 kernelEntry = kernel->entryPoint(); 144 145 // load symbols 146 if (!kernel->loadGlobalSymbols(kernelSymtab)) 147 fatal("could not load kernel symbols\n"); 148 149 if (!kernel->loadLocalSymbols(kernelSymtab)) 150 fatal("could not load kernel local symbols\n"); 151 152 if (!kernel->loadGlobalSymbols(debugSymbolTable)) 153 fatal("could not load kernel symbols\n"); 154 155 if (!kernel->loadLocalSymbols(debugSymbolTable)) 156 fatal("could not load kernel local symbols\n"); 157 158 DPRINTF(Loader, "Kernel start = %#x\n", kernelStart); 159 DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd); 160 DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry); 161 DPRINTF(Loader, "Kernel loaded...\n"); 162 } | 112 physProxy = new PortProxy(*getSystemPort()); 113 virtProxy = new FSTranslatingPortProxy(*getSystemPort()); |
163 } | 114 } |
164 165 // increment the number of running systms 166 numSystemsRunning++; 167 168 activeCpus.clear(); | |
169} 170 171System::~System() 172{ 173 delete kernelSymtab; 174 delete kernel; 175 176 for (uint32_t j = 0; j < numWorkIds; j++) 177 delete workItemStats[j]; 178} 179 180void | 115} 116 117System::~System() 118{ 119 delete kernelSymtab; 120 delete kernel; 121 122 for (uint32_t j = 0; j < numWorkIds; j++) 123 delete workItemStats[j]; 124} 125 126void |
127System::init() 128{ 129 // check that the system port is connected 130 if (!_systemPort.isConnected()) 131 panic("System port on %s is not connected.\n", name()); 132} 133 134Port* 135System::getPort(const std::string &if_name, int idx) 136{ 137 // no need to distinguish at the moment (besides checking) 138 return &_systemPort; 139} 140 141void |
|
181System::setMemoryMode(Enums::MemoryMode mode) 182{ 183 assert(getState() == Drained); 184 memoryMode = mode; 185} 186 187bool System::breakpoint() 188{ --- 67 unchanged lines hidden (view full) --- 256 257void 258System::initState() 259{ 260 if (FullSystem) { 261 int i; 262 for (i = 0; i < threadContexts.size(); i++) 263 TheISA::startupCPU(threadContexts[i], i); | 142System::setMemoryMode(Enums::MemoryMode mode) 143{ 144 assert(getState() == Drained); 145 memoryMode = mode; 146} 147 148bool System::breakpoint() 149{ --- 67 unchanged lines hidden (view full) --- 217 218void 219System::initState() 220{ 221 if (FullSystem) { 222 int i; 223 for (i = 0; i < threadContexts.size(); i++) 224 TheISA::startupCPU(threadContexts[i], i); |
225 // Moved from the constructor to here since it relies on the 226 // address map being resolved in the interconnect 227 /** 228 * Load the kernel code into memory 229 */ 230 if (params()->kernel == "") { 231 inform("No kernel set for full system simulation. " 232 "Assuming you know what you're doing...\n"); 233 } else { 234 // Load kernel code 235 kernel = createObjectFile(params()->kernel); 236 inform("kernel located at: %s", params()->kernel); 237 238 if (kernel == NULL) 239 fatal("Could not load kernel file %s", params()->kernel); 240 241 // Load program sections into memory 242 kernel->loadSections(physProxy, loadAddrMask); 243 244 // setup entry points 245 kernelStart = kernel->textBase(); 246 kernelEnd = kernel->bssBase() + kernel->bssSize(); 247 kernelEntry = kernel->entryPoint(); 248 249 // load symbols 250 if (!kernel->loadGlobalSymbols(kernelSymtab)) 251 fatal("could not load kernel symbols\n"); 252 253 if (!kernel->loadLocalSymbols(kernelSymtab)) 254 fatal("could not load kernel local symbols\n"); 255 256 if (!kernel->loadGlobalSymbols(debugSymbolTable)) 257 fatal("could not load kernel symbols\n"); 258 259 if (!kernel->loadLocalSymbols(debugSymbolTable)) 260 fatal("could not load kernel local symbols\n"); 261 262 DPRINTF(Loader, "Kernel start = %#x\n", kernelStart); 263 DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd); 264 DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry); 265 DPRINTF(Loader, "Kernel loaded...\n"); 266 } |
|
264 } | 267 } |
268 269 // increment the number of running systms 270 numSystemsRunning++; 271 272 activeCpus.clear(); 273 274 if (FullSystem) { 275 int i; 276 for (i = 0; i < threadContexts.size(); i++) 277 TheISA::startupCPU(threadContexts[i], i); 278 } |
|
265} 266 267void 268System::replaceThreadContext(ThreadContext *tc, int context_id) 269{ 270 if (context_id >= threadContexts.size()) { 271 panic("replaceThreadContext: bad id, %d >= %d\n", 272 context_id, threadContexts.size()); --- 122 unchanged lines hidden --- | 279} 280 281void 282System::replaceThreadContext(ThreadContext *tc, int context_id) 283{ 284 if (context_id >= threadContexts.size()) { 285 panic("replaceThreadContext: bad id, %d >= %d\n", 286 context_id, threadContexts.size()); --- 122 unchanged lines hidden --- |