system.cc revision 451
1/* 2 * Copyright (c) 2003 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include "base/loader/aout_object.hh" 30#include "base/loader/elf_object.hh" 31#include "base/loader/object_file.hh" 32#include "base/loader/symtab.hh" 33#include "base/remote_gdb.hh" 34#include "base/trace.hh" 35#include "cpu/exec_context.hh" 36#include "kern/linux/linux_events.hh" 37#include "kern/linux/linux_system.hh" 38#include "mem/functional_mem/memory_control.hh" 39#include "mem/functional_mem/physical_memory.hh" 40#include "sim/builder.hh" 41#include "targetarch/isa_traits.hh" 42#include "targetarch/vtophys.hh" 43 44//un-comment this to see the state of call stack when it changes. 45//#define SW_DEBUG 46 47using namespace std; 48 49LinuxSystem::LinuxSystem(const string _name, const uint64_t _init_param, 50 MemoryController *_memCtrl, PhysicalMemory *_physmem, 51 const string &kernel_path, const string &console_path, 52 const string &palcode, const string &boot_osflags, 53 const string &bootloader_path, const bool _bin) 54 : System(_name, _init_param, _memCtrl, _physmem, _bin), bin(_bin) 55{ 56 kernelSymtab = new SymbolTable; 57 consoleSymtab = new SymbolTable; 58 bootloaderSymtab = new SymbolTable; 59 60 ObjectFile *kernel = createObjectFile(kernel_path); 61 if (kernel == NULL) 62 fatal("Could not load kernel file %s", kernel_path); 63 64 ObjectFile *console = createObjectFile(console_path); 65 if (console == NULL) 66 fatal("Could not load console file %s", console_path); 67 68 ObjectFile *bootloader = createObjectFile(bootloader_path); 69 if (bootloader == NULL) 70 fatal("Could not load bootloader file %s", bootloader_path); 71 72 if (!kernel->loadGlobalSymbols(kernelSymtab)) 73 panic("could not load kernel symbols\n"); 74 75 if (!console->loadGlobalSymbols(consoleSymtab)) 76 panic("could not load console symbols\n"); 77 78 if (!bootloader->loadGlobalSymbols(bootloaderSymtab)) 79 panic("could not load bootloader symbols\n"); 80 81 // Load pal file 82 ObjectFile *pal = createObjectFile(palcode); 83 if (pal == NULL) 84 fatal("Could not load PALcode file %s", palcode); 85 pal->loadSections(physmem, true); 86 87 // Load console file 88 console->loadSections(physmem, true); 89 90 // Load kernel file 91 kernel->loadSections(physmem, true); 92 kernelStart = kernel->textBase(); 93 kernelEnd = kernel->bssBase() + kernel->bssSize(); 94 /* FIXME: entrypoint not in kernel, but in bootloader, 95 variable should be re-named appropriately */ 96 kernelEntry = kernel->entryPoint(); 97 98 99 DPRINTF(Loader, "Kernel start = %#x\n" 100 "Kernel end = %#x\n" 101 "Kernel entry = %#x\n", 102 kernelStart, kernelEnd, kernelEntry); 103 104 DPRINTF(Loader, "Kernel loaded...\n"); 105 106 // Load bootloader file 107 bootloader->loadSections(physmem, true); 108 kernelEntry = bootloader->entryPoint(); 109 kernelStart = bootloader->textBase(); 110 DPRINTF(Loader, "Bootloader entry at %#x\n", kernelEntry); 111 112#ifdef FS_MEASURE 113 //INSTRUMENTATION CODEGEN BEGIN ONE 114 if (bin == true) { 115 esIntrBin = new Statistics::MainBin(name() + " es_intr"); 116 fnBins.insert(make_pair("es_intr", esIntrBin)); 117 118 esRxeofBin = new Statistics::MainBin(name() + " es_rxeof"); 119 fnBins.insert(make_pair("es_rxeof", esRxeofBin)); 120 121 esNewbufBin = new Statistics::MainBin(name() + " es_newbuf"); 122 fnBins.insert(make_pair("es_newbuf", esNewbufBin)); 123 124 esDmaLoadBin = new Statistics::MainBin(name() + " es_dma_load"); 125 fnBins.insert(make_pair("es_dma_load", esDmaLoadBin)); 126 127 dmaMapLoadBin = new Statistics::MainBin(name() + " dma_map_load"); 128 fnBins.insert(make_pair("dma_map_load", dmaMapLoadBin)); 129 130 etherInputBin = new Statistics::MainBin(name() + " ether_input"); 131 fnBins.insert(make_pair("ether_input", etherInputBin)); 132 133 netisrInputBin = new Statistics::MainBin(name() + " netisr_input"); 134 fnBins.insert(make_pair("netisr_input", netisrInputBin)); 135 136 schednetisrIsrBin = new Statistics::MainBin(name() + " schednetisr_isr"); 137 fnBins.insert(make_pair("schednetisr_isr", schednetisrIsrBin)); 138 139 ipintrBin = new Statistics::MainBin(name() + " ipintr"); 140 fnBins.insert(make_pair("ipintr", ipintrBin)); 141 142 ipDooptionsBin = new Statistics::MainBin(name() + " ip_dooptions"); 143 fnBins.insert(make_pair("ip_dooptions", ipDooptionsBin)); 144 145 ipReassBin = new Statistics::MainBin(name() + " ip_reass"); 146 fnBins.insert(make_pair("ip_reass", ipReassBin)); 147 148 tcpInputBin = new Statistics::MainBin(name() + " tcp_input"); 149 fnBins.insert(make_pair("tcp_input", tcpInputBin)); 150 151 sbappendBin = new Statistics::MainBin(name() + " sbappend"); 152 fnBins.insert(make_pair("sbappend", sbappendBin)); 153 154 readBin = new Statistics::MainBin(name() + " read"); 155 fnBins.insert(make_pair("read", readBin)); 156 157 sooReadBin = new Statistics::MainBin(name() + " soo_read"); 158 fnBins.insert(make_pair("soo_read", sooReadBin)); 159 160 orecvBin = new Statistics::MainBin(name() + " orecv"); 161 fnBins.insert(make_pair("orecv", orecvBin)); 162 163 recvitBin = new Statistics::MainBin(name() + " recvit"); 164 fnBins.insert(make_pair("recvit", recvitBin)); 165 166 soreceiveBin = new Statistics::MainBin(name() + " soreceive"); 167 fnBins.insert(make_pair("soreceive", soreceiveBin)); 168 169 osendBin = new Statistics::MainBin(name() + " osend"); 170 fnBins.insert(make_pair("osend", osendBin)); 171 172 writeBin = new Statistics::MainBin(name() + " write"); 173 fnBins.insert(make_pair("write", writeBin)); 174 175 sooWriteBin = new Statistics::MainBin(name() + " soo_write"); 176 fnBins.insert(make_pair("soo_write", sooWriteBin)); 177 178 senditBin = new Statistics::MainBin(name() + " sendit"); 179 fnBins.insert(make_pair("sendit", senditBin)); 180 181 sosendBin = new Statistics::MainBin(name() + " sosend"); 182 fnBins.insert(make_pair("sosend", sosendBin)); 183 184 tcpSosendBin = new Statistics::MainBin(name() + " tcp_sosend"); 185 fnBins.insert(make_pair("tcp_sosend", tcpSosendBin)); 186 187 tcpOutputBin = new Statistics::MainBin(name() + " tcp_output"); 188 fnBins.insert(make_pair("tcp_output", tcpOutputBin)); 189 190 ipOutputBin = new Statistics::MainBin(name() + " ip_output"); 191 fnBins.insert(make_pair("ip_output", ipOutputBin)); 192 193 etherOutputBin = new Statistics::MainBin(name() + " ether_output"); 194 fnBins.insert(make_pair("ether_output", etherOutputBin)); 195 196 esStartBin = new Statistics::MainBin(name() + " es_start"); 197 fnBins.insert(make_pair("es_start", esStartBin)); 198 199 esTransmitBin = new Statistics::MainBin(name() + " es_transmit"); 200 fnBins.insert(make_pair("es_transmit", esTransmitBin)); 201 202 esTxeofBin = new Statistics::MainBin(name() + " es_txeof"); 203 fnBins.insert(make_pair("es_txeof", esTxeofBin)); 204 205 idleThreadBin = new Statistics::MainBin(name() + " idle_thread"); 206 fnBins.insert(make_pair("idle_thread", idleThreadBin)); 207 208 } 209 //INSTRUMENTATION CODEGEN END 210#endif //FS_MEASURE 211 212 kernelPanicEvent = new BreakPCEvent(&pcEventQueue, "kernel panic"); 213 consolePanicEvent = new BreakPCEvent(&pcEventQueue, "console panic"); 214 badaddrEvent = new LinuxBadAddrEvent(&pcEventQueue, "badaddr"); 215 skipPowerStateEvent = new LinuxSkipFuncEvent(&pcEventQueue, 216 "tl_v48_capture_power_state"); 217 skipScavengeBootEvent = new LinuxSkipFuncEvent(&pcEventQueue, 218 "pmap_scavenge_boot"); 219 printfEvent = new LinuxPrintfEvent(&pcEventQueue, "printf"); 220 /* debugPrintfEvent = new DebugPrintfEvent(&pcEventQueue, 221 "debug_printf", false); 222 debugPrintfrEvent = new DebugPrintfEvent(&pcEventQueue, 223 "debug_printfr", true); 224 dumpMbufEvent = new DumpMbufEvent(&pcEventQueue, "dump_mbuf"); 225*/ 226#ifdef FS_MEASURE 227 //INSTRUMENTATION CODEGEN BEGIN TWO 228 if (bin == true) { 229 esIntrEvent = new FnEvent(&pcEventQueue, "es_intr", this); 230 esRxeofEvent = new FnEvent(&pcEventQueue, "es_rxeof", this); 231 esNewbufEvent = new FnEvent(&pcEventQueue, "es_newbuf", this); 232 esDmaLoadEvent = new FnEvent(&pcEventQueue, "es_dma_load", this); 233 dmaMapLoadEvent = new FnEvent(&pcEventQueue, "dma_map_load", this); 234 etherInputEvent = new FnEvent(&pcEventQueue, "ether_input", this); 235 netisrInputEvent = new FnEvent(&pcEventQueue, "netisr_input", this); 236 schednetisrIsrEvent = new FnEvent(&pcEventQueue, "schednetisr_isr", this); 237 ipintrEvent = new FnEvent(&pcEventQueue, "ipintr", this); 238 ipDooptionsEvent = new FnEvent(&pcEventQueue, "ip_dooptions", this); 239 ipReassEvent = new FnEvent(&pcEventQueue, "ip_reass", this); 240 tcpInputEvent = new FnEvent(&pcEventQueue, "tcp_input", this); 241 sbappendEvent = new FnEvent(&pcEventQueue, "sbappend", this); 242 readEvent = new FnEvent(&pcEventQueue, "read", this); 243 sooReadEvent = new FnEvent(&pcEventQueue, "soo_read", this); 244 orecvEvent = new FnEvent(&pcEventQueue, "orecv", this); 245 recvitEvent = new FnEvent(&pcEventQueue, "recvit", this); 246 soreceiveEvent = new FnEvent(&pcEventQueue, "soreceive", this); 247 osendEvent = new FnEvent(&pcEventQueue, "osend", this); 248 writeEvent = new FnEvent(&pcEventQueue, "write", this); 249 sooWriteEvent = new FnEvent(&pcEventQueue, "soo_write", this); 250 senditEvent = new FnEvent(&pcEventQueue, "sendit", this); 251 sosendEvent = new FnEvent(&pcEventQueue, "sosend", this); 252 tcpSosendEvent = new FnEvent(&pcEventQueue, "tcp_sosend", this); 253 tcpOutputEvent = new FnEvent(&pcEventQueue, "tcp_output", this); 254 ipOutputEvent = new FnEvent(&pcEventQueue, "ip_output", this); 255 etherOutputEvent = new FnEvent(&pcEventQueue, "ether_output", this); 256 esStartEvent = new FnEvent(&pcEventQueue, "es_start", this); 257 esTransmitEvent = new FnEvent(&pcEventQueue, "es_transmit", this); 258 esTxeofEvent = new FnEvent(&pcEventQueue, "es_txeof", this); 259 idleThreadEvent = new FnEvent(&pcEventQueue, "idle_thread", this); 260 } 261 //INSTRUMENTATION CODEGEN END 262#endif //FS_MEASURE 263 264 Addr addr = 0; 265 if (kernelSymtab->findAddress("enable_async_printf", addr)) { 266 Addr paddr = vtophys(physmem, addr); 267 uint8_t *enable_async_printf = 268 physmem->dma_addr(paddr, sizeof(uint32_t)); 269 270 if (enable_async_printf) 271 *(uint32_t *)enable_async_printf = 0; 272 } 273 274 if (consoleSymtab->findAddress("env_booted_osflags", addr)) { 275 Addr paddr = vtophys(physmem, addr); 276 char *osflags = (char *)physmem->dma_addr(paddr, sizeof(uint32_t)); 277 278 if (osflags) 279 strcpy(osflags, boot_osflags.c_str()); 280 } 281 282 if (kernelSymtab->findAddress("panic", addr)) 283 kernelPanicEvent->schedule(addr); 284 else 285 panic("could not find kernel symbol \'panic\'"); 286 287 if (consoleSymtab->findAddress("panic", addr)) 288 consolePanicEvent->schedule(addr); 289 290 if (kernelSymtab->findAddress("badaddr", addr)) 291 badaddrEvent->schedule(addr); 292 // else 293 //panic("could not find kernel symbol \'badaddr\'"); 294 295 if (kernelSymtab->findAddress("tl_v48_capture_power_state", addr)) 296 skipPowerStateEvent->schedule(addr); 297 298 if (kernelSymtab->findAddress("pmap_scavenge_boot", addr)) 299 skipScavengeBootEvent->schedule(addr); 300 301#if TRACING_ON 302 if (kernelSymtab->findAddress("printk", addr)) 303 printfEvent->schedule(addr); 304 305 if (kernelSymtab->findAddress("m5printf", addr)) 306 debugPrintfEvent->schedule(addr); 307 308 if (kernelSymtab->findAddress("m5printfr", addr)) 309 debugPrintfrEvent->schedule(addr); 310 311 if (kernelSymtab->findAddress("m5_dump_mbuf", addr)) 312 dumpMbufEvent->schedule(addr); 313#endif 314 315#ifdef FS_MEASURE 316 //INSTRUMENTATION CODEGEN BEGIN THREE 317 if (bin == true) { 318 if (kernelSymtab->findAddress("es_intr", addr)) 319 esIntrEvent->schedule(addr); 320 else 321 panic("could not find kernel symbol \'es_intr\'"); 322 323 if (kernelSymtab->findAddress("es_rxeof", addr)) 324 esRxeofEvent->schedule(addr); 325 else 326 panic("could not find kernel symbol \'es_rxeof\'"); 327 328 if (kernelSymtab->findAddress("es_newbuf", addr)) 329 esNewbufEvent->schedule(addr); 330 else 331 panic("could not find kernel symbol \'es_newbuf\'"); 332 333 if (kernelSymtab->findAddress("es_dma_load", addr)) 334 esDmaLoadEvent->schedule(addr); 335 else 336 panic("could not find kernel symbol \'es_dma_load\'"); 337 338 if (kernelSymtab->findAddress("dma_map_load", addr)) 339 dmaMapLoadEvent->schedule(addr); 340 else 341 panic("could not find kernel symbol \'dma_map_load\'"); 342 343 if (kernelSymtab->findAddress("ether_input", addr)) 344 etherInputEvent->schedule(addr); 345 else 346 panic("could not find kernel symbol \'ether_input\'"); 347 348 if (kernelSymtab->findAddress("netisr_input", addr)) 349 netisrInputEvent->schedule(addr); 350 else 351 panic("could not find kernel symbol \'netisr_input\'"); 352 353 if (kernelSymtab->findAddress("schednetisr_isr", addr)) 354 schednetisrIsrEvent->schedule(addr); 355 else 356 panic("could not find kernel symbol \'schednetisr_isr\'"); 357 358 if (kernelSymtab->findAddress("ipintr", addr)) 359 ipintrEvent->schedule(addr); 360 else 361 panic("could not find kernel symbol \'ipintr\'"); 362 363 if (kernelSymtab->findAddress("ip_dooptions", addr)) 364 ipDooptionsEvent->schedule(addr); 365 else 366 panic("could not find kernel symbol \'ip_dooptions\'"); 367 368 if (kernelSymtab->findAddress("ip_reass", addr)) 369 ipReassEvent->schedule(addr); 370 else 371 panic("could not find kernel symbol \'ip_reass\'"); 372 373 if (kernelSymtab->findAddress("tcp_input", addr)) 374 tcpInputEvent->schedule(addr); 375 else 376 panic("could not find kernel symbol \'tcp_input\'"); 377 378 if (kernelSymtab->findAddress("sbappend", addr)) 379 sbappendEvent->schedule(addr); 380 else 381 panic("could not find kernel symbol \'sbappend\'"); 382 383 if (kernelSymtab->findAddress("read", addr)) 384 readEvent->schedule(addr); 385 else 386 panic("could not find kernel symbol \'read\'"); 387 388 if (kernelSymtab->findAddress("soo_read", addr)) 389 sooReadEvent->schedule(addr); 390 else 391 panic("could not find kernel symbol \'soo_read\'"); 392 393 if (kernelSymtab->findAddress("orecv", addr)) 394 orecvEvent->schedule(addr); 395 else 396 panic("could not find kernel symbol \'orecv\'"); 397 398 if (kernelSymtab->findAddress("recvit", addr)) 399 recvitEvent->schedule(addr); 400 else 401 panic("could not find kernel symbol \'recvit\'"); 402 403 if (kernelSymtab->findAddress("soreceive", addr)) 404 soreceiveEvent->schedule(addr); 405 else 406 panic("could not find kernel symbol \'soreceive\'"); 407 408 if (kernelSymtab->findAddress("osend", addr)) 409 osendEvent->schedule(addr); 410 else 411 panic("could not find kernel symbol \'osend\'"); 412 413 if (kernelSymtab->findAddress("write", addr)) 414 writeEvent->schedule(addr); 415 else 416 panic("could not find kernel symbol \'write\'"); 417 418 if (kernelSymtab->findAddress("soo_write", addr)) 419 sooWriteEvent->schedule(addr); 420 else 421 panic("could not find kernel symbol \'soo_write\'"); 422 423 if (kernelSymtab->findAddress("sendit", addr)) 424 senditEvent->schedule(addr); 425 else 426 panic("could not find kernel symbol \'sendit\'"); 427 428 if (kernelSymtab->findAddress("sosend", addr)) 429 sosendEvent->schedule(addr); 430 else 431 panic("could not find kernel symbol \'sosend\'"); 432 433 if (kernelSymtab->findAddress("tcp_sosend", addr)) 434 tcpSosendEvent->schedule(addr); 435 else 436 panic("could not find kernel symbol \'tcp_sosend\'"); 437 438 if (kernelSymtab->findAddress("tcp_output", addr)) 439 tcpOutputEvent->schedule(addr); 440 else 441 panic("could not find kernel symbol \'tcp_output\'"); 442 443 if (kernelSymtab->findAddress("ip_output", addr)) 444 ipOutputEvent->schedule(addr); 445 else 446 panic("could not find kernel symbol \'ip_output\'"); 447 448 if (kernelSymtab->findAddress("ether_output", addr)) 449 etherOutputEvent->schedule(addr); 450 else 451 panic("could not find kernel symbol \'ether_output\'"); 452 453 if (kernelSymtab->findAddress("es_start", addr)) 454 esStartEvent->schedule(addr); 455 else 456 panic("could not find kernel symbol \'es_start\'"); 457 458 if (kernelSymtab->findAddress("es_transmit", addr)) 459 esTransmitEvent->schedule(addr); 460 else 461 panic("could not find kernel symbol \'es_transmit\'"); 462 463 if (kernelSymtab->findAddress("es_txeof", addr)) 464 esTxeofEvent->schedule(addr); 465 else 466 panic("could not find kernel symbol \'es_txeof\'"); 467 468 if (kernelSymtab->findAddress("idle_thread", addr)) 469 idleThreadEvent->schedule(addr); 470 else 471 panic("could not find kernel symbol \'idle_thread\'"); 472 473 } 474 //INSTRUMENTATION CODEGEN END 475 if (bin == true) { 476 fnCalls 477 .name(name() + ":fnCalls") 478 .desc("all fn calls being tracked") 479 ; 480 481 populateMap("es_intr", ""); 482 populateMap("es_rxeof", "es_intr"); 483 populateMap("es_newbuf", "es_rxeof"); 484 populateMap("es_dma_load", "es_newbuf"); 485 populateMap("dma_map_load", "es_dma_load"); 486 populateMap("ether_input", "es_rxeof"); 487 populateMap("netisr_input", "ether_input"); 488 populateMap("schednetisr_isr", "netisr_input"); 489 490 populateMap("ipintr", ""); 491 populateMap("ip_dooptions", "ipintr"); 492 populateMap("ip_reass", "ipintr"); 493 populateMap("tcp_input", "ipintr"); 494 populateMap("sbappend", "tcp_input"); 495 496 populateMap("read", ""); 497 populateMap("orecv", ""); 498 populateMap("soo_read", "read"); 499 populateMap("recvit", "orecv"); 500 populateMap("soreceive", "recvit"); 501 populateMap("soreceive", "soo_read"); 502 503 populateMap("write", ""); 504 populateMap("osend", ""); 505 populateMap("soo_write", "write"); 506 populateMap("sendit", "osend"); 507 populateMap("sosend", "sendit"); 508 populateMap("sosend", "soo_write"); 509 populateMap("tcp_sosend", "sosend"); 510 populateMap("tcp_output", "tcp_sosend"); 511 populateMap("ip_output", "tcp_output"); 512 populateMap("ether_output", "ip_output"); 513 populateMap("es_start", "ether_output"); 514 populateMap("es_transmit", "es_start"); 515 516 populateMap("es_txeof", "es_intr"); 517 518 populateMap("idle_thread", ""); 519 } 520#endif //FS_MEASURE 521} 522 523LinuxSystem::~LinuxSystem() 524{ 525 delete kernel; 526 delete console; 527 528 delete kernelSymtab; 529 delete consoleSymtab; 530 delete bootloaderSymtab; 531 532 delete kernelPanicEvent; 533 delete consolePanicEvent; 534 delete badaddrEvent; 535 delete skipPowerStateEvent; 536 delete skipScavengeBootEvent; 537 delete printfEvent; 538 /*delete debugPrintfEvent; 539 delete debugPrintfrEvent; 540 delete dumpMbufEvent; 541*/ 542#ifdef FS_MEASURE 543 //INSTRUMENTATION CODEGEN BEGIN FOUR 544 if (bin == true) { 545 delete esIntrEvent; 546 delete esRxeofEvent; 547 delete esNewbufEvent; 548 delete esDmaLoadEvent; 549 delete dmaMapLoadEvent; 550 delete etherInputEvent; 551 delete netisrInputEvent; 552 delete schednetisrIsrEvent; 553 delete ipintrEvent; 554 delete ipDooptionsEvent; 555 delete ipReassEvent; 556 delete tcpInputEvent; 557 delete sbappendEvent; 558 delete readEvent; 559 delete sooReadEvent; 560 delete orecvEvent; 561 delete recvitEvent; 562 delete soreceiveEvent; 563 delete osendEvent; 564 delete writeEvent; 565 delete sooWriteEvent; 566 delete senditEvent; 567 delete sosendEvent; 568 delete tcpSosendEvent; 569 delete tcpOutputEvent; 570 delete ipOutputEvent; 571 delete etherOutputEvent; 572 delete esStartEvent; 573 delete esTransmitEvent; 574 delete esTxeofEvent; 575 delete idleThreadEvent; 576 } 577 //INSTRUMENTATION CODEGEN END 578#endif //FS_MEASURE 579} 580 581int 582LinuxSystem::registerExecContext(ExecContext *xc) 583{ 584 int xcIndex = System::registerExecContext(xc); 585 586 if (xcIndex == 0) { 587 // activate with zero delay so that we start ticking right 588 // away on cycle 0 589 xc->activate(0); 590 } 591 592 RemoteGDB *rgdb = new RemoteGDB(this, xc); 593 GDBListener *gdbl = new GDBListener(rgdb, 7000 + xcIndex); 594 gdbl->listen(); 595 596 if (remoteGDB.size() <= xcIndex) { 597 remoteGDB.resize(xcIndex+1); 598 } 599 600 remoteGDB[xcIndex] = rgdb; 601 602 return xcIndex; 603} 604 605 606void 607LinuxSystem::replaceExecContext(ExecContext *xc, int xcIndex) 608{ 609 System::replaceExecContext(xcIndex, xc); 610 remoteGDB[xcIndex]->replaceExecContext(xc); 611} 612 613bool 614LinuxSystem::breakpoint() 615{ 616 return remoteGDB[0]->trap(ALPHA_KENTRY_IF); 617} 618 619#ifdef FS_MEASURE 620void 621LinuxSystem::populateMap(std::string callee, std::string caller) 622{ 623 multimap<const string, string>::const_iterator i; 624 i = callerMap.insert(make_pair(callee, caller)); 625 assert(i != callerMap.end() && "should not fail populating callerMap"); 626} 627 628bool 629LinuxSystem::findCaller(std::string callee, std::string caller) const 630{ 631 typedef multimap<const std::string, std::string>::const_iterator iter; 632 pair<iter, iter> range; 633 634 range = callerMap.equal_range(callee); 635 for (iter i = range.first; i != range.second; ++i) { 636 if ((*i).second == caller) 637 return true; 638 } 639 return false; 640} 641 642void 643LinuxSystem::dumpState(ExecContext *xc) const 644{ 645#ifndef SW_DEBUG 646 return; 647#endif 648 if (xc->swCtx) { 649 stack<fnCall *> copy(xc->swCtx->callStack); 650 if (copy.empty()) 651 return; 652 cprintf("xc->swCtx:\n"); 653 fnCall *top; 654 cprintf("|| call: %d\n",xc->swCtx->calls); 655 for (top = copy.top(); !copy.empty(); copy.pop() ) { 656 top = copy.top(); 657 cprintf("|| %13s : %s \n", top->name, top->myBin->name()); 658 } 659 } 660} 661#endif //FS_MEASURE 662 663BEGIN_DECLARE_SIM_OBJECT_PARAMS(LinuxSystem) 664 665 Param<bool> bin; 666 SimObjectParam<MemoryController *> mem_ctl; 667 SimObjectParam<PhysicalMemory *> physmem; 668 Param<uint64_t> init_param; 669 670 Param<string> kernel_code; 671 Param<string> console_code; 672 Param<string> pal_code; 673 Param<string> boot_osflags; 674 Param<string> bootloader_code; 675 676END_DECLARE_SIM_OBJECT_PARAMS(LinuxSystem) 677 678BEGIN_INIT_SIM_OBJECT_PARAMS(LinuxSystem) 679 680 INIT_PARAM_DFLT(bin, "is this system to be binned", false), 681 INIT_PARAM(mem_ctl, "memory controller"), 682 INIT_PARAM(physmem, "phsyical memory"), 683 INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0), 684 INIT_PARAM(kernel_code, "file that contains the kernel code"), 685 INIT_PARAM(console_code, "file that contains the console code"), 686 INIT_PARAM(pal_code, "file that contains palcode"), 687 INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", 688 "a"), 689 INIT_PARAM(bootloader_code, "file that contains the bootloader") 690 691 692END_INIT_SIM_OBJECT_PARAMS(LinuxSystem) 693 694CREATE_SIM_OBJECT(LinuxSystem) 695{ 696 LinuxSystem *sys = new LinuxSystem(getInstanceName(), init_param, mem_ctl, 697 physmem, kernel_code, console_code, 698 pal_code, boot_osflags, bootloader_code, bin); 699 700 return sys; 701} 702 703REGISTER_SIM_OBJECT("LinuxSystem", LinuxSystem) 704