| 1 | /* $NetBSD: mm.h,v 1.3 2016/07/11 16:13:28 matt Exp $ */ |
| 2 | |
| 3 | /*- |
| 4 | * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in |
| 15 | * the documentation and/or other materials provided with the |
| 16 | * distribution. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 22 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 26 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 28 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 29 | * SUCH DAMAGE. |
| 30 | */ |
| 31 | |
| 32 | #ifndef _SYS_DEV_MM_H_ |
| 33 | #define _SYS_DEV_MM_H_ |
| 34 | |
| 35 | #include <sys/uio.h> |
| 36 | #include <uvm/uvm_prot.h> |
| 37 | |
| 38 | /* |
| 39 | * Required access check for the physical address. |
| 40 | */ |
| 41 | int mm_md_physacc(paddr_t, vm_prot_t); |
| 42 | |
| 43 | /* |
| 44 | * Optional open() hook for MD. Used by i386 for /dev/io emulation. |
| 45 | * |
| 46 | * machine/types.h must define __HAVE_MM_MD_OPEN to use this. |
| 47 | */ |
| 48 | int mm_md_open(dev_t, int, int, struct lwp *); |
| 49 | |
| 50 | /* |
| 51 | * Optional read/write hook for additional minor devices. |
| 52 | * Must handle the complete uio, not execute in a loop. |
| 53 | * |
| 54 | * machine/types.h must define __HAVE_MM_MD_READWRITE to use this. |
| 55 | */ |
| 56 | int mm_md_readwrite(dev_t, struct uio *); |
| 57 | |
| 58 | /* |
| 59 | * Optional mmap hook for additional MD minor devices. |
| 60 | * |
| 61 | * machine/types.h must define __HAVE_MM_MD_READWRITE to use this. |
| 62 | */ |
| 63 | paddr_t mm_md_mmap(dev_t, off_t, int); |
| 64 | |
| 65 | /* |
| 66 | * Optional access check for the virtual address. The third argument tells |
| 67 | * mm that the check was done and uvm_kernacc is overriden. |
| 68 | * |
| 69 | * machine/types.h must define __HAVE_MM_MD_KERNACC to use this. |
| 70 | */ |
| 71 | int mm_md_kernacc(void *, vm_prot_t, bool *); |
| 72 | |
| 73 | /* |
| 74 | * Optional hook to map physical address back to pre-mapped virtual space. |
| 75 | * This is used e.g. when physical memory is lineary mapped. |
| 76 | * |
| 77 | * machine/types.h must define __HAVE_MM_MD_DIRECT_MAPPED_PHYS to use this. |
| 78 | */ |
| 79 | bool mm_md_direct_mapped_phys(paddr_t, vaddr_t *); |
| 80 | |
| 81 | /* |
| 82 | * Optional hook to map virtual address back to physical address for explicit |
| 83 | * access check. This is used e.g. when physical memory is lineary mapped. |
| 84 | * |
| 85 | * machine/types.h must define __HAVE_MM_MD_DIRECT_MAPPED_IO to use this. |
| 86 | */ |
| 87 | bool mm_md_direct_mapped_io(void *, paddr_t *); |
| 88 | |
| 89 | /* |
| 90 | * Some architectures may need to deal with cache aliasing issues. |
| 91 | * Optional hook to fetch a page's current color and returns whether |
| 92 | * that page can be direct mapped. |
| 93 | * machine/types.h must define __HAVE_MM_MD_CACHE_ALIASING to use this. |
| 94 | */ |
| 95 | bool mm_md_page_color(paddr_t, int *); |
| 96 | |
| 97 | #endif /* _SYS_DEV_MM_H_ */ |
| 98 | |