1*517bc6b8Smaya /* $NetBSD: sgmapvar.h,v 1.19 2020/09/05 04:11:10 maya Exp $ */ 2413f678cSthorpej 3413f678cSthorpej /*- 48617f2c7Sthorpej * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc. 5413f678cSthorpej * All rights reserved. 6413f678cSthorpej * 7413f678cSthorpej * This code is derived from software contributed to The NetBSD Foundation 8413f678cSthorpej * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9413f678cSthorpej * NASA Ames Research Center. 10413f678cSthorpej * 11413f678cSthorpej * Redistribution and use in source and binary forms, with or without 12413f678cSthorpej * modification, are permitted provided that the following conditions 13413f678cSthorpej * are met: 14413f678cSthorpej * 1. Redistributions of source code must retain the above copyright 15413f678cSthorpej * notice, this list of conditions and the following disclaimer. 16413f678cSthorpej * 2. Redistributions in binary form must reproduce the above copyright 17413f678cSthorpej * notice, this list of conditions and the following disclaimer in the 18413f678cSthorpej * documentation and/or other materials provided with the distribution. 19413f678cSthorpej * 20413f678cSthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21413f678cSthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22413f678cSthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23413f678cSthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24413f678cSthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25413f678cSthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26413f678cSthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27413f678cSthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28413f678cSthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29413f678cSthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30413f678cSthorpej * POSSIBILITY OF SUCH DAMAGE. 31413f678cSthorpej */ 32413f678cSthorpej 33d273e10dSross #ifndef _ALPHA_COMMON_SGMAPVAR_H 34d273e10dSross #define _ALPHA_COMMON_SGMAPVAR_H 35d273e10dSross 36cf10107dSdyoung #include <sys/bus.h> 371fd968efSthorpej #include <sys/vmem.h> 38413f678cSthorpej 39413f678cSthorpej /* 40413f678cSthorpej * Bits n:13 of the DMA address are the index of the PTE into 41413f678cSthorpej * the SGMAP page table. 42413f678cSthorpej */ 43413f678cSthorpej #define SGMAP_ADDR_PTEIDX_SHIFT 13 44413f678cSthorpej 45413f678cSthorpej /* 46d08070a6Sthorpej * An Alpha SGMAP's state information. Nothing in the sgmap requires 47d685f990Sthorpej * locking[*], with the exception of the vmem arena, which takes care 48d685f990Sthorpej * of it on its own. 49d08070a6Sthorpej * 50d08070a6Sthorpej * [*] While the page table is a `global' resource, access to it is 51*517bc6b8Smaya * controlled by the arena; once a region has been allocated from 52d685f990Sthorpej * the arena, that region is effectively `locked'. 53413f678cSthorpej */ 54413f678cSthorpej struct alpha_sgmap { 551fd968efSthorpej vmem_t *aps_arena; /* arena to manage sgva space */ 56413f678cSthorpej void *aps_pt; /* page table */ 57413f678cSthorpej bus_addr_t aps_ptpa; /* page table physical address */ 58413f678cSthorpej bus_addr_t aps_sgvabase; /* base of the sgva space */ 59413f678cSthorpej bus_size_t aps_sgvasize; /* size of the sgva space */ 601ffa7b76Swiz bus_addr_t aps_wbase; /* base of the DMA window */ 61413f678cSthorpej }; 62413f678cSthorpej 63d5df5511Sthorpej extern vaddr_t alpha_sgmap_prefetch_spill_page_va; 64e62d894dSthorpej extern bus_addr_t alpha_sgmap_prefetch_spill_page_pa; 65e62d894dSthorpej 66c3d730dfSthorpej void alpha_sgmap_init(bus_dma_tag_t, struct alpha_sgmap *, 672981fec2Sthorpej const char *, bus_addr_t, bus_addr_t, bus_size_t, size_t, void *, 68c3d730dfSthorpej bus_size_t); 69413f678cSthorpej 70c3d730dfSthorpej int alpha_sgmap_dmamap_create(bus_dma_tag_t, bus_size_t, int, 71c3d730dfSthorpej bus_size_t, bus_size_t, int, bus_dmamap_t *); 72c3d730dfSthorpej void alpha_sgmap_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t); 73db36913cSthorpej 74d273e10dSross #endif /* _ALPHA_COMMON_SGMAPVAR_H */ 75