From 07159f9c56de91cb7d7bd6b6a795eebfee78133e Mon Sep 17 00:00:00 2001 From: Maxime Henrion Date: Tue, 25 Feb 2003 03:21:22 +0000 Subject: Cleanup of the d_mmap_t interface. - Get rid of the useless atop() / pmap_phys_address() detour. The device mmap handlers must now give back the physical address without atop()'ing it. - Don't borrow the physical address of the mapping in the returned int. Now we properly pass a vm_offset_t * and expect it to be filled by the mmap handler when the mapping was successful. The mmap handler must now return 0 when successful, any other value is considered as an error. Previously, returning -1 was the only way to fail. This change thus accidentally fixes some devices which were bogusly returning errno constants which would have been considered as addresses by the device pager. - Garbage collect the poorly named pmap_phys_address() now that it's no longer used. - Convert all the d_mmap_t consumers to the new API. I'm still not sure wheter we need a __FreeBSD_version bump for this, since and we didn't guarantee API/ABI stability until 5.1-RELEASE. Discussed with: alc, phk, jake Reviewed by: peter Compile-tested on: LINT (i386), GENERIC (alpha and sparc64) Runtime-tested on: i386 --- sys/vm/device_pager.c | 14 +++++++------- sys/vm/pmap.h | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'sys/vm') diff --git a/sys/vm/device_pager.c b/sys/vm/device_pager.c index e7acedcdbfb10..85f29aeb67955 100644 --- a/sys/vm/device_pager.c +++ b/sys/vm/device_pager.c @@ -107,7 +107,7 @@ dev_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t fo d_mmap_t *mapfunc; vm_object_t object; unsigned int npages; - vm_offset_t off; + vm_offset_t off, paddr; /* * Offset should be page aligned. @@ -137,7 +137,7 @@ dev_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t fo */ npages = OFF_TO_IDX(size); for (off = foff; npages--; off += PAGE_SIZE) - if ((*mapfunc)(dev, off, (int) prot) == -1) { + if ((*mapfunc)(dev, off, &paddr, (int)prot) != 0) { mtx_unlock(&Giant); return (NULL); } @@ -205,7 +205,7 @@ dev_pager_getpages(object, m, count, reqpage) vm_offset_t paddr; vm_page_t page; dev_t dev; - int i; + int i, ret; d_mmap_t *mapfunc; int prot; @@ -218,11 +218,11 @@ dev_pager_getpages(object, m, count, reqpage) if (mapfunc == NULL || mapfunc == (d_mmap_t *)nullop) panic("dev_pager_getpage: no map function"); - paddr = pmap_phys_address((*mapfunc) (dev, (vm_offset_t) offset << PAGE_SHIFT, prot)); - KASSERT(paddr != -1,("dev_pager_getpage: map function returns error")); + ret = (*mapfunc)(dev, (vm_offset_t)offset << PAGE_SHIFT, &paddr, prot); + KASSERT(ret == 0, ("dev_pager_getpage: map function returns error")); /* - * Replace the passed in reqpage page with our own fake page and free up the - * all of the original pages. + * Replace the passed in reqpage page with our own fake page and + * free up the all of the original pages. */ page = dev_pager_getfake(paddr); TAILQ_INSERT_TAIL(&object->un_pager.devp.devp_pglist, page, pageq); diff --git a/sys/vm/pmap.h b/sys/vm/pmap.h index 20a5bd3ce41ed..a403f6f7335e7 100644 --- a/sys/vm/pmap.h +++ b/sys/vm/pmap.h @@ -119,7 +119,6 @@ void pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, int pagelimit); boolean_t pmap_page_exists_quick(pmap_t pmap, vm_page_t m); void pmap_page_protect(vm_page_t m, vm_prot_t prot); -vm_offset_t pmap_phys_address(int); void pmap_pinit(pmap_t); void pmap_pinit0(pmap_t); void pmap_pinit2(pmap_t); -- cgit v1.3