Skip to content

Commit

Permalink
Add mmap
Browse files Browse the repository at this point in the history
  • Loading branch information
thelunatic committed Jul 8, 2019
1 parent e1d9605 commit a8fc3b2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
7 changes: 3 additions & 4 deletions freebsd/sys/dev/fb/fbd.c
Expand Up @@ -59,6 +59,9 @@ __FBSDID("$FreeBSD$");
#include <vm/pmap.h>

#include <rtems/bsd/local/fb_if.h>
#ifdef __rtems__
#define vtophys(a) (a)
#endif /* __rtems__ */

LIST_HEAD(fb_list_head_t, fb_list_entry) fb_list_head =
LIST_HEAD_INITIALIZER(fb_list_head);
Expand All @@ -82,9 +85,7 @@ static d_close_t fb_close;
static d_read_t fb_read;
static d_write_t fb_write;
static d_ioctl_t fb_ioctl;
#ifndef __rtems__
static d_mmap_t fb_mmap;
#endif /* __rtems__ */

static struct cdevsw fb_cdevsw = {
.d_version = D_VERSION,
Expand All @@ -94,9 +95,7 @@ static struct cdevsw fb_cdevsw = {
.d_read = fb_read,
.d_write = fb_write,
.d_ioctl = fb_ioctl,
#ifndef __rtems__
.d_mmap = fb_mmap,
#endif /* __rtems__ */
.d_name = "fb",
};

Expand Down
8 changes: 4 additions & 4 deletions freebsd/sys/kern/kern_conf.c
Expand Up @@ -328,8 +328,8 @@ static struct cdevsw dead_cdevsw = {
.d_write = dead_write,
.d_ioctl = dead_ioctl,
.d_poll = dead_poll,
#ifndef __rtems__
.d_mmap = dead_mmap,
#ifndef __rtems__
.d_strategy = dead_strategy,
#endif /* __rtems__ */
.d_name = "dead",
Expand Down Expand Up @@ -522,7 +522,6 @@ giant_kqfilter(struct cdev *dev, struct knote *kn)
return (retval);
}

#ifndef __rtems__
static int
giant_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot,
vm_memattr_t *memattr)
Expand All @@ -541,6 +540,7 @@ giant_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot,
return (retval);
}

#ifndef __rtems__
static int
giant_mmap_single(struct cdev *dev, vm_ooffset_t *offset, vm_size_t size,
vm_object_t *object, int nprot)
Expand Down Expand Up @@ -667,8 +667,8 @@ prep_cdevsw(struct cdevsw *devsw, int flags)
devsw->d_write = dead_write;
devsw->d_ioctl = dead_ioctl;
devsw->d_poll = dead_poll;
#ifndef __rtems__
devsw->d_mmap = dead_mmap;
#ifndef __rtems__
devsw->d_mmap_single = dead_mmap_single;
devsw->d_strategy = dead_strategy;
devsw->d_dump = dead_dump;
Expand Down Expand Up @@ -702,8 +702,8 @@ prep_cdevsw(struct cdevsw *devsw, int flags)
FIXUP(d_write, no_write, giant_write);
FIXUP(d_ioctl, no_ioctl, giant_ioctl);
FIXUP(d_poll, no_poll, giant_poll);
#ifndef __rtems__
FIXUP(d_mmap, no_mmap, giant_mmap);
#ifndef __rtems__
FIXUP(d_strategy, no_strategy, giant_strategy);
#endif /* __rtems__ */
FIXUP(d_kqfilter, no_kqfilter, giant_kqfilter);
Expand Down
2 changes: 1 addition & 1 deletion freebsd/sys/sys/conf.h
Expand Up @@ -209,8 +209,8 @@ struct cdevsw {
d_write_t *d_write;
d_ioctl_t *d_ioctl;
d_poll_t *d_poll;
#ifndef __rtems__
d_mmap_t *d_mmap;
#ifndef __rtems__
d_strategy_t *d_strategy;
dumper_t *d_dump;
#endif /* __rtems__ */
Expand Down
2 changes: 2 additions & 0 deletions rtemsbsd/include/machine/vm.h
@@ -0,0 +1,2 @@
#define VM_MEMATTR_DEFAULT 0
#define VM_MEMATTR_UNCACHEABLE 1
10 changes: 10 additions & 0 deletions rtemsbsd/sys/fs/devfs/devfs_devs.c
Expand Up @@ -387,6 +387,15 @@ devfs_imfs_kqfilter(rtems_libio_t *iop, struct knote *kn)
return error;
}

static int
devfs_imfs_mmap(rtems_libio_t *iop, void **addr, size_t len, int prot,
off_t off)
{
struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);

return (cdev->si_devsw->d_mmap( cdev, off, (vm_paddr_t *) addr, prot, VM_MEMATTR_DEFAULT));
}

static const rtems_filesystem_file_handlers_r devfs_imfs_handlers = {
.open_h = devfs_imfs_open,
.close_h = devfs_imfs_close,
Expand All @@ -403,6 +412,7 @@ static const rtems_filesystem_file_handlers_r devfs_imfs_handlers = {
.kqfilter_h = devfs_imfs_kqfilter,
.readv_h = devfs_imfs_readv,
.writev_h = devfs_imfs_writev,
.mmap_h = devfs_imfs_mmap,
};

static const IMFS_node_control devfs_imfs_control = IMFS_GENERIC_INITIALIZER(
Expand Down

0 comments on commit a8fc3b2

Please sign in to comment.