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