VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/GICR3Nem-darwin.cpp@ 107044

Last change on this file since 107044 was 105687, checked in by vboxsync, 3 months ago

VMMArm/GIC: Rename GICR3Kvm to GICR3Nem and add a stub for macOS Hypervisor.framework which will be handled by the NEM backend directly due to the hv_gic_* API being entangled with the rest of the hv_* API, bugref:10747

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
1/* $Id: GICR3Nem-darwin.cpp 105687 2024-08-15 12:45:46Z vboxsync $ */
2/** @file
3 * GIC - Generic Interrupt Controller Architecture (GICv3) - Hypervisor.framework in kernel interface.
4 */
5
6/*
7 * Copyright (C) 2024 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 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#define LOG_GROUP LOG_GROUP_DEV_APIC
33#include <VBox/log.h>
34#include "GICInternal.h"
35#include "NEMInternal.h" /* Need access to the VM file descriptor. */
36#include <VBox/vmm/gic.h>
37#include <VBox/vmm/cpum.h>
38#include <VBox/vmm/hm.h>
39#include <VBox/vmm/mm.h>
40#include <VBox/vmm/pdmdev.h>
41#include <VBox/vmm/ssm.h>
42#include <VBox/vmm/vm.h>
43
44#ifndef VBOX_DEVICE_STRUCT_TESTCASE
45
46
47/*********************************************************************************************************************************
48* Defined Constants And Macros *
49*********************************************************************************************************************************/
50
51
52/*********************************************************************************************************************************
53* Structures and Typedefs *
54*********************************************************************************************************************************/
55
56/**
57 * GICKvm PDM instance data (per-VM).
58 */
59typedef struct GICKVMDEV
60{
61 /** Pointer to the PDM device instance. */
62 PPDMDEVINSR3 pDevIns;
63} GICKVMDEV;
64/** Pointer to a GIC KVM device. */
65typedef GICKVMDEV *PGICKVMDEV;
66/** Pointer to a const GIC KVM device. */
67typedef GICKVMDEV const *PCGICKVMDEV;
68
69
70/*********************************************************************************************************************************
71* Global Variables *
72*********************************************************************************************************************************/
73
74
75
76/**
77 * @interface_method_impl{PDMDEVREG,pfnConstruct}
78 */
79DECLCALLBACK(int) gicR3NemConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
80{
81 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
82 PGICKVMDEV pThis = PDMDEVINS_2_DATA(pDevIns, PGICKVMDEV);
83 PVM pVM = PDMDevHlpGetVM(pDevIns);
84 PGIC pGic = VM_TO_GIC(pVM);
85 Assert(iInstance == 0); NOREF(iInstance);
86
87 RT_NOREF(pCfg);
88
89 /*
90 * Init the data.
91 */
92 pGic->pDevInsR3 = pDevIns;
93 pGic->fNemGic = true;
94 pThis->pDevIns = pDevIns;
95
96 /*
97 * Disable automatic PDM locking for this device.
98 */
99 int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
100 AssertRCReturn(rc, rc);
101
102 /*
103 * Register the GIC with PDM.
104 */
105 rc = PDMDevHlpApicRegister(pDevIns);
106 AssertLogRelRCReturn(rc, rc);
107
108 return VINF_SUCCESS;
109}
110
111
112/**
113 * GIC device registration structure.
114 */
115const PDMDEVREG g_DeviceGICNem =
116{
117 /* .u32Version = */ PDM_DEVREG_VERSION,
118 /* .uReserved0 = */ 0,
119 /* .szName = */ "gic-nem",
120 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_NEW_STYLE,
121 /* .fClass = */ PDM_DEVREG_CLASS_PIC,
122 /* .cMaxInstances = */ 1,
123 /* .uSharedVersion = */ 42,
124 /* .cbInstanceShared = */ sizeof(GICDEV),
125 /* .cbInstanceCC = */ 0,
126 /* .cbInstanceRC = */ 0,
127 /* .cMaxPciDevices = */ 0,
128 /* .cMaxMsixVectors = */ 0,
129 /* .pszDescription = */ "Generic Interrupt Controller",
130#if defined(IN_RING3)
131 /* .szRCMod = */ "VMMRC.rc",
132 /* .szR0Mod = */ "VMMR0.r0",
133 /* .pfnConstruct = */ gicR3NemConstruct,
134 /* .pfnDestruct = */ NULL,
135 /* .pfnRelocate = */ NULL,
136 /* .pfnMemSetup = */ NULL,
137 /* .pfnPowerOn = */ NULL,
138 /* .pfnReset = */ NULL,
139 /* .pfnSuspend = */ NULL,
140 /* .pfnResume = */ NULL,
141 /* .pfnAttach = */ NULL,
142 /* .pfnDetach = */ NULL,
143 /* .pfnQueryInterface = */ NULL,
144 /* .pfnInitComplete = */ NULL,
145 /* .pfnPowerOff = */ NULL,
146 /* .pfnSoftReset = */ NULL,
147 /* .pfnReserved0 = */ NULL,
148 /* .pfnReserved1 = */ NULL,
149 /* .pfnReserved2 = */ NULL,
150 /* .pfnReserved3 = */ NULL,
151 /* .pfnReserved4 = */ NULL,
152 /* .pfnReserved5 = */ NULL,
153 /* .pfnReserved6 = */ NULL,
154 /* .pfnReserved7 = */ NULL,
155#else
156# error "Not in IN_RING3!"
157#endif
158 /* .u32VersionEnd = */ PDM_DEVREG_VERSION
159};
160
161#endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
162
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