summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2006-04-10 20:02:36 -0400
committerSteve Reinhardt <stever@eecs.umich.edu>2006-04-10 20:02:36 -0400
commitcab1af2ee871ce88ace9c877a1163ace4319c51d (patch)
treeaa7b6a52798d59819aee46286d4ece539fd47eb5 /sim
parent59ab31cd803fbc0e341e805ec510cab1ec997e98 (diff)
downloadgem5-cab1af2ee871ce88ace9c877a1163ace4319c51d.tar.xz
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
Diffstat (limited to 'sim')
-rw-r--r--sim/syscall_emul.hh31
1 files changed, 17 insertions, 14 deletions
diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh
index ae1196f03..58db2469e 100644
--- a/sim/syscall_emul.hh
+++ b/sim/syscall_emul.hh
@@ -700,22 +700,25 @@ mmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
int flags = xc->getSyscallArg(3);
// int fd = p->sim_fd(xc->getSyscallArg(4));
// int offset = xc->getSyscallArg(5);
- Addr junk;
-
- if (start == 0) {
- // user didn't give an address... pick one from our "mmap region"
- start = p->mmap_end;
- for (ChunkGenerator gen(start, roundUp(length, TheISA::VMPageSize), TheISA::VMPageSize); !gen.done(); gen.next()) {
- if (!p->pTable->translate(gen.addr(), junk))
- 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 ((start % TheISA::VMPageSize) != 0 ||
+ (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;
+ p->pTable->allocate(start, length);
+ p->mmap_end += length;
+
if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
warn("allowing mmap of file @ fd %d. "
"This will break if not /dev/zero.", xc->getSyscallArg(4));