process.cc (7487:2a5e4070155e) | process.cc (7488:cf7c4345ea82) |
---|---|
1/* 2 * Copyright (c) 2001-2005 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; --- 482 unchanged lines hidden (view full) --- 491 UNSERIALIZE_SCALAR(flags); 492 UNSERIALIZE_SCALAR(readPipeSource); 493 UNSERIALIZE_SCALAR(fileOffset); 494} 495 496void 497Process::serialize(std::ostream &os) 498{ | 1/* 2 * Copyright (c) 2001-2005 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; --- 482 unchanged lines hidden (view full) --- 491 UNSERIALIZE_SCALAR(flags); 492 UNSERIALIZE_SCALAR(readPipeSource); 493 UNSERIALIZE_SCALAR(fileOffset); 494} 495 496void 497Process::serialize(std::ostream &os) 498{ |
499 SERIALIZE_SCALAR(initialContextLoaded); | |
500 SERIALIZE_SCALAR(brk_point); 501 SERIALIZE_SCALAR(stack_base); 502 SERIALIZE_SCALAR(stack_size); 503 SERIALIZE_SCALAR(stack_min); 504 SERIALIZE_SCALAR(next_thread_stack_base); 505 SERIALIZE_SCALAR(mmap_start); 506 SERIALIZE_SCALAR(mmap_end); 507 SERIALIZE_SCALAR(nxm_start); --- 6 unchanged lines hidden (view full) --- 514 } 515 SERIALIZE_SCALAR(M5_pid); 516 517} 518 519void 520Process::unserialize(Checkpoint *cp, const std::string §ion) 521{ | 499 SERIALIZE_SCALAR(brk_point); 500 SERIALIZE_SCALAR(stack_base); 501 SERIALIZE_SCALAR(stack_size); 502 SERIALIZE_SCALAR(stack_min); 503 SERIALIZE_SCALAR(next_thread_stack_base); 504 SERIALIZE_SCALAR(mmap_start); 505 SERIALIZE_SCALAR(mmap_end); 506 SERIALIZE_SCALAR(nxm_start); --- 6 unchanged lines hidden (view full) --- 513 } 514 SERIALIZE_SCALAR(M5_pid); 515 516} 517 518void 519Process::unserialize(Checkpoint *cp, const std::string §ion) 520{ |
522 UNSERIALIZE_SCALAR(initialContextLoaded); | |
523 UNSERIALIZE_SCALAR(brk_point); 524 UNSERIALIZE_SCALAR(stack_base); 525 UNSERIALIZE_SCALAR(stack_size); 526 UNSERIALIZE_SCALAR(stack_min); 527 UNSERIALIZE_SCALAR(next_thread_stack_base); 528 UNSERIALIZE_SCALAR(mmap_start); 529 UNSERIALIZE_SCALAR(mmap_end); 530 UNSERIALIZE_SCALAR(nxm_start); --- 43 unchanged lines hidden (view full) --- 574 // didn't load any symbols 575 delete debugSymbolTable; 576 debugSymbolTable = NULL; 577 } 578 } 579} 580 581void | 521 UNSERIALIZE_SCALAR(brk_point); 522 UNSERIALIZE_SCALAR(stack_base); 523 UNSERIALIZE_SCALAR(stack_size); 524 UNSERIALIZE_SCALAR(stack_min); 525 UNSERIALIZE_SCALAR(next_thread_stack_base); 526 UNSERIALIZE_SCALAR(mmap_start); 527 UNSERIALIZE_SCALAR(mmap_end); 528 UNSERIALIZE_SCALAR(nxm_start); --- 43 unchanged lines hidden (view full) --- 572 // didn't load any symbols 573 delete debugSymbolTable; 574 debugSymbolTable = NULL; 575 } 576 } 577} 578 579void |
582LiveProcess::argsInit(int intSize, int pageSize) 583{ 584 Process::startup(); 585 586 // load object file into target memory 587 objFile->loadSections(initVirtMem); 588 589 // Calculate how much space we need for arg & env arrays. 590 int argv_array_size = intSize * (argv.size() + 1); 591 int envp_array_size = intSize * (envp.size() + 1); 592 int arg_data_size = 0; 593 for (vector<string>::size_type i = 0; i < argv.size(); ++i) { 594 arg_data_size += argv[i].size() + 1; 595 } 596 int env_data_size = 0; 597 for (vector<string>::size_type i = 0; i < envp.size(); ++i) { 598 env_data_size += envp[i].size() + 1; 599 } 600 601 int space_needed = 602 argv_array_size + envp_array_size + arg_data_size + env_data_size; 603 if (space_needed < 32*1024) 604 space_needed = 32*1024; 605 606 // set bottom of stack 607 stack_min = stack_base - space_needed; 608 // align it 609 stack_min = roundDown(stack_min, pageSize); 610 stack_size = stack_base - stack_min; 611 // map memory 612 pTable->allocate(stack_min, roundUp(stack_size, pageSize)); 613 614 // map out initial stack contents 615 Addr argv_array_base = stack_min + intSize; // room for argc 616 Addr envp_array_base = argv_array_base + argv_array_size; 617 Addr arg_data_base = envp_array_base + envp_array_size; 618 Addr env_data_base = arg_data_base + arg_data_size; 619 620 // write contents to stack 621 uint64_t argc = argv.size(); 622 if (intSize == 8) 623 argc = htog((uint64_t)argc); 624 else if (intSize == 4) 625 argc = htog((uint32_t)argc); 626 else 627 panic("Unknown int size"); 628 629 initVirtMem->writeBlob(stack_min, (uint8_t*)&argc, intSize); 630 631 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); 632 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); 633 634 ThreadContext *tc = system->getThreadContext(contextIds[0]); 635 636 setSyscallArg(tc, 0, argc); 637 setSyscallArg(tc, 1, argv_array_base); 638 tc->setIntReg(StackPointerReg, stack_min); 639 640 Addr prog_entry = objFile->entryPoint(); 641 tc->setPC(prog_entry); 642 tc->setNextPC(prog_entry + sizeof(MachInst)); 643 644#if THE_ISA != ALPHA_ISA && THE_ISA != POWER_ISA //e.g. MIPS or Sparc 645 tc->setNextNPC(prog_entry + (2 * sizeof(MachInst))); 646#endif 647 648 num_processes++; 649} 650 651void | |
652LiveProcess::syscall(int64_t callnum, ThreadContext *tc) 653{ 654 num_syscalls++; 655 656 SyscallDesc *desc = getDesc(callnum); 657 if (desc == NULL) 658 fatal("Syscall %d out of range", callnum); 659 --- 148 unchanged lines hidden --- | 580LiveProcess::syscall(int64_t callnum, ThreadContext *tc) 581{ 582 num_syscalls++; 583 584 SyscallDesc *desc = getDesc(callnum); 585 if (desc == NULL) 586 fatal("Syscall %d out of range", callnum); 587 --- 148 unchanged lines hidden --- |