/* $OpenBSD: drm_linux.h,v 1.93 2019/04/14 10:14:51 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * Copyright (c) 2017 Martin Pieuchot * * 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. */ #ifndef _DRM_LINUX_H_ #define _DRM_LINUX_H_ #include #include #include #include #include #include /* The Linux code doesn't meet our usual standards! */ #ifdef __clang__ #pragma clang diagnostic ignored "-Wenum-conversion" #pragma clang diagnostic ignored "-Winitializer-overrides" #pragma clang diagnostic ignored "-Wtautological-compare" #pragma clang diagnostic ignored "-Wunneeded-internal-declaration" #pragma clang diagnostic ignored "-Wunused-const-variable" #pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers" #pragma clang diagnostic ignored "-Wunused-function" #pragma clang diagnostic ignored "-Wunused-variable" #pragma clang diagnostic ignored "-Wparentheses-equality" #pragma clang diagnostic ignored "-Wmissing-braces" #else #pragma GCC diagnostic ignored "-Wformat-zero-length" #endif #define STUB() do { printf("%s: stub\n", __func__); } while(0) #define KBUILD_MODNAME "drm" #define KHZ2PICOS(a) (1000000000UL/(a)) #ifndef PCI_MEM_START #define PCI_MEM_START 0 #endif #ifndef PCI_MEM_END #define PCI_MEM_END 0xffffffff #endif #ifndef PCI_MEM64_END #define PCI_MEM64_END 0xffffffffffffffff #endif #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ #ifdef __macppc__ static inline int of_machine_is_compatible(const char *model) { extern char *hw_prod; return (strcmp(model, hw_prod) == 0); } #endif #define POISON_INUSE 0xdb #if defined(__amd64__) || defined(__i386__) #define X86_FEATURE_CLFLUSH 1 #define X86_FEATURE_XMM4_1 2 #define X86_FEATURE_PAT 3 #define X86_FEATURE_HYPERVISOR 4 static inline bool static_cpu_has(uint16_t f) { switch (f) { case X86_FEATURE_CLFLUSH: return curcpu()->ci_cflushsz != 0; case X86_FEATURE_XMM4_1: return (cpu_ecxfeature & CPUIDECX_SSE41) != 0; case X86_FEATURE_PAT: return (curcpu()->ci_feature_flags & CPUID_PAT) != 0; case X86_FEATURE_HYPERVISOR: return (cpu_ecxfeature & CPUIDECX_HV) != 0; default: return false; } } #define boot_cpu_has(x) static_cpu_has(x) #endif #endif