VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/HostX86Impl.cpp

Last change on this file was 106061, checked in by vboxsync, 8 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.1 KB
Line 
1/* $Id: HostX86Impl.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation - x86 host specific IHost methods / attributes.
4 */
5
6/*
7 * Copyright (C) 2023-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#define LOG_GROUP LOG_GROUP_MAIN_HOSTX86
29#include "LoggingNew.h"
30
31#include "HostX86Impl.h"
32
33#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
34# include <iprt/asm-amd64-x86.h>
35#endif
36#include <iprt/mp.h>
37
38
39/*
40 * HostX86 implementation.
41 */
42DEFINE_EMPTY_CTOR_DTOR(HostX86)
43
44HRESULT HostX86::FinalConstruct()
45{
46 return BaseFinalConstruct();
47}
48
49void HostX86::FinalRelease()
50{
51 uninit();
52
53 BaseFinalRelease();
54}
55
56HRESULT HostX86::init(void)
57{
58 /* Enclose the state transition NotReady->InInit->Ready */
59 AutoInitSpan autoInitSpan(this);
60 AssertReturn(autoInitSpan.isOk(), E_FAIL);
61
62 /* Confirm a successful initialization */
63 autoInitSpan.setSucceeded();
64
65 return S_OK;
66}
67
68void HostX86::uninit()
69{
70 /* Enclose the state transition Ready->InUninit->NotReady */
71 AutoUninitSpan autoUninitSpan(this);
72 if (autoUninitSpan.uninitDone())
73 return;
74}
75
76/**
77 * Returns the specific CPUID leaf.
78 *
79 * @returns COM status code
80 * @param aCpuId The CPU number. Mostly ignored.
81 * @param aLeaf The leaf number.
82 * @param aSubLeaf The sub-leaf number.
83 * @param aValEAX Where to return EAX.
84 * @param aValEBX Where to return EBX.
85 * @param aValECX Where to return ECX.
86 * @param aValEDX Where to return EDX.
87 */
88HRESULT HostX86::getProcessorCPUIDLeaf(ULONG aCpuId, ULONG aLeaf, ULONG aSubLeaf,
89 ULONG *aValEAX, ULONG *aValEBX, ULONG *aValECX, ULONG *aValEDX)
90{
91 // no locking required
92
93 /* Check that the CPU is online. */
94 /** @todo later use RTMpOnSpecific. */
95 if (!RTMpIsCpuOnline(aCpuId))
96 return RTMpIsCpuPresent(aCpuId)
97 ? setError(E_FAIL, tr("CPU no.%u is not present"), aCpuId)
98 : setError(E_FAIL, tr("CPU no.%u is not online"), aCpuId);
99
100#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
101 uint32_t uEAX, uEBX, uECX, uEDX;
102 ASMCpuId_Idx_ECX(aLeaf, aSubLeaf, &uEAX, &uEBX, &uECX, &uEDX);
103 *aValEAX = uEAX;
104 *aValEBX = uEBX;
105 *aValECX = uECX;
106 *aValEDX = uEDX;
107#else
108 RT_NOREF(aLeaf, aSubLeaf);
109 *aValEAX = 0;
110 *aValEBX = 0;
111 *aValECX = 0;
112 *aValEDX = 0;
113#endif
114
115 return S_OK;
116}
117
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