VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibCpuHotPlug.cpp@ 53402

Last change on this file since 53402 was 33540, checked in by vboxsync, 14 years ago

*: spelling fixes, thanks Timeless!

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: VBoxGuestR3LibCpuHotPlug.cpp 33540 2010-10-28 09:27:05Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, CPU Hot Plugging.
4 */
5
6/*
7 * Copyright (C) 2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*******************************************************************************
29* Header Files *
30*******************************************************************************/
31#include "VBGLR3Internal.h"
32
33
34/**
35 * Initialize CPU hot plugging.
36 *
37 * This will enable the CPU hot plugging events.
38 *
39 * @returns VBox status code.
40 */
41VBGLR3DECL(int) VbglR3CpuHotPlugInit(void)
42{
43 int rc = VbglR3CtlFilterMask(VMMDEV_EVENT_CPU_HOTPLUG, 0);
44 if (RT_FAILURE(rc))
45 return rc;
46
47 VMMDevCpuHotPlugStatusRequest Req;
48 vmmdevInitRequest(&Req.header, VMMDevReq_SetCpuHotPlugStatus);
49 Req.enmStatusType = VMMDevCpuStatusType_Enable;
50 rc = vbglR3GRPerform(&Req.header);
51 if (RT_FAILURE(rc))
52 VbglR3CtlFilterMask(0, VMMDEV_EVENT_CPU_HOTPLUG);
53
54 return rc;
55}
56
57
58/**
59 * Terminate CPU hot plugging.
60 *
61 * This will disable the CPU hot plugging events.
62 *
63 * @returns VBox status.
64 */
65VBGLR3DECL(int) VbglR3CpuHotPlugTerm(void)
66{
67 /* Clear the events. */
68 VbglR3CtlFilterMask(0, VMMDEV_EVENT_CPU_HOTPLUG);
69
70 VMMDevCpuHotPlugStatusRequest Req;
71 vmmdevInitRequest(&Req.header, VMMDevReq_SetCpuHotPlugStatus);
72 Req.enmStatusType = VMMDevCpuStatusType_Disable;
73 return vbglR3GRPerform(&Req.header);
74}
75
76
77/**
78 * Waits for a CPU hot plugging event and retrieve the data associated with it.
79 *
80 * @returns VBox status code.
81 * @param penmEventType Where to store the event type on success.
82 * @param pidCpuCore Where to store the CPU core ID on success.
83 * @param pidCpuPackage Where to store the CPU package ID on success.
84 */
85VBGLR3DECL(int) VbglR3CpuHotPlugWaitForEvent(VMMDevCpuEventType *penmEventType, uint32_t *pidCpuCore, uint32_t *pidCpuPackage)
86{
87 AssertPtrReturn(penmEventType, VERR_INVALID_POINTER);
88 AssertPtrReturn(pidCpuCore, VERR_INVALID_POINTER);
89 AssertPtrReturn(pidCpuPackage, VERR_INVALID_POINTER);
90
91 VBoxGuestWaitEventInfo waitEvent;
92 waitEvent.u32TimeoutIn = RT_INDEFINITE_WAIT;
93 waitEvent.u32EventMaskIn = VMMDEV_EVENT_CPU_HOTPLUG;
94 waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR;
95 waitEvent.u32EventFlagsOut = 0;
96 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent));
97 if (RT_SUCCESS(rc))
98 {
99 /* did we get the right event? */
100 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_CPU_HOTPLUG)
101 {
102 VMMDevGetCpuHotPlugRequest Req;
103
104 /* get the CPU hot plugging request */
105 vmmdevInitRequest(&Req.header, VMMDevReq_GetCpuHotPlugRequest);
106 Req.idCpuCore = UINT32_MAX;
107 Req.idCpuPackage = UINT32_MAX;
108 Req.enmEventType = VMMDevCpuEventType_None;
109 rc = vbglR3GRPerform(&Req.header);
110 if (RT_SUCCESS(rc))
111 {
112 *penmEventType = Req.enmEventType;
113 *pidCpuCore = Req.idCpuCore;
114 *pidCpuPackage = Req.idCpuPackage;
115 return VINF_SUCCESS;
116 }
117 }
118 else
119 rc = VERR_TRY_AGAIN;
120 }
121 return rc;
122}
123
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