summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormux <mux@FreeBSD.org>2003-02-25 03:21:22 +0000
committermux <mux@FreeBSD.org>2003-02-25 03:21:22 +0000
commit541937cf7373ff6a61c871266ea041503bb02233 (patch)
treea4ad6d456fdd984cdf9c6c6abd5e4654a9b7e3e0 /sys
parentf52965fa5d8b4bdc23c2e702d17f5537a81f6d01 (diff)
downloadFreeBSD-src-541937cf7373ff6a61c871266ea041503bb02233.zip
FreeBSD-src-541937cf7373ff6a61c871266ea041503bb02233.tar.gz
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
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/alpha/mem.c5
-rw-r--r--sys/alpha/alpha/pmap.c7
-rw-r--r--sys/amd64/amd64/mem.c9
-rw-r--r--sys/amd64/amd64/pmap.c7
-rw-r--r--sys/dev/agp/agp.c5
-rw-r--r--sys/dev/bktr/bktr_os.c5
-rw-r--r--sys/dev/drm/drm_vm.h16
-rw-r--r--sys/dev/fb/fb.c8
-rw-r--r--sys/dev/fb/fbreg.h5
-rw-r--r--sys/dev/fb/gfb.c16
-rw-r--r--sys/dev/fb/s3_pci.c5
-rw-r--r--sys/dev/fb/vga.c19
-rw-r--r--sys/dev/fb/vgareg.h2
-rw-r--r--sys/dev/firewire/fwdev.c4
-rw-r--r--sys/dev/firewire/fwmem.c2
-rw-r--r--sys/dev/gfb/gfb_pci.c4
-rw-r--r--sys/dev/sound/pcm/dsp.c7
-rw-r--r--sys/dev/syscons/syscons.c4
-rw-r--r--sys/dev/tdfx/tdfx_pci.c9
-rw-r--r--sys/geom/geom_stats.c8
-rw-r--r--sys/i386/i386/elan-mmcr.c5
-rw-r--r--sys/i386/i386/mem.c9
-rw-r--r--sys/i386/i386/pmap.c7
-rw-r--r--sys/i386/isa/pcvt/pcvt_drv.c5
-rw-r--r--sys/i386/isa/spigot.c5
-rw-r--r--sys/i386/isa/vesa.c13
-rw-r--r--sys/ia64/ia64/mem.c5
-rw-r--r--sys/ia64/ia64/pmap.c6
-rw-r--r--sys/isa/vga_isa.c4
-rw-r--r--sys/kern/subr_xxx.c3
-rw-r--r--sys/pc98/cbus/gdc.c4
-rw-r--r--sys/pc98/pc98/pc98gdc.c4
-rw-r--r--sys/pc98/pc98/syscons.c4
-rw-r--r--sys/pci/agp.c5
-rw-r--r--sys/pci/meteor.c5
-rw-r--r--sys/pci/xrpu.c5
-rw-r--r--sys/powerpc/aim/mmu_oea.c7
-rw-r--r--sys/powerpc/powerpc/mmu_oea.c7
-rw-r--r--sys/powerpc/powerpc/pmap.c7
-rw-r--r--sys/sparc64/sparc64/pmap.c7
-rw-r--r--sys/sys/conf.h3
-rw-r--r--sys/sys/linedisc.h3
-rw-r--r--sys/vm/device_pager.c14
-rw-r--r--sys/vm/pmap.h1
44 files changed, 122 insertions, 163 deletions
diff --git a/sys/alpha/alpha/mem.c b/sys/alpha/alpha/mem.c
index 9aab3fc..18fb05e 100644
--- a/sys/alpha/alpha/mem.c
+++ b/sys/alpha/alpha/mem.c
@@ -222,7 +222,7 @@ kmemphys:
* instead of going through read/write *
\*******************************************************/
static int
-memmmap(dev_t dev, vm_offset_t offset, int prot)
+memmmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
/*
* /dev/mem is the only one that makes sense through this
@@ -238,7 +238,8 @@ memmmap(dev_t dev, vm_offset_t offset, int prot)
*/
if ((prot & alpha_pa_access(atop((vm_offset_t)offset))) != prot)
return (-1);
- return (alpha_btop(ALPHA_PHYS_TO_K0SEG(offset)));
+ *paddr = ALPHA_PHYS_TO_K0SEG(offset);
+ return (0);
}
static int
diff --git a/sys/alpha/alpha/pmap.c b/sys/alpha/alpha/pmap.c
index 3bf6bc1..06fb7ca 100644
--- a/sys/alpha/alpha/pmap.c
+++ b/sys/alpha/alpha/pmap.c
@@ -2807,13 +2807,6 @@ pmap_page_protect(vm_page_t m, vm_prot_t prot)
}
}
-vm_offset_t
-pmap_phys_address(ppn)
- int ppn;
-{
- return (alpha_ptob(ppn));
-}
-
/*
* pmap_ts_referenced:
*
diff --git a/sys/amd64/amd64/mem.c b/sys/amd64/amd64/mem.c
index 41fa636..a045d96 100644
--- a/sys/amd64/amd64/mem.c
+++ b/sys/amd64/amd64/mem.c
@@ -215,22 +215,25 @@ mmrw(dev_t dev, struct uio *uio, int flags)
* instead of going through read/write *
\*******************************************************/
static int
-memmmap(dev_t dev, vm_offset_t offset, int prot)
+memmmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
switch (minor(dev))
{
/* minor device 0 is physical memory */
case 0:
- return (i386_btop(offset));
+ *paddr = offset;
+ break;
/* minor device 1 is kernel memory */
case 1:
- return (i386_btop(vtophys(offset)));
+ *paddr = vtophys(offset);
+ break;
default:
return (-1);
}
+ return (0);
}
/*
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 8d6df39..ca469aa 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -3124,13 +3124,6 @@ pmap_page_protect(vm_page_t m, vm_prot_t prot)
}
}
-vm_offset_t
-pmap_phys_address(ppn)
- int ppn;
-{
- return (i386_ptob(ppn));
-}
-
/*
* pmap_ts_referenced:
*
diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c
index f821026..be2f7f8 100644
--- a/sys/dev/agp/agp.c
+++ b/sys/dev/agp/agp.c
@@ -722,14 +722,15 @@ agp_ioctl(dev_t kdev, u_long cmd, caddr_t data, int fflag, struct thread *td)
}
static int
-agp_mmap(dev_t kdev, vm_offset_t offset, int prot)
+agp_mmap(dev_t kdev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
device_t dev = KDEV2DEV(kdev);
struct agp_softc *sc = device_get_softc(dev);
if (offset > AGP_GET_APERTURE(dev))
return -1;
- return atop(rman_get_start(sc->as_aperture) + offset);
+ *paddr = rman_get_start(sc->as_aperture) + offset;
+ return 0;
}
/* Implementation of the kernel api */
diff --git a/sys/dev/bktr/bktr_os.c b/sys/dev/bktr/bktr_os.c
index 4aae13c..7c7f9a1 100644
--- a/sys/dev/bktr/bktr_os.c
+++ b/sys/dev/bktr/bktr_os.c
@@ -753,7 +753,7 @@ bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct thread *td
*
*/
static int
-bktr_mmap( dev_t dev, vm_offset_t offset, int nprot )
+bktr_mmap( dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot )
{
int unit;
bktr_ptr_t bktr;
@@ -779,7 +779,8 @@ bktr_mmap( dev_t dev, vm_offset_t offset, int nprot )
if (offset >= bktr->alloc_pages * PAGE_SIZE)
return( -1 );
- return( atop(vtophys(bktr->bigbuf) + offset) );
+ *paddr = vtophys(bktr->bigbuf) + offset;
+ return( 0 );
}
static int
diff --git a/sys/dev/drm/drm_vm.h b/sys/dev/drm/drm_vm.h
index 5fd9a39..705ca48 100644
--- a/sys/dev/drm/drm_vm.h
+++ b/sys/dev/drm/drm_vm.h
@@ -5,7 +5,8 @@
#include <vm/vm.h>
#include <vm/pmap.h>
-static int DRM(dma_mmap)(dev_t kdev, vm_offset_t offset, int prot)
+static int DRM(dma_mmap)(dev_t kdev, vm_offset_t offset, vm_offset_t *paddr,
+ int prot)
{
drm_device_t *dev = kdev->si_drv1;
drm_device_dma_t *dma = dev->dma;
@@ -19,10 +20,11 @@ static int DRM(dma_mmap)(dev_t kdev, vm_offset_t offset, int prot)
physical = dma->pagelist[page];
DRM_DEBUG("0x%08x (page %lu) => 0x%08lx\n", offset, page, physical);
- return atop(physical);
+ *paddr = physical;
+ return 0;
}
-int DRM(mmap)(dev_t kdev, vm_offset_t offset, int prot)
+int DRM(mmap)(dev_t kdev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
drm_device_t *dev = kdev->si_drv1;
drm_map_t *map = NULL;
@@ -43,7 +45,7 @@ int DRM(mmap)(dev_t kdev, vm_offset_t offset, int prot)
if (dev->dma
&& offset >= 0
&& offset < ptoa(dev->dma->page_count))
- return DRM(dma_mmap)(kdev, offset, prot);
+ return DRM(dma_mmap)(kdev, offset, paddr, prot);
/* A sequential search of a linked list is
fine here because: 1) there will only be
@@ -72,9 +74,11 @@ int DRM(mmap)(dev_t kdev, vm_offset_t offset, int prot)
case _DRM_FRAME_BUFFER:
case _DRM_REGISTERS:
case _DRM_AGP:
- return atop(offset);
+ *paddr = offset;
+ return 0;
case _DRM_SHM:
- return atop(vtophys(offset));
+ *paddr = vtophys(offset);
+ return 0;
default:
return -1; /* This should never happen. */
}
diff --git a/sys/dev/fb/fb.c b/sys/dev/fb/fb.c
index 0dbb73b..6f8bab7 100644
--- a/sys/dev/fb/fb.c
+++ b/sys/dev/fb/fb.c
@@ -501,7 +501,7 @@ fbioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
}
static int
-fbmmap(dev_t dev, vm_offset_t offset, int nprot)
+fbmmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
int unit;
@@ -509,7 +509,7 @@ fbmmap(dev_t dev, vm_offset_t offset, int nprot)
if (vidcdevsw[unit] == NULL)
return ENXIO;
return (*vidcdevsw[unit]->d_mmap)(makedev(0, adapter[unit]->va_minor),
- offset, nprot);
+ offset, paddr, nprot);
}
#if experimental
@@ -591,9 +591,9 @@ int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp, u_long cmd,
}
int genfbmmap(genfb_softc_t *sc, video_adapter_t *adp, vm_offset_t offset,
- int prot)
+ vm_offset_t *paddr, int prot)
{
- return (*vidsw[adp->va_index]->mmap)(adp, offset, prot);
+ return (*vidsw[adp->va_index]->mmap)(adp, offset, paddr, prot);
}
#endif /* FB_INSTALL_CDEV */
diff --git a/sys/dev/fb/fbreg.h b/sys/dev/fb/fbreg.h
index d556791..ce9869e 100644
--- a/sys/dev/fb/fbreg.h
+++ b/sys/dev/fb/fbreg.h
@@ -81,7 +81,8 @@ typedef int vi_blank_display_t(video_adapter_t *adp, int mode);
#define V_DISPLAY_STAND_BY 2
#define V_DISPLAY_SUSPEND 3
*/
-typedef int vi_mmap_t(video_adapter_t *adp, vm_offset_t offset, int prot);
+typedef int vi_mmap_t(video_adapter_t *adp, vm_offset_t offset,
+ vm_offset_t *paddr, int prot);
typedef int vi_ioctl_t(video_adapter_t *adp, u_long cmd, caddr_t data);
typedef int vi_clear_t(video_adapter_t *adp);
typedef int vi_fill_rect_t(video_adapter_t *adp, int val, int x, int y,
@@ -212,7 +213,7 @@ int genfbwrite(genfb_softc_t *sc, video_adapter_t *adp,
int genfbioctl(genfb_softc_t *sc, video_adapter_t *adp,
u_long cmd, caddr_t arg, int flag, struct thread *td);
int genfbmmap(genfb_softc_t *sc, video_adapter_t *adp,
- vm_offset_t offset, int prot);
+ vm_offset_t offset, vm_offset_t *paddr, int prot);
#endif /* FB_INSTALL_CDEV */
diff --git a/sys/dev/fb/gfb.c b/sys/dev/fb/gfb.c
index fcb8aed..4e03169 100644
--- a/sys/dev/fb/gfb.c
+++ b/sys/dev/fb/gfb.c
@@ -451,20 +451,14 @@ gfb_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
}
int
-gfb_mmap(video_adapter_t *adp, vm_offset_t offset, int prot)
+gfb_mmap(video_adapter_t *adp, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
- int error;
+ /* XXX */
if(offset > adp->va_window_size - PAGE_SIZE)
- error = ENXIO;
-#ifdef __i386__
- error = i386_btop(adp->va_info.vi_window + offset);
-#elsif defined(__alpha__)
- error = alpha_btop(adp->va_info.vi_window + offset);
-#else
- error = ENXIO;
-#endif
- return(error);
+ return(ENXIO);
+ *paddr = adp->va_info.vi_window + offset;
+ return(0);
}
int
diff --git a/sys/dev/fb/s3_pci.c b/sys/dev/fb/s3_pci.c
index c7a1be8..69549db 100644
--- a/sys/dev/fb/s3_pci.c
+++ b/sys/dev/fb/s3_pci.c
@@ -389,9 +389,10 @@ s3lfb_blank_display(video_adapter_t *adp, int mode)
}
static int
-s3lfb_mmap(video_adapter_t *adp, vm_offset_t offset, int prot)
+s3lfb_mmap(video_adapter_t *adp, vm_offset_t offset, vm_offset_t *paddr,
+ int prot)
{
- return (*prevvidsw->mmap)(adp, offset, prot);
+ return (*prevvidsw->mmap)(adp, offset, paddr, prot);
}
static int
diff --git a/sys/dev/fb/vga.c b/sys/dev/fb/vga.c
index 56e015b..562f716 100644
--- a/sys/dev/fb/vga.c
+++ b/sys/dev/fb/vga.c
@@ -133,9 +133,10 @@ vga_ioctl(dev_t dev, vga_softc_t *sc, u_long cmd, caddr_t arg, int flag,
}
int
-vga_mmap(dev_t dev, vga_softc_t *sc, vm_offset_t offset, int prot)
+vga_mmap(dev_t dev, vga_softc_t *sc, vm_offset_t offset, vm_offset_t *paddr,
+ int prot)
{
- return genfbmmap(&sc->gensc, sc->adp, offset, prot);
+ return genfbmmap(&sc->gensc, sc->adp, offset, paddr, prot);
}
#endif /* FB_INSTALL_CDEV */
@@ -2449,7 +2450,8 @@ vga_blank_display(video_adapter_t *adp, int mode)
* all adapters
*/
static int
-vga_mmap_buf(video_adapter_t *adp, vm_offset_t offset, int prot)
+vga_mmap_buf(video_adapter_t *adp, vm_offset_t offset, vm_offset_t *paddr,
+ int prot)
{
if (adp->va_info.vi_flags & V_INFO_LINEAR)
return -1;
@@ -2463,15 +2465,8 @@ vga_mmap_buf(video_adapter_t *adp, vm_offset_t offset, int prot)
if (offset > adp->va_window_size - PAGE_SIZE)
return -1;
-#ifdef __i386__
- return i386_btop(adp->va_info.vi_window + offset);
-#endif
-#ifdef __alpha__
- return alpha_btop(adp->va_info.vi_window + offset);
-#endif
-#ifdef __ia64__
- return ia64_btop(adp->va_info.vi_window + offset);
-#endif
+ *paddr = adp->va_info.vi_window + offset;
+ return 0;
}
#ifndef VGA_NO_MODE_CHANGE
diff --git a/sys/dev/fb/vgareg.h b/sys/dev/fb/vgareg.h
index f59c7ee..f390318 100644
--- a/sys/dev/fb/vgareg.h
+++ b/sys/dev/fb/vgareg.h
@@ -87,7 +87,7 @@ int vga_write(dev_t dev, vga_softc_t *sc, struct uio *uio, int flag);
int vga_ioctl(dev_t dev, vga_softc_t *sc, u_long cmd, caddr_t arg,
int flag, struct thread *td);
int vga_mmap(dev_t dev, vga_softc_t *sc, vm_offset_t offset,
- int prot);
+ vm_offset_t *paddr, int prot);
#endif
extern int (*vga_sub_configure)(int flags);
diff --git a/sys/dev/firewire/fwdev.c b/sys/dev/firewire/fwdev.c
index 31b3a2c..a85db14 100644
--- a/sys/dev/firewire/fwdev.c
+++ b/sys/dev/firewire/fwdev.c
@@ -921,13 +921,13 @@ fw_poll(dev_t dev, int events, fw_proc *td)
}
static int
-fw_mmap (dev_t dev, vm_offset_t offset, int nproto)
+fw_mmap (dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nproto)
{
struct firewire_softc *fc;
int unit = DEV2UNIT(dev);
if (DEV_FWMEM(dev))
- return fwmem_mmap(dev, offset, nproto);
+ return fwmem_mmap(dev, offset, paddr, nproto);
fc = devclass_get_softc(firewire_devclass, unit);
diff --git a/sys/dev/firewire/fwmem.c b/sys/dev/firewire/fwmem.c
index dd3a27a..9c64fdc 100644
--- a/sys/dev/firewire/fwmem.c
+++ b/sys/dev/firewire/fwmem.c
@@ -419,7 +419,7 @@ fwmem_poll (dev_t dev, int events, fw_proc *td)
return EINVAL;
}
int
-fwmem_mmap (dev_t dev, vm_offset_t offset, int nproto)
+fwmem_mmap (dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nproto)
{
return EINVAL;
}
diff --git a/sys/dev/gfb/gfb_pci.c b/sys/dev/gfb/gfb_pci.c
index 3b38781..904f536 100644
--- a/sys/dev/gfb/gfb_pci.c
+++ b/sys/dev/gfb/gfb_pci.c
@@ -313,12 +313,12 @@ pcigfb_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
}
int
-pcigfb_mmap(dev_t dev, vm_offset_t offset, int prot)
+pcigfb_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
struct gfb_softc *sc;
sc = (struct gfb_softc *)devclass_get_softc(gfb_devclass, minor(dev));
- return genfbmmap(&sc->gensc, sc->adp, offset, prot);
+ return genfbmmap(&sc->gensc, sc->adp, offset, paddr, prot);
}
#endif /*FB_INSTALL_CDEV*/
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
index f2d463c..cc3c840 100644
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -990,11 +990,10 @@ dsp_poll(dev_t i_dev, int events, struct thread *td)
}
static int
-dsp_mmap(dev_t i_dev, vm_offset_t offset, int nprot)
+dsp_mmap(dev_t i_dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
struct pcm_channel *wrch = NULL, *rdch = NULL, *c;
intrmask_t s;
- int ret;
if (nprot & PROT_EXEC)
return -1;
@@ -1034,11 +1033,11 @@ dsp_mmap(dev_t i_dev, vm_offset_t offset, int nprot)
if (!(c->flags & CHN_F_MAPPED))
c->flags |= CHN_F_MAPPED;
- ret = atop(vtophys(sndbuf_getbufofs(c->bufsoft, offset)));
+ *paddr = vtophys(sndbuf_getbufofs(c->bufsoft, offset));
relchns(i_dev, rdch, wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
splx(s);
- return ret;
+ return 0;
}
int
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index aeb80fa..987e57e 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -3364,14 +3364,14 @@ next_code:
}
static int
-scmmap(dev_t dev, vm_offset_t offset, int nprot)
+scmmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
scr_stat *scp;
scp = SC_STAT(dev);
if (scp != scp->sc->cur_scp)
return -1;
- return (*vidsw[scp->sc->adapter]->mmap)(scp->sc->adp, offset, nprot);
+ return (*vidsw[scp->sc->adapter]->mmap)(scp->sc->adp, offset, paddr, nprot);
}
static int
diff --git a/sys/dev/tdfx/tdfx_pci.c b/sys/dev/tdfx/tdfx_pci.c
index 40fcfad..33e0896 100644
--- a/sys/dev/tdfx/tdfx_pci.c
+++ b/sys/dev/tdfx/tdfx_pci.c
@@ -441,7 +441,7 @@ tdfx_close(dev_t dev, int fflag, int devtype, struct thread *td)
}
static int
-tdfx_mmap(dev_t dev, vm_offset_t offset, int nprot)
+tdfx_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
/*
* mmap(2) is called by a user process to request that an area of memory
@@ -472,14 +472,17 @@ tdfx_mmap(dev_t dev, vm_offset_t offset, int nprot)
/* We must stay within the bound of our address space */
if((offset & 0xff000000) == tdfx_info[0]->addr0) {
offset &= 0xffffff;
- return atop(rman_get_start(tdfx_info[0]->memrange) + offset);
+ *paddr = rman_get_start(tdfx_info[0]->memrange) + offset;
+ return 0;
}
if(tdfx_count > 1) {
tdfx_info[1] = (struct tdfx_softc*)devclass_get_softc(tdfx_devclass, 1);
if((offset & 0xff000000) == tdfx_info[1]->addr0) {
offset &= 0xffffff;
- return atop(rman_get_start(tdfx_info[1]->memrange) + offset);
+ *paddr = rman_get_start(tdfx_info[1]->memrange) +
+ offset;
+ return 0;
}
}
diff --git a/sys/geom/geom_stats.c b/sys/geom/geom_stats.c
index caf0780..2577b2a 100644
--- a/sys/geom/geom_stats.c
+++ b/sys/geom/geom_stats.c
@@ -122,15 +122,17 @@ static struct cdevsw geom_stats_cdevsw = {
};
static int
-g_stat_mmap(dev_t dev, vm_offset_t offset, int nprot)
+g_stat_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
struct statspage *spp;
if (nprot != VM_PROT_READ)
return (-1);
TAILQ_FOREACH(spp, &pagelist, list) {
- if (offset == 0)
- return (vtophys(spp->stat) >> PAGE_SHIFT);
+ if (offset == 0) {
+ *paddr = vtophys(spp->stat);
+ return (0);
+ }
offset -= PAGE_SIZE;
}
return (-1);
diff --git a/sys/i386/i386/elan-mmcr.c b/sys/i386/i386/elan-mmcr.c
index c36a154..cf324d3 100644
--- a/sys/i386/i386/elan-mmcr.c
+++ b/sys/i386/i386/elan-mmcr.c
@@ -309,14 +309,15 @@ elan_write(dev_t dev, struct uio *uio, int ioflag)
}
static int
-elan_mmap(dev_t dev, vm_offset_t offset, int nprot)
+elan_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
if (minor(dev) != ELAN_MMCR)
return (EOPNOTSUPP);
if (offset >= 0x1000)
return (-1);
- return (i386_btop(0xfffef000));
+ *paddr = 0xfffef000;
+ return (0);
}
static int
diff --git a/sys/i386/i386/mem.c b/sys/i386/i386/mem.c
index 41fa636..a045d96 100644
--- a/sys/i386/i386/mem.c
+++ b/sys/i386/i386/mem.c
@@ -215,22 +215,25 @@ mmrw(dev_t dev, struct uio *uio, int flags)
* instead of going through read/write *
\*******************************************************/
static int
-memmmap(dev_t dev, vm_offset_t offset, int prot)
+memmmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
switch (minor(dev))
{
/* minor device 0 is physical memory */
case 0:
- return (i386_btop(offset));
+ *paddr = offset;
+ break;
/* minor device 1 is kernel memory */
case 1:
- return (i386_btop(vtophys(offset)));
+ *paddr = vtophys(offset);
+ break;
default:
return (-1);
}
+ return (0);
}
/*
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index 8d6df39..ca469aa 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -3124,13 +3124,6 @@ pmap_page_protect(vm_page_t m, vm_prot_t prot)
}
}
-vm_offset_t
-pmap_phys_address(ppn)
- int ppn;
-{
- return (i386_ptob(ppn));
-}
-
/*
* pmap_ts_referenced:
*
diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c
index 45b74b3..72a23e0 100644
--- a/sys/i386/isa/pcvt/pcvt_drv.c
+++ b/sys/i386/isa/pcvt/pcvt_drv.c
@@ -420,11 +420,12 @@ pcvt_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)
* driver mmap
*---------------------------------------------------------------------------*/
static int
-pcvt_mmap(dev_t dev, vm_offset_t offset, int nprot)
+pcvt_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
if (offset > 0x20000 - PAGE_SIZE)
return -1;
- return i386_btop((0xa0000 + offset));
+ *paddr = 0xa0000 + offset;
+ return 0;
}
/*---------------------------------------------------------------------------*
diff --git a/sys/i386/isa/spigot.c b/sys/i386/isa/spigot.c
index bc6df62..79ad930 100644
--- a/sys/i386/isa/spigot.c
+++ b/sys/i386/isa/spigot.c
@@ -273,7 +273,7 @@ struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[unit];
}
static int
-spigot_mmap(dev_t dev, vm_offset_t offset, int nprot)
+spigot_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[0];
@@ -285,5 +285,6 @@ struct spigot_softc *ss = (struct spigot_softc *)&spigot_softc[0];
if(nprot & PROT_EXEC)
return -1;
- return i386_btop(ss->maddr);
+ *paddr = ss->maddr;
+ return 0;
}
diff --git a/sys/i386/isa/vesa.c b/sys/i386/isa/vesa.c
index 5284cec..3c3f604 100644
--- a/sys/i386/isa/vesa.c
+++ b/sys/i386/isa/vesa.c
@@ -1278,7 +1278,8 @@ vesa_blank_display(video_adapter_t *adp, int mode)
}
static int
-vesa_mmap(video_adapter_t *adp, vm_offset_t offset, int prot)
+vesa_mmap(video_adapter_t *adp, vm_offset_t offset, vm_offset_t *paddr,
+ int prot)
{
#if VESA_DEBUG > 0
printf("vesa_mmap(): window:0x%x, buffer:0x%x, offset:0x%x\n",
@@ -1290,14 +1291,10 @@ vesa_mmap(video_adapter_t *adp, vm_offset_t offset, int prot)
/* XXX: is this correct? */
if (offset > adp->va_window_size - PAGE_SIZE)
return -1;
-#ifdef __i386__
- return i386_btop(adp->va_info.vi_buffer + offset);
-#endif
-#ifdef __alpha__ /* XXX */
- return alpha_btop(adp->va_info.vi_buffer + offset);
-#endif
+ *paddr = adp->va_info.vi_buffer + offset;
+ return 0;
} else {
- return (*prevvidsw->mmap)(adp, offset, prot);
+ return (*prevvidsw->mmap)(adp, offset, paddr, prot);
}
}
diff --git a/sys/ia64/ia64/mem.c b/sys/ia64/ia64/mem.c
index 152f9b4..146b684 100644
--- a/sys/ia64/ia64/mem.c
+++ b/sys/ia64/ia64/mem.c
@@ -221,7 +221,7 @@ kmemphys:
* instead of going through read/write *
\*******************************************************/
static int
-memmmap(dev_t dev, vm_offset_t offset, int prot)
+memmmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
/*
* /dev/mem is the only one that makes sense through this
@@ -237,7 +237,8 @@ memmmap(dev_t dev, vm_offset_t offset, int prot)
*/
if ((prot & ia64_pa_access(atop((vm_offset_t)offset))) != prot)
return (-1);
- return (ia64_btop(IA64_PHYS_TO_RR7(offset)));
+ *paddr = IA64_PHYS_TO_RR7(offset);
+ return (0);
}
static int
diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c
index 0be8b83..738fefc 100644
--- a/sys/ia64/ia64/pmap.c
+++ b/sys/ia64/ia64/pmap.c
@@ -2236,12 +2236,6 @@ pmap_page_protect(vm_page_t m, vm_prot_t prot)
}
}
-vm_offset_t
-pmap_phys_address(int ppn)
-{
- return (ia64_ptob(ppn));
-}
-
/*
* pmap_ts_referenced:
*
diff --git a/sys/isa/vga_isa.c b/sys/isa/vga_isa.c
index 101dc55..9e7e61b 100644
--- a/sys/isa/vga_isa.c
+++ b/sys/isa/vga_isa.c
@@ -196,9 +196,9 @@ isavga_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
}
static int
-isavga_mmap(dev_t dev, vm_offset_t offset, int prot)
+isavga_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
- return vga_mmap(dev, VGA_SOFTC(VGA_UNIT(dev)), offset, prot);
+ return vga_mmap(dev, VGA_SOFTC(VGA_UNIT(dev)), offset, paddr, prot);
}
#endif /* FB_INSTALL_CDEV */
diff --git a/sys/kern/subr_xxx.c b/sys/kern/subr_xxx.c
index 6730bc7..65e4096 100644
--- a/sys/kern/subr_xxx.c
+++ b/sys/kern/subr_xxx.c
@@ -132,9 +132,10 @@ nokqfilter(dev, kn)
}
int
-nommap(dev, offset, nprot)
+nommap(dev, offset, paddr, nprot)
dev_t dev;
vm_offset_t offset;
+ vm_offset_t *paddr;
int nprot;
{
diff --git a/sys/pc98/cbus/gdc.c b/sys/pc98/cbus/gdc.c
index 0f8aadf..e5d0788 100644
--- a/sys/pc98/cbus/gdc.c
+++ b/sys/pc98/cbus/gdc.c
@@ -397,12 +397,12 @@ gdcioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
}
static int
-gdcmmap(dev_t dev, vm_offset_t offset, int prot)
+gdcmmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
gdc_softc_t *sc;
sc = GDC_SOFTC(GDC_UNIT(dev));
- return genfbmmap(&sc->gensc, sc->adp, offset, prot);
+ return genfbmmap(&sc->gensc, sc->adp, offset, paddr, prot);
}
#endif /* FB_INSTALL_CDEV */
diff --git a/sys/pc98/pc98/pc98gdc.c b/sys/pc98/pc98/pc98gdc.c
index 0f8aadf..e5d0788 100644
--- a/sys/pc98/pc98/pc98gdc.c
+++ b/sys/pc98/pc98/pc98gdc.c
@@ -397,12 +397,12 @@ gdcioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
}
static int
-gdcmmap(dev_t dev, vm_offset_t offset, int prot)
+gdcmmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
gdc_softc_t *sc;
sc = GDC_SOFTC(GDC_UNIT(dev));
- return genfbmmap(&sc->gensc, sc->adp, offset, prot);
+ return genfbmmap(&sc->gensc, sc->adp, offset, paddr, prot);
}
#endif /* FB_INSTALL_CDEV */
diff --git a/sys/pc98/pc98/syscons.c b/sys/pc98/pc98/syscons.c
index e9fc96e..0adbd50 100644
--- a/sys/pc98/pc98/syscons.c
+++ b/sys/pc98/pc98/syscons.c
@@ -3383,14 +3383,14 @@ next_code:
}
static int
-scmmap(dev_t dev, vm_offset_t offset, int nprot)
+scmmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
scr_stat *scp;
scp = SC_STAT(dev);
if (scp != scp->sc->cur_scp)
return -1;
- return (*vidsw[scp->sc->adapter]->mmap)(scp->sc->adp, offset, nprot);
+ return (*vidsw[scp->sc->adapter]->mmap)(scp->sc->adp, offset, paddr, nprot);
}
static int
diff --git a/sys/pci/agp.c b/sys/pci/agp.c
index f821026..be2f7f8 100644
--- a/sys/pci/agp.c
+++ b/sys/pci/agp.c
@@ -722,14 +722,15 @@ agp_ioctl(dev_t kdev, u_long cmd, caddr_t data, int fflag, struct thread *td)
}
static int
-agp_mmap(dev_t kdev, vm_offset_t offset, int prot)
+agp_mmap(dev_t kdev, vm_offset_t offset, vm_offset_t *paddr, int prot)
{
device_t dev = KDEV2DEV(kdev);
struct agp_softc *sc = device_get_softc(dev);
if (offset > AGP_GET_APERTURE(dev))
return -1;
- return atop(rman_get_start(sc->as_aperture) + offset);
+ *paddr = rman_get_start(sc->as_aperture) + offset;
+ return 0;
}
/* Implementation of the kernel api */
diff --git a/sys/pci/meteor.c b/sys/pci/meteor.c
index 340c709..fd1f7f6 100644
--- a/sys/pci/meteor.c
+++ b/sys/pci/meteor.c
@@ -2107,7 +2107,7 @@ meteor_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
}
int
-meteor_mmap(dev_t dev, vm_offset_t offset, int nprot)
+meteor_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
int unit;
@@ -2126,6 +2126,7 @@ meteor_mmap(dev_t dev, vm_offset_t offset, int nprot)
if(offset >= mtr->alloc_pages * PAGE_SIZE)
return -1;
- return i386_btop(vtophys(mtr->bigbuf) + offset);
+ *paddr = vtophys(mtr->bigbuf) + offset;
+ return 0;
}
#endif
diff --git a/sys/pci/xrpu.c b/sys/pci/xrpu.c
index dc21896..379a749 100644
--- a/sys/pci/xrpu.c
+++ b/sys/pci/xrpu.c
@@ -136,12 +136,13 @@ xrpu_close(dev_t dev, int flag, int mode, struct thread *td)
}
static int
-xrpu_mmap(dev_t dev, vm_offset_t offset, int nprot)
+xrpu_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot)
{
struct softc *sc = dev->si_drv1;
if (offset >= 0x1000000)
return (-1);
- return (i386_btop(sc->physbase + offset));
+ *paddr = sc->physbase + offset;
+ return (0);
}
static int
diff --git a/sys/powerpc/aim/mmu_oea.c b/sys/powerpc/aim/mmu_oea.c
index 77f3451..3180768 100644
--- a/sys/powerpc/aim/mmu_oea.c
+++ b/sys/powerpc/aim/mmu_oea.c
@@ -1452,13 +1452,6 @@ pmap_protect(pmap_t pm, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot)
}
}
-vm_offset_t
-pmap_phys_address(int ppn)
-{
- TODO;
- return (0);
-}
-
/*
* Map a list of wired pages into kernel virtual address space. This is
* intended for temporary mappings which do not need page modification or
diff --git a/sys/powerpc/powerpc/mmu_oea.c b/sys/powerpc/powerpc/mmu_oea.c
index 77f3451..3180768 100644
--- a/sys/powerpc/powerpc/mmu_oea.c
+++ b/sys/powerpc/powerpc/mmu_oea.c
@@ -1452,13 +1452,6 @@ pmap_protect(pmap_t pm, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot)
}
}
-vm_offset_t
-pmap_phys_address(int ppn)
-{
- TODO;
- return (0);
-}
-
/*
* Map a list of wired pages into kernel virtual address space. This is
* intended for temporary mappings which do not need page modification or
diff --git a/sys/powerpc/powerpc/pmap.c b/sys/powerpc/powerpc/pmap.c
index 77f3451..3180768 100644
--- a/sys/powerpc/powerpc/pmap.c
+++ b/sys/powerpc/powerpc/pmap.c
@@ -1452,13 +1452,6 @@ pmap_protect(pmap_t pm, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot)
}
}
-vm_offset_t
-pmap_phys_address(int ppn)
-{
- TODO;
- return (0);
-}
-
/*
* Map a list of wired pages into kernel virtual address space. This is
* intended for temporary mappings which do not need page modification or
diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c
index ec19d89..12372a1 100644
--- a/sys/sparc64/sparc64/pmap.c
+++ b/sys/sparc64/sparc64/pmap.c
@@ -1778,13 +1778,6 @@ pmap_page_protect(vm_page_t m, vm_prot_t prot)
}
}
-vm_offset_t
-pmap_phys_address(int ppn)
-{
-
- return (sparc64_ptob(ppn));
-}
-
/*
* pmap_ts_referenced:
*
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index 10d09d9..7be960f 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -157,7 +157,8 @@ typedef int d_read_t(dev_t dev, struct uio *uio, int ioflag);
typedef int d_write_t(dev_t dev, struct uio *uio, int ioflag);
typedef int d_poll_t(dev_t dev, int events, struct thread *td);
typedef int d_kqfilter_t(dev_t dev, struct knote *kn);
-typedef int d_mmap_t(dev_t dev, vm_offset_t offset, int nprot);
+typedef int d_mmap_t(dev_t dev, vm_offset_t offset, vm_offset_t *paddr,
+ int nprot);
typedef int l_open_t(dev_t dev, struct tty *tp);
typedef int l_close_t(struct tty *tp, int flag);
diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h
index 10d09d9..7be960f 100644
--- a/sys/sys/linedisc.h
+++ b/sys/sys/linedisc.h
@@ -157,7 +157,8 @@ typedef int d_read_t(dev_t dev, struct uio *uio, int ioflag);
typedef int d_write_t(dev_t dev, struct uio *uio, int ioflag);
typedef int d_poll_t(dev_t dev, int events, struct thread *td);
typedef int d_kqfilter_t(dev_t dev, struct knote *kn);
-typedef int d_mmap_t(dev_t dev, vm_offset_t offset, int nprot);
+typedef int d_mmap_t(dev_t dev, vm_offset_t offset, vm_offset_t *paddr,
+ int nprot);
typedef int l_open_t(dev_t dev, struct tty *tp);
typedef int l_close_t(struct tty *tp, int flag);
diff --git a/sys/vm/device_pager.c b/sys/vm/device_pager.c
index e7acedc..85f29ae 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 20a5bd3..a403f6f 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);
OpenPOWER on IntegriCloud