VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/PDMR0Driver.cpp@ 84007

Last change on this file since 84007 was 84007, checked in by vboxsync, 5 years ago

VMMR0: Move the PDM R0 device helper into its own file like it is done in R3, move the PDM R0 driver helpers to PDMR0Driver as it belongs there really

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/* $Id: PDMR0Driver.cpp 84007 2020-04-27 13:23:11Z vboxsync $ */
2/** @file
3 * PDM - Pluggable Device and Driver Manager, R0 Driver parts.
4 */
5
6/*
7 * Copyright (C) 2010-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
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_PDM_DRIVER
23#include "PDMInternal.h"
24#include <VBox/vmm/pdm.h>
25#include <VBox/vmm/vmcc.h>
26#include <VBox/vmm/gvmm.h>
27
28#include <VBox/log.h>
29#include <iprt/errcore.h>
30#include <iprt/assert.h>
31
32
33
34/** @name Ring-0 Context Driver Helpers
35 * @{
36 */
37
38/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetError} */
39static DECLCALLBACK(int) pdmR0DrvHlp_VMSetError(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
40{
41 PDMDRV_ASSERT_DRVINS(pDrvIns);
42 va_list args;
43 va_start(args, pszFormat);
44 int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMR0, rc, RT_SRC_POS_ARGS, pszFormat, args); Assert(rc2 == rc); NOREF(rc2);
45 va_end(args);
46 return rc;
47}
48
49
50/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetErrorV} */
51static DECLCALLBACK(int) pdmR0DrvHlp_VMSetErrorV(PPDMDRVINS pDrvIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
52{
53 PDMDRV_ASSERT_DRVINS(pDrvIns);
54 int rc2 = VMSetErrorV(pDrvIns->Internal.s.pVMR0, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
55 return rc;
56}
57
58
59/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetRuntimeError} */
60static DECLCALLBACK(int) pdmR0DrvHlp_VMSetRuntimeError(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
61 const char *pszFormat, ...)
62{
63 PDMDRV_ASSERT_DRVINS(pDrvIns);
64 va_list va;
65 va_start(va, pszFormat);
66 int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVMR0, fFlags, pszErrorId, pszFormat, va);
67 va_end(va);
68 return rc;
69}
70
71
72/** @interface_method_impl{PDMDRVHLPR0,pfnVMSetRuntimeErrorV} */
73static DECLCALLBACK(int) pdmR0DrvHlp_VMSetRuntimeErrorV(PPDMDRVINS pDrvIns, uint32_t fFlags, const char *pszErrorId,
74 const char *pszFormat, va_list va)
75{
76 PDMDRV_ASSERT_DRVINS(pDrvIns);
77 int rc = VMSetRuntimeErrorV(pDrvIns->Internal.s.pVMR0, fFlags, pszErrorId, pszFormat, va);
78 return rc;
79}
80
81
82/** @interface_method_impl{PDMDRVHLPR0,pfnAssertEMT} */
83static DECLCALLBACK(bool) pdmR0DrvHlp_AssertEMT(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
84{
85 PDMDRV_ASSERT_DRVINS(pDrvIns);
86 if (VM_IS_EMT(pDrvIns->Internal.s.pVMR0))
87 return true;
88
89 RTAssertMsg1Weak("AssertEMT", iLine, pszFile, pszFunction);
90 RTAssertPanic();
91 return false;
92}
93
94
95/** @interface_method_impl{PDMDRVHLPR0,pfnAssertOther} */
96static DECLCALLBACK(bool) pdmR0DrvHlp_AssertOther(PPDMDRVINS pDrvIns, const char *pszFile, unsigned iLine, const char *pszFunction)
97{
98 PDMDRV_ASSERT_DRVINS(pDrvIns);
99 if (!VM_IS_EMT(pDrvIns->Internal.s.pVMR0))
100 return true;
101
102 RTAssertMsg1Weak("AssertOther", iLine, pszFile, pszFunction);
103 RTAssertPanic();
104 return false;
105}
106
107
108/**
109 * The Ring-0 Context Driver Helper Callbacks.
110 */
111extern DECLEXPORT(const PDMDRVHLPR0) g_pdmR0DrvHlp =
112{
113 PDM_DRVHLPRC_VERSION,
114 pdmR0DrvHlp_VMSetError,
115 pdmR0DrvHlp_VMSetErrorV,
116 pdmR0DrvHlp_VMSetRuntimeError,
117 pdmR0DrvHlp_VMSetRuntimeErrorV,
118 pdmR0DrvHlp_AssertEMT,
119 pdmR0DrvHlp_AssertOther,
120 PDM_DRVHLPRC_VERSION
121};
122
123/** @} */
124
125
126
127/**
128 * PDMDrvHlpCallR0 helper.
129 *
130 * @returns See PFNPDMDRVREQHANDLERR0.
131 * @param pGVM The global (ring-0) VM structure. (For validation.)
132 * @param pReq Pointer to the request buffer.
133 */
134VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(PGVM pGVM, PPDMDRIVERCALLREQHANDLERREQ pReq)
135{
136 /*
137 * Validate input and make the call.
138 */
139 int rc = GVMMR0ValidateGVM(pGVM);
140 if (RT_SUCCESS(rc))
141 {
142 AssertPtrReturn(pReq, VERR_INVALID_POINTER);
143 AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
144
145 PPDMDRVINS pDrvIns = pReq->pDrvInsR0;
146 AssertPtrReturn(pDrvIns, VERR_INVALID_POINTER);
147 AssertReturn(pDrvIns->Internal.s.pVMR0 == pGVM, VERR_INVALID_PARAMETER);
148
149 PFNPDMDRVREQHANDLERR0 pfnReqHandlerR0 = pDrvIns->Internal.s.pfnReqHandlerR0;
150 AssertPtrReturn(pfnReqHandlerR0, VERR_INVALID_POINTER);
151
152 rc = pfnReqHandlerR0(pDrvIns, pReq->uOperation, pReq->u64Arg);
153 }
154 return rc;
155}
156
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