Changeset 99080 in vbox for trunk/src/VBox/Frontends/VBoxBFE
- Timestamp:
- Mar 21, 2023 11:06:54 AM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp
r99050 r99080 63 63 } while (0) 64 64 65 #define DTB_ADDR 0x40000000 66 65 67 66 68 /********************************************************************************************************************************* … … 81 83 static VMSTATE g_enmVmState = VMSTATE_CREATING; 82 84 static const char *g_pszLoadMem = NULL; 85 static const char *g_pszLoadDtb = NULL; 83 86 84 87 /** @todo currently this is only set but never read. */ … … 237 240 */ 238 241 PCFGMNODE pRoot = pVMM->pfnCFGMR3GetRoot(pVM); 239 rc = pVMM->pfnCFGMR3InsertString(pRoot, "Name", "Default VM"); UPDATE_RC(); 240 rc = pVMM->pfnCFGMR3InsertInteger(pRoot, "RamSize", g_u32MemorySizeMB * _1M); UPDATE_RC(); 241 rc = pVMM->pfnCFGMR3InsertInteger(pRoot, "RamHoleSize", 512U * _1M); UPDATE_RC(); 242 rc = pVMM->pfnCFGMR3InsertInteger(pRoot, "TimerMillies", 1000); UPDATE_RC(); 242 rc = pVMM->pfnCFGMR3InsertString(pRoot, "Name", "Default VM"); UPDATE_RC(); 243 rc = pVMM->pfnCFGMR3InsertInteger(pRoot, "TimerMillies", 1000); UPDATE_RC(); 244 245 /* 246 * Memory setup. 247 */ 248 PCFGMNODE pMem = NULL; 249 rc = pVMM->pfnCFGMR3InsertNode(pRoot, "MM", &pMem); UPDATE_RC(); 250 rc = pVMM->pfnCFGMR3InsertNode(pMem, "MemRegions", &pMem); UPDATE_RC(); 251 252 PCFGMNODE pMemRegion = NULL; 253 rc = pVMM->pfnCFGMR3InsertNode(pMem, "Flash", &pMemRegion); UPDATE_RC(); 254 rc = pVMM->pfnCFGMR3InsertInteger(pMemRegion, "GCPhysStart", 0); UPDATE_RC(); 255 rc = pVMM->pfnCFGMR3InsertInteger(pMemRegion, "Size", 128 * _1M); UPDATE_RC(); 256 257 rc = pVMM->pfnCFGMR3InsertNode(pMem, "Conventional", &pMemRegion); UPDATE_RC(); 258 rc = pVMM->pfnCFGMR3InsertInteger(pMemRegion, "GCPhysStart", DTB_ADDR); UPDATE_RC(); 259 rc = pVMM->pfnCFGMR3InsertInteger(pMemRegion, "Size", (uint64_t)g_u32MemorySizeMB * _1M); UPDATE_RC(); 260 243 261 244 262 /* … … 314 332 315 333 334 /** 335 * Loads the content of a given file into guest RAM starting at the given guest physical address. 336 * 337 * @returns VBox status code. 338 * @param pszFile The file to load. 339 * @param GCPhysStart The physical start address to load the file at. 340 */ 341 static int vboxbfeLoadFileAtGCPhys(const char *pszFile, RTGCPHYS GCPhysStart) 342 { 343 RTFILE hFile = NIL_RTFILE; 344 int rc = RTFileOpen(&hFile, pszFile, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 345 if (RT_SUCCESS(rc)) 346 { 347 uint8_t abRead[GUEST_PAGE_SIZE]; 348 RTGCPHYS GCPhys = GCPhysStart; 349 350 for (;;) 351 { 352 size_t cbThisRead = 0; 353 rc = RTFileRead(hFile, &abRead[0], sizeof(abRead), &cbThisRead); 354 if (RT_FAILURE(rc)) 355 break; 356 357 rc = g_pVMM->pfnPGMPhysSimpleWriteGCPhys(g_pVM, GCPhys, &abRead[0], cbThisRead); 358 if (RT_FAILURE(rc)) 359 break; 360 361 GCPhys += cbThisRead; 362 if (cbThisRead < sizeof(abRead)) 363 break; 364 } 365 366 RTFileClose(hFile); 367 } 368 else 369 RTPrintf("Loading file %s failed -> %Rrc\n", pszFile, rc); 370 371 return rc; 372 } 373 374 316 375 /** VM asynchronous operations thread */ 317 376 DECLCALLBACK(int) vboxbfeVMPowerUpThread(RTTHREAD hThread, void *pvUser) … … 386 445 if (g_pszLoadMem) 387 446 { 388 RTFILE hFile = NIL_RTFILE; 389 rc = RTFileOpen(&hFile, g_pszLoadMem, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 390 if (RT_SUCCESS(rc)) 391 { 392 uint8_t abRead[GUEST_PAGE_SIZE]; 393 RTGCPHYS GCPhys = 0; 394 395 for (;;) 396 { 397 size_t cbThisRead = 0; 398 rc = RTFileRead(hFile, &abRead[0], sizeof(abRead), &cbThisRead); 399 if (RT_FAILURE(rc)) 400 break; 401 402 rc = g_pVMM->pfnPGMPhysSimpleWriteGCPhys(g_pVM, GCPhys, &abRead[0], cbThisRead); 403 if (RT_FAILURE(rc)) 404 break; 405 406 GCPhys += cbThisRead; 407 if (cbThisRead < sizeof(abRead)) 408 break; 409 } 410 411 RTFileClose(hFile); 412 } 413 else 414 RTPrintf("Loading file %s failed -> %Rrc\n", g_pszLoadMem, rc); 415 447 rc = vboxbfeLoadFileAtGCPhys(g_pszLoadMem, 0 /*GCPhysStart*/); 448 if (RT_FAILURE(rc)) 449 goto failure; 450 } 451 452 if (g_pszLoadDtb) 453 { 454 rc = vboxbfeLoadFileAtGCPhys(g_pszLoadDtb, DTB_ADDR); 416 455 if (RT_FAILURE(rc)) 417 456 goto failure; … … 494 533 { "--memory-size-mib", 'm', RTGETOPT_REQ_UINT32 }, 495 534 { "--load-file-into-ram", 'l', RTGETOPT_REQ_STRING }, 535 { "--load-dtb", 'd', RTGETOPT_REQ_STRING }, 496 536 { "--load-vmm", 'v', RTGETOPT_REQ_STRING }, 497 537 }; … … 516 556 case 'l': 517 557 g_pszLoadMem = ValueUnion.psz; 558 break; 559 case 'd': 560 g_pszLoadDtb = ValueUnion.psz; 518 561 break; 519 562 case 'v':
Note:
See TracChangeset
for help on using the changeset viewer.