VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/linux/initterm-r0drv-linux.c@ 48935

Last change on this file since 48935 was 48935, checked in by vboxsync, 11 years ago

Runtime: Whitespace and svn:keyword cleanups by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.9 KB
Line 
1/* $Id: initterm-r0drv-linux.c 48935 2013-10-07 21:19:37Z vboxsync $ */
2/** @file
3 * IPRT - Initialization & Termination, R0 Driver, Linux.
4 */
5
6/*
7 * Copyright (C) 2006-2012 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include "the-linux-kernel.h"
32#include "internal/iprt.h"
33#include <iprt/err.h>
34#include <iprt/assert.h>
35#include "internal/initterm.h"
36
37
38/*******************************************************************************
39* Global Variables *
40*******************************************************************************/
41/** The IPRT work queue. */
42#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
43static struct workqueue_struct *g_prtR0LnxWorkQueue;
44#else
45static DECLARE_TASK_QUEUE(g_rtR0LnxWorkQueue);
46#endif
47
48
49/*******************************************************************************
50* Internal Functions *
51*******************************************************************************/
52#if defined(RT_ARCH_AMD64) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
53/* in alloc-r0drv0-linux.c */
54DECLHIDDEN(void) rtR0MemExecCleanup(void);
55#endif
56
57
58/**
59 * Pushes an item onto the IPRT work queue.
60 *
61 * @param pWork The work item.
62 * @param pfnWorker The callback function. It will be called back
63 * with @a pWork as argument.
64 */
65DECLHIDDEN(void) rtR0LnxWorkqueuePush(RTR0LNXWORKQUEUEITEM *pWork, void (*pfnWorker)(RTR0LNXWORKQUEUEITEM *))
66{
67#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
68# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
69 INIT_WORK(pWork, pfnWorker);
70# else
71 INIT_WORK(pWork, pfnWorker, pWork);
72# endif
73 queue_work(g_prtR0LnxWorkQueue, pWork);
74#else
75 INIT_TQUEUE(pWork, (void (*)(void *))pfnWorker, pWork);
76 queue_task(pWork, &g_rtR0LnxWorkQueue);
77#endif
78}
79
80
81/**
82 * Flushes all items in the IPRT work queue.
83 *
84 * @remarks This is mostly for 2.4.x compatability. Must not be called from
85 * atomic contexts or with unncessary locks held.
86 */
87DECLHIDDEN(void) rtR0LnxWorkqueueFlush(void)
88{
89#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
90 flush_workqueue(g_prtR0LnxWorkQueue);
91#else
92 run_task_queue(&g_rtR0LnxWorkQueue);
93#endif
94}
95
96
97DECLHIDDEN(int) rtR0InitNative(void)
98{
99#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
100 g_prtR0LnxWorkQueue = create_workqueue("iprt");
101 if (!g_prtR0LnxWorkQueue)
102 return VERR_NO_MEMORY;
103#endif
104
105 return VINF_SUCCESS;
106}
107
108
109DECLHIDDEN(void) rtR0TermNative(void)
110{
111 rtR0LnxWorkqueueFlush();
112#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
113 destroy_workqueue(g_prtR0LnxWorkQueue);
114 g_prtR0LnxWorkQueue = NULL;
115#endif
116
117#if defined(RT_ARCH_AMD64) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
118 rtR0MemExecCleanup();
119#endif
120}
121
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette