bus_private.h revision 131224
1240116Smarcel/*- 2240116Smarcel * Copyright (c) 1997, 1998 Justin T. Gibbs. 3240116Smarcel * Copyright (c) 2002 by Thomas Moestl <tmm@FreeBSD.org>. 4240116Smarcel * All rights reserved. 5240116Smarcel * 6240116Smarcel * Redistribution and use in source and binary forms, with or without 7240116Smarcel * modification, are permitted provided that the following conditions 8240116Smarcel * are met: 9240116Smarcel * 1. Redistributions of source code must retain the above copyright 10240116Smarcel * notice, this list of conditions and the following disclaimer. 11240116Smarcel * 2. Redistributions in binary form must reproduce the above copyright 12240116Smarcel * notice, this list of conditions and the following disclaimer in the 13240116Smarcel * documentation and/or other materials provided with the distribution. 14240116Smarcel * 15240116Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16240116Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17240116Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18240116Smarcel * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 19240116Smarcel * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20240116Smarcel * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21240116Smarcel * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22240116Smarcel * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23240116Smarcel * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 24240116Smarcel * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25240116Smarcel * 26275988Sngie * from: FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.25 2002/01/05 27275988Sngie * 28240116Smarcel * $FreeBSD: head/sys/sparc64/include/bus_private.h 131224 2004-06-28 04:04:43Z scottl $ 29240116Smarcel */ 30240116Smarcel 31240116Smarcel#ifndef _MACHINE_BUS_PRIVATE_H_ 32240116Smarcel#define _MACHINE_BUS_PRIVATE_H_ 33240116Smarcel 34240116Smarcel#include <sys/queue.h> 35240116Smarcel 36240116Smarcel/* 37240116Smarcel * Helpers 38240116Smarcel */ 39240116Smarcelint sparc64_bus_mem_map(bus_space_tag_t, bus_space_handle_t, bus_size_t, 40240116Smarcel int, vm_offset_t, void **); 41240116Smarcelint sparc64_bus_mem_unmap(void *, bus_size_t); 42240116Smarcelbus_space_handle_t sparc64_fake_bustag(int, bus_addr_t, struct bus_space_tag *); 43240116Smarcel 44240116Smarcelstruct bus_dmamap_res { 45240116Smarcel struct resource *dr_res; 46240116Smarcel bus_size_t dr_used; 47240116Smarcel SLIST_ENTRY(bus_dmamap_res) dr_link; 48240116Smarcel}; 49240116Smarcel 50240116Smarcel/* 51240116Smarcel * Callers of the bus_dma interfaces must always protect their tags and maps 52240116Smarcel * appropriately against concurrent access. However, when a map is on a LRU 53240116Smarcel * queue, there is a second access path to it; for this case, the locking rules 54240116Smarcel * are given in the parenthesized comments below: 55240116Smarcel * q - locked by the mutex protecting the queue. 56240116Smarcel * p - private to the owner of the map, no access through the queue. 57240116Smarcel * * - comment refers to pointer target. 58240116Smarcel * Only the owner of the map is allowed to insert the map into a queue. Removal 59240116Smarcel * and repositioning (i.e. temporal removal and reinsertion) is allowed to all 60240116Smarcel * if the queue lock is held. 61240116Smarcel */ 62240116Smarcelstruct bus_dmamap { 63240116Smarcel TAILQ_ENTRY(bus_dmamap) dm_maplruq; /* (q) */ 64240116Smarcel SLIST_HEAD(, bus_dmamap_res) dm_reslist; /* (q, *q) */ 65240116Smarcel int dm_onq; /* (q) */ 66240116Smarcel int dm_flags; /* (p) */ 67240116Smarcel}; 68240116Smarcel 69240116Smarcel/* Flag values. */ 70240116Smarcel#define DMF_LOADED 1 /* Map is loaded */ 71240116Smarcel#define DMF_COHERENT 2 /* Coherent mapping requested */ 72240116Smarcel 73240116Smarcelint sparc64_dma_alloc_map(bus_dma_tag_t dmat, bus_dmamap_t *mapp); 74240116Smarcelvoid sparc64_dma_free_map(bus_dma_tag_t dmat, bus_dmamap_t map); 75240116Smarcel 76240116Smarcel/* 77240116Smarcel * XXX: This is a kluge. It would be better to handle dma tags in a hierarchical 78240116Smarcel * way, and have a BUS_GET_DMA_TAG(); however, since this is not currently the 79240116Smarcel * case, save a root tag in the relevant bus attach function and use that. 80240116Smarcel */ 81240116Smarcelextern bus_dma_tag_t sparc64_root_dma_tag; 82240116Smarcel 83240116Smarcel#endif /* !_MACHINE_BUS_PRIVATE_H_ */ 84240116Smarcel