Changeset 6820 in vbox
- Timestamp:
- Feb 5, 2008 9:54:28 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27930
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pgm.h
r6546 r6820 1425 1425 #endif /* !VBOX_WITH_NEW_PHYS_CODE */ 1426 1426 1427 PGMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc); 1428 1427 1429 /** 1428 1430 * Interface that the MMR3RamRegister(), MMR3RomRegister() and MMIO handler -
trunk/src/VBox/VMM/PGMInternal.h
r6765 r6820 668 668 * For pure MMIO and dynamically allocated ranges this is NULL, while for all ranges this is a valid pointer. */ 669 669 R3PTRTYPE(void *) pvHC; 670 /** The range description. */ 671 R3PTRTYPE(const char *) pszDesc; 672 673 /** Padding to make aPage aligned on sizeof(PGMPAGE). */ 674 RTR3PTR apvReserved[HC_ARCH_BITS == 32 ? 2 : 1]; 670 675 671 676 /** Array of physical guest page tracking structures. */ -
trunk/src/VBox/VMM/PGMPhys.cpp
r6546 r6820 47 47 * PGMR3PhysWriteByte/Word/Dword 48 48 */ 49 /** @todo rename and add U64. */ 49 50 50 51 #define PGMPHYSFN_READNAME PGMR3PhysReadByte … … 66 67 #include "PGMPhys.h" 67 68 69 70 71 /** 72 * Sets up a range RAM. 73 * 74 * This will check for conflicting registrations, make a resource 75 * reservation for the memory (with GMM), and setup the per-page 76 * tracking structures (PGMPAGE). 77 * 78 * @returns VBox stutus code. 79 * @param pVM Pointer to the shared VM structure. 80 * @param GCPhys The physical address of the RAM. 81 * @param cb The size of the RAM. 82 * @param pszDesc The description - not copied, so, don't free or change it. 83 */ 84 PGMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc) 85 { 86 /* 87 * Validate input. 88 */ 89 Log(("PGMR3PhysRegisterRam: GCPhys=%RGp cb=%RGp pszDesc=%s\n", GCPhys, cb, pszDesc)); 90 AssertReturn(RT_ALIGN_T(GCPhys, PAGE_SIZE, RTGCPHYS) == GCPhys, VERR_INVALID_PARAMETER); 91 AssertReturn(RT_ALIGN_T(cb, PAGE_SIZE, RTGCPHYS) == cb, VERR_INVALID_PARAMETER); 92 AssertReturn(cb > 0, VERR_INVALID_PARAMETER); 93 RTGCPHYS GCPhysLast = GCPhys + (cb - 1); 94 AssertMsgReturn(GCPhysLast > GCPhys, ("The range wraps! GCPhys=%RGp cb=%RGp\n", GCPhys, cb), VERR_INVALID_PARAMETER); 95 AssertPtrReturn(pszDesc, VERR_INVALID_POINTER); 96 VM_ASSERT_EMT_RETURN(pVM, VERR_VM_THREAD_NOT_EMT); 97 98 /* 99 * Find range location and check for conflicts. 100 * (We don't lock here because the locking by EMT is only required on update.) 101 */ 102 PPGMRAMRANGE pPrev = NULL; 103 PPGMRAMRANGE pCur = pVM->pgm.s.pRamRangesHC; 104 while (pCur && GCPhysLast >= pCur->GCPhys) 105 { 106 if ( GCPhys <= pCur->GCPhysLast 107 && GCPhysLast >= pCur->GCPhys) 108 AssertLogRelMsgFailedReturn(("%RGp-%RGp (%s) conflicts with existing %RGp-%RGp (%s)\n", 109 GCPhys, GCPhysLast, pszDesc, 110 pCur->GCPhys, pCur->GCPhysLast, pCur->pszDesc), 111 VERR_PGM_RAM_CONFLICT); 112 113 /* next */ 114 pPrev = pCur; 115 pCur = pCur->pNextHC; 116 } 117 118 /* 119 * Register it with GMM (the API bitches). 120 */ 121 const RTGCPHYS cPages = cb >> PAGE_SHIFT; 122 int rc = MMR3IncreaseBaseReservation(pVM, cPages); 123 if (RT_FAILURE(rc)) 124 return rc; 125 126 /* 127 * Allocate RAM range. 128 */ 129 const size_t cbRamRange = RT_OFFSETOF(PGMRAMRANGE, aPages[cPages]); 130 PPGMRAMRANGE pNew; 131 rc = MMR3HyperAllocOnceNoRel(pVM, cbRamRange, 0, MM_TAG_PGM_PHYS, (void **)&pNew); 132 AssertLogRelMsgRCReturn(rc, ("cbRamRange=%zd\n", cbRamRange), rc); 133 134 /* 135 * Initialize the range. 136 */ 137 pNew->GCPhys = GCPhys; 138 pNew->GCPhysLast = GCPhysLast; 139 pNew->pszDesc = pszDesc; 140 pNew->cb = cb; 141 pNew->fFlags = 0; 142 143 pNew->pavHCChunkHC = NULL; 144 pNew->pavHCChunkGC = 0; 145 pNew->pvHC = NULL; 146 147 RTGCPHYS iPage = cPages; 148 while (iPage-- > 0) 149 { 150 pNew->aPages[iPage].HCPhys = pVM->pgm.s.HCPhysZeroPg; 151 pNew->aPages[iPage].u2State = PGM_PAGE_STATE_ZERO; 152 pNew->aPages[iPage].fWrittenTo = 0; 153 pNew->aPages[iPage].fSomethingElse = 0; 154 pNew->aPages[iPage].idPage = NIL_GMM_PAGEID; 155 pNew->aPages[iPage].u32B = 0; 156 } 157 158 /* 159 * Insert the new RAM range. 160 * (Take the lock just so that we're playing by the rules.) 161 */ 162 pgmLock(pVM); 163 pNew->pNextHC = pCur; 164 //pNew->pNextR0 = pCur ? MMHyperCCToR0(pVM, pCur) : NIL_RTR0PTR; 165 pNew->pNextGC = pCur ? MMHyperCCToGC(pVM, pCur) : NIL_RTGCPTR; 166 if (pPrev) 167 { 168 pPrev->pNextHC = pNew; 169 //pPrev->pNextR0 = MMHyperCCToR0(pVM, pNew); 170 pPrev->pNextGC = MMHyperCCToGC(pVM, pNew); 171 } 172 else 173 { 174 pVM->pgm.s.pRamRangesHC = pNew; 175 //pVM->pgm.s.pRamRangesR0 = MMHyperCCToR0(pVM, pNew); 176 pVM->pgm.s.pRamRangesGC = MMHyperCCToGC(pVM, pNew); 177 } 178 pgmUnlock(pVM); 179 180 return VINF_SUCCESS; 181 } 68 182 69 183 -
trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp
r6796 r6820 536 536 GEN_CHECK_OFF(PGMRAMRANGE, GCPhysLast); 537 537 GEN_CHECK_OFF(PGMRAMRANGE, cb); 538 GEN_CHECK_OFF(PGMRAMRANGE, fFlags); 538 539 GEN_CHECK_OFF(PGMRAMRANGE, pvHC); 540 GEN_CHECK_OFF(PGMRAMRANGE, pszDesc); 539 541 GEN_CHECK_OFF(PGMRAMRANGE, aPages); 542 GEN_CHECK_OFF(PGMRAMRANGE, aPages[1]); 540 543 GEN_CHECK_SIZE(PGMTREES); 541 544 GEN_CHECK_OFF(PGMTREES, PhysHandlers); -
trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp
r6796 r6820 210 210 CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, pvPageHC, sizeof(RTHCPTR)); 211 211 CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, GCPhys, sizeof(RTGCPHYS)); 212 CHECK_SIZE(PGMPAGE, 16); 213 CHECK_MEMBER_ALIGNMENT(PGMRAMRANGE, aPages, 16); 212 214 213 215 /* misc */
Note:
See TracChangeset
for help on using the changeset viewer.