iommuvar.h revision 116541
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 116541 2003-06-18 16:41:36Z 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 44 */ 45struct iommu_state { 46 int is_tsbsize; /* 0 = 8K, ... */ 47 u_int64_t is_dvmabase; 48 int64_t is_cr; /* IOMMU control register value */ 49 50 vm_paddr_t is_flushpa[2]; 51 volatile int64_t *is_flushva[2]; 52 /* 53 * When a flush is completed, 64 bytes will be stored at the given 54 * location, the first double word being 1, to indicate completion. 55 * The lower 6 address bits are ignored, so the addresses need to be 56 * suitably aligned; over-allocate a large enough margin to be able 57 * to adjust it. 58 * Two such buffers are needed. 59 * Needs to be volatile or egcs optimizes away loads. 60 */ 61 volatile char is_flush[STRBUF_FLUSHSYNC_NBYTES * 3 - 1]; 62 63 /* copies of our parents state, to allow us to be self contained */ 64 bus_space_tag_t is_bustag; /* our bus tag */ 65 bus_space_handle_t is_bushandle; 66 bus_addr_t is_iommu; /* IOMMU registers */ 67 bus_addr_t is_sb[2]; /* streaming buffer */ 68 bus_addr_t is_dtag; /* tag diagnostics access */ 69 bus_addr_t is_ddram; /* data ram diag. access */ 70 bus_addr_t is_dqueue; /* LRU queue diag. access */ 71 bus_addr_t is_dva; /* VA diag. register */ 72 bus_addr_t is_dtcmp; /* tag compare diag. access */ 73 74 STAILQ_ENTRY(iommu_state) is_link; 75}; 76 77/* interfaces for PCI/SBUS code */ 78void iommu_init(char *, struct iommu_state *, int, u_int32_t, int); 79void iommu_reset(struct iommu_state *); 80void iommu_enter(struct iommu_state *, vm_offset_t, vm_paddr_t, int); 81void iommu_remove(struct iommu_state *, vm_offset_t, size_t); 82void iommu_decode_fault(struct iommu_state *, vm_offset_t); 83 84extern struct bus_dma_methods iommu_dma_methods; 85 86#endif /* !_MACHINE_IOMMUVAR_H_ */ 87