1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1999-2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_1394_ADAPTERS_HCI1394_BUF_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_1394_ADAPTERS_HCI1394_BUF_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * hci1394_buf.h
32*7c478bd9Sstevel@tonic-gate  *   These routines handle IO bound memory.  They include routines to alloc and
33*7c478bd9Sstevel@tonic-gate  *   free. IO bound memory and a routine to get the adapter's default dma
34*7c478bd9Sstevel@tonic-gate  *   attributes.
35*7c478bd9Sstevel@tonic-gate  */
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
38*7c478bd9Sstevel@tonic-gate extern "C" {
39*7c478bd9Sstevel@tonic-gate #endif
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
43*7c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /*
47*7c478bd9Sstevel@tonic-gate  * Input parameters into buf_alloc().
48*7c478bd9Sstevel@tonic-gate  *    bp_length - size of buffer to alloc and map into IO space.
49*7c478bd9Sstevel@tonic-gate  *    bp_max_cookies - maximum number of cookies we can handle.
50*7c478bd9Sstevel@tonic-gate  *    bp_alignment - buffer alignment requirements.
51*7c478bd9Sstevel@tonic-gate  *
52*7c478bd9Sstevel@tonic-gate  * bp_max_cookies overwrites the adapter's default dma_attr_sgllen setting.
53*7c478bd9Sstevel@tonic-gate  * bp_alignment overwrites the adapter's default dma_attr_align setting.
54*7c478bd9Sstevel@tonic-gate  */
55*7c478bd9Sstevel@tonic-gate typedef struct hci1394_buf_parms_s {
56*7c478bd9Sstevel@tonic-gate 	size_t		bp_length;
57*7c478bd9Sstevel@tonic-gate 	uint_t		bp_max_cookies;
58*7c478bd9Sstevel@tonic-gate 	uint64_t	bp_alignment;
59*7c478bd9Sstevel@tonic-gate } hci1394_buf_parms_t;
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /*
62*7c478bd9Sstevel@tonic-gate  * Output from buf_alloc().  This structure contains information
63*7c478bd9Sstevel@tonic-gate  * about the buffer allocated.
64*7c478bd9Sstevel@tonic-gate  */
65*7c478bd9Sstevel@tonic-gate typedef struct hci1394_buf_info_s {
66*7c478bd9Sstevel@tonic-gate 	ddi_dma_cookie_t	bi_cookie; /* ddi_dma_addr_bind_handle */
67*7c478bd9Sstevel@tonic-gate 	uint_t			bi_cookie_count; /* ddi_dma_addr_bind_handle */
68*7c478bd9Sstevel@tonic-gate 	caddr_t			bi_kaddr; /* ddi_dma_mem_alloc */
69*7c478bd9Sstevel@tonic-gate 	size_t			bi_length; /* copy of input parms bp_length */
70*7c478bd9Sstevel@tonic-gate 	size_t			bi_real_length; /* ddi_dma_mem_alloc */
71*7c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	bi_handle; /* ddi_dma_mem_alloc */
72*7c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t	bi_dma_handle; /* ddi_dma_alloc_handle */
73*7c478bd9Sstevel@tonic-gate } hci1394_buf_info_t;
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate /*
76*7c478bd9Sstevel@tonic-gate  * private structure to track buffer information
77*7c478bd9Sstevel@tonic-gate  */
78*7c478bd9Sstevel@tonic-gate typedef struct hci1394_buf_s {
79*7c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t	bu_handle;
80*7c478bd9Sstevel@tonic-gate 	ddi_dma_handle_t	bu_dma_handle;
81*7c478bd9Sstevel@tonic-gate 	hci1394_drvinfo_t 	*bu_drvinfo;
82*7c478bd9Sstevel@tonic-gate } hci1394_buf_t;
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate /*
85*7c478bd9Sstevel@tonic-gate  * handle passed back from alloc() and used for free()
86*7c478bd9Sstevel@tonic-gate  */
87*7c478bd9Sstevel@tonic-gate typedef struct hci1394_buf_s	*hci1394_buf_handle_t;
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate void hci1394_buf_attr_get(ddi_dma_attr_t *dma_attr);
91*7c478bd9Sstevel@tonic-gate int hci1394_buf_alloc(hci1394_drvinfo_t *drvinfo, hci1394_buf_parms_t *parms,
92*7c478bd9Sstevel@tonic-gate     hci1394_buf_info_t *info, hci1394_buf_handle_t *handle);
93*7c478bd9Sstevel@tonic-gate void hci1394_buf_free(hci1394_buf_handle_t *handle);
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate /* warlock directives */
96*7c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Single user", hci1394_buf_info_s hci1394_buf_s))
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
99*7c478bd9Sstevel@tonic-gate }
100*7c478bd9Sstevel@tonic-gate #endif
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_1394_ADAPTERS_HCI1394_BUF_H */
103