/* $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