VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/PMUR3.cpp@ 106476

Last change on this file since 106476 was 106476, checked in by vboxsync, 4 months 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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/* $Id: PMUR3.cpp 106476 2024-10-18 12:57:36Z 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#if 0
86 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
87 {
88 PVMCPU pVCpuDest = pVM->apCpusR3[idCpu];
89
90 @todo
91 }
92#endif
93}
94
95
96/**
97 * @interface_method_impl{PDMDEVREG,pfnRelocate}
98 */
99DECLCALLBACK(void) pmuR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
100{
101 RT_NOREF(pDevIns, offDelta);
102}
103
104
105/**
106 * @interface_method_impl{PDMDEVREG,pfnDestruct}
107 */
108DECLCALLBACK(int) pmuR3Destruct(PPDMDEVINS pDevIns)
109{
110 LogFlowFunc(("pDevIns=%p\n", pDevIns));
111 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
112
113 return VINF_SUCCESS;
114}
115
116
117/**
118 * @interface_method_impl{PDMDEVREG,pfnConstruct}
119 */
120DECLCALLBACK(int) pmuR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
121{
122 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
123 PVM pVM = PDMDevHlpGetVM(pDevIns);
124 Assert(iInstance == 0); NOREF(iInstance); RT_NOREF(pCfg);
125
126 /*
127 * Init the data.
128 */
129 //pPmu->pDevInsR3 = pDevIns;
130
131 /*
132 * Validate PMU settings.
133 */
134 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "", "");
135
136 /*
137 * Disable automatic PDM locking for this device.
138 */
139 int rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
140 AssertRCReturn(rc, rc);
141
142 /*
143 * Initialize the PMU state.
144 */
145 for (uint32_t i = 0; i < RT_ELEMENTS(g_aSysRegRanges_PMU); i++)
146 {
147 rc = CPUMR3SysRegRangesInsert(pVM, &g_aSysRegRanges_PMU[i]);
148 AssertLogRelRCReturn(rc, rc);
149 }
150
151#if 0
152
153 /* Finally, initialize the state. */
154 rc = pmuR3InitState(pVM);
155 AssertRCReturn(rc, rc);
156
157 pmuR3Reset(pDevIns);
158#endif
159 return VINF_SUCCESS;
160}
161
162#endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
163
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