1/* 2 * Copyright (c) 2003-2004 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; --- 74 unchanged lines hidden (view full) --- 83void 84Sparc32LiveProcess::startup() 85{ 86 argsInit(32 / 8, VMPageSize); 87 88 //From the SPARC ABI 89 90 //The process runs in user mode |
91 threadContexts[0]->setMiscReg(MISCREG_PSTATE, 0x02); |
92 93 //Setup default FP state |
94 threadContexts[0]->setMiscRegNoEffect(MISCREG_FSR, 0); |
95 |
96 threadContexts[0]->setMiscRegNoEffect(MISCREG_TICK, 0); |
97 // 98 /* 99 * Register window management registers 100 */ 101 102 //No windows contain info from other programs |
103 //threadContexts[0]->setMiscRegNoEffect(MISCREG_OTHERWIN, 0); |
104 threadContexts[0]->setIntReg(NumIntArchRegs + 6, 0); 105 //There are no windows to pop |
106 //threadContexts[0]->setMiscRegNoEffect(MISCREG_CANRESTORE, 0); |
107 threadContexts[0]->setIntReg(NumIntArchRegs + 4, 0); 108 //All windows are available to save into |
109 //threadContexts[0]->setMiscRegNoEffect(MISCREG_CANSAVE, NWindows - 2); |
110 threadContexts[0]->setIntReg(NumIntArchRegs + 3, NWindows - 2); 111 //All windows are "clean" |
112 //threadContexts[0]->setMiscRegNoEffect(MISCREG_CLEANWIN, NWindows); |
113 threadContexts[0]->setIntReg(NumIntArchRegs + 5, NWindows); 114 //Start with register window 0 |
115 threadContexts[0]->setMiscRegNoEffect(MISCREG_CWP, 0); |
116 //Always use spill and fill traps 0 |
117 //threadContexts[0]->setMiscRegNoEffect(MISCREG_WSTATE, 0); |
118 threadContexts[0]->setIntReg(NumIntArchRegs + 7, 0); 119 //Set the trap level to 0 |
120 threadContexts[0]->setMiscRegNoEffect(MISCREG_TL, 0); |
121 //Set the ASI register to something fixed |
122 threadContexts[0]->setMiscRegNoEffect(MISCREG_ASI, ASI_PRIMARY); |
123} 124 125void 126Sparc64LiveProcess::startup() 127{ 128 argsInit(sizeof(IntReg), VMPageSize); 129 130 //From the SPARC ABI 131 132 //The process runs in user mode |
133 threadContexts[0]->setMiscReg(MISCREG_PSTATE, 0x02); |
134 135 //Setup default FP state |
136 threadContexts[0]->setMiscRegNoEffect(MISCREG_FSR, 0); |
137 |
138 threadContexts[0]->setMiscRegNoEffect(MISCREG_TICK, 0); |
139 // 140 /* 141 * Register window management registers 142 */ 143 144 //No windows contain info from other programs |
145 //threadContexts[0]->setMiscRegNoEffect(MISCREG_OTHERWIN, 0); |
146 threadContexts[0]->setIntReg(NumIntArchRegs + 6, 0); 147 //There are no windows to pop |
148 //threadContexts[0]->setMiscRegNoEffect(MISCREG_CANRESTORE, 0); |
149 threadContexts[0]->setIntReg(NumIntArchRegs + 4, 0); 150 //All windows are available to save into |
151 //threadContexts[0]->setMiscRegNoEffect(MISCREG_CANSAVE, NWindows - 2); |
152 threadContexts[0]->setIntReg(NumIntArchRegs + 3, NWindows - 2); 153 //All windows are "clean" |
154 //threadContexts[0]->setMiscRegNoEffect(MISCREG_CLEANWIN, NWindows); |
155 threadContexts[0]->setIntReg(NumIntArchRegs + 5, NWindows); 156 //Start with register window 0 |
157 threadContexts[0]->setMiscRegNoEffect(MISCREG_CWP, 0); |
158 //Always use spill and fill traps 0 |
159 //threadContexts[0]->setMiscRegNoEffect(MISCREG_WSTATE, 0); |
160 threadContexts[0]->setIntReg(NumIntArchRegs + 7, 0); 161 //Set the trap level to 0 |
162 threadContexts[0]->setMiscRegNoEffect(MISCREG_TL, 0); |
163 //Set the ASI register to something fixed |
164 threadContexts[0]->setMiscRegNoEffect(MISCREG_ASI, ASI_PRIMARY); |
165} 166 167M5_32_auxv_t::M5_32_auxv_t(int32_t type, int32_t val) 168{ 169 a_type = TheISA::htog(type); 170 a_val = TheISA::htog(val); 171} 172 --- 333 unchanged lines hidden (view full) --- 506 auxv.push_back(auxv_t(SPARC_AT_GID, gid())); 507 auxv.push_back(auxv_t(SPARC_AT_EGID, egid())); 508 //Whether to enable "secure mode" in the executable 509 auxv.push_back(auxv_t(SPARC_AT_SECURE, 0)); 510 } 511 512 //Figure out how big the initial stack needs to be 513 |
514 // The unaccounted for 0 at the top of the stack 515 int mysterious_size = intSize; |
516 517 //This is the name of the file which is present on the initial stack 518 //It's purpose is to let the user space linker examine the original file. 519 int file_name_size = filename.size() + 1; 520 521 int env_data_size = 0; 522 for (int i = 0; i < envp.size(); ++i) { 523 env_data_size += envp[i].size() + 1; 524 } 525 int arg_data_size = 0; 526 for (int i = 0; i < argv.size(); ++i) { 527 arg_data_size += argv[i].size() + 1; 528 } 529 |
530 //The info_block |
531 int info_block_size = |
532 (file_name_size + |
533 env_data_size + |
534 arg_data_size); |
535 |
536 //Each auxilliary vector is two 8 byte words |
537 int aux_array_size = intSize * 2 * (auxv.size() + 1); 538 539 int envp_array_size = intSize * (envp.size() + 1); 540 int argv_array_size = intSize * (argv.size() + 1); 541 542 int argc_size = intSize; 543 int window_save_size = intSize * 16; 544 545 int space_needed = |
546 mysterious_size + |
547 aux_array_size + 548 envp_array_size + 549 argv_array_size + 550 argc_size + 551 window_save_size; 552 553 stack_min = stack_base - space_needed; 554 stack_min &= alignmentMask; --- 6 unchanged lines hidden (view full) --- 561 // map out initial stack contents 562 uint32_t window_save_base = stack_min; 563 uint32_t argc_base = window_save_base + window_save_size; 564 uint32_t argv_array_base = argc_base + argc_size; 565 uint32_t envp_array_base = argv_array_base + argv_array_size; 566 uint32_t auxv_array_base = envp_array_base + envp_array_size; 567 //The info block is pushed up against the top of the stack, while 568 //the rest of the initial stack frame is aligned to an 8 byte boudary. |
569 uint32_t arg_data_base = stack_base - info_block_size; |
570 uint32_t env_data_base = arg_data_base + arg_data_size; 571 uint32_t file_name_base = env_data_base + env_data_size; 572 uint32_t mysterious_base = file_name_base + file_name_size; 573 574 DPRINTF(Sparc, "The addresses of items on the initial stack:\n"); 575 DPRINTF(Sparc, "0x%x - file name\n", file_name_base); 576 DPRINTF(Sparc, "0x%x - env data\n", env_data_base); 577 DPRINTF(Sparc, "0x%x - arg data\n", arg_data_base); --- 42 unchanged lines hidden (view full) --- 620 int fillSize = sizeof(MachInst) * numFillInsts; 621 int spillSize = sizeof(MachInst) * numSpillInsts; 622 fillStart = stack_base; 623 spillStart = fillStart + fillSize; 624 initVirtMem->writeBlob(fillStart, (uint8_t*)fillHandler32, fillSize); 625 initVirtMem->writeBlob(spillStart, (uint8_t*)spillHandler32, spillSize); 626 627 //Set up the thread context to start running the process |
628 threadContexts[0]->setIntReg(ArgumentReg0, argc); 629 threadContexts[0]->setIntReg(ArgumentReg1, argv_array_base); |
630 threadContexts[0]->setIntReg(StackPointerReg, stack_min); 631 632 uint32_t prog_entry = objFile->entryPoint(); 633 threadContexts[0]->setPC(prog_entry); 634 threadContexts[0]->setNextPC(prog_entry + sizeof(MachInst)); 635 threadContexts[0]->setNextNPC(prog_entry + (2 * sizeof(MachInst))); 636 637 //Align the "stack_min" to a page boundary. 638 stack_min = roundDown(stack_min, pageSize); 639 640// num_processes++; 641} |