VirtualBox

source: vbox/trunk/include/VBox/vmm/vmcc.h@ 80268

Last change on this file since 80268 was 80268, checked in by vboxsync, 6 years ago

VMM: Refactoring VMMAll/* to use VMCC & VMMCPUCC. bugref:9217

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/** @file
2 * VM - The Virtual Machine, GVM/GVMCPU or VM/VMCPU depending on context.
3 */
4
5/*
6 * Copyright (C) 2019 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_vmm_vmcc_h
27#define VBOX_INCLUDED_vmm_vmcc_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32
33#include <VBox/vmm/vm.h>
34#ifdef IN_RING0
35# include <VBox/vmm/gvm.h>
36#else
37# include <VBox/vmm/uvm.h>
38#endif
39
40/** @typedef VMCC
41 * Context specific VM derived structure.
42 * This is plain VM in ring-3 and GVM (inherits from VM) in ring-0. */
43/** @typedef VMCPUCC
44 * Context specific VMCPU derived structure.
45 * This is plain VM in ring-3 and GVMCPU (inherits from VMCPU) in ring-0. */
46#ifdef IN_RING0
47typedef GVM VMCC;
48typedef GVMCPU VMCPUCC;
49#else
50typedef VM VMCC;
51typedef VMCPU VMCPUCC;
52#endif
53
54/** @def VMCC_GET_CPU_0
55 * Gets the context specfic pointer to virtual CPU \#0.
56 * @param a_pVM The context specfic VM structure.
57 */
58#if defined(IN_RING0) && defined(VBOX_BUGREF_9217)
59# define VMCC_GET_CPU_0(a_pVM) (&(a_pVM)->aCpus[0])
60#else
61# define VMCC_GET_CPU_0(a_pVM) ((a_pVM)->CTX_SUFF(apCpus)[0])
62#endif
63
64/** @def VMCC_GET_CPU
65 * Gets the context specfic pointer to a virtual CPU by index (ID).
66 * @param a_pVM The context specfic VM structure.
67 * @param a_idCpu The CPU number to get (caller ensures validity).
68 */
69#if defined(IN_RING0) && defined(VBOX_BUGREF_9217)
70# define VMCC_GET_CPU(a_pVM, a_idCpu) (&(a_pVM)->aCpus[(a_idCpu)])
71#else
72# define VMCC_GET_CPU(a_pVM, a_idCpu) ((a_pVM)->CTX_SUFF(apCpus)[(a_idCpu)])
73#endif
74
75/** @def VMCC_FOR_EACH_VMCPU
76 * For enumerating VCpus in ascending order, avoiding unnecessary apCpusR0
77 * access in ring-0, caching the CPU count and not checking for CPU \#0.
78 * @note Close loop with VMCC_FOR_EACH_VMCPU_END. */
79/** @def VMCC_FOR_EACH_VMCPU_END
80 * Ends a VMCC_FOR_EACH_VMCPU loop. */
81#define VMCC_FOR_EACH_VMCPU(a_pVM) \
82 { \
83 VMCPUID idCpu = 0; \
84 VMCPUID const cCpus = (a_pVM)->cCpus; \
85 PVMCPUCC pVCpu = VMCC_GET_CPU_0(a_pVM); \
86 for (;;) \
87 {
88#define VMCC_FOR_EACH_VMCPU_END(a_pVM) \
89 /* advance */ \
90 if (++idCpu >= cCpus) \
91 break; \
92 pVCpu = VMCC_GET_CPU(pVM, idCpu); \
93 } \
94 } do { } while(0)
95
96#endif /* !VBOX_INCLUDED_vmm_vmcc_h */
97
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette