VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/PMUAll.cpp@ 107044

Last change on this file since 107044 was 106479, checked in by vboxsync, 5 weeks ago

VMMArm: Skeleton of the PMU device emulation enough to make Windows/ARM boot as a guest and have it out of the NEM darwin backend, bugref:10778 [release build fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1/* $Id: PMUAll.cpp 106479 2024-10-18 13:26:55Z vboxsync $ */
2/** @file
3 * PMU - Performance Monitoring Unit. - All Contexts.
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_PMU
33#include "PMUInternal.h"
34#include <VBox/vmm/pmu.h>
35#include <VBox/vmm/pdmdev.h>
36#include <VBox/vmm/vmcc.h>
37#include <VBox/vmm/vmm.h>
38#include <VBox/vmm/vmcpuset.h>
39#ifdef IN_RING0
40# include <VBox/vmm/gvmm.h>
41#endif
42
43#include <iprt/asm-arm.h>
44
45
46/*********************************************************************************************************************************
47* Internal Functions *
48*********************************************************************************************************************************/
49
50
51/*********************************************************************************************************************************
52* Global Variables *
53*********************************************************************************************************************************/
54
55/**
56 * Reads a PMU system register.
57 *
58 * @returns Strict VBox status code.
59 * @param pVCpu The cross context virtual CPU structure.
60 * @param u32Reg The system register being read.
61 * @param pu64Value Where to store the read value.
62 */
63VMM_INT_DECL(VBOXSTRICTRC) PMUReadSysReg(PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t *pu64Value)
64{
65 /*
66 * Validate.
67 */
68 VMCPU_ASSERT_EMT(pVCpu);
69 Assert(pu64Value);
70
71 *pu64Value = 0;
72
73#if 0
74 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, pDevIns->pCritSectRoR3, VERR_IGNORED);
75 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, pDevIns->pCritSectRoR3, rcLock);
76#endif
77
78 RT_NOREF(pVCpu);
79 switch (u32Reg)
80 {
81 case ARMV8_AARCH64_SYSREG_PMCCNTR_EL0:
82 *pu64Value = ASMReadTSC() * 100;
83 break;
84 case ARMV8_AARCH64_SYSREG_PMCR_EL0:
85 case ARMV8_AARCH64_SYSREG_PMCNTENCLR_EL0:
86 case ARMV8_AARCH64_SYSREG_PMUSERENR_EL0:
87 break;
88 default:
89 AssertReleaseFailed();
90 break;
91 }
92
93 //PDMDevHlpCritSectLeave(pDevIns, pDevIns->pCritSectRoR3);
94
95 LogFlowFunc(("pVCpu=%p u32Reg=%#x pu64Value=%RX64\n", pVCpu, u32Reg, *pu64Value));
96 return VINF_SUCCESS;
97}
98
99
100/**
101 * Writes an PMU system register.
102 *
103 * @returns Strict VBox status code.
104 * @param pVCpu The cross context virtual CPU structure.
105 * @param u32Reg The system register being written (IPRT system register identifier).
106 * @param u64Value The value to write.
107 */
108VMM_INT_DECL(VBOXSTRICTRC) PMUWriteSysReg(PVMCPUCC pVCpu, uint32_t u32Reg, uint64_t u64Value)
109{
110 /*
111 * Validate.
112 */
113 VMCPU_ASSERT_EMT(pVCpu);
114 LogFlowFunc(("pVCpu=%p u32Reg=%#x u64Value=%RX64\n", pVCpu, u32Reg, u64Value));
115
116#if 0
117 int const rcLock = PDMDevHlpCritSectEnter(pDevIns, pDevIns->pCritSectRoR3, VERR_IGNORED);
118 PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, pDevIns->pCritSectRoR3, rcLock);
119#endif
120
121 RT_NOREF(pVCpu, u64Value);
122 switch (u32Reg)
123 {
124 case ARMV8_AARCH64_SYSREG_PMCNTENCLR_EL0:
125 case ARMV8_AARCH64_SYSREG_PMOVSCLR_EL0:
126 case ARMV8_AARCH64_SYSREG_PMINTENCLR_EL1:
127 case ARMV8_AARCH64_SYSREG_PMCR_EL0:
128 case ARMV8_AARCH64_SYSREG_PMCCFILTR_EL0:
129 case ARMV8_AARCH64_SYSREG_PMCNTENSET_EL0:
130 case ARMV8_AARCH64_SYSREG_PMUSERENR_EL0:
131 case ARMV8_AARCH64_SYSREG_PMCCNTR_EL0:
132 break;
133 default:
134 AssertReleaseFailed();
135 break;
136 }
137
138 //PDMDevHlpCritSectLeave(pDevIns, pDevIns->pCritSectRoR3);
139 return VINF_SUCCESS;
140}
141
142
143#ifndef IN_RING3
144
145/**
146 * @callback_method_impl{PDMDEVREGR0,pfnConstruct}
147 */
148static DECLCALLBACK(int) pmuRZConstruct(PPDMDEVINS pDevIns)
149{
150 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
151 AssertReleaseFailed();
152 return VINF_SUCCESS;
153}
154#endif /* !IN_RING3 */
155
156/**
157 * PMU device registration structure.
158 */
159const PDMDEVREG g_DevicePMU =
160{
161 /* .u32Version = */ PDM_DEVREG_VERSION,
162 /* .uReserved0 = */ 0,
163 /* .szName = */ "pmu",
164 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RZ | PDM_DEVREG_FLAGS_NEW_STYLE,
165 /* .fClass = */ PDM_DEVREG_CLASS_ARCH,
166 /* .cMaxInstances = */ 1,
167 /* .uSharedVersion = */ 42,
168 /* .cbInstanceShared = */ sizeof(PMUDEV),
169 /* .cbInstanceCC = */ 0,
170 /* .cbInstanceRC = */ 0,
171 /* .cMaxPciDevices = */ 0,
172 /* .cMaxMsixVectors = */ 0,
173 /* .pszDescription = */ "Performance Monitoring Unit",
174#if defined(IN_RING3)
175 /* .szRCMod = */ "VMMRC.rc",
176 /* .szR0Mod = */ "VMMR0.r0",
177 /* .pfnConstruct = */ pmuR3Construct,
178 /* .pfnDestruct = */ pmuR3Destruct,
179 /* .pfnRelocate = */ pmuR3Relocate,
180 /* .pfnMemSetup = */ NULL,
181 /* .pfnPowerOn = */ NULL,
182 /* .pfnReset = */ pmuR3Reset,
183 /* .pfnSuspend = */ NULL,
184 /* .pfnResume = */ NULL,
185 /* .pfnAttach = */ NULL,
186 /* .pfnDetach = */ NULL,
187 /* .pfnQueryInterface = */ NULL,
188 /* .pfnInitComplete = */ NULL,
189 /* .pfnPowerOff = */ NULL,
190 /* .pfnSoftReset = */ NULL,
191 /* .pfnReserved0 = */ NULL,
192 /* .pfnReserved1 = */ NULL,
193 /* .pfnReserved2 = */ NULL,
194 /* .pfnReserved3 = */ NULL,
195 /* .pfnReserved4 = */ NULL,
196 /* .pfnReserved5 = */ NULL,
197 /* .pfnReserved6 = */ NULL,
198 /* .pfnReserved7 = */ NULL,
199#elif defined(IN_RING0)
200 /* .pfnEarlyConstruct = */ NULL,
201 /* .pfnConstruct = */ pmuRZConstruct,
202 /* .pfnDestruct = */ NULL,
203 /* .pfnFinalDestruct = */ NULL,
204 /* .pfnRequest = */ NULL,
205 /* .pfnReserved0 = */ NULL,
206 /* .pfnReserved1 = */ NULL,
207 /* .pfnReserved2 = */ NULL,
208 /* .pfnReserved3 = */ NULL,
209 /* .pfnReserved4 = */ NULL,
210 /* .pfnReserved5 = */ NULL,
211 /* .pfnReserved6 = */ NULL,
212 /* .pfnReserved7 = */ NULL,
213#elif defined(IN_RC)
214 /* .pfnConstruct = */ pmuRZConstruct,
215 /* .pfnReserved0 = */ NULL,
216 /* .pfnReserved1 = */ NULL,
217 /* .pfnReserved2 = */ NULL,
218 /* .pfnReserved3 = */ NULL,
219 /* .pfnReserved4 = */ NULL,
220 /* .pfnReserved5 = */ NULL,
221 /* .pfnReserved6 = */ NULL,
222 /* .pfnReserved7 = */ NULL,
223#else
224# error "Not in IN_RING3, IN_RING0 or IN_RC!"
225#endif
226 /* .u32VersionEnd = */ PDM_DEVREG_VERSION
227};
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