- Timestamp:
- Jan 12, 2023 3:57:23 PM (2 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA.cpp
r97779 r98065 311 311 312 312 /** 313 * Mark a page in VGA A0000- AFFFF range as remapped.313 * Mark a page in VGA A0000-BFFFF range as remapped. 314 314 * 315 315 * @param pThis VGA instance data. … … 318 318 DECLINLINE(void) vgaMarkRemapped(PVGASTATE pThis, RTGCPHYS offVGAMem) 319 319 { 320 AssertMsg(offVGAMem < _ 64K, ("offVGAMem = %p > 64K\n", offVGAMem));321 ASMBitSet(&pThis->bmPageMapBitmap,offVGAMem >> GUEST_PAGE_SHIFT);322 pThis->fRemappedVGA = true; 323 } 324 325 /** 326 * Checks if a page in VGA A0000- AFFFF range is remapped.320 AssertMsg(offVGAMem < _128K, ("offVGAMem = %RGp\n", offVGAMem)); 321 pThis->bmPageRemappedVGA |= RT_BIT_32((uint32_t)offVGAMem >> GUEST_PAGE_SHIFT); 322 } 323 324 325 /** 326 * Checks if a page in VGA A0000-BFFFF range is remapped. 327 327 * 328 328 * @returns true if remapped. … … 333 333 DECLINLINE(bool) vgaIsRemapped(PVGASTATE pThis, RTGCPHYS offVGAMem) 334 334 { 335 AssertMsg(offVGAMem < _64K, ("offVGAMem = %p > 64K\n", offVGAMem)); 336 return ASMBitTest(&pThis->bmPageMapBitmap, offVGAMem >> GUEST_PAGE_SHIFT); 337 } 335 AssertMsg(offVGAMem < _128K, ("offVGAMem = %RGp\n", offVGAMem)); 336 return pThis->bmPageRemappedVGA & RT_BIT_32((uint32_t)offVGAMem >> GUEST_PAGE_SHIFT); 337 } 338 338 339 339 340 /** … … 344 345 DECLINLINE(void) vgaResetRemapped(PVGASTATE pThis) 345 346 { 346 pThis-> fRemappedVGA = false;347 ASMBitClearRange(&pThis->bmPageMapBitmap, 0, _64K >> GUEST_PAGE_SHIFT); 348 } 347 pThis->bmPageRemappedVGA = 0; 348 } 349 349 350 350 351 /** … … 745 746 || pThis->sr_index == 2 /* plane mask */) 746 747 { 747 if (pThis-> fRemappedVGA)748 if (pThis->bmPageRemappedVGA != 0) 748 749 { 749 750 PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy); … … 785 786 if (pThis->gr_index == 6 /* memory map mode */) 786 787 { 787 if (pThis-> fRemappedVGA)788 if (pThis->bmPageRemappedVGA != 0) 788 789 { 789 790 PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy); … … 1044 1045 # ifndef IN_RC 1045 1046 /* The VGA region is (could be) affected by this change; reset all aliases we've created. */ 1046 if (pThis-> fRemappedVGA)1047 if (pThis->bmPageRemappedVGA != 0) 1047 1048 { 1048 1049 PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy); … … 1154 1155 1155 1156 /* The VGA region is (could be) affected by this change; reset all aliases we've created. */ 1156 if (pThis-> fRemappedVGA)1157 if (pThis->bmPageRemappedVGA != 0) 1157 1158 { 1158 1159 PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy); … … 1221 1222 1222 1223 /* convert to VGA memory offset */ 1224 addr &= 0x1ffff; 1223 1225 #ifndef IN_RC 1224 RTGCPHYS GCPhys = addr; /* save original address*/1226 RTGCPHYS const offMmio = addr; /* save original MMIO range offset */ 1225 1227 #endif 1226 addr &= 0x1ffff;1227 1228 1228 1229 int const memory_map_mode = (pThis->gr[6] >> 2) & 3; … … 1253 1254 /* If all planes are accessible, then map the page to the frame buffer and make it writable. */ 1254 1255 if ( (pThis->sr[2] & 3) == 3 1255 && !vgaIsRemapped(pThis, GCPhys - 0xa0000)1256 && !vgaIsRemapped(pThis, offMmio) 1256 1257 && pThis->GCPhysVRAM) 1257 1258 { 1258 1259 /** @todo only allow read access (doesn't work now) */ 1259 1260 STAM_COUNTER_INC(&pThis->StatMapPage); 1260 PDMDevHlpMmioMapMmio2Page(pDevIns, pThis->hMmioLegacy, GCPhys - 0xa0000, 1261 pThis->hMmio2VRam, addr, X86_PTE_RW | X86_PTE_P); 1261 PDMDevHlpMmioMapMmio2Page(pDevIns, pThis->hMmioLegacy, offMmio, pThis->hMmio2VRam, addr, X86_PTE_RW | X86_PTE_P); 1262 1262 /* Set as dirty as write accesses won't be noticed now. */ 1263 1263 vgaR3MarkDirty(pThis, addr); 1264 vgaMarkRemapped(pThis, GCPhys - 0xa0000);1264 vgaMarkRemapped(pThis, offMmio); 1265 1265 } 1266 1266 #endif /* !IN_RC */ … … 1327 1327 1328 1328 /* convert to VGA memory offset */ 1329 addr &= 0x1ffff; 1329 1330 #ifndef IN_RC 1330 RTGCPHYS const GCPhys = addr; /* save original address*/1331 RTGCPHYS const offMmio = addr; /* save original MMIO range offset */ 1331 1332 #endif 1332 addr &= 0x1ffff;1333 1333 1334 1334 int const memory_map_mode = (pThis->gr[6] >> 2) & 3; … … 1362 1362 /* If all planes are accessible, then map the page to the frame buffer and make it writable. */ 1363 1363 if ( (pThis->sr[2] & 3) == 3 1364 && !vgaIsRemapped(pThis, GCPhys - 0xa0000)1364 && !vgaIsRemapped(pThis, offMmio) 1365 1365 && pThis->GCPhysVRAM) 1366 1366 { 1367 1367 STAM_COUNTER_INC(&pThis->StatMapPage); 1368 PDMDevHlpMmioMapMmio2Page(pDevIns, pThis->hMmioLegacy, GCPhys - 0xa0000, 1369 pThis->hMmio2VRam, addr, X86_PTE_RW | X86_PTE_P); 1370 vgaMarkRemapped(pThis, GCPhys - 0xa0000); 1368 PDMDevHlpMmioMapMmio2Page(pDevIns, pThis->hMmioLegacy, offMmio, pThis->hMmio2VRam, addr, X86_PTE_RW | X86_PTE_P); 1369 vgaMarkRemapped(pThis, offMmio); 1371 1370 } 1372 1371 #endif /* !IN_RC */ … … 3659 3658 * @callback_method_impl{FNIOMMMIONEWREAD, 3660 3659 * Legacy VGA memory (0xa0000 - 0xbffff) read hook\, to be called from IOM.} 3660 * 3661 * @note The @a off is an absolute address in the 0xa0000 - 0xbffff range, not 3662 * an offset. 3661 3663 */ 3662 3664 static DECLCALLBACK(VBOXSTRICTRC) vgaMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb) … … 3718 3720 * @callback_method_impl{FNIOMMMIONEWWRITE, 3719 3721 * Legacy VGA memory (0xa0000 - 0xbffff) write hook\, to be called from IOM.} 3722 * 3723 * @note The @a off is an absolute address in the 0xa0000 - 0xbffff range, not 3724 * an offset. 3720 3725 */ 3721 3726 static DECLCALLBACK(VBOXSTRICTRC) vgaMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb) … … 4875 4880 vgaR3UpdateDirtyBitsAndResetMonitoring(pDevIns, pThis); 4876 4881 4877 if (pThis-> fRemappedVGA)4882 if (pThis->bmPageRemappedVGA != 0) 4878 4883 { 4879 4884 PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy); … … 4904 4909 } 4905 4910 4906 if (pThis-> fRemappedVGA)4911 if (pThis->bmPageRemappedVGA != 0) 4907 4912 { 4908 4913 PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy); … … 6126 6131 AssertRC(rc); 6127 6132 } 6128 if (pThis-> fRemappedVGA)6133 if (pThis->bmPageRemappedVGA != 0) 6129 6134 { 6130 6135 PDMDevHlpMmioResetRegion(pDevIns, pThis->hMmioLegacy); -
trunk/src/VBox/Devices/Graphics/DevVGA.h
r96407 r98065 362 362 /** Bitmap tracking dirty pages. */ 363 363 uint64_t bmDirtyBitmap[VGA_VRAM_MAX / GUEST_PAGE_SIZE / 64]; 364 /** Bitmap tracking remapped pages (only needs 16 bits). */ 365 uint64_t bmPageMapBitmap; 364 /** Bitmap tracking which VGA memory pages in the 0xa0000-0xbffff region has 365 * been remapped to allow direct access. 366 * @note It's quite possible that mapping in the 0xb0000-0xbffff isn't possible, 367 * but we're playing safe and cover the whole VGA MMIO region here. */ 368 uint32_t bmPageRemappedVGA; 366 369 367 370 /** Flag indicating that there are dirty bits. This is used to optimize the handler resetting. */ 368 371 bool fHasDirtyBits; 369 /** Flag indicating that the VGA memory in the 0xa0000-0xbffff region has been remapped to allow direct access. */ 372 /** Flag indicating that the VGA memory in the 0xa0000-0xbffff region has been remapped to allow direct access. 373 * @todo This is just an unnecessary summmary of bmPageMapBitmap. */ 370 374 bool fRemappedVGA; 371 375 /** Whether to render the guest VRAM to the framebuffer memory. False only for some LFB modes. */ … … 381 385 bool fVMSVGAPciId; 382 386 bool fVMSVGAPciBarLayout; 383 bool Padding4[3];384 387 #else 385 bool Padding4[4+3];388 bool afPadding4[4]; 386 389 #endif 387 390 -
trunk/src/VBox/Devices/testcase/tstDeviceStructSize.cpp
r96512 r98065 409 409 CHECK_MEMBER_ALIGNMENT(VGASTATE, StatRZMemoryRead, 8); 410 410 CHECK_MEMBER_ALIGNMENT(VGASTATE, CritSectIRQ, 8); 411 CHECK_MEMBER_ALIGNMENT(VGASTATE, bmDirtyBitmap, 8); 412 CHECK_MEMBER_ALIGNMENT(VGASTATE, pciRegions, 8); 411 413 CHECK_MEMBER_ALIGNMENT(VMMDEV, CritSect, 8); 412 414 #ifdef VBOX_WITH_PCI_PASSTHROUGH_IMPL
Note:
See TracChangeset
for help on using the changeset viewer.