VirtualBox

Changeset 82074 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Nov 21, 2019 11:07:10 AM (5 years ago)
Author:
vboxsync
Message:

DevVGA: Converted VRAM allocation and registration to new style. bugref:9218

Location:
trunk/src/VBox/Devices/Graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r82072 r82074  
    5050 *            across different .cpp files !!!
    5151 */
    52 /** The size of the VGA GC mapping.
    53  * This is supposed to be all the VGA memory accessible to the guest.
    54  * The initial value was 256KB but NTAllInOne.iso appears to access more
    55  * thus the limit was upped to 512KB.
    56  *
    57  * @todo Someone with some VGA knowhow should make a better guess at this value.
    58  */
    59 #define VGA_MAPPING_SIZE    _512K
    6052
    6153#ifdef VBOX_WITH_HGSMI
     
    56715663 * @callback_method_impl{FNPCIIOREGIONMAP, Mapping/unmapping the VRAM MMI2 region}
    56725664 */
    5673 static DECLCALLBACK(int) vgaR3IORegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
    5674                                           RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
     5665static DECLCALLBACK(int) vgaR3PciIORegionVRamMapUnmap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
     5666                                                      RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
    56755667{
    56765668    PVGASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PVGASTATE);
    5677     RT_NOREF(cb);
    5678     Log(("vgaR3IORegionMap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
     5669    Log(("vgaR3PciIORegionVRamMapUnmap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
     5670    RT_NOREF(pPciDev, cb);
    56795671
    56805672    AssertReturn(iRegion == pThis->pciRegions.iVRAM && enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR);
     
    56895681         * Mapping the VRAM.
    56905682         */
    5691         rc = PDMDevHlpMMIOExMap(pDevIns, pPciDev, iRegion, GCPhysAddress);
    5692         AssertRC(rc);
     5683        rc = PDMDevHlpMmio2Map(pDevIns, pThis->hMmio2VRam, GCPhysAddress);
     5684        AssertLogRelRC(rc);
    56935685        if (RT_SUCCESS(rc))
    56945686        {
     
    56965688                                            pThis->hLfbAccessHandlerType, pThis, pDevIns->pvInstanceDataR0,
    56975689                                            pDevIns->pvInstanceDataRC, "VGA LFB");
    5698             AssertRC(rc);
     5690            AssertLogRelRC(rc);
    56995691            if (RT_SUCCESS(rc))
    57005692            {
     
    57025694                pThis->vbe_regs[VBE_DISPI_INDEX_FB_BASE_HI] = GCPhysAddress >> 16;
    57035695            }
     5696            rc = VINF_PCI_MAPPING_DONE; /* caller doesn't care about any other status, so no problem overwriting error here */
    57045697        }
    57055698    }
     
    57075700    {
    57085701        /*
    5709          * Unmapping of the VRAM in progress.
     5702         * Unmapping of the VRAM in progress (caller will do that).
    57105703         * Deregister the access handler so PGM doesn't get upset.
    57115704         */
    57125705        Assert(pThis->GCPhysVRAM);
    5713 #ifdef VBOX_WITH_VMSVGA
     5706# ifdef VBOX_WITH_VMSVGA
    57145707        Assert(!pThis->svga.fEnabled || !pThis->svga.fVRAMTracking);
    57155708        if (    !pThis->svga.fEnabled
     
    57185711                )
    57195712           )
     5713# endif
    57205714        {
    5721 #endif
    57225715            rc = PGMHandlerPhysicalDeregister(PDMDevHlpGetVM(pDevIns), pThis->GCPhysVRAM);
    57235716            AssertRC(rc);
    5724 #ifdef VBOX_WITH_VMSVGA
    5725         }
     5717        }
     5718# ifdef VBOX_WITH_VMSVGA
    57265719        else
    57275720            rc = VINF_SUCCESS;
    5728 #endif
     5721# endif
    57295722        pThis->GCPhysVRAM = 0;
    57305723        /* NB: VBE_DISPI_INDEX_FB_BASE_HI is left unchanged here. */
     
    66476640        AssertRCReturn(rc, rc);
    66486641
    6649         rc = PDMDevHlpPCIIORegionRegister(pDevIns, pThis->pciRegions.iVRAM, pThis->vram_size,
    6650                                           PCI_ADDRESS_SPACE_MEM_PREFETCH, vgaR3IORegionMap);
    6651         if (RT_FAILURE(rc))
    6652             return rc;
    66536642        rc = PDMDevHlpPCIIORegionRegister(pDevIns, pThis->pciRegions.iFIFO, pThis->svga.cbFIFO,
    66546643                                          PCI_ADDRESS_SPACE_MEM_PREFETCH, vmsvgaR3IORegionMap);
    6655         if (RT_FAILURE(rc))
    6656             return rc;
     6644        AssertRCReturn(rc, rc);
    66576645        pPciDev->pfnRegionLoadChangeHookR3 = vgaR3PciRegionLoadChangeHook;
    66586646    }
    6659     else
    66606647#endif /* VBOX_WITH_VMSVGA */
    6661     {
    6662         rc = PDMDevHlpPCIIORegionRegister(pDevIns, pThis->pciRegions.iVRAM, pThis->vram_size,
    6663                                           PCI_ADDRESS_SPACE_MEM_PREFETCH, vgaR3IORegionMap);
    6664         if (RT_FAILURE(rc))
    6665             return rc;
    6666     }
    66676648
    66686649    /*
    6669      * Allocate the VRAM and map the first 512KB of it into GC so we can speed up VGA support.
     6650     * Allocate VRAM and create a PCI region for it.
     6651     */
     6652    rc = PDMDevHlpPCIIORegionCreateMmio2Ex(pDevIns, pThis->pciRegions.iVRAM, pThis->vram_size,
     6653                                           PCI_ADDRESS_SPACE_MEM_PREFETCH, 0 /*fFlags*/, vgaR3PciIORegionVRamMapUnmap,
     6654                                           "VRam", (void **)&pThis->vram_ptrR3, &pThis->hMmio2VRam);
     6655    AssertLogRelRCReturn(rc, PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
     6656                                                 N_("Failed to allocate %u bytes of VRAM"), pThis->vram_size));
     6657    pThis->vram_ptrR0 = (RTR0PTR)pThis->vram_ptrR3; /** @todo @bugref{1865} Map parts into R0 or just use PGM access (Mac only). */
     6658
     6659    /*
     6660     * Register access handler types for tracking dirty VRAM pages.
     6661     */
     6662    rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_WRITE,
     6663                                          vgaLFBAccessHandler,
     6664                                          g_DeviceVga.pszR0Mod, "vgaLFBAccessHandler", "vgaLbfAccessPfHandler",
     6665                                          g_DeviceVga.pszRCMod, "vgaLFBAccessHandler", "vgaLbfAccessPfHandler",
     6666                                          "VGA LFB", &pThis->hLfbAccessHandlerType);
     6667    AssertRCReturn(rc, rc);
     6668
     6669    /*
     6670     * Allocate VMSVGA FIFO.
    66706671     */
    66716672#ifdef VBOX_WITH_VMSVGA
     
    66816682                                        N_("Failed to allocate %u bytes of memory for the VMSVGA device"), pThis->svga.cbFIFO);
    66826683        pThis->svga.pFIFOR0 = (RTR0PTR)pThis->svga.pFIFOR3;
    6683     }
    6684 #endif
    6685     rc = PDMDevHlpMMIO2Register(pDevIns, pPciDev, pThis->pciRegions.iVRAM, pThis->vram_size, 0, (void **)&pThis->vram_ptrR3, "VRam");
    6686     AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMMIO2Register(%#x,) -> %Rrc\n", pThis->vram_size, rc), rc);
    6687     pThis->vram_ptrR0 = (RTR0PTR)pThis->vram_ptrR3; /** @todo @bugref{1865} Map parts into R0 or just use PGM access (Mac only). */
    6688 
    6689 #ifdef VBOX_WITH_RAW_MODE_KEEP
    6690     if (pDevIns->fRCEnabled)
    6691     {
    6692         RTRCPTR pRCMapping = 0;
    6693         rc = PDMDevHlpMMHyperMapMMIO2(pDevIns, pPciDev, pThis->pciRegions.iVRAM, 0 /* off */,  VGA_MAPPING_SIZE,
    6694                                       "VGA VRam", &pRCMapping);
    6695         AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMMHyperMapMMIO2(%#x,) -> %Rrc\n", VGA_MAPPING_SIZE, rc), rc);
    6696         pThis->vram_ptrRC = pRCMapping;
    6697 # ifdef VBOX_WITH_VMSVGA
     6684
     6685# ifdef VBOX_WITH_RAW_MODE_KEEP
    66986686        /* Don't need a mapping in RC */
    66996687# endif
    6700     }
    6701 #endif
    6702 
    6703 #if defined(VBOX_WITH_2X_4GB_ADDR_SPACE)
    6704     if (pDevIns->fR0Enabled)
    6705     {
    6706         RTR0PTR pR0Mapping = 0;
    6707         rc = PDMDevHlpMMIO2MapKernel(pDevIns, iPCIRegionVRAM, 0 /* off */,  VGA_MAPPING_SIZE, "VGA VRam", &pR0Mapping);
    6708         AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMapMMIO2IntoR0(%#x,) -> %Rrc\n", VGA_MAPPING_SIZE, rc), rc);
    6709         pThis->vram_ptrR0 = pR0Mapping;
    6710 # ifdef VBOX_WITH_VMSVGA
    6711         if (pThis->fVMSVGAEnabled)
     6688# if defined(VBOX_WITH_2X_4GB_ADDR_SPACE)
     6689        if (pDevIns->fR0Enabled)
    67126690        {
    67136691            RTR0PTR pR0Mapping = 0;
     
    67196697    }
    67206698#endif
    6721 
    6722     /*
    6723      * Register access handler types.
    6724      */
    6725     rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_WRITE,
    6726                                           vgaLFBAccessHandler,
    6727                                           g_DeviceVga.pszR0Mod, "vgaLFBAccessHandler", "vgaLbfAccessPfHandler",
    6728                                           g_DeviceVga.pszRCMod, "vgaLFBAccessHandler", "vgaLbfAccessPfHandler",
    6729                                           "VGA LFB", &pThis->hLfbAccessHandlerType);
    6730     AssertRCReturn(rc, rc);
    6731 
    67326699
    67336700    /*
     
    74367403        AssertRCReturn(rc, rc);
    74377404    }
     7405# endif
     7406
     7407    /*
     7408     * Map the start of the VRAM into this context.
     7409     */
     7410# if defined(VBOX_WITH_2X_4GB_ADDR_SPACE)
     7411    rc = PDMDevHlpMmio2SetUpContext(pDevIns, pThis->hMmio2VRam, 0 /* off */, VGA_MAPPING_SIZE, (void **)&pThis->CTX_SUFF(vram_ptr));
     7412    AssertLogRelMsgRCReturn(rc, ("PDMDevHlpMmio2SetUpContext(,VRAM,0,%#x,) -> %Rrc\n", VGA_MAPPING_SIZE, rc), rc);
    74387413# endif
    74397414
  • trunk/src/VBox/Devices/Graphics/DevVGA.h

    r82072 r82074  
    4747#endif
    4848
     49#include <VBoxVideoVBE.h>
     50#include <VBoxVideoVBEPrivate.h>
     51
     52#ifdef VBOX_WITH_HGSMI
     53# include "HGSMI/HGSMIHost.h"
     54#endif /* VBOX_WITH_HGSMI */
     55#include "DevVGASavedState.h"
     56
     57#ifdef VBOX_WITH_VMSVGA
     58# include "DevVGA-SVGA.h"
     59#endif
     60
     61#include <iprt/list.h>
     62
     63
    4964/** Use VBE bytewise I/O. Only needed for Windows Longhorn/Vista betas and backwards compatibility. */
    5065#define VBE_BYTEWISE_IO
     
    5974#endif
    6075
    61 #include <VBoxVideoVBE.h>
    62 #include <VBoxVideoVBEPrivate.h>
    63 
    64 #ifdef VBOX_WITH_HGSMI
    65 # include "HGSMI/HGSMIHost.h"
    66 #endif /* VBOX_WITH_HGSMI */
    67 #include "DevVGASavedState.h"
    68 
    69 #ifdef VBOX_WITH_VMSVGA
    70 # include "DevVGA-SVGA.h"
    71 #endif
    72 
    73 #include <iprt/list.h>
     76/** The size of the VGA GC mapping.
     77 * This is supposed to be all the VGA memory accessible to the guest.
     78 * The initial value was 256KB but NTAllInOne.iso appears to access more
     79 * thus the limit was upped to 512KB.
     80 *
     81 * @todo Someone with some VGA knowhow should make a better guess at this value.
     82 */
     83#define VGA_MAPPING_SIZE    _512K
     84
    7485
    7586#define MSR_COLOR_EMULATION 0x01
     
    544555    IOMIOPORTHANDLE             hIoPortVmSvga;
    545556# endif
    546 
     557    /** The MMIO2 handle of the VRAM. */
     558    PGMMMIO2HANDLE              hMmio2VRam;
    547559#endif /* VBOX */
    548560} VGAState;
Note: See TracChangeset for help on using the changeset viewer.

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