the-linux-kernel.h revision 1cd55a40a30997c1baf5b231a5bb88b6f8f047e5
/* $Id$ */
/** @file
* IPRT - Include all necessary headers for the Linux kernel.
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___the_linux_kernel_h
#define ___the_linux_kernel_h
/*
* Then use the linux bool type for all the stuff include here.
*/
#define bool linux_bool
# include <generated/autoconf.h>
#else
# ifndef AUTOCONF_INCLUDED
# include <linux/autoconf.h>
# endif
#endif
/* We only support 2.4 and 2.6 series kernels */
#endif
#endif
#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
# define MODVERSIONS
# include <linux/modversions.h>
# endif
#endif
#ifndef KBUILD_STR
# define KBUILD_STR(s) s
# else
# define KBUILD_STR(s) #s
# endif
#endif
# endif
#include <linux/spinlock.h>
# include <linux/semaphore.h>
#else /* older kernels */
# include <asm/semaphore.h>
#endif /* older kernels */
# include <linux/moduleparam.h>
#endif
#endif
#endif
#endif
#endif
# include <linux/notifier.h>
#endif
/* For the basic additions module */
#include <linux/interrupt.h>
#include <linux/completion.h>
#include <linux/compiler.h>
#ifndef HAVE_UNLOCKED_IOCTL /* linux/fs.h defines this */
# include <linux/smp_lock.h>
#endif
/* For the shared folders module */
#define wchar_t linux_wchar_t
/* For thread-context hooks. */
#endif
/* for workqueue / task queues. */
# include <linux/workqueue.h>
#else
#endif
#endif
# ifndef page_to_pfn
# endif
#endif
#ifndef DEFINE_WAIT
#endif
/*
* 2.4 / early 2.6 compatibility wrappers
*/
# ifndef MAX_JIFFY_OFFSET
# endif
{
# else
# endif
}
{
# if HZ > 1000
return MAX_JIFFY_OFFSET;
# endif
# else
# endif
}
# endif /* < 2.4.29 || >= 2.6.0 */
#endif /* < 2.6.7 */
/*
* 2.4 compatibility wrappers
*/
do { \
add_wait_queue(q, wait); \
} while (0)
# define after_wait(wait) \
do { \
} while (0)
# define finish_wait(q, wait) \
do { \
remove_wait_queue(q, wait); \
} while (0)
#else /* >= 2.6.0 */
# define after_wait(wait) do {} while (0)
#endif /* >= 2.6.0 */
/** @def TICK_NSEC
* The time between ticks in nsec */
#ifndef TICK_NSEC
#endif
/*
* This sucks soooo badly on x86! Why don't they export __PAGE_KERNEL_EXEC so PAGE_KERNEL_EXEC would be usable?
*/
# define MY_PAGE_KERNEL_EXEC PAGE_KERNEL_EXEC
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8) && defined(PAGE_KERNEL_EXEC) && defined(CONFIG_X86_PAE)
# ifdef __PAGE_KERNEL_EXEC
/* >= 2.6.27 */
# define MY_PAGE_KERNEL_EXEC __pgprot(cpu_has_pge ? __PAGE_KERNEL_EXEC | _PAGE_GLOBAL : __PAGE_KERNEL_EXEC)
# else
# define MY_PAGE_KERNEL_EXEC __pgprot(cpu_has_pge ? _PAGE_KERNEL_EXEC | _PAGE_GLOBAL : _PAGE_KERNEL_EXEC)
# endif
#else
# define MY_PAGE_KERNEL_EXEC PAGE_KERNEL
#endif
/*
* The redhat hack section.
* - The current hacks are for 2.4.21-15.EL only.
*/
#ifndef NO_REDHAT_HACKS
/* accounting. */
# ifdef VM_ACCOUNT
# define USE_RHEL4_MUNMAP
# endif
# endif
/* backported remap_page_range. */
# ifdef tlb_vma /* probably not good enough... */
# define HAVE_26_STYLE_REMAP_PAGE_RANGE 1
# endif
# endif
# ifndef RT_ARCH_AMD64
/* In 2.6.9-22.ELsmp we have to call change_page_attr() twice when changing
* the page attributes from PAGE_KERNEL to something else, because there appears
* to be a bug in one of the many patches that redhat applied.
* It should be safe to do this on less buggy linux kernels too. ;-)
*/
do { \
} while (0)
# endif /* !RT_ARCH_AMD64 */
#endif /* !NO_REDHAT_HACKS */
#ifndef MY_CHANGE_PAGE_ATTR
# ifdef RT_ARCH_AMD64 /** @todo This is a cheap hack, but it'll get around that 'else BUG();' in __change_page_attr(). */
do { \
} while (0)
# else
# endif
#endif
#else
do { \
} while (0)
do { \
} while (0)
#endif
/** @def ONE_MSEC_IN_JIFFIES
* The number of jiffies that make up 1 millisecond. Must be at least 1! */
#if HZ <= 1000
# define ONE_MSEC_IN_JIFFIES 1
#else
# error "HZ is not a multiple of 1000, the GIP stuff won't work right!"
#endif
/*
* Stop using the linux bool type.
*/
#undef bool
/*
* There are post-2.6.24 kernels (confusingly with unchanged version number)
* which eliminate macros which were marked as deprecated.
*/
#ifndef __attribute_used__
#define __attribute_used__ __used
#endif
/**
* Hack for shortening pointers on linux so we can stuff more stuff into the
* task_struct::comm field. This is used by the semaphore code but put here
* because we don't have any better place atm. Don't use outside IPRT, please.
*/
#ifdef RT_ARCH_AMD64
#else
#endif
/**
* Puts semaphore info into the task_struct::comm field if IPRT_DEBUG_SEMS is
* defined.
*/
#ifdef IPRT_DEBUG_SEMS
#else
#endif
/**
* Puts semaphore info into the task_struct::comm field if IPRT_DEBUG_SEMS is
* defined.
*/
#ifdef IPRT_DEBUG_SEMS
snprintf(current->comm, sizeof(current->comm), "%c%lx:%d", (chState), IPRT_DEBUG_SEMS_ADDRESS(pThis), rc);
#else
#endif
/*
*/
#ifndef ___iprt_param_h
#endif
/*
* Some global indicator macros.
*/
/** @def IPRT_LINUX_HAS_HRTIMER
* Whether the kernel support high resolution timers (Linux kernel versions
* 2.6.28 and later (hrtimer_add_expires_ns() & schedule_hrtimeout). */
# define IPRT_LINUX_HAS_HRTIMER
#endif
/*
* Workqueue stuff, see initterm-r0drv-linux.c.
*/
typedef struct work_struct RTR0LNXWORKQUEUEITEM;
#else
typedef struct tq_struct RTR0LNXWORKQUEUEITEM;
#endif
DECLHIDDEN(void) rtR0LnxWorkqueuePush(RTR0LNXWORKQUEUEITEM *pWork, void (*pfnWorker)(RTR0LNXWORKQUEUEITEM *));
DECLHIDDEN(void) rtR0LnxWorkqueueFlush(void);
#endif