Changeset b68ca55 in rtems-libbsd
- Timestamp:
- 07/18/19 08:56:26 (4 years ago)
- 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)
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
freebsd/sys/kern/kern_conf.c
rbc2ba9a rb68ca55 329 329 .d_ioctl = dead_ioctl, 330 330 .d_poll = dead_poll, 331 #ifndef __rtems__332 331 .d_mmap = dead_mmap, 332 #ifndef __rtems__ 333 333 .d_strategy = dead_strategy, 334 334 #endif /* __rtems__ */ … … 523 523 } 524 524 525 #ifndef __rtems__526 525 static int 527 526 giant_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, int nprot, … … 542 541 } 543 542 543 #ifndef __rtems__ 544 544 static int 545 545 giant_mmap_single(struct cdev *dev, vm_ooffset_t *offset, vm_size_t size, … … 668 668 devsw->d_ioctl = dead_ioctl; 669 669 devsw->d_poll = dead_poll; 670 #ifndef __rtems__671 670 devsw->d_mmap = dead_mmap; 671 #ifndef __rtems__ 672 672 devsw->d_mmap_single = dead_mmap_single; 673 673 devsw->d_strategy = dead_strategy; … … 703 703 FIXUP(d_ioctl, no_ioctl, giant_ioctl); 704 704 FIXUP(d_poll, no_poll, giant_poll); 705 #ifndef __rtems__706 705 FIXUP(d_mmap, no_mmap, giant_mmap); 706 #ifndef __rtems__ 707 707 FIXUP(d_strategy, no_strategy, giant_strategy); 708 708 #endif /* __rtems__ */ -
freebsd/sys/sys/conf.h
rbc2ba9a rb68ca55 210 210 d_ioctl_t *d_ioctl; 211 211 d_poll_t *d_poll; 212 #ifndef __rtems__213 212 d_mmap_t *d_mmap; 213 #ifndef __rtems__ 214 214 d_strategy_t *d_strategy; 215 215 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 388 388 } 389 389 390 static int 391 devfs_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 423 err: 424 return rtems_bsd_error_to_status_and_errno(error); 425 } 426 390 427 static const rtems_filesystem_file_handlers_r devfs_imfs_handlers = { 391 428 .open_h = devfs_imfs_open, … … 404 441 .readv_h = devfs_imfs_readv, 405 442 .writev_h = devfs_imfs_writev, 443 .mmap_h = devfs_imfs_mmap, 406 444 }; 407 445 -
testsuite/cdev01/test_cdev.c
rbc2ba9a rb68ca55 31 31 32 32 #include <machine/rtems-bsd-kernel-space.h> 33 #include <machine/vm.h> 33 34 #include <sys/types.h> 34 35 #include <sys/conf.h> 36 #include <sys/mman.h> 35 37 36 38 #include <rtems/seterr.h> … … 47 49 static d_poll_t testpoll; 48 50 static d_kqfilter_t testkqfilter; 51 static d_mmap_t testmmap; 49 52 50 53 static struct cdevsw test_cdevsw = { … … 60 63 .d_poll = testpoll, 61 64 .d_kqfilter = testkqfilter, 65 .d_mmap = testmmap, 62 66 }; 63 67 … … 78 82 test_state *state = dev->si_drv1; 79 83 80 assert(*state == TEST_ KQFILTER);84 assert(*state == TEST_MMAP); 81 85 *state = TEST_CLOSED; 82 86 … … 149 153 } 150 154 155 static int 156 testmmap(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 151 170 void 152 171 test_make_dev(test_state *state, const char *name) -
testsuite/cdev01/test_cdev01.h
rbc2ba9a rb68ca55 43 43 TEST_POLL, 44 44 TEST_KQFILTER, 45 TEST_CLOSED 45 TEST_MMAP, 46 TEST_CLOSED, 46 47 } test_state; 47 48 -
testsuite/cdev01/test_main.c
rbc2ba9a rb68ca55 36 36 #include <sys/uio.h> 37 37 #include <sys/ioctl.h> 38 #include <sys/mman.h> 38 39 39 40 #include <assert.h> … … 126 127 assert(errno == TEST_KQ_ERRNO); 127 128 129 rv = mmap(NULL, 1, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 130 assert(rv == 0); 131 128 132 rv = close(fd); 129 133 assert(rv == 0);
Note: See TracChangeset
for help on using the changeset viewer.