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