riscv: Add memmmap so we can mmap /dev/mem

Reviewed by:	mhorne
Sponsored by:	Axiado
Differential Revision:	https://reviews.freebsd.org/D26622
This commit is contained in:
Kristof Provost 2020-10-01 15:04:55 +00:00
parent 94510c294d
commit 57712c0b76
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366315
2 changed files with 16 additions and 1 deletions

View File

@ -35,6 +35,6 @@
d_open_t memopen;
d_read_t memrw;
d_ioctl_t memioctl_md;
#define memmmap (d_mmap_t *)NULL
d_mmap_t memmmap;
#endif /* _MACHINE_MEMDEV_H_ */

View File

@ -122,6 +122,21 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
return (error);
}
/*
* Allow user processes to MMAP some memory sections
* instead of going through read/write.
*/
int
memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
int prot __unused, vm_memattr_t *memattr __unused)
{
if (dev2unit(dev) == CDEV_MINOR_MEM) {
*paddr = offset;
return (0);
}
return (-1);
}
int
memioctl_md(struct cdev *dev __unused, u_long cmd __unused,
caddr_t data __unused, int flags __unused, struct thread *td __unused)