TD3:I3 implements ReadAtVirtual()
This commit is contained in:
parent
c35ccf876c
commit
8521a8b554
2 changed files with 56 additions and 6 deletions
|
@ -113,17 +113,37 @@ AddrSpace::AddrSpace (OpenFile * executable)
|
|||
{
|
||||
DEBUG ('a', "Initializing code segment, at 0x%x, size 0x%x\n",
|
||||
noffH.code.virtualAddr, noffH.code.size);
|
||||
executable->ReadAt (&(machine->mainMemory[noffH.code.virtualAddr]),
|
||||
noffH.code.size, noffH.code.inFileAddr);
|
||||
#ifdef CHANGED
|
||||
ReadAtVirtual(
|
||||
executable,
|
||||
noffH.code.virtualAddr,
|
||||
noffH.code.size,
|
||||
noffH.code.inFileAddr,
|
||||
pageTable,
|
||||
numPages
|
||||
);
|
||||
#endif
|
||||
// executable->ReadAt (&(machine->mainMemory[noffH.code.virtualAddr]),
|
||||
// noffH.code.size, noffH.code.inFileAddr);
|
||||
}
|
||||
if (noffH.initData.size > 0)
|
||||
{
|
||||
DEBUG ('a', "Initializing data segment, at 0x%x, size 0x%x\n",
|
||||
noffH.initData.virtualAddr, noffH.initData.size);
|
||||
executable->ReadAt (&
|
||||
(machine->mainMemory
|
||||
[noffH.initData.virtualAddr]),
|
||||
noffH.initData.size, noffH.initData.inFileAddr);
|
||||
#ifdef CHANGED
|
||||
ReadAtVirtual(
|
||||
executable,
|
||||
noffH.initData.virtualAddr,
|
||||
noffH.initData.size,
|
||||
noffH.initData.inFileAddr,
|
||||
pageTable,
|
||||
numPages
|
||||
);
|
||||
#endif
|
||||
// executable->ReadAt (&
|
||||
// (machine->mainMemory
|
||||
// [noffH.initData.virtualAddr]),
|
||||
// noffH.initData.size, noffH.initData.inFileAddr);
|
||||
}
|
||||
|
||||
DEBUG ('a', "Area for stacks at 0x%x, size 0x%x\n",
|
||||
|
@ -348,4 +368,28 @@ AddrSpace::DeAllocateUserStack(int addr){
|
|||
memoryMap->Clear(bit);
|
||||
semAllocateUserStack->V();
|
||||
}
|
||||
|
||||
void
|
||||
AddrSpace::ReadAtVirtual(OpenFile *executable,
|
||||
int virtualaddr, int numBytes, int position, TranslationEntry *pageTable, unsigned int numPages) {
|
||||
|
||||
DEBUG('a',"ReadAtVirtual\n");
|
||||
char buffer[numBytes];
|
||||
int size = executable->ReadAt(&buffer, numBytes, position);
|
||||
|
||||
// Backup current page table
|
||||
TranslationEntry *oldPageTable = machine->currentPageTable;
|
||||
machine->currentPageTable = pageTable;
|
||||
int oldPageTableSize = machine->currentPageTableSize;
|
||||
machine->currentPageTableSize = numPages;
|
||||
|
||||
// Copy bytes from out buffet to our page
|
||||
int i;
|
||||
for(i=0;i<size;i++) {
|
||||
machine->WriteMem(virtualaddr+i, 1, *(buffer+i));
|
||||
}
|
||||
// Get back our old page table
|
||||
machine->currentPageTable = oldPageTable;
|
||||
machine->currentPageTableSize = oldPageTableSize;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue