Clean up mmapFunc.
sim/syscall_emul.hh: Clean up mmapFunc: args should be aligned and PageTable::allocate already handles multi-page allocations, so most of thw work done here was unnecessary (as far as I can tell). I didn't test this beyond compiling though... --HG-- extra : convert_revision : d79591a1cc58ea82ea911cc05e0970e81e1d2c60
This commit is contained in:
parent
59ab31cd80
commit
cab1af2ee8
|
@ -700,21 +700,24 @@ mmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
|
||||||
int flags = xc->getSyscallArg(3);
|
int flags = xc->getSyscallArg(3);
|
||||||
// int fd = p->sim_fd(xc->getSyscallArg(4));
|
// int fd = p->sim_fd(xc->getSyscallArg(4));
|
||||||
// int offset = xc->getSyscallArg(5);
|
// int offset = xc->getSyscallArg(5);
|
||||||
Addr junk;
|
|
||||||
|
|
||||||
if (start == 0) {
|
if ((start % TheISA::VMPageSize) != 0 ||
|
||||||
// user didn't give an address... pick one from our "mmap region"
|
(length % TheISA::VMPageSize) != 0) {
|
||||||
|
warn("mmap failing: arguments not page-aligned: "
|
||||||
|
"start 0x%x length 0x%x",
|
||||||
|
start, length);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start != 0) {
|
||||||
|
warn("mmap: ignoring suggested map address 0x%x, using 0x%x",
|
||||||
|
start, p->mmap_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
// pick next address from our "mmap region"
|
||||||
start = p->mmap_end;
|
start = p->mmap_end;
|
||||||
for (ChunkGenerator gen(start, roundUp(length, TheISA::VMPageSize), TheISA::VMPageSize); !gen.done(); gen.next()) {
|
p->pTable->allocate(start, length);
|
||||||
if (!p->pTable->translate(gen.addr(), junk))
|
p->mmap_end += length;
|
||||||
p->pTable->allocate(roundDown(gen.addr(), TheISA::VMPageSize), TheISA::VMPageSize);
|
|
||||||
}
|
|
||||||
p->mmap_end += roundUp(length, TheISA::VMPageSize);
|
|
||||||
if (p->nxm_start != 0) {
|
|
||||||
//If we have an nxm space, make sure we haven't colided
|
|
||||||
assert(p->mmap_end < p->nxm_start);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
|
if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
|
||||||
warn("allowing mmap of file @ fd %d. "
|
warn("allowing mmap of file @ fd %d. "
|
||||||
|
|
Loading…
Reference in a new issue