Changeset 99907 in vbox for trunk/src/VBox/VMM
- Timestamp:
- May 22, 2023 4:58:55 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/MM.cpp
r99739 r99907 171 171 #include <iprt/assert.h> 172 172 #include <iprt/string.h> 173 #if defined(VBOX_VMM_TARGET_ARMV8) 174 # include <iprt/file.h> 175 #endif 173 176 174 177 … … 271 274 #if defined(VBOX_VMM_TARGET_ARMV8) 272 275 /** 276 * Initializes the given RAM range with data from the given file. 277 * 278 * @returns VBox status code. 279 * @param pVM The cross context VM structure. 280 * @param GCPhysStart Where to start putting the file content. 281 * @param pszFilename The file to read the data from. 282 */ 283 static int mmR3RamRegionInitFromFile(PVM pVM, RTGCPHYS GCPhysStart, const char *pszFilename) 284 { 285 RTFILE hFile = NIL_RTFILE; 286 int rc = RTFileOpen(&hFile, pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 287 if (RT_SUCCESS(rc)) 288 { 289 uint8_t abRead[GUEST_PAGE_SIZE]; 290 RTGCPHYS GCPhys = GCPhysStart; 291 292 for (;;) 293 { 294 size_t cbThisRead = 0; 295 rc = RTFileRead(hFile, &abRead[0], sizeof(abRead), &cbThisRead); 296 if (RT_FAILURE(rc)) 297 break; 298 299 rc = PGMPhysSimpleWriteGCPhys(pVM, GCPhys, &abRead[0], cbThisRead); 300 if (RT_FAILURE(rc)) 301 break; 302 303 GCPhys += cbThisRead; 304 if (cbThisRead < sizeof(abRead)) 305 break; 306 } 307 308 RTFileClose(hFile); 309 } 310 311 if (RT_FAILURE(rc)) 312 LogRel(("RAM#%RGp: Loading file %s failed -> %Rrc\n", GCPhysStart, pszFilename, rc)); 313 314 return rc; 315 } 316 317 318 /** 273 319 * This sets up the RAM ranges from the VM config. 274 320 * … … 322 368 LogRel(("Failed to register memory region '%s' GCPhysStart=%RGp Size=%#RX64 -> %Rrc\n", 323 369 szMemRegion, u64GCPhysStart, u64MemSize)); 370 break; 371 } 372 373 char *pszFilename = NULL; 374 rc = CFGMR3QueryStringAlloc(pCur, "PrepopulateFromFile", &pszFilename); 375 if (RT_SUCCESS(rc)) 376 { 377 rc = mmR3RamRegionInitFromFile(pVM, u64GCPhysStart, pszFilename); 378 MMR3HeapFree(pszFilename); 379 if (RT_FAILURE(rc)) 380 break; 381 } 382 else if (rc != VERR_CFGM_VALUE_NOT_FOUND) 383 { 384 LogRel(("Failed to query \"PrepopulateFromFile\" for memory region %s -> %Rrc\n", szMemRegion, rc)); 324 385 break; 325 386 }
Note:
See TracChangeset
for help on using the changeset viewer.