VirtualBox

source: vbox/trunk/src/VBox/VMM/include/DBGFInline.h@ 96860

Last change on this file since 96860 was 96407, checked in by vboxsync, 22 months ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1/* $Id: DBGFInline.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * DBGF - Internal header file containing the inlined functions.
4 */
5
6/*
7 * Copyright (C) 2020-2022 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#ifndef VMM_INCLUDED_SRC_include_DBGFInline_h
29#define VMM_INCLUDED_SRC_include_DBGFInline_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34
35/**
36 * Initializes the given L2 table entry with the given values.
37 *
38 * @returns nothing.
39 * @param pL2Entry The L2 entry to intialize.
40 * @param hBp The breakpoint handle.
41 * @param GCPtr The GC pointer used as the key (only the upper 6 bytes are used).
42 * @param idxL2Left The left L2 table index.
43 * @param idxL2Right The right L2 table index.
44 * @param iDepth The depth of the node in the tree.
45 */
46DECLINLINE(void) dbgfBpL2TblEntryInit(PDBGFBPL2ENTRY pL2Entry, DBGFBP hBp, RTGCPTR GCPtr,
47 uint32_t idxL2Left, uint32_t idxL2Right, uint8_t iDepth)
48{
49 uint64_t u64GCPtrKeyAndBpHnd1 = ((uint64_t)hBp & DBGF_BP_L2_ENTRY_BP_1ST_MASK) << DBGF_BP_L2_ENTRY_BP_1ST_SHIFT
50 | DBGF_BP_INT3_L2_KEY_EXTRACT_FROM_ADDR(GCPtr);
51 uint64_t u64LeftRightIdxDepthBpHnd2 = (((uint64_t)hBp & DBGF_BP_L2_ENTRY_BP_2ND_MASK) >> 16) << DBGF_BP_L2_ENTRY_BP_2ND_SHIFT
52 | ((uint64_t)iDepth << DBGF_BP_L2_ENTRY_DEPTH_SHIFT)
53 | ((uint64_t)idxL2Right << DBGF_BP_L2_ENTRY_RIGHT_IDX_SHIFT)
54 | ((uint64_t)idxL2Left << DBGF_BP_L2_ENTRY_LEFT_IDX_SHIFT);
55
56 ASMAtomicWriteU64(&pL2Entry->u64GCPtrKeyAndBpHnd1, u64GCPtrKeyAndBpHnd1);
57 ASMAtomicWriteU64(&pL2Entry->u64LeftRightIdxDepthBpHnd2, u64LeftRightIdxDepthBpHnd2);
58}
59
60
61/**
62 * Updates the given L2 table entry with the new pointers.
63 *
64 * @returns nothing.
65 * @param pL2Entry The L2 entry to update.
66 * @param idxL2Left The new left L2 table index.
67 * @param idxL2Right The new right L2 table index.
68 * @param iDepth The new depth of the tree.
69 */
70DECLINLINE(void) dbgfBpL2TblEntryUpdate(PDBGFBPL2ENTRY pL2Entry, uint32_t idxL2Left, uint32_t idxL2Right,
71 uint8_t iDepth)
72{
73 uint64_t u64LeftRightIdxDepthBpHnd2 = ASMAtomicReadU64(&pL2Entry->u64LeftRightIdxDepthBpHnd2) & DBGF_BP_L2_ENTRY_BP_2ND_L2_ENTRY_MASK;
74 u64LeftRightIdxDepthBpHnd2 |= ((uint64_t)iDepth << DBGF_BP_L2_ENTRY_DEPTH_SHIFT)
75 | ((uint64_t)idxL2Right << DBGF_BP_L2_ENTRY_RIGHT_IDX_SHIFT)
76 | ((uint64_t)idxL2Left << DBGF_BP_L2_ENTRY_LEFT_IDX_SHIFT);
77
78 ASMAtomicWriteU64(&pL2Entry->u64LeftRightIdxDepthBpHnd2, u64LeftRightIdxDepthBpHnd2);
79}
80
81
82/**
83 * Updates the given L2 table entry with the left pointer.
84 *
85 * @returns nothing.
86 * @param pL2Entry The L2 entry to update.
87 * @param idxL2Left The new left L2 table index.
88 * @param iDepth The new depth of the tree.
89 */
90DECLINLINE(void) dbgfBpL2TblEntryUpdateLeft(PDBGFBPL2ENTRY pL2Entry, uint32_t idxL2Left, uint8_t iDepth)
91{
92 uint64_t u64LeftRightIdxDepthBpHnd2 = ASMAtomicReadU64(&pL2Entry->u64LeftRightIdxDepthBpHnd2) & ( DBGF_BP_L2_ENTRY_BP_2ND_L2_ENTRY_MASK
93 | DBGF_BP_L2_ENTRY_RIGHT_IDX_MASK);
94
95 u64LeftRightIdxDepthBpHnd2 |= ((uint64_t)iDepth << DBGF_BP_L2_ENTRY_DEPTH_SHIFT)
96 | ((uint64_t)idxL2Left << DBGF_BP_L2_ENTRY_LEFT_IDX_SHIFT);
97
98 ASMAtomicWriteU64(&pL2Entry->u64LeftRightIdxDepthBpHnd2, u64LeftRightIdxDepthBpHnd2);
99}
100
101
102/**
103 * Updates the given L2 table entry with the right pointer.
104 *
105 * @returns nothing.
106 * @param pL2Entry The L2 entry to update.
107 * @param idxL2Right The new right L2 table index.
108 * @param iDepth The new depth of the tree.
109 */
110DECLINLINE(void) dbgfBpL2TblEntryUpdateRight(PDBGFBPL2ENTRY pL2Entry, uint32_t idxL2Right, uint8_t iDepth)
111{
112 uint64_t u64LeftRightIdxDepthBpHnd2 = ASMAtomicReadU64(&pL2Entry->u64LeftRightIdxDepthBpHnd2) & ( DBGF_BP_L2_ENTRY_BP_2ND_L2_ENTRY_MASK
113 | DBGF_BP_L2_ENTRY_LEFT_IDX_MASK);
114
115 u64LeftRightIdxDepthBpHnd2 |= ((uint64_t)iDepth << DBGF_BP_L2_ENTRY_DEPTH_SHIFT)
116 | ((uint64_t)idxL2Right << DBGF_BP_L2_ENTRY_RIGHT_IDX_SHIFT);
117
118 ASMAtomicWriteU64(&pL2Entry->u64LeftRightIdxDepthBpHnd2, u64LeftRightIdxDepthBpHnd2);
119}
120
121#ifdef IN_RING3
122/**
123 * Returns the internal breakpoint owner state for the given handle.
124 *
125 * @returns Pointer to the internal breakpoint owner state or NULL if the handle is invalid.
126 * @param pUVM The user mode VM handle.
127 * @param hBpOwner The breakpoint owner handle to resolve.
128 */
129DECLINLINE(PDBGFBPOWNERINT) dbgfR3BpOwnerGetByHnd(PUVM pUVM, DBGFBPOWNER hBpOwner)
130{
131 AssertReturn(hBpOwner < DBGF_BP_OWNER_COUNT_MAX, NULL);
132 AssertPtrReturn(pUVM->dbgf.s.pbmBpOwnersAllocR3, NULL);
133
134 AssertReturn(ASMBitTest(pUVM->dbgf.s.pbmBpOwnersAllocR3, hBpOwner), NULL);
135 return &pUVM->dbgf.s.paBpOwnersR3[hBpOwner];
136}
137#endif
138
139#endif /* !VMM_INCLUDED_SRC_include_DBGFInline_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use