diff --git a/src/sim/process.cc b/src/sim/process.cc --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -324,7 +324,7 @@ fatal("Maximum stack size exceeded\n"); allocateMem(memState->stack_min, TheISA::PageBytes); inform("Increasing stack size by one page."); - }; + } return true; } return false; diff --git a/src/base/loader/object_file.hh b/src/base/loader/object_file.hh --- a/src/base/loader/object_file.hh +++ b/src/base/loader/object_file.hh @@ -73,7 +73,7 @@ uint8_t *fileData; size_t len; - Arch arch; + Arch arch; OpSys opSys; ObjectFile(const std::string &_filename, size_t _len, uint8_t *_data, @@ -113,9 +113,9 @@ protected: struct Section { - Addr baseAddr; + Addr baseAddr; uint8_t *fileImage; - size_t size; + size_t size; }; Addr entry; diff --git a/src/base/loader/elf_object.hh b/src/base/loader/elf_object.hh --- a/src/base/loader/elf_object.hh +++ b/src/base/loader/elf_object.hh @@ -51,12 +51,11 @@ class ElfObject : public ObjectFile { protected: - - //The global definition of a "Section" is closest to elf's segments. + // The global definition of a gem5 "Section" is closest to ELF's segments. typedef ObjectFile::Section Segment; - //These values are provided to a linux process by the kernel, so we - //need to keep them around. + // These values are provided to a linux process by the kernel, so we + // need to keep them around. Addr _programHeaderTable; uint16_t _programHeaderSize; uint16_t _programHeaderCount; diff --git a/src/arch/x86/process.cc b/src/arch/x86/process.cc --- a/src/arch/x86/process.cc +++ b/src/arch/x86/process.cc @@ -73,9 +73,9 @@ INTREG_RDI, INTREG_RSI, INTREG_RDX, - //This argument register is r10 for syscalls and rcx for C. + // This argument register is r10 for syscalls and rcx for C. INTREG_R10W, - //INTREG_RCX, + // INTREG_RCX, INTREG_R8W, INTREG_R9W }; @@ -199,7 +199,7 @@ argsInit(sizeof(uint64_t), PageBytes); - // Set up the vsyscall page for this process. + // Set up the vsyscall page for this process. allocateMem(vsyscallPage.base, vsyscallPage.size); uint8_t vtimeBlob[] = { 0x48,0xc7,0xc0,0xc9,0x00,0x00,0x00, // mov $0xc9,%rax @@ -582,7 +582,7 @@ dataAttr.expandDown = 0; dataAttr.system = 1; - //Initialize the segment registers. + // Initialize the segment registers. for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) { tc->setMiscRegNoEffect(MISCREG_SEG_BASE(seg), 0); tc->setMiscRegNoEffect(MISCREG_SEG_EFF_BASE(seg), 0); @@ -614,7 +614,7 @@ efer.ffxsr = 1; // Turn on fast fxsave and fxrstor. tc->setMiscReg(MISCREG_EFER, efer); - //Set up the registers that describe the operating mode. + // Set up the registers that describe the operating mode. CR0 cr0 = 0; cr0.pg = 1; // Turn on paging. cr0.cd = 0; // Don't disable caching. @@ -693,7 +693,7 @@ dataAttr.expandDown = 0; dataAttr.system = 1; - //Initialize the segment registers. + // Initialize the segment registers. for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) { tc->setMiscRegNoEffect(MISCREG_SEG_BASE(seg), 0); tc->setMiscRegNoEffect(MISCREG_SEG_EFF_BASE(seg), 0); @@ -734,7 +734,7 @@ efer.ffxsr = 1; // Turn on fast fxsave and fxrstor. tc->setMiscReg(MISCREG_EFER, efer); - //Set up the registers that describe the operating mode. + // Set up the registers that describe the operating mode. CR0 cr0 = 0; cr0.pg = 1; // Turn on paging. cr0.cd = 0; // Don't disable caching. @@ -771,7 +771,7 @@ else filename = argv[0]; - //We want 16 byte alignment + // We want 16 byte alignment uint64_t align = 16; // Patch the ld_bias for dynamic executables. @@ -857,13 +857,13 @@ // X86_IA64Processor | 0; - //Bits which describe the system hardware capabilities - //XXX Figure out what these should be + // Bits which describe the system hardware capabilities + // XXX Figure out what these should be auxv.push_back(auxv_t(M5_AT_HWCAP, features)); - //The system page size + // The system page size auxv.push_back(auxv_t(M5_AT_PAGESZ, X86ISA::PageBytes)); - //Frequency at which times() increments - //Defined to be 100 in the kernel source. + // Frequency at which times() increments + // Defined to be 100 in the kernel source. auxv.push_back(auxv_t(M5_AT_CLKTCK, 100)); // This is the virtual address of the program header tables if they // appear in the executable image. @@ -876,32 +876,32 @@ // zero for static executables or contain the base address for // dynamic executables. auxv.push_back(auxv_t(M5_AT_BASE, getBias())); - //XXX Figure out what this should be. + // XXX Figure out what this should be. auxv.push_back(auxv_t(M5_AT_FLAGS, 0)); - //The entry point to the program + // The entry point to the program auxv.push_back(auxv_t(M5_AT_ENTRY, objFile->entryPoint())); - //Different user and group IDs + // Different user and group IDs auxv.push_back(auxv_t(M5_AT_UID, uid())); auxv.push_back(auxv_t(M5_AT_EUID, euid())); auxv.push_back(auxv_t(M5_AT_GID, gid())); auxv.push_back(auxv_t(M5_AT_EGID, egid())); - //Whether to enable "secure mode" in the executable + // Whether to enable "secure mode" in the executable auxv.push_back(auxv_t(M5_AT_SECURE, 0)); - //The address of 16 "random" bytes. + // The address of 16 "random" bytes. auxv.push_back(auxv_t(M5_AT_RANDOM, 0)); - //The name of the program + // The name of the program auxv.push_back(auxv_t(M5_AT_EXECFN, 0)); - //The platform string + // The platform string auxv.push_back(auxv_t(M5_AT_PLATFORM, 0)); } - //Figure out how big the initial stack needs to be + // Figure out how big the initial stack needs to be // A sentry NULL void pointer at the top of the stack. int sentry_size = intSize; - //This is the name of the file which is present on the initial stack - //It's purpose is to let the user space linker examine the original file. + // This is the name of the file which is present on the initial stack + // It's purpose is to let the user space linker examine the original file. int file_name_size = filename.size() + 1; const int numRandomBytes = 16; @@ -917,10 +917,10 @@ for (int i = 0; i < argv.size(); ++i) arg_data_size += argv[i].size() + 1; - //The info_block needs to be padded so it's size is a multiple of the - //alignment mask. Also, it appears that there needs to be at least some - //padding, so if the size is already a multiple, we need to increase it - //anyway. + // The info_block needs to be padded so its size is a multiple of the + // alignment mask. Also, it appears that there needs to be at least some + // padding, so if the size is already a multiple, we need to increase it + // anyway. int base_info_block_size = sentry_size + file_name_size + env_data_size + arg_data_size; @@ -928,7 +928,7 @@ int info_block_padding = info_block_size - base_info_block_size; - //Each auxilliary vector is two 8 byte words + // Each auxiliary vector is two 8 byte words int aux_array_size = intSize * 2 * (auxv.size() + 1); int envp_array_size = intSize * (envp.size() + 1); @@ -936,15 +936,15 @@ int argc_size = intSize; - //Figure out the size of the contents of the actual initial frame + // Figure out the size of the contents of the actual initial frame int frame_size = aux_array_size + envp_array_size + argv_array_size + argc_size; - //There needs to be padding after the auxiliary vector data so that the - //very bottom of the stack is aligned properly. + // There needs to be padding after the auxiliary vector data so that the + // very bottom of the stack is aligned properly. int partial_size = frame_size + aux_data_size; int aligned_partial_size = roundUp(partial_size, align); int aux_padding = aligned_partial_size - partial_size; @@ -996,15 +996,14 @@ IntType argc = argv.size(); IntType guestArgc = X86ISA::htog(argc); - //Write out the sentry void * + // Write out the sentry void * IntType sentry_NULL = 0; - initVirtMem.writeBlob(sentry_base, - (uint8_t*)&sentry_NULL, sentry_size); + initVirtMem.writeBlob(sentry_base, (uint8_t*)&sentry_NULL, sentry_size); - //Write the file name + // Write the file name initVirtMem.writeString(file_name_base, filename.c_str()); - //Fix up the aux vectors which point to data + // Fix up the aux vectors which point to data assert(auxv[auxv.size() - 3].a_type == M5_AT_RANDOM); auxv[auxv.size() - 3].a_val = aux_data_base; assert(auxv[auxv.size() - 2].a_type == M5_AT_EXECFN); @@ -1012,14 +1011,15 @@ assert(auxv[auxv.size() - 1].a_type == M5_AT_PLATFORM); auxv[auxv.size() - 1].a_val = aux_data_base + numRandomBytes; - //Copy the aux stuff + + // Copy the aux stuff for (int x = 0; x < auxv.size(); x++) { initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize, (uint8_t*)&(auxv[x].a_type), intSize); initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize, (uint8_t*)&(auxv[x].a_val), intSize); } - //Write out the terminating zeroed auxilliary vector + // Write out the terminating zeroed auxiliary vector const uint64_t zero = 0; initVirtMem.writeBlob(auxv_array_base + auxv.size() * 2 * intSize, (uint8_t*)&zero, intSize); @@ -1034,14 +1034,14 @@ initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize); ThreadContext *tc = system->getThreadContext(contextIds[0]); - //Set the stack pointer register + // Set the stack pointer register tc->setIntReg(StackPointerReg, memState->stack_min); // There doesn't need to be any segment base added in since we're dealing // with the flat segmentation model. tc->pcState(getStartPC()); - //Align the "stack_min" to a page boundary. + // Align the "stack_min" to a page boundary. memState->stack_min = roundDown(memState->stack_min, pageSize); } # Node ID baf743047c381c4bca28ad50d1cd37e239e0608a # Parent 00370b5d68876412778a5dc6feaf1ac0dd5a36f9 diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc --- a/src/arch/x86/linux/process.cc +++ b/src/arch/x86/linux/process.cc @@ -83,7 +83,7 @@ GetGS = 0x1004 }; - //First argument is the code, second is the address + // First argument is the code, second is the address int index = 0; int code = process->getSyscallArg(tc, index); uint64_t addr = process->getSyscallArg(tc, index); @@ -91,7 +91,7 @@ SETranslatingPortProxy &p = tc->getMemProxy(); switch(code) { - //Each of these valid options should actually check addr. + // Each of these valid options should actually check addr. case SetFS: tc->setMiscRegNoEffect(MISCREG_FS_BASE, addr); tc->setMiscRegNoEffect(MISCREG_FS_EFF_BASE, addr); diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -174,8 +174,7 @@ tp.memsetBlob(gen.addr(), zero, size_needed); if (gen.addr() + PageBytes > next_page && next_page < new_brk && - p->pTable->translate(next_page)) - { + p->pTable->translate(next_page)) { size_needed = PageBytes - size_needed; tp.memsetBlob(next_page, zero, size_needed); } @@ -557,7 +556,7 @@ string path; if (!tc->getMemProxy().tryReadString(path, process->getSyscallArg(tc, index))) - return -EFAULT; + return -EFAULT; int64_t length = process->getSyscallArg(tc, index, 64); @@ -712,7 +711,6 @@ // to the underlying OS warn("fcntl64(%d, %d) passed through to host\n", tgt_fd, cmd); return fcntl(sim_fd, cmd); - // return 0; } } @@ -808,8 +806,8 @@ // simulation to be deterministic. // EUID goes in r20. - tc->setIntReg(SyscallPseudoReturnReg, process->euid()); //EUID - return process->uid(); // UID + tc->setIntReg(SyscallPseudoReturnReg, process->euid()); // EUID + return process->uid(); // UID } @@ -818,7 +816,7 @@ ThreadContext *tc) { // Get current group ID. EGID goes in r20. - tc->setIntReg(SyscallPseudoReturnReg, process->egid()); //EGID + tc->setIntReg(SyscallPseudoReturnReg, process->egid()); // EGID return process->gid(); } diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -266,8 +266,8 @@ Process *p, ThreadContext *tc, int index); /// Futex system call -/// Implemented by Daniel Sanchez -/// Used by printf's in multi-threaded apps +/// Implemented by Daniel Sanchez +/// Used by printf's in multi-threaded apps template SyscallReturn futexFunc(SyscallDesc *desc, int callnum, Process *process, @@ -457,7 +457,7 @@ tgt->st_mtimeX = TheISA::htog(tgt->st_mtimeX); tgt->st_ctimeX = host->st_ctime; tgt->st_ctimeX = TheISA::htog(tgt->st_ctimeX); - // Force the block size to be 8k. This helps to ensure buffered io works + // Force the block size to be 8KB. This helps to ensure buffered io works // consistently across different hosts. tgt->st_blksize = 0x2000; tgt->st_blksize = TheISA::htog(tgt->st_blksize); @@ -488,11 +488,11 @@ #endif } -//Here are a couple convenience functions +// Here are a couple of convenience functions template static void copyOutStatBuf(SETranslatingPortProxy &mem, Addr addr, - hst_stat *host, bool fakeTTY = false) + hst_stat *host, bool fakeTTY = false) { typedef TypedBufferArg tgt_stat_buf; tgt_stat_buf tgt(addr); @@ -503,7 +503,7 @@ template static void copyOutStat64Buf(SETranslatingPortProxy &mem, Addr addr, - hst_stat64 *host, bool fakeTTY = false) + hst_stat64 *host, bool fakeTTY = false) { typedef TypedBufferArg tgt_stat_buf; tgt_stat_buf tgt(addr); @@ -1562,24 +1562,24 @@ TypedBufferArg rlp(process->getSyscallArg(tc, index)); switch (resource) { - case OS::TGT_RLIMIT_STACK: - // max stack size in bytes: make up a number (8MB for now) - rlp->rlim_cur = rlp->rlim_max = 8 * 1024 * 1024; - rlp->rlim_cur = TheISA::htog(rlp->rlim_cur); - rlp->rlim_max = TheISA::htog(rlp->rlim_max); - break; + case OS::TGT_RLIMIT_STACK: + // max stack size in bytes: make up a number (8MB for now) + rlp->rlim_cur = rlp->rlim_max = 8 * 1024 * 1024; + rlp->rlim_cur = TheISA::htog(rlp->rlim_cur); + rlp->rlim_max = TheISA::htog(rlp->rlim_max); + break; - case OS::TGT_RLIMIT_DATA: - // max data segment size in bytes: make up a number - rlp->rlim_cur = rlp->rlim_max = 256 * 1024 * 1024; - rlp->rlim_cur = TheISA::htog(rlp->rlim_cur); - rlp->rlim_max = TheISA::htog(rlp->rlim_max); - break; + case OS::TGT_RLIMIT_DATA: + // max data segment size in bytes: make up a number + rlp->rlim_cur = rlp->rlim_max = 256 * 1024 * 1024; + rlp->rlim_cur = TheISA::htog(rlp->rlim_cur); + rlp->rlim_max = TheISA::htog(rlp->rlim_max); + break; - default: - warn("getrlimit: unimplemented resource %d", resource); - return -EINVAL; - break; + default: + warn("getrlimit: unimplemented resource %d", resource); + return -EINVAL; + break; } rlp.copyOut(tc->getMemProxy()); @@ -1661,8 +1661,7 @@ tp.copyIn(tc->getMemProxy()); struct timeval hostTimeval[2]; - for (int i = 0; i < 2; ++i) - { + for (int i = 0; i < 2; ++i) { hostTimeval[i].tv_sec = TheISA::gtoh((*tp)[i].tv_sec); hostTimeval[i].tv_usec = TheISA::gtoh((*tp)[i].tv_usec); }