diff options
-rw-r--r-- | src/sys/include/vm/map.h | 3 | ||||
-rw-r--r-- | src/sys/vm/vm_map.c | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/sys/include/vm/map.h b/src/sys/include/vm/map.h index 4e0f27e..69d7d73 100644 --- a/src/sys/include/vm/map.h +++ b/src/sys/include/vm/map.h @@ -44,6 +44,9 @@ * @len: Length of mapping (4K aligned) * @prot: Memory protection flags (PROT_*) * + * XXX: If spec->va or spec->pa is a value of zero, an address + * will be assigned and shared by both. + * * Returns zero on success, otherwise a less than zero value * on failure. */ diff --git a/src/sys/vm/vm_map.c b/src/sys/vm/vm_map.c index 1b27a21..d8cb4b7 100644 --- a/src/sys/vm/vm_map.c +++ b/src/sys/vm/vm_map.c @@ -31,6 +31,7 @@ #include <sys/param.h> #include <sys/errno.h> #include <sys/syslog.h> +#include <vm/physseg.h> #include <vm/mmu.h> #include <vm/map.h> #include <vm/vm.h> @@ -57,6 +58,22 @@ __vm_map(struct vm_vas *vas, struct mmu_map *spec, size_t len, int prot) /* Must be 4K aligned */ len = ALIGN_UP(len, PSIZE); + + /* + * If we encounter any address that is zero, we + * must assign our own. + */ + if (spec->pa == 0 || spec->va == 0) { + spec->pa = vm_alloc_frame(len / PSIZE); + if (spec->va == 0) + spec->va = spec->pa; + } + + if (spec->pa == 0) { + return -ENOMEM; + } + + /* Must be on a 4K boundary */ spec->va = ALIGN_DOWN(spec->va, PSIZE); spec->pa = ALIGN_DOWN(spec->pa, PSIZE); |