VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/DBGFCpu.cpp@ 45457

Last change on this file since 45457 was 44529, checked in by vboxsync, 12 years ago

header (C) fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1/* $Id: DBGFCpu.cpp 44529 2013-02-04 15:54:15Z vboxsync $ */
2/** @file
3 * DBGF - Debugger Facility, CPU State Accessors.
4 */
5
6/*
7 * Copyright (C) 2009-2013 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
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#define LOG_GROUP LOG_GROUP_DBGF
23#include <VBox/vmm/dbgf.h>
24#include <VBox/vmm/cpum.h>
25#include "DBGFInternal.h"
26#include <VBox/vmm/vm.h>
27#include <VBox/vmm/uvm.h>
28#include <VBox/err.h>
29#include <VBox/log.h>
30#include <VBox/param.h>
31#include <iprt/assert.h>
32
33
34/**
35 * Wrapper around CPUMGetGuestMode.
36 *
37 * @returns VINF_SUCCESS.
38 * @param pVM Pointer to the VM.
39 * @param idCpu The current CPU ID.
40 * @param penmMode Where to return the mode.
41 */
42static DECLCALLBACK(int) dbgfR3CpuGetMode(PVM pVM, VMCPUID idCpu, CPUMMODE *penmMode)
43{
44 Assert(idCpu == VMMGetCpuId(pVM));
45 PVMCPU pVCpu = VMMGetCpuById(pVM, idCpu);
46 *penmMode = CPUMGetGuestMode(pVCpu);
47 return VINF_SUCCESS;
48}
49
50
51/**
52 * Get the current CPU mode.
53 *
54 * @returns The CPU mode on success, CPUMMODE_INVALID on failure.
55 * @param pUVM The user mode VM handle.
56 * @param idCpu The target CPU ID.
57 */
58VMMR3DECL(CPUMMODE) DBGFR3CpuGetMode(PUVM pUVM, VMCPUID idCpu)
59{
60 UVM_ASSERT_VALID_EXT_RETURN(pUVM, CPUMMODE_INVALID);
61 VM_ASSERT_VALID_EXT_RETURN(pUVM->pVM, CPUMMODE_INVALID);
62 AssertReturn(idCpu < pUVM->pVM->cCpus, CPUMMODE_INVALID);
63
64 CPUMMODE enmMode;
65 int rc = VMR3ReqPriorityCallWaitU(pUVM, idCpu, (PFNRT)dbgfR3CpuGetMode, 3, pUVM->pVM, idCpu, &enmMode);
66 if (RT_FAILURE(rc))
67 return CPUMMODE_INVALID;
68 return enmMode;
69}
70
71
72/**
73 * Get the number of CPUs (or threads if you insist).
74 *
75 * @returns The number of CPUs
76 * @param pUVM The user mode VM handle.
77 */
78VMMR3DECL(VMCPUID) DBGFR3CpuGetCount(PUVM pUVM)
79{
80 UVM_ASSERT_VALID_EXT_RETURN(pUVM, 1);
81 return pUVM->cCpus;
82}
83
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