VirtualBox

source: vbox/trunk/src/VBox/VMM/DBGFAddr.cpp@ 4014

Last change on this file since 4014 was 2981, checked in by vboxsync, 17 years ago

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1/* $Id: DBGFAddr.cpp 2981 2007-06-01 16:01:28Z vboxsync $ */
2/** @file
3 * VMM DBGF - Debugger Facility, Mixed Address Methods.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#define LOG_GROUP LOG_GROUP_DBGF
27#include <VBox/dbgf.h>
28#include <VBox/selm.h>
29#include "DBGFInternal.h"
30#include <VBox/vm.h>
31#include <VBox/mm.h>
32#include <VBox/err.h>
33#include <VBox/log.h>
34
35
36
37/**
38 * Checks if an address is in the HMA or not.
39 * @returns true if it's inside the HMA.
40 * @returns flase if it's not inside the HMA.
41 * @param pVM The VM handle.
42 * @param FlatPtr The address in question.
43 */
44DECLINLINE(bool) dbgfR3IsHMA(PVM pVM, RTGCUINTPTR FlatPtr)
45{
46 return MMHyperIsInsideArea(pVM, FlatPtr);
47}
48
49
50/**
51 * Creates a mixed address from a Sel:off pair.
52 *
53 * @returns VBox status code.
54 * @param pVM The VM handle.
55 * @param pAddress Where to store the mixed address.
56 * @param Sel The selector part.
57 * @param off The offset part.
58 */
59DBGFR3DECL(int) DBGFR3AddrFromSelOff(PVM pVM, PDBGFADDRESS pAddress, RTSEL Sel, RTUINTPTR off)
60{
61 pAddress->Sel = Sel;
62 pAddress->off = off;
63 if (Sel != DBGF_SEL_FLAT)
64 {
65 SELMSELINFO SelInfo;
66 int rc = SELMR3GetSelectorInfo(pVM, Sel, &SelInfo);
67 if (VBOX_FAILURE(rc))
68 return rc;
69 if (off > SelInfo.cbLimit)
70 return VERR_OUT_OF_SELECTOR_BOUNDS;
71 pAddress->FlatPtr = SelInfo.GCPtrBase + off;
72 /** @todo fix this flat selector test! */
73 if ( !SelInfo.GCPtrBase
74 && SelInfo.Raw.Gen.u1Granularity
75 && SelInfo.Raw.Gen.u1DefBig)
76 pAddress->fFlags = DBGFADDRESS_FLAGS_FLAT;
77 else if (SelInfo.cbLimit <= 0xffff)
78 pAddress->fFlags = DBGFADDRESS_FLAGS_FAR16;
79 else if (SelInfo.cbLimit <= 0xffffffff)
80 pAddress->fFlags = DBGFADDRESS_FLAGS_FAR32;
81 else
82 pAddress->fFlags = DBGFADDRESS_FLAGS_FAR64;
83 }
84 else
85 {
86 pAddress->FlatPtr = off;
87 pAddress->fFlags = DBGFADDRESS_FLAGS_FLAT;
88 }
89 pAddress->fFlags |= DBGFADDRESS_FLAGS_VALID;
90 if (dbgfR3IsHMA(pVM, pAddress->FlatPtr))
91 pAddress->fFlags |= DBGFADDRESS_FLAGS_HMA;
92
93 return VINF_SUCCESS;
94}
95
96
97/**
98 * Creates a mixed address from a flat address.
99 *
100 * @param pVM The VM handle.
101 * @param pAddress Where to store the mixed address.
102 * @param FlatPtr The flat pointer.
103 */
104DBGFR3DECL(void) DBGFR3AddrFromFlat(PVM pVM, PDBGFADDRESS pAddress, RTGCUINTPTR FlatPtr)
105{
106 pAddress->Sel = DBGF_SEL_FLAT;
107 pAddress->off = FlatPtr;
108 pAddress->FlatPtr = FlatPtr;
109 pAddress->fFlags = DBGFADDRESS_FLAGS_FLAT | DBGFADDRESS_FLAGS_VALID;
110 if (dbgfR3IsHMA(pVM, pAddress->FlatPtr))
111 pAddress->fFlags |= DBGFADDRESS_FLAGS_HMA;
112}
113
114
115/**
116 * Checks if the specified address is valid (checks the structure pointer too).
117 *
118 * @returns true if valid.
119 * @returns false if invalid.
120 * @param pVM The VM handle.
121 * @param pAddress The address to validate.
122 */
123DBGFR3DECL(bool) DBGFR3AddrIsValid(PVM pVM, PCDBGFADDRESS pAddress)
124{
125 if (!VALID_PTR(pAddress))
126 return false;
127 if (!DBGFADDRESS_IS_VALID(pAddress))
128 return false;
129 /* more? */
130 return true;
131}
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