iommuvar.h revision 117390
1/* 2 * Copyright (c) 1999 Matthew R. Green 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. The name of the author may not be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * from: NetBSD: iommuvar.h,v 1.9 2001/07/20 00:07:13 eeh Exp 29 * 30 * $FreeBSD: head/sys/sparc64/include/iommuvar.h 117390 2003-07-10 23:27:35Z tmm $ 31 */ 32 33#ifndef _MACHINE_IOMMUVAR_H_ 34#define _MACHINE_IOMMUVAR_H_ 35 36#define IO_PAGE_SIZE PAGE_SIZE_8K 37#define IO_PAGE_MASK PAGE_MASK_8K 38#define IO_PAGE_SHIFT PAGE_SHIFT_8K 39#define round_io_page(x) round_page(x) 40#define trunc_io_page(x) trunc_page(x) 41 42/* 43 * Per-IOMMU state. The parenthesized comments indicate the locking strategy: 44 * i - protected by iommu_mtx. 45 * r - read-only after initialization. 46 * * - comment refers to pointer target / target hardware registers 47 * (for bus_addr_t). 48 * iommu_map_lruq is also locked by iommu_mtx. Elements of iommu_tsb may only 49 * be accessed from functions operating on the map owning the corresponding 50 * resource, so the locking the user is required to do to protect the map is 51 * sufficient. As soon as the TSBs are divorced, these will be moved into struct 52 * iommu_state, and each state struct will get its own lock. 53 * iommu_dvma_rman needs to be moved there too, but has its own internal lock. 54 */ 55struct iommu_state { 56 int is_tsbsize; /* (r) 0 = 8K, ... */ 57 u_int64_t is_dvmabase; /* (r) */ 58 int64_t is_cr; /* (r) Control reg value */ 59 60 vm_paddr_t is_flushpa[2]; /* (r) */ 61 volatile int64_t *is_flushva[2]; /* (r, *i) */ 62 /* 63 * (i) 64 * When a flush is completed, 64 bytes will be stored at the given 65 * location, the first double word being 1, to indicate completion. 66 * The lower 6 address bits are ignored, so the addresses need to be 67 * suitably aligned; over-allocate a large enough margin to be able 68 * to adjust it. 69 * Two such buffers are needed. 70 */ 71 volatile char is_flush[STRBUF_FLUSHSYNC_NBYTES * 3 - 1]; 72 73 /* copies of our parents state, to allow us to be self contained */ 74 bus_space_tag_t is_bustag; /* (r) Our bus tag */ 75 bus_space_handle_t is_bushandle; /* (r) */ 76 bus_addr_t is_iommu; /* (r, *i) IOMMU registers */ 77 bus_addr_t is_sb[2]; /* (r, *i) Streaming buffer */ 78 /* Tag diagnostics access */ 79 bus_addr_t is_dtag; /* (r, *r) */ 80 /* Data RAM diagnostic access */ 81 bus_addr_t is_ddram; /* (r, *r) */ 82 /* LRU queue diag. access */ 83 bus_addr_t is_dqueue; /* (r, *r) */ 84 /* Virtual address diagnostics register */ 85 bus_addr_t is_dva; /* (r, *r) */ 86 /* Tag compare diagnostics access */ 87 bus_addr_t is_dtcmp; /* (r, *r) */ 88 89 STAILQ_ENTRY(iommu_state) is_link; /* (r) */ 90}; 91 92/* interfaces for PCI/SBUS code */ 93void iommu_init(char *, struct iommu_state *, int, u_int32_t, int); 94void iommu_reset(struct iommu_state *); 95void iommu_decode_fault(struct iommu_state *, vm_offset_t); 96 97extern struct bus_dma_methods iommu_dma_methods; 98 99#endif /* !_MACHINE_IOMMUVAR_H_ */ 100