mm.h revision 1.4
11.4Sandvar/*	$NetBSD: mm.h,v 1.4 2021/09/11 20:28:06 andvar Exp $	*/
21.2Srmind
31.2Srmind/*-
41.2Srmind * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>.
51.2Srmind * All rights reserved.
61.2Srmind *
71.2Srmind * Redistribution and use in source and binary forms, with or without
81.2Srmind * modification, are permitted provided that the following conditions
91.2Srmind * are met:
101.2Srmind *
111.2Srmind * 1. Redistributions of source code must retain the above copyright
121.2Srmind *    notice, this list of conditions and the following disclaimer.
131.2Srmind * 2. Redistributions in binary form must reproduce the above copyright
141.2Srmind *    notice, this list of conditions and the following disclaimer in
151.2Srmind *    the documentation and/or other materials provided with the
161.2Srmind *    distribution.
171.2Srmind *
181.2Srmind * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
191.2Srmind * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
201.2Srmind * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
211.2Srmind * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
221.2Srmind * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
231.2Srmind * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
241.2Srmind * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
251.2Srmind * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
261.2Srmind * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
271.2Srmind * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
281.2Srmind * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
291.2Srmind * SUCH DAMAGE.
301.2Srmind */
311.2Srmind
321.2Srmind#ifndef _SYS_DEV_MM_H_
331.2Srmind#define _SYS_DEV_MM_H_
341.2Srmind
351.2Srmind#include <sys/uio.h>
361.2Srmind#include <uvm/uvm_prot.h>
371.2Srmind
381.2Srmind/*
391.2Srmind * Required access check for the physical address.
401.2Srmind */
411.2Srmindint	mm_md_physacc(paddr_t, vm_prot_t);
421.2Srmind
431.2Srmind/*
441.2Srmind * Optional open() hook for MD.  Used by i386 for /dev/io emulation.
451.2Srmind *
461.2Srmind * machine/types.h must define __HAVE_MM_MD_OPEN to use this.
471.2Srmind */
481.2Srmindint	mm_md_open(dev_t, int, int, struct lwp *);
491.2Srmind
501.2Srmind/*
511.2Srmind * Optional read/write hook for additional minor devices.
521.2Srmind * Must handle the complete uio, not execute in a loop.
531.2Srmind *
541.2Srmind * machine/types.h must define __HAVE_MM_MD_READWRITE to use this.
551.2Srmind */
561.2Srmindint	mm_md_readwrite(dev_t, struct uio *);
571.2Srmind
581.2Srmind/*
591.2Srmind * Optional mmap hook for additional MD minor devices.
601.2Srmind *
611.2Srmind * machine/types.h must define __HAVE_MM_MD_READWRITE to use this.
621.2Srmind */
631.2Srmindpaddr_t	mm_md_mmap(dev_t, off_t, int);
641.2Srmind
651.2Srmind/*
661.2Srmind * Optional access check for the virtual address. The third argument tells
671.4Sandvar * mm that the check was done and uvm_kernacc is overridden.
681.2Srmind *
691.2Srmind * machine/types.h must define __HAVE_MM_MD_KERNACC to use this.
701.2Srmind */
711.2Srmindint	mm_md_kernacc(void *, vm_prot_t, bool *);
721.2Srmind
731.2Srmind/*
741.2Srmind * Optional hook to map physical address back to pre-mapped virtual space.
751.2Srmind * This is used e.g. when physical memory is lineary mapped.
761.2Srmind *
771.2Srmind * machine/types.h must define __HAVE_MM_MD_DIRECT_MAPPED_PHYS to use this.
781.2Srmind */
791.2Srmindbool	mm_md_direct_mapped_phys(paddr_t, vaddr_t *);
801.2Srmind
811.2Srmind/*
821.2Srmind * Optional hook to map virtual address back to physical address for explicit
831.2Srmind * access check. This is used e.g. when physical memory is lineary mapped.
841.2Srmind *
851.2Srmind * machine/types.h must define __HAVE_MM_MD_DIRECT_MAPPED_IO to use this.
861.2Srmind */
871.2Srmindbool	mm_md_direct_mapped_io(void *, paddr_t *);
881.2Srmind
891.2Srmind/*
901.2Srmind * Some architectures may need to deal with cache aliasing issues.
911.3Smatt * Optional hook to fetch a page's current color and returns whether
921.3Smatt * that page can be direct mapped.
931.3Smatt * machine/types.h must define __HAVE_MM_MD_CACHE_ALIASING to use this.
941.2Srmind */
951.3Smattbool	mm_md_page_color(paddr_t, int *);
961.2Srmind
971.2Srmind#endif /* _SYS_DEV_MM_H_ */
98