VirtualBox

Changeset 70740 in vbox


Ignore:
Timestamp:
Jan 25, 2018 2:13:56 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120499
Message:

DevPcArch.cpp: Make RAM in the range 0xa0000 and 0xfffff be reserved, making emm386 happy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevPcArch.cpp

    r69500 r70740  
    2323#include <VBox/vmm/pdmdev.h>
    2424#include <VBox/vmm/mm.h>
     25#include <VBox/vmm/pgm.h>
    2526#include <VBox/log.h>
    2627#include <VBox/err.h>
     
    186187
    187188/**
     189 * @callback_method_impl{FNIOMMMIOWRITE, Ignores writes to the reserved memory.}
     190 */
     191static DECLCALLBACK(int) pcarchReservedMemoryWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr,
     192                                                   void const *pv, unsigned cb)
     193{
     194    Log2(("pcarchReservedMemoryRead: %#RGp LB %#x %.*Rhxs\n", GCPhysAddr, cb, RT_MIN(cb, 16), pv));
     195    NOREF(pDevIns); NOREF(pvUser); NOREF(GCPhysAddr); NOREF(pv); NOREF(cb);
     196    return VINF_SUCCESS;
     197}
     198
     199
     200/**
     201 * @callback_method_impl{FNIOMMMIOREAD, The reserved memory reads as 0xff.}
     202 */
     203static DECLCALLBACK(int) pcarchReservedMemoryRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
     204{
     205    Log2(("pcarchReservedMemoryRead: %#RGp LB %#x\n", GCPhysAddr, cb));
     206    NOREF(pDevIns); NOREF(pvUser); NOREF(GCPhysAddr);
     207    memset(pv, 0xff, cb);
     208    return VINF_SUCCESS;
     209}
     210
     211
     212/**
     213 * @interface_method_impl{PDMDEVREG,pfnInitComplete,
     214 *      Turn RAM pages between 0xa0000 and 0xfffff into reserved memory.}
     215 */
     216static DECLCALLBACK(int) pcarchInitComplete(PPDMDEVINS pDevIns)
     217{
     218    PVM             pVM       = PDMDevHlpGetVM(pDevIns);
     219    int             iRegion   = 0;
     220    RTGCPHYS const  GCPhysEnd = 0x100000;
     221    RTGCPHYS        GCPhysCur = 0x0a0000;
     222    do
     223    {
     224        if (!PGMPhysIsGCPhysNormal(pVM, GCPhysCur))
     225            GCPhysCur += X86_PAGE_SIZE;
     226        else
     227        {
     228            RTGCPHYS const GCPhysStart = GCPhysCur;
     229            do
     230                GCPhysCur += X86_PAGE_SIZE;
     231            while (GCPhysCur < GCPhysEnd && PGMPhysIsGCPhysNormal(pVM, GCPhysCur));
     232
     233            int rc = PDMDevHlpMMIORegister(pDevIns, GCPhysStart, GCPhysCur - GCPhysStart, NULL /*pvUser*/,
     234                                           IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
     235                                           pcarchReservedMemoryWrite, pcarchReservedMemoryRead,
     236                                           MMR3HeapAPrintf(pVM, MM_TAG_PGM_PHYS /* bad bird*/, "PC Arch Reserved #%u", iRegion));
     237            AssertLogRelRCReturn(rc, rc);
     238        }
     239    } while (GCPhysCur < GCPhysEnd);
     240
     241    return VINF_SUCCESS;
     242}
     243
     244
     245/**
    188246 * @interface_method_impl{PDMDEVREG,pfnConstruct}
    189247 */
     
    271329    NULL,
    272330    /* pfnInitComplete. */
    273     NULL,
     331    pcarchInitComplete,
    274332    /* pfnPowerOff */
    275333    NULL,
Note: See TracChangeset for help on using the changeset viewer.

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