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",
|
DEBUG ('a', "Initializing code segment, at 0x%x, size 0x%x\n",
|
||||||
noffH.code.virtualAddr, noffH.code.size);
|
noffH.code.virtualAddr, noffH.code.size);
|
||||||
executable->ReadAt (&(machine->mainMemory[noffH.code.virtualAddr]),
|
#ifdef CHANGED
|
||||||
noffH.code.size, noffH.code.inFileAddr);
|
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)
|
if (noffH.initData.size > 0)
|
||||||
{
|
{
|
||||||
DEBUG ('a', "Initializing data segment, at 0x%x, size 0x%x\n",
|
DEBUG ('a', "Initializing data segment, at 0x%x, size 0x%x\n",
|
||||||
noffH.initData.virtualAddr, noffH.initData.size);
|
noffH.initData.virtualAddr, noffH.initData.size);
|
||||||
executable->ReadAt (&
|
#ifdef CHANGED
|
||||||
(machine->mainMemory
|
ReadAtVirtual(
|
||||||
[noffH.initData.virtualAddr]),
|
executable,
|
||||||
noffH.initData.size, noffH.initData.inFileAddr);
|
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",
|
DEBUG ('a', "Area for stacks at 0x%x, size 0x%x\n",
|
||||||
|
@ -348,4 +368,28 @@ AddrSpace::DeAllocateUserStack(int addr){
|
||||||
memoryMap->Clear(bit);
|
memoryMap->Clear(bit);
|
||||||
semAllocateUserStack->V();
|
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
|
#endif
|
||||||
|
|
|
@ -54,12 +54,18 @@ class AddrSpace:public dontcopythis
|
||||||
BitMap * memoryMap;
|
BitMap * memoryMap;
|
||||||
int AllocateUserStack();
|
int AllocateUserStack();
|
||||||
void DeAllocateUserStack(int addr);
|
void DeAllocateUserStack(int addr);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
NoffHeader noffH; // Program layout
|
NoffHeader noffH; // Program layout
|
||||||
|
|
||||||
TranslationEntry * pageTable; // Page table
|
TranslationEntry * pageTable; // Page table
|
||||||
unsigned int numPages; // Number of pages in the page table
|
unsigned int numPages; // Number of pages in the page table
|
||||||
|
#ifdef CHANGED
|
||||||
|
static void ReadAtVirtual(OpenFile *executable,
|
||||||
|
int virtualaddr, int numBytes, int position, TranslationEntry *pageTable, unsigned int numPages);
|
||||||
|
#endif //CHANGED
|
||||||
};
|
};
|
||||||
|
|
||||||
extern List AddrspaceList;
|
extern List AddrspaceList;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue