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