system.cc revision 848
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 "cpu/base_cpu.hh" 37#include "kern/linux/linux_events.hh" 38#include "kern/linux/linux_system.hh" 39#include "mem/functional_mem/memory_control.hh" 40#include "mem/functional_mem/physical_memory.hh" 41#include "sim/builder.hh" 42#include "dev/platform.hh" 43#include "targetarch/isa_traits.hh" 44#include "targetarch/vtophys.hh" 45 46extern SymbolTable *debugSymbolTable; 47 48//un-comment this to see the state of call stack when it changes. 49//#define SW_DEBUG 50 51using namespace std; 52 53LinuxSystem::LinuxSystem(const string _name, const uint64_t _init_param, 54 MemoryController *_memCtrl, PhysicalMemory *_physmem, 55 const string &kernel_path, const string &console_path, 56 const string &palcode, const string &boot_osflags, 57 const string &bootloader_path, const bool _bin) 58 : System(_name, _init_param, _memCtrl, _physmem, _bin), bin(_bin) 59{ 60 kernelSymtab = new SymbolTable; 61 consoleSymtab = new SymbolTable; 62 bootloaderSymtab = new SymbolTable; 63 64 ObjectFile *kernel = createObjectFile(kernel_path); 65 if (kernel == NULL) 66 fatal("Could not load kernel file %s", kernel_path); 67 68 ObjectFile *console = createObjectFile(console_path); 69 if (console == NULL) 70 fatal("Could not load console file %s", console_path); 71 72 ObjectFile *bootloader = createObjectFile(bootloader_path); 73 if (bootloader == NULL) 74 fatal("Could not load bootloader file %s", bootloader_path); 75 76 if (!kernel->loadGlobalSymbols(kernelSymtab)) 77 panic("could not load kernel symbols\n"); 78 debugSymbolTable = kernelSymtab; 79 80 if (!kernel->loadLocalSymbols(kernelSymtab)) 81 panic("could not load kernel local symbols\n"); 82 83 if (!console->loadGlobalSymbols(consoleSymtab)) 84 panic("could not load console symbols\n"); 85 86 if (!bootloader->loadGlobalSymbols(bootloaderSymtab)) 87 panic("could not load bootloader symbols\n"); 88 89 // Load pal file 90 ObjectFile *pal = createObjectFile(palcode); 91 if (pal == NULL) 92 fatal("Could not load PALcode file %s", palcode); 93 pal->loadSections(physmem, true); 94 95 // Load console file 96 console->loadSections(physmem, true); 97 98 // Load kernel file 99 kernel->loadSections(physmem, true); 100 kernelStart = kernel->textBase(); 101 kernelEnd = kernel->bssBase() + kernel->bssSize(); 102 /* FIXME: entrypoint not in kernel, but in bootloader, 103 variable should be re-named appropriately */ 104 kernelEntry = kernel->entryPoint(); 105 106 107 DPRINTF(Loader, "Kernel start = %#x\n" 108 "Kernel end = %#x\n" 109 "Kernel entry = %#x\n", 110 kernelStart, kernelEnd, kernelEntry); 111 112 DPRINTF(Loader, "Kernel loaded...\n"); 113 114 // Load bootloader file 115 bootloader->loadSections(physmem, true); 116 kernelEntry = bootloader->entryPoint(); 117 kernelStart = bootloader->textBase(); 118 DPRINTF(Loader, "Bootloader entry at %#x\n", kernelEntry); 119 120 //INSTRUMENTATION CODEGEN BEGIN ONE 121 if (bin == true) { 122 esIntrBin = new Statistics::MainBin(name() + " es_intr"); 123 fnBins.insert(make_pair("es_intr", esIntrBin)); 124 125 esRxeofBin = new Statistics::MainBin(name() + " es_rxeof"); 126 fnBins.insert(make_pair("es_rxeof", esRxeofBin)); 127 128 esNewbufBin = new Statistics::MainBin(name() + " es_newbuf"); 129 fnBins.insert(make_pair("es_newbuf", esNewbufBin)); 130 131 esDmaLoadBin = new Statistics::MainBin(name() + " es_dma_load"); 132 fnBins.insert(make_pair("es_dma_load", esDmaLoadBin)); 133 134 dmaMapLoadBin = new Statistics::MainBin(name() + " dma_map_load"); 135 fnBins.insert(make_pair("dma_map_load", dmaMapLoadBin)); 136 137 etherInputBin = new Statistics::MainBin(name() + " ether_input"); 138 fnBins.insert(make_pair("ether_input", etherInputBin)); 139 140 netisrInputBin = new Statistics::MainBin(name() + " netisr_input"); 141 fnBins.insert(make_pair("netisr_input", netisrInputBin)); 142 143 schednetisrIsrBin = new Statistics::MainBin(name() + " schednetisr_isr"); 144 fnBins.insert(make_pair("schednetisr_isr", schednetisrIsrBin)); 145 146 ipintrBin = new Statistics::MainBin(name() + " ipintr"); 147 fnBins.insert(make_pair("ipintr", ipintrBin)); 148 149 ipDooptionsBin = new Statistics::MainBin(name() + " ip_dooptions"); 150 fnBins.insert(make_pair("ip_dooptions", ipDooptionsBin)); 151 152 ipReassBin = new Statistics::MainBin(name() + " ip_reass"); 153 fnBins.insert(make_pair("ip_reass", ipReassBin)); 154 155 tcpInputBin = new Statistics::MainBin(name() + " tcp_input"); 156 fnBins.insert(make_pair("tcp_input", tcpInputBin)); 157 158 sbappendBin = new Statistics::MainBin(name() + " sbappend"); 159 fnBins.insert(make_pair("sbappend", sbappendBin)); 160 161 readBin = new Statistics::MainBin(name() + " read"); 162 fnBins.insert(make_pair("read", readBin)); 163 164 sooReadBin = new Statistics::MainBin(name() + " soo_read"); 165 fnBins.insert(make_pair("soo_read", sooReadBin)); 166 167 orecvBin = new Statistics::MainBin(name() + " orecv"); 168 fnBins.insert(make_pair("orecv", orecvBin)); 169 170 recvitBin = new Statistics::MainBin(name() + " recvit"); 171 fnBins.insert(make_pair("recvit", recvitBin)); 172 173 soreceiveBin = new Statistics::MainBin(name() + " soreceive"); 174 fnBins.insert(make_pair("soreceive", soreceiveBin)); 175 176 osendBin = new Statistics::MainBin(name() + " osend"); 177 fnBins.insert(make_pair("osend", osendBin)); 178 179 writeBin = new Statistics::MainBin(name() + " write"); 180 fnBins.insert(make_pair("write", writeBin)); 181 182 sooWriteBin = new Statistics::MainBin(name() + " soo_write"); 183 fnBins.insert(make_pair("soo_write", sooWriteBin)); 184 185 senditBin = new Statistics::MainBin(name() + " sendit"); 186 fnBins.insert(make_pair("sendit", senditBin)); 187 188 sosendBin = new Statistics::MainBin(name() + " sosend"); 189 fnBins.insert(make_pair("sosend", sosendBin)); 190 191 tcpSosendBin = new Statistics::MainBin(name() + " tcp_sosend"); 192 fnBins.insert(make_pair("tcp_sosend", tcpSosendBin)); 193 194 tcpOutputBin = new Statistics::MainBin(name() + " tcp_output"); 195 fnBins.insert(make_pair("tcp_output", tcpOutputBin)); 196 197 ipOutputBin = new Statistics::MainBin(name() + " ip_output"); 198 fnBins.insert(make_pair("ip_output", ipOutputBin)); 199 200 etherOutputBin = new Statistics::MainBin(name() + " ether_output"); 201 fnBins.insert(make_pair("ether_output", etherOutputBin)); 202 203 esStartBin = new Statistics::MainBin(name() + " es_start"); 204 fnBins.insert(make_pair("es_start", esStartBin)); 205 206 esTransmitBin = new Statistics::MainBin(name() + " es_transmit"); 207 fnBins.insert(make_pair("es_transmit", esTransmitBin)); 208 209 esTxeofBin = new Statistics::MainBin(name() + " es_txeof"); 210 fnBins.insert(make_pair("es_txeof", esTxeofBin)); 211 212 idleThreadBin = new Statistics::MainBin(name() + " idle_thread"); 213 fnBins.insert(make_pair("idle_thread", idleThreadBin)); 214 215 } 216 //INSTRUMENTATION CODEGEN END 217 218 kernelPanicEvent = new BreakPCEvent(&pcEventQueue, "kernel panic"); 219 consolePanicEvent = new BreakPCEvent(&pcEventQueue, "console panic"); 220 badaddrEvent = new LinuxBadAddrEvent(&pcEventQueue, "badaddr"); 221 skipPowerStateEvent = new LinuxSkipFuncEvent(&pcEventQueue, 222 "tl_v48_capture_power_state"); 223 skipScavengeBootEvent = new LinuxSkipFuncEvent(&pcEventQueue, 224 "pmap_scavenge_boot"); 225 printfEvent = new LinuxPrintfEvent(&pcEventQueue, "printf"); 226 227 skipIdeDelay50msEvent = new LinuxSkipIdeDelay50msEvent(&pcEventQueue, 228 "ide_delay_50ms"); 229 230 skipDelayLoopEvent = new LinuxSkipDelayLoopEvent(&pcEventQueue, 231 "calibrate_delay"); 232 233 /* debugPrintfEvent = new DebugPrintfEvent(&pcEventQueue, 234 "debug_printf", false); 235 debugPrintfrEvent = new DebugPrintfEvent(&pcEventQueue, 236 "debug_printfr", true); 237 dumpMbufEvent = new DumpMbufEvent(&pcEventQueue, "dump_mbuf"); 238*/ 239#ifdef FS_MEASURE 240 //INSTRUMENTATION CODEGEN BEGIN TWO 241 if (bin == true) { 242 esIntrEvent = new LinuxFnEvent(&pcEventQueue, "es_intr", this); 243 esRxeofEvent = new LinuxFnEvent(&pcEventQueue, "es_rxeof", this); 244 esNewbufEvent = new LinuxFnEvent(&pcEventQueue, "es_newbuf", this); 245 esDmaLoadEvent = new LinuxFnEvent(&pcEventQueue, "es_dma_load", this); 246 dmaMapLoadEvent = new LinuxFnEvent(&pcEventQueue, "dma_map_load", this); 247 etherInputEvent = new LinuxFnEvent(&pcEventQueue, "ether_input", this); 248 netisrInputEvent = new LinuxFnEvent(&pcEventQueue, "netisr_input", this); 249 schednetisrIsrEvent = new LinuxFnEvent(&pcEventQueue, "schednetisr_isr", this); 250 ipintrEvent = new LinuxFnEvent(&pcEventQueue, "ipintr", this); 251 ipDooptionsEvent = new LinuxFnEvent(&pcEventQueue, "ip_dooptions", this); 252 ipReassEvent = new LinuxFnEvent(&pcEventQueue, "ip_reass", this); 253 tcpInputEvent = new LinuxFnEvent(&pcEventQueue, "tcp_input", this); 254 sbappendEvent = new LinuxFnEvent(&pcEventQueue, "sbappend", this); 255 readEvent = new LinuxFnEvent(&pcEventQueue, "read", this); 256 sooReadEvent = new LinuxFnEvent(&pcEventQueue, "soo_read", this); 257 orecvEvent = new LinuxFnEvent(&pcEventQueue, "orecv", this); 258 recvitEvent = new LinuxFnEvent(&pcEventQueue, "recvit", this); 259 soreceiveEvent = new LinuxFnEvent(&pcEventQueue, "soreceive", this); 260 osendEvent = new LinuxFnEvent(&pcEventQueue, "osend", this); 261 writeEvent = new LinuxFnEvent(&pcEventQueue, "write", this); 262 sooWriteEvent = new LinuxFnEvent(&pcEventQueue, "soo_write", this); 263 senditEvent = new LinuxFnEvent(&pcEventQueue, "sendit", this); 264 sosendEvent = new LinuxFnEvent(&pcEventQueue, "sosend", this); 265 tcpSosendEvent = new LinuxFnEvent(&pcEventQueue, "tcp_sosend", this); 266 tcpOutputEvent = new LinuxFnEvent(&pcEventQueue, "tcp_output", this); 267 ipOutputEvent = new LinuxFnEvent(&pcEventQueue, "ip_output", this); 268 etherOutputEvent = new LinuxFnEvent(&pcEventQueue, "ether_output", this); 269 esStartEvent = new LinuxFnEvent(&pcEventQueue, "es_start", this); 270 esTransmitEvent = new LinuxFnEvent(&pcEventQueue, "es_transmit", this); 271 esTxeofEvent = new LinuxFnEvent(&pcEventQueue, "es_txeof", this); 272 idleThreadEvent = new LinuxFnEvent(&pcEventQueue, "idle_thread", this); 273 } 274 //INSTRUMENTATION CODEGEN END 275#endif //FS_MEASURE 276 277 Addr addr = 0; 278 279 if (kernelSymtab->findAddress("est_cycle_freq", addr)) { 280 Addr paddr = vtophys(physmem, addr); 281 uint8_t *est_cycle_frequency = 282 physmem->dma_addr(paddr, sizeof(uint64_t)); 283 284 if (est_cycle_frequency) 285 *(uint64_t *)est_cycle_frequency = ticksPerSecond; 286 } 287 288 if (kernelSymtab->findAddress("aic7xxx_no_reset", addr)) { 289 Addr paddr = vtophys(physmem, addr); 290 uint8_t *aic7xxx_no_reset = 291 physmem->dma_addr(paddr, sizeof(uint32_t)); 292 293 if (aic7xxx_no_reset) { 294 *(uint32_t *)aic7xxx_no_reset = 1; 295 } 296 } 297 298 if (consoleSymtab->findAddress("env_booted_osflags", addr)) { 299 Addr paddr = vtophys(physmem, addr); 300 char *osflags = (char *)physmem->dma_addr(paddr, sizeof(uint32_t)); 301 302 if (osflags) 303 strcpy(osflags, boot_osflags.c_str()); 304 } 305 306 if (consoleSymtab->findAddress("xxm_rpb", addr)) { 307 Addr paddr = vtophys(physmem, addr); 308 char *hwprb = (char *)physmem->dma_addr(paddr, sizeof(uint64_t)); 309 310 if (hwprb) { 311 *(uint64_t*)(hwprb+0x50) = 34; // Tsunami 312 *(uint64_t*)(hwprb+0x58) = (1<<10); 313 } 314 else 315 panic("could not translate hwprb addr to set system type/variation\n"); 316 317 } else 318 panic("could not find hwprb to set system type/variation\n"); 319 320 if (kernelSymtab->findAddress("panic", addr)) 321 kernelPanicEvent->schedule(addr); 322 else 323 panic("could not find kernel symbol \'panic\'"); 324 325 if (consoleSymtab->findAddress("panic", addr)) 326 consolePanicEvent->schedule(addr); 327 328 if (kernelSymtab->findAddress("badaddr", addr)) 329 badaddrEvent->schedule(addr); 330 // else 331 //panic("could not find kernel symbol \'badaddr\'"); 332 333 if (kernelSymtab->findAddress("tl_v48_capture_power_state", addr)) 334 skipPowerStateEvent->schedule(addr); 335 336 if (kernelSymtab->findAddress("pmap_scavenge_boot", addr)) 337 skipScavengeBootEvent->schedule(addr); 338 339 if (kernelSymtab->findAddress("ide_delay_50ms", addr)) 340 skipIdeDelay50msEvent->schedule(addr+8); 341 342 if (kernelSymtab->findAddress("calibrate_delay", addr)) 343 skipDelayLoopEvent->schedule(addr+8); 344 345#if TRACING_ON 346 if (kernelSymtab->findAddress("printk", addr)) 347 printfEvent->schedule(addr); 348 349 if (kernelSymtab->findAddress("m5printf", addr)) 350 debugPrintfEvent->schedule(addr); 351 352 if (kernelSymtab->findAddress("m5printfr", addr)) 353 debugPrintfrEvent->schedule(addr); 354 355 if (kernelSymtab->findAddress("m5_dump_mbuf", addr)) 356 dumpMbufEvent->schedule(addr); 357#endif 358 359#ifdef FS_MEASURE 360 //INSTRUMENTATION CODEGEN BEGIN THREE 361 if (bin == true) { 362 if (kernelSymtab->findAddress("es_intr", addr)) 363 esIntrEvent->schedule(addr); 364 else 365 panic("could not find kernel symbol \'es_intr\'"); 366 367 if (kernelSymtab->findAddress("es_rxeof", addr)) 368 esRxeofEvent->schedule(addr); 369 else 370 panic("could not find kernel symbol \'es_rxeof\'"); 371 372 if (kernelSymtab->findAddress("es_newbuf", addr)) 373 esNewbufEvent->schedule(addr); 374 else 375 panic("could not find kernel symbol \'es_newbuf\'"); 376 377 if (kernelSymtab->findAddress("es_dma_load", addr)) 378 esDmaLoadEvent->schedule(addr); 379 else 380 panic("could not find kernel symbol \'es_dma_load\'"); 381 382 if (kernelSymtab->findAddress("dma_map_load", addr)) 383 dmaMapLoadEvent->schedule(addr); 384 else 385 panic("could not find kernel symbol \'dma_map_load\'"); 386 387 if (kernelSymtab->findAddress("ether_input", addr)) 388 etherInputEvent->schedule(addr); 389 else 390 panic("could not find kernel symbol \'ether_input\'"); 391 392 if (kernelSymtab->findAddress("netisr_input", addr)) 393 netisrInputEvent->schedule(addr); 394 else 395 panic("could not find kernel symbol \'netisr_input\'"); 396 397 if (kernelSymtab->findAddress("schednetisr_isr", addr)) 398 schednetisrIsrEvent->schedule(addr); 399 else 400 panic("could not find kernel symbol \'schednetisr_isr\'"); 401 402 if (kernelSymtab->findAddress("ipintr", addr)) 403 ipintrEvent->schedule(addr); 404 else 405 panic("could not find kernel symbol \'ipintr\'"); 406 407 if (kernelSymtab->findAddress("ip_dooptions", addr)) 408 ipDooptionsEvent->schedule(addr); 409 else 410 panic("could not find kernel symbol \'ip_dooptions\'"); 411 412 if (kernelSymtab->findAddress("ip_reass", addr)) 413 ipReassEvent->schedule(addr); 414 else 415 panic("could not find kernel symbol \'ip_reass\'"); 416 417 if (kernelSymtab->findAddress("tcp_input", addr)) 418 tcpInputEvent->schedule(addr); 419 else 420 panic("could not find kernel symbol \'tcp_input\'"); 421 422 if (kernelSymtab->findAddress("sbappend", addr)) 423 sbappendEvent->schedule(addr); 424 else 425 panic("could not find kernel symbol \'sbappend\'"); 426 427 if (kernelSymtab->findAddress("read", addr)) 428 readEvent->schedule(addr); 429 else 430 panic("could not find kernel symbol \'read\'"); 431 432 if (kernelSymtab->findAddress("soo_read", addr)) 433 sooReadEvent->schedule(addr); 434 else 435 panic("could not find kernel symbol \'soo_read\'"); 436 437 if (kernelSymtab->findAddress("orecv", addr)) 438 orecvEvent->schedule(addr); 439 else 440 panic("could not find kernel symbol \'orecv\'"); 441 442 if (kernelSymtab->findAddress("recvit", addr)) 443 recvitEvent->schedule(addr); 444 else 445 panic("could not find kernel symbol \'recvit\'"); 446 447 if (kernelSymtab->findAddress("soreceive", addr)) 448 soreceiveEvent->schedule(addr); 449 else 450 panic("could not find kernel symbol \'soreceive\'"); 451 452 if (kernelSymtab->findAddress("osend", addr)) 453 osendEvent->schedule(addr); 454 else 455 panic("could not find kernel symbol \'osend\'"); 456 457 if (kernelSymtab->findAddress("write", addr)) 458 writeEvent->schedule(addr); 459 else 460 panic("could not find kernel symbol \'write\'"); 461 462 if (kernelSymtab->findAddress("soo_write", addr)) 463 sooWriteEvent->schedule(addr); 464 else 465 panic("could not find kernel symbol \'soo_write\'"); 466 467 if (kernelSymtab->findAddress("sendit", addr)) 468 senditEvent->schedule(addr); 469 else 470 panic("could not find kernel symbol \'sendit\'"); 471 472 if (kernelSymtab->findAddress("sosend", addr)) 473 sosendEvent->schedule(addr); 474 else 475 panic("could not find kernel symbol \'sosend\'"); 476 477 if (kernelSymtab->findAddress("tcp_sosend", addr)) 478 tcpSosendEvent->schedule(addr); 479 else 480 panic("could not find kernel symbol \'tcp_sosend\'"); 481 482 if (kernelSymtab->findAddress("tcp_output", addr)) 483 tcpOutputEvent->schedule(addr); 484 else 485 panic("could not find kernel symbol \'tcp_output\'"); 486 487 if (kernelSymtab->findAddress("ip_output", addr)) 488 ipOutputEvent->schedule(addr); 489 else 490 panic("could not find kernel symbol \'ip_output\'"); 491 492 if (kernelSymtab->findAddress("ether_output", addr)) 493 etherOutputEvent->schedule(addr); 494 else 495 panic("could not find kernel symbol \'ether_output\'"); 496 497 if (kernelSymtab->findAddress("es_start", addr)) 498 esStartEvent->schedule(addr); 499 else 500 panic("could not find kernel symbol \'es_start\'"); 501 502 if (kernelSymtab->findAddress("es_transmit", addr)) 503 esTransmitEvent->schedule(addr); 504 else 505 panic("could not find kernel symbol \'es_transmit\'"); 506 507 if (kernelSymtab->findAddress("es_txeof", addr)) 508 esTxeofEvent->schedule(addr); 509 else 510 panic("could not find kernel symbol \'es_txeof\'"); 511 512 if (kernelSymtab->findAddress("idle_thread", addr)) 513 idleThreadEvent->schedule(addr); 514 else 515 panic("could not find kernel symbol \'idle_thread\'"); 516 517 } 518 //INSTRUMENTATION CODEGEN END 519 if (bin == true) { 520 fnCalls 521 .name(name() + ":fnCalls") 522 .desc("all fn calls being tracked") 523 ; 524 525 populateMap("es_intr", ""); 526 populateMap("es_rxeof", "es_intr"); 527 populateMap("es_newbuf", "es_rxeof"); 528 populateMap("es_dma_load", "es_newbuf"); 529 populateMap("dma_map_load", "es_dma_load"); 530 populateMap("ether_input", "es_rxeof"); 531 populateMap("netisr_input", "ether_input"); 532 populateMap("schednetisr_isr", "netisr_input"); 533 534 populateMap("ipintr", ""); 535 populateMap("ip_dooptions", "ipintr"); 536 populateMap("ip_reass", "ipintr"); 537 populateMap("tcp_input", "ipintr"); 538 populateMap("sbappend", "tcp_input"); 539 540 populateMap("read", ""); 541 populateMap("orecv", ""); 542 populateMap("soo_read", "read"); 543 populateMap("recvit", "orecv"); 544 populateMap("soreceive", "recvit"); 545 populateMap("soreceive", "soo_read"); 546 547 populateMap("write", ""); 548 populateMap("osend", ""); 549 populateMap("soo_write", "write"); 550 populateMap("sendit", "osend"); 551 populateMap("sosend", "sendit"); 552 populateMap("sosend", "soo_write"); 553 populateMap("tcp_sosend", "sosend"); 554 populateMap("tcp_output", "tcp_sosend"); 555 populateMap("ip_output", "tcp_output"); 556 populateMap("ether_output", "ip_output"); 557 populateMap("es_start", "ether_output"); 558 populateMap("es_transmit", "es_start"); 559 560 populateMap("es_txeof", "es_intr"); 561 562 populateMap("idle_thread", ""); 563 } 564#endif //FS_MEASURE 565} 566 567LinuxSystem::~LinuxSystem() 568{ 569 delete kernel; 570 delete console; 571 572 delete kernelSymtab; 573 delete consoleSymtab; 574 delete bootloaderSymtab; 575 576 delete kernelPanicEvent; 577 delete consolePanicEvent; 578 delete badaddrEvent; 579 delete skipPowerStateEvent; 580 delete skipScavengeBootEvent; 581 delete printfEvent; 582 /*delete debugPrintfEvent; 583 delete debugPrintfrEvent; 584 delete dumpMbufEvent; 585*/ 586#ifdef FS_MEASURE 587 //INSTRUMENTATION CODEGEN BEGIN FOUR 588 if (bin == true) { 589 delete esIntrEvent; 590 delete esRxeofEvent; 591 delete esNewbufEvent; 592 delete esDmaLoadEvent; 593 delete dmaMapLoadEvent; 594 delete etherInputEvent; 595 delete netisrInputEvent; 596 delete schednetisrIsrEvent; 597 delete ipintrEvent; 598 delete ipDooptionsEvent; 599 delete ipReassEvent; 600 delete tcpInputEvent; 601 delete sbappendEvent; 602 delete readEvent; 603 delete sooReadEvent; 604 delete orecvEvent; 605 delete recvitEvent; 606 delete soreceiveEvent; 607 delete osendEvent; 608 delete writeEvent; 609 delete sooWriteEvent; 610 delete senditEvent; 611 delete sosendEvent; 612 delete tcpSosendEvent; 613 delete tcpOutputEvent; 614 delete ipOutputEvent; 615 delete etherOutputEvent; 616 delete esStartEvent; 617 delete esTransmitEvent; 618 delete esTxeofEvent; 619 delete idleThreadEvent; 620 } 621 //INSTRUMENTATION CODEGEN END 622#endif //FS_MEASURE 623} 624 625void 626LinuxSystem::setDelayLoop(ExecContext *xc) 627{ 628 Addr addr = 0; 629 if (kernelSymtab->findAddress("loops_per_jiffy", addr)) { 630 Addr paddr = vtophys(physmem, addr); 631 632 uint8_t *loops_per_jiffy = 633 physmem->dma_addr(paddr, sizeof(uint32_t)); 634 635 Tick cpuFreq = xc->cpu->getFreq(); 636 Tick intrFreq = platform->interrupt_frequency; 637 *(uint32_t *)loops_per_jiffy = 638 (uint32_t)((cpuFreq / intrFreq) * 0.9988); 639 } 640} 641 642int 643LinuxSystem::registerExecContext(ExecContext *xc) 644{ 645 int xcIndex = System::registerExecContext(xc); 646 647 if (xcIndex == 0) { 648 // activate with zero delay so that we start ticking right 649 // away on cycle 0 650 xc->activate(0); 651 } 652 653 RemoteGDB *rgdb = new RemoteGDB(this, xc); 654 GDBListener *gdbl = new GDBListener(rgdb, 7000 + xcIndex); 655 gdbl->listen(); 656 657 if (remoteGDB.size() <= xcIndex) { 658 remoteGDB.resize(xcIndex+1); 659 } 660 661 remoteGDB[xcIndex] = rgdb; 662 663 return xcIndex; 664} 665 666 667void 668LinuxSystem::replaceExecContext(ExecContext *xc, int xcIndex) 669{ 670 System::replaceExecContext(xcIndex, xc); 671 remoteGDB[xcIndex]->replaceExecContext(xc); 672} 673 674bool 675LinuxSystem::breakpoint() 676{ 677 return remoteGDB[0]->trap(ALPHA_KENTRY_IF); 678} 679 680void 681LinuxSystem::populateMap(std::string callee, std::string caller) 682{ 683 multimap<const string, string>::const_iterator i; 684 i = callerMap.insert(make_pair(callee, caller)); 685 assert(i != callerMap.end() && "should not fail populating callerMap"); 686} 687 688bool 689LinuxSystem::findCaller(std::string callee, std::string caller) const 690{ 691 typedef multimap<const std::string, std::string>::const_iterator iter; 692 pair<iter, iter> range; 693 694 range = callerMap.equal_range(callee); 695 for (iter i = range.first; i != range.second; ++i) { 696 if ((*i).second == caller) 697 return true; 698 } 699 return false; 700} 701 702void 703LinuxSystem::dumpState(ExecContext *xc) const 704{ 705#ifndef SW_DEBUG 706 return; 707#endif 708 if (xc->swCtx) { 709 stack<fnCall *> copy(xc->swCtx->callStack); 710 if (copy.empty()) 711 return; 712 cprintf("xc->swCtx:\n"); 713 fnCall *top; 714 cprintf("|| call: %d\n",xc->swCtx->calls); 715 for (top = copy.top(); !copy.empty(); copy.pop() ) { 716 top = copy.top(); 717 cprintf("|| %13s : %s \n", top->name, top->myBin->name()); 718 } 719 } 720} 721 722BEGIN_DECLARE_SIM_OBJECT_PARAMS(LinuxSystem) 723 724 Param<bool> bin; 725 SimObjectParam<MemoryController *> mem_ctl; 726 SimObjectParam<PhysicalMemory *> physmem; 727 Param<uint64_t> init_param; 728 729 Param<string> kernel_code; 730 Param<string> console_code; 731 Param<string> pal_code; 732 Param<string> boot_osflags; 733 Param<string> bootloader_code; 734 735END_DECLARE_SIM_OBJECT_PARAMS(LinuxSystem) 736 737BEGIN_INIT_SIM_OBJECT_PARAMS(LinuxSystem) 738 739 INIT_PARAM_DFLT(bin, "is this system to be binned", false), 740 INIT_PARAM(mem_ctl, "memory controller"), 741 INIT_PARAM(physmem, "phsyical memory"), 742 INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0), 743 INIT_PARAM(kernel_code, "file that contains the kernel code"), 744 INIT_PARAM(console_code, "file that contains the console code"), 745 INIT_PARAM(pal_code, "file that contains palcode"), 746 INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", 747 "a"), 748 INIT_PARAM(bootloader_code, "file that contains the bootloader") 749 750 751END_INIT_SIM_OBJECT_PARAMS(LinuxSystem) 752 753CREATE_SIM_OBJECT(LinuxSystem) 754{ 755 LinuxSystem *sys = new LinuxSystem(getInstanceName(), init_param, mem_ctl, 756 physmem, kernel_code, console_code, 757 pal_code, boot_osflags, bootloader_code, bin); 758 759 return sys; 760} 761 762REGISTER_SIM_OBJECT("LinuxSystem", LinuxSystem) 763