VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibCpuHotplug.cpp@ 25976

Last change on this file since 25976 was 25976, checked in by vboxsync, 15 years ago

Build fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/* $Id: VBoxGuestR3LibCpuHotplug.cpp 25976 2010-01-22 15:40:27Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, CPU hotplug.
4 */
5
6/*
7 * Copyright (C) 2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#include "VBGLR3Internal.h"
27
28VBGLR3DECL(int) VbglR3CpuHotplugInit(void)
29{
30 int rc = VINF_SUCCESS;
31 VMMDevCpuHotPlugStatusRequest Req;
32 vmmdevInitRequest(&Req.header, VMMDevReq_SetCpuHotPlugStatus);
33 Req.enmStatusType = VMMDevCpuStatusType_Enable;
34
35 rc = VbglR3CtlFilterMask(VMMDEV_EVENT_CPU_HOTPLUG, 0);
36 if (RT_FAILURE(rc))
37 return rc;
38
39 rc = vbglR3GRPerform(&Req.header);
40 if (RT_FAILURE(rc))
41 VbglR3CtlFilterMask(0, VMMDEV_EVENT_CPU_HOTPLUG);
42
43 return rc;
44}
45
46VBGLR3DECL(int) VbglR3CpuHotplugTerm(void)
47{
48 VMMDevCpuHotPlugStatusRequest Req;
49 vmmdevInitRequest(&Req.header, VMMDevReq_SetCpuHotPlugStatus);
50 Req.enmStatusType = VMMDevCpuStatusType_Disable;
51
52 /* Clear the events. */
53 VbglR3CtlFilterMask(0, VMMDEV_EVENT_CPU_HOTPLUG);
54
55 int rc = vbglR3GRPerform(&Req.header);
56 return rc;
57}
58
59VBGLR3DECL(int) VbglR3CpuHotplugWaitForEvent(VMMDevCpuEventType *penmEventType, uint32_t *pidCpuCore, uint32_t *pidCpuPackage)
60{
61 VBoxGuestWaitEventInfo waitEvent;
62 int rc;
63
64 AssertPtrReturn(penmEventType, VERR_INVALID_PARAMETER);
65 AssertPtrReturn(pidCpuCore, VERR_INVALID_PARAMETER);
66 AssertPtrReturn(pidCpuPackage, VERR_INVALID_PARAMETER);
67 waitEvent.u32TimeoutIn = RT_INDEFINITE_WAIT;
68 waitEvent.u32EventMaskIn = VMMDEV_EVENT_CPU_HOTPLUG;
69 waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR;
70 waitEvent.u32EventFlagsOut = 0;
71 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent));
72 if (RT_SUCCESS(rc))
73 {
74 /* did we get the right event? */
75 if (waitEvent.u32EventFlagsOut & VMMDEV_EVENT_CPU_HOTPLUG)
76 {
77 VMMDevGetCpuHotplugRequest Req;
78
79 /* get the seamless change request */
80 vmmdevInitRequest(&Req.header, VMMDevReq_GetCpuHotPlugRequest);
81 Req.idCpuCore = UINT32_MAX;
82 Req.idCpuPackage = UINT32_MAX;
83 Req.enmEventType = VMMDevCpuEventType_None;
84 rc = vbglR3GRPerform(&Req.header);
85 if (RT_SUCCESS(rc))
86 {
87 *penmEventType = Req.enmEventType;
88 *pidCpuCore = Req.idCpuCore;
89 *pidCpuPackage = Req.idCpuPackage;
90 return VINF_SUCCESS;
91 }
92 }
93 else
94 rc = VERR_TRY_AGAIN;
95 }
96 return rc;
97}
98
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