VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/PMUR3.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: 5.1 KB
Line 
1/* $Id: PMUR3.cpp 106479 2024-10-18 13:26:55Z vboxsync $ */
2/** @file
3 * PMU - Performance Monitoring Unit.
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 <VBox/log.h>
34#include "PMUInternal.h"
35#include <VBox/vmm/gic.h>
36#include <VBox/vmm/cpum.h>
37#include <VBox/vmm/hm.h>
38#include <VBox/vmm/mm.h>
39#include <VBox/vmm/pdmdev.h>
40#include <VBox/vmm/ssm.h>
41#include <VBox/vmm/vm.h>
42
43#include <iprt/armv8.h>
44
45
46#ifndef VBOX_DEVICE_STRUCT_TESTCASE
47
48
49/*********************************************************************************************************************************
50* Defined Constants And Macros *
51*********************************************************************************************************************************/
52
53
54# define PMU_SYSREGRANGE(a_uFirst, a_uLast, a_szName) \
55 { (a_uFirst), (a_uLast), kCpumSysRegRdFn_Pmu, kCpumSysRegWrFn_Pmu, 0, 0, 0, 0, 0, 0, a_szName, { 0 }, { 0 }, { 0 }, { 0 } }
56
57
58/*********************************************************************************************************************************
59* Global Variables *
60*********************************************************************************************************************************/
61/**
62 * System register ranges for the PMU.
63 */
64static CPUMSYSREGRANGE const g_aSysRegRanges_PMU[] =
65{
66 PMU_SYSREGRANGE(ARMV8_AARCH64_SYSREG_PMINTENCLR_EL1, ARMV8_AARCH64_SYSREG_PMINTENCLR_EL1, "PMINTENCLR_EL1"),
67 PMU_SYSREGRANGE(ARMV8_AARCH64_SYSREG_PMCR_EL0, ARMV8_AARCH64_SYSREG_PMOVSCLR_EL0, "PMCR_EL0 - PMOVSCLR_EL0"),
68 PMU_SYSREGRANGE(ARMV8_AARCH64_SYSREG_PMCCNTR_EL0, ARMV8_AARCH64_SYSREG_PMCCNTR_EL0, "PMCCNTR_EL0"),
69 PMU_SYSREGRANGE(ARMV8_AARCH64_SYSREG_PMUSERENR_EL0, ARMV8_AARCH64_SYSREG_PMUSERENR_EL0, "PMUSERENR_EL0"),
70 PMU_SYSREGRANGE(ARMV8_AARCH64_SYSREG_PMCCFILTR_EL0, ARMV8_AARCH64_SYSREG_PMCCFILTR_EL0, "PMCCFILTR_EL0"),
71};
72
73
74/**
75 * @interface_method_impl{PDMDEVREG,pfnReset}
76 */
77DECLCALLBACK(void) pmuR3Reset(PPDMDEVINS pDevIns)
78{
79 PVM pVM = PDMDevHlpGetVM(pDevIns);
80 VM_ASSERT_EMT0(pVM);
81 VM_ASSERT_IS_NOT_RUNNING(pVM);
82
83 LogFlow(("PMU: pmuR3Reset\n"));
84
85 RT_NOREF(pVM);
86#if 0
87 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
88 {
89 PVMCPU pVCpuDest = pVM->apCpusR3[idCpu];
90
91 @todo
92 }
93#endif
94}
95
96
97/**
98 * @interface_method_impl{PDMDEVREG,pfnRelocate}
99 */
100DECLCALLBACK(void) pmuR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
101{
102 RT_NOREF(pDevIns, offDelta);
103}
104
105
106/**
107 * @interface_method_impl{PDMDEVREG,pfnDestruct}
108 */
109DECLCALLBACK(int) pmuR3Destruct(PPDMDEVINS pDevIns)
110{
111 LogFlowFunc(("pDevIns=%p\n", pDevIns));
112 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
113
114 return VINF_SUCCESS;
115}
116
117
118/**
119 * @interface_method_impl{PDMDEVREG,pfnConstruct}
120 */
121DECLCALLBACK(int) pmuR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
122{
123 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
124 PVM pVM = PDMDevHlpGetVM(pDevIns);
125 Assert(iInstance == 0); NOREF(iInstance); RT_NOREF(pCfg);
126
127 /*
128 * Init the data.
129 */
130 //pPmu->pDevInsR3 = pDevIns;
131
132 /*
133 * Validate PMU settings.
134 */
135 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "", "");
136
137 /*
138 * Disable automatic PDM locking for this device.
139 */
140 int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
141 AssertRCReturn(rc, rc);
142
143 /*
144 * Initialize the PMU state.
145 */
146 for (uint32_t i = 0; i < RT_ELEMENTS(g_aSysRegRanges_PMU); i++)
147 {
148 rc = CPUMR3SysRegRangesInsert(pVM, &g_aSysRegRanges_PMU[i]);
149 AssertLogRelRCReturn(rc, rc);
150 }
151
152#if 0
153
154 /* Finally, initialize the state. */
155 rc = pmuR3InitState(pVM);
156 AssertRCReturn(rc, rc);
157
158 pmuR3Reset(pDevIns);
159#endif
160 return VINF_SUCCESS;
161}
162
163#endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
164
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