From f347fde22f1297e4f022600d201780d5ead78114 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Wed, 25 Sep 2024 16:09:09 -0400 Subject: Delete no-longer-needed nvgpu headers The dependency on these was removed in commit 8340d234. --- include/nvgpu/posix/atomic.h | 191 ---------------------------------- include/nvgpu/posix/barrier.h | 44 -------- include/nvgpu/posix/bitops.h | 95 ----------------- include/nvgpu/posix/bug.h | 56 ---------- include/nvgpu/posix/circ_buf.h | 44 -------- include/nvgpu/posix/cond.h | 59 ----------- include/nvgpu/posix/io.h | 114 --------------------- include/nvgpu/posix/kmem.h | 36 ------- include/nvgpu/posix/lock.h | 69 ------------- include/nvgpu/posix/log2.h | 37 ------- include/nvgpu/posix/nvgpu_mem.h | 32 ------ include/nvgpu/posix/nvlink.h | 24 ----- include/nvgpu/posix/pci.h | 28 ----- include/nvgpu/posix/probe.h | 31 ------ include/nvgpu/posix/rwsem.h | 35 ------- include/nvgpu/posix/sizes.h | 38 ------- include/nvgpu/posix/sort.h | 35 ------- include/nvgpu/posix/thread.h | 51 ---------- include/nvgpu/posix/types.h | 221 ---------------------------------------- include/nvgpu/posix/vm.h | 41 -------- 20 files changed, 1281 deletions(-) delete mode 100644 include/nvgpu/posix/atomic.h delete mode 100644 include/nvgpu/posix/barrier.h delete mode 100644 include/nvgpu/posix/bitops.h delete mode 100644 include/nvgpu/posix/bug.h delete mode 100644 include/nvgpu/posix/circ_buf.h delete mode 100644 include/nvgpu/posix/cond.h delete mode 100644 include/nvgpu/posix/io.h delete mode 100644 include/nvgpu/posix/kmem.h delete mode 100644 include/nvgpu/posix/lock.h delete mode 100644 include/nvgpu/posix/log2.h delete mode 100644 include/nvgpu/posix/nvgpu_mem.h delete mode 100644 include/nvgpu/posix/nvlink.h delete mode 100644 include/nvgpu/posix/pci.h delete mode 100644 include/nvgpu/posix/probe.h delete mode 100644 include/nvgpu/posix/rwsem.h delete mode 100644 include/nvgpu/posix/sizes.h delete mode 100644 include/nvgpu/posix/sort.h delete mode 100644 include/nvgpu/posix/thread.h delete mode 100644 include/nvgpu/posix/types.h delete mode 100644 include/nvgpu/posix/vm.h (limited to 'include/nvgpu/posix') diff --git a/include/nvgpu/posix/atomic.h b/include/nvgpu/posix/atomic.h deleted file mode 100644 index c9d9212..0000000 --- a/include/nvgpu/posix/atomic.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_ATOMIC_H__ -#define __NVGPU_POSIX_ATOMIC_H__ - -#include - -/* - * Note: this code uses the GCC builtins to implement atomics. - */ - -#define __atomic_cmpxchg(p, v, c) __sync_val_compare_and_swap(p, v, c) -#define __atomic_and(p, v) __sync_fetch_and_and(p, v) -#define __atomic_or(p, v) __sync_fetch_and_or(p, v) - -#define cmpxchg __atomic_cmpxchg - -/* - * Place holders until real atomics can be implemented... Yay for GCC builtins! - * We can use those eventually to define all the Linux atomic ops. - * - * TODO: make these _actually_ atomic! - */ -typedef struct __nvgpu_posix_atomic { - int v; -} nvgpu_atomic_t; - -typedef struct __nvgpu_posix_atomic64 { - long v; -} nvgpu_atomic64_t; - -#define __nvgpu_atomic_init(i) { i } -#define __nvgpu_atomic64_init(i) { i } - -static inline void __nvgpu_atomic_set(nvgpu_atomic_t *v, int i) -{ - v->v = i; -} - -static inline int __nvgpu_atomic_read(nvgpu_atomic_t *v) -{ - return v->v; -} - -static inline void __nvgpu_atomic_inc(nvgpu_atomic_t *v) -{ - v->v++; -} - -static inline int __nvgpu_atomic_inc_return(nvgpu_atomic_t *v) -{ - v->v++; - return v->v; -} - -static inline void __nvgpu_atomic_dec(nvgpu_atomic_t *v) -{ - v->v--; -} - -static inline int __nvgpu_atomic_dec_return(nvgpu_atomic_t *v) -{ - v->v--; - return v->v; -} - -static inline int __nvgpu_atomic_cmpxchg(nvgpu_atomic_t *v, int old, int new) -{ - if (v->v == old) - v->v = new; - - return v->v; -} - -static inline int __nvgpu_atomic_xchg(nvgpu_atomic_t *v, int new) -{ - v->v = new; - return new; -} - -static inline bool __nvgpu_atomic_inc_and_test(nvgpu_atomic_t *v) -{ - v->v++; - return v->v ? true : false; -} - -static inline bool __nvgpu_atomic_dec_and_test(nvgpu_atomic_t *v) -{ - v->v--; - return v->v ? true : false; -} - -static inline bool __nvgpu_atomic_sub_and_test(int i, nvgpu_atomic_t *v) -{ - v->v -= i; - return v->v ? true : false; -} - -static inline int __nvgpu_atomic_add_return(int i, nvgpu_atomic_t *v) -{ - v->v += i; - return v->v; -} - -static inline int __nvgpu_atomic_add_unless(nvgpu_atomic_t *v, int a, int u) -{ - if (v->v != u) - v->v += a; - - return v->v; -} - -static inline void __nvgpu_atomic64_set(nvgpu_atomic64_t *v, long i) -{ - v->v = i; -} - -static inline long __nvgpu_atomic64_read(nvgpu_atomic64_t *v) -{ - return v->v; -} - -static inline void __nvgpu_atomic64_add(long x, nvgpu_atomic64_t *v) -{ - v->v += x; -} - -static inline void __nvgpu_atomic64_inc(nvgpu_atomic64_t *v) -{ - v->v++; -} - -static inline long __nvgpu_atomic64_inc_return(nvgpu_atomic64_t *v) -{ - v->v++; - return v->v; -} - -static inline void __nvgpu_atomic64_dec(nvgpu_atomic64_t *v) -{ - v->v--; -} - -static inline long __nvgpu_atomic64_dec_return(nvgpu_atomic64_t *v) -{ - v->v--; - return v->v; -} - -static inline long __nvgpu_atomic64_cmpxchg(nvgpu_atomic64_t *v, - long old, long new) -{ - - if (v->v == old) - v->v = new; - - return v->v; -} - -static inline void __nvgpu_atomic64_sub(long x, nvgpu_atomic64_t *v) -{ - v->v -= x; -} - -static inline long __nvgpu_atomic64_sub_return(long x, nvgpu_atomic64_t *v) -{ - v->v -= x; - return v->v; -} - -#endif diff --git a/include/nvgpu/posix/barrier.h b/include/nvgpu/posix/barrier.h deleted file mode 100644 index edc7b12..0000000 --- a/include/nvgpu/posix/barrier.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_BARRIER_H__ -#define __NVGPU_POSIX_BARRIER_H__ - -#define ACCESS_ONCE(x) (*(volatile __typeof__(x) *)&x) - -/* - * TODO: implement all these! - */ -#define __nvgpu_mb() -#define __nvgpu_rmb() -#define __nvgpu_wmb() - -#define __nvgpu_smp_mb() -#define __nvgpu_smp_rmb() -#define __nvgpu_smp_wmb() - -#define __nvgpu_read_barrier_depends() -#define __nvgpu_smp_read_barrier_depends() - -#define __NV_ACCESS_ONCE(x) ACCESS_ONCE(x) - -#endif diff --git a/include/nvgpu/posix/bitops.h b/include/nvgpu/posix/bitops.h deleted file mode 100644 index e8c663b..0000000 --- a/include/nvgpu/posix/bitops.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_BITOPS_H__ -#define __NVGPU_POSIX_BITOPS_H__ - -#include - -/* - * Assume an 8 bit byte, of course. - */ -#define BITS_PER_BYTE 8UL -#define BITS_PER_LONG (__SIZEOF_LONG__ * BITS_PER_BYTE) -#define BITS_TO_LONGS(bits) \ - (bits + (BITS_PER_LONG - 1) / BITS_PER_LONG) - -/* - * Deprecated; use the explicit BITxx() macros instead. - */ -#define BIT(i) BIT64(i) - -#define GENMASK(h, l) \ - (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) - -#define DECLARE_BITMAP(bmap, bits) \ - unsigned long bmap[BITS_TO_LONGS(bits)] - -#define for_each_set_bit(bit, addr, size) \ - for ((bit) = find_first_bit((addr), (size)); \ - (bit) < (size); \ - (bit) = find_next_bit((addr), (size), (bit) + 1)) - -#define ffs(word) __ffs(word) -#define ffz(word) __ffs(~(word)) -#define fls(word) __fls(word) - -/* - * Clashes with symbols in libc it seems. - */ -#define __ffs(word) __nvgpu_posix_ffs(word) -#define __fls(word) __nvgpu_posix_fls(word) - -unsigned long __nvgpu_posix_ffs(unsigned long word); -unsigned long __nvgpu_posix_fls(unsigned long word); - -unsigned long find_first_bit(const unsigned long *addr, unsigned long size); -unsigned long find_next_bit(const unsigned long *addr, unsigned long size, - unsigned long offset); -unsigned long find_first_zero_bit(const unsigned long *addr, - unsigned long size); - -bool test_bit(int nr, const volatile unsigned long *addr); -bool test_and_set_bit(int nr, volatile unsigned long *addr); -bool test_and_clear_bit(int nr, volatile unsigned long *addr); - -/* - * These two are atomic. - */ -void set_bit(int nr, volatile unsigned long *addr); -void clear_bit(int nr, volatile unsigned long *addr); - -void bitmap_set(unsigned long *map, unsigned int start, int len); -void bitmap_clear(unsigned long *map, unsigned int start, int len); -unsigned long bitmap_find_next_zero_area_off(unsigned long *map, - unsigned long size, - unsigned long start, - unsigned int nr, - unsigned long align_mask, - unsigned long align_offset); -unsigned long bitmap_find_next_zero_area(unsigned long *map, - unsigned long size, - unsigned long start, - unsigned int nr, - unsigned long align_mask); - -#endif diff --git a/include/nvgpu/posix/bug.h b/include/nvgpu/posix/bug.h deleted file mode 100644 index 04389a9..0000000 --- a/include/nvgpu/posix/bug.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_BUG_H__ -#define __NVGPU_POSIX_BUG_H__ - -#include - -/* - * TODO: make these actually useful! - */ - -#define BUG() __bug("") -#define BUG_ON(cond) \ - do { \ - if (cond) \ - BUG(); \ - } while (0) - -#define WARN(cond, msg, arg...) __warn(cond, msg, ##arg) -#define WARN_ON(cond) __warn(cond, "") - -#define WARN_ONCE(cond, msg, arg...) \ - ({static int __warned__ = 0; \ - if (!__warned__) { \ - WARN(cond, msg, ##arg); \ - __warned__ = 1; \ - } \ - cond; }) - - -void dump_stack(void); - -void __bug(const char *fmt, ...) __attribute__ ((noreturn)); -bool __warn(bool cond, const char *fmt, ...); - -#endif diff --git a/include/nvgpu/posix/circ_buf.h b/include/nvgpu/posix/circ_buf.h deleted file mode 100644 index 8d9b5ea..0000000 --- a/include/nvgpu/posix/circ_buf.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_CIRC_BUF_H__ -#define __NVGPU_POSIX_CIRC_BUF_H__ - -#include - -/* TODO: implement. */ - -#define CIRC_CNT(head, tail, size) \ - ({(void)head; \ - (void)tail; \ - (void)size; \ - BUG(); \ - 1; }) - -#define CIRC_SPACE(head, tail, size) \ - ({(void)head; \ - (void)tail; \ - (void)size; \ - BUG(); \ - 1; }) - -#endif diff --git a/include/nvgpu/posix/cond.h b/include/nvgpu/posix/cond.h deleted file mode 100644 index 3528388..0000000 --- a/include/nvgpu/posix/cond.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_COND_H__ -#define __NVGPU_POSIX_COND_H__ - -#include - -struct nvgpu_cond { - /* Place holder until this can be properly implemented. */ -}; - -/** - * NVGPU_COND_WAIT - Wait for a condition to be true - * - * @c - The condition variable to sleep on - * @condition - The condition that needs to be true - * @timeout_ms - Timeout in milliseconds, or 0 for infinite wait - * - * Wait for a condition to become true. Returns -ETIMEOUT if - * the wait timed out with condition false. - */ -#define NVGPU_COND_WAIT(c, condition, timeout_ms) \ - ({BUG(); 1; }) - -/** - * NVGPU_COND_WAIT_INTERRUPTIBLE - Wait for a condition to be true - * - * @c - The condition variable to sleep on - * @condition - The condition that needs to be true - * @timeout_ms - Timeout in milliseconds, or 0 for infinite wait - * - * Wait for a condition to become true. Returns -ETIMEOUT if - * the wait timed out with condition false or -ERESTARTSYS on - * signal. - */ -#define NVGPU_COND_WAIT_INTERRUPTIBLE(c, condition, timeout_ms) \ - ({BUG(); 1; }) - -#endif diff --git a/include/nvgpu/posix/io.h b/include/nvgpu/posix/io.h deleted file mode 100644 index 98be4d0..0000000 --- a/include/nvgpu/posix/io.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef NVGPU_POSIX_IO_H -#define NVGPU_POSIX_IO_H - -#include -#include - -struct gk20a; - -/** - * Here lies the interface for a unit test module to interact with the nvgpu IO - * accessors. This interface provides the ability for a module to react to nvgpu - * calling nvgpu IO accessors so that nvgpu can handle various HW sequences even - * when run in unit testing mode. - * - * The primary interface is simply callbacks to the unit test module which the - * module can handle how ever it wishes. - */ - -struct nvgpu_reg_access { - /* - * Address of the register write relative to the base of the register - * space. I.e you can compare this against values in the HW headers - * directly to check what register is being read/written to/from. - */ - u32 addr; - - /* - * Writes: this is the value being written. - * Reads: populate with the value to return. - */ - u32 value; -}; - -struct nvgpu_posix_io_callbacks { - void (*writel)(struct gk20a *g, struct nvgpu_reg_access *access); - void (*writel_check)(struct gk20a *g, struct nvgpu_reg_access *access); - void (*__readl)(struct gk20a *g, struct nvgpu_reg_access *access); - void (*readl)(struct gk20a *g, struct nvgpu_reg_access *access); - void (*bar1_writel)(struct gk20a *g, struct nvgpu_reg_access *access); - void (*bar1_readl)(struct gk20a *g, struct nvgpu_reg_access *access); - void (*usermode_writel)(struct gk20a *g, - struct nvgpu_reg_access *access); -}; - -struct nvgpu_posix_io_callbacks *nvgpu_posix_register_io( - struct gk20a *g, - struct nvgpu_posix_io_callbacks *io_callbacks); - -struct nvgpu_posix_io_reg_space { - u32 base; - u32 size; - u32 *data; - struct nvgpu_list_node link; -}; - -static inline struct nvgpu_posix_io_reg_space * -nvgpu_posix_io_reg_space_from_link(struct nvgpu_list_node *node) -{ - return (struct nvgpu_posix_io_reg_space *) - ((uintptr_t)node - offsetof(struct nvgpu_posix_io_reg_space, link)); -}; - -void nvgpu_posix_io_init_reg_space(struct gk20a *g); -int nvgpu_posix_io_get_error_code(struct gk20a *g); -void nvgpu_posix_io_reset_error_code(struct gk20a *g); -int nvgpu_posix_io_add_reg_space(struct gk20a *g, u32 base, u32 size); -struct nvgpu_posix_io_reg_space *nvgpu_posix_io_get_reg_space(struct gk20a *g, - u32 addr); -void nvgpu_posix_io_delete_reg_space(struct gk20a *g, u32 base); -void nvgpu_posix_io_writel_reg_space(struct gk20a *g, u32 addr, u32 data); -u32 nvgpu_posix_io_readl_reg_space(struct gk20a *g, u32 addr); - -struct nvgpu_posix_io_reg_access { - struct nvgpu_reg_access access; - struct nvgpu_list_node link; -}; - -static inline struct nvgpu_posix_io_reg_access * -nvgpu_posix_io_reg_access_from_link(struct nvgpu_list_node *node) -{ - return (struct nvgpu_posix_io_reg_access *) - ((uintptr_t)node - offsetof(struct nvgpu_posix_io_reg_access, link)); -}; - -void nvgpu_posix_io_start_recorder(struct gk20a *g); -void nvgpu_posix_io_reset_recorder(struct gk20a *g); -void nvgpu_posix_io_record_access(struct gk20a *g, - struct nvgpu_reg_access *access); -bool nvgpu_posix_io_check_sequence(struct gk20a *g, - struct nvgpu_reg_access *sequence, u32 size, bool strict); - -#endif diff --git a/include/nvgpu/posix/kmem.h b/include/nvgpu/posix/kmem.h deleted file mode 100644 index efcdd3d..0000000 --- a/include/nvgpu/posix/kmem.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_KMEM_H__ -#define __NVGPU_POSIX_KMEM_H__ - -#include - -void *__nvgpu_kmalloc(struct gk20a *g, size_t size, void *ip); -void *__nvgpu_kzalloc(struct gk20a *g, size_t size, void *ip); -void *__nvgpu_kcalloc(struct gk20a *g, size_t n, size_t size, void *ip); -void *__nvgpu_vmalloc(struct gk20a *g, unsigned long size, void *ip); -void *__nvgpu_vzalloc(struct gk20a *g, unsigned long size, void *ip); -void __nvgpu_kfree(struct gk20a *g, void *addr); -void __nvgpu_vfree(struct gk20a *g, void *addr); - -#endif diff --git a/include/nvgpu/posix/lock.h b/include/nvgpu/posix/lock.h deleted file mode 100644 index 82eddd0..0000000 --- a/include/nvgpu/posix/lock.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_LOCK_H__ -#define __NVGPU_POSIX_LOCK_H__ - -#include - -#include - -/* - * All locks for posix nvgpu are just pthread locks. There's not a lot of reason - * to have real spinlocks in userspace since we aren't using real HW or running - * perf critical code where a sleep could be devestating. - * - * This could be revisited later, though. - */ -struct __nvgpu_posix_lock { - pthread_mutex_t mutex; -}; - -static inline void __nvgpu_posix_lock_acquire(struct __nvgpu_posix_lock *lock) -{ - pthread_mutex_lock(&lock->mutex); -} - -static inline int __nvgpu_posix_lock_try_acquire( - struct __nvgpu_posix_lock *lock) -{ - return pthread_mutex_trylock(&lock->mutex); -} - -static inline void __nvgpu_posix_lock_release(struct __nvgpu_posix_lock *lock) -{ - pthread_mutex_unlock(&lock->mutex); -} - -struct nvgpu_mutex { - struct __nvgpu_posix_lock lock; -}; - -struct nvgpu_spinlock { - struct __nvgpu_posix_lock lock; -}; - -struct nvgpu_raw_spinlock { - struct __nvgpu_posix_lock lock; -}; - -#endif /* NVGPU_LOCK_LINUX_H */ diff --git a/include/nvgpu/posix/log2.h b/include/nvgpu/posix/log2.h deleted file mode 100644 index ca95c10..0000000 --- a/include/nvgpu/posix/log2.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_LOG2_H__ -#define __NVGPU_POSIX_LOG2_H__ - -#define ilog2(x) (fls(x) - 1) - -#define roundup_pow_of_two(x) (1UL << fls((x) - 1)) -#define rounddown_pow_of_two(x) (1UL << (fls(x) - 1)) - -#define is_power_of_2(x) \ - ({ \ - typeof(x) __x__ = (x); \ - (__x__ != 0 && ((__x__ & (__x__ - 1)) == 0)); \ - }) - -#endif diff --git a/include/nvgpu/posix/nvgpu_mem.h b/include/nvgpu/posix/nvgpu_mem.h deleted file mode 100644 index 30cdf60..0000000 --- a/include/nvgpu/posix/nvgpu_mem.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_NVGPU_MEM_H__ -#define __NVGPU_POSIX_NVGPU_MEM_H__ - -struct nvgpu_mem_priv { - /* - * Eventually this will require an implementation using nvmap. - */ -}; - -#endif diff --git a/include/nvgpu/posix/nvlink.h b/include/nvgpu/posix/nvlink.h deleted file mode 100644 index 99cf837..0000000 --- a/include/nvgpu/posix/nvlink.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __NVGPU_POSIX_NVLINK_H__ -#define __NVGPU_POSIX_NVLINK_H__ - -/* - * Empty... - */ - -#endif diff --git a/include/nvgpu/posix/pci.h b/include/nvgpu/posix/pci.h deleted file mode 100644 index cd9fc14..0000000 --- a/include/nvgpu/posix/pci.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_PCI_H__ -#define __NVGPU_POSIX_PCI_H__ - -#define PCI_VENDOR_ID_NVIDIA 0x10de - -#endif diff --git a/include/nvgpu/posix/probe.h b/include/nvgpu/posix/probe.h deleted file mode 100644 index a9763aa..0000000 --- a/include/nvgpu/posix/probe.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_PROBE_H__ -#define __NVGPU_POSIX_PROBE_H__ - -struct gk20a; - -struct gk20a *nvgpu_posix_probe(void); -void nvgpu_posix_cleanup(struct gk20a *g); - -#endif diff --git a/include/nvgpu/posix/rwsem.h b/include/nvgpu/posix/rwsem.h deleted file mode 100644 index 65aa931..0000000 --- a/include/nvgpu/posix/rwsem.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_RWSEM_H__ -#define __NVGPU_POSIX_RWSEM_H__ - -#include - -struct nvgpu_rwsem { - struct nvgpu_spinlock lock; - - int readers; - int writers; -}; - -#endif diff --git a/include/nvgpu/posix/sizes.h b/include/nvgpu/posix/sizes.h deleted file mode 100644 index 3fda757..0000000 --- a/include/nvgpu/posix/sizes.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_SIZES_H__ -#define __NVGPU_POSIX_SIZES_H__ - -#define SZ_1K (1UL << 10) -#define SZ_4K (SZ_1K << 2) -#define SZ_64K (SZ_1K << 6) -#define SZ_128K (SZ_1K << 7) - -#define SZ_1M (1UL << 20) -#define SZ_16M (SZ_1M << 4) -#define SZ_256M (SZ_1M << 8) - -#define SZ_1G (1UL << 30) -#define SZ_4G (SZ_1G << 2) - -#endif diff --git a/include/nvgpu/posix/sort.h b/include/nvgpu/posix/sort.h deleted file mode 100644 index 6a6920e..0000000 --- a/include/nvgpu/posix/sort.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_SORT_H__ -#define __NVGPU_POSIX_SORT_H__ - -#include - -static void sort(void *base, size_t num, size_t size, - int (*cmp)(const void *, const void *), - void (*swap)(void *, void *, int)) -{ - __bug("sort() not implemented yet!"); -} - -#endif diff --git a/include/nvgpu/posix/thread.h b/include/nvgpu/posix/thread.h deleted file mode 100644 index a312cc1..0000000 --- a/include/nvgpu/posix/thread.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_THREAD_H__ -#define __NVGPU_POSIX_THREAD_H__ - -#include - -#include - -/* - * Handles passing an nvgpu thread function into a posix thread. - */ -struct nvgpu_posix_thread_data { - int (*fn)(void *data); - void *data; -}; - -/* - * For some reason POSIX only allows 16 bytes of name length. - */ -#define NVGPU_THREAD_POSIX_MAX_NAMELEN 16 - -struct nvgpu_thread { - bool running; - bool should_stop; - pthread_t thread; - struct nvgpu_posix_thread_data nvgpu; - char tname[16]; -}; - -#endif diff --git a/include/nvgpu/posix/types.h b/include/nvgpu/posix/types.h deleted file mode 100644 index 12078b9..0000000 --- a/include/nvgpu/posix/types.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_TYPES_H__ -#define __NVGPU_POSIX_TYPES_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * For endianness functions. - */ -#include - -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef unsigned long long u64; - -typedef signed char s8; -typedef signed short s16; -typedef signed int s32; -typedef signed long long s64; - -#define min_t(type, a, b) \ - ({ \ - type __a = (a); \ - type __b = (b); \ - __a < __b ? __a : __b; \ - }) - -#if defined(min) -#undef min -#endif -#if defined(max) -#undef max -#endif - -#define min(a, b) \ - ({ \ - (a) < (b) ? a : b; \ - }) -#define max(a, b) \ - ({ \ - (a) > (b) ? a : b; \ - }) -#define min3(a, b, c) min(min(a, b), c) - -#define PAGE_SIZE 4096U - -#define ARRAY_SIZE(array) \ - (sizeof(array) / sizeof((array)[0])) - -#define MAX_SCHEDULE_TIMEOUT LONG_MAX - -#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) - -/* - * Only used in clk_gm20b.c which we will never unit test. Don't use! - */ -#define DIV_ROUND_CLOSEST(x, divisor) ({BUG(); 0; }) - -/* - * Joys of userspace: usually division just works since the compiler can link - * against external division functions implicitly. - */ -#define do_div(a, b) ((a) /= (b)) -#define div64_u64(a, b) ((a) / (b)) - -#define __round_mask(x, y) ((__typeof__(x))((y) - 1)) -#define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1) -#define roundup(x, y) round_up(x, y) -#define round_down(x, y) ((x) & ~__round_mask(x, y)) - -#define ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) -#define ALIGN(x, a) ALIGN_MASK(x, (typeof(x))(a) - 1) -#define PAGE_ALIGN(x) ALIGN(x, PAGE_SIZE) - -/* - * Caps return at the size of the buffer not what would have been written if buf - * were arbitrarily sized. - */ -static inline int scnprintf(char *buf, size_t size, const char *format, ...) -{ - size_t ret; - va_list args; - - va_start(args, format); - ret = vsnprintf(buf, size, format, args); - va_end(args); - - return ret <= size ? ret : size; -} - -static inline u32 be32_to_cpu(u32 x) -{ - /* - * Conveniently big-endian happens to be network byte order as well so - * we can use ntohl() for this. - */ - return ntohl(x); -} - -/* - * Hamming weights. - */ -static inline unsigned long __hweight8(uint8_t x) -{ - return (unsigned long)(!!(x & (1 << 0)) + - !!(x & (1 << 1)) + - !!(x & (1 << 2)) + - !!(x & (1 << 3)) + - !!(x & (1 << 4)) + - !!(x & (1 << 5)) + - !!(x & (1 << 6)) + - !!(x & (1 << 7))); -} - -static inline unsigned long __hweight16(uint16_t x) -{ - return __hweight8((uint8_t)x) + - __hweight8((uint8_t)((x & 0xff00) >> 8)); -} - -static inline unsigned long __hweight32(uint32_t x) -{ - return __hweight16((uint16_t)x) + - __hweight16((uint16_t)((x & 0xffff0000) >> 16)); -} - -static inline unsigned long __hweight64(uint64_t x) -{ - return __hweight32((uint32_t)x) + - __hweight32((uint32_t)((x & 0xffffffff00000000) >> 32)); -} - -#define hweight32 __hweight32 -#define hweight_long __hweight64 - -/* - * Better suited under a compiler.h type header file, but for now these can live - * here. - */ -#define __must_check -#define __maybe_unused __attribute__((unused)) -#define __iomem -#define __user -#define unlikely -#define likely - -#define __stringify(x) #x - -/* - * Prevent compiler optimizations from mangling writes. But likely most uses of - * this in nvgpu are incorrect (i.e unnecessary). - */ -#define WRITE_ONCE(p, v) \ - ({ \ - volatile typeof(p) *__p__ = &(p); \ - *__p__ = v; \ - }) - -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - -#define __packed __attribute__((packed)) - -#define IS_ENABLED(config) 0 - -#define MAX_ERRNO 4095 - -#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO) - -static inline void *ERR_PTR(long error) -{ - return (void *) error; -} - -static inline long PTR_ERR(void *error) -{ - return (long)(uintptr_t)error; -} - -static inline bool IS_ERR(const void *ptr) -{ - return IS_ERR_VALUE((unsigned long)ptr); -} - -static inline bool IS_ERR_OR_NULL(const void *ptr) -{ - return (ptr == NULL) || IS_ERR_VALUE((unsigned long)ptr); -} - -#endif diff --git a/include/nvgpu/posix/vm.h b/include/nvgpu/posix/vm.h deleted file mode 100644 index ae997d3..0000000 --- a/include/nvgpu/posix/vm.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef __NVGPU_POSIX_VM_H__ -#define __NVGPU_POSIX_VM_H__ - -#include - -struct nvgpu_os_buffer { - /* - * We just use malloc() buffers in userspace. - */ - void *buf; - size_t size; -}; - -struct nvgpu_mapped_buf_priv { - void *buf; - size_t size; -}; - -#endif -- cgit v1.2.2