xref: /gfx-drm/usr/src/uts/common/drm/drm_os_solaris.h (revision 47dc10d7)
1 /*
2  * file drm_os_solaris.h
3  *
4  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the next
14  * paragraph) shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  * OTHER DEALINGS IN THE SOFTWARE.
24  *
25  *
26  * Solaris OS abstractions
27  */
28 
29 #ifndef	_DRM_OS_SOLARIS_H
30 #define	_DRM_OS_SOLARIS_H
31 
32 /* Only Solaris builds should be here */
33 #if defined(__sun)
34 
35 /* A couple of "hints" definitions not needed for Solaris drivers */
36 #ifndef	__user
37 #define	__user
38 #endif
39 #ifndef __force
40 #define	__force
41 #endif
42 #ifndef __must_check
43 #define	__must_check
44 #endif
45 
46 typedef uint64_t drm_u64_t;
47 
48 /*
49  * Some defines that are best put in ioccom.h, but live here till then.
50  */
51 
52 /* Reverse ioctl command lookup. */
53 #define	_IOC_NR(nr)	(((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
54 
55 /* Mask values that would otherwise not be in drm.h or ioccom.h */
56 #define	_IOC_NRMASK	((1 << _IOC_NRBITS)-1)
57 #define	_IOC_TYPEMASK   ((1 << _IOC_TYPEBITS)-1)
58 #define	_IOC_SIZEMASK   ((1 << _IOC_SIZEBITS)-1)
59 #define	_IOC_DIRMASK    ((1 << _IOC_DIRBITS)-1)
60 
61 /* Solaris uses a bit for none, but calls it IOC_VOID */
62 #define	_IOC_NONE	1U
63 #define	_IOC_WRITE	2U
64 #define	_IOC_READ	4U
65 
66 #define	_IOC_SIZE(nr)		(((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
67 
68 #if defined(__sun)
69 /* Things that should be defined in drmP.h */
70 #define	DRM_IOCTL_NR(n)		_IOC_NR(n)
71 #endif /* __sun */
72 
73 #define	XFREE86_VERSION(major, minor, patch, snap) \
74 		((major << 16) | (minor << 8) | patch)
75 
76 #ifndef	CONFIG_XFREE86_VERSION
77 #define	CONFIG_XFREE86_VERSION XFREE86_VERSION(4, 1, 0, 0)
78 #endif
79 
80 #if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4, 1, 0, 0)
81 #define	DRM_PROC_DEVICES "/proc/devices"
82 #define	DRM_PROC_MISC	 "/proc/misc"
83 #define	DRM_PROC_DRM	 "/proc/drm"
84 #define	DRM_DEV_DRM	 "/dev/drm"
85 #define	DRM_DEV_MODE	 (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
86 #define	DRM_DEV_UID	 0
87 #define	DRM_DEV_GID	 0
88 #endif /* CONFIG_XFREE86_VERSION < XFREE86_VERSION(4, 1, 0, 0) */
89 
90 #if CONFIG_XFREE86_VERSION >= XFREE86_VERSION(4, 1, 0, 0)
91 #ifdef __OpenBSD__
92 #define	DRM_MAJOR	81
93 #endif
94 #if defined(__linux__) || defined(__NetBSD__)
95 #define	DRM_MAJOR	226
96 #endif
97 #define	DRM_MAX_MINORi	15
98 #endif /* CONFIG_XFREE86_VERSION >= XFREE86_VERSION(4,1,0,0) */
99 
100 
101 #ifdef _KERNEL
102 /* Defines that are only relevant for kernel modules and drivers */
103 
104 #ifdef	__lint
105 /* Don't lint these macros. */
106 #define	BUG_ON(a)
107 #define	WARN_ON(a)
108 #else
109 #define BUG_ON(a)	ASSERT(!(a))
110 #define WARN_ON(a)	do { \
111 		if(a) drm_debug_print(CE_WARN, __func__, __LINE__, #a);\
112 	} while (__lintzero)
113 #endif /* __lint */
114 
115 #define BUG()		BUG_ON(1)
116 
117 #endif /* _KERNEL */
118 #endif /* __sun */
119 #endif /* _DRM_OS_SOLARIS_H */
120