summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_conf.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2009-08-28 14:06:55 +0000
committerjhb <jhb@FreeBSD.org>2009-08-28 14:06:55 +0000
commit7b069e86c6dbd397d4d622acf8c924f2ade8127d (patch)
tree90a42d70408be865b0d3f244445d7106ff89a054 /sys/kern/kern_conf.c
parentb546d1fee4837a126b1e940e542b8d9ff2132bc6 (diff)
downloadFreeBSD-src-7b069e86c6dbd397d4d622acf8c924f2ade8127d.zip
FreeBSD-src-7b069e86c6dbd397d4d622acf8c924f2ade8127d.tar.gz
Extend the device pager to support different memory attributes on different
pages in an object. - Add a new variant of d_mmap() currently called d_mmap2() which accepts an additional in/out parameter that is the memory attribute to use for the requested page. - A driver either uses d_mmap() or d_mmap2() for all requests but not both. The current implementation uses a flag in the cdevsw (D_MMAP2) to indicate that the driver provides a d_mmap2() handler instead of d_mmap(). This is done to make the change ABI compatible with existing drivers and MFC'able to 7 and 8. Submitted by: alc MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_conf.c')
-rw-r--r--sys/kern/kern_conf.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c
index 8a5577c..8504e48 100644
--- a/sys/kern/kern_conf.c
+++ b/sys/kern/kern_conf.c
@@ -302,7 +302,7 @@ static struct cdevsw dead_cdevsw = {
#define no_read (d_read_t *)enodev
#define no_write (d_write_t *)enodev
#define no_ioctl (d_ioctl_t *)enodev
-#define no_mmap (d_mmap_t *)enodev
+#define no_mmap (d_mmap2_t *)enodev
#define no_kqfilter (d_kqfilter_t *)enodev
#define no_mmap_single (d_mmap_single_t *)enodev
@@ -469,7 +469,8 @@ giant_kqfilter(struct cdev *dev, struct knote *kn)
}
static int
-giant_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot)
+giant_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot,
+ vm_memattr_t *memattr)
{
struct cdevsw *dsw;
int retval;
@@ -478,7 +479,11 @@ giant_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot)
if (dsw == NULL)
return (ENXIO);
mtx_lock(&Giant);
- retval = dsw->d_gianttrick->d_mmap(dev, offset, paddr, nprot);
+ if (dsw->d_gianttrick->d_flags & D_MMAP2)
+ retval = dsw->d_gianttrick->d_mmap2(dev, offset, paddr, nprot,
+ memattr);
+ else
+ retval = dsw->d_gianttrick->d_mmap(dev, offset, paddr, nprot);
mtx_unlock(&Giant);
dev_relthread(dev);
return (retval);
@@ -614,6 +619,7 @@ prep_cdevsw(struct cdevsw *devsw)
if (devsw->d_gianttrick == NULL) {
memcpy(dsw2, devsw, sizeof *dsw2);
devsw->d_gianttrick = dsw2;
+ devsw->d_flags |= D_MMAP2;
dsw2 = NULL;
}
}
@@ -634,7 +640,7 @@ prep_cdevsw(struct cdevsw *devsw)
FIXUP(d_write, no_write, giant_write);
FIXUP(d_ioctl, no_ioctl, giant_ioctl);
FIXUP(d_poll, no_poll, giant_poll);
- FIXUP(d_mmap, no_mmap, giant_mmap);
+ FIXUP(d_mmap2, no_mmap, giant_mmap);
FIXUP(d_strategy, no_strategy, giant_strategy);
FIXUP(d_kqfilter, no_kqfilter, giant_kqfilter);
FIXUP(d_mmap_single, no_mmap_single, giant_mmap_single);
OpenPOWER on IntegriCloud