VirtualBox

vbox的更動 7635 路徑 trunk/src/VBox/Devices/Graphics


忽略:
時間撮記:
2008-3-28 下午05:15:38 (17 年 以前)
作者:
vboxsync
訊息:

The new MMIO2 code.
WARNING! This changes the pci mapping protocol for MMIO2 so it's working the same way as I/O ports and normal MMIO memory. External users of the interface will have to update their mapping routines.

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r7259 r7635  
    19991999    for(y = 0; y < height; y++) {
    20002000        addr = addr1;
    2001         /* CGA/MDA compatibility. Note that these addresses are all 
     2001        /* CGA/MDA compatibility. Note that these addresses are all
    20022002         * shifted left by two compared to VGA specs.
    20032003         */
     
    41084108
    41094109/**
    4110  * Callback function for mapping an PCI I/O region.
     4110 * Callback function for unmapping and/or mapping the VRAM MMIO2 region (called by the PCI bus).
    41114111 *
    41124112 * @return VBox status code.
     
    41214121{
    41224122    int         rc;
    4123     PVGASTATE   pData = PDMINS2DATA(pPciDev->pDevIns, PVGASTATE);
     4123    PPDMDEVINS  pDevIns = pPciDev->pDevIns;
     4124    PVGASTATE   pData = PDMINS2DATA(pDevIns, PVGASTATE);
    41244125    LogFlow(("vgaR3IORegionMap: iRegion=%d GCPhysAddress=%VGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
    4125 
    4126     /*
    4127      * VRam mapping.
    4128      */
    4129     if (iRegion == 0 && enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH)
     4126    AssertReturn(iRegion == 0 && enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR);
     4127
     4128    if (GCPhysAddress != NIL_RTGCPHYS)
    41304129    {
    41314130        /*
    4132          * Register and lock the VRAM.
    4133          *
    4134          * Windows usually re-initializes the PCI devices, so we have to check whether the memory was
    4135          * already registered before trying to do that all over again.
     4131         * Mapping the VRAM.
    41364132         */
    4137         PVM pVM = PDMDevHlpGetVM(pPciDev->pDevIns);
    4138         if (pData->GCPhysVRAM)
     4133        rc = PDMDevHlpMMIO2Map(pDevIns, iRegion, GCPhysAddress);
     4134        AssertRC(rc);
     4135        if (RT_SUCCESS(rc))
    41394136        {
    4140             AssertMsg(pData->GCPhysVRAM == GCPhysAddress,
    4141                       ("The Guest OS relocated our LFB! old GCPhysVRAM=%VGp new GCPhysAddress=%VGp\n",
    4142                        pData->GCPhysVRAM, GCPhysAddress));
    4143             rc = VINF_SUCCESS;
    4144         }
    4145         else
    4146         {
    4147             /*
    4148              * Register and lock the VRAM.
    4149              */
    4150             rc = MMR3PhysRegister(pVM, pData->vram_ptrHC, GCPhysAddress, pData->vram_size, MM_RAM_FLAGS_MMIO2, "VRam");
    4151             if (VBOX_SUCCESS(rc))
    4152             {
    4153                 if (!pData->GCPhysVRAM)
    4154                     rc = PGMR3HandlerPhysicalRegister(pVM, PGMPHYSHANDLERTYPE_PHYSICAL_WRITE,
    4155                                                       GCPhysAddress, GCPhysAddress + (pData->vram_size - 1),
    4156                                                       vgaR3LFBAccessHandler, pData,
    4157                                                       g_DeviceVga.szR0Mod, "vgaR0LFBAccessHandler", pData->pDevInsHC->pvInstanceDataR0,
    4158                                                       g_DeviceVga.szGCMod, "vgaGCLFBAccessHandler", pData->pDevInsHC->pvInstanceDataGC,
    4159                                                       "VGA LFB");
    4160                 if (VBOX_SUCCESS(rc))
    4161                 {
    4162                     /*
    4163                      * Map the first 256KB of the VRAM into GC for GC VGA support.
    4164                      */
    4165                     RTGCPTR GCPtr;
    4166                     rc = MMR3HyperMapGCPhys(pVM, GCPhysAddress, VGA_MAPPING_SIZE, "VGA VRam", &GCPtr);
    4167                     if (VBOX_SUCCESS(rc))
    4168                     {
    4169                         MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
    4170 
    4171                         pData->vram_ptrGC = GCPtr;
    4172                         pData->GCPhysVRAM = GCPhysAddress;
    4173                         return VINF_SUCCESS;
    4174                     }
    4175                     AssertMsgFailed(("MMR3HyperMapGCPhys failed, rc=%Vrc\n", rc));
    4176                 }
    4177                 else
    4178                     AssertMsgFailed(("Failed to register write handler for VRAM! rc=%Vrc\n", rc));
    4179             }
    4180             else
    4181                 AssertReleaseMsgFailed(("Failed to register VRAM! rc=%Vra\n", rc));
    4182         }
    4183         return rc;
     4137            rc = PGMR3HandlerPhysicalRegister(PDMDevHlpGetVM(pDevIns),
     4138                                              PGMPHYSHANDLERTYPE_PHYSICAL_WRITE,
     4139                                              GCPhysAddress, GCPhysAddress + (pData->vram_size - 1),
     4140                                              vgaR3LFBAccessHandler, pData,
     4141                                              g_DeviceVga.szR0Mod, "vgaR0LFBAccessHandler", pDevIns->pvInstanceDataR0,
     4142                                              g_DeviceVga.szGCMod, "vgaGCLFBAccessHandler", pDevIns->pvInstanceDataGC,
     4143                                              "VGA LFB");
     4144            AssertRC(rc);
     4145            if (RT_SUCCESS(rc))
     4146                pData->GCPhysVRAM = GCPhysAddress;
     4147        }
    41844148    }
    41854149    else
    4186         AssertReleaseMsgFailed(("Huh!?! iRegion=%d enmType=%d\n", iRegion, enmType));
    4187     return VERR_INTERNAL_ERROR;
     4150    {
     4151        /*
     4152         * Unmapping of the VRAM in progress.
     4153         * Deregister the access handler so PGM doesn't get upset.
     4154         */
     4155        Assert(pData->GCPhysVRAM);
     4156        rc = PGMHandlerPhysicalDeregister(PDMDevHlpGetVM(pDevIns), pData->GCPhysVRAM);
     4157        AssertRC(rc);
     4158        pData->GCPhysVRAM = 0;
     4159    }
     4160    return rc;
    41884161}
    41894162
     
    46194592
    46204593    /*
     4594     * Allocate the VRAM and map the first 256KB of it into GC so we can speed up VGA support.
     4595     */
     4596    rc = PDMDevHlpMMIO2Register(pDevIns, 0 /* iRegion */, pData->vram_size, (void **)&pData->vram_ptrHC, "VRam");
     4597    AssertMsgRC(rc, ("PDMDevHlpMMIO2Register(%#x,) -> %Rrc\n", pData->vram_size, rc));
     4598
     4599    rc = PDMDevHlpMMHyperMapMMIO2(pDevIns, 0 /* iRegion */, 0 /* off */,  VGA_MAPPING_SIZE, "VGA VRam", &pData->vram_ptrGC);
     4600    AssertMsgRC(rc, ("MMR3HyperMapGCPhys(%#x,) -> %Rrc\n", pData->vram_size, rc));
     4601
     4602    /*
    46214603     * Register I/O ports, ROM and save state.
    46224604     */
     
    47624744    AssertReleaseMsg(g_cbVgaBiosBinary <= _64K && g_cbVgaBiosBinary >= 32*_1K, ("g_cbVgaBiosBinary=%#x\n", g_cbVgaBiosBinary));
    47634745    AssertReleaseMsg(RT_ALIGN_Z(g_cbVgaBiosBinary, PAGE_SIZE) == g_cbVgaBiosBinary, ("g_cbVgaBiosBinary=%#x\n", g_cbVgaBiosBinary));
    4764     rc = PDMDevHlpROMRegister(pDevIns, 0x000c0000, g_cbVgaBiosBinary, &g_abVgaBiosBinary[0], 
     4746    rc = PDMDevHlpROMRegister(pDevIns, 0x000c0000, g_cbVgaBiosBinary, &g_abVgaBiosBinary[0],
    47654747                              false /* fShadow */, "VGA BIOS");
    47664748    if (VBOX_FAILURE(rc))
     
    47814763    if (pData->Dev.devfn != 16 && iInstance == 0)
    47824764        Log(("!!WARNING!!: pData->dev.devfn=%d (ignore if testcase or no started by Main)\n", pData->Dev.devfn));
    4783     rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, pData->vram_size, PCI_ADDRESS_SPACE_MEM_PREFETCH, vgaR3IORegionMap);
     4765
     4766    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0 /* iRegion */, pData->vram_size, PCI_ADDRESS_SPACE_MEM_PREFETCH, vgaR3IORegionMap);
    47844767    if (VBOX_FAILURE(rc))
    47854768        return rc;
     
    47984781    if (VBOX_FAILURE(rc))
    47994782        return rc;
    4800 
    4801     /*
    4802      * Allocate the VRAM.
    4803      */
    4804     rc = SUPPageAlloc(pData->vram_size >> PAGE_SHIFT, (void **)&pData->vram_ptrHC);
    4805     if (VBOX_FAILURE(rc))
    4806     {
    4807         AssertMsgFailed(("SUPPageAlloc(%#x,) -> %d\n", pData->vram_size, rc));
    4808         return rc;
    4809     }
    48104783
    48114784#ifdef VBE_NEW_DYN_LIST
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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