process.cc (4117:2807cee7b892) | process.cc (4164:c4a2eeafec9e) |
---|---|
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; --- 497 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 | 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; --- 497 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; | 514 // The unaccounted for 8 byte 0 at the top of the stack 515 int mysterious_size = 8; |
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 | 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 | 530 //The info_block - This seems to need an pad for some reason. |
531 int info_block_size = | 531 int info_block_size = |
532 (file_name_size + | 532 (mysterious_size + 533 file_name_size + |
533 env_data_size + | 534 env_data_size + |
534 arg_data_size); | 535 arg_data_size + intSize); |
535 | 536 |
536 //Each auxilliary vector is two 8 byte words | 537 //Each auxilliary vector is two 4 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 = | 538 int aux_array_size = intSize * 2 * (auxv.size() + 1); 539 540 int envp_array_size = intSize * (envp.size() + 1); 541 int argv_array_size = intSize * (argv.size() + 1); 542 543 int argc_size = intSize; 544 int window_save_size = intSize * 16; 545 546 int space_needed = |
546 mysterious_size + | 547 info_block_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. | 548 aux_array_size + 549 envp_array_size + 550 argv_array_size + 551 argc_size + 552 window_save_size; 553 554 stack_min = stack_base - space_needed; 555 stack_min &= alignmentMask; --- 6 unchanged lines hidden (view full) --- 562 // map out initial stack contents 563 uint32_t window_save_base = stack_min; 564 uint32_t argc_base = window_save_base + window_save_size; 565 uint32_t argv_array_base = argc_base + argc_size; 566 uint32_t envp_array_base = argv_array_base + argv_array_size; 567 uint32_t auxv_array_base = envp_array_base + envp_array_size; 568 //The info block is pushed up against the top of the stack, while 569 //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 arg_data_base = stack_base - info_block_size + intSize; |
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 | 571 uint32_t env_data_base = arg_data_base + arg_data_size; 572 uint32_t file_name_base = env_data_base + env_data_size; 573 uint32_t mysterious_base = file_name_base + file_name_size; 574 575 DPRINTF(Sparc, "The addresses of items on the initial stack:\n"); 576 DPRINTF(Sparc, "0x%x - file name\n", file_name_base); 577 DPRINTF(Sparc, "0x%x - env data\n", env_data_base); 578 DPRINTF(Sparc, "0x%x - arg data\n", arg_data_base); --- 42 unchanged lines hidden (view full) --- 621 int fillSize = sizeof(MachInst) * numFillInsts; 622 int spillSize = sizeof(MachInst) * numSpillInsts; 623 fillStart = stack_base; 624 spillStart = fillStart + fillSize; 625 initVirtMem->writeBlob(fillStart, (uint8_t*)fillHandler32, fillSize); 626 initVirtMem->writeBlob(spillStart, (uint8_t*)spillHandler32, spillSize); 627 628 //Set up the thread context to start running the process |
628 threadContexts[0]->setIntReg(ArgumentReg0, argc); 629 threadContexts[0]->setIntReg(ArgumentReg1, argv_array_base); | 629 //threadContexts[0]->setIntReg(ArgumentReg0, argc); 630 //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} | 631 threadContexts[0]->setIntReg(StackPointerReg, stack_min); 632 633 uint32_t prog_entry = objFile->entryPoint(); 634 threadContexts[0]->setPC(prog_entry); 635 threadContexts[0]->setNextPC(prog_entry + sizeof(MachInst)); 636 threadContexts[0]->setNextNPC(prog_entry + (2 * sizeof(MachInst))); 637 638 //Align the "stack_min" to a page boundary. 639 stack_min = roundDown(stack_min, pageSize); 640 641// num_processes++; 642} |