VirtualBox

Changeset 99908 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
May 22, 2023 4:59:46 PM (20 months ago)
Author:
vboxsync
Message:

FE/VBoxBFE: Use the new PrepopulateFromFile CFGM key when initializing the UEFI and DTB area, bugref:10397

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp

    r99894 r99908  
    740740    rc = pVMM->pfnCFGMR3InsertInteger(pMemRegion, "GCPhysStart",   0);                          UPDATE_RC();
    741741    rc = pVMM->pfnCFGMR3InsertInteger(pMemRegion, "Size", 64 * _1M);                            UPDATE_RC();
     742    if (g_pszLoadMem)
     743    {
     744        rc = pVMM->pfnCFGMR3InsertString(pMemRegion, "PrepopulateFromFile", g_pszLoadMem);      UPDATE_RC();
     745    }
    742746
    743747    rc = pVMM->pfnCFGMR3InsertNode(pMem, "Conventional", &pMemRegion);                          UPDATE_RC();
    744748    rc = pVMM->pfnCFGMR3InsertInteger(pMemRegion, "GCPhysStart",   DTB_ADDR);                   UPDATE_RC();
    745749    rc = pVMM->pfnCFGMR3InsertInteger(pMemRegion, "Size", (uint64_t)g_u32MemorySizeMB * _1M);   UPDATE_RC();
    746 
     750    if (g_pszLoadDtb)
     751    {
     752        rc = pVMM->pfnCFGMR3InsertString(pMemRegion, "PrepopulateFromFile", g_pszLoadDtb);      UPDATE_RC();
     753
     754    }
    747755
    748756    /*
     
    983991
    984992/**
    985  * Loads the content of a given file into guest RAM starting at the given guest physical address.
    986  *
    987  * @returns VBox status code.
    988  * @param   pszFile         The file to load.
    989  * @param   GCPhysStart     The physical start address to load the file at.
    990  */
    991 static int vboxbfeLoadFileAtGCPhys(const char *pszFile, RTGCPHYS GCPhysStart)
    992 {
    993     RTFILE hFile = NIL_RTFILE;
    994     int rc = RTFileOpen(&hFile, pszFile, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    995     if (RT_SUCCESS(rc))
    996     {
    997         uint8_t abRead[GUEST_PAGE_SIZE];
    998         RTGCPHYS GCPhys = GCPhysStart;
    999 
    1000         for (;;)
    1001         {
    1002             size_t cbThisRead = 0;
    1003             rc = RTFileRead(hFile, &abRead[0], sizeof(abRead), &cbThisRead);
    1004             if (RT_FAILURE(rc))
    1005                 break;
    1006 
    1007             rc = g_pVMM->pfnPGMPhysSimpleWriteGCPhys(g_pVM, GCPhys, &abRead[0], cbThisRead);
    1008             if (RT_FAILURE(rc))
    1009                 break;
    1010 
    1011             GCPhys += cbThisRead;
    1012             if (cbThisRead < sizeof(abRead))
    1013                 break;
    1014         }
    1015 
    1016         RTFileClose(hFile);
    1017     }
    1018     else
    1019         RTPrintf("Loading file %s failed -> %Rrc\n", pszFile, rc);
    1020 
    1021     return rc;
    1022 }
    1023 
    1024 
    1025 /**
    1026993 * @interface_method_impl{VMM2USERMETHODS,pfnQueryGenericObject}
    1027994 */
     
    11161083        RTPrintf("Error: VMR3AtStateRegister failed with %Rrc.\n", rc);
    11171084        goto failure;
    1118     }
    1119 
    1120     /*
    1121      * Prepopulate the memory?
    1122      */
    1123     if (g_pszLoadMem)
    1124     {
    1125         rc = vboxbfeLoadFileAtGCPhys(g_pszLoadMem, 0 /*GCPhysStart*/);
    1126         if (RT_FAILURE(rc))
    1127             goto failure;
    1128     }
    1129 
    1130     if (g_pszLoadDtb)
    1131     {
    1132         rc = vboxbfeLoadFileAtGCPhys(g_pszLoadDtb, DTB_ADDR);
    1133         if (RT_FAILURE(rc))
    1134             goto failure;
    11351085    }
    11361086
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