1*89a84585Sjmatthew /* $OpenBSD: sgmapvar.h,v 1.7 2014/06/14 23:11:20 jmatthew Exp $ */ 28f164632Sart /* $NetBSD: sgmapvar.h,v 1.10 1998/08/14 16:50:02 thorpej Exp $ */ 38f164632Sart 48f164632Sart /*- 58f164632Sart * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 68f164632Sart * All rights reserved. 78f164632Sart * 88f164632Sart * This code is derived from software contributed to The NetBSD Foundation 98f164632Sart * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 108f164632Sart * NASA Ames Research Center. 118f164632Sart * 128f164632Sart * Redistribution and use in source and binary forms, with or without 138f164632Sart * modification, are permitted provided that the following conditions 148f164632Sart * are met: 158f164632Sart * 1. Redistributions of source code must retain the above copyright 168f164632Sart * notice, this list of conditions and the following disclaimer. 178f164632Sart * 2. Redistributions in binary form must reproduce the above copyright 188f164632Sart * notice, this list of conditions and the following disclaimer in the 198f164632Sart * documentation and/or other materials provided with the distribution. 208f164632Sart * 218f164632Sart * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 228f164632Sart * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 238f164632Sart * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 248f164632Sart * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 258f164632Sart * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 268f164632Sart * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 278f164632Sart * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 288f164632Sart * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 298f164632Sart * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 308f164632Sart * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 318f164632Sart * POSSIBILITY OF SUCH DAMAGE. 328f164632Sart */ 338f164632Sart 348f164632Sart #ifndef _ALPHA_COMMON_SGMAPVAR_H 358f164632Sart #define _ALPHA_COMMON_SGMAPVAR_H 368f164632Sart 378f164632Sart #include <sys/extent.h> 38ef2fb739Skettenis #include <sys/mutex.h> 398f164632Sart #include <machine/bus.h> 408f164632Sart 418f164632Sart /* 428f164632Sart * Bits n:13 of the DMA address are the index of the PTE into 438f164632Sart * the SGMAP page table. 448f164632Sart */ 458f164632Sart #define SGMAP_ADDR_PTEIDX_SHIFT 13 468f164632Sart 478f164632Sart /* 488f164632Sart * An Alpha SGMAP's state information. Nothing in the sgmap requires 498f164632Sart * locking[*], with the exception of the extent map. Locking of the 508f164632Sart * extent map is handled within the extent manager itself. 518f164632Sart * 528f164632Sart * [*] While the page table is a `global' resource, access to it is 538f164632Sart * controlled by the extent map; once a region has been allocated from 548f164632Sart * the map, that region is effectively `locked'. 558f164632Sart */ 568f164632Sart struct alpha_sgmap { 578f164632Sart struct extent *aps_ex; /* extent map to manage sgva space */ 58ef2fb739Skettenis struct mutex aps_mtx; 598f164632Sart void *aps_pt; /* page table */ 608f164632Sart bus_addr_t aps_ptpa; /* page table physical address */ 618f164632Sart bus_addr_t aps_sgvabase; /* base of the sgva space */ 628f164632Sart bus_size_t aps_sgvasize; /* size of the sgva space */ 638f164632Sart bus_addr_t aps_wbase; /* base of the dma window */ 648f164632Sart }; 658f164632Sart 668f164632Sart extern vaddr_t alpha_sgmap_prefetch_spill_page_va; 678f164632Sart extern bus_addr_t alpha_sgmap_prefetch_spill_page_pa; 688f164632Sart 69c4071fd1Smillert void alpha_sgmap_init(bus_dma_tag_t, struct alpha_sgmap *, 708f164632Sart const char *, bus_addr_t, bus_addr_t, bus_size_t, size_t, void *, 71c4071fd1Smillert bus_size_t); 728f164632Sart 73*89a84585Sjmatthew int alpha_sgmap_dmamap_setup(bus_dmamap_t, int, int); 74*89a84585Sjmatthew void alpha_sgmap_dmamap_teardown(bus_dmamap_t); 75c87b4400Smartin int alpha_sgmap_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t, 76c87b4400Smartin bus_size_t, int, bus_dmamap_t *); 77c87b4400Smartin void alpha_sgmap_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t); 78c87b4400Smartin 798f164632Sart #endif /* _ALPHA_COMMON_SGMAPVAR_H */ 80