diff options
Diffstat (limited to 'include/nvgpu/linux')
| -rw-r--r-- | include/nvgpu/linux/atomic.h | 149 | ||||
| -rw-r--r-- | include/nvgpu/linux/barrier.h | 37 | ||||
| -rw-r--r-- | include/nvgpu/linux/cond.h | 81 | ||||
| -rw-r--r-- | include/nvgpu/linux/dma.h | 38 | ||||
| -rw-r--r-- | include/nvgpu/linux/kmem.h | 47 | ||||
| -rw-r--r-- | include/nvgpu/linux/lock.h | 81 | ||||
| -rw-r--r-- | include/nvgpu/linux/nvgpu_mem.h | 89 | ||||
| -rw-r--r-- | include/nvgpu/linux/nvlink.h | 31 | ||||
| -rw-r--r-- | include/nvgpu/linux/os_fence_android.h | 48 | ||||
| -rw-r--r-- | include/nvgpu/linux/rwsem.h | 26 | ||||
| -rw-r--r-- | include/nvgpu/linux/sim.h | 38 | ||||
| -rw-r--r-- | include/nvgpu/linux/sim_pci.h | 26 | ||||
| -rw-r--r-- | include/nvgpu/linux/thread.h | 29 | ||||
| -rw-r--r-- | include/nvgpu/linux/vm.h | 92 |
14 files changed, 812 insertions, 0 deletions
diff --git a/include/nvgpu/linux/atomic.h b/include/nvgpu/linux/atomic.h new file mode 100644 index 0000000..0734672 --- /dev/null +++ b/include/nvgpu/linux/atomic.h | |||
| @@ -0,0 +1,149 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #ifndef __NVGPU_ATOMIC_LINUX_H__ | ||
| 17 | #define __NVGPU_ATOMIC_LINUX_H__ | ||
| 18 | |||
| 19 | #ifdef __KERNEL__ | ||
| 20 | #include <linux/atomic.h> | ||
| 21 | #endif | ||
| 22 | |||
| 23 | typedef struct nvgpu_atomic { | ||
| 24 | atomic_t atomic_var; | ||
| 25 | } nvgpu_atomic_t; | ||
| 26 | |||
| 27 | typedef struct nvgpu_atomic64 { | ||
| 28 | atomic64_t atomic_var; | ||
| 29 | } nvgpu_atomic64_t; | ||
| 30 | |||
| 31 | #define __nvgpu_atomic_init(i) { ATOMIC_INIT(i) } | ||
| 32 | #define __nvgpu_atomic64_init(i) { ATOMIC64_INIT(i) } | ||
| 33 | |||
| 34 | static inline void __nvgpu_atomic_set(nvgpu_atomic_t *v, int i) | ||
| 35 | { | ||
| 36 | atomic_set(&v->atomic_var, i); | ||
| 37 | } | ||
| 38 | |||
| 39 | static inline int __nvgpu_atomic_read(nvgpu_atomic_t *v) | ||
| 40 | { | ||
| 41 | return atomic_read(&v->atomic_var); | ||
| 42 | } | ||
| 43 | |||
| 44 | static inline void __nvgpu_atomic_inc(nvgpu_atomic_t *v) | ||
| 45 | { | ||
| 46 | atomic_inc(&v->atomic_var); | ||
| 47 | } | ||
| 48 | |||
| 49 | static inline int __nvgpu_atomic_inc_return(nvgpu_atomic_t *v) | ||
| 50 | { | ||
| 51 | return atomic_inc_return(&v->atomic_var); | ||
| 52 | } | ||
| 53 | |||
| 54 | static inline void __nvgpu_atomic_dec(nvgpu_atomic_t *v) | ||
| 55 | { | ||
| 56 | atomic_dec(&v->atomic_var); | ||
| 57 | } | ||
| 58 | |||
| 59 | static inline int __nvgpu_atomic_dec_return(nvgpu_atomic_t *v) | ||
| 60 | { | ||
| 61 | return atomic_dec_return(&v->atomic_var); | ||
| 62 | } | ||
| 63 | |||
| 64 | static inline int __nvgpu_atomic_cmpxchg(nvgpu_atomic_t *v, int old, int new) | ||
| 65 | { | ||
| 66 | return atomic_cmpxchg(&v->atomic_var, old, new); | ||
| 67 | } | ||
| 68 | |||
| 69 | static inline int __nvgpu_atomic_xchg(nvgpu_atomic_t *v, int new) | ||
| 70 | { | ||
| 71 | return atomic_xchg(&v->atomic_var, new); | ||
| 72 | } | ||
| 73 | |||
| 74 | static inline bool __nvgpu_atomic_inc_and_test(nvgpu_atomic_t *v) | ||
| 75 | { | ||
| 76 | return atomic_inc_and_test(&v->atomic_var); | ||
| 77 | } | ||
| 78 | |||
| 79 | static inline bool __nvgpu_atomic_dec_and_test(nvgpu_atomic_t *v) | ||
| 80 | { | ||
| 81 | return atomic_dec_and_test(&v->atomic_var); | ||
| 82 | } | ||
| 83 | |||
| 84 | static inline bool __nvgpu_atomic_sub_and_test(int i, nvgpu_atomic_t *v) | ||
| 85 | { | ||
| 86 | return atomic_sub_and_test(i, &v->atomic_var); | ||
| 87 | } | ||
| 88 | |||
| 89 | static inline int __nvgpu_atomic_add_return(int i, nvgpu_atomic_t *v) | ||
| 90 | { | ||
| 91 | return atomic_add_return(i, &v->atomic_var); | ||
| 92 | } | ||
| 93 | |||
| 94 | static inline int __nvgpu_atomic_add_unless(nvgpu_atomic_t *v, int a, int u) | ||
| 95 | { | ||
| 96 | return atomic_add_unless(&v->atomic_var, a, u); | ||
| 97 | } | ||
| 98 | |||
| 99 | static inline void __nvgpu_atomic64_set(nvgpu_atomic64_t *v, long i) | ||
| 100 | { | ||
| 101 | atomic64_set(&v->atomic_var, i); | ||
| 102 | } | ||
| 103 | |||
| 104 | static inline long __nvgpu_atomic64_read(nvgpu_atomic64_t *v) | ||
| 105 | { | ||
| 106 | return atomic64_read(&v->atomic_var); | ||
| 107 | } | ||
| 108 | |||
| 109 | static inline void __nvgpu_atomic64_add(long x, nvgpu_atomic64_t *v) | ||
| 110 | { | ||
| 111 | atomic64_add(x, &v->atomic_var); | ||
| 112 | } | ||
| 113 | |||
| 114 | static inline void __nvgpu_atomic64_inc(nvgpu_atomic64_t *v) | ||
| 115 | { | ||
| 116 | atomic64_inc(&v->atomic_var); | ||
| 117 | } | ||
| 118 | |||
| 119 | static inline long __nvgpu_atomic64_inc_return(nvgpu_atomic64_t *v) | ||
| 120 | { | ||
| 121 | return atomic64_inc_return(&v->atomic_var); | ||
| 122 | } | ||
| 123 | |||
| 124 | static inline void __nvgpu_atomic64_dec(nvgpu_atomic64_t *v) | ||
| 125 | { | ||
| 126 | atomic64_dec(&v->atomic_var); | ||
| 127 | } | ||
| 128 | |||
| 129 | static inline void __nvgpu_atomic64_dec_return(nvgpu_atomic64_t *v) | ||
| 130 | { | ||
| 131 | atomic64_dec_return(&v->atomic_var); | ||
| 132 | } | ||
| 133 | |||
| 134 | static inline long __nvgpu_atomic64_cmpxchg(nvgpu_atomic64_t *v, | ||
| 135 | long old, long new) | ||
| 136 | { | ||
| 137 | return atomic64_cmpxchg(&v->atomic_var, old, new); | ||
| 138 | } | ||
| 139 | |||
| 140 | static inline void __nvgpu_atomic64_sub(long x, nvgpu_atomic64_t *v) | ||
| 141 | { | ||
| 142 | atomic64_sub(x, &v->atomic_var); | ||
| 143 | } | ||
| 144 | |||
| 145 | static inline long __nvgpu_atomic64_sub_return(long x, nvgpu_atomic64_t *v) | ||
| 146 | { | ||
| 147 | return atomic64_sub_return(x, &v->atomic_var); | ||
| 148 | } | ||
| 149 | #endif /*__NVGPU_ATOMIC_LINUX_H__ */ | ||
diff --git a/include/nvgpu/linux/barrier.h b/include/nvgpu/linux/barrier.h new file mode 100644 index 0000000..ef867c4 --- /dev/null +++ b/include/nvgpu/linux/barrier.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #ifndef __NVGPU_BARRIER_LINUX_H__ | ||
| 18 | #define __NVGPU_BARRIER_LINUX_H__ | ||
| 19 | |||
| 20 | #include <asm/barrier.h> | ||
| 21 | |||
| 22 | #define __nvgpu_mb() mb() | ||
| 23 | #define __nvgpu_rmb() rmb() | ||
| 24 | #define __nvgpu_wmb() wmb() | ||
| 25 | |||
| 26 | #define __nvgpu_smp_mb() smp_mb() | ||
| 27 | #define __nvgpu_smp_rmb() smp_rmb() | ||
| 28 | #define __nvgpu_smp_wmb() smp_wmb() | ||
| 29 | |||
| 30 | #define __nvgpu_read_barrier_depends() read_barrier_depends() | ||
| 31 | #define __nvgpu_smp_read_barrier_depends() smp_read_barrier_depends() | ||
| 32 | |||
| 33 | #define __NV_ACCESS_ONCE(x) ACCESS_ONCE(x) | ||
| 34 | |||
| 35 | #define __nvgpu_speculation_barrier() speculation_barrier() | ||
| 36 | |||
| 37 | #endif /* __NVGPU_BARRIER_LINUX_H__ */ | ||
diff --git a/include/nvgpu/linux/cond.h b/include/nvgpu/linux/cond.h new file mode 100644 index 0000000..b53ada3 --- /dev/null +++ b/include/nvgpu/linux/cond.h | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms and conditions of the GNU General Public License, | ||
| 6 | * version 2, as published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
