summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/drm/drm_os_solaris.h
blob: 7b5e63b85f8ab4783c0a56999cf8bc7153373bf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * file drm_os_solaris.h
 *
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 *
 * Solaris OS abstractions
 */

#ifndef	_DRM_OS_SOLARIS_H
#define	_DRM_OS_SOLARIS_H

/* Only Solaris builds should be here */
#if defined(__sun)

/* A couple of "hints" definitions not needed for Solaris drivers */
#ifndef	__user
#define	__user
#endif
#ifndef __force
#define	__force
#endif
#ifndef __must_check
#define	__must_check
#endif

typedef uint64_t drm_u64_t;

/*
 * Some defines that are best put in ioccom.h, but live here till then.
 */

/* Reverse ioctl command lookup. */
#define	_IOC_NR(nr)	(((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)

/* Mask values that would otherwise not be in drm.h or ioccom.h */
#define	_IOC_NRMASK	((1 << _IOC_NRBITS)-1)
#define	_IOC_TYPEMASK   ((1 << _IOC_TYPEBITS)-1)
#define	_IOC_SIZEMASK   ((1 << _IOC_SIZEBITS)-1)
#define	_IOC_DIRMASK    ((1 << _IOC_DIRBITS)-1)

/* Solaris uses a bit for none, but calls it IOC_VOID */
#define	_IOC_NONE	1U
#define	_IOC_WRITE	2U
#define	_IOC_READ	4U

#define	_IOC_SIZE(nr)		(((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)

#if defined(__sun)
/* Things that should be defined in drmP.h */
#define	DRM_IOCTL_NR(n)		_IOC_NR(n)
#endif /* __sun */

#define	XFREE86_VERSION(major, minor, patch, snap) \
		((major << 16) | (minor << 8) | patch)

#ifndef	CONFIG_XFREE86_VERSION
#define	CONFIG_XFREE86_VERSION XFREE86_VERSION(4, 1, 0, 0)
#endif

#if CONFIG_XFREE86_VERSION < XFREE86_VERSION(4, 1, 0, 0)
#define	DRM_PROC_DEVICES "/proc/devices"
#define	DRM_PROC_MISC	 "/proc/misc"
#define	DRM_PROC_DRM	 "/proc/drm"
#define	DRM_DEV_DRM	 "/dev/drm"
#define	DRM_DEV_MODE	 (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
#define	DRM_DEV_UID	 0
#define	DRM_DEV_GID	 0
#endif /* CONFIG_XFREE86_VERSION < XFREE86_VERSION(4, 1, 0, 0) */

#if CONFIG_XFREE86_VERSION >= XFREE86_VERSION(4, 1, 0, 0)
#ifdef __OpenBSD__
#define	DRM_MAJOR	81
#endif
#if defined(__linux__) || defined(__NetBSD__)
#define	DRM_MAJOR	226
#endif
#define	DRM_MAX_MINORi	15
#endif /* CONFIG_XFREE86_VERSION >= XFREE86_VERSION(4,1,0,0) */


#ifdef _KERNEL
/* Defines that are only relevant for kernel modules and drivers */

#ifdef	__lint
/* Don't lint these macros. */
#define	BUG_ON(a)
#define	WARN_ON(a)
#else
#define BUG_ON(a)	ASSERT(!(a))
#define WARN_ON(a)	do { \
		if(a) drm_debug_print(CE_WARN, __func__, __LINE__, #a);\
	} while (__lintzero)
#endif /* __lint */

#define BUG()		BUG_ON(1)

#endif /* _KERNEL */
#endif /* __sun */
#endif /* _DRM_OS_SOLARIS_H */