VirtualBox

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

Last change on this file since 55268 was 55112, checked in by vboxsync, 10 years ago

Runtime: Linux < 2.6.13 fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.8 KB
Line 
1/* $Id: initterm-r0drv-linux.c 55112 2015-04-07 12:05:52Z 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/* in alloc-r0drv0-linux.c */
53DECLHIDDEN(void) rtR0MemExecCleanup(void);
54
55
56/**
57 * Pushes an item onto the IPRT work queue.
58 *
59 * @param pWork The work item.
60 * @param pfnWorker The callback function. It will be called back
61 * with @a pWork as argument.
62 */
63DECLHIDDEN(void) rtR0LnxWorkqueuePush(RTR0LNXWORKQUEUEITEM *pWork, void (*pfnWorker)(RTR0LNXWORKQUEUEITEM *))
64{
65#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
66# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
67 INIT_WORK(pWork, pfnWorker);
68# else
69 INIT_WORK(pWork, pfnWorker, pWork);
70# endif
71 queue_work(g_prtR0LnxWorkQueue, pWork);
72#else
73 INIT_TQUEUE(pWork, (void (*)(void *))pfnWorker, pWork);
74 queue_task(pWork, &g_rtR0LnxWorkQueue);
75#endif
76}
77
78
79/**
80 * Flushes all items in the IPRT work queue.
81 *
82 * @remarks This is mostly for 2.4.x compatability. Must not be called from
83 * atomic contexts or with unncessary locks held.
84 */
85DECLHIDDEN(void) rtR0LnxWorkqueueFlush(void)
86{
87#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
88 flush_workqueue(g_prtR0LnxWorkQueue);
89#else
90 run_task_queue(&g_rtR0LnxWorkQueue);
91#endif
92}
93
94
95DECLHIDDEN(int) rtR0InitNative(void)
96{
97#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
98 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
99 g_prtR0LnxWorkQueue = create_workqueue("iprt-VBoxWQueue");
100 #else
101 g_prtR0LnxWorkQueue = create_workqueue("iprt-VBoxQ");
102 #endif
103 if (!g_prtR0LnxWorkQueue)
104 return VERR_NO_MEMORY;
105#endif
106
107 return VINF_SUCCESS;
108}
109
110
111DECLHIDDEN(void) rtR0TermNative(void)
112{
113 rtR0LnxWorkqueueFlush();
114#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
115 destroy_workqueue(g_prtR0LnxWorkQueue);
116 g_prtR0LnxWorkQueue = NULL;
117#endif
118
119 rtR0MemExecCleanup();
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