FreeBSD/sys/powerpc/powerpc/mem.c
/*
 * allow user processes to MMAP some memory sections
 * instead of going through read/write
 */
allow user processes to MMAP some memory sections
instead of going through read/write
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, vm_memattr_t *memattr)
{
	int i;
	if (dev2unit(dev) == CDEV_MINOR_MEM)
		*paddr = offset;
	else if (dev2unit(dev) == CDEV_MINOR_KMEM)
		*paddr = vtophys(offset);
	else
		return (EFAULT);
	for (i = 0; i < mem_range_softc.mr_ndesc; i++) {
		if (!(mem_range_softc.mr_desc[i].mr_flags & MDF_ACTIVE))
			continue;
		if (offset >= mem_range_softc.mr_desc[i].mr_base &&
		    offset < mem_range_softc.mr_desc[i].mr_base +
		    mem_range_softc.mr_desc[i].mr_len) {
			switch (mem_range_softc.mr_desc[i].mr_flags &
			    MDF_ATTRMASK) {
			case MDF_WRITEBACK:
				*memattr = VM_MEMATTR_WRITE_BACK;
				break;
			case MDF_WRITECOMBINE:
				*memattr = VM_MEMATTR_WRITE_COMBINING;
				break;
			case MDF_UNCACHEABLE:
				*memattr = VM_MEMATTR_UNCACHEABLE;
				break;
			case MDF_WRITETHROUGH:
				*memattr = VM_MEMATTR_WRITE_THROUGH;
				break;
			}
			break;
		}
	}
	return (0);
}
int memmmap ( struct cdev * dev , vm_ooffset_t offset , vm_paddr_t * paddr , int prot , vm_memattr_t * memattr ) { int i ; if ( dev2unit ( dev ) == CDEV_MINOR_MEM ) * paddr = offset ; else if ( dev2unit ( dev ) == CDEV_MINOR_KMEM ) * paddr = vtophys ( offset ) ; else return ( EFAULT ) ; for ( i = 0 ; i < mem_range_softc . mr_ndesc ; i ++ ) { if ( ! ( mem_range_softc . mr_desc [ i ] . mr_flags & MDF_ACTIVE ) ) continue ; if ( offset >= mem_range_softc . mr_desc [ i ] . mr_base && offset < mem_range_softc . mr_desc [ i ] . mr_base + mem_range_softc . mr_desc [ i ] . mr_len ) { switch ( mem_range_softc . mr_desc [ i ] . mr_flags & MDF_ATTRMASK ) { case MDF_WRITEBACK : * memattr = VM_MEMATTR_WRITE_BACK ; break ; case MDF_WRITECOMBINE : * memattr = VM_MEMATTR_WRITE_COMBINING ; break ; case MDF_UNCACHEABLE : * memattr = VM_MEMATTR_UNCACHEABLE ; break ; case MDF_WRITETHROUGH : * memattr = VM_MEMATTR_WRITE_THROUGH ; break ; } break ; } } return ( 0 ) ; }
allow user processes to MMAP some memory sections
 instead of going through read/write
allow user processes to MMAP some memory sections instead of going through read / write