Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected boolean loadSections() {
- if (numPages > Machine.processor().getNumPhysPages()) {
- coff.close();
- Lib.debug(dbgProcess, "\tinsufficient physical memory");
- return false;
- }
- // load sections
- for (int s=0; s<coff.getNumSections(); s++) {
- CoffSection section = coff.getSection(s);
- Lib.debug(dbgProcess, "\tinitializing " + section.getName()
- + " section (" + section.getLength() + " pages)");
- for (int i=0; i<section.getLength(); i++) {
- int vpn = section.getFirstVPN()+i;
- // for now, just assume virtual addresses=physical addresses
- section.loadPage(i, vpn);
- }
- }
- return true;
- }
- /**
- * Release any resources allocated by <tt>loadSections()</tt>.
- */
- protected void unloadSections() {
- }
- /**
- * Initialize the processor's registers in preparation for running the
- * program loaded into this process. Set the PC register to point at the
- * start function, set the stack pointer register to point at the top of
- * the stack, set the A0 and A1 registers to argc and argv, respectively,
- * and initialize all other registers to 0.
- */
- public void initRegisters() {
- Processor processor = Machine.processor();
- // by default, everything's 0
- for (int i=0; i<processor.numUserRegisters; i++)
- processor.writeRegister(i, 0);
- // initialize PC and SP according
- processor.writeRegister(Processor.regPC, initialPC);
- processor.writeRegister(Processor.regSP, initialSP);
- // initialize the first two argument registers to argc and argv
- processor.writeRegister(Processor.regA0, argc);
- processor.writeRegister(Processor.regA1, argv);
- }
- /**
- * Handle the halt() system call.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement