xref: /illumos-gate/usr/src/uts/common/sys/1394/adapters/hci1394_buf.h (revision dd72704bd9e794056c558153663c739e2012d721)
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 /*
31  * hci1394_buf.h
32  *   These routines handle IO bound memory.  They include routines to alloc and
33  *   free. IO bound memory and a routine to get the adapter's default dma
34  *   attributes.
35  */
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #include <sys/ddi.h>
42 #include <sys/modctl.h>
43 #include <sys/sunddi.h>
44 
45 
46 /*
47  * Input parameters into buf_alloc().
48  *    bp_length - size of buffer to alloc and map into IO space.
49  *    bp_max_cookies - maximum number of cookies we can handle.
50  *    bp_alignment - buffer alignment requirements.
51  *
52  * bp_max_cookies overwrites the adapter's default dma_attr_sgllen setting.
53  * bp_alignment overwrites the adapter's default dma_attr_align setting.
54  */
55 typedef struct hci1394_buf_parms_s {
56 	size_t		bp_length;
57 	uint_t		bp_max_cookies;
58 	uint64_t	bp_alignment;
59 } hci1394_buf_parms_t;
60 
61 /*
62  * Output from buf_alloc().  This structure contains information
63  * about the buffer allocated.
64  */
65 typedef struct hci1394_buf_info_s {
66 	ddi_dma_cookie_t	bi_cookie; /* ddi_dma_addr_bind_handle */
67 	uint_t			bi_cookie_count; /* ddi_dma_addr_bind_handle */
68 	caddr_t			bi_kaddr; /* ddi_dma_mem_alloc */
69 	size_t			bi_length; /* copy of input parms bp_length */
70 	size_t			bi_real_length; /* ddi_dma_mem_alloc */
71 	ddi_acc_handle_t	bi_handle; /* ddi_dma_mem_alloc */
72 	ddi_dma_handle_t	bi_dma_handle; /* ddi_dma_alloc_handle */
73 } hci1394_buf_info_t;
74 
75 /*
76  * private structure to track buffer information
77  */
78 typedef struct hci1394_buf_s {
79 	ddi_acc_handle_t	bu_handle;
80 	ddi_dma_handle_t	bu_dma_handle;
81 	hci1394_drvinfo_t 	*bu_drvinfo;
82 } hci1394_buf_t;
83 
84 /*
85  * handle passed back from alloc() and used for free()
86  */
87 typedef struct hci1394_buf_s	*hci1394_buf_handle_t;
88 
89 
90 void hci1394_buf_attr_get(ddi_dma_attr_t *dma_attr);
91 int hci1394_buf_alloc(hci1394_drvinfo_t *drvinfo, hci1394_buf_parms_t *parms,
92     hci1394_buf_info_t *info, hci1394_buf_handle_t *handle);
93 void hci1394_buf_free(hci1394_buf_handle_t *handle);
94 
95 /* warlock directives */
96 _NOTE(SCHEME_PROTECTS_DATA("Single user", hci1394_buf_info_s hci1394_buf_s))
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif	/* _SYS_1394_ADAPTERS_HCI1394_BUF_H */
103