Ticket #13665: vivek-gsoc2017-drm_1-squash.diff
File vivek-gsoc2017-drm_1-squash.diff, 307.0 KB (added by , 7 years ago) |
---|
-
new file headers/compatibility/linux/asm/bitops/const_hweight.h
diff --git a/headers/compatibility/linux/asm/bitops/const_hweight.h b/headers/compatibility/linux/asm/bitops/const_hweight.h new file mode 100644 index 0000000000..ac2c795f7c
- + 1 /*- 2 * Copyright (c) 2015 François Tigeot 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef _ASM_BITOPS_CONST_HWEIGHT_H_ 28 #define _ASM_BITOPS_CONST_HWEIGHT_H_ 29 30 static __inline uint16_t 31 hweight16(uint32_t x) 32 { 33 x = (x & 0x5555) + ((x & 0xaaaa) >> 1); 34 x = (x & 0x3333) + ((x & 0xcccc) >> 2); 35 x = (x + (x >> 4)) & 0x0f0f; 36 x = (x + (x >> 8)) & 0x00ff; 37 return (x); 38 } 39 40 #endif /* _ASM_BITOPS_CONST_HWEIGHT_H_ */ -
new file headers/compatibility/linux/asm/bitops/non-atomic.h
diff --git a/headers/compatibility/linux/asm/bitops/non-atomic.h b/headers/compatibility/linux/asm/bitops/non-atomic.h new file mode 100644 index 0000000000..3282812d75
- + 1 /* 2 * Copyright (c) 2014 François Tigeot 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef _ASM_BITOPS_NON_ATOMIC_H_ 28 #define _ASM_BITOPS_NON_ATOMIC_H_ 29 30 static inline void __set_bit(int nr, volatile unsigned long *addr) 31 { 32 *(addr + (nr / BITS_PER_LONG)) |= (1 << (nr % BITS_PER_LONG)); 33 } 34 35 static inline void __clear_bit(int nr, volatile unsigned long *addr) 36 { 37 *(addr + (nr / BITS_PER_LONG)) &= ~(1 << (nr % BITS_PER_LONG)); 38 } 39 40 #endif /* _ASM_BITOPS_NON_ATOMIC_H_ */ -
new file headers/compatibility/linux/asm/io.h
diff --git a/headers/compatibility/linux/asm/io.h b/headers/compatibility/linux/asm/io.h new file mode 100644 index 0000000000..412f922709
- + 1 /* 2 * Copyright (c) 2015 Hamish Morrison 3 * Copyright (c) 2014 François Tigeot 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice unmodified, this list of conditions, and the following 11 * disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef _ASM_IO_H_ 29 #define _ASM_IO_H_ 30 31 32 #define ioread8(addr) *(volatile uint8_t *)((char *)addr) 33 #define ioread16(addr) *(volatile uint16_t *)((char *)addr) 34 #define ioread32(addr) *(volatile uint32_t *)((char *)addr) 35 36 #define iowrite8(data, addr) *(volatile uint8_t *)((char *)addr) = data; 37 #define iowrite16(data, addr) *(volatile uint16_t *)((char *)addr) = data; 38 #define iowrite32(data, addr) *(volatile uint32_t *)((char *)addr) = data; 39 40 static inline void __iomem *map_common(resource_size_t addr, unsigned long size, 41 uint32 flags) 42 { 43 void* address; 44 area_id area = map_physical_memory("lio", addr, size, flags, 45 B_READ_AREA | B_WRITE_AREA, &address); 46 if (area < 0) 47 return NULL; 48 49 return address; 50 } 51 52 /* ioremap: map bus memory into CPU space */ 53 static inline void __iomem *ioremap(resource_size_t phys_addr, unsigned long size) 54 { 55 return map_common(phys_addr, size, B_ANY_KERNEL_ADDRESS | B_MTR_UC); 56 } 57 58 static inline void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size) 59 { 60 return map_common(phys_addr, size, B_ANY_KERNEL_ADDRESS | B_MTR_WC); 61 } 62 63 #endif /* _ASM_IO_H_ */ -
new file headers/compatibility/linux/asm/ioctl.h
diff --git a/headers/compatibility/linux/asm/ioctl.h b/headers/compatibility/linux/asm/ioctl.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/asm/mman.h
diff --git a/headers/compatibility/linux/asm/mman.h b/headers/compatibility/linux/asm/mman.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/asm/pgalloc.h
diff --git a/headers/compatibility/linux/asm/pgalloc.h b/headers/compatibility/linux/asm/pgalloc.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/asm/types.h
diff --git a/headers/compatibility/linux/asm/types.h b/headers/compatibility/linux/asm/types.h new file mode 100644 index 0000000000..6006e1a23b
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 #ifndef _ASM_TYPES_H_ 29 #define _ASM_TYPES_H_ 30 31 32 typedef signed char __s8; 33 typedef unsigned char __u8; 34 35 typedef signed short __s16; 36 typedef unsigned short __u16; 37 38 typedef signed int __s32; 39 typedef unsigned int __u32; 40 41 #if defined(__GNUC__) // && !defined(__STRICT_ANSI__) 42 typedef signed long long __s64; 43 typedef uint64_t __u64; 44 #endif 45 46 typedef signed char s8; 47 typedef unsigned char u8; 48 49 typedef signed short s16; 50 typedef unsigned short u16; 51 52 typedef signed int s32; 53 typedef unsigned int u32; 54 55 typedef signed long long s64; 56 typedef unsigned long long u64; 57 58 /* DMA addresses come in generic and 64-bit flavours. */ 59 typedef phys_addr_t dma_addr_t; 60 typedef phys_addr_t dma64_addr_t; 61 62 63 #endif /* _ASM_TYPES_H_ */ -
new file headers/compatibility/linux/linux/agp_backend.h
diff --git a/headers/compatibility/linux/linux/agp_backend.h b/headers/compatibility/linux/linux/agp_backend.h new file mode 100644 index 0000000000..532940e412
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _LINUX_AGP_BACKEND_H 6 #define _LINUX_AGP_BACKEND_H 7 8 #include <SupportDefs.h> 9 10 enum chipset_type { 11 NOT_SUPPORTED, 12 SUPPORTED 13 }; 14 15 struct agp_version { 16 uint16 major; 17 uint16 minor; 18 }; 19 20 struct agp_kern_info { 21 struct agp_version version; 22 struct pci_dev* dev; 23 enum chipset_type chipset; 24 unsigned long mode; 25 unsigned long aper_base; 26 size_t aper_size; 27 int max_memory; 28 int current_memory; 29 bool cant_use_aperture; 30 unsigned long page_mask; 31 // const struct vm_operations_struct* vm_ops; 32 }; 33 34 struct agp_bridge_data; 35 36 struct agp_memory { 37 }; 38 39 #endif -
new file headers/compatibility/linux/linux/atomic.h
diff --git a/headers/compatibility/linux/linux/atomic.h b/headers/compatibility/linux/linux/atomic.h new file mode 100644 index 0000000000..236ac56199
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013-2015 François Tigeot 6 * Copyright (c) 2015 Hamish Morrison 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice unmodified, this list of conditions, and the following 14 * disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef _ASM_ATOMIC_H_ 32 #define _ASM_ATOMIC_H_ 33 34 #include <SupportDefs.h> 35 #include <arch/atomic.h> 36 #include <sys/types.h> 37 #include <linux/compiler.h> 38 39 typedef struct { 40 uint32 counter; 41 } atomic_t; 42 43 typedef struct { 44 uint64 counter; 45 } atomic64_t; 46 47 #define atomic_inc_return(v) atomic_add_return(1, (v)) 48 #define atomic_add_negative(i, v) (atomic_add_return((i), (v)) < 0) 49 #define atomic_sub_and_test(i, v) (atomic_sub_return((i), (v)) == 0) 50 #define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0) 51 #define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0) 52 #define atomic_dec_return(v) atomic_sub_return(1, (v)) 53 54 #define atomic_xchg(p, v) atomic_get_and_set(&((p)->counter), v) 55 #define atomic64_xchg(p, v) atomic_get_and_set64(&((p)->counter), v) 56 57 static inline int 58 atomic_add_return(int i, atomic_t *v) 59 { 60 return i + atomic_add(&v->counter, i); 61 } 62 63 static inline int 64 atomic_sub_return(int i, atomic_t *v) 65 { 66 return atomic_add(&v->counter, -i) - i; 67 } 68 69 static inline void 70 linux_atomic_set(atomic_t *v, int i) 71 { 72 atomic_set(&v->counter, i); 73 } 74 75 static inline void 76 atomic64_set(atomic64_t *v, long i) 77 { 78 atomic_set64(&v->counter, i); 79 } 80 81 static inline int 82 atomic_read(atomic_t *v) 83 { 84 return atomic_get(&v->counter); 85 } 86 87 static inline int64_t 88 atomic64_read(atomic64_t *v) 89 { 90 return atomic_get64(&v->counter); 91 } 92 93 static inline int 94 atomic_inc(atomic_t *v) 95 { 96 return atomic_add(&v->counter, 1) + 1; 97 } 98 99 static inline int 100 atomic_dec(atomic_t *v) 101 { 102 return atomic_add(&v->counter, -1) - 1; 103 } 104 105 static inline int atomic_add_unless(atomic_t *v, int a, int u) 106 { 107 int c, old; 108 c = atomic_read(v); 109 for (;;) { 110 if (unlikely(c == (u))) 111 break; 112 // old = atomic_cmpxchg((v), c, c + (a)); /*Linux*/ 113 old = atomic_test_and_set(&v->counter, c + (a), c); 114 if (likely(old == c)) 115 break; 116 c = old; 117 } 118 return c != (u); 119 } 120 121 #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 122 123 static inline void 124 atomic_clear_mask(int mask, atomic_t *v) 125 { 126 atomic_and(&v->counter, ~mask); 127 } 128 129 static inline void 130 atomic_set_mask(int mask, atomic_t *v) 131 { 132 atomic_or(&v->counter, mask); 133 } 134 135 #define atomic_sub(i, v) atomic_sub_return((i), (v)) 136 137 /* 138 #undef atomic_add 139 #undef atomic_set 140 #define atomic_add(i, v) atomic_add_return((i), (v)) 141 #define atomic_set(v, i) linux_atomic_set((v), (i)) 142 */ 143 144 #endif /* _ASM_ATOMIC_H_ */ -
new file headers/compatibility/linux/linux/bitops.h
diff --git a/headers/compatibility/linux/linux/bitops.h b/headers/compatibility/linux/linux/bitops.h new file mode 100644 index 0000000000..e80f9a0e2a
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 #ifndef _LINUX_BITOPS_H_ 29 #define _LINUX_BITOPS_H_ 30 31 #include <string.h> 32 33 #include <SupportDefs.h> 34 35 36 #ifndef howmany 37 #define howmany(x, y) (((x)+((y)-1))/(y)) 38 #endif 39 40 #ifdef __LP64__ 41 #define BITS_PER_LONG 64 42 #else 43 #define BITS_PER_LONG 32 44 #endif 45 #define BIT_MASK(n) (~0UL >> (BITS_PER_LONG - (n))) 46 #define BITS_TO_LONGS(n) howmany((n), BITS_PER_LONG) 47 #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) 48 49 static inline int 50 __ffs(int mask) 51 { 52 #if __GNUC__ >= 4 53 return __builtin_ffs(mask) - 1; 54 #else 55 int i; 56 unsigned int umask = (unsigned int)mask; 57 for (i = 0; umask != 0; i++) { 58 if ((umask & 0x1) != 0) 59 return i; 60 umask >>= 1; 61 } 62 return -1; 63 #endif 64 } 65 66 static inline int 67 __fls(int mask) 68 { 69 #if __GNUC__ >= 4 70 return sizeof(int) * 8 - __builtin_clz(mask) + 1; 71 #else 72 int i; 73 unsigned int umask = (unsigned int)mask; 74 for (i = 0; umask != 0; i++) { 75 umask >>= 1; 76 } 77 return i - 1; 78 #endif 79 } 80 81 static inline int 82 __ffsl(long mask) 83 { 84 #if __GNUC__ >= 4 85 return __builtin_ffsl(mask) - 1; 86 #else 87 int i; 88 unsigned long umask = (unsigned long)mask; 89 for (i = 0; umask != 0; i++) { 90 if ((umask & 0x1) != 0) 91 return i; 92 umask >>= 1; 93 } 94 return -1; 95 #endif 96 } 97 98 static inline int 99 __flsl(long mask) 100 { 101 #if __GNUC__ >= 4 102 return sizeof(int) * 8 - __builtin_clzl(mask) + 1; 103 #else 104 int i; 105 unsigned long umask = (unsigned long)mask; 106 for (i = 0; umask != 0; i++) { 107 umask >>= 1; 108 } 109 return i - 1; 110 #endif 111 } 112 113 114 #define ffz(mask) __ffs(~(mask)) 115 116 static inline int get_count_order(unsigned int count) 117 { 118 int order; 119 120 order = __fls(count); 121 if (count & (count - 1)) 122 order++; 123 return order; 124 } 125 126 static inline unsigned long 127 find_first_bit(unsigned long *addr, unsigned long size) 128 { 129 long mask; 130 int bit; 131 132 for (bit = 0; size >= BITS_PER_LONG; 133 size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) { 134 if (*addr == 0) 135 continue; 136 return (bit + __ffsl(*addr)); 137 } 138 if (size) { 139 mask = (*addr) & BIT_MASK(size); 140 if (mask) 141 bit += __ffsl(mask); 142 else 143 bit += size; 144 } 145 return (bit); 146 } 147 148 static inline unsigned long 149 find_first_zero_bit(unsigned long *addr, unsigned long size) 150 { 151 long mask; 152 int bit; 153 154 for (bit = 0; size >= BITS_PER_LONG; 155 size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) { 156 if (~(*addr) == 0) 157 continue; 158 return (bit + __ffsl(~(*addr))); 159 } 160 if (size) { 161 mask = ~(*addr) & BIT_MASK(size); 162 if (mask) 163 bit += __ffsl(mask); 164 else 165 bit += size; 166 } 167 return (bit); 168 } 169 170 static inline unsigned long 171 find_last_bit(unsigned long *addr, unsigned long size) 172 { 173 long mask; 174 int offs; 175 int bit; 176 int pos; 177 178 pos = size / BITS_PER_LONG; 179 offs = size % BITS_PER_LONG; 180 bit = BITS_PER_LONG * pos; 181 addr += pos; 182 if (offs) { 183 mask = (*addr) & BIT_MASK(offs); 184 if (mask) 185 return (bit + __flsl(mask)); 186 } 187 while (--pos) { 188 addr--; 189 bit -= BITS_PER_LONG; 190 if (*addr) 191 return (bit + __flsl(mask)); 192 } 193 return (size); 194 } 195 196 static inline unsigned long 197 find_next_bit(unsigned long *addr, unsigned long size, unsigned long offset) 198 { 199 long mask; 200 int offs; 201 int bit; 202 int pos; 203 204 if (offset >= size) 205 return (size); 206 pos = offset / BITS_PER_LONG; 207 offs = offset % BITS_PER_LONG; 208 bit = BITS_PER_LONG * pos; 209 addr += pos; 210 if (offs) { 211 mask = (*addr) & ~BIT_MASK(offs); 212 if (mask) 213 return (bit + __ffsl(mask)); 214 bit += BITS_PER_LONG; 215 addr++; 216 } 217 for (size -= bit; size >= BITS_PER_LONG; 218 size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) { 219 if (*addr == 0) 220 continue; 221 return (bit + __ffsl(*addr)); 222 } 223 if (size) { 224 mask = (*addr) & BIT_MASK(size); 225 if (mask) 226 bit += __ffsl(mask); 227 else 228 bit += size; 229 } 230 return (bit); 231 } 232 233 static inline unsigned long 234 find_next_zero_bit(unsigned long *addr, unsigned long size, 235 unsigned long offset) 236 { 237 long mask; 238 int offs; 239 int bit; 240 int pos; 241 242 if (offset >= size) 243 return (size); 244 pos = offset / BITS_PER_LONG; 245 offs = offset % BITS_PER_LONG; 246 bit = BITS_PER_LONG * pos; 247 addr += pos; 248 if (offs) { 249 mask = ~(*addr) & ~BIT_MASK(offs); 250 if (mask) 251 return (bit + __ffsl(mask)); 252 bit += BITS_PER_LONG; 253 addr++; 254 } 255 for (size -= bit; size >= BITS_PER_LONG; 256 size -= BITS_PER_LONG, bit += BITS_PER_LONG, addr++) { 257 if (~(*addr) == 0) 258 continue; 259 return (bit + __ffsl(~(*addr))); 260 } 261 if (size) { 262 mask = ~(*addr) & BIT_MASK(size); 263 if (mask) 264 bit += __ffsl(mask); 265 else 266 bit += size; 267 } 268 return (bit); 269 } 270 271 static inline void 272 bitmap_zero(unsigned long *addr, int size) 273 { 274 int len; 275 276 len = BITS_TO_LONGS(size) * sizeof(long); 277 memset(addr, 0, len); 278 } 279 280 static inline void 281 bitmap_fill(unsigned long *addr, int size) 282 { 283 int tail; 284 int len; 285 286 len = (size / BITS_PER_LONG) * sizeof(long); 287 memset(addr, 0xff, len); 288 tail = size & (BITS_PER_LONG - 1); 289 if (tail) 290 addr[size / BITS_PER_LONG] = BIT_MASK(tail); 291 } 292 293 static inline int 294 bitmap_full(unsigned long *addr, int size) 295 { 296 long mask; 297 int tail; 298 int len; 299 int i; 300 301 len = size / BITS_PER_LONG; 302 for (i = 0; i < len; i++) 303 if (addr[i] != ~0UL) 304 return (0); 305 tail = size & (BITS_PER_LONG - 1); 306 if (tail) { 307 mask = BIT_MASK(tail); 308 if ((addr[i] & mask) != mask) 309 return (0); 310 } 311 return (1); 312 } 313 314 static inline int 315 bitmap_empty(unsigned long *addr, int size) 316 { 317 long mask; 318 int tail; 319 int len; 320 int i; 321 322 len = size / BITS_PER_LONG; 323 for (i = 0; i < len; i++) 324 if (addr[i] != 0) 325 return (0); 326 tail = size & (BITS_PER_LONG - 1); 327 if (tail) { 328 mask = BIT_MASK(tail); 329 if ((addr[i] & mask) != 0) 330 return (0); 331 } 332 return (1); 333 } 334 335 #define NBLONG BITS_PER_LONG 336 337 #define set_bit(i, a) \ 338 atomic_or64(&((volatile long *)(a))[(i)/NBLONG], 1 << (i) % NBLONG) 339 340 #define clear_bit(i, a) \ 341 atomic_and64(&((volatile long *)(a))[(i)/NBLONG], ~(1 << (i) % NBLONG)) 342 343 #define test_bit(i, a) \ 344 !!(atomic_get64(&((volatile long *)(a))[(i)/NBLONG]) & 1 << ((i) % NBLONG)) 345 346 static inline long 347 test_and_clear_bit(long bit, long *var) 348 { 349 long val; 350 351 var += bit / BITS_PER_LONG; 352 bit %= BITS_PER_LONG; 353 bit = 1 << bit; 354 do { 355 val = *(volatile long *)var; 356 #if BITS_PER_LONG == 32 357 } while (atomic_test_and_set((long*)var, val & ~bit, val) == 0); 358 #else 359 } while (atomic_test_and_set64((long*)var, val & ~bit, val) == 0); 360 #endif 361 362 return !!(val & bit); 363 } 364 365 static inline long 366 test_and_set_bit(long bit, volatile unsigned long *var) 367 { 368 long val; 369 370 var += bit / BITS_PER_LONG; 371 bit %= BITS_PER_LONG; 372 bit = 1 << bit; 373 do { 374 val = *(volatile long *)var; 375 #if BITS_PER_LONG == 32 376 } while (atomic_test_and_set((long*)var, val | bit, val) == 0); 377 #else 378 } while (atomic_test_and_set64((long*)var, val | bit, val) == 0); 379 #endif 380 381 return !!(val & bit); 382 } 383 384 385 #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG)) 386 #define BITMAP_LAST_WORD_MASK(nbits) \ 387 ( \ 388 ((nbits) % BITS_PER_LONG) ? \ 389 (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ 390 ) 391 392 393 static inline void 394 bitmap_set(unsigned long *map, int start, int nr) 395 { 396 unsigned long *p = map + BIT_WORD(start); 397 const int size = start + nr; 398 int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG); 399 unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start); 400 401 while (nr - bits_to_set >= 0) { 402 *p |= mask_to_set; 403 nr -= bits_to_set; 404 bits_to_set = BITS_PER_LONG; 405 mask_to_set = ~0UL; 406 p++; 407 } 408 if (nr) { 409 mask_to_set &= BITMAP_LAST_WORD_MASK(size); 410 *p |= mask_to_set; 411 } 412 } 413 414 static inline void 415 bitmap_clear(unsigned long *map, int start, int nr) 416 { 417 unsigned long *p = map + BIT_WORD(start); 418 const int size = start + nr; 419 int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG); 420 unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start); 421 422 while (nr - bits_to_clear >= 0) { 423 *p &= ~mask_to_clear; 424 nr -= bits_to_clear; 425 bits_to_clear = BITS_PER_LONG; 426 mask_to_clear = ~0UL; 427 p++; 428 } 429 if (nr) { 430 mask_to_clear &= BITMAP_LAST_WORD_MASK(size); 431 *p &= ~mask_to_clear; 432 } 433 } 434 435 enum { 436 REG_OP_ISFREE, /* true if region is all zero bits */ 437 REG_OP_ALLOC, /* set all bits in region */ 438 REG_OP_RELEASE, /* clear all bits in region */ 439 }; 440 441 static int __reg_op(unsigned long *bitmap, int pos, int order, int reg_op) 442 { 443 int nbits_reg; /* number of bits in region */ 444 int index; /* index first long of region in bitmap */ 445 int offset; /* bit offset region in bitmap[index] */ 446 int nlongs_reg; /* num longs spanned by region in bitmap */ 447 int nbitsinlong; /* num bits of region in each spanned long */ 448 unsigned long mask; /* bitmask for one long of region */ 449 int i; /* scans bitmap by longs */ 450 int ret = 0; /* return value */ 451 452 /* 453 * Either nlongs_reg == 1 (for small orders that fit in one long) 454 * or (offset == 0 && mask == ~0UL) (for larger multiword orders.) 455 */ 456 nbits_reg = 1 << order; 457 index = pos / BITS_PER_LONG; 458 offset = pos - (index * BITS_PER_LONG); 459 nlongs_reg = BITS_TO_LONGS(nbits_reg); 460 nbitsinlong = min_c(nbits_reg, BITS_PER_LONG); 461 462 /* 463 * Can't do "mask = (1UL << nbitsinlong) - 1", as that 464 * overflows if nbitsinlong == BITS_PER_LONG. 465 */ 466 mask = (1UL << (nbitsinlong - 1)); 467 mask += mask - 1; 468 mask <<= offset; 469 470 switch (reg_op) { 471 case REG_OP_ISFREE: 472 for (i = 0; i < nlongs_reg; i++) { 473 if (bitmap[index + i] & mask) 474 goto done; 475 } 476 ret = 1; /* all bits in region free (zero) */ 477 break; 478 479 case REG_OP_ALLOC: 480 for (i = 0; i < nlongs_reg; i++) 481 bitmap[index + i] |= mask; 482 break; 483 484 case REG_OP_RELEASE: 485 for (i = 0; i < nlongs_reg; i++) 486 bitmap[index + i] &= ~mask; 487 break; 488 } 489 done: 490 return ret; 491 } 492 493 /** 494 * bitmap_find_free_region - find a contiguous aligned mem region 495 * @bitmap: array of unsigned longs corresponding to the bitmap 496 * @bits: number of bits in the bitmap 497 * @order: region size (log base 2 of number of bits) to find 498 * 499 * Find a region of free (zero) bits in a @bitmap of @bits bits and 500 * allocate them (set them to one). Only consider regions of length 501 * a power (@order) of two, aligned to that power of two, which 502 * makes the search algorithm much faster. 503 * 504 * Return the bit offset in bitmap of the allocated region, 505 * or -errno on failure. 506 */ 507 static inline int 508 bitmap_find_free_region(unsigned long *bitmap, int bits, int order) 509 { 510 int pos, end; /* scans bitmap by regions of size order */ 511 512 for (pos = 0 ; (end = pos + (1 << order)) <= bits; pos = end) { 513 if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE)) 514 continue; 515 __reg_op(bitmap, pos, order, REG_OP_ALLOC); 516 return pos; 517 } 518 return -ENOMEM; 519 } 520 521 /** 522 * bitmap_release_region - release allocated bitmap region 523 * @bitmap: array of unsigned longs corresponding to the bitmap 524 * @pos: beginning of bit region to release 525 * @order: region size (log base 2 of number of bits) to release 526 * 527 * This is the complement to __bitmap_find_free_region() and releases 528 * the found region (by clearing it in the bitmap). 529 * 530 * No return value. 531 */ 532 static inline void 533 bitmap_release_region(unsigned long *bitmap, int pos, int order) 534 { 535 __reg_op(bitmap, pos, order, REG_OP_RELEASE); 536 } 537 538 #include <asm/bitops/non-atomic.h> 539 #include <asm/bitops/const_hweight.h> 540 541 #endif /* _LINUX_BITOPS_H_ */ -
new file headers/compatibility/linux/linux/cdev.h
diff --git a/headers/compatibility/linux/linux/cdev.h b/headers/compatibility/linux/linux/cdev.h new file mode 100644 index 0000000000..df3a700dca
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #ifndef _LINUX_CDEV_H_ 31 #define _LINUX_CDEV_H_ 32 33 #include <linux/kobject.h> 34 #include <linux/kdev_t.h> 35 #include <linux/list.h> 36 37 struct file_operations; 38 struct inode; 39 struct module; 40 41 struct cdev { 42 struct kobject kobj; 43 struct module* owner; 44 const struct file_operations* ops; 45 46 dev_t dev; 47 unsigned count; 48 struct list_head entry; 49 }; 50 51 52 extern int cdev_add(struct cdev* cdev, dev_t dev, unsigned count); 53 54 55 static inline void 56 cdev_release(struct kobject *kobj) 57 { 58 struct cdev* cdev; 59 60 cdev = container_of(kobj, struct cdev, kobj); 61 kfree(cdev); 62 } 63 64 static inline void 65 cdev_static_release(struct kobject *kobj) 66 { 67 } 68 69 static struct kobj_type cdev_ktype = { 70 .release = cdev_release, 71 }; 72 73 static struct kobj_type cdev_static_ktype = { 74 .release = cdev_static_release, 75 }; 76 77 static inline void 78 cdev_init(struct cdev* cdev, const struct file_operations *ops) 79 { 80 kobject_init(&cdev->kobj, &cdev_static_ktype); 81 cdev->ops = ops; 82 } 83 84 static inline struct cdev* 85 cdev_alloc(void) 86 { 87 struct cdev* cdev; 88 89 cdev = kzalloc(sizeof(struct cdev), GFP_KERNEL); 90 if (cdev != NULL) 91 kobject_init(&cdev->kobj, &cdev_ktype); 92 return cdev; 93 } 94 95 static inline void 96 cdev_put(struct cdev *p) 97 { 98 kobject_put(&p->kobj); 99 } 100 101 102 103 static inline void 104 cdev_del(struct cdev* cdev) 105 { 106 kobject_put(&cdev->kobj); 107 } 108 109 110 #endif /* _LINUX_CDEV_H_ */ -
new file headers/compatibility/linux/linux/compiler.h
diff --git a/headers/compatibility/linux/linux/compiler.h b/headers/compatibility/linux/linux/compiler.h new file mode 100644 index 0000000000..75de7265a4
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef _LINUX_COMPILER_H_ 30 #define _LINUX_COMPILER_H_ 31 32 #include <sys/cdefs.h> 33 34 #define __user 35 #define __kernel 36 #define __safe 37 #define __force 38 #define __nocast 39 #define __iomem 40 #define __chk_user_ptr(x) 0 41 #define __chk_io_ptr(x) 0 42 #define __builtin_warning(x, y...) (1) 43 #define __acquires(x) 44 #define __releases(x) 45 #define __acquire(x) 0 46 #define __release(x) 0 47 #define __cond_lock(x,c) (c) 48 #define __bitwise 49 #define __devinitdata 50 #define __init 51 #define __devinit 52 #define __devexit 53 #define __exit 54 #define __stringify(x) #x 55 #define __attribute_const__ __attribute__((__const__)) 56 #undef __always_inline 57 #define __always_inline inline 58 59 #if __GNUC__ >= 4 60 #define likely(x) __builtin_expect(!!(x), 1) 61 #define unlikely(x) __builtin_expect(!!(x), 0) 62 #else 63 #define likely(x) x 64 #define unlikely(x) x 65 #endif 66 67 #define typeof(x) __typeof(x) 68 69 #define __read_mostly 70 #define __always_unused 71 #define __must_check __heedresult 72 73 #endif /* _LINUX_COMPILER_H_ */ -
new file headers/compatibility/linux/linux/device.h
diff --git a/headers/compatibility/linux/linux/device.h b/headers/compatibility/linux/linux/device.h new file mode 100644 index 0000000000..3728183e51
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef _LINUX_DEVICE_H_ 30 #define _LINUX_DEVICE_H_ 31 32 #include <linux/types.h> 33 #include <linux/kobject.h> 34 #include <linux/list.h> 35 #include <linux/compiler.h> 36 #include <linux/types.h> 37 #include <linux/module.h> 38 #include <linux/workqueue.h> 39 #include <linux/sysfs.h> 40 #include <linux/kdev_t.h> 41 42 #include <stdio.h> 43 44 45 enum irqreturn { IRQ_NONE = 0, IRQ_HANDLED, IRQ_WAKE_THREAD, }; 46 typedef enum irqreturn irqreturn_t; 47 48 struct device; 49 50 51 struct class { 52 const char* name; 53 struct module* owner; 54 struct kobject kobj; 55 56 void (*class_release)(struct class* class); 57 void (*dev_release)(struct device* dev); 58 char* (*devnode)(struct device* dev, umode_t* mode); 59 }; 60 61 struct device { 62 struct device* parent; 63 struct list_head irqents; 64 65 dev_t devt; 66 struct class* class; 67 struct kobject kobj; 68 69 void (*release)(struct device *dev); 70 uint64_t* dma_mask; 71 void* driver_data; 72 73 unsigned int irq; 74 unsigned int msix; 75 unsigned int msix_max; 76 77 // Private 78 struct device_node* node; 79 }; 80 81 82 struct device_driver { 83 }; 84 85 // TODO 86 //extern struct device linux_rootdev; 87 extern struct kobject class_root; 88 89 90 struct class_attribute { 91 struct attribute attr; 92 ssize_t (*show)(struct class *, struct class_attribute *, char *); 93 ssize_t (*store)(struct class *, struct class_attribute *, const char *, size_t); 94 const void *(*namespace)(struct class *, const struct class_attribute *); 95 }; 96 97 #define CLASS_ATTR(_name, _mode, _show, _store) \ 98 struct class_attribute class_attr_##_name = \ 99 { { #_name, NULL, _mode }, _show, _store } 100 101 struct device_attribute { 102 struct attribute attr; 103 ssize_t (*show)(struct device *, 104 struct device_attribute *, char *); 105 ssize_t (*store)(struct device *, 106 struct device_attribute *, const char *, 107 size_t); 108 }; 109 110 #define DEVICE_ATTR(_name, _mode, _show, _store) \ 111 struct device_attribute dev_attr_##_name = \ 112 { { #_name, NULL, _mode }, _show, _store } 113 114 /* Simple class attribute that is just a static string */ 115 struct class_attribute_string { 116 struct class_attribute attr; 117 char *str; 118 }; 119 120 static inline ssize_t 121 show_class_attr_string(struct class *class, 122 struct class_attribute *attr, char *buf) 123 { 124 struct class_attribute_string *cs; 125 cs = container_of(attr, struct class_attribute_string, attr); 126 return snprintf(buf, PAGE_SIZE, "%s\n", cs->str); 127 } 128 129 /* Currently read-only only */ 130 #define _CLASS_ATTR_STRING(_name, _mode, _str) \ 131 { __ATTR(_name, _mode, show_class_attr_string, NULL), _str } 132 #define CLASS_ATTR_STRING(_name, _mode, _str) \ 133 struct class_attribute_string class_attr_##_name = \ 134 _CLASS_ATTR_STRING(_name, _mode, _str) 135 136 #define dev_err(dev, fmt, ...) kprintf(fmt, ##__VA_ARGS__) 137 #define dev_warn(dev, fmt, ...) kprintf(fmt, ##__VA_ARGS__) 138 #define dev_info(dev, fmt, ...) kprintf(fmt, ##__VA_ARGS__) 139 #define dev_printk(lvl, dev, fmt, ...) kprintf(fmt, ##__VA_ARGS__) 140 141 static inline void * 142 dev_get_drvdata(struct device *dev) 143 { 144 return dev->driver_data; 145 } 146 147 static inline void 148 dev_set_drvdata(struct device *dev, void *data) 149 { 150 dev->driver_data = data; 151 } 152 153 static inline struct device * 154 get_device(struct device *dev) 155 { 156 if (dev) 157 kobject_get(&dev->kobj); 158 159 return (dev); 160 } 161 162 static inline char * 163 dev_name(const struct device *dev) 164 { 165 return kobject_name(&dev->kobj); 166 } 167 168 #define dev_set_name(_dev, _fmt, ...) \ 169 kobject_set_name(&(_dev)->kobj, (_fmt), ##__VA_ARGS__) 170 171 static inline void 172 put_device(struct device *dev) 173 { 174 if (dev) 175 kobject_put(&dev->kobj); 176 } 177 178 static inline ssize_t 179 class_show(struct kobject *kobj, struct attribute *attr, char *buf) 180 { 181 struct class_attribute *dattr; 182 ssize_t error; 183 184 dattr = container_of(attr, struct class_attribute, attr); 185 error = -EIO; 186 if (dattr->show) 187 error = dattr->show(container_of(kobj, struct class, kobj), 188 dattr, buf); 189 return (error); 190 } 191 192 static inline ssize_t 193 class_store(struct kobject *kobj, struct attribute *attr, const char *buf, 194 size_t count) 195 { 196 struct class_attribute *dattr; 197 ssize_t error; 198 199 dattr = container_of(attr, struct class_attribute, attr); 200 error = -EIO; 201 if (dattr->store) 202 error = dattr->store(container_of(kobj, struct class, kobj), 203 dattr, buf, count); 204 return (error); 205 } 206 207 static inline void 208 class_release(struct kobject *kobj) 209 { 210 struct class *class; 211 212 class = container_of(kobj, struct class, kobj); 213 if (class->class_release) 214 class->class_release(class); 215 } 216 217 static struct sysfs_ops class_sysfs = { 218 .show = class_show, 219 .store = class_store, 220 }; 221 222 static struct kobj_type class_ktype = { 223 .release = class_release, 224 .sysfs_ops = &class_sysfs 225 }; 226 227 static inline int 228 class_register(struct class *class) 229 { 230 kobject_init(&class->kobj, &class_ktype); 231 kobject_set_name(&class->kobj, class->name); 232 kobject_add(&class->kobj, &class_root, class->name); 233 234 return (0); 235 } 236 237 static inline void 238 class_unregister(struct class *class) 239 { 240 kobject_put(&class->kobj); 241 } 242 243 static inline void 244 device_release(struct kobject *kobj) 245 { 246 struct device *dev; 247 248 dev = container_of(kobj, struct device, kobj); 249 /* This is the precedence defined by linux. */ 250 if (dev->release) 251 dev->release(dev); 252 else if (dev->class && dev->class->dev_release) 253 dev->class->dev_release(dev); 254 } 255 256 static inline ssize_t 257 dev_show(struct kobject *kobj, struct attribute *attr, char *buf) 258 { 259 struct device_attribute *dattr; 260 ssize_t error; 261 262 dattr = container_of(attr, struct device_attribute, attr); 263 error = -EIO; 264 if (dattr->show) 265 error = dattr->show(container_of(kobj, struct device, kobj), 266 dattr, buf); 267 return (error); 268 } 269 270 static inline ssize_t 271 dev_store(struct kobject *kobj, struct attribute *attr, const char *buf, 272 size_t count) 273 { 274 struct device_attribute *dattr; 275 ssize_t error; 276 277 dattr = container_of(attr, struct device_attribute, attr); 278 error = -EIO; 279 if (dattr->store) 280 error = dattr->store(container_of(kobj, struct device, kobj), 281 dattr, buf, count); 282 return (error); 283 } 284 285 static struct sysfs_ops dev_sysfs = { .show = dev_show, .store = dev_store, }; 286 static struct kobj_type dev_ktype = { 287 .release = device_release, 288 .sysfs_ops = &dev_sysfs 289 }; 290 291 292 extern void device_initialize(struct device* dev); 293 extern int device_register(struct device* dev); 294 extern void device_unregister(struct device* dev); 295 296 extern struct device* device_create(struct class* class, struct device* parent, 297 dev_t devt, void* drvdata, const char* fmt, ...); 298 extern void device_destroy(struct class *class, dev_t devt); 299 300 301 static inline void 302 class_kfree(struct class* class) 303 { 304 kfree(class); 305 } 306 307 static inline struct class* 308 class_create(struct module* owner, const char* name) 309 { 310 struct class* class; 311 int error; 312 313 class = kzalloc(sizeof(*class), GFP_KERNEL); 314 class->owner = owner; 315 class->name= name; 316 class->class_release = class_kfree; 317 error = class_register(class); 318 if (error) { 319 kfree(class); 320 return (NULL); 321 } 322 323 return (class); 324 } 325 326 static inline void 327 class_destroy(struct class *class) 328 { 329 if (class == NULL) 330 return; 331 class_unregister(class); 332 } 333 334 static inline int 335 device_create_file(struct device *dev, const struct device_attribute *attr) 336 { 337 if (dev) 338 return sysfs_create_file(&dev->kobj, &attr->attr); 339 return -EINVAL; 340 } 341 342 static inline void 343 device_remove_file(struct device *dev, const struct device_attribute *attr) 344 { 345 if (dev) 346 sysfs_remove_file(&dev->kobj, &attr->attr); 347 } 348 349 static inline int 350 class_create_file(struct class *class, const struct class_attribute *attr) 351 { 352 if (class) 353 return sysfs_create_file(&class->kobj, &attr->attr); 354 return -EINVAL; 355 } 356 357 static inline void 358 class_remove_file(struct class *class, const struct class_attribute *attr) 359 { 360 if (class) 361 sysfs_remove_file(&class->kobj, &attr->attr); 362 } 363 364 static inline int dev_to_node(struct device *dev) 365 { 366 return -1; 367 } 368 369 370 #endif /* _LINUX_DEVICE_H_ */ -
new file headers/compatibility/linux/linux/dma-fence.h
diff --git a/headers/compatibility/linux/linux/dma-fence.h b/headers/compatibility/linux/linux/dma-fence.h new file mode 100644 index 0000000000..e119abdf5e
- + 1 #ifndef _LINUX_DMA_FENCE_H_ 2 #define _LINUX_DMA_FENCE_H_ 3 4 #endif /* _LINUX_DMA_FENCE_H_ */ -
new file headers/compatibility/linux/linux/dma-mapping.h
diff --git a/headers/compatibility/linux/linux/dma-mapping.h b/headers/compatibility/linux/linux/dma-mapping.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/linux/errno.h
diff --git a/headers/compatibility/linux/linux/errno.h b/headers/compatibility/linux/linux/errno.h new file mode 100644 index 0000000000..4592c1889b
- + 1 /* 2 * Copyright (c) 2014 François Tigeot 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef _LINUX_ERRNO_H_ 28 #define _LINUX_ERRNO_H_ 29 30 #define ERESTARTSYS EINTR 31 32 #endif /* _LINUX_ERRNO_H_ */ -
new file headers/compatibility/linux/linux/file.h
diff --git a/headers/compatibility/linux/linux/file.h b/headers/compatibility/linux/linux/file.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/linux/fs.h
diff --git a/headers/compatibility/linux/linux/fs.h b/headers/compatibility/linux/linux/fs.h new file mode 100644 index 0000000000..11dcc5ad1f
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013 Mellanox Technologies, Ltd. 6 * Copyright (c) 2015 Hamish Morrison 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice unmodified, this list of conditions, and the following 14 * disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 #ifndef _LINUX_FS_H_ 31 #define _LINUX_FS_H_ 32 33 #include <linux/types.h> 34 35 struct inode; 36 struct module; 37 struct vm_area_struct; 38 struct poll_table_struct; 39 40 41 #define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH) 42 #define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH) 43 44 45 struct file_operations; 46 47 struct file { 48 const struct file_operations* f_op; 49 void* private_data; 50 int f_flags; 51 int f_mode; 52 53 // Private 54 struct inode* inode; 55 }; 56 57 struct inode { 58 umode_t i_mode; 59 unsigned int i_flags; 60 dev_t i_rdev; 61 union { 62 struct cdev* i_cdev; 63 }; 64 void* i_private; 65 }; 66 67 68 struct file_operations { 69 struct module* owner; 70 71 int (*open)(struct inode *, struct file *); 72 int (*release)(struct inode *, struct file *); 73 ssize_t (*read)(struct file *, char __user *, size_t, loff_t *); 74 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); 75 76 long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long); 77 loff_t (*llseek)(struct file *, loff_t, int); 78 unsigned int (*poll) (struct file *, struct poll_table_struct *); 79 int (*mmap)(struct file *, struct vm_area_struct *); 80 }; 81 82 #define fops_get(fops) (fops) 83 #define replace_fops(file, fops) ((file)->f_op = (fops)) 84 85 86 #define FMODE_READ FREAD 87 #define FMODE_WRITE FWRITE 88 #define FMODE_EXEC FEXEC 89 90 91 extern int register_chrdev(unsigned int major, const char* name, 92 const struct file_operations* ops); 93 extern void unregister_chrdev(unsigned int major, const char* name); 94 95 static inline int 96 register_chrdev_region(dev_t dev, unsigned range, const char*name) 97 { 98 return 0; 99 } 100 101 static inline void 102 unregister_chrdev_region(dev_t dev, unsigned range) 103 { 104 return; 105 } 106 107 static inline int 108 alloc_chrdev_region(dev_t* dev, unsigned baseminor, unsigned count, 109 const char* name) 110 { 111 // TODO 112 return 0; 113 } 114 115 static inline dev_t iminor(struct inode* inode) 116 { 117 return MINOR(inode->i_rdev); 118 } 119 120 static inline dev_t imajor(struct inode* inode) 121 { 122 return MAJOR(inode->i_rdev); 123 } 124 125 static inline struct inode* igrab(struct inode* inode) 126 { 127 return inode; 128 } 129 130 static inline void iput(struct inode* inode) 131 { 132 } 133 134 #endif /* _LINUX_FS_H_ */ -
new file headers/compatibility/linux/linux/gfp.h
diff --git a/headers/compatibility/linux/linux/gfp.h b/headers/compatibility/linux/linux/gfp.h new file mode 100644 index 0000000000..86d3815f3c
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #ifndef _LINUX_GFP_H_ 31 #define _LINUX_GFP_H_ 32 33 #include <malloc.h> 34 35 36 struct page { 37 void* address; 38 }; 39 40 41 #define __GFP_NOWARN 0 42 #define __GFP_HIGHMEM 0 43 #define __GFP_ZERO 0x08 44 45 #define GFP_KERNEL 0 46 #define GFP_USER 0 47 #define GFP_HIGHUSER 0 48 #define GFP_HIGHUSER_MOVABLE 0 49 #define GFP_NOWAIT HEAP_DONT_WAIT_FOR_MEMORY 50 #define GFP_ATOMIC HEAP_DONT_WAIT_FOR_MEMORY 51 #define GFP_IOFS HEAP_DONT_WAIT_FOR_MEMORY 52 53 static inline void* 54 page_address(struct page *page) 55 { 56 return page->address; 57 } 58 59 #if 0 60 61 static inline unsigned long 62 _get_page(gfp_t mask) 63 { 64 return (unsigned long)memalign_etc(PAGE_SIZE, PAGE_SIZE, mask); 65 } 66 67 static inline unsigned long 68 get_zeroed_page(gfp_t mask) 69 { 70 unsigned long page = _get_page(mask); 71 memset((void*)page, 0, PAGE_SIZE); 72 return page; 73 } 74 75 #define get_zeroed_page(mask) _get_page((mask) | M_ZERO) 76 #define alloc_page(mask) virt_to_page(_get_page((mask))) 77 #define __get_free_page(mask) _get_page((mask)) 78 79 static inline void 80 free_page(unsigned long page) 81 { 82 83 if (page == 0) 84 return; 85 kmem_free(kmem_arena, page, PAGE_SIZE); 86 } 87 88 static inline void 89 __free_page(struct page *m) 90 { 91 92 if (m->object != kmem_object) 93 panic("__free_page: Freed page %p not allocated via wrappers.", 94 m); 95 kmem_free(kmem_arena, (vm_offset_t)page_address(m), PAGE_SIZE); 96 } 97 98 static inline void 99 __free_pages(struct page *m, unsigned int order) 100 { 101 size_t size; 102 103 if (m == NULL) 104 return; 105 size = PAGE_SIZE << order; 106 kmem_free(kmem_arena, (vm_offset_t)page_address(m), size); 107 } 108 109 /* 110 * Alloc pages allocates directly from the buddy allocator on linux so 111 * order specifies a power of two bucket of pages and the results 112 * are expected to be aligned on the size as well. 113 */ 114 static inline struct page* 115 alloc_pages(gfp_t gfp_mask, unsigned int order) 116 { 117 void* address; 118 size_t size; 119 120 size = PAGE_SIZE << order; 121 area_id area = create_area("linux pages", &address, B_ANY_KERNEL_ADDRESS, 122 size, B_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA); 123 if (area < 0) 124 return NULL; 125 126 return page_struct(address); 127 } 128 129 #define alloc_pages_node(node, mask, order) alloc_pages(mask, order) 130 131 #define kmalloc_node(chunk, mask, node) kmalloc(chunk, mask) 132 133 #endif 134 135 #endif /* _LINUX_GFP_H_ */ -
new file headers/compatibility/linux/linux/highmem.h
diff --git a/headers/compatibility/linux/linux/highmem.h b/headers/compatibility/linux/linux/highmem.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/linux/idr.h
diff --git a/headers/compatibility/linux/linux/idr.h b/headers/compatibility/linux/linux/idr.h new file mode 100644 index 0000000000..553c40b3f8
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #ifndef _LINUX_IDR_H_ 31 #define _LINUX_IDR_H_ 32 33 #include <lock.h> 34 #include <linux/types.h> 35 36 #define NBBY 8 37 38 #define IDR_BITS 5 39 #define IDR_SIZE (1 << IDR_BITS) 40 #define IDR_MASK (IDR_SIZE - 1) 41 42 #define MAX_ID_SHIFT ((sizeof(int) * NBBY) - 1) 43 #define MAX_ID_BIT (1U << MAX_ID_SHIFT) 44 #define MAX_ID_MASK (MAX_ID_BIT - 1) 45 #define MAX_LEVEL (MAX_ID_SHIFT + IDR_BITS - 1) / IDR_BITS 46 47 #define MAX_IDR_SHIFT (sizeof(int)*8 - 1) 48 #define MAX_IDR_BIT (1U << MAX_IDR_SHIFT) 49 #define MAX_IDR_MASK (MAX_IDR_BIT - 1) 50 51 struct idr_layer { 52 unsigned long bitmap; 53 struct idr_layer* ary[IDR_SIZE]; 54 }; 55 56 struct idr { 57 mutex lock; 58 struct idr_layer* top; 59 struct idr_layer* avail; 60 int layers; 61 }; 62 63 #define DEFINE_IDR(name) \ 64 struct idr name = { \ 65 .lock = MUTEX_INITIALIZER("linux idr") \ 66 }; 67 68 void *idr_find(struct idr *idp, int id); 69 int idr_pre_get(struct idr *idp, gfp_t gfp_mask); 70 int idr_get_new(struct idr *idp, void *ptr, int *id); 71 int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id); 72 void *idr_replace(struct idr *idp, void *ptr, int id); 73 void idr_remove(struct idr *idp, int id); 74 void idr_remove_all(struct idr *idp); 75 void idr_destroy(struct idr *idp); 76 void idr_init(struct idr *idp); 77 int idr_alloc(struct idr* idr, void* ptr, int start, int end, gfp_t mask); 78 79 #endif /* _LINUX_IDR_H_ */ -
new file headers/compatibility/linux/linux/init.h
diff --git a/headers/compatibility/linux/linux/init.h b/headers/compatibility/linux/linux/init.h new file mode 100644 index 0000000000..317c5bf828
- + 1 /* 2 * Copyright 2015 Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _LINUX_INIT_H 6 #define _LINUX_INIT_H 7 8 9 typedef int (*initcall_t)(void); 10 11 12 #define __init 13 14 #define module_init(func) \ 15 static initcall_t __attribute__ ((section(".module_init"))) \ 16 __init_##func = func; 17 18 19 #endif -
new file headers/compatibility/linux/linux/io.h
diff --git a/headers/compatibility/linux/linux/io.h b/headers/compatibility/linux/linux/io.h new file mode 100644 index 0000000000..a59d652916
- + 1 /* 2 * Copyright (c) 2014 François Tigeot 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef _LINUX_IO_H_ 28 #define _LINUX_IO_H_ 29 30 #include <asm/io.h> 31 32 static inline void 33 writel(uint32_t value, void* addr) 34 { 35 *(volatile uint32_t*)addr = value; 36 } 37 38 static inline uint32_t 39 readl(void* addr) 40 { 41 return *(volatile uint32_t*)addr; 42 } 43 44 #endif /* _LINUX_IO_H_ */ -
new file headers/compatibility/linux/linux/jiffies.h
diff --git a/headers/compatibility/linux/linux/jiffies.h b/headers/compatibility/linux/linux/jiffies.h new file mode 100644 index 0000000000..a09339cbef
- + 1 /* 2 * Copyright (c) 2014-2015 François Tigeot 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef _LINUX_JIFFIES_H_ 28 #define _LINUX_JIFFIES_H_ 29 30 #include <linux/math64.h> 31 #include <linux/time.h> 32 33 #define HZ 1000000 34 35 #define jiffies_to_msecs(x) (((int64_t)(x)) * 1000 / HZ) 36 #define msecs_to_jiffies(x) (((int64_t)(x)) * HZ / 1000) 37 #define jiffies ticks 38 #define time_after(a,b) ((long)(b) - (long)(a) < 0) 39 #define time_after_eq(a,b) ((long)(b) - (long)(a) <= 0) 40 41 static inline unsigned long 42 timespec_to_jiffies(const struct timespec *ts) 43 { 44 unsigned long result; 45 46 result = ((unsigned long)HZ * ts->tv_sec) + (ts->tv_nsec / NSEC_PER_SEC); 47 if (result > LONG_MAX) 48 result = LONG_MAX; 49 50 return result; 51 } 52 53 static inline 54 unsigned long usecs_to_jiffies(const unsigned int u) 55 { 56 unsigned long result; 57 58 result = (u * HZ) / 1000000; 59 if (result < 1) 60 return 1; 61 else 62 return result; 63 } 64 65 #endif /* _LINUX_JIFFIES_H_ */ -
new file headers/compatibility/linux/linux/kdev_t.h
diff --git a/headers/compatibility/linux/linux/kdev_t.h b/headers/compatibility/linux/linux/kdev_t.h new file mode 100644 index 0000000000..11fce8f26d
- + 1 /* 2 * Copyright 2015 Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _LINUX_KDEV_T_H 6 #define _LINUX_KDEV_T_H 7 8 #define MAJOR(devt) ((devt) >> 20) 9 #define MINOR(devt) ((devt) & 0xfffff) 10 #define MKDEV(major, minor) (((major) << 20) | (minor)) 11 12 #endif -
new file headers/compatibility/linux/linux/kernel.h
diff --git a/headers/compatibility/linux/linux/kernel.h b/headers/compatibility/linux/linux/kernel.h new file mode 100644 index 0000000000..f4009aa5a4
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2014 François Tigeot 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef _LINUX_KERNEL_H_ 30 #define _LINUX_KERNEL_H_ 31 32 #include <linux/bitops.h> 33 #include <linux/compiler.h> 34 #include <linux/log2.h> 35 #include <linux/types.h> 36 37 #include <stdarg.h> 38 39 #define PAGE_SHIFT 12 40 41 #define KERN_CONT "" 42 #define KERN_EMERG "<0>" 43 #define KERN_ALERT "<1>" 44 #define KERN_CRIT "<2>" 45 #define KERN_ERR "<3>" 46 #define KERN_WARNING "<4>" 47 #define KERN_NOTICE "<5>" 48 #define KERN_INFO "<6>" 49 #define KERN_DEBUG "<7>" 50 51 #define BUG() do \ 52 { \ 53 panic("BUG in %s at %s:%u", \ 54 __func__, __FILE__, __LINE__); \ 55 } while (0) 56 57 #define BUG_ON(condition) do { if (condition) BUG(); } while(0) 58 59 #define _WARN_STR(x) #x 60 61 #define WARN_ON(condition) ({ \ 62 int __ret = !!(condition); \ 63 if (__ret) \ 64 kprintf("WARNING %s failed at %s:%d\n", \ 65 _WARN_STR(condition), __FILE__, __LINE__); \ 66 unlikely(__ret); \ 67 }) 68 69 #define WARN_ON_ONCE(condition) ({ \ 70 static int __warned; \ 71 int __ret = !!(condition); \ 72 if (__ret && !__warned) { \ 73 kprintf("WARNING %s failed at %s:%d\n", \ 74 _WARN_STR(condition), __FILE__, __LINE__); \ 75 __warned = 1; \ 76 } \ 77 unlikely(__ret); \ 78 }) 79 80 #undef ALIGN 81 #define ALIGN(x, y) (((x) + ((y) - 1)) & ~((y) - 1)) 82 #define DIV_ROUND_UP (((x) + ((y) - 1)) / (y)) 83 84 #define printk(X...) kprintf(X) 85 #define pr_debug(fmt, ...) printk(KERN_DEBUG # fmt, ##__VA_ARGS__) 86 87 #ifndef pr_fmt 88 #define pr_fmt(fmt) fmt 89 #endif 90 91 /* 92 * Print a one-time message (analogous to WARN_ONCE() et al): 93 */ 94 #define printk_once(x...) ({ \ 95 static bool __print_once; \ 96 \ 97 if (!__print_once) { \ 98 __print_once = true; \ 99 printk(x); \ 100 } \ 101 }) 102 103 104 105 #define pr_emerg(fmt, ...) \ 106 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) 107 #define pr_alert(fmt, ...) \ 108 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) 109 #define pr_crit(fmt, ...) \ 110 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) 111 #define pr_err(fmt, ...) \ 112 kprintf(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) 113 #define pr_warning(fmt, ...) \ 114 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) 115 #define pr_warn pr_warning 116 #define pr_notice(fmt, ...) \ 117 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) 118 #define pr_info(fmt, ...) \ 119 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) 120 #define pr_cont(fmt, ...) \ 121 printk(KERN_CONT fmt, ##__VA_ARGS__) 122 123 /* pr_devel() should produce zero code unless DEBUG is defined */ 124 #ifdef DEBUG 125 #define pr_devel(fmt, ...) \ 126 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) 127 #else 128 #define pr_devel(fmt, ...) \ 129 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) 130 #endif 131 132 #ifndef WARN 133 #define WARN(condition, format...) ({ \ 134 int __ret_warn_on = !!(condition); \ 135 if (unlikely(__ret_warn_on)) \ 136 pr_warning(format); \ 137 unlikely(__ret_warn_on); \ 138 }) 139 #endif 140 141 #define WARN_ONCE(condition, format...) ({ \ 142 static bool __warned_once; \ 143 \ 144 if ((condition) && !__warned_once) { \ 145 WARN(condition, format); \ 146 __warned_once = true; \ 147 } \ 148 }) 149 150 #define container_of(ptr, type, member) \ 151 ({ \ 152 __typeof(((type *)0)->member) *_p = (ptr); \ 153 (type *)((char *)_p - offsetof(type, member)); \ 154 }) 155 156 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 157 158 #define simple_strtoul strtoul 159 #define simple_strtol strtol 160 161 //#define min(x, y) (x < y ? x : y) 162 //#define max(x, y) (x > y ? x : y) 163 #define min_t(type, _x, _y) (type)(_x) < (type)(_y) ? (type)(_x) : (_y) 164 #define max_t(type, _x, _y) (type)(_x) > (type)(_y) ? (type)(_x) : (_y) 165 166 /* 167 * This looks more complex than it should be. But we need to 168 * get the type for the ~ right in round_down (it needs to be 169 * as wide as the result!), and we want to evaluate the macro 170 * arguments just once each. 171 */ 172 #define __round_mask(x, y) ((__typeof__(x))((y)-1)) 173 #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) 174 #define round_down(x, y) ((x) & ~__round_mask(x, y)) 175 176 #define num_possible_cpus() mp_ncpus 177 178 typedef struct pm_message { 179 int event; 180 } pm_message_t; 181 182 /* Swap values of a and b */ 183 #define swap(a, b) \ 184 ({ \ 185 typeof(a) _swap_tmp = a; \ 186 a = b; \ 187 b = _swap_tmp; \ 188 }) 189 190 #define DIV_ROUND_CLOSEST(x, divisor) (((x) + ((divisor) /2)) / (divisor)) 191 192 193 extern char* kvasprintf(gfp_t gfp, const char* fmt, va_list ap); 194 extern char* kasprintf(gfp_t gfp, const char* fmt, ...); 195 196 197 #endif /* _LINUX_KERNEL_H_ */ -
new file headers/compatibility/linux/linux/kobject.h
diff --git a/headers/compatibility/linux/linux/kobject.h b/headers/compatibility/linux/linux/kobject.h new file mode 100644 index 0000000000..6195a1966b
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef _LINUX_KOBJECT_H_ 30 #define _LINUX_KOBJECT_H_ 31 32 #include <linux/kernel.h> 33 #include <linux/kref.h> 34 #include <linux/list.h> 35 #include <linux/slab.h> 36 37 #include <stdio.h> 38 39 40 struct kobject; 41 42 43 struct kobj_type { 44 void (*release)(struct kobject *kobj); 45 const struct sysfs_ops *sysfs_ops; 46 struct attribute **default_attrs; 47 }; 48 49 extern struct kobj_type kfree_type; 50 51 struct kobject { 52 struct kobject *parent; 53 char *name; 54 struct kref kref; 55 struct kobj_type *ktype; 56 struct list_head entry; 57 }; 58 59 extern struct kobject *mm_kobj; 60 61 static inline void 62 kobject_init(struct kobject *kobj, struct kobj_type *ktype) 63 { 64 65 kref_init(&kobj->kref); 66 INIT_LIST_HEAD(&kobj->entry); 67 kobj->ktype = ktype; 68 } 69 70 static inline void kobject_put(struct kobject *kobj); 71 void kobject_release(struct kref *kref); 72 73 static inline void 74 kobject_put(struct kobject *kobj) 75 { 76 if (kobj) 77 kref_put(&kobj->kref, kobject_release); 78 } 79 80 static inline struct kobject * 81 kobject_get(struct kobject *kobj) 82 { 83 84 if (kobj) 85 kref_get(&kobj->kref); 86 return kobj; 87 } 88 89 static inline int 90 kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list args) 91 { 92 char *old; 93 char *name; 94 95 old = kobj->name; 96 97 if (old && !fmt) 98 return 0; 99 100 name = kzalloc(MAXPATHLEN, GFP_KERNEL); 101 if (!name) 102 return -ENOMEM; 103 vsnprintf(name, MAXPATHLEN, fmt, args); 104 kobj->name = name; 105 kfree(old); 106 for (; *name != '\0'; name++) 107 if (*name == '/') 108 *name = '!'; 109 return (0); 110 } 111 112 int kobject_add(struct kobject *kobj, struct kobject *parent, 113 const char *fmt, ...); 114 115 static inline struct kobject * 116 kobject_create(void) 117 { 118 struct kobject *kobj; 119 120 kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); 121 if (kobj == NULL) 122 return (NULL); 123 kobject_init(kobj, &kfree_type); 124 125 return (kobj); 126 } 127 128 static inline struct kobject * 129 kobject_create_and_add(const char *name, struct kobject *parent) 130 { 131 struct kobject *kobj; 132 133 kobj = kobject_create(); 134 if (kobj == NULL) 135 return (NULL); 136 if (kobject_add(kobj, parent, "%s", name) == 0) 137 return (kobj); 138 kobject_put(kobj); 139 140 return (NULL); 141 } 142 143 144 static inline char * 145 kobject_name(const struct kobject *kobj) 146 { 147 148 return kobj->name; 149 } 150 151 int kobject_set_name(struct kobject *kobj, const char *fmt, ...); 152 int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype, 153 struct kobject *parent, const char *fmt, ...); 154 155 /* sysfs.h calles for 'kobject' which is defined here, 156 * so we need to add the include only after the 'kobject' def. 157 */ 158 #include <linux/sysfs.h> 159 160 struct kobj_attribute { 161 struct attribute attr; 162 ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr, 163 char *buf); 164 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr, 165 const char *buf, size_t count); 166 }; 167 168 #endif /* _LINUX_KOBJECT_H_ */ -
new file headers/compatibility/linux/linux/kref.h
diff --git a/headers/compatibility/linux/linux/kref.h b/headers/compatibility/linux/linux/kref.h new file mode 100644 index 0000000000..45f4c9eae0
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013 François Tigeot 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef _LINUX_KREF_H_ 30 #define _LINUX_KREF_H_ 31 32 #include <linux/atomic.h> 33 34 struct kref { 35 atomic_t count; 36 }; 37 38 static inline void 39 kref_init(struct kref *kref) 40 { 41 kref->count.counter = 1; 42 } 43 44 static inline void 45 kref_get(struct kref *kref) 46 { 47 atomic_add_return(1, &kref->count); 48 } 49 50 static inline int 51 kref_put(struct kref *kref, void (*rel)(struct kref *kref)) 52 { 53 if (atomic_sub(1, &kref->count) <= 0) { 54 rel(kref); 55 return 1; 56 } 57 return 0; 58 } 59 60 static inline int 61 kref_sub(struct kref *kref, unsigned int count, 62 void (*rel)(struct kref *kref)) 63 { 64 if (atomic_sub(1, &kref->count) <= 0) { 65 rel(kref); 66 return 1; 67 } 68 return 0; 69 } 70 71 /* 72 * kref_get_unless_zero: Increment refcount for object unless it is zero. 73 */ 74 static inline int 75 kref_get_unless_zero(struct kref *kref) 76 { 77 return atomic_add_unless(&kref->count, 1, 0); 78 } 79 80 #endif /* _LINUX_KREF_H_ */ -
new file headers/compatibility/linux/linux/list.h
diff --git a/headers/compatibility/linux/linux/list.h b/headers/compatibility/linux/linux/list.h new file mode 100644 index 0000000000..cbd56753f6
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 #ifndef _LINUX_LIST_H_ 29 #define _LINUX_LIST_H_ 30 31 #include <stddef.h> 32 33 34 struct list_head { 35 struct list_head *next; 36 struct list_head *prev; 37 }; 38 39 static inline void 40 INIT_LIST_HEAD(struct list_head *list) 41 { 42 list->next = list->prev = list; 43 } 44 45 #define LIST_HEAD_INIT(list) { &(list), &(list) } 46 47 static inline int 48 list_empty(const struct list_head *head) 49 { 50 51 return (head->next == head); 52 } 53 54 static inline void 55 list_del(struct list_head *entry) 56 { 57 58 entry->next->prev = entry->prev; 59 entry->prev->next = entry->next; 60 } 61 62 static inline void list_replace(struct list_head *old, 63 struct list_head *entry) 64 { 65 entry->next = old->next; 66 entry->next->prev = entry; 67 entry->prev = old->prev; 68 entry->prev->next = entry; 69 } 70 71 static inline void 72 _list_add(struct list_head *entry, struct list_head *prev, 73 struct list_head *next) 74 { 75 76 next->prev = entry; 77 entry->next = next; 78 entry->prev = prev; 79 prev->next = entry; 80 } 81 82 static inline void 83 list_del_init(struct list_head *entry) 84 { 85 86 list_del(entry); 87 INIT_LIST_HEAD(entry); 88 } 89 90 #define list_entry(ptr, type, field) container_of(ptr, type, field) 91 92 #define list_first_entry(ptr, type, member) \ 93 list_entry((ptr)->next, type, member) 94 95 #define list_for_each(p, head) \ 96 for (p = (head)->next; p != (head); p = p->next) 97 98 #define list_for_each_safe(p, n, head) \ 99 for (p = (head)->next, n = p->next; p != (head); p = n, n = p->next) 100 101 #define list_for_each_entry(p, h, field) \ 102 for (p = list_entry((h)->next, typeof(*p), field); &p->field != (h); \ 103 p = list_entry(p->field.next, typeof(*p), field)) 104 105 #define list_for_each_entry_continue_reverse(pos, head, member) \ 106 for (pos = list_entry(pos->member.prev, typeof(*pos), member); \ 107 &pos->member != (head); \ 108 pos = list_entry(pos->member.prev, typeof(*pos), member)) 109 110 #define list_for_each_entry_safe(p, n, h, field) \ 111 for (p = list_entry((h)->next, typeof(*p), field), \ 112 n = list_entry(p->field.next, typeof(*p), field); &p->field != (h);\ 113 p = n, n = list_entry(n->field.next, typeof(*n), field)) 114 115 #define list_for_each_entry_safe_from(pos, n, head, member) \ 116 for (n = list_entry(pos->member.next, typeof(*pos), member); \ 117 &pos->member != (head); \ 118 pos = n, n = list_entry(n->member.next, typeof(*n), member)) 119 120 #define list_for_each_entry_reverse(p, h, field) \ 121 for (p = list_entry((h)->prev, typeof(*p), field); &p->field != (h); \ 122 p = list_entry(p->field.prev, typeof(*p), field)) 123 124 #define list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = p->prev) 125 126 static inline void 127 list_add(struct list_head *entry, struct list_head *head) 128 { 129 130 _list_add(entry, head, head->next); 131 } 132 133 static inline void 134 list_add_tail(struct list_head *entry, struct list_head *head) 135 { 136 137 _list_add(entry, head->prev, head); 138 } 139 140 static inline void 141 list_move(struct list_head *list, struct list_head *head) 142 { 143 144 list_del(list); 145 list_add(list, head); 146 } 147 148 static inline void 149 list_move_tail(struct list_head *entry, struct list_head *head) 150 { 151 152 list_del(entry); 153 list_add_tail(entry, head); 154 } 155 156 static inline void 157 _list_splice(const struct list_head *list, struct list_head *prev, 158 struct list_head *next) 159 { 160 struct list_head *first; 161 struct list_head *last; 162 163 if (list_empty(list)) 164 return; 165 first = list->next; 166 last = list->prev; 167 first->prev = prev; 168 prev->next = first; 169 last->next = next; 170 next->prev = last; 171 } 172 173 static inline void 174 list_splice(const struct list_head *list, struct list_head *head) 175 { 176 177 _list_splice(list, head, head->next); 178 } 179 180 static inline void 181 list_splice_tail(struct list_head *list, struct list_head *head) 182 { 183 184 _list_splice(list, head->prev, head); 185 } 186 187 static inline void 188 list_splice_init(struct list_head *list, struct list_head *head) 189 { 190 191 _list_splice(list, head, head->next); 192 INIT_LIST_HEAD(list); 193 } 194 195 static inline void 196 list_splice_tail_init(struct list_head *list, struct list_head *head) 197 { 198 199 _list_splice(list, head->prev, head); 200 INIT_LIST_HEAD(list); 201 } 202 203 #define LINUX_LIST_HEAD(name) struct list_head name = { &(name), &(name) } 204 205 206 struct hlist_head { 207 struct hlist_node *first; 208 }; 209 210 struct hlist_node { 211 struct hlist_node *next, **pprev; 212 }; 213 214 #define HLIST_HEAD_INIT { } 215 #define HLIST_HEAD(name) struct hlist_head name = HLIST_HEAD_INIT 216 #define INIT_HLIST_HEAD(head) (head)->first = NULL 217 #define INIT_HLIST_NODE(node) \ 218 do { \ 219 (node)->next = NULL; \ 220 (node)->pprev = NULL; \ 221 } while (0) 222 223 static inline int 224 hlist_unhashed(const struct hlist_node *h) 225 { 226 227 return !h->pprev; 228 } 229 230 static inline int 231 hlist_empty(const struct hlist_head *h) 232 { 233 234 return !h->first; 235 } 236 237 static inline void 238 hlist_del(struct hlist_node *n) 239 { 240 241 if (n->next) 242 n->next->pprev = n->pprev; 243 *n->pprev = n->next; 244 } 245 246 static inline void 247 hlist_del_init(struct hlist_node *n) 248 { 249 250 if (hlist_unhashed(n)) 251 return; 252 hlist_del(n); 253 INIT_HLIST_NODE(n); 254 } 255 256 static inline void 257 hlist_add_head(struct hlist_node *n, struct hlist_head *h) 258 { 259 260 n->next = h->first; 261 if (h->first) 262 h->first->pprev = &n->next; 263 h->first = n; 264 n->pprev = &h->first; 265 } 266 267 static inline void 268 hlist_add_before(struct hlist_node *n, struct hlist_node *next) 269 { 270 271 n->pprev = next->pprev; 272 n->next = next; 273 next->pprev = &n->next; 274 *(n->pprev) = n; 275 } 276 277 static inline void 278 hlist_add_after(struct hlist_node *n, struct hlist_node *next) 279 { 280 281 next->next = n->next; 282 n->next = next; 283 next->pprev = &n->next; 284 if (next->next) 285 next->next->pprev = &next->next; 286 } 287 288 static inline void 289 hlist_move_list(struct hlist_head *from, struct hlist_head *to) 290 { 291 292 to->first = from->first; 293 if (to->first) 294 to->first->pprev = &to->first; 295 from->first = NULL; 296 } 297 298 #define hlist_entry(ptr, type, field) container_of(ptr, type, field) 299 300 #define hlist_for_each(p, head) \ 301 for (p = (head)->first; p; p = p->next) 302 303 #define hlist_for_each_safe(p, n, head) \ 304 for (p = (head)->first; p && ({ n = p->next; 1; }); p = n) 305 306 #define hlist_for_each_entry(tp, p, head, field) \ 307 for (p = (head)->first; \ 308 p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next) 309 310 #define hlist_for_each_entry_continue(tp, p, field) \ 311 for (p = (p)->next; \ 312 p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next) 313 314 #define hlist_for_each_entry_from(tp, p, field) \ 315 for (; p ? (tp = hlist_entry(p, typeof(*tp), field)): NULL; p = p->next) 316 317 #define hlist_for_each_entry_safe(tp, p, n, head, field) \ 318 for (p = (head)->first; p ? \ 319 (n = p->next) | (tp = hlist_entry(p, typeof(*tp), field)) : \ 320 NULL; p = n) 321 322 void drm_list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv, 323 struct list_head *a, struct list_head *b)); 324 325 #define hlist_for_each_entry_rcu(tp, p, head, field) \ 326 hlist_for_each_entry(tp, p, head, field) 327 328 #define hlist_add_after_rcu(prev, n) hlist_add_after(prev, n) 329 330 #define hlist_add_head_rcu(n, h) hlist_add_head(n, h) 331 332 #define hlist_del_init_rcu(n) hlist_del_init(n) 333 334 #endif /* _LINUX_LIST_H_ */ -
new file headers/compatibility/linux/linux/log2.h
diff --git a/headers/compatibility/linux/linux/log2.h b/headers/compatibility/linux/linux/log2.h new file mode 100644 index 0000000000..108b0e79bc
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #ifndef _LINUX_LOG2_H_ 31 #define _LINUX_LOG2_H_ 32 33 #include <linux/bitops.h> 34 #include <linux/types.h> 35 36 static inline unsigned long 37 roundup_pow_of_two(unsigned long x) 38 { 39 if (x == 0) 40 return 1; 41 if (x == 1) 42 return 1; 43 return 1UL << (__flsl(x - 1) + 1); 44 } 45 46 static inline int 47 is_power_of_2(unsigned long n) 48 { 49 return n == roundup_pow_of_two(n); 50 } 51 52 static inline unsigned long 53 rounddown_pow_of_two(unsigned long x) 54 { 55 if (x == 1) 56 return 1; 57 return 1UL << __flsl(x); 58 } 59 60 61 /* 62 * deal with unrepresentable constant logarithms 63 */ 64 extern __attribute__((const, noreturn)) 65 int ____ilog2_NaN(void); 66 67 /* 68 * non-constant log of base 2 calculators 69 * - the arch may override these in asm/bitops.h if they can be implemented 70 * more efficiently than using fls() and fls64() 71 * - the arch is not required to handle n==0 if implementing the fallback 72 */ 73 #ifndef CONFIG_ARCH_HAS_ILOG2_U32 74 static inline __attribute__((const)) 75 int __ilog2_u32(u32 n) 76 { 77 return __flsl(n); 78 } 79 #endif 80 81 #ifndef CONFIG_ARCH_HAS_ILOG2_U64 82 static inline __attribute__((const)) 83 int __ilog2_u64(u64 n) 84 { 85 return __flsl(n); 86 } 87 #endif 88 89 90 /** 91 * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value 92 * @n - parameter 93 * 94 * constant-capable log of base 2 calculation 95 * - this can be used to initialise global variables from constant data, hence 96 * the massive ternary operator construction 97 * 98 * selects the appropriately-sized optimised version depending on sizeof(n) 99 */ 100 #define ilog2(n) \ 101 ( \ 102 __builtin_constant_p(n) ? ( \ 103 (n) < 1 ? ____ilog2_NaN() : \ 104 (n) & (1ULL << 63) ? 63 : \ 105 (n) & (1ULL << 62) ? 62 : \ 106 (n) & (1ULL << 61) ? 61 : \ 107 (n) & (1ULL << 60) ? 60 : \ 108 (n) & (1ULL << 59) ? 59 : \ 109 (n) & (1ULL << 58) ? 58 : \ 110 (n) & (1ULL << 57) ? 57 : \ 111 (n) & (1ULL << 56) ? 56 : \ 112 (n) & (1ULL << 55) ? 55 : \ 113 (n) & (1ULL << 54) ? 54 : \ 114 (n) & (1ULL << 53) ? 53 : \ 115 (n) & (1ULL << 52) ? 52 : \ 116 (n) & (1ULL << 51) ? 51 : \ 117 (n) & (1ULL << 50) ? 50 : \ 118 (n) & (1ULL << 49) ? 49 : \ 119 (n) & (1ULL << 48) ? 48 : \ 120 (n) & (1ULL << 47) ? 47 : \ 121 (n) & (1ULL << 46) ? 46 : \ 122 (n) & (1ULL << 45) ? 45 : \ 123 (n) & (1ULL << 44) ? 44 : \ 124 (n) & (1ULL << 43) ? 43 : \ 125 (n) & (1ULL << 42) ? 42 : \ 126 (n) & (1ULL << 41) ? 41 : \ 127 (n) & (1ULL << 40) ? 40 : \ 128 (n) & (1ULL << 39) ? 39 : \ 129 (n) & (1ULL << 38) ? 38 : \ 130 (n) & (1ULL << 37) ? 37 : \ 131 (n) & (1ULL << 36) ? 36 : \ 132 (n) & (1ULL << 35) ? 35 : \ 133 (n) & (1ULL << 34) ? 34 : \ 134 (n) & (1ULL << 33) ? 33 : \ 135 (n) & (1ULL << 32) ? 32 : \ 136 (n) & (1ULL << 31) ? 31 : \ 137 (n) & (1ULL << 30) ? 30 : \ 138 (n) & (1ULL << 29) ? 29 : \ 139 (n) & (1ULL << 28) ? 28 : \ 140 (n) & (1ULL << 27) ? 27 : \ 141 (n) & (1ULL << 26) ? 26 : \ 142 (n) & (1ULL << 25) ? 25 : \ 143 (n) & (1ULL << 24) ? 24 : \ 144 (n) & (1ULL << 23) ? 23 : \ 145 (n) & (1ULL << 22) ? 22 : \ 146 (n) & (1ULL << 21) ? 21 : \ 147 (n) & (1ULL << 20) ? 20 : \ 148 (n) & (1ULL << 19) ? 19 : \ 149 (n) & (1ULL << 18) ? 18 : \ 150 (n) & (1ULL << 17) ? 17 : \ 151 (n) & (1ULL << 16) ? 16 : \ 152 (n) & (1ULL << 15) ? 15 : \ 153 (n) & (1ULL << 14) ? 14 : \ 154 (n) & (1ULL << 13) ? 13 : \ 155 (n) & (1ULL << 12) ? 12 : \ 156 (n) & (1ULL << 11) ? 11 : \ 157 (n) & (1ULL << 10) ? 10 : \ 158 (n) & (1ULL << 9) ? 9 : \ 159 (n) & (1ULL << 8) ? 8 : \ 160 (n) & (1ULL << 7) ? 7 : \ 161 (n) & (1ULL << 6) ? 6 : \ 162 (n) & (1ULL << 5) ? 5 : \ 163 (n) & (1ULL << 4) ? 4 : \ 164 (n) & (1ULL << 3) ? 3 : \ 165 (n) & (1ULL << 2) ? 2 : \ 166 (n) & (1ULL << 1) ? 1 : \ 167 (n) & (1ULL << 0) ? 0 : \ 168 ____ilog2_NaN() \ 169 ) : \ 170 (sizeof(n) <= 4) ? \ 171 __ilog2_u32(n) : \ 172 __ilog2_u64(n) \ 173 ) 174 175 #endif /* _LINUX_LOG2_H_ */ -
new file headers/compatibility/linux/linux/math64.h
diff --git a/headers/compatibility/linux/linux/math64.h b/headers/compatibility/linux/linux/math64.h new file mode 100644 index 0000000000..94650ca4a9
- + 1 /*- 2 * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved. 3 * Copyright (c) 2014 Mellanox Technologies, Ltd. All rights reserved. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice unmodified, this list of conditions, and the following 11 * disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef _LINUX_MATH64_H 29 #define _LINUX_MATH64_H 30 31 #include <linux/types.h> 32 #include <linux/bitops.h> 33 34 #if BITS_PER_LONG == 64 35 36 # define do_div(n, base) ({ \ 37 uint32_t __base = (base); \ 38 uint32_t __rem; \ 39 __rem = ((uint64_t)(n)) % __base; \ 40 (n) = ((uint64_t)(n)) / __base; \ 41 __rem; \ 42 }) 43 44 /** 45 * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder 46 * 47 * This is commonly provided by 32bit archs to provide an optimized 64bit 48 * divide. 49 */ 50 static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) 51 { 52 *remainder = dividend % divisor; 53 return dividend / divisor; 54 } 55 56 57 #elif BITS_PER_LONG == 32 58 59 static uint32_t __div64_32(uint64_t *n, uint32_t base) 60 { 61 uint64_t rem = *n; 62 uint64_t b = base; 63 uint64_t res, d = 1; 64 uint32_t high = rem >> 32; 65 66 /* Reduce the thing a bit first */ 67 res = 0; 68 if (high >= base) { 69 high /= base; 70 res = (uint64_t) high << 32; 71 rem -= (uint64_t) (high*base) << 32; 72 } 73 74 while ((int64_t)b > 0 && b < rem) { 75 b = b+b; 76 d = d+d; 77 } 78 79 do { 80 if (rem >= b) { 81 rem -= b; 82 res += d; 83 } 84 b >>= 1; 85 d >>= 1; 86 } while (d); 87 88 *n = res; 89 return rem; 90 } 91 92 # define do_div(n, base) ({ \ 93 uint32_t __base = (base); \ 94 uint32_t __rem; \ 95 (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \ 96 if (likely(((n) >> 32) == 0)) { \ 97 __rem = (uint32_t)(n) % __base; \ 98 (n) = (uint32_t)(n) / __base; \ 99 } else \ 100 __rem = __div64_32(&(n), __base); \ 101 __rem; \ 102 }) 103 104 #ifndef div_u64_rem 105 static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) 106 { 107 *remainder = do_div(dividend, divisor); 108 return dividend; 109 } 110 #endif 111 112 #endif /* BITS_PER_LONG */ 113 114 115 116 /** 117 ** div_u64 - unsigned 64bit divide with 32bit divisor 118 ** 119 ** This is the most common 64bit divide and should be used if possible, 120 ** as many 32bit archs can optimize this variant better than a full 64bit 121 ** divide. 122 * */ 123 #ifndef div_u64 124 125 static inline u64 div_u64(u64 dividend, u32 divisor) 126 { 127 u32 remainder; 128 return div_u64_rem(dividend, divisor, &remainder); 129 } 130 #endif 131 132 #endif /* _LINUX_MATH64_H */ -
new file headers/compatibility/linux/linux/miscdevice.h
diff --git a/headers/compatibility/linux/linux/miscdevice.h b/headers/compatibility/linux/linux/miscdevice.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/linux/mm.h
diff --git a/headers/compatibility/linux/linux/mm.h b/headers/compatibility/linux/linux/mm.h new file mode 100644 index 0000000000..907a7c6d33
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef _LINUX_MM_H_ 30 #define _LINUX_MM_H_ 31 32 #include <linux/errno.h> 33 #include <linux/kernel.h> 34 35 #define PAGE_ALIGN(addr) round_page(addr) 36 37 struct vm_area_struct { 38 uintptr_t vm_start; 39 uintptr_t vm_end; 40 uintptr_t vm_pgoff; 41 phys_addr_t vm_pfn; /* PFN For mmap. */ 42 uintptr_t vm_page_prot; 43 }; 44 45 /* 46 * Compute log2 of the power of two rounded up count of pages 47 * needed for size bytes. 48 */ 49 static inline int 50 get_order(unsigned long size) 51 { 52 int order; 53 54 size = (size - 1) >> PAGE_SHIFT; 55 order = 0; 56 while (size) { 57 order++; 58 size >>= 1; 59 } 60 return (order); 61 } 62 63 /* 64 * This only works via mmap ops. 65 */ 66 #if 0 67 static inline int 68 io_remap_pfn_range(struct vm_area_struct *vma, 69 unsigned long addr, unsigned long pfn, unsigned long size, 70 vm_memattr_t prot) 71 { 72 vma->vm_page_prot = prot; 73 vma->vm_pfn = pfn; 74 75 return (0); 76 } 77 #endif 78 79 #endif /* _LINUX_MM_H_ */ -
new file headers/compatibility/linux/linux/module.h
diff --git a/headers/compatibility/linux/linux/module.h b/headers/compatibility/linux/linux/module.h new file mode 100644 index 0000000000..536257cda0
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef _LINUX_MODULE_H_ 30 #define _LINUX_MODULE_H_ 31 32 #include <linux/list.h> 33 #include <linux/compiler.h> 34 #include <linux/moduleparam.h> 35 36 #define MODULE_AUTHOR(name) 37 #define MODULE_DESCRIPTION(name) 38 #define MODULE_LICENSE(name) 39 40 #ifndef MODULE_VERSION 41 #define MODULE_VERSION(name) 42 #endif 43 44 #define THIS_MODULE ((struct module *)0) 45 46 #define EXPORT_SYMBOL(name) 47 #define EXPORT_SYMBOL_GPL(name) 48 49 #endif /* _LINUX_MODULE_H_ */ -
new file headers/compatibility/linux/linux/moduleparam.h
diff --git a/headers/compatibility/linux/linux/moduleparam.h b/headers/compatibility/linux/linux/moduleparam.h new file mode 100644 index 0000000000..e87c79ee13
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #ifndef _LINUX_MODULEPARAM_H_ 31 #define _LINUX_MODULEPARAM_H_ 32 33 #include <linux/types.h> 34 35 /* 36 * These are presently not hooked up to anything. In linux the parameters 37 * can be set when modules are loaded. On FreeBSD these could be mapped 38 * to kenv in the future. 39 */ 40 struct kernel_param; 41 42 typedef int (*param_set_fn)(const char *val, struct kernel_param *kp); 43 typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp); 44 45 struct kernel_param { 46 const char *name; 47 u16 perm; 48 u16 flags; 49 param_set_fn set; 50 param_get_fn get; 51 union { 52 void *arg; 53 struct kparam_string *str; 54 struct kparam_array *arr; 55 } un; 56 }; 57 58 #define KPARAM_ISBOOL 2 59 60 struct kparam_string { 61 unsigned int maxlen; 62 char *string; 63 }; 64 65 struct kparam_array 66 { 67 unsigned int max; 68 unsigned int *num; 69 param_set_fn set; 70 param_get_fn get; 71 unsigned int elemsize; 72 void *elem; 73 }; 74 75 static inline void 76 param_sysinit(struct kernel_param *param) 77 { 78 } 79 80 #define module_param_call(name, set, get, arg, perm) \ 81 static struct kernel_param __param_##name = \ 82 { #name, perm, 0, set, get, { arg } }; \ 83 SYSINIT(name##_param_sysinit, SI_SUB_DRIVERS, SI_ORDER_FIRST, \ 84 param_sysinit, &__param_##name); 85 86 #define module_param_string(name, string, len, perm) 87 88 #define module_param_named(name, var, type, mode) \ 89 module_param_call(name, param_set_##type, param_get_##type, &var, mode) 90 91 #define module_param(var, type, mode) \ 92 module_param_named(var, var, type, mode) 93 94 #define module_param_array(var, type, addr_argc, mode) \ 95 module_param_named(var, var, type, mode) 96 97 #define MODULE_PARM_DESC(name, desc) 98 99 static inline int 100 param_set_byte(const char *val, struct kernel_param *kp) 101 { 102 103 return 0; 104 } 105 106 static inline int 107 param_get_byte(char *buffer, struct kernel_param *kp) 108 { 109 110 return 0; 111 } 112 113 114 static inline int 115 param_set_short(const char *val, struct kernel_param *kp) 116 { 117 118 return 0; 119 } 120 121 static inline int 122 param_get_short(char *buffer, struct kernel_param *kp) 123 { 124 125 return 0; 126 } 127 128 129 static inline int 130 param_set_ushort(const char *val, struct kernel_param *kp) 131 { 132 133 return 0; 134 } 135 136 static inline int 137 param_get_ushort(char *buffer, struct kernel_param *kp) 138 { 139 140 return 0; 141 } 142 143 144 static inline int 145 param_set_int(const char *val, struct kernel_param *kp) 146 { 147 148 return 0; 149 } 150 151 static inline int 152 param_get_int(char *buffer, struct kernel_param *kp) 153 { 154 155 return 0; 156 } 157 158 159 static inline int 160 param_set_uint(const char *val, struct kernel_param *kp) 161 { 162 163 return 0; 164 } 165 166 static inline int 167 param_get_uint(char *buffer, struct kernel_param *kp) 168 { 169 170 return 0; 171 } 172 173 174 static inline int 175 param_set_long(const char *val, struct kernel_param *kp) 176 { 177 178 return 0; 179 } 180 181 static inline int 182 param_get_long(char *buffer, struct kernel_param *kp) 183 { 184 185 return 0; 186 } 187 188 189 static inline int 190 param_set_ulong(const char *val, struct kernel_param *kp) 191 { 192 193 return 0; 194 } 195 196 static inline int 197 param_get_ulong(char *buffer, struct kernel_param *kp) 198 { 199 200 return 0; 201 } 202 203 204 static inline int 205 param_set_charp(const char *val, struct kernel_param *kp) 206 { 207 208 return 0; 209 } 210 211 static inline int 212 param_get_charp(char *buffer, struct kernel_param *kp) 213 { 214 215 return 0; 216 } 217 218 219 static inline int 220 param_set_bool(const char *val, struct kernel_param *kp) 221 { 222 223 return 0; 224 } 225 226 static inline int 227 param_get_bool(char *buffer, struct kernel_param *kp) 228 { 229 230 return 0; 231 } 232 233 #endif /* _LINUX_MODULEPARAM_H_ */ -
new file headers/compatibility/linux/linux/mutex.h
diff --git a/headers/compatibility/linux/linux/mutex.h b/headers/compatibility/linux/linux/mutex.h new file mode 100644 index 0000000000..f74668d56d
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef _LINUX_MUTEX_H_ 30 #define _LINUX_MUTEX_H_ 31 32 #include <lock.h> 33 34 typedef struct linux_mutex { 35 mutex lock; 36 } mutex_t; 37 38 #define mutex_lock(_m) mutex_lock(&(_m)->lock) 39 #define mutex_lock_nested(_m, _s) mutex_lock(_m) 40 #define mutex_lock_interruptible(_m) ({ mutex_lock((_m)); 0; }) 41 #define mutex_unlock(_m) mutex_unlock(&(_m)->sx) 42 #define mutex_trylock(_m) (mutex_trylock(&(_m)->sx) == B_OK) 43 44 #define DEFINE_MUTEX(lock) \ 45 mutex_t lock; \ 46 mutex_init(&(lock)->lock, "linux mutex"); 47 48 49 static inline void 50 linux_mutex_init(mutex_t *m) 51 { 52 mutex_init(&m->lock, "linux mutex"); 53 } 54 55 #define mutex_init linux_mutex_init 56 #define mutex linux_mutex 57 58 #endif /* _LINUX_MUTEX_H_ */ -
new file headers/compatibility/linux/linux/pci.h
diff --git a/headers/compatibility/linux/linux/pci.h b/headers/compatibility/linux/linux/pci.h new file mode 100644 index 0000000000..49c2d2d0ef
- + 1 /* 2 * Copyright (c) 2014 François Tigeot 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef LINUX_PCI_H 28 #define LINUX_PCI_H 29 30 31 #include <bus/PCI.h> 32 33 #include <linux/device.h> 34 #include <linux/io.h> 35 36 #include <linux/pci_ids.h> 37 38 39 #define PCI_ANY_ID (~0u) 40 41 struct pci_driver; 42 43 struct pci_dev { 44 uint16 vendor; 45 uint16 device; 46 uint16 subvendor; 47 uint16 subdevice; 48 uint32 class; 49 50 // Private 51 struct pci_device* dev; 52 struct pci_device_module_info* module; 53 struct pci_device_id* matching_id; 54 struct pci_driver* driver; 55 struct device_node* node; 56 }; 57 58 59 struct pci_device_id { 60 uint16 vendor; 61 uint16 device; 62 uint16 subvendor; 63 uint16 subdevice; 64 uint32 class; 65 uint32 class_mask; 66 }; 67 68 #define PCI_DEVICE(vend, dev) \ 69 .vendor = (vend), \ 70 .device = (dev), \ 71 .subvendor = PCI_ANY_ID, \ 72 .subdevice = PCI_ANY_ID 73 74 #define PCI_DEVICE_SUB(vend, dev, subv, subd) \ 75 .vendor = (vend), \ 76 .device = (dev), \ 77 .subvendor = (subv), \ 78 .subdevice = (subd) 79 80 #define PCI_DEVICE_CLASS(cls, mask) \ 81 .vendor = PCI_ANY_ID, \ 82 .device = PCI_ANY_ID, \ 83 .subvendor = PCI_ANY_ID, \ 84 .device = PCI_ANY_ID, \ 85 .class = (cls), \ 86 .class_mask = (mask) 87 88 89 #define DEFINE_PCI_DEVICE_TABLE(table) \ 90 const struct pci_device_id table[] 91 92 93 struct pci_driver { 94 struct list_head list; 95 96 const char* name; 97 const struct pci_device_id* id_table; 98 int (*probe)(struct pci_dev* dev, const struct pci_device_id* id); 99 int (*remove)(struct pci_dev* dev, const struct pci_device_id* id); 100 101 /* Unused by DRM: 102 * int (*suspend)(struct pci_dev* dev, pm_message_t state); 103 * int (*suspend_late)(struct pci_dev* dev, pm_message_t state); 104 * int (*resume_early)(struct pci_dev* dev); 105 * int (*resume)(struct pci_dev* dev); 106 * void (*shutdown)(struct pci_dev* dev); 107 */ 108 109 struct device_driver driver; 110 }; 111 112 113 extern int pci_register_driver(struct pci_driver* driver); 114 115 116 #define to_pci_driver(driver) container_of(driver, struct pci_driver, driver) 117 118 119 static inline int 120 pci_read_config_byte(struct pci_dev *pdev, int where, u8 *val) 121 { 122 *val = (u16)pdev->module->read_pci_config(pdev->dev, where, 1); 123 return 0; 124 } 125 126 static inline int 127 pci_read_config_word(struct pci_dev *pdev, int where, u16 *val) 128 { 129 *val = (u16)pdev->module->read_pci_config(pdev->dev, where, 2); 130 return 0; 131 } 132 133 static inline int 134 pci_read_config_dword(struct pci_dev *pdev, int where, u32 *val) 135 { 136 *val = (u32)pdev->module->read_pci_config(pdev->dev, where, 4); 137 return 0; 138 } 139 140 static inline int 141 pci_write_config_byte(struct pci_dev *pdev, int where, u8 val) 142 { 143 pdev->module->write_pci_config(pdev->dev, where, val, 1); 144 return 0; 145 } 146 147 static inline int 148 pci_write_config_word(struct pci_dev *pdev, int where, u16 val) 149 { 150 pdev->module->write_pci_config(pdev->dev, where, val, 2); 151 return 0; 152 } 153 154 static inline int 155 pci_write_config_dword(struct pci_dev *pdev, int where, u32 val) 156 { 157 pdev->module->write_pci_config(pdev->dev, where, val, 4); 158 return 0; 159 } 160 161 162 static inline struct pci_dev * 163 pci_dev_get(struct pci_dev *dev) 164 { 165 /* Linux increments a reference count here */ 166 return dev; 167 } 168 169 static inline struct pci_dev * 170 pci_dev_put(struct pci_dev *dev) 171 { 172 /* Linux decrements a reference count here */ 173 return dev; 174 } 175 176 177 static inline int 178 pci_set_dma_mask(struct pci_dev *dev, u64 mask) 179 { 180 return -EIO; 181 } 182 183 static inline int 184 pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) 185 { 186 return -EIO; 187 } 188 189 #endif /* LINUX_PCI_H */ -
new file headers/compatibility/linux/linux/pci_ids.h
diff --git a/headers/compatibility/linux/linux/pci_ids.h b/headers/compatibility/linux/linux/pci_ids.h new file mode 100644 index 0000000000..b8487a4298
- + 1 /* 2 * Copyright (c) 2014 François Tigeot 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef LINUX_PCI_IDS_H 28 #define LINUX_PCI_IDS_H 29 30 #define PCI_BASE_CLASS_DISPLAY 0x03 31 32 #define PCI_VENDOR_ID_ATI 0x1002 33 34 #define PCI_VENDOR_ID_IBM 0x1014 35 36 #define PCI_VENDOR_ID_DELL 0x1028 37 38 #define PCI_VENDOR_ID_HP 0x103c 39 40 #define PCI_VENDOR_ID_ASUSTEK 0x1043 41 42 #define PCI_VENDOR_ID_SONY 0x104d 43 44 #define PCI_VENDOR_ID_APPLE 0x106b 45 46 #define PCI_VENDOR_ID_NVIDIA 0x10de 47 48 #define PCI_VENDOR_ID_VIA 0x1106 49 50 #define PCI_VENDOR_ID_SERVERWORKS 0x1166 51 52 #define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2 53 54 #define PCI_VENDOR_ID_INTEL 0x8086 55 56 #endif /* LINUX_PCI_IDS_H */ -
new file headers/compatibility/linux/linux/platform_device.h
diff --git a/headers/compatibility/linux/linux/platform_device.h b/headers/compatibility/linux/linux/platform_device.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/linux/poll.h
diff --git a/headers/compatibility/linux/linux/poll.h b/headers/compatibility/linux/linux/poll.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/linux/ratelimit.h
diff --git a/headers/compatibility/linux/linux/ratelimit.h b/headers/compatibility/linux/linux/ratelimit.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/linux/rbtree.h
diff --git a/headers/compatibility/linux/linux/rbtree.h b/headers/compatibility/linux/linux/rbtree.h new file mode 100644 index 0000000000..1592f7f9fa
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _LINUX_RBTREE_H 6 #define _LINUX_RBTREE_H 7 8 9 #define RB_NONE 0 10 #define RB_RED 1 11 #define RB_BLACK 2 12 13 14 struct rb_node { 15 int colour; 16 struct rb_node* parent; 17 struct rb_node* rb_left; 18 struct rb_node* rb_right; 19 }; 20 21 #define rb_parent(r) ((struct rb_node*)((r)->parent)) 22 #define rb_color(r) ((struct rb_node*)((r)->colour)) 23 24 #define rb_is_red(r) (rb_color(r) == RB_RED) 25 #define rb_is_black(r) (rb_color(r) == RB_BLACK) 26 27 #define rb_set_parent(r, p) (rb_parent(r) = (p)) 28 #define rb_set_color(r, c) (rb_color(r) = (c)) 29 30 #define rb_entry(ptr, type, member) container_of(ptr, type, member) 31 32 33 #endif -
new file headers/compatibility/linux/linux/sched.h
diff --git a/headers/compatibility/linux/linux/sched.h b/headers/compatibility/linux/linux/sched.h new file mode 100644 index 0000000000..56c1d3d9b9
- + 1 /* 2 * Copyright (c) 2015 Hamish Morrison 3 * Copyright (c) 2015 François Tigeot 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice unmodified, this list of conditions, and the following 11 * disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef _LINUX_SCHED_H_ 29 #define _LINUX_SCHED_H_ 30 31 32 #define TASK_RUNNING ~0UL 33 #define TASK_UNINTERRUPTIBLE 0 34 #define TASK_INTERRUPTIBLE B_CAN_INTERRUPT 35 #define TASK_KILLABLE B_KILL_CAN_INTERRUPT 36 37 #define MAX_SCHEDULE_TIMEOUT B_INFINITE_TIMEOUT 38 39 /* 40 * schedule_timeout - sleep until timeout 41 * @timeout: timeout value in jiffies 42 */ 43 extern long schedule_timeout(long timeout); 44 45 extern void schedule(); 46 47 48 #endif /* _LINUX_SCHED_H_ */ -
new file headers/compatibility/linux/linux/slab.h
diff --git a/headers/compatibility/linux/linux/slab.h b/headers/compatibility/linux/linux/slab.h new file mode 100644 index 0000000000..d87ea79f0f
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * Copyright (c) 2015 Hamish Morrison 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice unmodified, this list of conditions, and the following 14 * disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 #ifndef _LINUX_SLAB_H_ 31 #define _LINUX_SLAB_H_ 32 33 #include <heap.h> 34 #include <slab/Slab.h> 35 36 #include <linux/types.h> 37 #include <linux/gfp.h> 38 39 40 41 static inline void* kmalloc(size_t size, uint32 flags) 42 { 43 void* addr = malloc_etc(size, flags); 44 if (addr != NULL && (flags & __GFP_ZERO) != 0) 45 memset(addr, 0, size); 46 47 return addr; 48 } 49 50 51 #define PAGE_KERNEL 0x0001 52 53 54 #define kvmalloc(size) kmalloc((size), 0) 55 #define kzalloc(size, flags) kmalloc((size), (flags) | __GFP_ZERO) 56 #define kzalloc_node(size, flags, node) kzalloc(size, flags) 57 #define kfree(ptr) free((ptr)) 58 #define krealloc(ptr, size, flags) realloc((ptr), (size)) 59 #define kcalloc(n, size, flags) kmalloc((n) * (size), (flags) | __GFP_ZERO) 60 #define vzalloc(size) kzalloc((size), GFP_KERNEL) 61 #define vfree(arg) kfree((arg)) 62 #define kvfree(arg) kfree((arg)) 63 #define vmalloc(size) kmalloc((size), GFP_KERNEL) 64 #define vmalloc_node(size, node) kmalloc((size), GFP_KERNEL) 65 66 // XXX 67 #define __vmalloc(size, flags, prot) kmalloc((size), (flags)) 68 #define is_vmalloc_addr(ptr) (true) 69 70 71 struct kmem_cache { 72 object_cache* cache; 73 }; 74 75 76 #define SLAB_HWCACHE_ALIGN 0x0001 77 78 79 static inline status_t 80 kmem_ctor(void* cookie, void* object) 81 { 82 void (*ctor)(void *) = cookie; 83 ctor(object); 84 return 0; 85 } 86 87 88 static inline struct kmem_cache * 89 kmem_cache_create(char *name, size_t size, size_t align, u_long flags, 90 void (*ctor)(void *)) 91 { 92 struct kmem_cache *c = (struct kmem_cache*)malloc(sizeof(struct kmem_cache)); 93 94 c->cache = create_object_cache(name, size, align, 95 ctor != NULL ? (void*)kmem_ctor : NULL, kmem_ctor, NULL); 96 return c; 97 } 98 99 static inline void * 100 kmem_cache_alloc(struct kmem_cache *c, int flags) 101 { 102 return object_cache_alloc(c->cache, flags); 103 } 104 105 static inline void 106 kmem_cache_free(struct kmem_cache *c, void *m) 107 { 108 object_cache_free(c->cache, m, 0); 109 } 110 111 static inline void 112 kmem_cache_destroy(struct kmem_cache *c) 113 { 114 delete_object_cache(c->cache); 115 free(c); 116 } 117 118 #endif /* _LINUX_SLAB_H_ */ -
new file headers/compatibility/linux/linux/sysfs.h
diff --git a/headers/compatibility/linux/linux/sysfs.h b/headers/compatibility/linux/linux/sysfs.h new file mode 100644 index 0000000000..5d80ece562
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #ifndef _LINUX_SYSFS_H_ 31 #define _LINUX_SYSFS_H_ 32 33 34 struct attribute { 35 const char* name; 36 struct module* owner; 37 mode_t mode; 38 }; 39 40 struct sysfs_ops { 41 ssize_t (*show)(struct kobject*, struct attribute*, char*); 42 ssize_t (*store)(struct kobject*, struct attribute*, const char*, 43 size_t); 44 }; 45 46 struct attribute_group { 47 const char* name; 48 mode_t (*is_visible)(struct kobject*, struct attribute*, int); 49 struct attribute** attrs; 50 }; 51 52 53 #define __ATTR(_name, _mode, _show, _store) { \ 54 .attr = { .name = __stringify(_name), .mode = _mode }, \ 55 .show = _show, .store = _store, \ 56 } 57 58 #define __ATTR_RO(_name) { \ 59 .attr = { .name = __stringify(_name), .mode = 0444 }, \ 60 .show = _name##_show, \ 61 } 62 63 #define __ATTR_NULL { .attr = { .name = NULL } } 64 65 66 static inline int 67 sysfs_create_file(struct kobject* kobj, const struct attribute* attr) 68 { 69 return 0; 70 } 71 72 static inline void 73 sysfs_remove_file(struct kobject* kobj, const struct attribute* attr) 74 { 75 } 76 77 static inline void 78 sysfs_remove_group(struct kobject* kobj, const struct attribute_group* grp) 79 { 80 } 81 82 static inline int 83 sysfs_create_group(struct kobject* kobj, const struct attribute_group* grp) 84 { 85 return 0; 86 } 87 88 static inline int 89 sysfs_create_dir(struct kobject* kobj) 90 { 91 return 0; 92 } 93 94 static inline void 95 sysfs_remove_dir(struct kobject* kobj) 96 { 97 } 98 99 #define sysfs_attr_init(attr) do {} while(0) 100 101 102 #endif /* _LINUX_SYSFS_H_ */ -
new file headers/compatibility/linux/linux/time.h
diff --git a/headers/compatibility/linux/linux/time.h b/headers/compatibility/linux/linux/time.h new file mode 100644 index 0000000000..5b3affd5c3
- + 1 /* 2 * Copyright (c) 2014 François Tigeot 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef _LINUX_TIME_H_ 28 #define _LINUX_TIME_H_ 29 30 #define NSEC_PER_USEC 1000L 31 #define NSEC_PER_SEC 1000000000L 32 33 #include <sys/time.h> 34 35 36 static inline struct timeval 37 ns_to_timeval(const int64_t nsec) 38 { 39 struct timeval tv; 40 long rem; 41 42 if (nsec == 0) { 43 tv.tv_sec = 0; 44 tv.tv_usec = 0; 45 return (tv); 46 } 47 48 tv.tv_sec = nsec / NSEC_PER_SEC; 49 rem = nsec % NSEC_PER_SEC; 50 if (rem < 0) { 51 tv.tv_sec--; 52 rem += NSEC_PER_SEC; 53 } 54 tv.tv_usec = rem / 1000; 55 return (tv); 56 } 57 58 static inline int64_t 59 timeval_to_ns(const struct timeval *tv) 60 { 61 return ((int64_t)tv->tv_sec * NSEC_PER_SEC) + 62 tv->tv_usec * NSEC_PER_USEC; 63 } 64 65 static inline void 66 set_normalized_timespec(struct timespec *ts, time_t sec, int64_t nsec) 67 { 68 if (nsec >= NSEC_PER_SEC) { 69 sec += nsec / NSEC_PER_SEC; 70 nsec %= NSEC_PER_SEC; 71 } 72 73 if (nsec < 0) { 74 sec += nsec / NSEC_PER_SEC; 75 nsec = (nsec % NSEC_PER_SEC) + NSEC_PER_SEC; 76 } 77 78 ts->tv_sec = sec; 79 ts->tv_nsec = nsec; 80 } 81 82 static inline struct timespec 83 timespec_sub(struct timespec lhs, struct timespec rhs) 84 { 85 struct timespec ts; 86 set_normalized_timespec(&ts, lhs.tv_sec - rhs.tv_sec, 87 lhs.tv_nsec - rhs.tv_nsec); 88 return ts; 89 } 90 91 static inline int64_t 92 timespec_to_ns(const struct timespec *ts) 93 { 94 return ((ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec); 95 } 96 97 static inline struct timespec 98 ns_to_timespec(const int64_t nsec) 99 { 100 struct timespec ts; 101 int32_t rem; 102 103 if (nsec == 0) { 104 ts.tv_sec = 0; 105 ts.tv_nsec = 0; 106 return (ts); 107 } 108 109 ts.tv_sec = nsec / NSEC_PER_SEC; 110 rem = nsec % NSEC_PER_SEC; 111 if (rem < 0) { 112 ts.tv_sec--; 113 rem += NSEC_PER_SEC; 114 } 115 ts.tv_nsec = rem; 116 return (ts); 117 } 118 119 static inline int 120 timespec_valid(const struct timespec *ts) 121 { 122 if (ts->tv_sec < 0 || ts->tv_sec > 100000000 || 123 ts->tv_nsec < 0 || ts->tv_nsec >= 1000000000) 124 return (0); 125 return (1); 126 } 127 128 static inline void 129 getrawmonotonic(struct timespec *ts) 130 { 131 uint32_t rem; 132 bigtime_t nsec = system_time_nsecs(); 133 134 ts->tv_sec = nsec / NSEC_PER_SEC; 135 rem = nsec % NSEC_PER_SEC; 136 if (rem < 0) { 137 ts->tv_sec--; 138 rem += NSEC_PER_SEC; 139 } 140 ts->tv_nsec = rem; 141 } 142 143 #endif /* _LINUX_TIME_H_ */ -
new file headers/compatibility/linux/linux/types.h
diff --git a/headers/compatibility/linux/linux/types.h b/headers/compatibility/linux/linux/types.h new file mode 100644 index 0000000000..a4270080f2
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice unmodified, this list of conditions, and the following 12 * disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 #ifndef _LINUX_TYPES_H_ 29 #define _LINUX_TYPES_H_ 30 31 #include <SupportDefs.h> 32 #include <linux/compiler.h> 33 #include <asm/types.h> 34 35 36 typedef uint16 __le16; 37 typedef uint16 __be16; 38 typedef uint32 __le32; 39 typedef uint32 __be32; 40 typedef uint64 __le64; 41 typedef uint64 __be64; 42 #if !defined(__bool_true_false_are_defined) && !defined(__cplusplus) 43 typedef _Bool bool; 44 #define true TRUE 45 #define false FALSE 46 #endif 47 48 typedef unsigned long kernel_ulong_t; 49 typedef unsigned gfp_t; 50 typedef uint64_t loff_t; 51 typedef phys_addr_t resource_size_t; 52 53 #define DECLARE_BITMAP(n, bits) \ 54 unsigned long n[howmany(bits, sizeof(long) * 8)] 55 56 #endif /* _LINUX_TYPES_H_ */ -
new file headers/compatibility/linux/linux/uaccess.h
diff --git a/headers/compatibility/linux/linux/uaccess.h b/headers/compatibility/linux/linux/uaccess.h new file mode 100644 index 0000000000..ab6e844349
- + 1 /* 2 * Copyright (c) 2015 François Tigeot 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice unmodified, this list of conditions, and the following 10 * disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef _LINUX_UACCESS_H_ 28 #define _LINUX_UACCESS_H_ 29 30 static inline void pagefault_disable(void) 31 { 32 atomic_set_int(&curthread->td_flags, TDF_NOFAULT); 33 } 34 35 static inline void pagefault_enable(void) 36 { 37 atomic_clear_int(&curthread->td_flags, TDF_NOFAULT); 38 } 39 40 #endif /* _LINUX_UACCESS_H_ */ -
new file headers/compatibility/linux/linux/vmalloc.h
diff --git a/headers/compatibility/linux/linux/vmalloc.h b/headers/compatibility/linux/linux/vmalloc.h new file mode 100644 index 0000000000..2849931f78
- + 1 /* 2 * Copyright 2015, Hamish Morrison, hamishm53@gmail.com. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef _H 6 #define _H 7 8 9 #endif -
new file headers/compatibility/linux/linux/workqueue.h
diff --git a/headers/compatibility/linux/linux/workqueue.h b/headers/compatibility/linux/linux/workqueue.h new file mode 100644 index 0000000000..415c882803
- + 1 /*- 2 * Copyright (c) 2010 Isilon Systems, Inc. 3 * Copyright (c) 2010 iX Systems, Inc. 4 * Copyright (c) 2010 Panasas, Inc. 5 * Copyright (c) 2015 Hamish Morrison 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice unmodified, this list of conditions, and the following 13 * disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef _LINUX_WORKQUEUE_H_ 30 #define _LINUX_WORKQUEUE_H_ 31 32 #include <linux/list.h> 33 #include <linux/types.h> 34 #include <linux/kernel.h> 35 36 #include <KernelExport.h> 37 38 39 extern int32 smp_get_num_cpus(void); 40 41 42 struct workqueue_struct; 43 struct work_struct; 44 45 typedef void (*work_func_t)(struct work_struct* work); 46 47 struct work_struct { 48 struct workqueue_struct* queue; 49 struct list_head list; 50 bool linked; 51 work_func_t fn; 52 long data; 53 }; 54 55 struct delayed_work { 56 struct work_struct work; 57 struct timer event; 58 }; 59 60 61 62 #define INIT_WORK(work, func) \ 63 do { \ 64 (work)->fn = (func); \ 65 (work)->queue = NULL; \ 66 INIT_LIST_HEAD(&(work)->list); \ 67 } while (0) 68 69 #define INIT_DELAYED_WORK INIT_WORK 70 #define INIT_DEFERRABLE_WORK INIT_DELAYED_WORK 71 72 73 /* TODO!! 74 #define schedule_work(work) \ 75 do { \ 76 (work)->taskqueue = taskqueue_thread[mycpuid]; \ 77 taskqueue_enqueue(taskqueue_thread[mycpuid], &(work)->work_task); \ 78 } while (0) 79 80 #define flush_scheduled_work() flush_taskqueue(taskqueue_thread[mycpuid]) 81 82 static inline bool schedule_delayed_work(struct delayed_work *dwork, 83 unsigned long delay) 84 { 85 struct workqueue_struct wq; 86 wq.taskqueue = taskqueue_thread[mycpuid]; 87 return queue_delayed_work(&wq, dwork, delay); 88 } 89 */ 90 91 92 extern bool queue_work(struct workqueue_struct *wq, struct work_struct *work); 93 94 extern bool queue_delayed_work(struct workqueue_struct *wq, 95 struct delayed_work *work, unsigned long delay); 96 97 extern struct workqueue_struct * _workqueue_create(const char* name, 98 int threads); 99 100 static inline struct workqueue_struct * 101 create_singlethread_workqueue(const char *name) { 102 return _workqueue_create(name, 1); 103 } 104 105 static inline struct workqueue_struct * 106 create_workqueue(const char *name) { 107 return _workqueue_create(name, smp_get_num_cpus()); 108 } 109 110 extern void destroy_workqueue(struct workqueue_struct *wq); 111 extern void flush_workqueue(struct workqueue_struct *wq); 112 113 extern bool cancel_work_sync(struct work_struct *work); 114 extern bool cancel_delayed_work(struct delayed_work *work); 115 extern bool cancel_delayed_work_sync(struct delayed_work *work); 116 117 #endif /* _LINUX_WORKQUEUE_H_ */ -
new file headers/private/graphics/drm/drm/drmP.h
diff --git a/headers/private/graphics/drm/drm/drmP.h b/headers/private/graphics/drm/drm/drmP.h new file mode 100644 index 0000000000..6105c050d7
- + 1 /* 2 * Internal Header for the Direct Rendering Manager 3 * 4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 6 * Copyright (c) 2009-2010, Code Aurora Forum. 7 * All rights reserved. 8 * 9 * Author: Rickard E. (Rik) Faith <faith@valinux.com> 10 * Author: Gareth Hughes <gareth@valinux.com> 11 * 12 * Permission is hereby granted, free of charge, to any person obtaining a 13 * copy of this software and associated documentation files (the "Software"), 14 * to deal in the Software without restriction, including without limitation 15 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 16 * and/or sell copies of the Software, and to permit persons to whom the 17 * Software is furnished to do so, subject to the following conditions: 18 * 19 * The above copyright notice and this permission notice (including the next 20 * paragraph) shall be included in all copies or substantial portions of the 21 * Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 27 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 28 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 29 * OTHER DEALINGS IN THE SOFTWARE. 30 */ 31 32 #ifndef _DRM_P_H_ 33 #define _DRM_P_H_ 34 35 #include <linux/agp_backend.h> 36 #include <linux/cdev.h> 37 #include <linux/dma-mapping.h> 38 #include <linux/file.h> 39 #include <linux/fs.h> 40 #include <linux/highmem.h> 41 #include <linux/idr.h> 42 #include <linux/init.h> 43 #include <linux/io.h> 44 #include <linux/jiffies.h> 45 #include <linux/kernel.h> 46 #include <linux/kref.h> 47 #include <linux/miscdevice.h> 48 #include <linux/mm.h> 49 #include <linux/mutex.h> 50 #include <linux/pci.h> 51 #include <linux/platform_device.h> 52 #include <linux/poll.h> 53 #include <linux/ratelimit.h> 54 #include <linux/rbtree.h> 55 #include <linux/sched.h> 56 #include <linux/slab.h> 57 #include <linux/types.h> 58 #include <linux/vmalloc.h> 59 #include <linux/workqueue.h> 60 #include <linux/dma-fence.h> 61 62 #include <asm/mman.h> 63 #include <asm/pgalloc.h> 64 #include <linux/uaccess.h> 65 66 #include <uapi/drm/drm.h> 67 #include <uapi/drm/drm_mode.h> 68 69 #include <drm/drm_agpsupport.h> 70 #include <drm/drm_crtc.h> 71 #include <drm/drm_fourcc.h> 72 #include <drm/drm_global.h> 73 #include <drm/drm_hashtab.h> 74 #include <drm/drm_mem_util.h> 75 #include <drm/drm_mm.h> 76 #include <drm/drm_os_linux.h> 77 #include <drm/drm_sarea.h> 78 #include <drm/drm_vma_manager.h> 79 #include <drm/drm_drv.h> 80 81 struct module; 82 83 struct drm_file; 84 struct drm_device; 85 struct drm_agp_head; 86 struct drm_local_map; 87 struct drm_device_dma; 88 struct drm_dma_handle; 89 struct drm_gem_object; 90 struct drm_master; 91 struct drm_vblank_crtc; 92 93 struct device_node; 94 struct videomode; 95 struct reservation_object; 96 struct dma_buf_attachment; 97 98 /* 99 * The following categories are defined: 100 * 101 * CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, drm_memory.c, ... 102 * This is the category used by the DRM_DEBUG() macro. 103 * 104 * DRIVER: Used in the vendor specific part of the driver: i915, radeon, ... 105 * This is the category used by the DRM_DEBUG_DRIVER() macro. 106 * 107 * KMS: used in the modesetting code. 108 * This is the category used by the DRM_DEBUG_KMS() macro. 109 * 110 * PRIME: used in the prime code. 111 * This is the category used by the DRM_DEBUG_PRIME() macro. 112 * 113 * ATOMIC: used in the atomic code. 114 * This is the category used by the DRM_DEBUG_ATOMIC() macro. 115 * 116 * VBL: used for verbose debug message in the vblank code 117 * This is the category used by the DRM_DEBUG_VBL() macro. 118 * 119 * Enabling verbose debug messages is done through the drm.debug parameter, 120 * each category being enabled by a bit. 121 * 122 * drm.debug=0x1 will enable CORE messages 123 * drm.debug=0x2 will enable DRIVER messages 124 * drm.debug=0x3 will enable CORE and DRIVER messages 125 * ... 126 * drm.debug=0x3f will enable all messages 127 * 128 * An interesting feature is that it's possible to enable verbose logging at 129 * run-time by echoing the debug value in its sysfs node: 130 * # echo 0xf > /sys/module/drm/parameters/debug 131 */ 132 #define DRM_UT_NONE 0x00 133 #define DRM_UT_CORE 0x01 134 #define DRM_UT_DRIVER 0x02 135 #define DRM_UT_KMS 0x04 136 #define DRM_UT_PRIME 0x08 137 #define DRM_UT_ATOMIC 0x10 138 #define DRM_UT_VBL 0x20 139 #define DRM_UT_STATE 0x40 140 141 /***********************************************************************/ 142 /** \name DRM template customization defaults */ 143 /*@{*/ 144 145 /***********************************************************************/ 146 /** \name Macros to make printk easier */ 147 /*@{*/ 148 149 #define _DRM_PRINTK(once, level, fmt, ...) \ 150 do { \ 151 printk##once(KERN_##level "[" DRM_NAME "] " fmt, \ 152 ##__VA_ARGS__); \ 153 } while (0) 154 155 #define DRM_INFO(fmt, ...) \ 156 _DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__) 157 #define DRM_NOTE(fmt, ...) \ 158 _DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__) 159 #define DRM_WARN(fmt, ...) \ 160 _DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__) 161 162 #define DRM_INFO_ONCE(fmt, ...) \ 163 _DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__) 164 #define DRM_NOTE_ONCE(fmt, ...) \ 165 _DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__) 166 #define DRM_WARN_ONCE(fmt, ...) \ 167 _DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__) 168 169 /** 170 * Error output. 171 * 172 * \param fmt printf() like format string. 173 * \param arg arguments 174 */ 175 #define DRM_DEV_ERROR(dev, fmt, ...) \ 176 drm_dev_printk(dev, KERN_ERR, DRM_UT_NONE, __func__, " *ERROR*",\ 177 fmt, ##__VA_ARGS__) 178 #define DRM_ERROR(fmt, ...) \ 179 drm_printk(KERN_ERR, DRM_UT_NONE, fmt, ##__VA_ARGS__) 180 181 /** 182 * Rate limited error output. Like DRM_ERROR() but won't flood the log. 183 * 184 * \param fmt printf() like format string. 185 * \param arg arguments 186 */ 187 #define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...) \ 188 ({ \ 189 static DEFINE_RATELIMIT_STATE(_rs, \ 190 DEFAULT_RATELIMIT_INTERVAL, \ 191 DEFAULT_RATELIMIT_BURST); \ 192 \ 193 if (__ratelimit(&_rs)) \ 194 DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__); \ 195 }) 196 #define DRM_ERROR_RATELIMITED(fmt, ...) \ 197 DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) 198 199 #define DRM_DEV_INFO(dev, fmt, ...) \ 200 drm_dev_printk(dev, KERN_INFO, DRM_UT_NONE, __func__, "", fmt, \ 201 ##__VA_ARGS__) 202 203 #define DRM_DEV_INFO_ONCE(dev, fmt, ...) \ 204 ({ \ 205 static bool __print_once __read_mostly; \ 206 if (!__print_once) { \ 207 __print_once = true; \ 208 DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \ 209 } \ 210 }) 211 212 /** 213 * Debug output. 214 * 215 * \param fmt printf() like format string. 216 * \param arg arguments 217 */ 218 #define DRM_DEV_DEBUG(dev, fmt, args...) \ 219 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_CORE, __func__, "", fmt, \ 220 ##args) 221 #define DRM_DEBUG(fmt, ...) \ 222 drm_printk(KERN_DEBUG, DRM_UT_CORE, fmt, ##__VA_ARGS__) 223 224 #define DRM_DEV_DEBUG_DRIVER(dev, fmt, args...) \ 225 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_DRIVER, __func__, "", \ 226 fmt, ##args) 227 #define DRM_DEBUG_DRIVER(fmt, ...) \ 228 drm_printk(KERN_DEBUG, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) 229 230 #define DRM_DEV_DEBUG_KMS(dev, fmt, args...) \ 231 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_KMS, __func__, "", fmt, \ 232 ##args) 233 #define DRM_DEBUG_KMS(fmt, ...) \ 234 drm_printk(KERN_DEBUG, DRM_UT_KMS, fmt, ##__VA_ARGS__) 235 236 #define DRM_DEV_DEBUG_PRIME(dev, fmt, args...) \ 237 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_PRIME, __func__, "", \ 238 fmt, ##args) 239 #define DRM_DEBUG_PRIME(fmt, ...) \ 240 drm_printk(KERN_DEBUG, DRM_UT_PRIME, fmt, ##__VA_ARGS__) 241 242 #define DRM_DEV_DEBUG_ATOMIC(dev, fmt, args...) \ 243 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ATOMIC, __func__, "", \ 244 fmt, ##args) 245 #define DRM_DEBUG_ATOMIC(fmt, ...) \ 246 drm_printk(KERN_DEBUG, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) 247 248 #define DRM_DEV_DEBUG_VBL(dev, fmt, args...) \ 249 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_VBL, __func__, "", fmt, \ 250 ##args) 251 #define DRM_DEBUG_VBL(fmt, ...) \ 252 drm_printk(KERN_DEBUG, DRM_UT_VBL, fmt, ##__VA_ARGS__) 253 254 #define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, level, fmt, args...) \ 255 ({ \ 256 static DEFINE_RATELIMIT_STATE(_rs, \ 257 DEFAULT_RATELIMIT_INTERVAL, \ 258 DEFAULT_RATELIMIT_BURST); \ 259 if (__ratelimit(&_rs)) \ 260 drm_dev_printk(dev, KERN_DEBUG, DRM_UT_ ## level, \ 261 __func__, "", fmt, ##args); \ 262 }) 263 264 /** 265 * Rate limited debug output. Like DRM_DEBUG() but won't flood the log. 266 * 267 * \param fmt printf() like format string. 268 * \param arg arguments 269 */ 270 #define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, args...) \ 271 DEV__DRM_DEFINE_DEBUG_RATELIMITED(dev, CORE, fmt, ##args) 272 #define DRM_DEBUG_RATELIMITED(fmt, args...) \ 273 DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##args) 274 #define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, args...) \ 275 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRIVER, fmt, ##args) 276 #define DRM_DEBUG_DRIVER_RATELIMITED(fmt, args...) \ 277 DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##args) 278 #define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, args...) \ 279 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, KMS, fmt, ##args) 280 #define DRM_DEBUG_KMS_RATELIMITED(fmt, args...) \ 281 DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##args) 282 #define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, args...) \ 283 _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, PRIME, fmt, ##args) 284 #define DRM_DEBUG_PRIME_RATELIMITED(fmt, args...) \ 285 DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##args) 286 287 /* Format strings and argument splitters to simplify printing 288 * various "complex" objects 289 */ 290 #define DRM_MODE_FMT "%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x" 291 #define DRM_MODE_ARG(m) \ 292 (m)->base.id, (m)->name, (m)->vrefresh, (m)->clock, \ 293 (m)->hdisplay, (m)->hsync_start, (m)->hsync_end, (m)->htotal, \ 294 (m)->vdisplay, (m)->vsync_start, (m)->vsync_end, (m)->vtotal, \ 295 (m)->type, (m)->flags 296 297 #define DRM_RECT_FMT "%dx%d%+d%+d" 298 #define DRM_RECT_ARG(r) drm_rect_width(r), drm_rect_height(r), (r)->x1, (r)->y1 299 300 /* for rect's in fixed-point format: */ 301 #define DRM_RECT_FP_FMT "%d.%06ux%d.%06u%+d.%06u%+d.%06u" 302 #define DRM_RECT_FP_ARG(r) \ 303 drm_rect_width(r) >> 16, ((drm_rect_width(r) & 0xffff) * 15625) >> 10, \ 304 drm_rect_height(r) >> 16, ((drm_rect_height(r) & 0xffff) * 15625) >> 10, \ 305 (r)->x1 >> 16, (((r)->x1 & 0xffff) * 15625) >> 10, \ 306 (r)->y1 >> 16, (((r)->y1 & 0xffff) * 15625) >> 10 307 308 /*@}*/ 309 310 /***********************************************************************/ 311 /** \name Internal types and structures */ 312 /*@{*/ 313 314 #define DRM_IF_VERSION(maj, min) (maj << 16 | min) 315 316 /** 317 * Ioctl function type. 318 * 319 * \param inode device inode. 320 * \param file_priv DRM file private pointer. 321 * \param cmd command. 322 * \param arg argument. 323 */ 324 typedef int drm_ioctl_t(struct drm_device *dev, void *data, 325 struct drm_file *file_priv); 326 327 typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd, 328 unsigned long arg); 329 330 #define DRM_IOCTL_NR(n) _IOC_NR(n) 331 #define DRM_MAJOR 226 332 333 #define DRM_AUTH 0x1 334 #define DRM_MASTER 0x2 335 #define DRM_ROOT_ONLY 0x4 336 #define DRM_CONTROL_ALLOW 0x8 337 #define DRM_UNLOCKED 0x10 338 #define DRM_RENDER_ALLOW 0x20 339 340 struct drm_ioctl_desc { 341 unsigned int cmd; 342 int flags; 343 drm_ioctl_t *func; 344 const char *name; 345 }; 346 347 /** 348 * Creates a driver or general drm_ioctl_desc array entry for the given 349 * ioctl, for use by drm_ioctl(). 350 */ 351 352 #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \ 353 [DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \ 354 .cmd = DRM_IOCTL_##ioctl, \ 355 .func = _func, \ 356 .flags = _flags, \ 357 .name = #ioctl \ 358 } 359 360 /* Event queued up for userspace to read */ 361 struct drm_pending_event { 362 struct completion *completion; 363 void (*completion_release)(struct completion *completion); 364 struct drm_event *event; 365 struct dma_fence *fence; 366 struct list_head link; 367 struct list_head pending_link; 368 struct drm_file *file_priv; 369 pid_t pid; /* pid of requester, no guarantee it's valid by the time 370 we deliver the event, for tracing only */ 371 }; 372 373 struct drm_prime_file_private { 374 struct mutex lock; 375 struct rb_root dmabufs; 376 struct rb_root handles; 377 }; 378 379 /** File private data */ 380 struct drm_file { 381 unsigned authenticated :1; 382 /* true when the client has asked us to expose stereo 3D mode flags */ 383 unsigned stereo_allowed :1; 384 /* 385 * true if client understands CRTC primary planes and cursor planes 386 * in the plane list 387 */ 388 unsigned universal_planes:1; 389 /* true if client understands atomic properties */ 390 unsigned atomic:1; 391 /* 392 * This client is the creator of @master. 393 * Protected by struct drm_device::master_mutex. 394 */ 395 unsigned is_master:1; 396 397 struct pid *pid; 398 drm_magic_t magic; 399 struct list_head lhead; 400 struct drm_minor *minor; 401 unsigned long lock_count; 402 403 /** Mapping of mm object handles to object pointers. */ 404 struct idr object_idr; 405 /** Lock for synchronization of access to object_idr. */ 406 spinlock_t table_lock; 407 408 struct file *filp; 409 void *driver_priv; 410 411 struct drm_master *master; /* master this node is currently associated with 412 N.B. not always dev->master */ 413 /** 414 * fbs - List of framebuffers associated with this file. 415 * 416 * Protected by fbs_lock. Note that the fbs list holds a reference on 417 * the fb object to prevent it from untimely disappearing. 418 */ 419 struct list_head fbs; 420 struct mutex fbs_lock; 421 422 /** User-created blob properties; this retains a reference on the 423 * property. */ 424 struct list_head blobs; 425 426 wait_queue_head_t event_wait; 427 struct list_head pending_event_list; 428 struct list_head event_list; 429 int event_space; 430 431 struct mutex event_read_lock; 432 433 struct drm_prime_file_private prime; 434 }; 435 436 /** 437 * Lock data. 438 */ 439 struct drm_lock_data { 440 struct drm_hw_lock *hw_lock; /**< Hardware lock */ 441 /** Private of lock holder's file (NULL=kernel) */ 442 struct drm_file *file_priv; 443 wait_queue_head_t lock_queue; /**< Queue of blocked processes */ 444 unsigned long lock_time; /**< Time of last lock in jiffies */ 445 spinlock_t spinlock; 446 uint32_t kernel_waiters; 447 uint32_t user_waiters; 448 int idle_has_lock; 449 }; 450 451 /* Flags and return codes for get_vblank_timestamp() driver function. */ 452 #define DRM_CALLED_FROM_VBLIRQ 1 453 #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0) 454 #define DRM_VBLANKTIME_IN_VBLANK (1 << 1) 455 456 /* get_scanout_position() return flags */ 457 #define DRM_SCANOUTPOS_VALID (1 << 0) 458 #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1) 459 #define DRM_SCANOUTPOS_ACCURATE (1 << 2) 460 461 enum drm_minor_type { 462 DRM_MINOR_PRIMARY, 463 DRM_MINOR_CONTROL, 464 DRM_MINOR_RENDER, 465 DRM_MINOR_CNT, 466 }; 467 468 /** 469 * Info file list entry. This structure represents a debugfs or proc file to 470 * be created by the drm core 471 */ 472 struct drm_info_list { 473 const char *name; /** file name */ 474 int (*show)(struct seq_file*, void*); /** show callback */ 475 u32 driver_features; /**< Required driver features for this entry */ 476 void *data; 477 }; 478 479 /** 480 * debugfs node structure. This structure represents a debugfs file. 481 */ 482 struct drm_info_node { 483 struct list_head list; 484 struct drm_minor *minor; 485 const struct drm_info_list *info_ent; 486 struct dentry *dent; 487 }; 488 489 /** 490 * DRM minor structure. This structure represents a drm minor number. 491 */ 492 struct drm_minor { 493 int index; /**< Minor device number */ 494 int type; /**< Control or render */ 495 struct device *kdev; /**< Linux device */ 496 struct drm_device *dev; 497 498 struct dentry *debugfs_root; 499 500 struct list_head debugfs_list; 501 struct mutex debugfs_lock; /* Protects debugfs_list. */ 502 }; 503 504 /** 505 * DRM device structure. This structure represent a complete card that 506 * may contain multiple heads. 507 */ 508 struct drm_device { 509 struct list_head legacy_dev_list;/**< list of devices per driver for stealth attach cleanup */ 510 int if_version; /**< Highest interface version set */ 511 512 /** \name Lifetime Management */ 513 /*@{ */ 514 struct kref ref; /**< Object ref-count */ 515 struct device *dev; /**< Device structure of bus-device */ 516 struct drm_driver *driver; /**< DRM driver managing the device */ 517 void *dev_private; /**< DRM driver private data */ 518 struct drm_minor *control; /**< Control node */ 519 struct drm_minor *primary; /**< Primary node */ 520 struct drm_minor *render; /**< Render node */ 521 bool registered; 522 523 /* currently active master for this device. Protected by master_mutex */ 524 struct drm_master *master; 525 526 atomic_t unplugged; /**< Flag whether dev is dead */ 527 struct inode *anon_inode; /**< inode for private address-space */ 528 char *unique; /**< unique name of the device */ 529 /*@} */ 530 531 /** \name Locks */ 532 /*@{ */ 533 struct mutex struct_mutex; /**< For others */ 534 struct mutex master_mutex; /**< For drm_minor::master and drm_file::is_master */ 535 /*@} */ 536 537 /** \name Usage Counters */ 538 /*@{ */ 539 int open_count; /**< Outstanding files open, protected by drm_global_mutex. */ 540 spinlock_t buf_lock; /**< For drm_device::buf_use and a few other things. */ 541 int buf_use; /**< Buffers in use -- cannot alloc */ 542 atomic_t buf_alloc; /**< Buffer allocation in progress */ 543 /*@} */ 544 545 struct mutex filelist_mutex; 546 struct list_head filelist; 547 548 /** \name Memory management */ 549 /*@{ */ 550 struct list_head maplist; /**< Linked list of regions */ 551 struct drm_open_hash map_hash; /**< User token hash table for maps */ 552 553 /** \name Context handle management */ 554 /*@{ */ 555 struct list_head ctxlist; /**< Linked list of context handles */ 556 struct mutex ctxlist_mutex; /**< For ctxlist */ 557 558 struct idr ctx_idr; 559 560 struct list_head vmalist; /**< List of vmas (for debugging) */ 561 562 /*@} */ 563 564 /** \name DMA support */ 565 /*@{ */ 566 struct drm_device_dma *dma; /**< Optional pointer for DMA support */ 567 /*@} */ 568 569 /** \name Context support */ 570 /*@{ */ 571 572 __volatile__ long context_flag; /**< Context swapping flag */ 573 int last_context; /**< Last current context */ 574 /*@} */ 575 576 /** \name VBLANK IRQ support */ 577 /*@{ */ 578 bool irq_enabled; 579 int irq; 580 581 /* 582 * If true, vblank interrupt will be disabled immediately when the 583 * refcount drops to zero, as opposed to via the vblank disable 584 * timer. 585 * This can be set to true it the hardware has a working vblank 586 * counter and the driver uses drm_vblank_on() and drm_vblank_off() 587 * appropriately. 588 */ 589 bool vblank_disable_immediate; 590 591 /* array of size num_crtcs */ 592 struct drm_vblank_crtc *vblank; 593 594 spinlock_t vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */ 595 spinlock_t vbl_lock; 596 597 u32 max_vblank_count; /**< size of vblank counter register */ 598 599 /** 600 * List of events 601 */ 602 struct list_head vblank_event_list; 603 spinlock_t event_lock; 604 605 /*@} */ 606 607 struct drm_agp_head *agp; /**< AGP data */ 608 609 struct pci_dev *pdev; /**< PCI device structure */ 610 #ifdef __alpha__ 611 struct pci_controller *hose; 612 #endif 613 614 struct platform_device *platformdev; /**< Platform device struture */ 615 struct virtio_device *virtdev; 616 617 struct drm_sg_mem *sg; /**< Scatter gather memory */ 618 unsigned int num_crtcs; /**< Number of CRTCs on this device */ 619 620 struct { 621 int context; 622 struct drm_hw_lock *lock; 623 } sigdata; 624 625 struct drm_local_map *agp_buffer_map; 626 unsigned int agp_buffer_token; 627 628 struct drm_mode_config mode_config; /**< Current mode config */ 629 630 /** \name GEM information */ 631 /*@{ */ 632 struct mutex object_name_lock; 633 struct idr object_name_idr; 634 struct drm_vma_offset_manager *vma_offset_manager; 635 /*@} */ 636 int switch_power_state; 637 }; 638 639 /** 640 * drm_drv_uses_atomic_modeset - check if the driver implements 641 * atomic_commit() 642 * @dev: DRM device 643 * 644 * This check is useful if drivers do not have DRIVER_ATOMIC set but 645 * have atomic modesetting internally implemented. 646 */ 647 static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev) 648 { 649 return dev->mode_config.funcs->atomic_commit != NULL; 650 } 651 652 #include <drm/drm_irq.h> 653 654 #define DRM_SWITCH_POWER_ON 0 655 #define DRM_SWITCH_POWER_OFF 1 656 #define DRM_SWITCH_POWER_CHANGING 2 657 #define DRM_SWITCH_POWER_DYNAMIC_OFF 3 658 659 static __inline__ int drm_core_check_feature(struct drm_device *dev, 660 int feature) 661 { 662 return ((dev->driver->driver_features & feature) ? 1 : 0); 663 } 664 665 static inline void drm_device_set_unplugged(struct drm_device *dev) 666 { 667 smp_wmb(); 668 atomic_set(&dev->unplugged, 1); 669 } 670 671 static inline int drm_device_is_unplugged(struct drm_device *dev) 672 { 673 int ret = atomic_read(&dev->unplugged); 674 smp_rmb(); 675 return ret; 676 } 677 678 static inline bool drm_is_render_client(const struct drm_file *file_priv) 679 { 680 return file_priv->minor->type == DRM_MINOR_RENDER; 681 } 682 683 static inline bool drm_is_control_client(const struct drm_file *file_priv) 684 { 685 return file_priv->minor->type == DRM_MINOR_CONTROL; 686 } 687 688 static inline bool drm_is_primary_client(const struct drm_file *file_priv) 689 { 690 return file_priv->minor->type == DRM_MINOR_PRIMARY; 691 } 692 693 /******************************************************************/ 694 /** \name Internal function definitions */ 695 /*@{*/ 696 697 /* Driver support (drm_drv.h) */ 698 extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv); 699 extern long drm_ioctl(struct file *filp, 700 unsigned int cmd, unsigned long arg); 701 #ifdef CONFIG_COMPAT 702 extern long drm_compat_ioctl(struct file *filp, 703 unsigned int cmd, unsigned long arg); 704 #else 705 /* Let drm_compat_ioctl be assigned to .compat_ioctl unconditionally */ 706 #define drm_compat_ioctl NULL 707 #endif 708 extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags); 709 710 /* File Operations (drm_fops.c) */ 711 int drm_open(struct inode *inode, struct file *filp); 712 ssize_t drm_read(struct file *filp, char __user *buffer, 713 size_t count, loff_t *offset); 714 int drm_release(struct inode *inode, struct file *filp); 715 unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); 716 int drm_event_reserve_init_locked(struct drm_device *dev, 717 struct drm_file *file_priv, 718 struct drm_pending_event *p, 719 struct drm_event *e); 720 int drm_event_reserve_init(struct drm_device *dev, 721 struct drm_file *file_priv, 722 struct drm_pending_event *p, 723 struct drm_event *e); 724 void drm_event_cancel_free(struct drm_device *dev, 725 struct drm_pending_event *p); 726 void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e); 727 void drm_send_event(struct drm_device *dev, struct drm_pending_event *e); 728 729 /* Misc. IOCTL support (drm_ioctl.c) */ 730 int drm_noop(struct drm_device *dev, void *data, 731 struct drm_file *file_priv); 732 int drm_invalid_op(struct drm_device *dev, void *data, 733 struct drm_file *file_priv); 734 735 /* 736 * These are exported to drivers so that they can implement fencing using 737 * DMA quiscent + idle. DMA quiescent usually requires the hardware lock. 738 */ 739 740 /* Debugfs support */ 741 #if defined(CONFIG_DEBUG_FS) 742 extern int drm_debugfs_create_files(const struct drm_info_list *files, 743 int count, struct dentry *root, 744 struct drm_minor *minor); 745 extern int drm_debugfs_remove_files(const struct drm_info_list *files, 746 int count, struct drm_minor *minor); 747 #else 748 static inline int drm_debugfs_create_files(const struct drm_info_list *files, 749 int count, struct dentry *root, 750 struct drm_minor *minor) 751 { 752 return 0; 753 } 754 755 static inline int drm_debugfs_remove_files(const struct drm_info_list *files, 756 int count, struct drm_minor *minor) 757 { 758 return 0; 759 } 760 #endif 761 762 struct dma_buf_export_info; 763 764 extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev, 765 struct drm_gem_object *obj, 766 int flags); 767 extern int drm_gem_prime_handle_to_fd(struct drm_device *dev, 768 struct drm_file *file_priv, uint32_t handle, uint32_t flags, 769 int *prime_fd); 770 extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, 771 struct dma_buf *dma_buf); 772 extern int drm_gem_prime_fd_to_handle(struct drm_device *dev, 773 struct drm_file *file_priv, int prime_fd, uint32_t *handle); 774 struct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev, 775 struct dma_buf_export_info *exp_info); 776 extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf); 777 778 extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, 779 dma_addr_t *addrs, int max_pages); 780 extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages); 781 extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); 782 783 784 extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size, 785 size_t align); 786 extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah); 787 788 /* sysfs support (drm_sysfs.c) */ 789 extern void drm_sysfs_hotplug_event(struct drm_device *dev); 790 791 792 /*@}*/ 793 794 extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); 795 extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); 796 #ifdef CONFIG_PCI 797 extern int drm_get_pci_dev(struct pci_dev *pdev, 798 const struct pci_device_id *ent, 799 struct drm_driver *driver); 800 extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master); 801 #else 802 static inline int drm_get_pci_dev(struct pci_dev *pdev, 803 const struct pci_device_id *ent, 804 struct drm_driver *driver) 805 { 806 return -ENOSYS; 807 } 808 809 static inline int drm_pci_set_busid(struct drm_device *dev, 810 struct drm_master *master) 811 { 812 return -ENOSYS; 813 } 814 #endif 815 816 #define DRM_PCIE_SPEED_25 1 817 #define DRM_PCIE_SPEED_50 2 818 #define DRM_PCIE_SPEED_80 4 819 820 extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask); 821 extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw); 822 823 /* platform section */ 824 extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); 825 826 /* returns true if currently okay to sleep */ 827 static __inline__ bool drm_can_sleep(void) 828 { 829 if (in_atomic() || in_dbg_master() || irqs_disabled()) 830 return false; 831 return true; 832 } 833 834 /* helper for handling conditionals in various for_each macros */ 835 #define for_each_if(condition) if (!(condition)) {} else 836 837 #endif -
new file headers/private/graphics/drm/drm/drm_agpsupport.h
diff --git a/headers/private/graphics/drm/drm/drm_agpsupport.h b/headers/private/graphics/drm/drm/drm_agpsupport.h new file mode 100644 index 0000000000..b2d912670a
- + 1 #ifndef _DRM_AGPSUPPORT_H_ 2 #define _DRM_AGPSUPPORT_H_ 3 4 #include <linux/agp_backend.h> 5 #include <linux/kernel.h> 6 #include <linux/list.h> 7 #include <linux/mm.h> 8 #include <linux/mutex.h> 9 #include <linux/types.h> 10 #include <uapi/drm/drm.h> 11 12 struct drm_device; 13 struct drm_file; 14 15 struct drm_agp_head { 16 struct agp_kern_info agp_info; 17 struct list_head memory; 18 unsigned long mode; 19 struct agp_bridge_data *bridge; 20 int enabled; 21 int acquired; 22 unsigned long base; 23 int agp_mtrr; 24 int cant_use_aperture; 25 unsigned long page_mask; 26 }; 27 28 #if IS_ENABLED(CONFIG_AGP) 29 30 void drm_free_agp(struct agp_memory * handle, int pages); 31 int drm_bind_agp(struct agp_memory * handle, unsigned int start); 32 int drm_unbind_agp(struct agp_memory * handle); 33 struct agp_memory *drm_agp_bind_pages(struct drm_device *dev, 34 struct page **pages, 35 unsigned long num_pages, 36 uint32_t gtt_offset, 37 uint32_t type); 38 39 struct drm_agp_head *drm_agp_init(struct drm_device *dev); 40 void drm_legacy_agp_clear(struct drm_device *dev); 41 int drm_agp_acquire(struct drm_device *dev); 42 int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, 43 struct drm_file *file_priv); 44 int drm_agp_release(struct drm_device *dev); 45 int drm_agp_release_ioctl(struct drm_device *dev, void *data, 46 struct drm_file *file_priv); 47 int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); 48 int drm_agp_enable_ioctl(struct drm_device *dev, void *data, 49 struct drm_file *file_priv); 50 int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info); 51 int drm_agp_info_ioctl(struct drm_device *dev, void *data, 52 struct drm_file *file_priv); 53 int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); 54 int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, 55 struct drm_file *file_priv); 56 int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); 57 int drm_agp_free_ioctl(struct drm_device *dev, void *data, 58 struct drm_file *file_priv); 59 int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); 60 int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, 61 struct drm_file *file_priv); 62 int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); 63 int drm_agp_bind_ioctl(struct drm_device *dev, void *data, 64 struct drm_file *file_priv); 65 66 #else /* CONFIG_AGP */ 67 68 static inline void drm_free_agp(struct agp_memory * handle, int pages) 69 { 70 } 71 72 static inline int drm_bind_agp(struct agp_memory * handle, unsigned int start) 73 { 74 return -ENODEV; 75 } 76 77 static inline int drm_unbind_agp(struct agp_memory * handle) 78 { 79 return -ENODEV; 80 } 81 82 static inline struct agp_memory *drm_agp_bind_pages(struct drm_device *dev, 83 struct page **pages, 84 unsigned long num_pages, 85 uint32_t gtt_offset, 86 uint32_t type) 87 { 88 return NULL; 89 } 90 91 static inline struct drm_agp_head *drm_agp_init(struct drm_device *dev) 92 { 93 return NULL; 94 } 95 96 static inline void drm_legacy_agp_clear(struct drm_device *dev) 97 { 98 } 99 100 static inline int drm_agp_acquire(struct drm_device *dev) 101 { 102 return -ENODEV; 103 } 104 105 static inline int drm_agp_release(struct drm_device *dev) 106 { 107 return -ENODEV; 108 } 109 110 static inline int drm_agp_enable(struct drm_device *dev, 111 struct drm_agp_mode mode) 112 { 113 return -ENODEV; 114 } 115 116 static inline int drm_agp_info(struct drm_device *dev, 117 struct drm_agp_info *info) 118 { 119 return -ENODEV; 120 } 121 122 static inline int drm_agp_alloc(struct drm_device *dev, 123 struct drm_agp_buffer *request) 124 { 125 return -ENODEV; 126 } 127 128 static inline int drm_agp_free(struct drm_device *dev, 129 struct drm_agp_buffer *request) 130 { 131 return -ENODEV; 132 } 133 134 static inline int drm_agp_unbind(struct drm_device *dev, 135 struct drm_agp_binding *request) 136 { 137 return -ENODEV; 138 } 139 140 static inline int drm_agp_bind(struct drm_device *dev, 141 struct drm_agp_binding *request) 142 { 143 return -ENODEV; 144 } 145 146 #endif /* CONFIG_AGP */ 147 148 #endif /* _DRM_AGPSUPPORT_H_ */ -
new file headers/private/graphics/drm/drm/drm_crtc.h
diff --git a/headers/private/graphics/drm/drm/drm_crtc.h b/headers/private/graphics/drm/drm/drm_crtc.h new file mode 100644 index 0000000000..8f0b195e4a
- + 1 /* 2 * Copyright © 2006 Keith Packard 3 * Copyright © 2007-2008 Dave Airlie 4 * Copyright © 2007-2008 Intel Corporation 5 * Jesse Barnes <jesse.barnes@intel.com> 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * and/or sell copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included in 15 * all copies or substantial portions of the 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 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 #ifndef __DRM_CRTC_H__ 26 #define __DRM_CRTC_H__ 27 28 #include <linux/i2c.h> 29 #include <linux/spinlock.h> 30 #include <linux/types.h> 31 #include <linux/fb.h> 32 #include <linux/hdmi.h> 33 #include <linux/media-bus-format.h> 34 #include <uapi/drm/drm_mode.h> 35 #include <uapi/drm/drm_fourcc.h> 36 #include <drm/drm_modeset_lock.h> 37 #include <drm/drm_rect.h> 38 #include <drm/drm_mode_object.h> 39 #include <drm/drm_framebuffer.h> 40 #include <drm/drm_modes.h> 41 #include <drm/drm_connector.h> 42 #include <drm/drm_property.h> 43 #include <drm/drm_bridge.h> 44 #include <drm/drm_edid.h> 45 #include <drm/drm_plane.h> 46 #include <drm/drm_blend.h> 47 #include <drm/drm_color_mgmt.h> 48 #include <drm/drm_debugfs_crc.h> 49 #include <drm/drm_mode_config.h> 50 51 struct drm_device; 52 struct drm_mode_set; 53 struct drm_file; 54 struct drm_clip_rect; 55 struct drm_printer; 56 struct device_node; 57 struct dma_fence; 58 struct edid; 59 60 static inline int64_t U642I64(uint64_t val) 61 { 62 return (int64_t)*((int64_t *)&val); 63 } 64 static inline uint64_t I642U64(int64_t val) 65 { 66 return (uint64_t)*((uint64_t *)&val); 67 } 68 69 struct drm_crtc; 70 struct drm_pending_vblank_event; 71 struct drm_plane; 72 struct drm_bridge; 73 struct drm_atomic_state; 74 75 struct drm_crtc_helper_funcs; 76 struct drm_plane_helper_funcs; 77 78 /** 79 * struct drm_crtc_state - mutable CRTC state 80 * @crtc: backpointer to the CRTC 81 * @enable: whether the CRTC should be enabled, gates all other state 82 * @active: whether the CRTC is actively displaying (used for DPMS) 83 * @planes_changed: planes on this crtc are updated 84 * @mode_changed: @mode or @enable has been changed 85 * @active_changed: @active has been toggled. 86 * @connectors_changed: connectors to this crtc have been updated 87 * @zpos_changed: zpos values of planes on this crtc have been updated 88 * @color_mgmt_changed: color management properties have changed (degamma or 89 * gamma LUT or CSC matrix) 90 * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes 91 * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors 92 * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders 93 * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings 94 * @mode: current mode timings 95 * @mode_blob: &drm_property_blob for @mode 96 * @degamma_lut: Lookup table for converting framebuffer pixel data 97 * before apply the conversion matrix 98 * @ctm: Transformation matrix 99 * @gamma_lut: Lookup table for converting pixel data after the 100 * conversion matrix 101 * @state: backpointer to global drm_atomic_state 102 * 103 * Note that the distinction between @enable and @active is rather subtile: 104 * Flipping @active while @enable is set without changing anything else may 105 * never return in a failure from the &drm_mode_config_funcs.atomic_check 106 * callback. Userspace assumes that a DPMS On will always succeed. In other 107 * words: @enable controls resource assignment, @active controls the actual 108 * hardware state. 109 * 110 * The three booleans active_changed, connectors_changed and mode_changed are 111 * intended to indicate whether a full modeset is needed, rather than strictly 112 * describing what has changed in a commit. 113 * See also: drm_atomic_crtc_needs_modeset() 114 */ 115 struct drm_crtc_state { 116 struct drm_crtc *crtc; 117 118 bool enable; 119 bool active; 120 121 /* computed state bits used by helpers and drivers */ 122 bool planes_changed : 1; 123 bool mode_changed : 1; 124 bool active_changed : 1; 125 bool connectors_changed : 1; 126 bool zpos_changed : 1; 127 bool color_mgmt_changed : 1; 128 129 /* attached planes bitmask: 130 * WARNING: transitional helpers do not maintain plane_mask so 131 * drivers not converted over to atomic helpers should not rely 132 * on plane_mask being accurate! 133 */ 134 u32 plane_mask; 135 136 u32 connector_mask; 137 u32 encoder_mask; 138 139 /* adjusted_mode: for use by helpers and drivers */ 140 struct drm_display_mode adjusted_mode; 141 142 struct drm_display_mode mode; 143 144 /* blob property to expose current mode to atomic userspace */ 145 struct drm_property_blob *mode_blob; 146 147 /* blob property to expose color management to userspace */ 148 struct drm_property_blob *degamma_lut; 149 struct drm_property_blob *ctm; 150 struct drm_property_blob *gamma_lut; 151 152 /** 153 * @target_vblank: 154 * 155 * Target vertical blank period when a page flip 156 * should take effect. 157 */ 158 159 u32 target_vblank; 160 161 /** 162 * @event: 163 * 164 * Optional pointer to a DRM event to signal upon completion of the 165 * state update. The driver must send out the event when the atomic 166 * commit operation completes. There are two cases: 167 * 168 * - The event is for a CRTC which is being disabled through this 169 * atomic commit. In that case the event can be send out any time 170 * after the hardware has stopped scanning out the current 171 * framebuffers. It should contain the timestamp and counter for the 172 * last vblank before the display pipeline was shut off. 173 * 174 * - For a CRTC which is enabled at the end of the commit (even when it 175 * undergoes an full modeset) the vblank timestamp and counter must 176 * be for the vblank right before the first frame that scans out the 177 * new set of buffers. Again the event can only be sent out after the 178 * hardware has stopped scanning out the old buffers. 179 * 180 * - Events for disabled CRTCs are not allowed, and drivers can ignore 181 * that case. 182 * 183 * This can be handled by the drm_crtc_send_vblank_event() function, 184 * which the driver should call on the provided event upon completion of 185 * the atomic commit. Note that if the driver supports vblank signalling 186 * and timestamping the vblank counters and timestamps must agree with 187 * the ones returned from page flip events. With the current vblank 188 * helper infrastructure this can be achieved by holding a vblank 189 * reference while the page flip is pending, acquired through 190 * drm_crtc_vblank_get() and released with drm_crtc_vblank_put(). 191 * Drivers are free to implement their own vblank counter and timestamp 192 * tracking though, e.g. if they have accurate timestamp registers in 193 * hardware. 194 * 195 * For hardware which supports some means to synchronize vblank 196 * interrupt delivery with committing display state there's also 197 * drm_crtc_arm_vblank_event(). See the documentation of that function 198 * for a detailed discussion of the constraints it needs to be used 199 * safely. 200 */ 201 struct drm_pending_vblank_event *event; 202 203 struct drm_atomic_state *state; 204 }; 205 206 /** 207 * struct drm_crtc_funcs - control CRTCs for a given device 208 * 209 * The drm_crtc_funcs structure is the central CRTC management structure 210 * in the DRM. Each CRTC controls one or more connectors (note that the name 211 * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. 212 * connectors, not just CRTs). 213 * 214 * Each driver is responsible for filling out this structure at startup time, 215 * in addition to providing other modesetting features, like i2c and DDC 216 * bus accessors. 217 */ 218 struct drm_crtc_funcs { 219 /** 220 * @reset: 221 * 222 * Reset CRTC hardware and software state to off. This function isn't 223 * called by the core directly, only through drm_mode_config_reset(). 224 * It's not a helper hook only for historical reasons. 225 * 226 * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset 227 * atomic state using this hook. 228 */ 229 void (*reset)(struct drm_crtc *crtc); 230 231 /** 232 * @cursor_set: 233 * 234 * Update the cursor image. The cursor position is relative to the CRTC 235 * and can be partially or fully outside of the visible area. 236 * 237 * Note that contrary to all other KMS functions the legacy cursor entry 238 * points don't take a framebuffer object, but instead take directly a 239 * raw buffer object id from the driver's buffer manager (which is 240 * either GEM or TTM for current drivers). 241 * 242 * This entry point is deprecated, drivers should instead implement 243 * universal plane support and register a proper cursor plane using 244 * drm_crtc_init_with_planes(). 245 * 246 * This callback is optional 247 * 248 * RETURNS: 249 * 250 * 0 on success or a negative error code on failure. 251 */ 252 int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, 253 uint32_t handle, uint32_t width, uint32_t height); 254 255 /** 256 * @cursor_set2: 257 * 258 * Update the cursor image, including hotspot information. The hotspot 259 * must not affect the cursor position in CRTC coordinates, but is only 260 * meant as a hint for virtualized display hardware to coordinate the 261 * guests and hosts cursor position. The cursor hotspot is relative to 262 * the cursor image. Otherwise this works exactly like @cursor_set. 263 * 264 * This entry point is deprecated, drivers should instead implement 265 * universal plane support and register a proper cursor plane using 266 * drm_crtc_init_with_planes(). 267 * 268 * This callback is optional. 269 * 270 * RETURNS: 271 * 272 * 0 on success or a negative error code on failure. 273 */ 274 int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv, 275 uint32_t handle, uint32_t width, uint32_t height, 276 int32_t hot_x, int32_t hot_y); 277 278 /** 279 * @cursor_move: 280 * 281 * Update the cursor position. The cursor does not need to be visible 282 * when this hook is called. 283 * 284 * This entry point is deprecated, drivers should instead implement 285 * universal plane support and register a proper cursor plane using 286 * drm_crtc_init_with_planes(). 287 * 288 * This callback is optional. 289 * 290 * RETURNS: 291 * 292 * 0 on success or a negative error code on failure. 293 */ 294 int (*cursor_move)(struct drm_crtc *crtc, int x, int y); 295 296 /** 297 * @gamma_set: 298 * 299 * Set gamma on the CRTC. 300 * 301 * This callback is optional. 302 * 303 * NOTE: 304 * 305 * Drivers that support gamma tables and also fbdev emulation through 306 * the provided helper library need to take care to fill out the gamma 307 * hooks for both. Currently there's a bit an unfortunate duplication 308 * going on, which should eventually be unified to just one set of 309 * hooks. 310 */ 311 int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, 312 uint32_t size); 313 314 /** 315 * @destroy: 316 * 317 * Clean up plane resources. This is only called at driver unload time 318 * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged 319 * in DRM. 320 */ 321 void (*destroy)(struct drm_crtc *crtc); 322 323 /** 324 * @set_config: 325 * 326 * This is the main legacy entry point to change the modeset state on a 327 * CRTC. All the details of the desired configuration are passed in a 328 * &struct drm_mode_set - see there for details. 329 * 330 * Drivers implementing atomic modeset should use 331 * drm_atomic_helper_set_config() to implement this hook. 332 * 333 * RETURNS: 334 * 335 * 0 on success or a negative error code on failure. 336 */ 337 int (*set_config)(struct drm_mode_set *set); 338 339 /** 340 * @page_flip: 341 * 342 * Legacy entry point to schedule a flip to the given framebuffer. 343 * 344 * Page flipping is a synchronization mechanism that replaces the frame 345 * buffer being scanned out by the CRTC with a new frame buffer during 346 * vertical blanking, avoiding tearing (except when requested otherwise 347 * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application 348 * requests a page flip the DRM core verifies that the new frame buffer 349 * is large enough to be scanned out by the CRTC in the currently 350 * configured mode and then calls this hook with a pointer to the new 351 * frame buffer. 352 * 353 * The driver must wait for any pending rendering to the new framebuffer 354 * to complete before executing the flip. It should also wait for any 355 * pending rendering from other drivers if the underlying buffer is a 356 * shared dma-buf. 357 * 358 * An application can request to be notified when the page flip has 359 * completed. The drm core will supply a &struct drm_event in the event 360 * parameter in this case. This can be handled by the 361 * drm_crtc_send_vblank_event() function, which the driver should call on 362 * the provided event upon completion of the flip. Note that if 363 * the driver supports vblank signalling and timestamping the vblank 364 * counters and timestamps must agree with the ones returned from page 365 * flip events. With the current vblank helper infrastructure this can 366 * be achieved by holding a vblank reference while the page flip is 367 * pending, acquired through drm_crtc_vblank_get() and released with 368 * drm_crtc_vblank_put(). Drivers are free to implement their own vblank 369 * counter and timestamp tracking though, e.g. if they have accurate 370 * timestamp registers in hardware. 371 * 372 * This callback is optional. 373 * 374 * NOTE: 375 * 376 * Very early versions of the KMS ABI mandated that the driver must 377 * block (but not reject) any rendering to the old framebuffer until the 378 * flip operation has completed and the old framebuffer is no longer 379 * visible. This requirement has been lifted, and userspace is instead 380 * expected to request delivery of an event and wait with recycling old 381 * buffers until such has been received. 382 * 383 * RETURNS: 384 * 385 * 0 on success or a negative error code on failure. Note that if a 386 * page flip operation is already pending the callback should return 387 * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode 388 * or just runtime disabled through DPMS respectively the new atomic 389 * "ACTIVE" state) should result in an -EINVAL error code. Note that 390 * drm_atomic_helper_page_flip() checks this already for atomic drivers. 391 */ 392 int (*page_flip)(struct drm_crtc *crtc, 393 struct drm_framebuffer *fb, 394 struct drm_pending_vblank_event *event, 395 uint32_t flags); 396 397 /** 398 * @page_flip_target: 399 * 400 * Same as @page_flip but with an additional parameter specifying the 401 * absolute target vertical blank period (as reported by 402 * drm_crtc_vblank_count()) when the flip should take effect. 403 * 404 * Note that the core code calls drm_crtc_vblank_get before this entry 405 * point, and will call drm_crtc_vblank_put if this entry point returns 406 * any non-0 error code. It's the driver's responsibility to call 407 * drm_crtc_vblank_put after this entry point returns 0, typically when 408 * the flip completes. 409 */ 410 int (*page_flip_target)(struct drm_crtc *crtc, 411 struct drm_framebuffer *fb, 412 struct drm_pending_vblank_event *event, 413 uint32_t flags, uint32_t target); 414 415 /** 416 * @set_property: 417 * 418 * This is the legacy entry point to update a property attached to the 419 * CRTC. 420 * 421 * Drivers implementing atomic modeset should use 422 * drm_atomic_helper_crtc_set_property() to implement this hook. 423 * 424 * This callback is optional if the driver does not support any legacy 425 * driver-private properties. 426 * 427 * RETURNS: 428 * 429 * 0 on success or a negative error code on failure. 430 */ 431 int (*set_property)(struct drm_crtc *crtc, 432 struct drm_property *property, uint64_t val); 433 434 /** 435 * @atomic_duplicate_state: 436 * 437 * Duplicate the current atomic state for this CRTC and return it. 438 * The core and helpers guarantee that any atomic state duplicated with 439 * this hook and still owned by the caller (i.e. not transferred to the 440 * driver by calling &drm_mode_config_funcs.atomic_commit) will be 441 * cleaned up by calling the @atomic_destroy_state hook in this 442 * structure. 443 * 444 * Atomic drivers which don't subclass &struct drm_crtc_state should use 445 * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the 446 * state structure to extend it with driver-private state should use 447 * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is 448 * duplicated in a consistent fashion across drivers. 449 * 450 * It is an error to call this hook before &drm_crtc.state has been 451 * initialized correctly. 452 * 453 * NOTE: 454 * 455 * If the duplicate state references refcounted resources this hook must 456 * acquire a reference for each of them. The driver must release these 457 * references again in @atomic_destroy_state. 458 * 459 * RETURNS: 460 * 461 * Duplicated atomic state or NULL when the allocation failed. 462 */ 463 struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); 464 465 /** 466 * @atomic_destroy_state: 467 * 468 * Destroy a state duplicated with @atomic_duplicate_state and release 469 * or unreference all resources it references 470 */ 471 void (*atomic_destroy_state)(struct drm_crtc *crtc, 472 struct drm_crtc_state *state); 473 474 /** 475 * @atomic_set_property: 476 * 477 * Decode a driver-private property value and store the decoded value 478 * into the passed-in state structure. Since the atomic core decodes all 479 * standardized properties (even for extensions beyond the core set of 480 * properties which might not be implemented by all drivers) this 481 * requires drivers to subclass the state structure. 482 * 483 * Such driver-private properties should really only be implemented for 484 * truly hardware/vendor specific state. Instead it is preferred to 485 * standardize atomic extension and decode the properties used to expose 486 * such an extension in the core. 487 * 488 * Do not call this function directly, use 489 * drm_atomic_crtc_set_property() instead. 490 * 491 * This callback is optional if the driver does not support any 492 * driver-private atomic properties. 493 * 494 * NOTE: 495 * 496 * This function is called in the state assembly phase of atomic 497 * modesets, which can be aborted for any reason (including on 498 * userspace's request to just check whether a configuration would be 499 * possible). Drivers MUST NOT touch any persistent state (hardware or 500 * software) or data structures except the passed in @state parameter. 501 * 502 * Also since userspace controls in which order properties are set this 503 * function must not do any input validation (since the state update is 504 * incomplete and hence likely inconsistent). Instead any such input 505 * validation must be done in the various atomic_check callbacks. 506 * 507 * RETURNS: 508 * 509 * 0 if the property has been found, -EINVAL if the property isn't 510 * implemented by the driver (which should never happen, the core only 511 * asks for properties attached to this CRTC). No other validation is 512 * allowed by the driver. The core already checks that the property 513 * value is within the range (integer, valid enum value, ...) the driver 514 * set when registering the property. 515 */ 516 int (*atomic_set_property)(struct drm_crtc *crtc, 517 struct drm_crtc_state *state, 518 struct drm_property *property, 519 uint64_t val); 520 /** 521 * @atomic_get_property: 522 * 523 * Reads out the decoded driver-private property. This is used to 524 * implement the GETCRTC IOCTL. 525 * 526 * Do not call this function directly, use 527 * drm_atomic_crtc_get_property() instead. 528 * 529 * This callback is optional if the driver does not support any 530 * driver-private atomic properties. 531 * 532 * RETURNS: 533 * 534 * 0 on success, -EINVAL if the property isn't implemented by the 535 * driver (which should never happen, the core only asks for 536 * properties attached to this CRTC). 537 */ 538 int (*atomic_get_property)(struct drm_crtc *crtc, 539 const struct drm_crtc_state *state, 540 struct drm_property *property, 541 uint64_t *val); 542 543 /** 544 * @late_register: 545 * 546 * This optional hook can be used to register additional userspace 547 * interfaces attached to the crtc like debugfs interfaces. 548 * It is called late in the driver load sequence from drm_dev_register(). 549 * Everything added from this callback should be unregistered in 550 * the early_unregister callback. 551 * 552 * Returns: 553 * 554 * 0 on success, or a negative error code on failure. 555 */ 556 int (*late_register)(struct drm_crtc *crtc); 557 558 /** 559 * @early_unregister: 560 * 561 * This optional hook should be used to unregister the additional 562 * userspace interfaces attached to the crtc from 563 * @late_register. It is called from drm_dev_unregister(), 564 * early in the driver unload sequence to disable userspace access 565 * before data structures are torndown. 566 */ 567 void (*early_unregister)(struct drm_crtc *crtc); 568 569 /** 570 * @set_crc_source: 571 * 572 * Changes the source of CRC checksums of frames at the request of 573 * userspace, typically for testing purposes. The sources available are 574 * specific of each driver and a %NULL value indicates that CRC 575 * generation is to be switched off. 576 * 577 * When CRC generation is enabled, the driver should call 578 * drm_crtc_add_crc_entry() at each frame, providing any information 579 * that characterizes the frame contents in the crcN arguments, as 580 * provided from the configured source. Drivers must accept a "auto" 581 * source name that will select a default source for this CRTC. 582 * 583 * This callback is optional if the driver does not support any CRC 584 * generation functionality. 585 * 586 * RETURNS: 587 * 588 * 0 on success or a negative error code on failure. 589 */ 590 int (*set_crc_source)(struct drm_crtc *crtc, const char *source, 591 size_t *values_cnt); 592 593 /** 594 * @atomic_print_state: 595 * 596 * If driver subclasses &struct drm_crtc_state, it should implement 597 * this optional hook for printing additional driver specific state. 598 * 599 * Do not call this directly, use drm_atomic_crtc_print_state() 600 * instead. 601 */ 602 void (*atomic_print_state)(struct drm_printer *p, 603 const struct drm_crtc_state *state); 604 }; 605 606 /** 607 * struct drm_crtc - central CRTC control structure 608 * @dev: parent DRM device 609 * @port: OF node used by drm_of_find_possible_crtcs() 610 * @head: list management 611 * @name: human readable name, can be overwritten by the driver 612 * @mutex: per-CRTC locking 613 * @base: base KMS object for ID tracking etc. 614 * @primary: primary plane for this CRTC 615 * @cursor: cursor plane for this CRTC 616 * @cursor_x: current x position of the cursor, used for universal cursor planes 617 * @cursor_y: current y position of the cursor, used for universal cursor planes 618 * @enabled: is this CRTC enabled? 619 * @mode: current mode timings 620 * @hwmode: mode timings as programmed to hw regs 621 * @x: x position on screen 622 * @y: y position on screen 623 * @funcs: CRTC control functions 624 * @gamma_size: size of gamma ramp 625 * @gamma_store: gamma ramp values 626 * @helper_private: mid-layer private data 627 * @properties: property tracking for this CRTC 628 * 629 * Each CRTC may have one or more connectors associated with it. This structure 630 * allows the CRTC to be controlled. 631 */ 632 struct drm_crtc { 633 struct drm_device *dev; 634 struct device_node *port; 635 struct list_head head; 636 637 char *name; 638 639 /** 640 * @mutex: 641 * 642 * This provides a read lock for the overall crtc state (mode, dpms 643 * state, ...) and a write lock for everything which can be update 644 * without a full modeset (fb, cursor data, crtc properties ...). A full 645 * modeset also need to grab &drm_mode_config.connection_mutex. 646 */ 647 struct drm_modeset_lock mutex; 648 649 struct drm_mode_object base; 650 651 /* primary and cursor planes for CRTC */ 652 struct drm_plane *primary; 653 struct drm_plane *cursor; 654 655 /** 656 * @index: Position inside the mode_config.list, can be used as an array 657 * index. It is invariant over the lifetime of the CRTC. 658 */ 659 unsigned index; 660 661 /* position of cursor plane on crtc */ 662 int cursor_x; 663 int cursor_y; 664 665 bool enabled; 666 667 /* Requested mode from modesetting. */ 668 struct drm_display_mode mode; 669 670 /* Programmed mode in hw, after adjustments for encoders, 671 * crtc, panel scaling etc. Needed for timestamping etc. 672 */ 673 struct drm_display_mode hwmode; 674 675 int x, y; 676 const struct drm_crtc_funcs *funcs; 677 678 /* Legacy FB CRTC gamma size for reporting to userspace */ 679 uint32_t gamma_size; 680 uint16_t *gamma_store; 681 682 /* if you are using the helper */ 683 const struct drm_crtc_helper_funcs *helper_private; 684 685 struct drm_object_properties properties; 686 687 /** 688 * @state: 689 * 690 * Current atomic state for this CRTC. 691 */ 692 struct drm_crtc_state *state; 693 694 /** 695 * @commit_list: 696 * 697 * List of &drm_crtc_commit structures tracking pending commits. 698 * Protected by @commit_lock. This list doesn't hold its own full 699 * reference, but burrows it from the ongoing commit. Commit entries 700 * must be removed from this list once the commit is fully completed, 701 * but before it's correspoding &drm_atomic_state gets destroyed. 702 */ 703 struct list_head commit_list; 704 705 /** 706 * @commit_lock: 707 * 708 * Spinlock to protect @commit_list. 709 */ 710 spinlock_t commit_lock; 711 712 /** 713 * @acquire_ctx: 714 * 715 * Per-CRTC implicit acquire context used by atomic drivers for legacy 716 * IOCTLs, so that atomic drivers can get at the locking acquire 717 * context. 718 */ 719 struct drm_modeset_acquire_ctx *acquire_ctx; 720 721 #ifdef CONFIG_DEBUG_FS 722 /** 723 * @debugfs_entry: 724 * 725 * Debugfs directory for this CRTC. 726 */ 727 struct dentry *debugfs_entry; 728 729 /** 730 * @crc: 731 * 732 * Configuration settings of CRC capture. 733 */ 734 struct drm_crtc_crc crc; 735 #endif 736 737 /** 738 * @fence_context: 739 * 740 * timeline context used for fence operations. 741 */ 742 unsigned int fence_context; 743 744 /** 745 * @fence_lock: 746 * 747 * spinlock to protect the fences in the fence_context. 748 */ 749 750 spinlock_t fence_lock; 751 /** 752 * @fence_seqno: 753 * 754 * Seqno variable used as monotonic counter for the fences 755 * created on the CRTC's timeline. 756 */ 757 unsigned long fence_seqno; 758 759 /** 760 * @timeline_name: 761 * 762 * The name of the CRTC's fence timeline. 763 */ 764 char timeline_name[32]; 765 }; 766 767 /** 768 * struct drm_mode_set - new values for a CRTC config change 769 * @fb: framebuffer to use for new config 770 * @crtc: CRTC whose configuration we're about to change 771 * @mode: mode timings to use 772 * @x: position of this CRTC relative to @fb 773 * @y: position of this CRTC relative to @fb 774 * @connectors: array of connectors to drive with this CRTC if possible 775 * @num_connectors: size of @connectors array 776 * 777 * This represents a modeset configuration for the legacy SETCRTC ioctl and is 778 * also used internally. Atomic drivers instead use &drm_atomic_state. 779 */ 780 struct drm_mode_set { 781 struct drm_framebuffer *fb; 782 struct drm_crtc *crtc; 783 struct drm_display_mode *mode; 784 785 uint32_t x; 786 uint32_t y; 787 788 struct drm_connector **connectors; 789 size_t num_connectors; 790 }; 791 792 #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) 793 794 __printf(6, 7) 795 int drm_crtc_init_with_planes(struct drm_device *dev, 796 struct drm_crtc *crtc, 797 struct drm_plane *primary, 798 struct drm_plane *cursor, 799 const struct drm_crtc_funcs *funcs, 800 const char *name, ...); 801 void drm_crtc_cleanup(struct drm_crtc *crtc); 802 803 /** 804 * drm_crtc_index - find the index of a registered CRTC 805 * @crtc: CRTC to find index for 806 * 807 * Given a registered CRTC, return the index of that CRTC within a DRM 808 * device's list of CRTCs. 809 */ 810 static inline unsigned int drm_crtc_index(const struct drm_crtc *crtc) 811 { 812 return crtc->index; 813 } 814 815 /** 816 * drm_crtc_mask - find the mask of a registered CRTC 817 * @crtc: CRTC to find mask for 818 * 819 * Given a registered CRTC, return the mask bit of that CRTC for an 820 * encoder's possible_crtcs field. 821 */ 822 static inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc) 823 { 824 return 1 << drm_crtc_index(crtc); 825 } 826 827 int drm_crtc_force_disable(struct drm_crtc *crtc); 828 int drm_crtc_force_disable_all(struct drm_device *dev); 829 830 int drm_mode_set_config_internal(struct drm_mode_set *set); 831 struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx); 832 833 /** 834 * drm_crtc_find - look up a CRTC object from its ID 835 * @dev: DRM device 836 * @id: &drm_mode_object ID 837 * 838 * This can be used to look up a CRTC from its userspace ID. Only used by 839 * drivers for legacy IOCTLs and interface, nowadays extensions to the KMS 840 * userspace interface should be done using &drm_property. 841 */ 842 static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, 843 uint32_t id) 844 { 845 struct drm_mode_object *mo; 846 mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC); 847 return mo ? obj_to_crtc(mo) : NULL; 848 } 849 850 /** 851 * drm_for_each_crtc - iterate over all CRTCs 852 * @crtc: a &struct drm_crtc as the loop cursor 853 * @dev: the &struct drm_device 854 * 855 * Iterate over all CRTCs of @dev. 856 */ 857 #define drm_for_each_crtc(crtc, dev) \ 858 list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) 859 860 #endif /* __DRM_CRTC_H__ */ -
new file headers/private/graphics/drm/uapi/drm/drm.h
diff --git a/headers/private/graphics/drm/uapi/drm/drm.h b/headers/private/graphics/drm/uapi/drm/drm.h new file mode 100644 index 0000000000..b0b8556136
- + 1 /** 2 * \file drm.h 3 * Header for the Direct Rendering Manager 4 * 5 * \author Rickard E. (Rik) Faith <faith@valinux.com> 6 * 7 * \par Acknowledgments: 8 * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic \c cmpxchg. 9 */ 10 11 /* 12 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 13 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 14 * All rights reserved. 15 * 16 * Permission is hereby granted, free of charge, to any person obtaining a 17 * copy of this software and associated documentation files (the "Software"), 18 * to deal in the Software without restriction, including without limitation 19 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 20 * and/or sell copies of the Software, and to permit persons to whom the 21 * Software is furnished to do so, subject to the following conditions: 22 * 23 * The above copyright notice and this permission notice (including the next 24 * paragraph) shall be included in all copies or substantial portions of the 25 * Software. 26 * 27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 30 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 31 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 32 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 33 * OTHER DEALINGS IN THE SOFTWARE. 34 */ 35 36 #ifndef _DRM_H_ 37 #define _DRM_H_ 38 39 #if defined(__KERNEL__) || defined(__linux__) 40 41 #include <linux/types.h> 42 #include <asm/ioctl.h> 43 typedef unsigned int drm_handle_t; 44 45 #else /* One of the BSDs */ 46 47 #include <sys/ioccom.h> 48 #include <sys/types.h> 49 typedef int8_t __s8; 50 typedef uint8_t __u8; 51 typedef int16_t __s16; 52 typedef uint16_t __u16; 53 typedef int32_t __s32; 54 typedef uint32_t __u32; 55 typedef int64_t __s64; 56 typedef uint64_t __u64; 57 typedef unsigned long drm_handle_t; 58 59 #endif 60 61 #define DRM_NAME "drm" /**< Name in kernel, /dev, and /proc */ 62 #define DRM_MIN_ORDER 5 /**< At least 2^5 bytes = 32 bytes */ 63 #define DRM_MAX_ORDER 22 /**< Up to 2^22 bytes = 4MB */ 64 #define DRM_RAM_PERCENT 10 /**< How much system ram can we lock? */ 65 66 #define _DRM_LOCK_HELD 0x80000000U /**< Hardware lock is held */ 67 #define _DRM_LOCK_CONT 0x40000000U /**< Hardware lock is contended */ 68 #define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD) 69 #define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT) 70 #define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT)) 71 72 typedef unsigned int drm_context_t; 73 typedef unsigned int drm_drawable_t; 74 typedef unsigned int drm_magic_t; 75 76 /** 77 * Cliprect. 78 * 79 * \warning: If you change this structure, make sure you change 80 * XF86DRIClipRectRec in the server as well 81 * 82 * \note KW: Actually it's illegal to change either for 83 * backwards-compatibility reasons. 84 */ 85 struct drm_clip_rect { 86 unsigned short x1; 87 unsigned short y1; 88 unsigned short x2; 89 unsigned short y2; 90 }; 91 92 /** 93 * Drawable information. 94 */ 95 struct drm_drawable_info { 96 unsigned int num_rects; 97 struct drm_clip_rect *rects; 98 }; 99 100 /** 101 * Texture region, 102 */ 103 struct drm_tex_region { 104 unsigned char next; 105 unsigned char prev; 106 unsigned char in_use; 107 unsigned char padding; 108 unsigned int age; 109 }; 110 111 /** 112 * Hardware lock. 113 * 114 * The lock structure is a simple cache-line aligned integer. To avoid 115 * processor bus contention on a multiprocessor system, there should not be any 116 * other data stored in the same cache line. 117 */ 118 struct drm_hw_lock { 119 __volatile__ unsigned int lock; /**< lock variable */ 120 char padding[60]; /**< Pad to cache line */ 121 }; 122 123 /** 124 * DRM_IOCTL_VERSION ioctl argument type. 125 * 126 * \sa drmGetVersion(). 127 */ 128 struct drm_version { 129 int version_major; /**< Major version */ 130 int version_minor; /**< Minor version */ 131 int version_patchlevel; /**< Patch level */ 132 size_t name_len; /**< Length of name buffer */ 133 char __user *name; /**< Name of driver */ 134 size_t date_len; /**< Length of date buffer */ 135 char __user *date; /**< User-space buffer to hold date */ 136 size_t desc_len; /**< Length of desc buffer */ 137 char __user *desc; /**< User-space buffer to hold desc */ 138 }; 139 140 /** 141 * DRM_IOCTL_GET_UNIQUE ioctl argument type. 142 * 143 * \sa drmGetBusid() and drmSetBusId(). 144 */ 145 struct drm_unique { 146 size_t unique_len; /**< Length of unique */ 147 char __user *unique; /**< Unique name for driver instantiation */ 148 }; 149 150 struct drm_list { 151 int count; /**< Length of user-space structures */ 152 struct drm_version __user *version; 153 }; 154 155 struct drm_block { 156 int unused; 157 }; 158 159 /** 160 * DRM_IOCTL_CONTROL ioctl argument type. 161 * 162 * \sa drmCtlInstHandler() and drmCtlUninstHandler(). 163 */ 164 struct drm_control { 165 enum { 166 DRM_ADD_COMMAND, 167 DRM_RM_COMMAND, 168 DRM_INST_HANDLER, 169 DRM_UNINST_HANDLER 170 } func; 171 int irq; 172 }; 173 174 /** 175 * Type of memory to map. 176 */ 177 enum drm_map_type { 178 _DRM_FRAME_BUFFER = 0, /**< WC (no caching), no core dump */ 179 _DRM_REGISTERS = 1, /**< no caching, no core dump */ 180 _DRM_SHM = 2, /**< shared, cached */ 181 _DRM_AGP = 3, /**< AGP/GART */ 182 _DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */ 183 _DRM_CONSISTENT = 5, /**< Consistent memory for PCI DMA */ 184 }; 185 186 /** 187 * Memory mapping flags. 188 */ 189 enum drm_map_flags { 190 _DRM_RESTRICTED = 0x01, /**< Cannot be mapped to user-virtual */ 191 _DRM_READ_ONLY = 0x02, 192 _DRM_LOCKED = 0x04, /**< shared, cached, locked */ 193 _DRM_KERNEL = 0x08, /**< kernel requires access */ 194 _DRM_WRITE_COMBINING = 0x10, /**< use write-combining if available */ 195 _DRM_CONTAINS_LOCK = 0x20, /**< SHM page that contains lock */ 196 _DRM_REMOVABLE = 0x40, /**< Removable mapping */ 197 _DRM_DRIVER = 0x80 /**< Managed by driver */ 198 }; 199 200 struct drm_ctx_priv_map { 201 unsigned int ctx_id; /**< Context requesting private mapping */ 202 void *handle; /**< Handle of map */ 203 }; 204 205 /** 206 * DRM_IOCTL_GET_MAP, DRM_IOCTL_ADD_MAP and DRM_IOCTL_RM_MAP ioctls 207 * argument type. 208 * 209 * \sa drmAddMap(). 210 */ 211 struct drm_map { 212 unsigned long offset; /**< Requested physical address (0 for SAREA)*/ 213 unsigned long size; /**< Requested physical size (bytes) */ 214 enum drm_map_type type; /**< Type of memory to map */ 215 enum drm_map_flags flags; /**< Flags */ 216 void *handle; /**< User-space: "Handle" to pass to mmap() */ 217 /**< Kernel-space: kernel-virtual address */ 218 int mtrr; /**< MTRR slot used */ 219 /* Private data */ 220 }; 221 222 /** 223 * DRM_IOCTL_GET_CLIENT ioctl argument type. 224 */ 225 struct drm_client { 226 int idx; /**< Which client desired? */ 227 int auth; /**< Is client authenticated? */ 228 unsigned long pid; /**< Process ID */ 229 unsigned long uid; /**< User ID */ 230 unsigned long magic; /**< Magic */ 231 unsigned long iocs; /**< Ioctl count */ 232 }; 233 234 enum drm_stat_type { 235 _DRM_STAT_LOCK, 236 _DRM_STAT_OPENS, 237 _DRM_STAT_CLOSES, 238 _DRM_STAT_IOCTLS, 239 _DRM_STAT_LOCKS, 240 _DRM_STAT_UNLOCKS, 241 _DRM_STAT_VALUE, /**< Generic value */ 242 _DRM_STAT_BYTE, /**< Generic byte counter (1024bytes/K) */ 243 _DRM_STAT_COUNT, /**< Generic non-byte counter (1000/k) */ 244 245 _DRM_STAT_IRQ, /**< IRQ */ 246 _DRM_STAT_PRIMARY, /**< Primary DMA bytes */ 247 _DRM_STAT_SECONDARY, /**< Secondary DMA bytes */ 248 _DRM_STAT_DMA, /**< DMA */ 249 _DRM_STAT_SPECIAL, /**< Special DMA (e.g., priority or polled) */ 250 _DRM_STAT_MISSED /**< Missed DMA opportunity */ 251 /* Add to the *END* of the list */ 252 }; 253 254 /** 255 * DRM_IOCTL_GET_STATS ioctl argument type. 256 */ 257 struct drm_stats { 258 unsigned long count; 259 struct { 260 unsigned long value; 261 enum drm_stat_type type; 262 } data[15]; 263 }; 264 265 /** 266 * Hardware locking flags. 267 */ 268 enum drm_lock_flags { 269 _DRM_LOCK_READY = 0x01, /**< Wait until hardware is ready for DMA */ 270 _DRM_LOCK_QUIESCENT = 0x02, /**< Wait until hardware quiescent */ 271 _DRM_LOCK_FLUSH = 0x04, /**< Flush this context's DMA queue first */ 272 _DRM_LOCK_FLUSH_ALL = 0x08, /**< Flush all DMA queues first */ 273 /* These *HALT* flags aren't supported yet 274 -- they will be used to support the 275 full-screen DGA-like mode. */ 276 _DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */ 277 _DRM_HALT_CUR_QUEUES = 0x20 /**< Halt all current queues */ 278 }; 279 280 /** 281 * DRM_IOCTL_LOCK, DRM_IOCTL_UNLOCK and DRM_IOCTL_FINISH ioctl argument type. 282 * 283 * \sa drmGetLock() and drmUnlock(). 284 */ 285 struct drm_lock { 286 int context; 287 enum drm_lock_flags flags; 288 }; 289 290 /** 291 * DMA flags 292 * 293 * \warning 294 * These values \e must match xf86drm.h. 295 * 296 * \sa drm_dma. 297 */ 298 enum drm_dma_flags { 299 /* Flags for DMA buffer dispatch */ 300 _DRM_DMA_BLOCK = 0x01, /**< 301 * Block until buffer dispatched. 302 * 303 * \note The buffer may not yet have 304 * been processed by the hardware -- 305 * getting a hardware lock with the 306 * hardware quiescent will ensure 307 * that the buffer has been 308 * processed. 309 */ 310 _DRM_DMA_WHILE_LOCKED = 0x02, /**< Dispatch while lock held */ 311 _DRM_DMA_PRIORITY = 0x04, /**< High priority dispatch */ 312 313 /* Flags for DMA buffer request */ 314 _DRM_DMA_WAIT = 0x10, /**< Wait for free buffers */ 315 _DRM_DMA_SMALLER_OK = 0x20, /**< Smaller-than-requested buffers OK */ 316 _DRM_DMA_LARGER_OK = 0x40 /**< Larger-than-requested buffers OK */ 317 }; 318 319 /** 320 * DRM_IOCTL_ADD_BUFS and DRM_IOCTL_MARK_BUFS ioctl argument type. 321 * 322 * \sa drmAddBufs(). 323 */ 324 struct drm_buf_desc { 325 int count; /**< Number of buffers of this size */ 326 int size; /**< Size in bytes */ 327 int low_mark; /**< Low water mark */ 328 int high_mark; /**< High water mark */ 329 enum { 330 _DRM_PAGE_ALIGN = 0x01, /**< Align on page boundaries for DMA */ 331 _DRM_AGP_BUFFER = 0x02, /**< Buffer is in AGP space */ 332 _DRM_SG_BUFFER = 0x04, /**< Scatter/gather memory buffer */ 333 _DRM_FB_BUFFER = 0x08, /**< Buffer is in frame buffer */ 334 _DRM_PCI_BUFFER_RO = 0x10 /**< Map PCI DMA buffer read-only */ 335 } flags; 336 unsigned long agp_start; /**< 337 * Start address of where the AGP buffers are 338 * in the AGP aperture 339 */ 340 }; 341 342 /** 343 * DRM_IOCTL_INFO_BUFS ioctl argument type. 344 */ 345 struct drm_buf_info { 346 int count; /**< Entries in list */ 347 struct drm_buf_desc __user *list; 348 }; 349 350 /** 351 * DRM_IOCTL_FREE_BUFS ioctl argument type. 352 */ 353 struct drm_buf_free { 354 int count; 355 int __user *list; 356 }; 357 358 /** 359 * Buffer information 360 * 361 * \sa drm_buf_map. 362 */ 363 struct drm_buf_pub { 364 int idx; /**< Index into the master buffer list */ 365 int total; /**< Buffer size */ 366 int used; /**< Amount of buffer in use (for DMA) */ 367 void __user *address; /**< Address of buffer */ 368 }; 369 370 /** 371 * DRM_IOCTL_MAP_BUFS ioctl argument type. 372 */ 373 struct drm_buf_map { 374 int count; /**< Length of the buffer list */ 375 void __user *virtual; /**< Mmap'd area in user-virtual */ 376 struct drm_buf_pub __user *list; /**< Buffer information */ 377 }; 378 379 /** 380 * DRM_IOCTL_DMA ioctl argument type. 381 * 382 * Indices here refer to the offset into the buffer list in drm_buf_get. 383 * 384 * \sa drmDMA(). 385 */ 386 struct drm_dma { 387 int context; /**< Context handle */ 388 int send_count; /**< Number of buffers to send */ 389 int __user *send_indices; /**< List of handles to buffers */ 390 int __user *send_sizes; /**< Lengths of data to send */ 391 enum drm_dma_flags flags; /**< Flags */ 392 int request_count; /**< Number of buffers requested */ 393 int request_size; /**< Desired size for buffers */ 394 int __user *request_indices; /**< Buffer information */ 395 int __user *request_sizes; 396 int granted_count; /**< Number of buffers granted */ 397 }; 398 399 enum drm_ctx_flags { 400 _DRM_CONTEXT_PRESERVED = 0x01, 401 _DRM_CONTEXT_2DONLY = 0x02 402 }; 403 404 /** 405 * DRM_IOCTL_ADD_CTX ioctl argument type. 406 * 407 * \sa drmCreateContext() and drmDestroyContext(). 408 */ 409 struct drm_ctx { 410 drm_context_t handle; 411 enum drm_ctx_flags flags; 412 }; 413 414 /** 415 * DRM_IOCTL_RES_CTX ioctl argument type. 416 */ 417 struct drm_ctx_res { 418 int count; 419 struct drm_ctx __user *contexts; 420 }; 421 422 /** 423 * DRM_IOCTL_ADD_DRAW and DRM_IOCTL_RM_DRAW ioctl argument type. 424 */ 425 struct drm_draw { 426 drm_drawable_t handle; 427 }; 428 429 /** 430 * DRM_IOCTL_UPDATE_DRAW ioctl argument type. 431 */ 432 typedef enum { 433 DRM_DRAWABLE_CLIPRECTS, 434 } drm_drawable_info_type_t; 435 436 struct drm_update_draw { 437 drm_drawable_t handle; 438 unsigned int type; 439 unsigned int num; 440 unsigned long long data; 441 }; 442 443 /** 444 * DRM_IOCTL_GET_MAGIC and DRM_IOCTL_AUTH_MAGIC ioctl argument type. 445 */ 446 struct drm_auth { 447 drm_magic_t magic; 448 }; 449 450 /** 451 * DRM_IOCTL_IRQ_BUSID ioctl argument type. 452 * 453 * \sa drmGetInterruptFromBusID(). 454 */ 455 struct drm_irq_busid { 456 int irq; /**< IRQ number */ 457 int busnum; /**< bus number */ 458 int devnum; /**< device number */ 459 int funcnum; /**< function number */ 460 }; 461 462 enum drm_vblank_seq_type { 463 _DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */ 464 _DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */ 465 /* bits 1-6 are reserved for high crtcs */ 466 _DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e, 467 _DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */ 468 _DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */ 469 _DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */ 470 _DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */ 471 _DRM_VBLANK_SIGNAL = 0x40000000 /**< Send signal instead of blocking, unsupported */ 472 }; 473 #define _DRM_VBLANK_HIGH_CRTC_SHIFT 1 474 475 #define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE) 476 #define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_EVENT | _DRM_VBLANK_SIGNAL | \ 477 _DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS) 478 479 struct drm_wait_vblank_request { 480 enum drm_vblank_seq_type type; 481 unsigned int sequence; 482 unsigned long signal; 483 }; 484 485 struct drm_wait_vblank_reply { 486 enum drm_vblank_seq_type type; 487 unsigned int sequence; 488 long tval_sec; 489 long tval_usec; 490 }; 491 492 /** 493 * DRM_IOCTL_WAIT_VBLANK ioctl argument type. 494 * 495 * \sa drmWaitVBlank(). 496 */ 497 union drm_wait_vblank { 498 struct drm_wait_vblank_request request; 499 struct drm_wait_vblank_reply reply; 500 }; 501 502 #define _DRM_PRE_MODESET 1 503 #define _DRM_POST_MODESET 2 504 505 /** 506 * DRM_IOCTL_MODESET_CTL ioctl argument type 507 * 508 * \sa drmModesetCtl(). 509 */ 510 struct drm_modeset_ctl { 511 __u32 crtc; 512 __u32 cmd; 513 }; 514 515 /** 516 * DRM_IOCTL_AGP_ENABLE ioctl argument type. 517 * 518 * \sa drmAgpEnable(). 519 */ 520 struct drm_agp_mode { 521 unsigned long mode; /**< AGP mode */ 522 }; 523 524 /** 525 * DRM_IOCTL_AGP_ALLOC and DRM_IOCTL_AGP_FREE ioctls argument type. 526 * 527 * \sa drmAgpAlloc() and drmAgpFree(). 528 */ 529 struct drm_agp_buffer { 530 unsigned long size; /**< In bytes -- will round to page boundary */ 531 unsigned long handle; /**< Used for binding / unbinding */ 532 unsigned long type; /**< Type of memory to allocate */ 533 unsigned long physical; /**< Physical used by i810 */ 534 }; 535 536 /** 537 * DRM_IOCTL_AGP_BIND and DRM_IOCTL_AGP_UNBIND ioctls argument type. 538 * 539 * \sa drmAgpBind() and drmAgpUnbind(). 540 */ 541 struct drm_agp_binding { 542 unsigned long handle; /**< From drm_agp_buffer */ 543 unsigned long offset; /**< In bytes -- will round to page boundary */ 544 }; 545 546 /** 547 * DRM_IOCTL_AGP_INFO ioctl argument type. 548 * 549 * \sa drmAgpVersionMajor(), drmAgpVersionMinor(), drmAgpGetMode(), 550 * drmAgpBase(), drmAgpSize(), drmAgpMemoryUsed(), drmAgpMemoryAvail(), 551 * drmAgpVendorId() and drmAgpDeviceId(). 552 */ 553 struct drm_agp_info { 554 int agp_version_major; 555 int agp_version_minor; 556 unsigned long mode; 557 unsigned long aperture_base; /* physical address */ 558 unsigned long aperture_size; /* bytes */ 559 unsigned long memory_allowed; /* bytes */ 560 unsigned long memory_used; 561 562 /* PCI information */ 563 unsigned short id_vendor; 564 unsigned short id_device; 565 }; 566 567 /** 568 * DRM_IOCTL_SG_ALLOC ioctl argument type. 569 */ 570 struct drm_scatter_gather { 571 unsigned long size; /**< In bytes -- will round to page boundary */ 572 unsigned long handle; /**< Used for mapping / unmapping */ 573 }; 574 575 /** 576 * DRM_IOCTL_SET_VERSION ioctl argument type. 577 */ 578 struct drm_set_version { 579 int drm_di_major; 580 int drm_di_minor; 581 int drm_dd_major; 582 int drm_dd_minor; 583 }; 584 585 /** DRM_IOCTL_GEM_CLOSE ioctl argument type */ 586 struct drm_gem_close { 587 /** Handle of the object to be closed. */ 588 __u32 handle; 589 __u32 pad; 590 }; 591 592 /** DRM_IOCTL_GEM_FLINK ioctl argument type */ 593 struct drm_gem_flink { 594 /** Handle for the object being named */ 595 __u32 handle; 596 597 /** Returned global name */ 598 __u32 name; 599 }; 600 601 /** DRM_IOCTL_GEM_OPEN ioctl argument type */ 602 struct drm_gem_open { 603 /** Name of object being opened */ 604 __u32 name; 605 606 /** Returned handle for the object */ 607 __u32 handle; 608 609 /** Returned size of the object */ 610 __u64 size; 611 }; 612 613 #define DRM_CAP_DUMB_BUFFER 0x1 614 #define DRM_CAP_VBLANK_HIGH_CRTC 0x2 615 #define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3 616 #define DRM_CAP_DUMB_PREFER_SHADOW 0x4 617 #define DRM_CAP_PRIME 0x5 618 #define DRM_PRIME_CAP_IMPORT 0x1 619 #define DRM_PRIME_CAP_EXPORT 0x2 620 #define DRM_CAP_TIMESTAMP_MONOTONIC 0x6 621 #define DRM_CAP_ASYNC_PAGE_FLIP 0x7 622 /* 623 * The CURSOR_WIDTH and CURSOR_HEIGHT capabilities return a valid widthxheight 624 * combination for the hardware cursor. The intention is that a hardware 625 * agnostic userspace can query a cursor plane size to use. 626 * 627 * Note that the cross-driver contract is to merely return a valid size; 628 * drivers are free to attach another meaning on top, eg. i915 returns the 629 * maximum plane size. 630 */ 631 #define DRM_CAP_CURSOR_WIDTH 0x8 632 #define DRM_CAP_CURSOR_HEIGHT 0x9 633 634 /** DRM_IOCTL_GET_CAP ioctl argument type */ 635 struct drm_get_cap { 636 __u64 capability; 637 __u64 value; 638 }; 639 640 /** 641 * DRM_CLIENT_CAP_STEREO_3D 642 * 643 * if set to 1, the DRM core will expose the stereo 3D capabilities of the 644 * monitor by advertising the supported 3D layouts in the flags of struct 645 * drm_mode_modeinfo. 646 */ 647 #define DRM_CLIENT_CAP_STEREO_3D 1 648 649 /** 650 * DRM_CLIENT_CAP_UNIVERSAL_PLANES 651 * 652 * If set to 1, the DRM core will expose all planes (overlay, primary, and 653 * cursor) to userspace. 654 */ 655 #define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2 656 657 /** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ 658 struct drm_set_client_cap { 659 __u64 capability; 660 __u64 value; 661 }; 662 663 #define DRM_CLOEXEC O_CLOEXEC 664 struct drm_prime_handle { 665 __u32 handle; 666 667 /** Flags.. only applicable for handle->fd */ 668 __u32 flags; 669 670 /** Returned dmabuf file descriptor */ 671 __s32 fd; 672 }; 673 674 #include <drm/drm_mode.h> 675 676 #define DRM_IOCTL_BASE 'd' 677 #define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr) 678 #define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type) 679 #define DRM_IOW(nr,type) _IOW(DRM_IOCTL_BASE,nr,type) 680 #define DRM_IOWR(nr,type) _IOWR(DRM_IOCTL_BASE,nr,type) 681 682 #define DRM_IOCTL_VERSION DRM_IOWR(0x00, struct drm_version) 683 #define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, struct drm_unique) 684 #define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, struct drm_auth) 685 #define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, struct drm_irq_busid) 686 #define DRM_IOCTL_GET_MAP DRM_IOWR(0x04, struct drm_map) 687 #define DRM_IOCTL_GET_CLIENT DRM_IOWR(0x05, struct drm_client) 688 #define DRM_IOCTL_GET_STATS DRM_IOR( 0x06, struct drm_stats) 689 #define DRM_IOCTL_SET_VERSION DRM_IOWR(0x07, struct drm_set_version) 690 #define DRM_IOCTL_MODESET_CTL DRM_IOW(0x08, struct drm_modeset_ctl) 691 #define DRM_IOCTL_GEM_CLOSE DRM_IOW (0x09, struct drm_gem_close) 692 #define DRM_IOCTL_GEM_FLINK DRM_IOWR(0x0a, struct drm_gem_flink) 693 #define DRM_IOCTL_GEM_OPEN DRM_IOWR(0x0b, struct drm_gem_open) 694 #define DRM_IOCTL_GET_CAP DRM_IOWR(0x0c, struct drm_get_cap) 695 #define DRM_IOCTL_SET_CLIENT_CAP DRM_IOW( 0x0d, struct drm_set_client_cap) 696 697 #define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, struct drm_unique) 698 #define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, struct drm_auth) 699 #define DRM_IOCTL_BLOCK DRM_IOWR(0x12, struct drm_block) 700 #define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, struct drm_block) 701 #define DRM_IOCTL_CONTROL DRM_IOW( 0x14, struct drm_control) 702 #define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, struct drm_map) 703 #define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, struct drm_buf_desc) 704 #define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, struct drm_buf_desc) 705 #define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, struct drm_buf_info) 706 #define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, struct drm_buf_map) 707 #define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, struct drm_buf_free) 708 709 #define DRM_IOCTL_RM_MAP DRM_IOW( 0x1b, struct drm_map) 710 711 #define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, struct drm_ctx_priv_map) 712 #define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, struct drm_ctx_priv_map) 713 714 #define DRM_IOCTL_SET_MASTER DRM_IO(0x1e) 715 #define DRM_IOCTL_DROP_MASTER DRM_IO(0x1f) 716 717 #define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, struct drm_ctx) 718 #define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, struct drm_ctx) 719 #define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, struct drm_ctx) 720 #define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, struct drm_ctx) 721 #define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, struct drm_ctx) 722 #define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, struct drm_ctx) 723 #define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, struct drm_ctx_res) 724 #define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, struct drm_draw) 725 #define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, struct drm_draw) 726 #define DRM_IOCTL_DMA DRM_IOWR(0x29, struct drm_dma) 727 #define DRM_IOCTL_LOCK DRM_IOW( 0x2a, struct drm_lock) 728 #define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, struct drm_lock) 729 #define DRM_IOCTL_FINISH DRM_IOW( 0x2c, struct drm_lock) 730 731 #define DRM_IOCTL_PRIME_HANDLE_TO_FD DRM_IOWR(0x2d, struct drm_prime_handle) 732 #define DRM_IOCTL_PRIME_FD_TO_HANDLE DRM_IOWR(0x2e, struct drm_prime_handle) 733 734 #define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30) 735 #define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31) 736 #define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, struct drm_agp_mode) 737 #define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, struct drm_agp_info) 738 #define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, struct drm_agp_buffer) 739 #define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, struct drm_agp_buffer) 740 #define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, struct drm_agp_binding) 741 #define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, struct drm_agp_binding) 742 743 #define DRM_IOCTL_SG_ALLOC DRM_IOWR(0x38, struct drm_scatter_gather) 744 #define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, struct drm_scatter_gather) 745 746 #define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, union drm_wait_vblank) 747 748 #define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw) 749 750 #define DRM_IOCTL_MODE_GETRESOURCES DRM_IOWR(0xA0, struct drm_mode_card_res) 751 #define DRM_IOCTL_MODE_GETCRTC DRM_IOWR(0xA1, struct drm_mode_crtc) 752 #define DRM_IOCTL_MODE_SETCRTC DRM_IOWR(0xA2, struct drm_mode_crtc) 753 #define DRM_IOCTL_MODE_CURSOR DRM_IOWR(0xA3, struct drm_mode_cursor) 754 #define DRM_IOCTL_MODE_GETGAMMA DRM_IOWR(0xA4, struct drm_mode_crtc_lut) 755 #define DRM_IOCTL_MODE_SETGAMMA DRM_IOWR(0xA5, struct drm_mode_crtc_lut) 756 #define DRM_IOCTL_MODE_GETENCODER DRM_IOWR(0xA6, struct drm_mode_get_encoder) 757 #define DRM_IOCTL_MODE_GETCONNECTOR DRM_IOWR(0xA7, struct drm_mode_get_connector) 758 #define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA8, struct drm_mode_mode_cmd) /* deprecated (never worked) */ 759 #define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) /* deprecated (never worked) */ 760 761 #define DRM_IOCTL_MODE_GETPROPERTY DRM_IOWR(0xAA, struct drm_mode_get_property) 762 #define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xAB, struct drm_mode_connector_set_property) 763 #define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xAC, struct drm_mode_get_blob) 764 #define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xAD, struct drm_mode_fb_cmd) 765 #define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xAE, struct drm_mode_fb_cmd) 766 #define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xAF, unsigned int) 767 #define DRM_IOCTL_MODE_PAGE_FLIP DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip) 768 #define DRM_IOCTL_MODE_DIRTYFB DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd) 769 770 #define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, struct drm_mode_create_dumb) 771 #define DRM_IOCTL_MODE_MAP_DUMB DRM_IOWR(0xB3, struct drm_mode_map_dumb) 772 #define DRM_IOCTL_MODE_DESTROY_DUMB DRM_IOWR(0xB4, struct drm_mode_destroy_dumb) 773 #define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res) 774 #define DRM_IOCTL_MODE_GETPLANE DRM_IOWR(0xB6, struct drm_mode_get_plane) 775 #define DRM_IOCTL_MODE_SETPLANE DRM_IOWR(0xB7, struct drm_mode_set_plane) 776 #define DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, struct drm_mode_fb_cmd2) 777 #define DRM_IOCTL_MODE_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties) 778 #define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property) 779 #define DRM_IOCTL_MODE_CURSOR2 DRM_IOWR(0xBB, struct drm_mode_cursor2) 780 781 /** 782 * Device specific ioctls should only be in their respective headers 783 * The device specific ioctl range is from 0x40 to 0x9f. 784 * Generic IOCTLS restart at 0xA0. 785 * 786 * \sa drmCommandNone(), drmCommandRead(), drmCommandWrite(), and 787 * drmCommandReadWrite(). 788 */ 789 #define DRM_COMMAND_BASE 0x40 790 #define DRM_COMMAND_END 0xA0 791 792 /** 793 * Header for events written back to userspace on the drm fd. The 794 * type defines the type of event, the length specifies the total 795 * length of the event (including the header), and user_data is 796 * typically a 64 bit value passed with the ioctl that triggered the 797 * event. A read on the drm fd will always only return complete 798 * events, that is, if for example the read buffer is 100 bytes, and 799 * there are two 64 byte events pending, only one will be returned. 800 * 801 * Event types 0 - 0x7fffffff are generic drm events, 0x80000000 and 802 * up are chipset specific. 803 */ 804 struct drm_event { 805 __u32 type; 806 __u32 length; 807 }; 808 809 #define DRM_EVENT_VBLANK 0x01 810 #define DRM_EVENT_FLIP_COMPLETE 0x02 811 812 struct drm_event_vblank { 813 struct drm_event base; 814 __u64 user_data; 815 __u32 tv_sec; 816 __u32 tv_usec; 817 __u32 sequence; 818 __u32 reserved; 819 }; 820 821 /* typedef area */ 822 #ifndef __KERNEL__ 823 typedef struct drm_clip_rect drm_clip_rect_t; 824 typedef struct drm_drawable_info drm_drawable_info_t; 825 typedef struct drm_tex_region drm_tex_region_t; 826 typedef struct drm_hw_lock drm_hw_lock_t; 827 typedef struct drm_version drm_version_t; 828 typedef struct drm_unique drm_unique_t; 829 typedef struct drm_list drm_list_t; 830 typedef struct drm_block drm_block_t; 831 typedef struct drm_control drm_control_t; 832 typedef enum drm_map_type drm_map_type_t; 833 typedef enum drm_map_flags drm_map_flags_t; 834 typedef struct drm_ctx_priv_map drm_ctx_priv_map_t; 835 typedef struct drm_map drm_map_t; 836 typedef struct drm_client drm_client_t; 837 typedef enum drm_stat_type drm_stat_type_t; 838 typedef struct drm_stats drm_stats_t; 839 typedef enum drm_lock_flags drm_lock_flags_t; 840 typedef struct drm_lock drm_lock_t; 841 typedef enum drm_dma_flags drm_dma_flags_t; 842 typedef struct drm_buf_desc drm_buf_desc_t; 843 typedef struct drm_buf_info drm_buf_info_t; 844 typedef struct drm_buf_free drm_buf_free_t; 845 typedef struct drm_buf_pub drm_buf_pub_t; 846 typedef struct drm_buf_map drm_buf_map_t; 847 typedef struct drm_dma drm_dma_t; 848 typedef union drm_wait_vblank drm_wait_vblank_t; 849 typedef struct drm_agp_mode drm_agp_mode_t; 850 typedef enum drm_ctx_flags drm_ctx_flags_t; 851 typedef struct drm_ctx drm_ctx_t; 852 typedef struct drm_ctx_res drm_ctx_res_t; 853 typedef struct drm_draw drm_draw_t; 854 typedef struct drm_update_draw drm_update_draw_t; 855 typedef struct drm_auth drm_auth_t; 856 typedef struct drm_irq_busid drm_irq_busid_t; 857 typedef enum drm_vblank_seq_type drm_vblank_seq_type_t; 858 859 typedef struct drm_agp_buffer drm_agp_buffer_t; 860 typedef struct drm_agp_binding drm_agp_binding_t; 861 typedef struct drm_agp_info drm_agp_info_t; 862 typedef struct drm_scatter_gather drm_scatter_gather_t; 863 typedef struct drm_set_version drm_set_version_t; 864 #endif 865 866 #endif -
new file headers/private/graphics/drm/uapi/drm/drm_mode.h
diff --git a/headers/private/graphics/drm/uapi/drm/drm_mode.h b/headers/private/graphics/drm/uapi/drm/drm_mode.h new file mode 100644 index 0000000000..a0db2d4aa5
- + 1 /* 2 * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> 3 * Copyright (c) 2007 Jakob Bornecrantz <wallbraker@gmail.com> 4 * Copyright (c) 2008 Red Hat Inc. 5 * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA 6 * Copyright (c) 2007-2008 Intel Corporation 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a 9 * copy of this software and associated documentation files (the "Software"), 10 * to deal in the Software without restriction, including without limitation 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 * and/or sell copies of the Software, and to permit persons to whom the 13 * Software is furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in 16 * all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 24 * IN THE SOFTWARE. 25 */ 26 27 #ifndef _DRM_MODE_H 28 #define _DRM_MODE_H 29 30 #include <linux/types.h> 31 32 #define DRM_DISPLAY_INFO_LEN 32 33 #define DRM_CONNECTOR_NAME_LEN 32 34 #define DRM_DISPLAY_MODE_LEN 32 35 #define DRM_PROP_NAME_LEN 32 36 37 #define DRM_MODE_TYPE_BUILTIN (1<<0) 38 #define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN) 39 #define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN) 40 #define DRM_MODE_TYPE_PREFERRED (1<<3) 41 #define DRM_MODE_TYPE_DEFAULT (1<<4) 42 #define DRM_MODE_TYPE_USERDEF (1<<5) 43 #define DRM_MODE_TYPE_DRIVER (1<<6) 44 45 /* Video mode flags */ 46 /* bit compatible with the xorg definitions. */ 47 #define DRM_MODE_FLAG_PHSYNC (1<<0) 48 #define DRM_MODE_FLAG_NHSYNC (1<<1) 49 #define DRM_MODE_FLAG_PVSYNC (1<<2) 50 #define DRM_MODE_FLAG_NVSYNC (1<<3) 51 #define DRM_MODE_FLAG_INTERLACE (1<<4) 52 #define DRM_MODE_FLAG_DBLSCAN (1<<5) 53 #define DRM_MODE_FLAG_CSYNC (1<<6) 54 #define DRM_MODE_FLAG_PCSYNC (1<<7) 55 #define DRM_MODE_FLAG_NCSYNC (1<<8) 56 #define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */ 57 #define DRM_MODE_FLAG_BCAST (1<<10) 58 #define DRM_MODE_FLAG_PIXMUX (1<<11) 59 #define DRM_MODE_FLAG_DBLCLK (1<<12) 60 #define DRM_MODE_FLAG_CLKDIV2 (1<<13) 61 /* 62 * When adding a new stereo mode don't forget to adjust DRM_MODE_FLAGS_3D_MAX 63 * (define not exposed to user space). 64 */ 65 #define DRM_MODE_FLAG_3D_MASK (0x1f<<14) 66 #define DRM_MODE_FLAG_3D_NONE (0<<14) 67 #define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14) 68 #define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (2<<14) 69 #define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (3<<14) 70 #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL (4<<14) 71 #define DRM_MODE_FLAG_3D_L_DEPTH (5<<14) 72 #define DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH (6<<14) 73 #define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (7<<14) 74 #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (8<<14) 75 76 77 /* DPMS flags */ 78 /* bit compatible with the xorg definitions. */ 79 #define DRM_MODE_DPMS_ON 0 80 #define DRM_MODE_DPMS_STANDBY 1 81 #define DRM_MODE_DPMS_SUSPEND 2 82 #define DRM_MODE_DPMS_OFF 3 83 84 /* Scaling mode options */ 85 #define DRM_MODE_SCALE_NONE 0 /* Unmodified timing (display or 86 software can still scale) */ 87 #define DRM_MODE_SCALE_FULLSCREEN 1 /* Full screen, ignore aspect */ 88 #define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */ 89 #define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */ 90 91 /* Picture aspect ratio options */ 92 #define DRM_MODE_PICTURE_ASPECT_NONE 0 93 #define DRM_MODE_PICTURE_ASPECT_4_3 1 94 #define DRM_MODE_PICTURE_ASPECT_16_9 2 95 96 /* Dithering mode options */ 97 #define DRM_MODE_DITHERING_OFF 0 98 #define DRM_MODE_DITHERING_ON 1 99 #define DRM_MODE_DITHERING_AUTO 2 100 101 /* Dirty info options */ 102 #define DRM_MODE_DIRTY_OFF 0 103 #define DRM_MODE_DIRTY_ON 1 104 #define DRM_MODE_DIRTY_ANNOTATE 2 105 106 struct drm_mode_modeinfo { 107 __u32 clock; 108 __u16 hdisplay, hsync_start, hsync_end, htotal, hskew; 109 __u16 vdisplay, vsync_start, vsync_end, vtotal, vscan; 110 111 __u32 vrefresh; 112 113 __u32 flags; 114 __u32 type; 115 char name[DRM_DISPLAY_MODE_LEN]; 116 }; 117 118 struct drm_mode_card_res { 119 __u64 fb_id_ptr; 120 __u64 crtc_id_ptr; 121 __u64 connector_id_ptr; 122 __u64 encoder_id_ptr; 123 __u32 count_fbs; 124 __u32 count_crtcs; 125 __u32 count_connectors; 126 __u32 count_encoders; 127 __u32 min_width, max_width; 128 __u32 min_height, max_height; 129 }; 130 131 struct drm_mode_crtc { 132 __u64 set_connectors_ptr; 133 __u32 count_connectors; 134 135 __u32 crtc_id; /**< Id */ 136 __u32 fb_id; /**< Id of framebuffer */ 137 138 __u32 x, y; /**< Position on the frameuffer */ 139 140 __u32 gamma_size; 141 __u32 mode_valid; 142 struct drm_mode_modeinfo mode; 143 }; 144 145 #define DRM_MODE_PRESENT_TOP_FIELD (1<<0) 146 #define DRM_MODE_PRESENT_BOTTOM_FIELD (1<<1) 147 148 /* Planes blend with or override other bits on the CRTC */ 149 struct drm_mode_set_plane { 150 __u32 plane_id; 151 __u32 crtc_id; 152 __u32 fb_id; /* fb object contains surface format type */ 153 __u32 flags; /* see above flags */ 154 155 /* Signed dest location allows it to be partially off screen */ 156 __s32 crtc_x, crtc_y; 157 __u32 crtc_w, crtc_h; 158 159 /* Source values are 16.16 fixed point */ 160 __u32 src_x, src_y; 161 __u32 src_h, src_w; 162 }; 163 164 struct drm_mode_get_plane { 165 __u32 plane_id; 166 167 __u32 crtc_id; 168 __u32 fb_id; 169 170 __u32 possible_crtcs; 171 __u32 gamma_size; 172 173 __u32 count_format_types; 174 __u64 format_type_ptr; 175 }; 176 177 struct drm_mode_get_plane_res { 178 __u64 plane_id_ptr; 179 __u32 count_planes; 180 }; 181 182 #define DRM_MODE_ENCODER_NONE 0 183 #define DRM_MODE_ENCODER_DAC 1 184 #define DRM_MODE_ENCODER_TMDS 2 185 #define DRM_MODE_ENCODER_LVDS 3 186 #define DRM_MODE_ENCODER_TVDAC 4 187 #define DRM_MODE_ENCODER_VIRTUAL 5 188 #define DRM_MODE_ENCODER_DSI 6 189 #define DRM_MODE_ENCODER_DPMST 7 190 191 struct drm_mode_get_encoder { 192 __u32 encoder_id; 193 __u32 encoder_type; 194 195 __u32 crtc_id; /**< Id of crtc */ 196 197 __u32 possible_crtcs; 198 __u32 possible_clones; 199 }; 200 201 /* This is for connectors with multiple signal types. */ 202 /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */ 203 #define DRM_MODE_SUBCONNECTOR_Automatic 0 204 #define DRM_MODE_SUBCONNECTOR_Unknown 0 205 #define DRM_MODE_SUBCONNECTOR_DVID 3 206 #define DRM_MODE_SUBCONNECTOR_DVIA 4 207 #define DRM_MODE_SUBCONNECTOR_Composite 5 208 #define DRM_MODE_SUBCONNECTOR_SVIDEO 6 209 #define DRM_MODE_SUBCONNECTOR_Component 8 210 #define DRM_MODE_SUBCONNECTOR_SCART 9 211 212 #define DRM_MODE_CONNECTOR_Unknown 0 213 #define DRM_MODE_CONNECTOR_VGA 1 214 #define DRM_MODE_CONNECTOR_DVII 2 215 #define DRM_MODE_CONNECTOR_DVID 3 216 #define DRM_MODE_CONNECTOR_DVIA 4 217 #define DRM_MODE_CONNECTOR_Composite 5 218 #define DRM_MODE_CONNECTOR_SVIDEO 6 219 #define DRM_MODE_CONNECTOR_LVDS 7 220 #define DRM_MODE_CONNECTOR_Component 8 221 #define DRM_MODE_CONNECTOR_9PinDIN 9 222 #define DRM_MODE_CONNECTOR_DisplayPort 10 223 #define DRM_MODE_CONNECTOR_HDMIA 11 224 #define DRM_MODE_CONNECTOR_HDMIB 12 225 #define DRM_MODE_CONNECTOR_TV 13 226 #define DRM_MODE_CONNECTOR_eDP 14 227 #define DRM_MODE_CONNECTOR_VIRTUAL 15 228 #define DRM_MODE_CONNECTOR_DSI 16 229 230 struct drm_mode_get_connector { 231 232 __u64 encoders_ptr; 233 __u64 modes_ptr; 234 __u64 props_ptr; 235 __u64 prop_values_ptr; 236 237 __u32 count_modes; 238 __u32 count_props; 239 __u32 count_encoders; 240 241 __u32 encoder_id; /**< Current Encoder */ 242 __u32 connector_id; /**< Id */ 243 __u32 connector_type; 244 __u32 connector_type_id; 245 246 __u32 connection; 247 __u32 mm_width, mm_height; /**< HxW in millimeters */ 248 __u32 subpixel; 249 250 __u32 pad; 251 }; 252 253 #define DRM_MODE_PROP_PENDING (1<<0) 254 #define DRM_MODE_PROP_RANGE (1<<1) 255 #define DRM_MODE_PROP_IMMUTABLE (1<<2) 256 #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */ 257 #define DRM_MODE_PROP_BLOB (1<<4) 258 #define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */ 259 260 /* non-extended types: legacy bitmask, one bit per type: */ 261 #define DRM_MODE_PROP_LEGACY_TYPE ( \ 262 DRM_MODE_PROP_RANGE | \ 263 DRM_MODE_PROP_ENUM | \ 264 DRM_MODE_PROP_BLOB | \ 265 DRM_MODE_PROP_BITMASK) 266 267 /* extended-types: rather than continue to consume a bit per type, 268 * grab a chunk of the bits to use as integer type id. 269 */ 270 #define DRM_MODE_PROP_EXTENDED_TYPE 0x0000ffc0 271 #define DRM_MODE_PROP_TYPE(n) ((n) << 6) 272 #define DRM_MODE_PROP_OBJECT DRM_MODE_PROP_TYPE(1) 273 #define DRM_MODE_PROP_SIGNED_RANGE DRM_MODE_PROP_TYPE(2) 274 275 struct drm_mode_property_enum { 276 __u64 value; 277 char name[DRM_PROP_NAME_LEN]; 278 }; 279 280 struct drm_mode_get_property { 281 __u64 values_ptr; /* values and blob lengths */ 282 __u64 enum_blob_ptr; /* enum and blob id ptrs */ 283 284 __u32 prop_id; 285 __u32 flags; 286 char name[DRM_PROP_NAME_LEN]; 287 288 __u32 count_values; 289 __u32 count_enum_blobs; 290 }; 291 292 struct drm_mode_connector_set_property { 293 __u64 value; 294 __u32 prop_id; 295 __u32 connector_id; 296 }; 297 298 struct drm_mode_obj_get_properties { 299 __u64 props_ptr; 300 __u64 prop_values_ptr; 301 __u32 count_props; 302 __u32 obj_id; 303 __u32 obj_type; 304 }; 305 306 struct drm_mode_obj_set_property { 307 __u64 value; 308 __u32 prop_id; 309 __u32 obj_id; 310 __u32 obj_type; 311 }; 312 313 struct drm_mode_get_blob { 314 __u32 blob_id; 315 __u32 length; 316 __u64 data; 317 }; 318 319 struct drm_mode_fb_cmd { 320 __u32 fb_id; 321 __u32 width, height; 322 __u32 pitch; 323 __u32 bpp; 324 __u32 depth; 325 /* driver specific handle */ 326 __u32 handle; 327 }; 328 329 #define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */ 330 331 struct drm_mode_fb_cmd2 { 332 __u32 fb_id; 333 __u32 width, height; 334 __u32 pixel_format; /* fourcc code from drm_fourcc.h */ 335 __u32 flags; /* see above flags */ 336 337 /* 338 * In case of planar formats, this ioctl allows up to 4 339 * buffer objects with offets and pitches per plane. 340 * The pitch and offset order is dictated by the fourcc, 341 * e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as: 342 * 343 * YUV 4:2:0 image with a plane of 8 bit Y samples 344 * followed by an interleaved U/V plane containing 345 * 8 bit 2x2 subsampled colour difference samples. 346 * 347 * So it would consist of Y as offset[0] and UV as 348 * offeset[1]. Note that offset[0] will generally 349 * be 0. 350 */ 351 __u32 handles[4]; 352 __u32 pitches[4]; /* pitch for each plane */ 353 __u32 offsets[4]; /* offset of each plane */ 354 }; 355 356 #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01 357 #define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02 358 #define DRM_MODE_FB_DIRTY_FLAGS 0x03 359 360 #define DRM_MODE_FB_DIRTY_MAX_CLIPS 256 361 362 /* 363 * Mark a region of a framebuffer as dirty. 364 * 365 * Some hardware does not automatically update display contents 366 * as a hardware or software draw to a framebuffer. This ioctl 367 * allows userspace to tell the kernel and the hardware what 368 * regions of the framebuffer have changed. 369 * 370 * The kernel or hardware is free to update more then just the 371 * region specified by the clip rects. The kernel or hardware 372 * may also delay and/or coalesce several calls to dirty into a 373 * single update. 374 * 375 * Userspace may annotate the updates, the annotates are a 376 * promise made by the caller that the change is either a copy 377 * of pixels or a fill of a single color in the region specified. 378 * 379 * If the DRM_MODE_FB_DIRTY_ANNOTATE_COPY flag is given then 380 * the number of updated regions are half of num_clips given, 381 * where the clip rects are paired in src and dst. The width and 382 * height of each one of the pairs must match. 383 * 384 * If the DRM_MODE_FB_DIRTY_ANNOTATE_FILL flag is given the caller 385 * promises that the region specified of the clip rects is filled 386 * completely with a single color as given in the color argument. 387 */ 388 389 struct drm_mode_fb_dirty_cmd { 390 __u32 fb_id; 391 __u32 flags; 392 __u32 color; 393 __u32 num_clips; 394 __u64 clips_ptr; 395 }; 396 397 struct drm_mode_mode_cmd { 398 __u32 connector_id; 399 struct drm_mode_modeinfo mode; 400 }; 401 402 #define DRM_MODE_CURSOR_BO 0x01 403 #define DRM_MODE_CURSOR_MOVE 0x02 404 #define DRM_MODE_CURSOR_FLAGS 0x03 405 406 /* 407 * depending on the value in flags different members are used. 408 * 409 * CURSOR_BO uses 410 * crtc_id 411 * width 412 * height 413 * handle - if 0 turns the cursor off 414 * 415 * CURSOR_MOVE uses 416 * crtc_id 417 * x 418 * y 419 */ 420 struct drm_mode_cursor { 421 __u32 flags; 422 __u32 crtc_id; 423 __s32 x; 424 __s32 y; 425 __u32 width; 426 __u32 height; 427 /* driver specific handle */ 428 __u32 handle; 429 }; 430 431 struct drm_mode_cursor2 { 432 __u32 flags; 433 __u32 crtc_id; 434 __s32 x; 435 __s32 y; 436 __u32 width; 437 __u32 height; 438 /* driver specific handle */ 439 __u32 handle; 440 __s32 hot_x; 441 __s32 hot_y; 442 }; 443 444 struct drm_mode_crtc_lut { 445 __u32 crtc_id; 446 __u32 gamma_size; 447 448 /* pointers to arrays */ 449 __u64 red; 450 __u64 green; 451 __u64 blue; 452 }; 453 454 #define DRM_MODE_PAGE_FLIP_EVENT 0x01 455 #define DRM_MODE_PAGE_FLIP_ASYNC 0x02 456 #define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT|DRM_MODE_PAGE_FLIP_ASYNC) 457 458 /* 459 * Request a page flip on the specified crtc. 460 * 461 * This ioctl will ask KMS to schedule a page flip for the specified 462 * crtc. Once any pending rendering targeting the specified fb (as of 463 * ioctl time) has completed, the crtc will be reprogrammed to display 464 * that fb after the next vertical refresh. The ioctl returns 465 * immediately, but subsequent rendering to the current fb will block 466 * in the execbuffer ioctl until the page flip happens. If a page 467 * flip is already pending as the ioctl is called, EBUSY will be 468 * returned. 469 * 470 * Flag DRM_MODE_PAGE_FLIP_EVENT requests that drm sends back a vblank 471 * event (see drm.h: struct drm_event_vblank) when the page flip is 472 * done. The user_data field passed in with this ioctl will be 473 * returned as the user_data field in the vblank event struct. 474 * 475 * Flag DRM_MODE_PAGE_FLIP_ASYNC requests that the flip happen 476 * 'as soon as possible', meaning that it not delay waiting for vblank. 477 * This may cause tearing on the screen. 478 * 479 * The reserved field must be zero until we figure out something 480 * clever to use it for. 481 */ 482 483 struct drm_mode_crtc_page_flip { 484 __u32 crtc_id; 485 __u32 fb_id; 486 __u32 flags; 487 __u32 reserved; 488 __u64 user_data; 489 }; 490 491 /* create a dumb scanout buffer */ 492 struct drm_mode_create_dumb { 493 uint32_t height; 494 uint32_t width; 495 uint32_t bpp; 496 uint32_t flags; 497 /* handle, pitch, size will be returned */ 498 uint32_t handle; 499 uint32_t pitch; 500 uint64_t size; 501 }; 502 503 /* set up for mmap of a dumb scanout buffer */ 504 struct drm_mode_map_dumb { 505 /** Handle for the object being mapped. */ 506 __u32 handle; 507 __u32 pad; 508 /** 509 * Fake offset to use for subsequent mmap call 510 * 511 * This is a fixed-size type for 32/64 compatibility. 512 */ 513 __u64 offset; 514 }; 515 516 struct drm_mode_destroy_dumb { 517 uint32_t handle; 518 }; 519 520 #endif -
src/add-ons/kernel/drivers/graphics/Jamfile
diff --git a/headers/private/graphics/3dfx/DriverInterface.h b/headers/private/graphics/legacy/3dfx/DriverInterface.h similarity index 100% rename from headers/private/graphics/3dfx/DriverInterface.h rename to headers/private/graphics/legacy/3dfx/DriverInterface.h diff --git a/headers/private/graphics/AGP.h b/headers/private/graphics/legacy/AGP.h similarity index 100% rename from headers/private/graphics/AGP.h rename to headers/private/graphics/legacy/AGP.h diff --git a/headers/private/graphics/ati/DriverInterface.h b/headers/private/graphics/legacy/ati/DriverInterface.h similarity index 100% rename from headers/private/graphics/ati/DriverInterface.h rename to headers/private/graphics/legacy/ati/DriverInterface.h diff --git a/headers/private/graphics/common/benaphore.h b/headers/private/graphics/legacy/common/benaphore.h similarity index 100% rename from headers/private/graphics/common/benaphore.h rename to headers/private/graphics/legacy/common/benaphore.h diff --git a/headers/private/graphics/common/bendian_bitfield.h b/headers/private/graphics/legacy/common/bendian_bitfield.h similarity index 100% rename from headers/private/graphics/common/bendian_bitfield.h rename to headers/private/graphics/legacy/common/bendian_bitfield.h diff --git a/headers/private/graphics/common/compute_display_timing.h b/headers/private/graphics/legacy/common/compute_display_timing.h similarity index 100% rename from headers/private/graphics/common/compute_display_timing.h rename to headers/private/graphics/legacy/common/compute_display_timing.h diff --git a/headers/private/graphics/common/create_display_modes.h b/headers/private/graphics/legacy/common/create_display_modes.h similarity index 100% rename from headers/private/graphics/common/create_display_modes.h rename to headers/private/graphics/legacy/common/create_display_modes.h diff --git a/headers/private/graphics/common/ddc.h b/headers/private/graphics/legacy/common/ddc.h similarity index 100% rename from headers/private/graphics/common/ddc.h rename to headers/private/graphics/legacy/common/ddc.h diff --git a/headers/private/graphics/common/debug_ext.h b/headers/private/graphics/legacy/common/debug_ext.h similarity index 100% rename from headers/private/graphics/common/debug_ext.h rename to headers/private/graphics/legacy/common/debug_ext.h diff --git a/headers/private/graphics/common/dp.h b/headers/private/graphics/legacy/common/dp.h similarity index 100% rename from headers/private/graphics/common/dp.h rename to headers/private/graphics/legacy/common/dp.h diff --git a/headers/private/graphics/common/dp_raw.h b/headers/private/graphics/legacy/common/dp_raw.h similarity index 100% rename from headers/private/graphics/common/dp_raw.h rename to headers/private/graphics/legacy/common/dp_raw.h diff --git a/headers/private/graphics/common/edid.h b/headers/private/graphics/legacy/common/edid.h similarity index 100% rename from headers/private/graphics/common/edid.h rename to headers/private/graphics/legacy/common/edid.h diff --git a/headers/private/graphics/common/edid_raw.h b/headers/private/graphics/legacy/common/edid_raw.h similarity index 100% rename from headers/private/graphics/common/edid_raw.h rename to headers/private/graphics/legacy/common/edid_raw.h diff --git a/headers/private/graphics/common/i2c.h b/headers/private/graphics/legacy/common/i2c.h similarity index 100% rename from headers/private/graphics/common/i2c.h rename to headers/private/graphics/legacy/common/i2c.h diff --git a/headers/private/graphics/common/lendian_bitfield.h b/headers/private/graphics/legacy/common/lendian_bitfield.h similarity index 100% rename from headers/private/graphics/common/lendian_bitfield.h rename to headers/private/graphics/legacy/common/lendian_bitfield.h diff --git a/headers/private/graphics/common/log_coll.h b/headers/private/graphics/legacy/common/log_coll.h similarity index 100% rename from headers/private/graphics/common/log_coll.h rename to headers/private/graphics/legacy/common/log_coll.h diff --git a/headers/private/graphics/common/memory_manager.h b/headers/private/graphics/legacy/common/memory_manager.h similarity index 100% rename from headers/private/graphics/common/memory_manager.h rename to headers/private/graphics/legacy/common/memory_manager.h diff --git a/headers/private/graphics/common/validate_display_mode.h b/headers/private/graphics/legacy/common/validate_display_mode.h similarity index 100% rename from headers/private/graphics/common/validate_display_mode.h rename to headers/private/graphics/legacy/common/validate_display_mode.h diff --git a/headers/private/graphics/common/video_configuration.h b/headers/private/graphics/legacy/common/video_configuration.h similarity index 100% rename from headers/private/graphics/common/video_configuration.h rename to headers/private/graphics/legacy/common/video_configuration.h diff --git a/headers/private/graphics/et6x00/DriverInterface.h b/headers/private/graphics/legacy/et6x00/DriverInterface.h similarity index 100% rename from headers/private/graphics/et6x00/DriverInterface.h rename to headers/private/graphics/legacy/et6x00/DriverInterface.h diff --git a/headers/private/graphics/intel_810/DriverInterface.h b/headers/private/graphics/legacy/intel_810/DriverInterface.h similarity index 100% rename from headers/private/graphics/intel_810/DriverInterface.h rename to headers/private/graphics/legacy/intel_810/DriverInterface.h diff --git a/headers/private/graphics/intel_extreme/AreaKeeper.h b/headers/private/graphics/legacy/intel_extreme/AreaKeeper.h similarity index 100% rename from headers/private/graphics/intel_extreme/AreaKeeper.h rename to headers/private/graphics/legacy/intel_extreme/AreaKeeper.h diff --git a/headers/private/graphics/intel_extreme/intel_extreme.h b/headers/private/graphics/legacy/intel_extreme/intel_extreme.h similarity index 100% rename from headers/private/graphics/intel_extreme/intel_extreme.h rename to headers/private/graphics/legacy/intel_extreme/intel_extreme.h diff --git a/headers/private/graphics/intel_extreme/lock.h b/headers/private/graphics/legacy/intel_extreme/lock.h similarity index 100% rename from headers/private/graphics/intel_extreme/lock.h rename to headers/private/graphics/legacy/intel_extreme/lock.h diff --git a/headers/private/graphics/intel_extreme/utility.h b/headers/private/graphics/legacy/intel_extreme/utility.h similarity index 100% rename from headers/private/graphics/intel_extreme/utility.h rename to headers/private/graphics/legacy/intel_extreme/utility.h diff --git a/headers/private/graphics/matrox/DriverInterface.h b/headers/private/graphics/legacy/matrox/DriverInterface.h similarity index 100% rename from headers/private/graphics/matrox/DriverInterface.h rename to headers/private/graphics/legacy/matrox/DriverInterface.h diff --git a/headers/private/graphics/matrox/mga_macros.h b/headers/private/graphics/legacy/matrox/mga_macros.h similarity index 100% rename from headers/private/graphics/matrox/mga_macros.h rename to headers/private/graphics/legacy/matrox/mga_macros.h diff --git a/headers/private/graphics/neomagic/DriverInterface.h b/headers/private/graphics/legacy/neomagic/DriverInterface.h similarity index 100% rename from headers/private/graphics/neomagic/DriverInterface.h rename to headers/private/graphics/legacy/neomagic/DriverInterface.h diff --git a/headers/private/graphics/neomagic/nm_macros.h b/headers/private/graphics/legacy/neomagic/nm_macros.h similarity index 100% rename from headers/private/graphics/neomagic/nm_macros.h rename to headers/private/graphics/legacy/neomagic/nm_macros.h diff --git a/headers/private/graphics/nvidia/DriverInterface.h b/headers/private/graphics/legacy/nvidia/DriverInterface.h similarity index 100% rename from headers/private/graphics/nvidia/DriverInterface.h rename to headers/private/graphics/legacy/nvidia/DriverInterface.h diff --git a/headers/private/graphics/nvidia/nv_acc.h b/headers/private/graphics/legacy/nvidia/nv_acc.h similarity index 100% rename from headers/private/graphics/nvidia/nv_acc.h rename to headers/private/graphics/legacy/nvidia/nv_acc.h diff --git a/headers/private/graphics/nvidia/nv_macros.h b/headers/private/graphics/legacy/nvidia/nv_macros.h similarity index 100% rename from headers/private/graphics/nvidia/nv_macros.h rename to headers/private/graphics/legacy/nvidia/nv_macros.h diff --git a/headers/private/graphics/nvidia_gpgpu/DriverInterface.h b/headers/private/graphics/legacy/nvidia_gpgpu/DriverInterface.h similarity index 100% rename from headers/private/graphics/nvidia_gpgpu/DriverInterface.h rename to headers/private/graphics/legacy/nvidia_gpgpu/DriverInterface.h diff --git a/headers/private/graphics/nvidia_gpgpu/nv_acc.h b/headers/private/graphics/legacy/nvidia_gpgpu/nv_acc.h similarity index 100% rename from headers/private/graphics/nvidia_gpgpu/nv_acc.h rename to headers/private/graphics/legacy/nvidia_gpgpu/nv_acc.h diff --git a/headers/private/graphics/nvidia_gpgpu/nv_macros.h b/headers/private/graphics/legacy/nvidia_gpgpu/nv_macros.h similarity index 100% rename from headers/private/graphics/nvidia_gpgpu/nv_macros.h rename to headers/private/graphics/legacy/nvidia_gpgpu/nv_macros.h diff --git a/headers/private/graphics/omap/omap3_regs.h b/headers/private/graphics/legacy/omap/omap3_regs.h similarity index 100% rename from headers/private/graphics/omap/omap3_regs.h rename to headers/private/graphics/legacy/omap/omap3_regs.h diff --git a/headers/private/graphics/radeon/2d_regs.h b/headers/private/graphics/legacy/radeon/2d_regs.h similarity index 100% rename from headers/private/graphics/radeon/2d_regs.h rename to headers/private/graphics/legacy/radeon/2d_regs.h diff --git a/headers/private/graphics/radeon/3d_regs.h b/headers/private/graphics/legacy/radeon/3d_regs.h similarity index 100% rename from headers/private/graphics/radeon/3d_regs.h rename to headers/private/graphics/legacy/radeon/3d_regs.h diff --git a/headers/private/graphics/radeon/accelerant_ext.h b/headers/private/graphics/legacy/radeon/accelerant_ext.h similarity index 100% rename from headers/private/graphics/radeon/accelerant_ext.h rename to headers/private/graphics/legacy/radeon/accelerant_ext.h diff --git a/headers/private/graphics/radeon/bios_regs.h b/headers/private/graphics/legacy/radeon/bios_regs.h similarity index 100% rename from headers/private/graphics/radeon/bios_regs.h rename to headers/private/graphics/legacy/radeon/bios_regs.h diff --git a/headers/private/graphics/radeon/buscntrl_regs.h b/headers/private/graphics/legacy/radeon/buscntrl_regs.h similarity index 100% rename from headers/private/graphics/radeon/buscntrl_regs.h rename to headers/private/graphics/legacy/radeon/buscntrl_regs.h diff --git a/headers/private/graphics/radeon/capture_regs.h b/headers/private/graphics/legacy/radeon/capture_regs.h similarity index 100% rename from headers/private/graphics/radeon/capture_regs.h rename to headers/private/graphics/legacy/radeon/capture_regs.h diff --git a/headers/private/graphics/radeon/config_regs.h b/headers/private/graphics/legacy/radeon/config_regs.h similarity index 100% rename from headers/private/graphics/radeon/config_regs.h rename to headers/private/graphics/legacy/radeon/config_regs.h diff --git a/headers/private/graphics/radeon/cp_regs.h b/headers/private/graphics/legacy/radeon/cp_regs.h similarity index 100% rename from headers/private/graphics/radeon/cp_regs.h rename to headers/private/graphics/legacy/radeon/cp_regs.h diff --git a/headers/private/graphics/radeon/crtc_regs.h b/headers/private/graphics/legacy/radeon/crtc_regs.h similarity index 100% rename from headers/private/graphics/radeon/crtc_regs.h rename to headers/private/graphics/legacy/radeon/crtc_regs.h diff --git a/headers/private/graphics/radeon/dac_regs.h b/headers/private/graphics/legacy/radeon/dac_regs.h similarity index 100% rename from headers/private/graphics/radeon/dac_regs.h rename to headers/private/graphics/legacy/radeon/dac_regs.h diff --git a/headers/private/graphics/radeon/ddc_regs.h b/headers/private/graphics/legacy/radeon/ddc_regs.h similarity index 100% rename from headers/private/graphics/radeon/ddc_regs.h rename to headers/private/graphics/legacy/radeon/ddc_regs.h diff --git a/headers/private/graphics/radeon/dma_regs.h b/headers/private/graphics/legacy/radeon/dma_regs.h similarity index 100% rename from headers/private/graphics/radeon/dma_regs.h rename to headers/private/graphics/legacy/radeon/dma_regs.h diff --git a/headers/private/graphics/radeon/fp_regs.h b/headers/private/graphics/legacy/radeon/fp_regs.h similarity index 100% rename from headers/private/graphics/radeon/fp_regs.h rename to headers/private/graphics/legacy/radeon/fp_regs.h diff --git a/headers/private/graphics/radeon/gpiopad_regs.h b/headers/private/graphics/legacy/radeon/gpiopad_regs.h similarity index 100% rename from headers/private/graphics/radeon/gpiopad_regs.h rename to headers/private/graphics/legacy/radeon/gpiopad_regs.h diff --git a/headers/private/graphics/radeon/log_enum.h b/headers/private/graphics/legacy/radeon/log_enum.h similarity index 100% rename from headers/private/graphics/radeon/log_enum.h rename to headers/private/graphics/legacy/radeon/log_enum.h diff --git a/headers/private/graphics/radeon/log_names.h b/headers/private/graphics/legacy/radeon/log_names.h similarity index 100% rename from headers/private/graphics/radeon/log_names.h rename to headers/private/graphics/legacy/radeon/log_names.h diff --git a/headers/private/graphics/radeon/memcntrl_regs.h b/headers/private/graphics/legacy/radeon/memcntrl_regs.h similarity index 100% rename from headers/private/graphics/radeon/memcntrl_regs.h rename to headers/private/graphics/legacy/radeon/memcntrl_regs.h diff --git a/headers/private/graphics/radeon/mmio.h b/headers/private/graphics/legacy/radeon/mmio.h similarity index 100% rename from headers/private/graphics/radeon/mmio.h rename to headers/private/graphics/legacy/radeon/mmio.h diff --git a/headers/private/graphics/radeon/multimon.h b/headers/private/graphics/legacy/radeon/multimon.h similarity index 100% rename from headers/private/graphics/radeon/multimon.h rename to headers/private/graphics/legacy/radeon/multimon.h diff --git a/headers/private/graphics/radeon/overlay_regs.h b/headers/private/graphics/legacy/radeon/overlay_regs.h similarity index 100% rename from headers/private/graphics/radeon/overlay_regs.h rename to headers/private/graphics/legacy/radeon/overlay_regs.h diff --git a/headers/private/graphics/radeon/pll_access.h b/headers/private/graphics/legacy/radeon/pll_access.h similarity index 100% rename from headers/private/graphics/radeon/pll_access.h rename to headers/private/graphics/legacy/radeon/pll_access.h diff --git a/headers/private/graphics/radeon/pll_regs.h b/headers/private/graphics/legacy/radeon/pll_regs.h similarity index 100% rename from headers/private/graphics/radeon/pll_regs.h rename to headers/private/graphics/legacy/radeon/pll_regs.h diff --git a/headers/private/graphics/radeon/radeon_bios.h b/headers/private/graphics/legacy/radeon/radeon_bios.h similarity index 100% rename from headers/private/graphics/radeon/radeon_bios.h rename to headers/private/graphics/legacy/radeon/radeon_bios.h diff --git a/headers/private/graphics/radeon/radeon_interface.h b/headers/private/graphics/legacy/radeon/radeon_interface.h similarity index 100% rename from headers/private/graphics/radeon/radeon_interface.h rename to headers/private/graphics/legacy/radeon/radeon_interface.h diff --git a/headers/private/graphics/radeon/radeon_regs.h b/headers/private/graphics/legacy/radeon/radeon_regs.h similarity index 100% rename from headers/private/graphics/radeon/radeon_regs.h rename to headers/private/graphics/legacy/radeon/radeon_regs.h diff --git a/headers/private/graphics/radeon/rbbm_regs.h b/headers/private/graphics/legacy/radeon/rbbm_regs.h similarity index 100% rename from headers/private/graphics/radeon/rbbm_regs.h rename to headers/private/graphics/legacy/radeon/rbbm_regs.h diff --git a/headers/private/graphics/radeon/theatre_regs.h b/headers/private/graphics/legacy/radeon/theatre_regs.h similarity index 100% rename from headers/private/graphics/radeon/theatre_regs.h rename to headers/private/graphics/legacy/radeon/theatre_regs.h diff --git a/headers/private/graphics/radeon/tv_out_regs.h b/headers/private/graphics/legacy/radeon/tv_out_regs.h similarity index 100% rename from headers/private/graphics/radeon/tv_out_regs.h rename to headers/private/graphics/legacy/radeon/tv_out_regs.h diff --git a/headers/private/graphics/radeon/utils.h b/headers/private/graphics/legacy/radeon/utils.h similarity index 100% rename from headers/private/graphics/radeon/utils.h rename to headers/private/graphics/legacy/radeon/utils.h diff --git a/headers/private/graphics/radeon/version.h b/headers/private/graphics/legacy/radeon/version.h similarity index 100% rename from headers/private/graphics/radeon/version.h rename to headers/private/graphics/legacy/radeon/version.h diff --git a/headers/private/graphics/radeon/vip_regs.h b/headers/private/graphics/legacy/radeon/vip_regs.h similarity index 100% rename from headers/private/graphics/radeon/vip_regs.h rename to headers/private/graphics/legacy/radeon/vip_regs.h diff --git a/headers/private/graphics/radeon_hd/AreaKeeper.h b/headers/private/graphics/legacy/radeon_hd/AreaKeeper.h similarity index 100% rename from headers/private/graphics/radeon_hd/AreaKeeper.h rename to headers/private/graphics/legacy/radeon_hd/AreaKeeper.h diff --git a/headers/private/graphics/radeon_hd/avivo_reg.h b/headers/private/graphics/legacy/radeon_hd/avivo_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/avivo_reg.h rename to headers/private/graphics/legacy/radeon_hd/avivo_reg.h diff --git a/headers/private/graphics/radeon_hd/car_reg.h b/headers/private/graphics/legacy/radeon_hd/car_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/car_reg.h rename to headers/private/graphics/legacy/radeon_hd/car_reg.h diff --git a/headers/private/graphics/radeon_hd/evergreen_reg.h b/headers/private/graphics/legacy/radeon_hd/evergreen_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/evergreen_reg.h rename to headers/private/graphics/legacy/radeon_hd/evergreen_reg.h diff --git a/headers/private/graphics/radeon_hd/lock.h b/headers/private/graphics/legacy/radeon_hd/lock.h similarity index 100% rename from headers/private/graphics/radeon_hd/lock.h rename to headers/private/graphics/legacy/radeon_hd/lock.h diff --git a/headers/private/graphics/radeon_hd/ni_reg.h b/headers/private/graphics/legacy/radeon_hd/ni_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/ni_reg.h rename to headers/private/graphics/legacy/radeon_hd/ni_reg.h diff --git a/headers/private/graphics/radeon_hd/r500_reg.h b/headers/private/graphics/legacy/radeon_hd/r500_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/r500_reg.h rename to headers/private/graphics/legacy/radeon_hd/r500_reg.h diff --git a/headers/private/graphics/radeon_hd/r600_reg.h b/headers/private/graphics/legacy/radeon_hd/r600_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/r600_reg.h rename to headers/private/graphics/legacy/radeon_hd/r600_reg.h diff --git a/headers/private/graphics/radeon_hd/r700_reg.h b/headers/private/graphics/legacy/radeon_hd/r700_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/r700_reg.h rename to headers/private/graphics/legacy/radeon_hd/r700_reg.h diff --git a/headers/private/graphics/radeon_hd/radeon_hd.h b/headers/private/graphics/legacy/radeon_hd/radeon_hd.h similarity index 100% rename from headers/private/graphics/radeon_hd/radeon_hd.h rename to headers/private/graphics/legacy/radeon_hd/radeon_hd.h diff --git a/headers/private/graphics/radeon_hd/radeon_reg.h b/headers/private/graphics/legacy/radeon_hd/radeon_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/radeon_reg.h rename to headers/private/graphics/legacy/radeon_hd/radeon_reg.h diff --git a/headers/private/graphics/radeon_hd/sea_reg.h b/headers/private/graphics/legacy/radeon_hd/sea_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/sea_reg.h rename to headers/private/graphics/legacy/radeon_hd/sea_reg.h diff --git a/headers/private/graphics/radeon_hd/si_reg.h b/headers/private/graphics/legacy/radeon_hd/si_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/si_reg.h rename to headers/private/graphics/legacy/radeon_hd/si_reg.h diff --git a/headers/private/graphics/radeon_hd/utility.h b/headers/private/graphics/legacy/radeon_hd/utility.h similarity index 100% rename from headers/private/graphics/radeon_hd/utility.h rename to headers/private/graphics/legacy/radeon_hd/utility.h diff --git a/headers/private/graphics/radeon_hd/vol_reg.h b/headers/private/graphics/legacy/radeon_hd/vol_reg.h similarity index 100% rename from headers/private/graphics/radeon_hd/vol_reg.h rename to headers/private/graphics/legacy/radeon_hd/vol_reg.h diff --git a/headers/private/graphics/s3/DriverInterface.h b/headers/private/graphics/legacy/s3/DriverInterface.h similarity index 100% rename from headers/private/graphics/s3/DriverInterface.h rename to headers/private/graphics/legacy/s3/DriverInterface.h diff --git a/headers/private/graphics/skeleton/DriverInterface.h b/headers/private/graphics/legacy/skeleton/DriverInterface.h similarity index 100% rename from headers/private/graphics/skeleton/DriverInterface.h rename to headers/private/graphics/legacy/skeleton/DriverInterface.h diff --git a/headers/private/graphics/skeleton/macros.h b/headers/private/graphics/legacy/skeleton/macros.h similarity index 100% rename from headers/private/graphics/skeleton/macros.h rename to headers/private/graphics/legacy/skeleton/macros.h diff --git a/headers/private/graphics/vesa/utility.h b/headers/private/graphics/legacy/vesa/utility.h similarity index 100% rename from headers/private/graphics/vesa/utility.h rename to headers/private/graphics/legacy/vesa/utility.h diff --git a/headers/private/graphics/vesa/vesa.h b/headers/private/graphics/legacy/vesa/vesa.h similarity index 100% rename from headers/private/graphics/vesa/vesa.h rename to headers/private/graphics/legacy/vesa/vesa.h diff --git a/headers/private/graphics/vesa/vesa_info.h b/headers/private/graphics/legacy/vesa/vesa_info.h similarity index 100% rename from headers/private/graphics/vesa/vesa_info.h rename to headers/private/graphics/legacy/vesa/vesa_info.h diff --git a/headers/private/graphics/vesa/vga.h b/headers/private/graphics/legacy/vesa/vga.h similarity index 100% rename from headers/private/graphics/vesa/vga.h rename to headers/private/graphics/legacy/vesa/vga.h diff --git a/headers/private/graphics/via/DriverInterface.h b/headers/private/graphics/legacy/via/DriverInterface.h similarity index 100% rename from headers/private/graphics/via/DriverInterface.h rename to headers/private/graphics/legacy/via/DriverInterface.h diff --git a/headers/private/graphics/via/macros.h b/headers/private/graphics/legacy/via/macros.h similarity index 100% rename from headers/private/graphics/via/macros.h rename to headers/private/graphics/legacy/via/macros.h diff --git a/headers/private/graphics/video_overlay.h b/headers/private/graphics/legacy/video_overlay.h similarity index 100% rename from headers/private/graphics/video_overlay.h rename to headers/private/graphics/legacy/video_overlay.h diff --git a/headers/private/graphics/vmware/DriverInterface.h b/headers/private/graphics/legacy/vmware/DriverInterface.h similarity index 100% rename from headers/private/graphics/vmware/DriverInterface.h rename to headers/private/graphics/legacy/vmware/DriverInterface.h diff --git a/headers/private/graphics/vmware/svga_reg.h b/headers/private/graphics/legacy/vmware/svga_reg.h similarity index 100% rename from headers/private/graphics/vmware/svga_reg.h rename to headers/private/graphics/legacy/vmware/svga_reg.h diff --git a/headers/private/graphics/vmware/vm_device_version.h b/headers/private/graphics/legacy/vmware/vm_device_version.h similarity index 100% rename from headers/private/graphics/vmware/vm_device_version.h rename to headers/private/graphics/legacy/vmware/vm_device_version.h diff --git a/src/add-ons/kernel/drivers/graphics/Jamfile b/src/add-ons/kernel/drivers/graphics/Jamfile index f8881e30a6..3cb271cdc5 100644
a b 1 1 SubDir HAIKU_TOP src add-ons kernel drivers graphics ; 2 2 3 SubInclude HAIKU_TOP src add-ons kernel drivers graphics 3dfx ; 4 SubInclude HAIKU_TOP src add-ons kernel drivers graphics ati ; 5 SubInclude HAIKU_TOP src add-ons kernel drivers graphics common ; 6 SubInclude HAIKU_TOP src add-ons kernel drivers graphics et6x00 ; 7 SubInclude HAIKU_TOP src add-ons kernel drivers graphics framebuffer ; 8 SubInclude HAIKU_TOP src add-ons kernel drivers graphics intel_810 ; 9 SubInclude HAIKU_TOP src add-ons kernel drivers graphics intel_extreme ; 10 SubInclude HAIKU_TOP src add-ons kernel drivers graphics matrox ; 11 SubInclude HAIKU_TOP src add-ons kernel drivers graphics neomagic ; 12 SubInclude HAIKU_TOP src add-ons kernel drivers graphics nvidia ; 13 SubInclude HAIKU_TOP src add-ons kernel drivers graphics nvidia_gpgpu ; 14 SubInclude HAIKU_TOP src add-ons kernel drivers graphics radeon ; 15 SubInclude HAIKU_TOP src add-ons kernel drivers graphics radeon_hd ; 16 SubInclude HAIKU_TOP src add-ons kernel drivers graphics s3 ; 17 SubInclude HAIKU_TOP src add-ons kernel drivers graphics skeleton ; 18 SubInclude HAIKU_TOP src add-ons kernel drivers graphics vesa ; 19 SubInclude HAIKU_TOP src add-ons kernel drivers graphics via ; 3 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy ; 4 SubInclude HAIKU_TOP src add-ons kernel drivers graphics drm ; -
new file src/add-ons/kernel/drivers/graphics/drm/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/drm/Jamfile b/src/add-ons/kernel/drivers/graphics/drm/Jamfile new file mode 100644 index 0000000000..11ab5f915a
- + 1 SubDir HAIKU_TOP src add-ons kernel drivers graphics drm ; 2 3 UsePrivateHeaders [ FDirName graphics drm ] ; 4 UsePrivateHeaders [ FDirName graphics drm uapi ] ; 5 UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility linux ] : true ; 6 7 UsePrivateKernelHeaders ; 8 UseHeaders $(HAIKU_PRIVATE_KERNEL_HEADERS) : true ; 9 10 SubDirCcFlags [ FDefines _KERNEL=1 B_USE_POSITIVE_POSIX_ERRORS=1 __KERNEL__=1 ] ; 11 12 KernelAddon drm : 13 drm_auth.c # NOT Complete 14 # drm_bufs.c # NOT Complete 15 # drm_cache.c # NOT Complete 16 # drm_context.c # NOT Complete 17 # drm_dma.c # NOT Complete 18 # drm_fops.c # NOT Complete 19 # drm_gem.c # NOT Complete 20 # drm_ioctl.c # NOT Complete 21 # drm_irq.c # NOT Complete 22 # drm_lock.c # NOT Complete 23 # drm_memory.c # NOT Complete 24 # drm_drv.c # NOT Complete 25 # drm_scatter.c # NOT Complete 26 # drm_pci.c # NOT Complete 27 # drm_platform.c # NOT Complete 28 # drm_sysfs.c # NOT Complete 29 # drm_hashtab.c # NOT Complete 30 # drm_mm.c # NOT Complete 31 # drm_crtc.c # NOT Complete 32 # drm_fourcc.c # NOT Complete 33 # drm_modes.c # NOT Complete 34 # drm_edid.c # NOT Complete 35 # drm_info.c # NOT Complete 36 # drm_encoder_slave.c # NOT Complete 37 # drm_trace_points.c # NOT Complete 38 # drm_global.c # NOT Complete 39 # drm_prime.c # NOT Complete 40 # drm_rect.c # NOT Complete 41 # drm_vma_manager.c # NOT Complete 42 # drm_flip_work.c # NOT Complete 43 # drm_modeset_lock.c # NOT Complete 44 # drm_atomic.c # NOT Complete 45 # drm_bridge.c # NOT Complete 46 # drm_framebuffer.c # NOT Complete 47 # drm_connector.c # NOT Complete 48 # drm_blend.c # NOT Complete 49 # drm_encoder.c # NOT Complete 50 # drm_mode_object.c # NOT Complete 51 # drm_property.c # NOT Complete 52 # drm_plane.c # NOT Complete 53 # drm_color_mgmt.c # NOT Complete 54 # drm_print.c # NOT Complete 55 # drm_dumb_buffers.c # NOT Complete 56 # drm_mode_config.c # NOT Complete 57 ; -
new file src/add-ons/kernel/drivers/graphics/drm/drm_auth.c
diff --git a/src/add-ons/kernel/drivers/graphics/drm/drm_auth.c b/src/add-ons/kernel/drivers/graphics/drm/drm_auth.c new file mode 100644 index 0000000000..7ff697389d
- + 1 /* 2 * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com 3 * 4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 6 * All Rights Reserved. 7 * 8 * Author Rickard E. (Rik) Faith <faith@valinux.com> 9 * Author Gareth Hughes <gareth@valinux.com> 10 * 11 * Permission is hereby granted, free of charge, to any person obtaining a 12 * copy of this software and associated documentation files (the "Software"), 13 * to deal in the Software without restriction, including without limitation 14 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 * and/or sell copies of the Software, and to permit persons to whom the 16 * Software is furnished to do so, subject to the following conditions: 17 * 18 * The above copyright notice and this permission notice (including the next 19 * paragraph) shall be included in all copies or substantial portions of the 20 * Software. 21 * 22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 25 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 * OTHER DEALINGS IN THE SOFTWARE. 29 */ 30 31 #include <drm/drmP.h> 32 #include "drm_internal.h" 33 #include "drm_legacy.h" 34 35 /** 36 * DOC: master and authentication 37 * 38 * &struct drm_master is used to track groups of clients with open 39 * primary/legacy device nodes. For every &struct drm_file which has had at 40 * least once successfully became the device master (either through the 41 * SET_MASTER IOCTL, or implicitly through opening the primary device node when 42 * no one else is the current master that time) there exists one &drm_master. 43 * This is noted in &drm_file.is_master. All other clients have just a pointer 44 * to the &drm_master they are associated with. 45 * 46 * In addition only one &drm_master can be the current master for a &drm_device. 47 * It can be switched through the DROP_MASTER and SET_MASTER IOCTL, or 48 * implicitly through closing/openeing the primary device node. See also 49 * drm_is_current_master(). 50 * 51 * Clients can authenticate against the current master (if it matches their own) 52 * using the GETMAGIC and AUTHMAGIC IOCTLs. Together with exchanging masters, 53 * this allows controlled access to the device for an entire group of mutually 54 * trusted clients. 55 */ 56 57 int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv) 58 { 59 struct drm_auth *auth = data; 60 int ret = 0; 61 62 mutex_lock(&dev->master_mutex); 63 if (!file_priv->magic) { 64 ret = idr_alloc(&file_priv->master->magic_map, file_priv, 65 1, 0, GFP_KERNEL); 66 if (ret >= 0) 67 file_priv->magic = ret; 68 } 69 auth->magic = file_priv->magic; 70 mutex_unlock(&dev->master_mutex); 71 72 DRM_DEBUG("%u\n", auth->magic); 73 74 return ret < 0 ? ret : 0; 75 } 76 77 int drm_authmagic(struct drm_device *dev, void *data, 78 struct drm_file *file_priv) 79 { 80 struct drm_auth *auth = data; 81 struct drm_file *file; 82 83 DRM_DEBUG("%u\n", auth->magic); 84 85 mutex_lock(&dev->master_mutex); 86 file = idr_find(&file_priv->master->magic_map, auth->magic); 87 if (file) { 88 file->authenticated = 1; 89 idr_replace(&file_priv->master->magic_map, NULL, auth->magic); 90 } 91 mutex_unlock(&dev->master_mutex); 92 93 return file ? 0 : -EINVAL; 94 } 95 96 static struct drm_master *drm_master_create(struct drm_device *dev) 97 { 98 struct drm_master *master; 99 100 master = kzalloc(sizeof(*master), GFP_KERNEL); 101 if (!master) 102 return NULL; 103 104 kref_init(&master->refcount); 105 spin_lock_init(&master->lock.spinlock); 106 init_waitqueue_head(&master->lock.lock_queue); 107 idr_init(&master->magic_map); 108 master->dev = dev; 109 110 return master; 111 } 112 113 static int drm_set_master(struct drm_device *dev, struct drm_file *fpriv, 114 bool new_master) 115 { 116 int ret = 0; 117 118 dev->master = drm_master_get(fpriv->master); 119 if (dev->driver->master_set) { 120 ret = dev->driver->master_set(dev, fpriv, new_master); 121 if (unlikely(ret != 0)) { 122 drm_master_put(&dev->master); 123 } 124 } 125 126 return ret; 127 } 128 129 static int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv) 130 { 131 struct drm_master *old_master; 132 int ret; 133 134 lockdep_assert_held_once(&dev->master_mutex); 135 136 old_master = fpriv->master; 137 fpriv->master = drm_master_create(dev); 138 if (!fpriv->master) { 139 fpriv->master = old_master; 140 return -ENOMEM; 141 } 142 143 if (dev->driver->master_create) { 144 ret = dev->driver->master_create(dev, fpriv->master); 145 if (ret) 146 goto out_err; 147 } 148 fpriv->is_master = 1; 149 fpriv->authenticated = 1; 150 151 ret = drm_set_master(dev, fpriv, true); 152 if (ret) 153 goto out_err; 154 155 if (old_master) 156 drm_master_put(&old_master); 157 158 return 0; 159 160 out_err: 161 /* drop references and restore old master on failure */ 162 drm_master_put(&fpriv->master); 163 fpriv->master = old_master; 164 165 return ret; 166 } 167 168 int drm_setmaster_ioctl(struct drm_device *dev, void *data, 169 struct drm_file *file_priv) 170 { 171 int ret = 0; 172 173 mutex_lock(&dev->master_mutex); 174 if (drm_is_current_master(file_priv)) 175 goto out_unlock; 176 177 if (dev->master) { 178 ret = -EINVAL; 179 goto out_unlock; 180 } 181 182 if (!file_priv->master) { 183 ret = -EINVAL; 184 goto out_unlock; 185 } 186 187 if (!file_priv->is_master) { 188 ret = drm_new_set_master(dev, file_priv); 189 goto out_unlock; 190 } 191 192 ret = drm_set_master(dev, file_priv, false); 193 out_unlock: 194 mutex_unlock(&dev->master_mutex); 195 return ret; 196 } 197 198 static void drm_drop_master(struct drm_device *dev, 199 struct drm_file *fpriv) 200 { 201 if (dev->driver->master_drop) 202 dev->driver->master_drop(dev, fpriv); 203 drm_master_put(&dev->master); 204 } 205 206 int drm_dropmaster_ioctl(struct drm_device *dev, void *data, 207 struct drm_file *file_priv) 208 { 209 int ret = -EINVAL; 210 211 mutex_lock(&dev->master_mutex); 212 if (!drm_is_current_master(file_priv)) 213 goto out_unlock; 214 215 if (!dev->master) 216 goto out_unlock; 217 218 ret = 0; 219 drm_drop_master(dev, file_priv); 220 out_unlock: 221 mutex_unlock(&dev->master_mutex); 222 return ret; 223 } 224 225 int drm_master_open(struct drm_file *file_priv) 226 { 227 struct drm_device *dev = file_priv->minor->dev; 228 int ret = 0; 229 230 /* if there is no current master make this fd it, but do not create 231 * any master object for render clients */ 232 mutex_lock(&dev->master_mutex); 233 if (!dev->master) 234 ret = drm_new_set_master(dev, file_priv); 235 else 236 file_priv->master = drm_master_get(dev->master); 237 mutex_unlock(&dev->master_mutex); 238 239 return ret; 240 } 241 242 void drm_master_release(struct drm_file *file_priv) 243 { 244 struct drm_device *dev = file_priv->minor->dev; 245 struct drm_master *master = file_priv->master; 246 247 mutex_lock(&dev->master_mutex); 248 if (file_priv->magic) 249 idr_remove(&file_priv->master->magic_map, file_priv->magic); 250 251 if (!drm_is_current_master(file_priv)) 252 goto out; 253 254 if (drm_core_check_feature(dev, DRIVER_LEGACY)) { 255 /* 256 * Since the master is disappearing, so is the 257 * possibility to lock. 258 */ 259 mutex_lock(&dev->struct_mutex); 260 if (master->lock.hw_lock) { 261 if (dev->sigdata.lock == master->lock.hw_lock) 262 dev->sigdata.lock = NULL; 263 master->lock.hw_lock = NULL; 264 master->lock.file_priv = NULL; 265 wake_up_interruptible_all(&master->lock.lock_queue); 266 } 267 mutex_unlock(&dev->struct_mutex); 268 } 269 270 if (dev->master == file_priv->master) 271 drm_drop_master(dev, file_priv); 272 out: 273 /* drop the master reference held by the file priv */ 274 if (file_priv->master) 275 drm_master_put(&file_priv->master); 276 mutex_unlock(&dev->master_mutex); 277 } 278 279 /** 280 * drm_is_current_master - checks whether @priv is the current master 281 * @fpriv: DRM file private 282 * 283 * Checks whether @fpriv is current master on its device. This decides whether a 284 * client is allowed to run DRM_MASTER IOCTLs. 285 * 286 * Most of the modern IOCTL which require DRM_MASTER are for kernel modesetting 287 * - the current master is assumed to own the non-shareable display hardware. 288 */ 289 bool drm_is_current_master(struct drm_file *fpriv) 290 { 291 return fpriv->is_master && fpriv->master == fpriv->minor->dev->master; 292 } 293 EXPORT_SYMBOL(drm_is_current_master); 294 295 /** 296 * drm_master_get - reference a master pointer 297 * @master: &struct drm_master 298 * 299 * Increments the reference count of @master and returns a pointer to @master. 300 */ 301 struct drm_master *drm_master_get(struct drm_master *master) 302 { 303 kref_get(&master->refcount); 304 return master; 305 } 306 EXPORT_SYMBOL(drm_master_get); 307 308 static void drm_master_destroy(struct kref *kref) 309 { 310 struct drm_master *master = container_of(kref, struct drm_master, refcount); 311 struct drm_device *dev = master->dev; 312 313 if (dev->driver->master_destroy) 314 dev->driver->master_destroy(dev, master); 315 316 drm_legacy_master_rmmaps(dev, master); 317 318 idr_destroy(&master->magic_map); 319 kfree(master->unique); 320 kfree(master); 321 } 322 323 /** 324 * drm_master_put - unreference and clear a master pointer 325 * @master: pointer to a pointer of &struct drm_master 326 * 327 * This decrements the &drm_master behind @master and sets it to NULL. 328 */ 329 void drm_master_put(struct drm_master **master) 330 { 331 kref_put(&(*master)->refcount, drm_master_destroy); 332 *master = NULL; 333 } 334 EXPORT_SYMBOL(drm_master_put); -
new file src/add-ons/kernel/drivers/graphics/legacy/Jamfile
diff --git a/src/add-ons/kernel/drivers/graphics/3dfx/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/3dfx/Jamfile similarity index 100% rename from src/add-ons/kernel/drivers/graphics/3dfx/Jamfile rename to src/add-ons/kernel/drivers/graphics/legacy/3dfx/Jamfile diff --git a/src/add-ons/kernel/drivers/graphics/3dfx/driver.cpp b/src/add-ons/kernel/drivers/graphics/legacy/3dfx/driver.cpp similarity index 100% rename from src/add-ons/kernel/drivers/graphics/3dfx/driver.cpp rename to src/add-ons/kernel/drivers/graphics/legacy/3dfx/driver.cpp diff --git a/src/add-ons/kernel/drivers/graphics/legacy/Jamfile b/src/add-ons/kernel/drivers/graphics/legacy/Jamfile new file mode 100644 index 0000000000..057cf7cea2
- + 1 SubDir HAIKU_TOP src add-ons kernel drivers graphics legacy ; 2 3 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy 3dfx ; 4 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy ati ; 5 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy common ; 6 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy et6x00 ; 7 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy framebuffer ; 8 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy intel_810 ; 9 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy intel_extreme ; 10 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy matrox ; 11 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy neomagic ; 12 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy nvidia ; 13 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy nvidia_gpgpu ; 14 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy radeon ; 15 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy radeon_hd ; 16 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy s3 ; 17 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy skeleton ; 18 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy vesa ; 19 SubInclude HAIKU_TOP src add-ons kernel drivers graphics legacy via ;