VirtualBox

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

Last change on this file since 86728 was 85698, checked in by vboxsync, 4 years ago

IPRT,lnx-kmods: Use new linux kernel version checking macros. Moved them to separate wrapper header.

  • 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 85698 2020-08-11 17:05:29Z vboxsync $ */
2/** @file
3 * IPRT - Initialization & Termination, R0 Driver, Linux.
4 */
5
6/*
7 * Copyright (C) 2006-2020 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/errcore.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 RTLNX_VER_MIN(2,5,41)
43static struct workqueue_struct *g_prtR0LnxWorkQueue;
44#else
45static DECLARE_TASK_QUEUE(g_rtR0LnxWorkQueue);
46#endif
47
48
49/**
50 * Pushes an item onto the IPRT work queue.
51 *
52 * @param pWork The work item.
53 * @param pfnWorker The callback function. It will be called back
54 * with @a pWork as argument.
55 */
56DECLHIDDEN(void) rtR0LnxWorkqueuePush(RTR0LNXWORKQUEUEITEM *pWork, void (*pfnWorker)(RTR0LNXWORKQUEUEITEM *))
57{
58 IPRT_LINUX_SAVE_EFL_AC();
59
60#if RTLNX_VER_MIN(2,5,41)
61# if RTLNX_VER_MIN(2,6,20)
62 INIT_WORK(pWork, pfnWorker);
63# else
64 INIT_WORK(pWork, (void (*)(void *))pfnWorker, pWork);
65# endif
66 queue_work(g_prtR0LnxWorkQueue, pWork);
67#else
68 INIT_TQUEUE(pWork, (void (*)(void *))pfnWorker, pWork);
69 queue_task(pWork, &g_rtR0LnxWorkQueue);
70#endif
71
72 IPRT_LINUX_RESTORE_EFL_AC();
73}
74
75
76/**
77 * Flushes all items in the IPRT work queue.
78 *
79 * @remarks This is mostly for 2.4.x compatability. Must not be called from
80 * atomic contexts or with unncessary locks held.
81 */
82DECLHIDDEN(void) rtR0LnxWorkqueueFlush(void)
83{
84 IPRT_LINUX_SAVE_EFL_AC();
85
86#if RTLNX_VER_MIN(2,5,41)
87 flush_workqueue(g_prtR0LnxWorkQueue);
88#else
89 run_task_queue(&g_rtR0LnxWorkQueue);
90#endif
91
92 IPRT_LINUX_RESTORE_EFL_AC();
93}
94
95
96DECLHIDDEN(int) rtR0InitNative(void)
97{
98 int rc = VINF_SUCCESS;
99 IPRT_LINUX_SAVE_EFL_AC();
100
101#if RTLNX_VER_MIN(2,5,41)
102 #if RTLNX_VER_MIN(2,6,13)
103 g_prtR0LnxWorkQueue = create_workqueue("iprt-VBoxWQueue");
104 #else
105 g_prtR0LnxWorkQueue = create_workqueue("iprt-VBoxQ");
106 #endif
107 if (!g_prtR0LnxWorkQueue)
108 rc = VERR_NO_MEMORY;
109#endif
110
111 IPRT_LINUX_RESTORE_EFL_AC();
112 return rc;
113}
114
115
116DECLHIDDEN(void) rtR0TermNative(void)
117{
118 IPRT_LINUX_SAVE_EFL_AC();
119
120 rtR0LnxWorkqueueFlush();
121#if RTLNX_VER_MIN(2,5,41)
122 destroy_workqueue(g_prtR0LnxWorkQueue);
123 g_prtR0LnxWorkQueue = NULL;
124#endif
125
126 rtR0MemExecCleanup();
127
128 IPRT_LINUX_RESTORE_EFL_AC();
129}
130
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