xref: /titanic_44/usr/src/uts/common/sys/ddimapreq.h (revision 3304b547f338da1a8537006874c53b8e9bf066bd)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright (c) 1991-1994 Sun Microsystems, Inc.
24*3304b547SRobert Mustacchi  * Copyright 2016 Joyent, Inc.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_DDIMAPREQ_H
287c478bd9Sstevel@tonic-gate #define	_SYS_DDIMAPREQ_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/mman.h>
337c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * Mapping requests are for an rnumber or for a regspec.
437c478bd9Sstevel@tonic-gate  *
447c478bd9Sstevel@tonic-gate  * A regspec is a generic triple, usually representing
457c478bd9Sstevel@tonic-gate  * 	type, offset, length
467c478bd9Sstevel@tonic-gate  *
477c478bd9Sstevel@tonic-gate  * And is interpreted privately between the child and parent.
487c478bd9Sstevel@tonic-gate  * The triple should be sufficient for representing byte addressable devices.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate typedef union {
527c478bd9Sstevel@tonic-gate 	int	rnumber;
537c478bd9Sstevel@tonic-gate 	struct	regspec *rp;
547c478bd9Sstevel@tonic-gate } ddi_map_obj_t;
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate typedef enum {
577c478bd9Sstevel@tonic-gate 	DDI_MT_RNUMBER = 0,
587c478bd9Sstevel@tonic-gate 	DDI_MT_REGSPEC
597c478bd9Sstevel@tonic-gate } ddi_map_type_t;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * Mapping operators:
637c478bd9Sstevel@tonic-gate  */
647c478bd9Sstevel@tonic-gate typedef enum {
657c478bd9Sstevel@tonic-gate 	DDI_MO_MAP_UNLOCKED = 0,	/* Create mapping, do not lock down */
667c478bd9Sstevel@tonic-gate 	DDI_MO_MAP_LOCKED,		/* Create locked down mapping */
677c478bd9Sstevel@tonic-gate 	DDI_MO_MAP_HANDLE,		/* Create handle, do not map */
687c478bd9Sstevel@tonic-gate 	DDI_MO_UNMAP,			/* Unmap (implies unlock, if locked) */
697c478bd9Sstevel@tonic-gate 	DDI_MO_UNLOCK			/* Unlock mapping, do *not* unmap */
707c478bd9Sstevel@tonic-gate } ddi_map_op_t;
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * Mapping request structure...
747c478bd9Sstevel@tonic-gate  */
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate typedef struct {
777c478bd9Sstevel@tonic-gate 	ddi_map_op_t map_op;
787c478bd9Sstevel@tonic-gate 	ddi_map_type_t map_type;
797c478bd9Sstevel@tonic-gate 	ddi_map_obj_t map_obj;
80*3304b547SRobert Mustacchi 	uint_t map_flags; /* See below... */
817c478bd9Sstevel@tonic-gate 	int map_prot;	/* Prot bits (see sys/mman.h) */
827c478bd9Sstevel@tonic-gate 	ddi_acc_hdl_t *map_handlep;
837c478bd9Sstevel@tonic-gate 	int map_vers;
847c478bd9Sstevel@tonic-gate } ddi_map_req_t;
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /*
877c478bd9Sstevel@tonic-gate  * version number
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate #define	DDI_MAP_VERSION		0x0001
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /*
927c478bd9Sstevel@tonic-gate  * Mappings subject to the following flags:
937c478bd9Sstevel@tonic-gate  */
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 			/*
967c478bd9Sstevel@tonic-gate 			 * Make mapping suitable for user program use.
977c478bd9Sstevel@tonic-gate 			 */
987c478bd9Sstevel@tonic-gate #define	DDI_MF_USER_MAPPING	0x1
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 			/*
1017c478bd9Sstevel@tonic-gate 			 * Make mapping suitable for kernel mapping.
1027c478bd9Sstevel@tonic-gate 			 */
1037c478bd9Sstevel@tonic-gate #define	DDI_MF_KERNEL_MAPPING	0x2
1047c478bd9Sstevel@tonic-gate #define	DDI_MF_DEVICE_MAPPING	0x4
1057c478bd9Sstevel@tonic-gate 
106*3304b547SRobert Mustacchi /*
107*3304b547SRobert Mustacchi  * The upper bits of map_flags are reserved for platform-specific flags. These
108*3304b547SRobert Mustacchi  * start with the highest bit and then work their way down. Currently only one
109*3304b547SRobert Mustacchi  * bit is used, and only on x86.
110*3304b547SRobert Mustacchi  */
111*3304b547SRobert Mustacchi 			/*
112*3304b547SRobert Mustacchi 			 * Indicates that there is an extended register
113*3304b547SRobert Mustacchi 			 * specification (fully 64-bit aware) being used. This
114*3304b547SRobert Mustacchi 			 * should only be used by children of the x86 root nexus
115*3304b547SRobert Mustacchi 			 * driver.
116*3304b547SRobert Mustacchi 			 */
117*3304b547SRobert Mustacchi #define	DDI_MF_EXT_REGSPEC	0x80000000
118*3304b547SRobert Mustacchi 
1197c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate /*
1227c478bd9Sstevel@tonic-gate  * Error (non-zero) return codes from DDI mapping functions...
1237c478bd9Sstevel@tonic-gate  */
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate #define	DDI_ME_GENERIC		(-1)	/* Generic un-enumerated error */
1267c478bd9Sstevel@tonic-gate #define	DDI_ME_UNIMPLEMENTED	(-2)	/* Unimplemented operator */
1277c478bd9Sstevel@tonic-gate #define	DDI_ME_NORESOURCES	(-3)	/* No resources, try later? */
1287c478bd9Sstevel@tonic-gate #define	DDI_ME_UNSUPPORTED	(-4)	/* Op is not supported in impl. */
1297c478bd9Sstevel@tonic-gate #define	DDI_ME_REGSPEC_RANGE	(-5)	/* Addressing range error */
1307c478bd9Sstevel@tonic-gate #define	DDI_ME_RNUMBER_RANGE	(-6)	/* Addressing range error */
1317c478bd9Sstevel@tonic-gate #define	DDI_ME_INVAL		(-7)	/* Invalid input parameter */
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1347c478bd9Sstevel@tonic-gate }
1357c478bd9Sstevel@tonic-gate #endif
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate #endif	/* _SYS_DDIMAPREQ_H */
138