VirtualBox

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

Last change on this file since 96763 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.2 KB
Line 
1/* $Id: initterm-r0drv-linux.c 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * IPRT - Initialization & Termination, R0 Driver, Linux.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#include "the-linux-kernel.h"
42#include "internal/iprt.h"
43#include <iprt/errcore.h>
44#include <iprt/assert.h>
45#include "internal/initterm.h"
46
47
48/*********************************************************************************************************************************
49* Global Variables *
50*********************************************************************************************************************************/
51/** The IPRT work queue. */
52#if RTLNX_VER_MIN(2,5,41)
53static struct workqueue_struct *g_prtR0LnxWorkQueue;
54#else
55static DECLARE_TASK_QUEUE(g_rtR0LnxWorkQueue);
56#endif
57
58
59/**
60 * Pushes an item onto the IPRT work queue.
61 *
62 * @param pWork The work item.
63 * @param pfnWorker The callback function. It will be called back
64 * with @a pWork as argument.
65 */
66DECLHIDDEN(void) rtR0LnxWorkqueuePush(RTR0LNXWORKQUEUEITEM *pWork, void (*pfnWorker)(RTR0LNXWORKQUEUEITEM *))
67{
68 IPRT_LINUX_SAVE_EFL_AC();
69
70#if RTLNX_VER_MIN(2,5,41)
71# if RTLNX_VER_MIN(2,6,20)
72 INIT_WORK(pWork, pfnWorker);
73# else
74 INIT_WORK(pWork, (void (*)(void *))pfnWorker, pWork);
75# endif
76 queue_work(g_prtR0LnxWorkQueue, pWork);
77#else
78 INIT_TQUEUE(pWork, (void (*)(void *))pfnWorker, pWork);
79 queue_task(pWork, &g_rtR0LnxWorkQueue);
80#endif
81
82 IPRT_LINUX_RESTORE_EFL_AC();
83}
84
85
86/**
87 * Flushes all items in the IPRT work queue.
88 *
89 * @remarks This is mostly for 2.4.x compatability. Must not be called from
90 * atomic contexts or with unncessary locks held.
91 */
92DECLHIDDEN(void) rtR0LnxWorkqueueFlush(void)
93{
94 IPRT_LINUX_SAVE_EFL_AC();
95
96#if RTLNX_VER_MIN(2,5,41)
97 flush_workqueue(g_prtR0LnxWorkQueue);
98#else
99 run_task_queue(&g_rtR0LnxWorkQueue);
100#endif
101
102 IPRT_LINUX_RESTORE_EFL_AC();
103}
104
105
106DECLHIDDEN(int) rtR0InitNative(void)
107{
108 int rc = VINF_SUCCESS;
109 IPRT_LINUX_SAVE_EFL_AC();
110
111#if RTLNX_VER_MIN(2,5,41)
112 #if RTLNX_VER_MIN(2,6,13)
113 g_prtR0LnxWorkQueue = create_workqueue("iprt-VBoxWQueue");
114 #else
115 g_prtR0LnxWorkQueue = create_workqueue("iprt-VBoxQ");
116 #endif
117 if (!g_prtR0LnxWorkQueue)
118 rc = VERR_NO_MEMORY;
119#endif
120
121 IPRT_LINUX_RESTORE_EFL_AC();
122 return rc;
123}
124
125
126DECLHIDDEN(void) rtR0TermNative(void)
127{
128 IPRT_LINUX_SAVE_EFL_AC();
129
130 rtR0LnxWorkqueueFlush();
131#if RTLNX_VER_MIN(2,5,41)
132 destroy_workqueue(g_prtR0LnxWorkQueue);
133 g_prtR0LnxWorkQueue = NULL;
134#endif
135
136 rtR0MemExecCleanup();
137
138 IPRT_LINUX_RESTORE_EFL_AC();
139}
140
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