xref: /titanic_44/usr/src/uts/common/sys/ddimapreq.h (revision 3304b547f338da1a8537006874c53b8e9bf066bd)
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) 1991-1994 Sun Microsystems, Inc.
24  * Copyright 2016 Joyent, Inc.
25  */
26 
27 #ifndef	_SYS_DDIMAPREQ_H
28 #define	_SYS_DDIMAPREQ_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/mman.h>
33 #include <sys/dditypes.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #ifdef	_KERNEL
40 
41 /*
42  * Mapping requests are for an rnumber or for a regspec.
43  *
44  * A regspec is a generic triple, usually representing
45  * 	type, offset, length
46  *
47  * And is interpreted privately between the child and parent.
48  * The triple should be sufficient for representing byte addressable devices.
49  */
50 
51 typedef union {
52 	int	rnumber;
53 	struct	regspec *rp;
54 } ddi_map_obj_t;
55 
56 typedef enum {
57 	DDI_MT_RNUMBER = 0,
58 	DDI_MT_REGSPEC
59 } ddi_map_type_t;
60 
61 /*
62  * Mapping operators:
63  */
64 typedef enum {
65 	DDI_MO_MAP_UNLOCKED = 0,	/* Create mapping, do not lock down */
66 	DDI_MO_MAP_LOCKED,		/* Create locked down mapping */
67 	DDI_MO_MAP_HANDLE,		/* Create handle, do not map */
68 	DDI_MO_UNMAP,			/* Unmap (implies unlock, if locked) */
69 	DDI_MO_UNLOCK			/* Unlock mapping, do *not* unmap */
70 } ddi_map_op_t;
71 
72 /*
73  * Mapping request structure...
74  */
75 
76 typedef struct {
77 	ddi_map_op_t map_op;
78 	ddi_map_type_t map_type;
79 	ddi_map_obj_t map_obj;
80 	uint_t map_flags; /* See below... */
81 	int map_prot;	/* Prot bits (see sys/mman.h) */
82 	ddi_acc_hdl_t *map_handlep;
83 	int map_vers;
84 } ddi_map_req_t;
85 
86 /*
87  * version number
88  */
89 #define	DDI_MAP_VERSION		0x0001
90 
91 /*
92  * Mappings subject to the following flags:
93  */
94 
95 			/*
96 			 * Make mapping suitable for user program use.
97 			 */
98 #define	DDI_MF_USER_MAPPING	0x1
99 
100 			/*
101 			 * Make mapping suitable for kernel mapping.
102 			 */
103 #define	DDI_MF_KERNEL_MAPPING	0x2
104 #define	DDI_MF_DEVICE_MAPPING	0x4
105 
106 /*
107  * The upper bits of map_flags are reserved for platform-specific flags. These
108  * start with the highest bit and then work their way down. Currently only one
109  * bit is used, and only on x86.
110  */
111 			/*
112 			 * Indicates that there is an extended register
113 			 * specification (fully 64-bit aware) being used. This
114 			 * should only be used by children of the x86 root nexus
115 			 * driver.
116 			 */
117 #define	DDI_MF_EXT_REGSPEC	0x80000000
118 
119 #endif	/* _KERNEL */
120 
121 /*
122  * Error (non-zero) return codes from DDI mapping functions...
123  */
124 
125 #define	DDI_ME_GENERIC		(-1)	/* Generic un-enumerated error */
126 #define	DDI_ME_UNIMPLEMENTED	(-2)	/* Unimplemented operator */
127 #define	DDI_ME_NORESOURCES	(-3)	/* No resources, try later? */
128 #define	DDI_ME_UNSUPPORTED	(-4)	/* Op is not supported in impl. */
129 #define	DDI_ME_REGSPEC_RANGE	(-5)	/* Addressing range error */
130 #define	DDI_ME_RNUMBER_RANGE	(-6)	/* Addressing range error */
131 #define	DDI_ME_INVAL		(-7)	/* Invalid input parameter */
132 
133 #ifdef	__cplusplus
134 }
135 #endif
136 
137 #endif	/* _SYS_DDIMAPREQ_H */
138