diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2014-04-01 20:16:51 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2014-04-01 20:16:51 +0000 |
commit | cf4a40c005a627642634be9c51716043952e6017 (patch) | |
tree | 42fe8929eb4ef376968c8fa4757c7d31ebf55978 /sys/dev/pci | |
parent | 9acc8ea82e86b28357a0320396de79e0327f6459 (diff) |
Move some duplicated code implementing Linux compatibility APIs and stick it
in a seperate header file. This will become a dumping ground for similar code.
ok jsg@
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/drm/drmP.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_linux.h | 65 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/i915_gem.c | 27 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915/i915_gem_execbuffer.c | 47 |
4 files changed, 69 insertions, 73 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index 315cc37680c..80d977fd205 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -1,4 +1,4 @@ -/* $OpenBSD: drmP.h,v 1.174 2014/03/26 14:41:41 mpi Exp $ */ +/* $OpenBSD: drmP.h,v 1.175 2014/04/01 20:16:50 kettenis Exp $ */ /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*- * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com */ @@ -62,6 +62,7 @@ #include <dev/pci/agpvar.h> #include <machine/bus.h> +#include "drm_linux.h" #include "drm_linux_list.h" #include "drm.h" #include "drm_mm.h" diff --git a/sys/dev/pci/drm/drm_linux.h b/sys/dev/pci/drm/drm_linux.h new file mode 100644 index 00000000000..e341f86d720 --- /dev/null +++ b/sys/dev/pci/drm/drm_linux.h @@ -0,0 +1,65 @@ +/* $OpenBSD: drm_linux.h,v 1.1 2014/04/01 20:16:50 kettenis Exp $ */ +/* + * Copyright (c) 2013, 2014 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#if defined(__i386__) || defined(__amd64__) + +static inline void +pagefault_disable(void) +{ + KASSERT(curcpu()->ci_inatomic == 0); + curcpu()->ci_inatomic = 1; +} + +static inline void +pagefault_enable(void) +{ + KASSERT(curcpu()->ci_inatomic == 1); + curcpu()->ci_inatomic = 0; +} + +static inline int +in_atomic(void) +{ + return curcpu()->ci_inatomic; +} + +static inline void * +kmap_atomic(struct vm_page *pg) +{ + vaddr_t va; + +#if defined (__HAVE_PMAP_DIRECT) + va = pmap_map_direct(pg); +#else + extern vaddr_t pmap_tmpmap_pa(paddr_t); + va = pmap_tmpmap_pa(VM_PAGE_TO_PHYS(pg)); +#endif + return (void *)va; +} + +static inline void +kunmap_atomic(void *addr) +{ +#if defined (__HAVE_PMAP_DIRECT) + pmap_unmap_direct((vaddr_t)addr); +#else + extern void pmap_tmpunmap_pa(void); + pmap_tmpunmap_pa(); +#endif +} + +#endif diff --git a/sys/dev/pci/drm/i915/i915_gem.c b/sys/dev/pci/drm/i915/i915_gem.c index 24069bf61a8..8b490dc6b35 100644 --- a/sys/dev/pci/drm/i915/i915_gem.c +++ b/sys/dev/pci/drm/i915/i915_gem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i915_gem.c,v 1.71 2014/03/24 17:06:49 kettenis Exp $ */ +/* $OpenBSD: i915_gem.c,v 1.72 2014/04/01 20:16:50 kettenis Exp $ */ /* * Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org> * @@ -326,31 +326,6 @@ kunmap(void *addr) #endif } -static inline void * -kmap_atomic(struct vm_page *pg) -{ - vaddr_t va; - -#if defined (__HAVE_PMAP_DIRECT) - va = pmap_map_direct(pg); -#else - extern vaddr_t pmap_tmpmap_pa(paddr_t); - va = pmap_tmpmap_pa(VM_PAGE_TO_PHYS(pg)); -#endif - return (void *)va; -} - -static inline void -kunmap_atomic(void *addr) -{ -#if defined (__HAVE_PMAP_DIRECT) - pmap_unmap_direct((vaddr_t)addr); -#else - extern void pmap_tmpunmap_pa(void); - pmap_tmpunmap_pa(); -#endif -} - static inline void drm_clflush_virt_range(void *addr, size_t len) { diff --git a/sys/dev/pci/drm/i915/i915_gem_execbuffer.c b/sys/dev/pci/drm/i915/i915_gem_execbuffer.c index d089a953a30..b71beb55710 100644 --- a/sys/dev/pci/drm/i915/i915_gem_execbuffer.c +++ b/sys/dev/pci/drm/i915/i915_gem_execbuffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i915_gem_execbuffer.c,v 1.27 2014/03/17 22:15:24 kettenis Exp $ */ +/* $OpenBSD: i915_gem_execbuffer.c,v 1.28 2014/04/01 20:16:50 kettenis Exp $ */ /* * Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org> * @@ -54,51 +54,6 @@ #include <sys/queue.h> #include <sys/task.h> -static inline void -pagefault_disable(void) -{ - KASSERT(curcpu()->ci_inatomic == 0); - curcpu()->ci_inatomic = 1; -} - -static inline void -pagefault_enable(void) -{ - KASSERT(curcpu()->ci_inatomic == 1); - curcpu()->ci_inatomic = 0; -} - -static inline int -in_atomic(void) -{ - return curcpu()->ci_inatomic; -} - -static inline void * -kmap_atomic(struct vm_page *pg) -{ - vaddr_t va; - -#if defined (__HAVE_PMAP_DIRECT) - va = pmap_map_direct(pg); -#else - extern vaddr_t pmap_tmpmap_pa(paddr_t); - va = pmap_tmpmap_pa(VM_PAGE_TO_PHYS(pg)); -#endif - return (void *)va; -} - -static inline void -kunmap_atomic(void *addr) -{ -#if defined (__HAVE_PMAP_DIRECT) - pmap_unmap_direct((vaddr_t)addr); -#else - extern void pmap_tmpunmap_pa(void); - pmap_tmpunmap_pa(); -#endif -} - static inline struct vm_page *i915_gem_object_get_page(struct drm_i915_gem_object *, int); struct eb_objects { |