Changeset b68ca55 in rtems-libbsd


Ignore:
Timestamp:
07/18/19 08:56:26 (4 years ago)
Author:
Vijay Kumar Banerjee <vijaykumar9597@…>
Branches:
5, master
Children:
e3bc24e
Parents:
bc2ba9a
git-author:
Vijay Kumar Banerjee <vijaykumar9597@…> (07/18/19 08:56:26)
git-committer:
Christian Mauderer <oss@…> (07/27/19 11:49:07)
Message:

Add mmap

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • freebsd/sys/kern/kern_conf.c

    rbc2ba9a rb68ca55  
    329329        .d_ioctl =      dead_ioctl,
    330330        .d_poll =       dead_poll,
    331 #ifndef __rtems__
    332331        .d_mmap =       dead_mmap,
     332#ifndef __rtems__
    333333        .d_strategy =   dead_strategy,
    334334#endif /* __rtems__ */
     
    523523}
    524524
    525 #ifndef __rtems__
    526525static int
    527526giant_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot,
     
    542541}
    543542
     543#ifndef __rtems__
    544544static int
    545545giant_mmap_single(struct cdev *dev, vm_ooffset_t *offset, vm_size_t size,
     
    668668                devsw->d_ioctl = dead_ioctl;
    669669                devsw->d_poll = dead_poll;
    670 #ifndef __rtems__
    671670                devsw->d_mmap = dead_mmap;
     671#ifndef __rtems__
    672672                devsw->d_mmap_single = dead_mmap_single;
    673673                devsw->d_strategy = dead_strategy;
     
    703703        FIXUP(d_ioctl,          no_ioctl,       giant_ioctl);
    704704        FIXUP(d_poll,           no_poll,        giant_poll);
    705 #ifndef __rtems__
    706705        FIXUP(d_mmap,           no_mmap,        giant_mmap);
     706#ifndef __rtems__
    707707        FIXUP(d_strategy,       no_strategy,    giant_strategy);
    708708#endif /* __rtems__ */
  • freebsd/sys/sys/conf.h

    rbc2ba9a rb68ca55  
    210210        d_ioctl_t               *d_ioctl;
    211211        d_poll_t                *d_poll;
    212 #ifndef __rtems__
    213212        d_mmap_t                *d_mmap;
     213#ifndef __rtems__
    214214        d_strategy_t            *d_strategy;
    215215        dumper_t                *d_dump;
  • rtemsbsd/include/machine/vm.h

    rbc2ba9a rb68ca55  
     1#define VM_MEMATTR_DEFAULT 0
     2#define VM_MEMATTR_UNCACHEABLE 1
  • rtemsbsd/sys/fs/devfs/devfs_devs.c

    rbc2ba9a rb68ca55  
    388388}
    389389
     390static int
     391devfs_imfs_mmap(rtems_libio_t *iop, void **addr, size_t len, int prot,
     392    off_t off)
     393{
     394        struct cdev *cdev = devfs_imfs_get_context_by_iop(iop);
     395        struct file *fp = rtems_bsd_iop_to_fp(iop);
     396        struct thread *td = rtems_bsd_get_curthread_or_null();
     397        struct file *fpop;
     398        struct cdevsw *dsw;
     399        int error, ref;
     400
     401        if (td != 0) {
     402                if (cdev == NULL) {
     403                        error = ENXIO;
     404                        goto err;
     405                }
     406                if (cdev->si_flags & SI_ALIAS) {
     407                        cdev = cdev->si_parent;
     408                }
     409                dsw = dev_refthread(cdev, &ref);
     410                if (dsw == NULL) {
     411                        error = ENXIO;
     412                        goto err;
     413                }
     414                fpop = td->td_fpop;
     415                curthread->td_fpop = fp;
     416                error = dsw->d_mmap( cdev, off, (vm_paddr_t *) addr, prot, VM_MEMATTR_DEFAULT);
     417                td->td_fpop = fpop;
     418                dev_relthread(cdev, ref);
     419        } else {
     420                error = ENOMEM;
     421        }
     422
     423err:
     424        return rtems_bsd_error_to_status_and_errno(error);
     425}
     426
    390427static const rtems_filesystem_file_handlers_r devfs_imfs_handlers = {
    391428        .open_h = devfs_imfs_open,
     
    404441        .readv_h = devfs_imfs_readv,
    405442        .writev_h = devfs_imfs_writev,
     443        .mmap_h = devfs_imfs_mmap,
    406444};
    407445
  • testsuite/cdev01/test_cdev.c

    rbc2ba9a rb68ca55  
    3131
    3232#include <machine/rtems-bsd-kernel-space.h>
     33#include <machine/vm.h>
    3334#include <sys/types.h>
    3435#include <sys/conf.h>
     36#include <sys/mman.h>
    3537
    3638#include <rtems/seterr.h>
     
    4749static  d_poll_t        testpoll;
    4850static  d_kqfilter_t    testkqfilter;
     51static  d_mmap_t        testmmap;
    4952
    5053static struct cdevsw test_cdevsw = {
     
    6063        .d_poll =       testpoll,
    6164        .d_kqfilter =   testkqfilter,
     65        .d_mmap =       testmmap,
    6266};
    6367
     
    7882        test_state *state = dev->si_drv1;
    7983
    80         assert(*state == TEST_KQFILTER);
     84        assert(*state == TEST_MMAP);
    8185        *state = TEST_CLOSED;
    8286
     
    149153}
    150154
     155static int
     156testmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
     157         int nprot, vm_memattr_t *memattr)
     158{
     159        test_state *state = dev->si_drv1;
     160
     161        assert(paddr != NULL);
     162        assert(memattr == VM_MEMATTR_DEFAULT);
     163        assert(nprot == (PROT_READ | PROT_WRITE));
     164        assert(*state == TEST_KQFILTER);
     165        *state = TEST_MMAP;
     166
     167        return 0;
     168}
     169
    151170void
    152171test_make_dev(test_state *state, const char *name)
  • testsuite/cdev01/test_cdev01.h

    rbc2ba9a rb68ca55  
    4343        TEST_POLL,
    4444        TEST_KQFILTER,
    45         TEST_CLOSED
     45        TEST_MMAP,
     46        TEST_CLOSED,
    4647} test_state;
    4748
  • testsuite/cdev01/test_main.c

    rbc2ba9a rb68ca55  
    3636#include <sys/uio.h>
    3737#include <sys/ioctl.h>
     38#include <sys/mman.h>
    3839
    3940#include <assert.h>
     
    126127        assert(errno == TEST_KQ_ERRNO);
    127128
     129        rv = mmap(NULL, 1, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
     130        assert(rv == 0);
     131
    128132        rv = close(fd);
    129133        assert(rv == 0);
Note: See TracChangeset for help on using the changeset viewer.