Changeset 81502 in vbox for trunk/src/VBox
- Timestamp:
- Oct 24, 2019 1:40:30 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/DevEFI.cpp
r81484 r81502 56 56 57 57 /* EFI includes */ 58 #ifdef _MSC_VER 59 # pragma warning(push) 60 # pragma warning(disable:4668) 58 #ifdef IN_RING3 59 # ifdef _MSC_VER 60 # pragma warning(push) 61 # pragma warning(disable:4668) 62 # endif 63 # include <ProcessorBind.h> 64 # ifdef _MSC_VER 65 # pragma warning(pop) 66 # endif 67 # include <Common/UefiBaseTypes.h> 68 # include <Common/PiFirmwareVolume.h> 69 # include <Common/PiFirmwareFile.h> 61 70 #endif 62 #include <ProcessorBind.h>63 #ifdef _MSC_VER64 # pragma warning(pop)65 #endif66 #include <Common/UefiBaseTypes.h>67 #include <Common/PiFirmwareVolume.h>68 #include <Common/PiFirmwareFile.h>69 71 70 72 … … 135 137 136 138 /** 137 * The EFI device s tate structure.139 * The EFI device shared state structure. 138 140 */ 139 141 typedef struct DEVEFI 142 { 143 /** The flash device containing the NVRAM. */ 144 FLASHCORE Flash; 145 /** The flash MMIO handle. */ 146 IOMMMIOHANDLE hMmioFlash; 147 } DEVEFI; 148 /** Pointer to the shared EFI state. */ 149 typedef DEVEFI *PDEVEFI; 150 151 /** 152 * The EFI device state structure for ring-3. 153 */ 154 typedef struct DEVEFIR3 140 155 { 141 156 /** Pointer back to the device instance. */ … … 245 260 /** NVRAM state variables. */ 246 261 NVRAMDESC NVRAM; 247 /** The flash device containing the NVRAM. */248 FLASHCORE Flash;249 262 /** Filename of the file containing the NVRAM store. */ 250 263 char *pszNvramFile; … … 264 277 PPDMINVRAMCONNECTOR pNvramDrv; 265 278 } Lun0; 266 } DEVEFI; 267 typedef DEVEFI *PDEVEFI; 279 } DEVEFIR3; 280 /** Pointer to the ring-3 EFI state. */ 281 typedef DEVEFIR3 *PDEVEFIR3; 282 283 284 /** 285 * The EFI device state structure for ring-0. 286 */ 287 typedef struct DEVEFIR0 288 { 289 uint32_t uEmpty; 290 } DEVEFIR0; 291 /** Pointer to the ring-0 EFI state. */ 292 typedef DEVEFIR0 *PDEVEFIR0; 293 294 295 /** 296 * The EFI device state structure for raw-mode. 297 */ 298 typedef struct DEVEFIRC 299 { 300 uint32_t uEmpty; 301 } DEVEFIRC; 302 /** Pointer to the raw-mode EFI state. */ 303 typedef DEVEFIRC *PDEVEFIRC; 304 305 306 /** @typedef DEVEFICC 307 * The instance data for the current context. */ 308 /** @typedef PDEVEFICC 309 * Pointer to the instance data for the current context. */ 310 #ifdef IN_RING3 311 typedef DEVEFIR3 DEVEFICC; 312 typedef PDEVEFIR3 PDEVEFICC; 313 #elif defined(IN_RING0) 314 typedef DEVEFIR0 DEVEFICC; 315 typedef PDEVEFIR0 PDEVEFICC; 316 #elif defined(IN_RC) 317 typedef DEVEFIRC DEVEFICC; 318 typedef PDEVEFIRC PDEVEFICC; 319 #else 320 # error "Not IN_RING3, IN_RING0 or IN_RC" 321 #endif 268 322 269 323 … … 287 341 * Global Variables * 288 342 *********************************************************************************************************************************/ 343 #ifdef IN_RING3 289 344 /** Saved state NVRAMDESC field descriptors. */ 290 345 static SSMFIELD const g_aEfiNvramDescField[] = … … 319 374 static const RTUUID g_UuidNvDataFv = { { 0x8d, 0x2b, 0xf1, 0xff, 0x96, 0x76, 0x8b, 0x4c, 0xa9, 0x85, 0x27, 0x47, 0x07, 0x5b, 0x4f, 0x50} }; 320 375 321 # ifdef VBOX_WITH_EFI_IN_DD2376 # ifdef VBOX_WITH_EFI_IN_DD2 322 377 /** Special file name value for indicating the 32-bit built-in EFI firmware. */ 323 378 static const char g_szEfiBuiltin32[] = "VBoxEFI32.fd"; 324 379 /** Special file name value for indicating the 64-bit built-in EFI firmware. */ 325 380 static const char g_szEfiBuiltin64[] = "VBoxEFI64.fd"; 326 #endif 327 328 329 381 # endif 382 #endif /* IN_RING3 */ 383 384 385 #ifdef IN_RING3 330 386 331 387 /** 332 388 * Flushes the variable list. 333 389 * 334 * @param pThis The EFI state.335 */ 336 static void nvramFlushDeviceVariableList(PDEVEFI pThis)337 { 338 while (!RTListIsEmpty(&pThis ->NVRAM.VarList))339 { 340 PEFIVAR pEfiVar = RTListNodeGetNext(&pThis ->NVRAM.VarList, EFIVAR, ListNode);390 * @param pThisCC The EFI state for the current context. 391 */ 392 static void nvramFlushDeviceVariableList(PDEVEFIR3 pThisCC) 393 { 394 while (!RTListIsEmpty(&pThisCC->NVRAM.VarList)) 395 { 396 PEFIVAR pEfiVar = RTListNodeGetNext(&pThisCC->NVRAM.VarList, EFIVAR, ListNode); 341 397 RTListNodeRemove(&pEfiVar->ListNode); 342 398 RTMemFree(pEfiVar); 343 399 } 344 400 345 pThis ->NVRAM.pCurVar = NULL;401 pThisCC->NVRAM.pCurVar = NULL; 346 402 } 347 403 … … 349 405 * This function looks up variable in NVRAM list. 350 406 */ 351 static int nvramLookupVariableByUuidAndName(PDEVEFI pThis, char *pszVariableName, PCRTUUID pUuid, PPEFIVAR ppEfiVar)407 static int nvramLookupVariableByUuidAndName(PDEVEFIR3 pThisCC, char *pszVariableName, PCRTUUID pUuid, PPEFIVAR ppEfiVar) 352 408 { 353 409 LogFlowFunc(("%RTuuid::'%s'\n", pUuid, pszVariableName)); … … 358 414 * Start by checking the last variable queried. 359 415 */ 360 if ( pThis ->NVRAM.pCurVar361 && pThis ->NVRAM.pCurVar->cchName == cchVariableName362 && memcmp(pThis ->NVRAM.pCurVar->szName, pszVariableName, cchVariableName + 1) == 0363 && RTUuidCompare(&pThis ->NVRAM.pCurVar->uuid, pUuid) == 0416 if ( pThisCC->NVRAM.pCurVar 417 && pThisCC->NVRAM.pCurVar->cchName == cchVariableName 418 && memcmp(pThisCC->NVRAM.pCurVar->szName, pszVariableName, cchVariableName + 1) == 0 419 && RTUuidCompare(&pThisCC->NVRAM.pCurVar->uuid, pUuid) == 0 364 420 ) 365 421 { 366 *ppEfiVar = pThis ->NVRAM.pCurVar;422 *ppEfiVar = pThisCC->NVRAM.pCurVar; 367 423 rc = VINF_SUCCESS; 368 424 } … … 373 429 */ 374 430 PEFIVAR pEfiVar; 375 RTListForEach(&pThis ->NVRAM.VarList, pEfiVar, EFIVAR, ListNode)431 RTListForEach(&pThisCC->NVRAM.VarList, pEfiVar, EFIVAR, ListNode) 376 432 { 377 433 Assert(strlen(pEfiVar->szName) == pEfiVar->cchName); … … 397 453 * This enforces the desired list ordering and/or insertion policy. 398 454 * 399 * @param pThis The EFI state.455 * @param pThisCC The EFI state for the current context. 400 456 * @param pEfiVar The variable to insert. 401 457 */ 402 static void nvramInsertVariable(PDEVEFI pThis, PEFIVAR pEfiVar)458 static void nvramInsertVariable(PDEVEFIR3 pThisCC, PEFIVAR pEfiVar) 403 459 { 404 460 #if 1 … … 407 463 */ 408 464 PEFIVAR pCurVar; 409 RTListForEach(&pThis ->NVRAM.VarList, pCurVar, EFIVAR, ListNode)465 RTListForEach(&pThisCC->NVRAM.VarList, pCurVar, EFIVAR, ListNode) 410 466 { 411 467 int iDiff = RTUuidCompare(&pEfiVar->uuid, &pCurVar->uuid); … … 423 479 * Add it at the end. 424 480 */ 425 RTListAppend(&pThis ->NVRAM.VarList, &pEfiVar->ListNode);481 RTListAppend(&pThisCC->NVRAM.VarList, &pEfiVar->ListNode); 426 482 } 427 483 … … 431 487 * 432 488 * @returns VBox status code. 433 * @param pThis The EFI state.434 */ 435 static int nvramLoad(PDEVEFI pThis)489 * @param pThisCC The EFI state for the current context. 490 */ 491 static int nvramLoad(PDEVEFIR3 pThisCC) 436 492 { 437 493 int rc; … … 443 499 pEfiVar->cchName = sizeof(pEfiVar->szName); 444 500 pEfiVar->cbValue = sizeof(pEfiVar->abValue); 445 rc = pThis ->Lun0.pNvramDrv->pfnVarQueryByIndex(pThis->Lun0.pNvramDrv, iVar,501 rc = pThisCC->Lun0.pNvramDrv->pfnVarQueryByIndex(pThisCC->Lun0.pNvramDrv, iVar, 446 502 &pEfiVar->uuid, &pEfiVar->szName[0], &pEfiVar->cchName, 447 503 &pEfiVar->fAttributes, &pEfiVar->abValue[0], &pEfiVar->cbValue); … … 469 525 470 526 /* Append it. */ 471 nvramInsertVariable(pThis , pEfiVar);472 pThis ->NVRAM.cVariables++;527 nvramInsertVariable(pThisCC, pEfiVar); 528 pThisCC->NVRAM.cVariables++; 473 529 } 474 530 … … 482 538 * 483 539 * @returns VBox status code. 484 * @param pThis The EFI state.485 */ 486 static int nvramStore(PDEVEFI pThis)540 * @param pThisCC The EFI state for the current context. 541 */ 542 static int nvramStore(PDEVEFIR3 pThisCC) 487 543 { 488 544 /* … … 491 547 PEFIVAR pEfiVar; 492 548 uint32_t cNonVolatile = 0; 493 RTListForEach(&pThis ->NVRAM.VarList, pEfiVar, EFIVAR, ListNode)549 RTListForEach(&pThisCC->NVRAM.VarList, pEfiVar, EFIVAR, ListNode) 494 550 if (pEfiVar->fAttributes & VBOX_EFI_VARIABLE_NON_VOLATILE) 495 551 cNonVolatile++; 496 int rc = pThis ->Lun0.pNvramDrv->pfnVarStoreSeqBegin(pThis->Lun0.pNvramDrv, cNonVolatile);552 int rc = pThisCC->Lun0.pNvramDrv->pfnVarStoreSeqBegin(pThisCC->Lun0.pNvramDrv, cNonVolatile); 497 553 if (RT_SUCCESS(rc)) 498 554 { … … 501 557 */ 502 558 uint32_t idxVar = 0; 503 RTListForEach(&pThis ->NVRAM.VarList, pEfiVar, EFIVAR, ListNode)559 RTListForEach(&pThisCC->NVRAM.VarList, pEfiVar, EFIVAR, ListNode) 504 560 { 505 561 /* Skip volatile variables. */ … … 507 563 continue; 508 564 509 int rc2 = pThis ->Lun0.pNvramDrv->pfnVarStoreSeqPut(pThis->Lun0.pNvramDrv, idxVar,565 int rc2 = pThisCC->Lun0.pNvramDrv->pfnVarStoreSeqPut(pThisCC->Lun0.pNvramDrv, idxVar, 510 566 &pEfiVar->uuid, pEfiVar->szName, pEfiVar->cchName, 511 567 pEfiVar->fAttributes, pEfiVar->abValue, pEfiVar->cbValue); … … 522 578 * Done. 523 579 */ 524 rc = pThis ->Lun0.pNvramDrv->pfnVarStoreSeqEnd(pThis->Lun0.pNvramDrv, rc);580 rc = pThisCC->Lun0.pNvramDrv->pfnVarStoreSeqEnd(pThisCC->Lun0.pNvramDrv, rc); 525 581 } 526 582 else … … 533 589 * variable into the VarOpBuf, set pCurVar and u32Status. 534 590 * 535 * @param pThis The EFI state.591 * @param pThisCC The EFI state for the current context. 536 592 * @param pEfiVar The resulting variable. NULL if not found / end. 537 593 * @param fEnumQuery Set if enumeration query, clear if specific. 538 594 */ 539 static void nvramWriteVariableOpQueryCopyResult(PDEVEFI pThis, PEFIVAR pEfiVar, bool fEnumQuery)540 { 541 RT_ZERO(pThis ->NVRAM.VarOpBuf.abValue);595 static void nvramWriteVariableOpQueryCopyResult(PDEVEFIR3 pThisCC, PEFIVAR pEfiVar, bool fEnumQuery) 596 { 597 RT_ZERO(pThisCC->NVRAM.VarOpBuf.abValue); 542 598 if (pEfiVar) 543 599 { 544 RT_ZERO(pThis ->NVRAM.VarOpBuf.szName);545 pThis ->NVRAM.VarOpBuf.uuid = pEfiVar->uuid;546 pThis ->NVRAM.VarOpBuf.cchName = pEfiVar->cchName;547 memcpy(pThis ->NVRAM.VarOpBuf.szName, pEfiVar->szName, pEfiVar->cchName); /* no need for + 1. */548 pThis ->NVRAM.VarOpBuf.fAttributes = pEfiVar->fAttributes;549 pThis ->NVRAM.VarOpBuf.cbValue = pEfiVar->cbValue;550 memcpy(pThis ->NVRAM.VarOpBuf.abValue, pEfiVar->abValue, pEfiVar->cbValue);551 pThis ->NVRAM.pCurVar = pEfiVar;552 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK;553 LogFlow(("EFI: Variable query -> %RTuuid::'%s' (%d) abValue=%.*Rhxs\n", &pThis ->NVRAM.VarOpBuf.uuid,554 pThis ->NVRAM.VarOpBuf.szName, pThis->NVRAM.VarOpBuf.cchName,555 pThis ->NVRAM.VarOpBuf.cbValue, pThis->NVRAM.VarOpBuf.abValue));600 RT_ZERO(pThisCC->NVRAM.VarOpBuf.szName); 601 pThisCC->NVRAM.VarOpBuf.uuid = pEfiVar->uuid; 602 pThisCC->NVRAM.VarOpBuf.cchName = pEfiVar->cchName; 603 memcpy(pThisCC->NVRAM.VarOpBuf.szName, pEfiVar->szName, pEfiVar->cchName); /* no need for + 1. */ 604 pThisCC->NVRAM.VarOpBuf.fAttributes = pEfiVar->fAttributes; 605 pThisCC->NVRAM.VarOpBuf.cbValue = pEfiVar->cbValue; 606 memcpy(pThisCC->NVRAM.VarOpBuf.abValue, pEfiVar->abValue, pEfiVar->cbValue); 607 pThisCC->NVRAM.pCurVar = pEfiVar; 608 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK; 609 LogFlow(("EFI: Variable query -> %RTuuid::'%s' (%d) abValue=%.*Rhxs\n", &pThisCC->NVRAM.VarOpBuf.uuid, 610 pThisCC->NVRAM.VarOpBuf.szName, pThisCC->NVRAM.VarOpBuf.cchName, 611 pThisCC->NVRAM.VarOpBuf.cbValue, pThisCC->NVRAM.VarOpBuf.abValue)); 556 612 } 557 613 else … … 561 617 else 562 618 LogFlow(("EFI: Variable query %RTuuid::'%s' -> NOT_FOUND \n", 563 &pThis ->NVRAM.VarOpBuf.uuid, pThis->NVRAM.VarOpBuf.szName));564 RT_ZERO(pThis ->NVRAM.VarOpBuf.szName);565 pThis ->NVRAM.VarOpBuf.fAttributes = 0;566 pThis ->NVRAM.VarOpBuf.cbValue = 0;567 pThis ->NVRAM.VarOpBuf.cchName = 0;568 pThis ->NVRAM.pCurVar = NULL;569 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_NOT_FOUND;619 &pThisCC->NVRAM.VarOpBuf.uuid, pThisCC->NVRAM.VarOpBuf.szName)); 620 RT_ZERO(pThisCC->NVRAM.VarOpBuf.szName); 621 pThisCC->NVRAM.VarOpBuf.fAttributes = 0; 622 pThisCC->NVRAM.VarOpBuf.cbValue = 0; 623 pThisCC->NVRAM.VarOpBuf.cchName = 0; 624 pThisCC->NVRAM.pCurVar = NULL; 625 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_NOT_FOUND; 570 626 } 571 627 } … … 575 631 * 576 632 * @returns IOM strict status code. 577 * @param pThis The EFI state.578 */ 579 static int nvramWriteVariableOpQuery(PDEVEFI pThis)580 { 581 Log(("EFI_VARIABLE_OP_QUERY: %RTuuid::'%s'\n", &pThis ->NVRAM.VarOpBuf.uuid, pThis->NVRAM.VarOpBuf.szName));633 * @param pThisCC The EFI state for the current context. 634 */ 635 static int nvramWriteVariableOpQuery(PDEVEFIR3 pThisCC) 636 { 637 Log(("EFI_VARIABLE_OP_QUERY: %RTuuid::'%s'\n", &pThisCC->NVRAM.VarOpBuf.uuid, pThisCC->NVRAM.VarOpBuf.szName)); 582 638 583 639 PEFIVAR pEfiVar; 584 int rc = nvramLookupVariableByUuidAndName(pThis ,585 pThis ->NVRAM.VarOpBuf.szName,586 &pThis ->NVRAM.VarOpBuf.uuid,640 int rc = nvramLookupVariableByUuidAndName(pThisCC, 641 pThisCC->NVRAM.VarOpBuf.szName, 642 &pThisCC->NVRAM.VarOpBuf.uuid, 587 643 &pEfiVar); 588 nvramWriteVariableOpQueryCopyResult(pThis , RT_SUCCESS(rc) ? pEfiVar : NULL, false /*fEnumQuery*/);644 nvramWriteVariableOpQueryCopyResult(pThisCC, RT_SUCCESS(rc) ? pEfiVar : NULL, false /*fEnumQuery*/); 589 645 return VINF_SUCCESS; 590 646 } … … 596 652 * 597 653 * @returns IOM strict status code. 598 * @param pThis The EFI state.599 */ 600 static int nvramWriteVariableOpQueryNext(PDEVEFI pThis)601 { 602 Log(("EFI_VARIABLE_OP_QUERY_NEXT: pCurVar=%p\n", pThis ->NVRAM.pCurVar));603 PEFIVAR pEfiVar = pThis ->NVRAM.pCurVar;654 * @param pThisCC The EFI state for the current context. 655 */ 656 static int nvramWriteVariableOpQueryNext(PDEVEFIR3 pThisCC) 657 { 658 Log(("EFI_VARIABLE_OP_QUERY_NEXT: pCurVar=%p\n", pThisCC->NVRAM.pCurVar)); 659 PEFIVAR pEfiVar = pThisCC->NVRAM.pCurVar; 604 660 if (pEfiVar) 605 pEfiVar = RTListGetNext(&pThis ->NVRAM.VarList, pEfiVar, EFIVAR, ListNode);661 pEfiVar = RTListGetNext(&pThisCC->NVRAM.VarList, pEfiVar, EFIVAR, ListNode); 606 662 else 607 pEfiVar = RTListGetFirst(&pThis ->NVRAM.VarList, EFIVAR, ListNode);608 nvramWriteVariableOpQueryCopyResult(pThis , pEfiVar, true /* fEnumQuery */);663 pEfiVar = RTListGetFirst(&pThisCC->NVRAM.VarList, EFIVAR, ListNode); 664 nvramWriteVariableOpQueryCopyResult(pThisCC, pEfiVar, true /* fEnumQuery */); 609 665 return VINF_SUCCESS; 610 666 } … … 614 670 * 615 671 * @returns IOM strict status code. 616 * @param pThis The EFI state.617 */ 618 static int nvramWriteVariableOpAdd(PDEVEFI pThis)672 * @param pThisCC The EFI state for the current context. 673 */ 674 static int nvramWriteVariableOpAdd(PDEVEFIR3 pThisCC) 619 675 { 620 676 Log(("EFI_VARIABLE_OP_ADD: %RTuuid::'%s' fAttributes=%#x abValue=%.*Rhxs\n", 621 &pThis ->NVRAM.VarOpBuf.uuid, pThis->NVRAM.VarOpBuf.szName, pThis->NVRAM.VarOpBuf.fAttributes,622 pThis ->NVRAM.VarOpBuf.cbValue, pThis->NVRAM.VarOpBuf.abValue));677 &pThisCC->NVRAM.VarOpBuf.uuid, pThisCC->NVRAM.VarOpBuf.szName, pThisCC->NVRAM.VarOpBuf.fAttributes, 678 pThisCC->NVRAM.VarOpBuf.cbValue, pThisCC->NVRAM.VarOpBuf.abValue)); 623 679 624 680 /* 625 681 * Validate and adjust the input a little before we start. 626 682 */ 627 int rc = RTStrValidateEncoding(pThis ->NVRAM.VarOpBuf.szName);683 int rc = RTStrValidateEncoding(pThisCC->NVRAM.VarOpBuf.szName); 628 684 if (RT_FAILURE(rc)) 629 LogRel(("EFI: Badly encoded variable name: %.*Rhxs\n", pThis ->NVRAM.VarOpBuf.cchName + 1, pThis->NVRAM.VarOpBuf.szName));685 LogRel(("EFI: Badly encoded variable name: %.*Rhxs\n", pThisCC->NVRAM.VarOpBuf.cchName + 1, pThisCC->NVRAM.VarOpBuf.szName)); 630 686 if (RT_FAILURE(rc)) 631 687 { 632 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;688 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 633 689 return VINF_SUCCESS; 634 690 } 635 pThis ->NVRAM.VarOpBuf.cchName = (uint32_t)RTStrNLen(pThis->NVRAM.VarOpBuf.szName, sizeof(pThis->NVRAM.VarOpBuf.szName));691 pThisCC->NVRAM.VarOpBuf.cchName = (uint32_t)RTStrNLen(pThisCC->NVRAM.VarOpBuf.szName, sizeof(pThisCC->NVRAM.VarOpBuf.szName)); 636 692 637 693 /* … … 639 695 */ 640 696 PEFIVAR pEfiVar; 641 rc = nvramLookupVariableByUuidAndName(pThis ,642 pThis ->NVRAM.VarOpBuf.szName,643 &pThis ->NVRAM.VarOpBuf.uuid,697 rc = nvramLookupVariableByUuidAndName(pThisCC, 698 pThisCC->NVRAM.VarOpBuf.szName, 699 &pThisCC->NVRAM.VarOpBuf.uuid, 644 700 &pEfiVar); 645 701 if (RT_SUCCESS(rc)) … … 649 705 if (pEfiVar->fAttributes & EFI_VARIABLE_XXXXXXX) 650 706 { 651 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_RO;707 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_RO; 652 708 break; 653 709 } 654 710 #endif 655 711 656 if (pThis ->NVRAM.VarOpBuf.cbValue == 0)712 if (pThisCC->NVRAM.VarOpBuf.cbValue == 0) 657 713 { 658 714 /* 659 715 * Delete it. 660 716 */ 661 LogRel(("EFI: Deleting variable %RTuuid::'%s'\n", &pThis ->NVRAM.VarOpBuf.uuid, pThis->NVRAM.VarOpBuf.szName));717 LogRel(("EFI: Deleting variable %RTuuid::'%s'\n", &pThisCC->NVRAM.VarOpBuf.uuid, pThisCC->NVRAM.VarOpBuf.szName)); 662 718 RTListNodeRemove(&pEfiVar->ListNode); 663 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK;664 pThis ->NVRAM.cVariables--;665 666 if (pThis ->NVRAM.pCurVar == pEfiVar)667 pThis ->NVRAM.pCurVar = NULL;719 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK; 720 pThisCC->NVRAM.cVariables--; 721 722 if (pThisCC->NVRAM.pCurVar == pEfiVar) 723 pThisCC->NVRAM.pCurVar = NULL; 668 724 RTMemFree(pEfiVar); 669 725 pEfiVar = NULL; … … 674 730 * Update/replace it. (The name and UUID are unchanged, of course.) 675 731 */ 676 LogRel(("EFI: Replacing variable %RTuuid::'%s' fAttrib=%#x cbValue=%#x\n", &pThis ->NVRAM.VarOpBuf.uuid,677 pThis ->NVRAM.VarOpBuf.szName, pThis->NVRAM.VarOpBuf.fAttributes, pThis->NVRAM.VarOpBuf.cbValue));678 pEfiVar->fAttributes = pThis ->NVRAM.VarOpBuf.fAttributes;679 pEfiVar->cbValue = pThis ->NVRAM.VarOpBuf.cbValue;680 memcpy(pEfiVar->abValue, pThis ->NVRAM.VarOpBuf.abValue, pEfiVar->cbValue);681 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK;732 LogRel(("EFI: Replacing variable %RTuuid::'%s' fAttrib=%#x cbValue=%#x\n", &pThisCC->NVRAM.VarOpBuf.uuid, 733 pThisCC->NVRAM.VarOpBuf.szName, pThisCC->NVRAM.VarOpBuf.fAttributes, pThisCC->NVRAM.VarOpBuf.cbValue)); 734 pEfiVar->fAttributes = pThisCC->NVRAM.VarOpBuf.fAttributes; 735 pEfiVar->cbValue = pThisCC->NVRAM.VarOpBuf.cbValue; 736 memcpy(pEfiVar->abValue, pThisCC->NVRAM.VarOpBuf.abValue, pEfiVar->cbValue); 737 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK; 682 738 } 683 739 } 684 else if (pThis ->NVRAM.VarOpBuf.cbValue == 0)740 else if (pThisCC->NVRAM.VarOpBuf.cbValue == 0) 685 741 { 686 742 /* delete operation, but nothing to delete. */ 687 743 LogFlow(("nvramWriteVariableOpAdd: Delete (not found)\n")); 688 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK;689 } 690 else if (pThis ->NVRAM.cVariables < EFI_VARIABLE_MAX)744 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK; 745 } 746 else if (pThisCC->NVRAM.cVariables < EFI_VARIABLE_MAX) 691 747 { 692 748 /* 693 749 * Add a new variable. 694 750 */ 695 LogRel(("EFI: Adding variable %RTuuid::'%s' fAttrib=%#x cbValue=%#x\n", &pThis ->NVRAM.VarOpBuf.uuid,696 pThis ->NVRAM.VarOpBuf.szName, pThis->NVRAM.VarOpBuf.fAttributes, pThis->NVRAM.VarOpBuf.cbValue));751 LogRel(("EFI: Adding variable %RTuuid::'%s' fAttrib=%#x cbValue=%#x\n", &pThisCC->NVRAM.VarOpBuf.uuid, 752 pThisCC->NVRAM.VarOpBuf.szName, pThisCC->NVRAM.VarOpBuf.fAttributes, pThisCC->NVRAM.VarOpBuf.cbValue)); 697 753 pEfiVar = (PEFIVAR)RTMemAllocZ(sizeof(EFIVAR)); 698 754 if (pEfiVar) 699 755 { 700 pEfiVar->uuid = pThis ->NVRAM.VarOpBuf.uuid;701 pEfiVar->cchName = pThis ->NVRAM.VarOpBuf.cchName;702 memcpy(pEfiVar->szName, pThis ->NVRAM.VarOpBuf.szName, pEfiVar->cchName); /* The buffer is zeroed, so skip '\0'. */703 pEfiVar->fAttributes = pThis ->NVRAM.VarOpBuf.fAttributes;704 pEfiVar->cbValue = pThis ->NVRAM.VarOpBuf.cbValue;705 memcpy(pEfiVar->abValue, pThis ->NVRAM.VarOpBuf.abValue, pEfiVar->cbValue);706 707 nvramInsertVariable(pThis , pEfiVar);708 pThis ->NVRAM.cVariables++;709 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK;756 pEfiVar->uuid = pThisCC->NVRAM.VarOpBuf.uuid; 757 pEfiVar->cchName = pThisCC->NVRAM.VarOpBuf.cchName; 758 memcpy(pEfiVar->szName, pThisCC->NVRAM.VarOpBuf.szName, pEfiVar->cchName); /* The buffer is zeroed, so skip '\0'. */ 759 pEfiVar->fAttributes = pThisCC->NVRAM.VarOpBuf.fAttributes; 760 pEfiVar->cbValue = pThisCC->NVRAM.VarOpBuf.cbValue; 761 memcpy(pEfiVar->abValue, pThisCC->NVRAM.VarOpBuf.abValue, pEfiVar->cbValue); 762 763 nvramInsertVariable(pThisCC, pEfiVar); 764 pThisCC->NVRAM.cVariables++; 765 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK; 710 766 } 711 767 else 712 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;768 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 713 769 } 714 770 else … … 717 773 * Too many variables. 718 774 */ 719 LogRelMax(5, ("EFI: Too many variables (%RTuuid::'%s' fAttrib=%#x cbValue=%#x)\n", &pThis ->NVRAM.VarOpBuf.uuid,720 pThis ->NVRAM.VarOpBuf.szName, pThis->NVRAM.VarOpBuf.fAttributes, pThis->NVRAM.VarOpBuf.cbValue));721 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;775 LogRelMax(5, ("EFI: Too many variables (%RTuuid::'%s' fAttrib=%#x cbValue=%#x)\n", &pThisCC->NVRAM.VarOpBuf.uuid, 776 pThisCC->NVRAM.VarOpBuf.szName, pThisCC->NVRAM.VarOpBuf.fAttributes, pThisCC->NVRAM.VarOpBuf.cbValue)); 777 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 722 778 Log(("nvramWriteVariableOpAdd: Too many variabled.\n")); 723 779 } … … 726 782 * Log the value of bugcheck variables. 727 783 */ 728 if ( ( pThis ->NVRAM.VarOpBuf.cbValue == 4729 || pThis ->NVRAM.VarOpBuf.cbValue == 8)730 && ( strcmp(pThis ->NVRAM.VarOpBuf.szName, "BugCheckCode") == 0731 || strcmp(pThis ->NVRAM.VarOpBuf.szName, "BugCheckParameter0") == 0732 || strcmp(pThis ->NVRAM.VarOpBuf.szName, "BugCheckParameter1") == 0733 || strcmp(pThis ->NVRAM.VarOpBuf.szName, "BugCheckParameter2") == 0734 || strcmp(pThis ->NVRAM.VarOpBuf.szName, "BugCheckParameter3") == 0735 || strcmp(pThis ->NVRAM.VarOpBuf.szName, "BugCheckProgress") == 0 ) )736 { 737 if (pThis ->NVRAM.VarOpBuf.cbValue == 4)738 LogRel(("EFI: %RTuuid::'%s' = %#010RX32\n", &pThis ->NVRAM.VarOpBuf.uuid, pThis->NVRAM.VarOpBuf.szName,739 RT_MAKE_U32_FROM_U8(pThis ->NVRAM.VarOpBuf.abValue[0], pThis->NVRAM.VarOpBuf.abValue[1],740 pThis ->NVRAM.VarOpBuf.abValue[2], pThis->NVRAM.VarOpBuf.abValue[3])));784 if ( ( pThisCC->NVRAM.VarOpBuf.cbValue == 4 785 || pThisCC->NVRAM.VarOpBuf.cbValue == 8) 786 && ( strcmp(pThisCC->NVRAM.VarOpBuf.szName, "BugCheckCode") == 0 787 || strcmp(pThisCC->NVRAM.VarOpBuf.szName, "BugCheckParameter0") == 0 788 || strcmp(pThisCC->NVRAM.VarOpBuf.szName, "BugCheckParameter1") == 0 789 || strcmp(pThisCC->NVRAM.VarOpBuf.szName, "BugCheckParameter2") == 0 790 || strcmp(pThisCC->NVRAM.VarOpBuf.szName, "BugCheckParameter3") == 0 791 || strcmp(pThisCC->NVRAM.VarOpBuf.szName, "BugCheckProgress") == 0 ) ) 792 { 793 if (pThisCC->NVRAM.VarOpBuf.cbValue == 4) 794 LogRel(("EFI: %RTuuid::'%s' = %#010RX32\n", &pThisCC->NVRAM.VarOpBuf.uuid, pThisCC->NVRAM.VarOpBuf.szName, 795 RT_MAKE_U32_FROM_U8(pThisCC->NVRAM.VarOpBuf.abValue[0], pThisCC->NVRAM.VarOpBuf.abValue[1], 796 pThisCC->NVRAM.VarOpBuf.abValue[2], pThisCC->NVRAM.VarOpBuf.abValue[3]))); 741 797 else 742 LogRel(("EFI: %RTuuid::'%s' = %#018RX64\n", &pThis ->NVRAM.VarOpBuf.uuid, pThis->NVRAM.VarOpBuf.szName,743 RT_MAKE_U64_FROM_U8(pThis ->NVRAM.VarOpBuf.abValue[0], pThis->NVRAM.VarOpBuf.abValue[1],744 pThis ->NVRAM.VarOpBuf.abValue[2], pThis->NVRAM.VarOpBuf.abValue[3],745 pThis ->NVRAM.VarOpBuf.abValue[4], pThis->NVRAM.VarOpBuf.abValue[5],746 pThis ->NVRAM.VarOpBuf.abValue[6], pThis->NVRAM.VarOpBuf.abValue[7])));747 } 748 749 750 LogFunc(("cVariables=%u u32Status=%#x\n", pThis ->NVRAM.cVariables, pThis->NVRAM.u32Status));798 LogRel(("EFI: %RTuuid::'%s' = %#018RX64\n", &pThisCC->NVRAM.VarOpBuf.uuid, pThisCC->NVRAM.VarOpBuf.szName, 799 RT_MAKE_U64_FROM_U8(pThisCC->NVRAM.VarOpBuf.abValue[0], pThisCC->NVRAM.VarOpBuf.abValue[1], 800 pThisCC->NVRAM.VarOpBuf.abValue[2], pThisCC->NVRAM.VarOpBuf.abValue[3], 801 pThisCC->NVRAM.VarOpBuf.abValue[4], pThisCC->NVRAM.VarOpBuf.abValue[5], 802 pThisCC->NVRAM.VarOpBuf.abValue[6], pThisCC->NVRAM.VarOpBuf.abValue[7]))); 803 } 804 805 806 LogFunc(("cVariables=%u u32Status=%#x\n", pThisCC->NVRAM.cVariables, pThisCC->NVRAM.u32Status)); 751 807 return VINF_SUCCESS; 752 808 } … … 756 812 * 757 813 * @returns IOM strict status code. 758 * @param pThis The EFI state.814 * @param pThisCC The EFI state for the current context. 759 815 * @param u32Value The value being written. 760 816 */ 761 static int nvramWriteVariableParam(PDEVEFI pThis, uint32_t u32Value)817 static int nvramWriteVariableParam(PDEVEFIR3 pThisCC, uint32_t u32Value) 762 818 { 763 819 int rc = VINF_SUCCESS; 764 switch (pThis ->NVRAM.enmOp)820 switch (pThisCC->NVRAM.enmOp) 765 821 { 766 822 case EFI_VM_VARIABLE_OP_START: … … 768 824 { 769 825 case EFI_VARIABLE_OP_QUERY: 770 rc = nvramWriteVariableOpQuery(pThis );826 rc = nvramWriteVariableOpQuery(pThisCC); 771 827 break; 772 828 773 829 case EFI_VARIABLE_OP_QUERY_NEXT: 774 rc = nvramWriteVariableOpQueryNext(pThis );830 rc = nvramWriteVariableOpQueryNext(pThisCC); 775 831 break; 776 832 777 833 case EFI_VARIABLE_OP_QUERY_REWIND: 778 834 Log2(("EFI_VARIABLE_OP_QUERY_REWIND\n")); 779 pThis ->NVRAM.pCurVar = NULL;780 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK;835 pThisCC->NVRAM.pCurVar = NULL; 836 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_OK; 781 837 break; 782 838 783 839 case EFI_VARIABLE_OP_ADD: 784 rc = nvramWriteVariableOpAdd(pThis );840 rc = nvramWriteVariableOpAdd(pThisCC); 785 841 break; 786 842 787 843 default: 788 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;844 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 789 845 LogRel(("EFI: Unknown EFI_VM_VARIABLE_OP_START value %#x\n", u32Value)); 790 846 break; … … 793 849 794 850 case EFI_VM_VARIABLE_OP_GUID: 795 Log2(("EFI_VM_VARIABLE_OP_GUID[%#x]=%#x\n", pThis ->NVRAM.offOpBuffer, u32Value));796 if (pThis ->NVRAM.offOpBuffer < sizeof(pThis->NVRAM.VarOpBuf.uuid))797 pThis ->NVRAM.VarOpBuf.uuid.au8[pThis->NVRAM.offOpBuffer++] = (uint8_t)u32Value;851 Log2(("EFI_VM_VARIABLE_OP_GUID[%#x]=%#x\n", pThisCC->NVRAM.offOpBuffer, u32Value)); 852 if (pThisCC->NVRAM.offOpBuffer < sizeof(pThisCC->NVRAM.VarOpBuf.uuid)) 853 pThisCC->NVRAM.VarOpBuf.uuid.au8[pThisCC->NVRAM.offOpBuffer++] = (uint8_t)u32Value; 798 854 else 799 855 { 800 856 LogRel(("EFI: Out of bounds EFI_VM_VARIABLE_OP_GUID write (%#x).\n", u32Value)); 801 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;857 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 802 858 } 803 859 break; … … 805 861 case EFI_VM_VARIABLE_OP_ATTRIBUTE: 806 862 Log2(("EFI_VM_VARIABLE_OP_ATTRIBUTE=%#x\n", u32Value)); 807 pThis ->NVRAM.VarOpBuf.fAttributes = u32Value;863 pThisCC->NVRAM.VarOpBuf.fAttributes = u32Value; 808 864 break; 809 865 810 866 case EFI_VM_VARIABLE_OP_NAME: 811 Log2(("EFI_VM_VARIABLE_OP_NAME[%#x]=%#x\n", pThis ->NVRAM.offOpBuffer, u32Value));812 if (pThis ->NVRAM.offOpBuffer < pThis->NVRAM.VarOpBuf.cchName)813 pThis ->NVRAM.VarOpBuf.szName[pThis->NVRAM.offOpBuffer++] = (uint8_t)u32Value;867 Log2(("EFI_VM_VARIABLE_OP_NAME[%#x]=%#x\n", pThisCC->NVRAM.offOpBuffer, u32Value)); 868 if (pThisCC->NVRAM.offOpBuffer < pThisCC->NVRAM.VarOpBuf.cchName) 869 pThisCC->NVRAM.VarOpBuf.szName[pThisCC->NVRAM.offOpBuffer++] = (uint8_t)u32Value; 814 870 else if (u32Value == 0) 815 Assert(pThis ->NVRAM.VarOpBuf.szName[sizeof(pThis->NVRAM.VarOpBuf.szName) - 1] == 0);871 Assert(pThisCC->NVRAM.VarOpBuf.szName[sizeof(pThisCC->NVRAM.VarOpBuf.szName) - 1] == 0); 816 872 else 817 873 { 818 874 LogRel(("EFI: Out of bounds EFI_VM_VARIABLE_OP_NAME write (%#x).\n", u32Value)); 819 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;875 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 820 876 } 821 877 break; … … 823 879 case EFI_VM_VARIABLE_OP_NAME_LENGTH: 824 880 Log2(("EFI_VM_VARIABLE_OP_NAME_LENGTH=%#x\n", u32Value)); 825 RT_ZERO(pThis ->NVRAM.VarOpBuf.szName);826 if (u32Value < sizeof(pThis ->NVRAM.VarOpBuf.szName))827 pThis ->NVRAM.VarOpBuf.cchName = u32Value;881 RT_ZERO(pThisCC->NVRAM.VarOpBuf.szName); 882 if (u32Value < sizeof(pThisCC->NVRAM.VarOpBuf.szName)) 883 pThisCC->NVRAM.VarOpBuf.cchName = u32Value; 828 884 else 829 885 { 830 886 LogRel(("EFI: Out of bounds EFI_VM_VARIABLE_OP_NAME_LENGTH write (%#x, max %#x).\n", 831 u32Value, sizeof(pThis ->NVRAM.VarOpBuf.szName) - 1));832 pThis ->NVRAM.VarOpBuf.cchName = sizeof(pThis->NVRAM.VarOpBuf.szName) - 1;833 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;887 u32Value, sizeof(pThisCC->NVRAM.VarOpBuf.szName) - 1)); 888 pThisCC->NVRAM.VarOpBuf.cchName = sizeof(pThisCC->NVRAM.VarOpBuf.szName) - 1; 889 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 834 890 } 835 Assert(pThis ->NVRAM.offOpBuffer == 0);891 Assert(pThisCC->NVRAM.offOpBuffer == 0); 836 892 break; 837 893 838 894 case EFI_VM_VARIABLE_OP_NAME_UTF16: 839 895 { 840 Log2(("EFI_VM_VARIABLE_OP_NAME_UTF16[%#x]=%#x\n", pThis ->NVRAM.offOpBuffer, u32Value));896 Log2(("EFI_VM_VARIABLE_OP_NAME_UTF16[%#x]=%#x\n", pThisCC->NVRAM.offOpBuffer, u32Value)); 841 897 /* Currently simplifying this to UCS2, i.e. no surrogates. */ 842 if (pThis ->NVRAM.offOpBuffer == 0)843 RT_ZERO(pThis ->NVRAM.VarOpBuf.szName);898 if (pThisCC->NVRAM.offOpBuffer == 0) 899 RT_ZERO(pThisCC->NVRAM.VarOpBuf.szName); 844 900 uint32_t cbUtf8 = (uint32_t)RTStrCpSize(u32Value); 845 if (pThis ->NVRAM.offOpBuffer + cbUtf8 < sizeof(pThis->NVRAM.VarOpBuf.szName))901 if (pThisCC->NVRAM.offOpBuffer + cbUtf8 < sizeof(pThisCC->NVRAM.VarOpBuf.szName)) 846 902 { 847 RTStrPutCp(&pThis ->NVRAM.VarOpBuf.szName[pThis->NVRAM.offOpBuffer], u32Value);848 pThis ->NVRAM.offOpBuffer += cbUtf8;903 RTStrPutCp(&pThisCC->NVRAM.VarOpBuf.szName[pThisCC->NVRAM.offOpBuffer], u32Value); 904 pThisCC->NVRAM.offOpBuffer += cbUtf8; 849 905 } 850 906 else if (u32Value == 0) 851 Assert(pThis ->NVRAM.VarOpBuf.szName[sizeof(pThis->NVRAM.VarOpBuf.szName) - 1] == 0);907 Assert(pThisCC->NVRAM.VarOpBuf.szName[sizeof(pThisCC->NVRAM.VarOpBuf.szName) - 1] == 0); 852 908 else 853 909 { 854 910 LogRel(("EFI: Out of bounds EFI_VM_VARIABLE_OP_NAME_UTF16 write (%#x).\n", u32Value)); 855 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;911 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 856 912 } 857 913 break; … … 859 915 860 916 case EFI_VM_VARIABLE_OP_VALUE: 861 Log2(("EFI_VM_VARIABLE_OP_VALUE[%#x]=%#x\n", pThis ->NVRAM.offOpBuffer, u32Value));862 if (pThis ->NVRAM.offOpBuffer < pThis->NVRAM.VarOpBuf.cbValue)863 pThis ->NVRAM.VarOpBuf.abValue[pThis->NVRAM.offOpBuffer++] = (uint8_t)u32Value;917 Log2(("EFI_VM_VARIABLE_OP_VALUE[%#x]=%#x\n", pThisCC->NVRAM.offOpBuffer, u32Value)); 918 if (pThisCC->NVRAM.offOpBuffer < pThisCC->NVRAM.VarOpBuf.cbValue) 919 pThisCC->NVRAM.VarOpBuf.abValue[pThisCC->NVRAM.offOpBuffer++] = (uint8_t)u32Value; 864 920 else 865 921 { 866 922 LogRel(("EFI: Out of bounds EFI_VM_VARIABLE_OP_VALUE write (%#x).\n", u32Value)); 867 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;923 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 868 924 } 869 925 break; … … 871 927 case EFI_VM_VARIABLE_OP_VALUE_LENGTH: 872 928 Log2(("EFI_VM_VARIABLE_OP_VALUE_LENGTH=%#x\n", u32Value)); 873 RT_ZERO(pThis ->NVRAM.VarOpBuf.abValue);874 if (u32Value <= sizeof(pThis ->NVRAM.VarOpBuf.abValue))875 pThis ->NVRAM.VarOpBuf.cbValue = u32Value;929 RT_ZERO(pThisCC->NVRAM.VarOpBuf.abValue); 930 if (u32Value <= sizeof(pThisCC->NVRAM.VarOpBuf.abValue)) 931 pThisCC->NVRAM.VarOpBuf.cbValue = u32Value; 876 932 else 877 933 { 878 934 LogRel(("EFI: Out of bounds EFI_VM_VARIABLE_OP_VALUE_LENGTH write (%#x, max %#x).\n", 879 u32Value, sizeof(pThis ->NVRAM.VarOpBuf.abValue)));880 pThis ->NVRAM.VarOpBuf.cbValue = sizeof(pThis->NVRAM.VarOpBuf.abValue);881 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;935 u32Value, sizeof(pThisCC->NVRAM.VarOpBuf.abValue))); 936 pThisCC->NVRAM.VarOpBuf.cbValue = sizeof(pThisCC->NVRAM.VarOpBuf.abValue); 937 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 882 938 } 883 Assert(pThis ->NVRAM.offOpBuffer == 0);939 Assert(pThisCC->NVRAM.offOpBuffer == 0); 884 940 break; 885 941 886 942 default: 887 pThis ->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR;888 LogRel(("EFI: Unexpected variable operation %#x\n", pThis ->NVRAM.enmOp));943 pThisCC->NVRAM.u32Status = EFI_VARIABLE_OP_STATUS_ERROR; 944 LogRel(("EFI: Unexpected variable operation %#x\n", pThisCC->NVRAM.enmOp)); 889 945 break; 890 946 } … … 896 952 * 897 953 * @returns IOM strict status code. 898 * @param pThis The EFI state.954 * @param pThisCC The EFI state for the current context. 899 955 * @param u32Value The value being written. 900 956 */ 901 static int nvramReadVariableOp(PDEVEFI pThis, uint32_t *pu32, unsigned cb)902 { 903 switch (pThis ->NVRAM.enmOp)957 static int nvramReadVariableOp(PDEVEFIR3 pThisCC, uint32_t *pu32, unsigned cb) 958 { 959 switch (pThisCC->NVRAM.enmOp) 904 960 { 905 961 case EFI_VM_VARIABLE_OP_START: 906 *pu32 = pThis ->NVRAM.u32Status;962 *pu32 = pThisCC->NVRAM.u32Status; 907 963 break; 908 964 909 965 case EFI_VM_VARIABLE_OP_GUID: 910 if (pThis ->NVRAM.offOpBuffer < sizeof(pThis->NVRAM.VarOpBuf.uuid) && cb == 1)911 *pu32 = pThis ->NVRAM.VarOpBuf.uuid.au8[pThis->NVRAM.offOpBuffer++];966 if (pThisCC->NVRAM.offOpBuffer < sizeof(pThisCC->NVRAM.VarOpBuf.uuid) && cb == 1) 967 *pu32 = pThisCC->NVRAM.VarOpBuf.uuid.au8[pThisCC->NVRAM.offOpBuffer++]; 912 968 else 913 969 { … … 921 977 922 978 case EFI_VM_VARIABLE_OP_ATTRIBUTE: 923 *pu32 = pThis ->NVRAM.VarOpBuf.fAttributes;979 *pu32 = pThisCC->NVRAM.VarOpBuf.fAttributes; 924 980 break; 925 981 926 982 case EFI_VM_VARIABLE_OP_NAME: 927 983 /* allow reading terminator char */ 928 if (pThis ->NVRAM.offOpBuffer <= pThis->NVRAM.VarOpBuf.cchName && cb == 1)929 *pu32 = pThis ->NVRAM.VarOpBuf.szName[pThis->NVRAM.offOpBuffer++];984 if (pThisCC->NVRAM.offOpBuffer <= pThisCC->NVRAM.VarOpBuf.cchName && cb == 1) 985 *pu32 = pThisCC->NVRAM.VarOpBuf.szName[pThisCC->NVRAM.offOpBuffer++]; 930 986 else 931 987 { … … 939 995 940 996 case EFI_VM_VARIABLE_OP_NAME_LENGTH: 941 *pu32 = pThis ->NVRAM.VarOpBuf.cchName;997 *pu32 = pThisCC->NVRAM.VarOpBuf.cchName; 942 998 break; 943 999 944 1000 case EFI_VM_VARIABLE_OP_NAME_UTF16: 945 1001 /* Lazy bird: ASSUME no surrogate pairs. */ 946 if (pThis ->NVRAM.offOpBuffer <= pThis->NVRAM.VarOpBuf.cchName && cb == 2)1002 if (pThisCC->NVRAM.offOpBuffer <= pThisCC->NVRAM.VarOpBuf.cchName && cb == 2) 947 1003 { 948 char const *psz1 = &pThis ->NVRAM.VarOpBuf.szName[pThis->NVRAM.offOpBuffer];1004 char const *psz1 = &pThisCC->NVRAM.VarOpBuf.szName[pThisCC->NVRAM.offOpBuffer]; 949 1005 char const *psz2 = psz1; 950 1006 RTUNICP Cp; 951 1007 RTStrGetCpEx(&psz2, &Cp); 952 1008 *pu32 = Cp; 953 Log2(("EFI_VM_VARIABLE_OP_NAME_UTF16[%u] => %#x (+%d)\n", pThis ->NVRAM.offOpBuffer, *pu32, psz2 - psz1));954 pThis ->NVRAM.offOpBuffer += psz2 - psz1;1009 Log2(("EFI_VM_VARIABLE_OP_NAME_UTF16[%u] => %#x (+%d)\n", pThisCC->NVRAM.offOpBuffer, *pu32, psz2 - psz1)); 1010 pThisCC->NVRAM.offOpBuffer += psz2 - psz1; 955 1011 } 956 1012 else … … 966 1022 case EFI_VM_VARIABLE_OP_NAME_LENGTH_UTF16: 967 1023 /* Lazy bird: ASSUME no surrogate pairs. */ 968 *pu32 = (uint32_t)RTStrUniLen(pThis ->NVRAM.VarOpBuf.szName);1024 *pu32 = (uint32_t)RTStrUniLen(pThisCC->NVRAM.VarOpBuf.szName); 969 1025 break; 970 1026 971 1027 case EFI_VM_VARIABLE_OP_VALUE: 972 if (pThis ->NVRAM.offOpBuffer < pThis->NVRAM.VarOpBuf.cbValue && cb == 1)973 *pu32 = pThis ->NVRAM.VarOpBuf.abValue[pThis->NVRAM.offOpBuffer++];1028 if (pThisCC->NVRAM.offOpBuffer < pThisCC->NVRAM.VarOpBuf.cbValue && cb == 1) 1029 *pu32 = pThisCC->NVRAM.VarOpBuf.abValue[pThisCC->NVRAM.offOpBuffer++]; 974 1030 else 975 1031 { … … 983 1039 984 1040 case EFI_VM_VARIABLE_OP_VALUE_LENGTH: 985 *pu32 = pThis ->NVRAM.VarOpBuf.cbValue;1041 *pu32 = pThisCC->NVRAM.VarOpBuf.cbValue; 986 1042 break; 987 1043 … … 1081 1137 { 1082 1138 RT_NOREF(pszArgs); 1083 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI);1084 PDM CritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);1085 1086 pHlp->pfnPrintf(pHlp, "NVRAM variables: %u\n", pThis ->NVRAM.cVariables);1139 PDEVEFIR3 pThisCC = PDMINS_2_DATA_CC(pDevIns, PDEVEFIR3); 1140 PDMDevHlpCritSectEnter(pDevIns, pDevIns->pCritSectRoR3, VERR_IGNORED); 1141 1142 pHlp->pfnPrintf(pHlp, "NVRAM variables: %u\n", pThisCC->NVRAM.cVariables); 1087 1143 PCEFIVAR pEfiVar; 1088 RTListForEach(&pThis ->NVRAM.VarList, pEfiVar, EFIVAR, ListNode)1144 RTListForEach(&pThisCC->NVRAM.VarList, pEfiVar, EFIVAR, ListNode) 1089 1145 { 1090 1146 /* Detect UTF-8 and UTF-16 strings. */ … … 1111 1167 } 1112 1168 1113 PDM CritSectLeave(pDevIns->pCritSectRoR3);1169 PDMDevHlpCritSectLeave(pDevIns, pDevIns->pCritSectRoR3); 1114 1170 } 1115 1171 … … 1120 1176 * 1121 1177 * @returns Size in bytes, UINT32_MAX on error. 1122 * @param pThis 1123 */ 1124 static uint32_t efiInfoSize(PDEVEFI pThis)1125 { 1126 switch (pThis ->iInfoSelector)1178 * @param pThisCC The EFI state for the current context. 1179 */ 1180 static uint32_t efiInfoSize(PDEVEFIR3 pThisCC) 1181 { 1182 switch (pThisCC->iInfoSelector) 1127 1183 { 1128 1184 case EFI_INFO_INDEX_VOLUME_BASE: … … 1137 1193 return 4; 1138 1194 case EFI_INFO_INDEX_BOOT_ARGS: 1139 return (uint32_t)RTStrNLen(pThis ->szBootArgs, sizeof(pThis->szBootArgs)) + 1;1195 return (uint32_t)RTStrNLen(pThisCC->szBootArgs, sizeof(pThisCC->szBootArgs)) + 1; 1140 1196 case EFI_INFO_INDEX_DEVICE_PROPS: 1141 return pThis ->cbDeviceProps;1197 return pThisCC->cbDeviceProps; 1142 1198 case EFI_INFO_INDEX_FSB_FREQUENCY: 1143 1199 case EFI_INFO_INDEX_CPU_FREQUENCY: … … 1155 1211 * 1156 1212 * @returns Next (current) byte. 1157 * @param pThis The EFI instance data.1213 * @param pThisCC The EFI state for the current context. 1158 1214 * @param u64 The value. 1159 1215 */ 1160 static uint8_t efiInfoNextByteU64(PDEVEFI pThis, uint64_t u64)1161 { 1162 uint64_t off = pThis ->offInfo;1216 static uint8_t efiInfoNextByteU64(PDEVEFIR3 pThisCC, uint64_t u64) 1217 { 1218 uint64_t off = pThisCC->offInfo; 1163 1219 if (off >= 8) 1164 1220 return 0; … … 1170 1226 * 1171 1227 * @returns Next (current) byte. 1172 * @param pThis The EFI instance data.1228 * @param pThisCC The EFI state for the current context. 1173 1229 * @param u32 The value. 1174 1230 */ 1175 static uint8_t efiInfoNextByteU32(PDEVEFI pThis, uint32_t u32)1176 { 1177 uint32_t off = pThis ->offInfo;1231 static uint8_t efiInfoNextByteU32(PDEVEFIR3 pThisCC, uint32_t u32) 1232 { 1233 uint32_t off = pThisCC->offInfo; 1178 1234 if (off >= 4) 1179 1235 return 0; … … 1185 1241 * 1186 1242 * @returns Next (current) byte. 1187 * @param pThis The EFI instance data.1243 * @param pThisCC The EFI state for the current context. 1188 1244 * @param pvBuf The buffer. 1189 1245 * @param cbBuf The buffer size. 1190 1246 */ 1191 static uint8_t efiInfoNextByteBuf(PDEVEFI pThis, void const *pvBuf, size_t cbBuf)1192 { 1193 uint32_t off = pThis ->offInfo;1247 static uint8_t efiInfoNextByteBuf(PDEVEFIR3 pThisCC, void const *pvBuf, size_t cbBuf) 1248 { 1249 uint32_t off = pThisCC->offInfo; 1194 1250 if (off >= cbBuf) 1195 1251 return 0; … … 1201 1257 * 1202 1258 * @returns Next (current) byte. 1203 * @param pThis The EFI instance data.1204 */ 1205 static uint8_t efiInfoNextByte(PDEVEFI pThis)1206 { 1207 switch (pThis ->iInfoSelector)1208 { 1209 1210 case EFI_INFO_INDEX_VOLUME_BASE: return efiInfoNextByteU64(pThis , pThis->GCLoadAddress);1211 case EFI_INFO_INDEX_VOLUME_SIZE: return efiInfoNextByteU64(pThis , pThis->cbEfiRom);1212 case EFI_INFO_INDEX_TEMPMEM_BASE: return efiInfoNextByteU32(pThis , VBOX_EFI_TOP_OF_STACK); /* just after stack */1213 case EFI_INFO_INDEX_TEMPMEM_SIZE: return efiInfoNextByteU32(pThis , _512K);1214 case EFI_INFO_INDEX_FSB_FREQUENCY: return efiInfoNextByteU64(pThis , pThis->u64FsbFrequency);1215 case EFI_INFO_INDEX_TSC_FREQUENCY: return efiInfoNextByteU64(pThis , pThis->u64TscFrequency);1216 case EFI_INFO_INDEX_CPU_FREQUENCY: return efiInfoNextByteU64(pThis , pThis->u64CpuFrequency);1217 case EFI_INFO_INDEX_BOOT_ARGS: return efiInfoNextByteBuf(pThis , pThis->szBootArgs, sizeof(pThis->szBootArgs));1218 case EFI_INFO_INDEX_DEVICE_PROPS: return efiInfoNextByteBuf(pThis , pThis->pbDeviceProps, pThis->cbDeviceProps);1219 case EFI_INFO_INDEX_GRAPHICS_MODE: return efiInfoNextByteU32(pThis , pThis->u32GraphicsMode);1220 case EFI_INFO_INDEX_HORIZONTAL_RESOLUTION: return efiInfoNextByteU32(pThis , pThis->u32HorizontalResolution);1221 case EFI_INFO_INDEX_VERTICAL_RESOLUTION: return efiInfoNextByteU32(pThis , pThis->u32VerticalResolution);1259 * @param pThisCC The EFI state for the current context. 1260 */ 1261 static uint8_t efiInfoNextByte(PDEVEFIR3 pThisCC) 1262 { 1263 switch (pThisCC->iInfoSelector) 1264 { 1265 1266 case EFI_INFO_INDEX_VOLUME_BASE: return efiInfoNextByteU64(pThisCC, pThisCC->GCLoadAddress); 1267 case EFI_INFO_INDEX_VOLUME_SIZE: return efiInfoNextByteU64(pThisCC, pThisCC->cbEfiRom); 1268 case EFI_INFO_INDEX_TEMPMEM_BASE: return efiInfoNextByteU32(pThisCC, VBOX_EFI_TOP_OF_STACK); /* just after stack */ 1269 case EFI_INFO_INDEX_TEMPMEM_SIZE: return efiInfoNextByteU32(pThisCC, _512K); 1270 case EFI_INFO_INDEX_FSB_FREQUENCY: return efiInfoNextByteU64(pThisCC, pThisCC->u64FsbFrequency); 1271 case EFI_INFO_INDEX_TSC_FREQUENCY: return efiInfoNextByteU64(pThisCC, pThisCC->u64TscFrequency); 1272 case EFI_INFO_INDEX_CPU_FREQUENCY: return efiInfoNextByteU64(pThisCC, pThisCC->u64CpuFrequency); 1273 case EFI_INFO_INDEX_BOOT_ARGS: return efiInfoNextByteBuf(pThisCC, pThisCC->szBootArgs, sizeof(pThisCC->szBootArgs)); 1274 case EFI_INFO_INDEX_DEVICE_PROPS: return efiInfoNextByteBuf(pThisCC, pThisCC->pbDeviceProps, pThisCC->cbDeviceProps); 1275 case EFI_INFO_INDEX_GRAPHICS_MODE: return efiInfoNextByteU32(pThisCC, pThisCC->u32GraphicsMode); 1276 case EFI_INFO_INDEX_HORIZONTAL_RESOLUTION: return efiInfoNextByteU32(pThisCC, pThisCC->u32HorizontalResolution); 1277 case EFI_INFO_INDEX_VERTICAL_RESOLUTION: return efiInfoNextByteU32(pThisCC, pThisCC->u32VerticalResolution); 1222 1278 1223 1279 /* Keep in sync with value in EfiThunk.asm */ 1224 case EFI_INFO_INDEX_STACK_BASE: return efiInfoNextByteU32(pThis , VBOX_EFI_TOP_OF_STACK - _128K); /* 2M - 128 K */1225 case EFI_INFO_INDEX_STACK_SIZE: return efiInfoNextByteU32(pThis , _128K);1226 case EFI_INFO_INDEX_MCFG_BASE: return efiInfoNextByteU64(pThis , pThis->u64McfgBase);1227 case EFI_INFO_INDEX_MCFG_SIZE: return efiInfoNextByteU64(pThis , pThis->cbMcfgLength);1280 case EFI_INFO_INDEX_STACK_BASE: return efiInfoNextByteU32(pThisCC, VBOX_EFI_TOP_OF_STACK - _128K); /* 2M - 128 K */ 1281 case EFI_INFO_INDEX_STACK_SIZE: return efiInfoNextByteU32(pThisCC, _128K); 1282 case EFI_INFO_INDEX_MCFG_BASE: return efiInfoNextByteU64(pThisCC, pThisCC->u64McfgBase); 1283 case EFI_INFO_INDEX_MCFG_SIZE: return efiInfoNextByteU64(pThisCC, pThisCC->cbMcfgLength); 1228 1284 1229 1285 default: 1230 PDMDevHlpDBGFStop(pThis ->pDevIns, RT_SRC_POS, "%#x", pThis->iInfoSelector);1286 PDMDevHlpDBGFStop(pThisCC->pDevIns, RT_SRC_POS, "%#x", pThisCC->iInfoSelector); 1231 1287 return 0; 1232 1288 } … … 1260 1316 * @returns VBox status suitable for I/O port write handler. 1261 1317 * 1262 * @param pThis The EFI state.1318 * @param pThisCC The EFI state for the current context. 1263 1319 * @param u32 The value being written. 1264 1320 * @param cb The size of the value. 1265 1321 */ 1266 static int efiPortImageEventWrite(PDEVEFI pThis, uint32_t u32, unsigned cb)1322 static int efiPortImageEventWrite(PDEVEFIR3 pThisCC, uint32_t u32, unsigned cb) 1267 1323 { 1268 1324 RT_NOREF(cb); … … 1278 1334 1279 1335 /* Reset the state. */ 1280 RT_ZERO(pThis ->ImageEvt);1281 pThis ->ImageEvt.uEvt = (uint8_t)u32; Assert(pThis->ImageEvt.uEvt == u32);1336 RT_ZERO(pThisCC->ImageEvt); 1337 pThisCC->ImageEvt.uEvt = (uint8_t)u32; Assert(pThisCC->ImageEvt.uEvt == u32); 1282 1338 return VINF_SUCCESS; 1283 1339 … … 1292 1348 { 1293 1349 s_cImageEvtLogged++; 1294 switch (pThis ->ImageEvt.uEvt)1350 switch (pThisCC->ImageEvt.uEvt) 1295 1351 { 1296 1352 /* ASSUMES the name ends with .pdb and the image file ends with .efi! */ 1297 1353 case EFI_IMAGE_EVT_CMD_START_LOAD32: 1298 1354 LogRel(("EFI: VBoxDbg> loadimage32 '%.*s.efi' %#llx LB %#llx\n", 1299 pThis ->ImageEvt.offName - 4, pThis->ImageEvt.szName, pThis->ImageEvt.uAddr0, pThis->ImageEvt.cb0));1300 if (pThis ->ImageEvt.offName > 4)1355 pThisCC->ImageEvt.offName - 4, pThisCC->ImageEvt.szName, pThisCC->ImageEvt.uAddr0, pThisCC->ImageEvt.cb0)); 1356 if (pThisCC->ImageEvt.offName > 4) 1301 1357 efiVBoxDbgScript("loadimage32 '%.*s.efi' %#llx\n", 1302 pThis ->ImageEvt.offName - 4, pThis->ImageEvt.szName, pThis->ImageEvt.uAddr0);1358 pThisCC->ImageEvt.offName - 4, pThisCC->ImageEvt.szName, pThisCC->ImageEvt.uAddr0); 1303 1359 break; 1304 1360 case EFI_IMAGE_EVT_CMD_START_LOAD64: 1305 1361 LogRel(("EFI: VBoxDbg> loadimage64 '%.*s.efi' %#llx LB %#llx\n", 1306 pThis ->ImageEvt.offName - 4, pThis->ImageEvt.szName, pThis->ImageEvt.uAddr0, pThis->ImageEvt.cb0));1307 if (pThis ->ImageEvt.offName > 4)1362 pThisCC->ImageEvt.offName - 4, pThisCC->ImageEvt.szName, pThisCC->ImageEvt.uAddr0, pThisCC->ImageEvt.cb0)); 1363 if (pThisCC->ImageEvt.offName > 4) 1308 1364 efiVBoxDbgScript("loadimage64 '%.*s.efi' %#llx\n", 1309 pThis ->ImageEvt.offName - 4, pThis->ImageEvt.szName, pThis->ImageEvt.uAddr0);1365 pThisCC->ImageEvt.offName - 4, pThisCC->ImageEvt.szName, pThisCC->ImageEvt.uAddr0); 1310 1366 break; 1311 1367 case EFI_IMAGE_EVT_CMD_START_UNLOAD32: … … 1313 1369 { 1314 1370 LogRel(("EFI: VBoxDbg> unload '%.*s.efi' # %#llx LB %#llx\n", 1315 pThis ->ImageEvt.offName - 4 - pThis->ImageEvt.offNameLastComponent,1316 &pThis ->ImageEvt.szName[pThis->ImageEvt.offNameLastComponent],1317 pThis ->ImageEvt.uAddr0, pThis->ImageEvt.cb0));1318 if (pThis ->ImageEvt.offName > 4)1371 pThisCC->ImageEvt.offName - 4 - pThisCC->ImageEvt.offNameLastComponent, 1372 &pThisCC->ImageEvt.szName[pThisCC->ImageEvt.offNameLastComponent], 1373 pThisCC->ImageEvt.uAddr0, pThisCC->ImageEvt.cb0)); 1374 if (pThisCC->ImageEvt.offName > 4) 1319 1375 efiVBoxDbgScript("unload '%.*s.efi'\n", 1320 pThis ->ImageEvt.offName - 4 - pThis->ImageEvt.offNameLastComponent,1321 &pThis ->ImageEvt.szName[pThis->ImageEvt.offNameLastComponent]);1376 pThisCC->ImageEvt.offName - 4 - pThisCC->ImageEvt.offNameLastComponent, 1377 &pThisCC->ImageEvt.szName[pThisCC->ImageEvt.offNameLastComponent]); 1322 1378 break; 1323 1379 } … … 1326 1382 { 1327 1383 LogRel(("EFI: relocate module to %#llx from %#llx\n", 1328 pThis ->ImageEvt.uAddr0, pThis->ImageEvt.uAddr1));1384 pThisCC->ImageEvt.uAddr0, pThisCC->ImageEvt.uAddr1)); 1329 1385 break; 1330 1386 } … … 1339 1395 case EFI_IMAGE_EVT_CMD_ADDR0: 1340 1396 AssertBreak(EFI_IMAGE_EVT_GET_PAYLOAD(u32) <= UINT16_MAX); 1341 pThis ->ImageEvt.uAddr0 <<= 16;1342 pThis ->ImageEvt.uAddr0 |= EFI_IMAGE_EVT_GET_PAYLOAD_U16(u32);1397 pThisCC->ImageEvt.uAddr0 <<= 16; 1398 pThisCC->ImageEvt.uAddr0 |= EFI_IMAGE_EVT_GET_PAYLOAD_U16(u32); 1343 1399 return VINF_SUCCESS; 1344 1400 1345 1401 case EFI_IMAGE_EVT_CMD_ADDR1: 1346 1402 AssertBreak(EFI_IMAGE_EVT_GET_PAYLOAD(u32) <= UINT16_MAX); 1347 pThis ->ImageEvt.uAddr1 <<= 16;1348 pThis ->ImageEvt.uAddr1 |= EFI_IMAGE_EVT_GET_PAYLOAD_U16(u32);1403 pThisCC->ImageEvt.uAddr1 <<= 16; 1404 pThisCC->ImageEvt.uAddr1 |= EFI_IMAGE_EVT_GET_PAYLOAD_U16(u32); 1349 1405 return VINF_SUCCESS; 1350 1406 1351 1407 case EFI_IMAGE_EVT_CMD_SIZE0: 1352 1408 AssertBreak(EFI_IMAGE_EVT_GET_PAYLOAD(u32) <= UINT16_MAX); 1353 pThis ->ImageEvt.cb0 <<= 16;1354 pThis ->ImageEvt.cb0 |= EFI_IMAGE_EVT_GET_PAYLOAD_U16(u32);1409 pThisCC->ImageEvt.cb0 <<= 16; 1410 pThisCC->ImageEvt.cb0 |= EFI_IMAGE_EVT_GET_PAYLOAD_U16(u32); 1355 1411 return VINF_SUCCESS; 1356 1412 1357 1413 case EFI_IMAGE_EVT_CMD_NAME: 1358 1414 AssertBreak(EFI_IMAGE_EVT_GET_PAYLOAD(u32) <= 0x7f); 1359 if (pThis ->ImageEvt.offName < sizeof(pThis->ImageEvt.szName) - 1)1415 if (pThisCC->ImageEvt.offName < sizeof(pThisCC->ImageEvt.szName) - 1) 1360 1416 { 1361 1417 char ch = EFI_IMAGE_EVT_GET_PAYLOAD_U8(u32); 1362 1418 if (ch == '\\') 1363 1419 ch = '/'; 1364 pThis ->ImageEvt.szName[pThis->ImageEvt.offName++] = ch;1420 pThisCC->ImageEvt.szName[pThisCC->ImageEvt.offName++] = ch; 1365 1421 if (ch == '/' || ch == ':') 1366 pThis ->ImageEvt.offNameLastComponent = pThis->ImageEvt.offName;1422 pThisCC->ImageEvt.offNameLastComponent = pThisCC->ImageEvt.offName; 1367 1423 } 1368 1424 else … … 1390 1446 { 1391 1447 RT_NOREF(pvUser); 1392 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI);1448 PDEVEFIR3 pThisCC = PDMINS_2_DATA_CC(pDevIns, PDEVEFIR3); 1393 1449 Log4(("EFI in: %x %x\n", Port, cb)); 1394 1450 … … 1396 1452 { 1397 1453 case EFI_INFO_PORT: 1398 if (pThis ->offInfo == -1 && cb == 4)1454 if (pThisCC->offInfo == -1 && cb == 4) 1399 1455 { 1400 pThis ->offInfo = 0;1401 uint32_t cbInfo = *pu32 = efiInfoSize(pThis );1456 pThisCC->offInfo = 0; 1457 uint32_t cbInfo = *pu32 = efiInfoSize(pThisCC); 1402 1458 if (cbInfo == UINT32_MAX) 1403 1459 return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "iInfoSelector=%#x (%d)\n", 1404 pThis ->iInfoSelector, pThis->iInfoSelector);1460 pThisCC->iInfoSelector, pThisCC->iInfoSelector); 1405 1461 } 1406 1462 else … … 1408 1464 if (cb != 1) 1409 1465 return VERR_IOM_IOPORT_UNUSED; 1410 *pu32 = efiInfoNextByte(pThis );1411 pThis ->offInfo++;1466 *pu32 = efiInfoNextByte(pThisCC); 1467 pThisCC->offInfo++; 1412 1468 } 1413 1469 return VINF_SUCCESS; … … 1424 1480 1425 1481 case EFI_PORT_VARIABLE_OP: 1426 return nvramReadVariableOp(pThis , pu32, cb);1482 return nvramReadVariableOp(pThisCC, pu32, cb); 1427 1483 1428 1484 case EFI_PORT_VARIABLE_PARAM: … … 1476 1532 { 1477 1533 RT_NOREF(pvUser); 1478 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI);1534 PDEVEFIR3 pThisCC = PDMINS_2_DATA_CC(pDevIns, PDEVEFIR3); 1479 1535 int rc = VINF_SUCCESS; 1480 1536 Log4(("efi: out %x %x %d\n", Port, u32, cb)); … … 1484 1540 case EFI_INFO_PORT: 1485 1541 Log2(("EFI_INFO_PORT: iInfoSelector=%#x\n", u32)); 1486 pThis ->iInfoSelector = u32;1487 pThis ->offInfo = -1;1542 pThisCC->iInfoSelector = u32; 1543 pThisCC->offInfo = -1; 1488 1544 break; 1489 1545 … … 1501 1557 if (u32 == '\n' || u32 == '\r') 1502 1558 { 1503 Assert(pThis ->iMsg < sizeof(pThis->szMsg));1504 pThis ->szMsg[pThis->iMsg] = '\0';1505 if (pThis ->iMsg)1506 LogRel2(("efi: %s\n", pThis ->szMsg));1507 pThis ->iMsg = 0;1559 Assert(pThisCC->iMsg < sizeof(pThisCC->szMsg)); 1560 pThisCC->szMsg[pThisCC->iMsg] = '\0'; 1561 if (pThisCC->iMsg) 1562 LogRel2(("efi: %s\n", pThisCC->szMsg)); 1563 pThisCC->iMsg = 0; 1508 1564 } 1509 1565 else 1510 1566 { 1511 if (pThis ->iMsg >= sizeof(pThis->szMsg) - 1)1567 if (pThisCC->iMsg >= sizeof(pThisCC->szMsg) - 1) 1512 1568 { 1513 pThis ->szMsg[pThis->iMsg] = '\0';1514 LogRel2(("efi: %s\n", pThis ->szMsg));1515 pThis ->iMsg = 0;1569 pThisCC->szMsg[pThisCC->iMsg] = '\0'; 1570 LogRel2(("efi: %s\n", pThisCC->szMsg)); 1571 pThisCC->iMsg = 0; 1516 1572 } 1517 pThis ->szMsg[pThis->iMsg] = (char)u32;1518 pThis ->szMsg[++pThis->iMsg] = '\0';1573 pThisCC->szMsg[pThisCC->iMsg] = (char)u32; 1574 pThisCC->szMsg[++pThisCC->iMsg] = '\0'; 1519 1575 } 1520 1576 break; … … 1541 1597 case EFI_PANIC_CMD_START_MSG: 1542 1598 LogRel(("Receiving EFI panic...\n")); 1543 pThis ->iPanicMsg = 0;1544 pThis ->szPanicMsg[0] = '\0';1599 pThisCC->iPanicMsg = 0; 1600 pThisCC->szPanicMsg[0] = '\0'; 1545 1601 break; 1546 1602 1547 1603 case EFI_PANIC_CMD_END_MSG: 1548 1604 #ifdef IN_RING3 1549 LogRel(("EFI: Panic! %s\n", pThis ->szPanicMsg));1605 LogRel(("EFI: Panic! %s\n", pThisCC->szPanicMsg)); 1550 1606 # ifdef VBOX_STRICT 1551 return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "EFI Panic: %s\n", pThis ->szPanicMsg);1607 return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "EFI Panic: %s\n", pThisCC->szPanicMsg); 1552 1608 # else 1553 1609 return VERR_INTERNAL_ERROR; … … 1563 1619 { 1564 1620 /* Add the message char to the buffer. */ 1565 uint32_t i = pThis ->iPanicMsg;1566 if (i + 1 < sizeof(pThis ->szPanicMsg))1621 uint32_t i = pThisCC->iPanicMsg; 1622 if (i + 1 < sizeof(pThisCC->szPanicMsg)) 1567 1623 { 1568 1624 char ch = EFI_PANIC_CMD_MSG_GET_CHAR(u32); 1569 1625 if ( ch == '\n' 1570 1626 && i > 0 1571 && pThis ->szPanicMsg[i - 1] == '\r')1627 && pThisCC->szPanicMsg[i - 1] == '\r') 1572 1628 i--; 1573 pThis ->szPanicMsg[i] = ch;1574 pThis ->szPanicMsg[i + 1] = '\0';1575 pThis ->iPanicMsg = i + 1;1629 pThisCC->szPanicMsg[i] = ch; 1630 pThisCC->szPanicMsg[i + 1] = '\0'; 1631 pThisCC->iPanicMsg = i + 1; 1576 1632 } 1577 1633 } … … 1591 1647 u32 = EFI_VM_VARIABLE_OP_ERROR; 1592 1648 } 1593 pThis ->NVRAM.offOpBuffer = 0;1594 pThis ->NVRAM.enmOp = (EFIVAROP)u32;1649 pThisCC->NVRAM.offOpBuffer = 0; 1650 pThisCC->NVRAM.enmOp = (EFIVAROP)u32; 1595 1651 Log2(("EFI_VARIABLE_OP: enmOp=%#x (%d)\n", u32, u32)); 1596 1652 break; … … 1598 1654 1599 1655 case EFI_PORT_VARIABLE_PARAM: 1600 rc = nvramWriteVariableParam(pThis , u32);1656 rc = nvramWriteVariableParam(pThisCC, u32); 1601 1657 break; 1602 1658 … … 1617 1673 1618 1674 case EFI_PORT_IMAGE_EVENT: 1619 rc = efiPortImageEventWrite(pThis , u32, cb);1675 rc = efiPortImageEventWrite(pThisCC, u32, cb); 1620 1676 break; 1621 1677 … … 1627 1683 } 1628 1684 1629 1630 #ifdef IN_RING3 /* for now */ 1631 /** @callback_method_impl{FNIOMMIWRITE, Flash memory write} */ 1632 PDMBOTHCBDECL(int) efiR3NvMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb) 1685 #endif /* IN_RING3 */ 1686 1687 1688 /** 1689 * @callback_method_impl{FNIOMMMIONEWWRITE, Flash memory write} 1690 */ 1691 static DECLCALLBACK(VBOXSTRICTRC) efiR3NvMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void const *pv, unsigned cb) 1633 1692 { 1634 1693 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 1635 RT_NOREF1(pvUser); 1636 1637 return flashWrite(&pThis->Flash, GCPhysAddr - pThis->GCPhysNvram, pv, cb); 1638 } 1639 1640 1641 /** @callback_method_impl{FNIOMMIOREAD, Flash memory read} */ 1642 PDMBOTHCBDECL(int) efiR3NvMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb) 1694 RT_NOREF(pvUser); 1695 1696 return flashWrite(&pThis->Flash, off, pv, cb); 1697 } 1698 1699 1700 /** 1701 * @callback_method_impl{FNIOMMMIONEWREAD, Flash memory read} 1702 */ 1703 static DECLCALLBACK(VBOXSTRICTRC) efiR3NvMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS off, void *pv, unsigned cb) 1643 1704 { 1644 1705 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 1645 RT_NOREF 1(pvUser);1646 1647 return flashRead(&pThis->Flash, GCPhysAddr - pThis->GCPhysNvram, pv, cb);1648 } 1649 #endif /* IN_RING3 for now */ 1650 1706 RT_NOREF(pvUser); 1707 1708 return flashRead(&pThis->Flash, off, pv, cb); 1709 } 1710 1711 #ifdef IN_RING3 1651 1712 1652 1713 static DECLCALLBACK(int) efiSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) … … 1655 1716 LogFlow(("efiSaveExec:\n")); 1656 1717 1657 return flashR3S smSaveExec(&pThis->Flash, pSSM);1718 return flashR3SaveExec(&pThis->Flash, pDevIns, pSSM); 1658 1719 } 1659 1720 1660 1721 static DECLCALLBACK(int) efiLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 1661 1722 { 1662 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 1723 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 1724 PDEVEFIR3 pThisCC = PDMINS_2_DATA_CC(pDevIns, PDEVEFIR3); 1725 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1663 1726 LogFlow(("efiLoadExec: uVersion=%d uPass=%d\n", uVersion, uPass)); 1664 1727 … … 1676 1739 int rc; 1677 1740 if (uVersion > EFI_SSM_VERSION_PRE_PROPER_NVRAM) 1678 rc = flashR3 SsmLoadExec(&pThis->Flash, pSSM);1741 rc = flashR3LoadExec(&pThis->Flash, pDevIns, pSSM); 1679 1742 else 1680 1743 { … … 1682 1745 * Kill the current variables before loading anything. 1683 1746 */ 1684 nvramFlushDeviceVariableList(pThis );1747 nvramFlushDeviceVariableList(pThisCC); 1685 1748 1686 1749 /* 1687 1750 * Load the NVRAM state. 1688 1751 */ 1689 rc = SSMR3GetStructEx(pSSM, &pThis->NVRAM, sizeof(NVRAMDESC), 0, g_aEfiNvramDescField, NULL);1752 rc = pHlp->pfnSSMGetStructEx(pSSM, &pThisCC->NVRAM, sizeof(NVRAMDESC), 0, g_aEfiNvramDescField, NULL); 1690 1753 AssertRCReturn(rc, rc); 1691 pThis ->NVRAM.pCurVar = NULL;1692 1693 rc = SSMR3GetStructEx(pSSM, &pThis->NVRAM.VarOpBuf, sizeof(EFIVAR), 0, g_aEfiVariableDescFields, NULL);1754 pThisCC->NVRAM.pCurVar = NULL; 1755 1756 rc = pHlp->pfnSSMGetStructEx(pSSM, &pThisCC->NVRAM.VarOpBuf, sizeof(EFIVAR), 0, g_aEfiVariableDescFields, NULL); 1694 1757 AssertRCReturn(rc, rc); 1695 1758 … … 1697 1760 * Load variables. 1698 1761 */ 1699 pThis ->NVRAM.pCurVar = NULL;1700 Assert(RTListIsEmpty(&pThis ->NVRAM.VarList));1701 RTListInit(&pThis ->NVRAM.VarList);1702 for (uint32_t i = 0; i < pThis ->NVRAM.cVariables; i++)1762 pThisCC->NVRAM.pCurVar = NULL; 1763 Assert(RTListIsEmpty(&pThisCC->NVRAM.VarList)); 1764 RTListInit(&pThisCC->NVRAM.VarList); 1765 for (uint32_t i = 0; i < pThisCC->NVRAM.cVariables; i++) 1703 1766 { 1704 1767 PEFIVAR pEfiVar = (PEFIVAR)RTMemAllocZ(sizeof(EFIVAR)); 1705 1768 AssertReturn(pEfiVar, VERR_NO_MEMORY); 1706 1769 1707 rc = SSMR3GetStructEx(pSSM, pEfiVar, sizeof(EFIVAR), 0, g_aEfiVariableDescFields, NULL);1770 rc = pHlp->pfnSSMGetStructEx(pSSM, pEfiVar, sizeof(EFIVAR), 0, g_aEfiVariableDescFields, NULL); 1708 1771 if (RT_SUCCESS(rc)) 1709 1772 { … … 1733 1796 updating the current variable pointer while we're here. */ 1734 1797 #if 1 1735 RTListAppend(&pThis ->NVRAM.VarList, &pEfiVar->ListNode);1798 RTListAppend(&pThisCC->NVRAM.VarList, &pEfiVar->ListNode); 1736 1799 #else 1737 nvramInsertVariable(pThis , pEfiVar);1800 nvramInsertVariable(pThisCC, pEfiVar); 1738 1801 #endif 1739 if (pThis ->NVRAM.idUniqueCurVar == pEfiVar->idUniqueSavedState)1740 pThis ->NVRAM.pCurVar = pEfiVar;1802 if (pThisCC->NVRAM.idUniqueCurVar == pEfiVar->idUniqueSavedState) 1803 pThisCC->NVRAM.pCurVar = pEfiVar; 1741 1804 } 1742 1805 } … … 1752 1815 { 1753 1816 LogFlowFunc(("ENTER: pIBase=%p pszIID=%p\n", pInterface, pszIID)); 1754 PDEVEFI pThis = RT_FROM_MEMBER(pInterface, DEVEFI, Lun0.IBase);1755 1756 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis ->Lun0.IBase);1817 PDEVEFIR3 pThisCC = RT_FROM_MEMBER(pInterface, DEVEFIR3, Lun0.IBase); 1818 1819 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThisCC->Lun0.IBase); 1757 1820 return NULL; 1758 1821 } … … 1780 1843 static DECLCALLBACK(int) efiInitComplete(PPDMDEVINS pDevIns) 1781 1844 { 1782 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI);1845 PDEVEFIR3 pThisCC = PDMINS_2_DATA_CC(pDevIns, PDEVEFIR3); 1783 1846 1784 1847 PVM pVM = PDMDevHlpGetVM(pDevIns); … … 1814 1877 * Number of CPUs. 1815 1878 */ 1816 cmosWrite(pDevIns, 0x60, pThis ->cCpus & 0xff);1879 cmosWrite(pDevIns, 0x60, pThisCC->cCpus & 0xff); 1817 1880 1818 1881 return VINF_SUCCESS; … … 1826 1889 { 1827 1890 RT_NOREF(enmCtx); 1828 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI);1891 PDEVEFIR3 pThisCC = PDMINS_2_DATA_CC(pDevIns, PDEVEFIR3); 1829 1892 1830 1893 /* 1831 1894 * Re-shadow the Firmware Volume and make it RAM/RAM. 1832 1895 */ 1833 uint32_t cPages = RT_ALIGN_64(pThis ->cbEfiRom, PAGE_SIZE) >> PAGE_SHIFT;1834 RTGCPHYS GCPhys = pThis ->GCLoadAddress;1896 uint32_t cPages = RT_ALIGN_64(pThisCC->cbEfiRom, PAGE_SIZE) >> PAGE_SHIFT; 1897 RTGCPHYS GCPhys = pThisCC->GCLoadAddress; 1835 1898 while (cPages > 0) 1836 1899 { … … 1865 1928 static DECLCALLBACK(void) efiReset(PPDMDEVINS pDevIns) 1866 1929 { 1867 PDEVEFI pThis= PDMINS_2_DATA(pDevIns, PDEVEFI);1868 1930 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 1931 PDEVEFIR3 pThisCC = PDMINS_2_DATA_CC(pDevIns, PDEVEFIR3); 1869 1932 LogFlow(("efiReset\n")); 1870 1933 1871 pThis ->iInfoSelector = 0;1872 pThis ->offInfo = -1;1873 1874 pThis ->iMsg = 0;1875 pThis ->szMsg[0] = '\0';1876 pThis ->iPanicMsg = 0;1877 pThis ->szPanicMsg[0] = '\0';1934 pThisCC->iInfoSelector = 0; 1935 pThisCC->offInfo = -1; 1936 1937 pThisCC->iMsg = 0; 1938 pThisCC->szMsg[0] = '\0'; 1939 pThisCC->iPanicMsg = 0; 1940 pThisCC->szPanicMsg[0] = '\0'; 1878 1941 1879 1942 flashR3Reset(&pThis->Flash); … … 1893 1956 static DECLCALLBACK(void) efiPowerOff(PPDMDEVINS pDevIns) 1894 1957 { 1895 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI);1896 1897 if (pThis ->Lun0.pNvramDrv)1898 nvramStore(pThis );1958 PDEVEFIR3 pThisCC = PDMINS_2_DATA_CC(pDevIns, PDEVEFIR3); 1959 1960 if (pThisCC->Lun0.pNvramDrv) 1961 nvramStore(pThisCC); 1899 1962 } 1900 1963 … … 1911 1974 static DECLCALLBACK(int) efiDestruct(PPDMDEVINS pDevIns) 1912 1975 { 1913 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI);1914 1976 PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns); 1915 1916 nvramFlushDeviceVariableList(pThis); 1917 1918 if ( !pThis->fNvramStateSaved 1919 && pThis->pszNvramFile) 1920 { 1921 int rc = flashR3SaveToFile(&pThis->Flash, pThis->pszNvramFile); 1977 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 1978 PDEVEFIR3 pThisCC = PDMINS_2_DATA_CC(pDevIns, PDEVEFIR3); 1979 1980 nvramFlushDeviceVariableList(pThisCC); 1981 1982 if ( !pThisCC->fNvramStateSaved 1983 && pThisCC->pszNvramFile) 1984 { 1985 int rc = flashR3SaveToFile(&pThis->Flash, pDevIns, pThisCC->pszNvramFile); 1922 1986 if (RT_FAILURE(rc)) 1923 LogRel(("EFI: Failed to save flash file to '%s' -> %Rrc\n", pThis ->pszNvramFile, rc));1924 } 1925 1926 flashR3Destruct(&pThis->Flash );1927 1928 if (pThis ->pszNvramFile)1929 { 1930 PDMDevHlpMMHeapFree(pDevIns, pThis ->pszNvramFile);1931 pThis ->pszNvramFile = NULL;1932 } 1933 1934 if (pThis ->pu8EfiRomFree)1935 { 1936 RTFileReadAllFree(pThis ->pu8EfiRomFree, (size_t)pThis->cbEfiRom + pThis->offEfiRom);1937 pThis ->pu8EfiRomFree = NULL;1987 LogRel(("EFI: Failed to save flash file to '%s' -> %Rrc\n", pThisCC->pszNvramFile, rc)); 1988 } 1989 1990 flashR3Destruct(&pThis->Flash, pDevIns); 1991 1992 if (pThisCC->pszNvramFile) 1993 { 1994 PDMDevHlpMMHeapFree(pDevIns, pThisCC->pszNvramFile); 1995 pThisCC->pszNvramFile = NULL; 1996 } 1997 1998 if (pThisCC->pu8EfiRomFree) 1999 { 2000 RTFileReadAllFree(pThisCC->pu8EfiRomFree, (size_t)pThisCC->cbEfiRom + pThisCC->offEfiRom); 2001 pThisCC->pu8EfiRomFree = NULL; 1938 2002 } 1939 2003 … … 1941 2005 * Free MM heap pointers (waste of time, but whatever). 1942 2006 */ 1943 if (pThis ->pszEfiRomFile)1944 { 1945 MMR3HeapFree(pThis->pszEfiRomFile);1946 pThis ->pszEfiRomFile = NULL;1947 } 1948 1949 if (pThis ->pu8EfiThunk)1950 { 1951 MMR3HeapFree(pThis->pu8EfiThunk);1952 pThis ->pu8EfiThunk = NULL;1953 } 1954 1955 if (pThis ->pbDeviceProps)1956 { 1957 PDMDevHlpMMHeapFree(pDevIns, pThis ->pbDeviceProps);1958 pThis ->pbDeviceProps = NULL;1959 pThis ->cbDeviceProps = 0;2007 if (pThisCC->pszEfiRomFile) 2008 { 2009 PDMDevHlpMMHeapFree(pDevIns, pThisCC->pszEfiRomFile); 2010 pThisCC->pszEfiRomFile = NULL; 2011 } 2012 2013 if (pThisCC->pu8EfiThunk) 2014 { 2015 PDMDevHlpMMHeapFree(pDevIns, pThisCC->pu8EfiThunk); 2016 pThisCC->pu8EfiThunk = NULL; 2017 } 2018 2019 if (pThisCC->pbDeviceProps) 2020 { 2021 PDMDevHlpMMHeapFree(pDevIns, pThisCC->pbDeviceProps); 2022 pThisCC->pbDeviceProps = NULL; 2023 pThisCC->cbDeviceProps = 0; 1960 2024 } 1961 2025 … … 1999 2063 * 2000 2064 * @returns VBox status code. 2001 * @param pThis The device instance data. 2002 */ 2003 static int efiParseFirmware(PDEVEFI pThis) 2004 { 2005 EFI_FIRMWARE_VOLUME_HEADER const *pFwVolHdr = (EFI_FIRMWARE_VOLUME_HEADER const *)pThis->pu8EfiRom; 2065 * @param pDevIns The device instance. 2066 * @param pThis The shared device state. 2067 * @param pThisCC The device state for the current context. 2068 */ 2069 static int efiParseFirmware(PPDMDEVINS pDevIns, PDEVEFI pThis, PDEVEFIR3 pThisCC) 2070 { 2071 EFI_FIRMWARE_VOLUME_HEADER const *pFwVolHdr = (EFI_FIRMWARE_VOLUME_HEADER const *)pThisCC->pu8EfiRom; 2006 2072 2007 2073 /* … … 2015 2081 VERR_VERSION_MISMATCH); 2016 2082 /** @todo check checksum, see PE spec vol. 3 */ 2017 AssertLogRelMsgReturn(pFwVolHdr->FvLength <= pThis ->cbEfiRom,2018 ("%#llx, expected %#llx\n", pFwVolHdr->FvLength, pThis ->cbEfiRom),2083 AssertLogRelMsgReturn(pFwVolHdr->FvLength <= pThisCC->cbEfiRom, 2084 ("%#llx, expected %#llx\n", pFwVolHdr->FvLength, pThisCC->cbEfiRom), 2019 2085 VERR_INVALID_PARAMETER); 2020 2086 AssertLogRelMsgReturn( pFwVolHdr->BlockMap[0].Length > 0 … … 2023 2089 VERR_INVALID_PARAMETER); 2024 2090 2025 AssertLogRelMsgReturn(!(pThis ->cbEfiRom & PAGE_OFFSET_MASK), ("%RX64\n", pThis->cbEfiRom), VERR_INVALID_PARAMETER);2091 AssertLogRelMsgReturn(!(pThisCC->cbEfiRom & PAGE_OFFSET_MASK), ("%RX64\n", pThisCC->cbEfiRom), VERR_INVALID_PARAMETER); 2026 2092 2027 2093 LogRel(("Found EFI FW Volume, %u bytes (%u %u-byte blocks)\n", pFwVolHdr->FvLength, pFwVolHdr->BlockMap[0].NumBlocks, pFwVolHdr->BlockMap[0].Length)); … … 2033 2099 2034 2100 /* Found NVRAM storage, configure flash device. */ 2035 pThis ->offEfiRom = pFwVolHdr->FvLength;2036 pThis ->cbNvram = pFwVolHdr->FvLength;2037 pThis ->GCPhysNvram = UINT32_C(0xfffff000) - pThis->cbEfiRom + PAGE_SIZE;2038 pThis ->cbEfiRom -= pThis->cbNvram;2039 2040 int rc = flashR3Init(&pThis->Flash, pThis ->pDevIns, 0xA289 /*Intel*/, pThis->cbNvram, pFwVolHdr->BlockMap[0].Length);2101 pThisCC->offEfiRom = pFwVolHdr->FvLength; 2102 pThisCC->cbNvram = pFwVolHdr->FvLength; 2103 pThisCC->GCPhysNvram = UINT32_C(0xfffff000) - pThisCC->cbEfiRom + PAGE_SIZE; 2104 pThisCC->cbEfiRom -= pThisCC->cbNvram; 2105 2106 int rc = flashR3Init(&pThis->Flash, pThisCC->pDevIns, 0xA289 /*Intel*/, pThisCC->cbNvram, pFwVolHdr->BlockMap[0].Length); 2041 2107 if (RT_FAILURE(rc)) 2042 2108 return rc; 2043 2109 2044 2110 /* If the file does not exist we initialize the NVRAM from the loaded ROM file. */ 2045 if (!pThis ->pszNvramFile || !RTPathExists(pThis->pszNvramFile))2046 rc = flashR3LoadFromBuf(&pThis->Flash, pThis ->pu8EfiRom, pThis->cbNvram);2111 if (!pThisCC->pszNvramFile || !RTPathExists(pThisCC->pszNvramFile)) 2112 rc = flashR3LoadFromBuf(&pThis->Flash, pThisCC->pu8EfiRom, pThisCC->cbNvram); 2047 2113 else 2048 rc = flashR3LoadFromFile(&pThis->Flash, p This->pszNvramFile);2114 rc = flashR3LoadFromFile(&pThis->Flash, pDevIns, pThisCC->pszNvramFile); 2049 2115 if (RT_FAILURE(rc)) 2050 2116 return rc; 2051 2117 2052 pThis ->GCLoadAddress = pThis->GCPhysNvram + pThis->cbNvram;2118 pThisCC->GCLoadAddress = pThisCC->GCPhysNvram + pThisCC->cbNvram; 2053 2119 2054 2120 return VINF_SUCCESS; … … 2059 2125 * 2060 2126 * @returns VBox status code. 2061 * @param pThis The device instance data. 2127 * @param pDevIns The device instance. 2128 * @param pThis The shared Efi state. 2129 * @param pThisCC The device state for the current context. 2062 2130 * @param pCfg Configuration node handle for the device. 2063 2131 */ 2064 static int efiLoadRom(P DEVEFI pThis, PCFGMNODE pCfg)2132 static int efiLoadRom(PPDMDEVINS pDevIns, PDEVEFI pThis, PDEVEFIR3 pThisCC, PCFGMNODE pCfg) 2065 2133 { 2066 2134 RT_NOREF(pCfg); … … 2071 2139 int rc; 2072 2140 #ifdef VBOX_WITH_EFI_IN_DD2 2073 if (RTStrCmp(pThis ->pszEfiRomFile, g_szEfiBuiltin32) == 0)2074 { 2075 pThis ->pu8EfiRomFree = NULL;2076 pThis ->pu8EfiRom = g_abEfiFirmware32;2077 pThis ->cbEfiRom = g_cbEfiFirmware32;2078 } 2079 else if (RTStrCmp(pThis ->pszEfiRomFile, g_szEfiBuiltin64) == 0)2080 { 2081 pThis ->pu8EfiRomFree = NULL;2082 pThis ->pu8EfiRom = g_abEfiFirmware64;2083 pThis ->cbEfiRom = g_cbEfiFirmware64;2141 if (RTStrCmp(pThisCC->pszEfiRomFile, g_szEfiBuiltin32) == 0) 2142 { 2143 pThisCC->pu8EfiRomFree = NULL; 2144 pThisCC->pu8EfiRom = g_abEfiFirmware32; 2145 pThisCC->cbEfiRom = g_cbEfiFirmware32; 2146 } 2147 else if (RTStrCmp(pThisCC->pszEfiRomFile, g_szEfiBuiltin64) == 0) 2148 { 2149 pThisCC->pu8EfiRomFree = NULL; 2150 pThisCC->pu8EfiRom = g_abEfiFirmware64; 2151 pThisCC->cbEfiRom = g_cbEfiFirmware64; 2084 2152 } 2085 2153 else … … 2088 2156 void *pvFile; 2089 2157 size_t cbFile; 2090 rc = RTFileReadAllEx(pThis ->pszEfiRomFile,2158 rc = RTFileReadAllEx(pThisCC->pszEfiRomFile, 2091 2159 0 /*off*/, 2092 2160 RTFOFF_MAX /*cbMax*/, … … 2095 2163 &cbFile); 2096 2164 if (RT_FAILURE(rc)) 2097 return PDMDevHlpVMSetError(p This->pDevIns, rc, RT_SRC_POS,2165 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 2098 2166 N_("Loading the EFI firmware volume '%s' failed with rc=%Rrc"), 2099 pThis ->pszEfiRomFile, rc);2100 pThis ->pu8EfiRomFree = (uint8_t *)pvFile;2101 pThis ->pu8EfiRom = (uint8_t *)pvFile;2102 pThis ->cbEfiRom = cbFile;2167 pThisCC->pszEfiRomFile, rc); 2168 pThisCC->pu8EfiRomFree = (uint8_t *)pvFile; 2169 pThisCC->pu8EfiRom = (uint8_t *)pvFile; 2170 pThisCC->cbEfiRom = cbFile; 2103 2171 } 2104 2172 … … 2106 2174 * Validate firmware volume and figure out the load address as well as the SEC entry point. 2107 2175 */ 2108 rc = efiParseFirmware(p This);2176 rc = efiParseFirmware(pDevIns, pThis, pThisCC); 2109 2177 if (RT_FAILURE(rc)) 2110 return PDMDevHlpVMSetError(p This->pDevIns, rc, RT_SRC_POS,2178 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 2111 2179 N_("Parsing the EFI firmware volume '%s' failed with rc=%Rrc"), 2112 pThis ->pszEfiRomFile, rc);2180 pThisCC->pszEfiRomFile, rc); 2113 2181 2114 2182 /* … … 2131 2199 "EFI Firmware Volume (Part 13)", "EFI Firmware Volume (Part 14)", "EFI Firmware Volume (Part 15)", "EFI Firmware Volume (Part 16)", 2132 2200 }; 2133 AssertLogRelMsgReturn(pThis ->cbEfiRom < RT_ELEMENTS(s_apszNames) * _512K,2201 AssertLogRelMsgReturn(pThisCC->cbEfiRom < RT_ELEMENTS(s_apszNames) * _512K, 2134 2202 ("EFI firmware image too big: %#RX64, max %#zx\n", 2135 pThis ->cbEfiRom, RT_ELEMENTS(s_apszNames) * _512K),2203 pThisCC->cbEfiRom, RT_ELEMENTS(s_apszNames) * _512K), 2136 2204 VERR_IMAGE_TOO_BIG); 2137 2205 2138 uint32_t const cbChunk = pThis ->cbNvram + pThis->cbEfiRom >= _2M ? _512K2139 : (uint32_t)RT_ALIGN_64((pThis ->cbNvram + pThis->cbEfiRom) / 4, PAGE_SIZE);2140 uint32_t cbLeft = pThis ->cbEfiRom; /* ASSUMES NVRAM comes first! */2141 uint32_t off = pThis ->offEfiRom + cbLeft; /* ASSUMES NVRAM comes first! */2142 RTGCPHYS64 GCPhys = pThis ->GCLoadAddress + cbLeft;2206 uint32_t const cbChunk = pThisCC->cbNvram + pThisCC->cbEfiRom >= _2M ? _512K 2207 : (uint32_t)RT_ALIGN_64((pThisCC->cbNvram + pThisCC->cbEfiRom) / 4, PAGE_SIZE); 2208 uint32_t cbLeft = pThisCC->cbEfiRom; /* ASSUMES NVRAM comes first! */ 2209 uint32_t off = pThisCC->offEfiRom + cbLeft; /* ASSUMES NVRAM comes first! */ 2210 RTGCPHYS64 GCPhys = pThisCC->GCLoadAddress + cbLeft; 2143 2211 AssertLogRelMsg(GCPhys == _4G, ("%RGp\n", GCPhys)); 2144 2212 … … 2152 2220 GCPhys -= cb; 2153 2221 off -= cb; 2154 rc = PDMDevHlpROMRegister(p This->pDevIns, GCPhys, cb, pThis->pu8EfiRom + off, cb,2222 rc = PDMDevHlpROMRegister(pDevIns, GCPhys, cb, pThisCC->pu8EfiRom + off, cb, 2155 2223 PGMPHYS_ROM_FLAGS_SHADOWED | PGMPHYS_ROM_FLAGS_PERMANENT_BINARY, s_apszNames[i]); 2156 2224 AssertRCReturn(rc, rc); … … 2168 2236 off -= cb; 2169 2237 /** @todo Add flag to prevent saved state loading from bitching about these regions. */ 2170 rc = PDMDevHlpROMRegister(p This->pDevIns, GCPhys, cb, pThis->pu8EfiRom + off, cb,2238 rc = PDMDevHlpROMRegister(pDevIns, GCPhys, cb, pThisCC->pu8EfiRom + off, cb, 2171 2239 PGMPHYS_ROM_FLAGS_SHADOWED | PGMPHYS_ROM_FLAGS_PERMANENT_BINARY 2172 2240 | PGMPHYS_ROM_FLAGS_MAYBE_MISSING_FROM_STATE, s_apszNames[i]); … … 2177 2245 2178 2246 /* Not sure what the purpose of this one is... */ 2179 rc = PDMDevHlpROMProtectShadow(p This->pDevIns, pThis->GCLoadAddress, (uint32_t)cbChunk, PGMROMPROT_READ_RAM_WRITE_IGNORE);2247 rc = PDMDevHlpROMProtectShadow(pDevIns, pThisCC->GCLoadAddress, (uint32_t)cbChunk, PGMROMPROT_READ_RAM_WRITE_IGNORE); 2180 2248 AssertRCReturn(rc, rc); 2181 2249 2182 2250 #else 2183 RTGCPHYS cbQuart = RT_ALIGN_64(pThis ->cbEfiRom / 4, PAGE_SIZE);2184 rc = PDMDevHlpROMRegister(p This->pDevIns,2185 pThis ->GCLoadAddress,2251 RTGCPHYS cbQuart = RT_ALIGN_64(pThisCC->cbEfiRom / 4, PAGE_SIZE); 2252 rc = PDMDevHlpROMRegister(pDevIns, 2253 pThisCC->GCLoadAddress, 2186 2254 cbQuart, 2187 pThis ->pu8EfiRom + pThis->uEfiRomOfs,2255 pThisCC->pu8EfiRom + pThisCC->uEfiRomOfs, 2188 2256 cbQuart, 2189 2257 PGMPHYS_ROM_FLAGS_SHADOWED | PGMPHYS_ROM_FLAGS_PERMANENT_BINARY, 2190 2258 "EFI Firmware Volume"); 2191 2259 AssertRCReturn(rc, rc); 2192 rc = PDMDevHlpROMProtectShadow(p This->pDevIns, pThis->GCLoadAddress, (uint32_t)cbQuart, PGMROMPROT_READ_RAM_WRITE_IGNORE);2260 rc = PDMDevHlpROMProtectShadow(pDevIns, pThisCC->GCLoadAddress, (uint32_t)cbQuart, PGMROMPROT_READ_RAM_WRITE_IGNORE); 2193 2261 AssertRCReturn(rc, rc); 2194 rc = PDMDevHlpROMRegister(p This->pDevIns,2195 pThis ->GCLoadAddress + cbQuart,2262 rc = PDMDevHlpROMRegister(pDevIns, 2263 pThisCC->GCLoadAddress + cbQuart, 2196 2264 cbQuart, 2197 pThis ->pu8EfiRom + pThis->uEfiRomOfs + cbQuart,2265 pThisCC->pu8EfiRom + pThisCC->uEfiRomOfs + cbQuart, 2198 2266 cbQuart, 2199 2267 PGMPHYS_ROM_FLAGS_SHADOWED | PGMPHYS_ROM_FLAGS_PERMANENT_BINARY, … … 2201 2269 if (RT_FAILURE(rc)) 2202 2270 return rc; 2203 rc = PDMDevHlpROMRegister(p This->pDevIns,2204 pThis ->GCLoadAddress + cbQuart * 2,2271 rc = PDMDevHlpROMRegister(pDevIns, 2272 pThisCC->GCLoadAddress + cbQuart * 2, 2205 2273 cbQuart, 2206 pThis ->pu8EfiRom + pThis->uEfiRomOfs + cbQuart * 2,2274 pThisCC->pu8EfiRom + pThisCC->uEfiRomOfs + cbQuart * 2, 2207 2275 cbQuart, 2208 2276 PGMPHYS_ROM_FLAGS_SHADOWED | PGMPHYS_ROM_FLAGS_PERMANENT_BINARY, … … 2210 2278 if (RT_FAILURE(rc)) 2211 2279 return rc; 2212 rc = PDMDevHlpROMRegister(p This->pDevIns,2213 pThis ->GCLoadAddress + cbQuart * 3,2214 pThis ->cbEfiRom - cbQuart * 3,2215 pThis ->pu8EfiRom + pThis->uEfiRomOfs + cbQuart * 3,2216 pThis ->cbEfiRom - cbQuart * 3,2280 rc = PDMDevHlpROMRegister(pDevIns, 2281 pThisCC->GCLoadAddress + cbQuart * 3, 2282 pThisCC->cbEfiRom - cbQuart * 3, 2283 pThisCC->pu8EfiRom + pThisCC->uEfiRomOfs + cbQuart * 3, 2284 pThisCC->cbEfiRom - cbQuart * 3, 2217 2285 PGMPHYS_ROM_FLAGS_SHADOWED | PGMPHYS_ROM_FLAGS_PERMANENT_BINARY, 2218 2286 "EFI Firmware Volume (Part 4)"); … … 2224 2292 * Register MMIO region for flash device. 2225 2293 */ 2226 rc = PDMDevHlpMMIORegister(pThis->pDevIns, pThis->GCPhysNvram, pThis->cbNvram, NULL /*pvUser*/, 2227 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU, 2228 efiR3NvMmioWrite, efiR3NvMmioRead, 2229 "Flash Memory"); 2294 rc = PDMDevHlpMmioCreateEx(pDevIns, pThisCC->cbNvram, IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU, 2295 NULL /*pPciDev*/, UINT32_MAX, efiR3NvMmioWrite, efiR3NvMmioRead, NULL, NULL /*pvUser*/, 2296 "Flash Memory", &pThis->hMmioFlash); 2230 2297 AssertRCReturn(rc, rc); 2231 LogRel(("EFI: Registered %uKB flash at %RGp\n", pThis->cbNvram / _1K, pThis->GCPhysNvram)); 2232 2298 rc = PDMDevHlpMmioMap(pDevIns, pThis->hMmioFlash, pThisCC->GCPhysNvram); 2299 AssertRCReturn(rc, rc); 2300 2301 LogRel(("EFI: Registered %uKB flash at %RGp\n", pThisCC->cbNvram / _1K, pThisCC->GCPhysNvram)); 2233 2302 return VINF_SUCCESS; 2234 2303 } … … 2248 2317 2249 2318 return val; 2250 2251 2319 } 2252 2320 … … 2254 2322 /** 2255 2323 * Converts a hex string into a binary data blob located at 2256 * pThis ->pbDeviceProps, size returned as pThis->cbDeviceProps.2324 * pThisCC->pbDeviceProps, size returned as pThisCC->cbDeviceProps. 2257 2325 * 2258 2326 * @returns VERR_NO_MEMORY or VINF_SUCCESS. 2259 * @param pThis The EFI instance data.2327 * @param pThisCC The device state for the current context. 2260 2328 * @param pszDeviceProps The device property hex string to decode. 2261 2329 */ 2262 static int efiParseDeviceString(PDEVEFI pThis, const char *pszDeviceProps)2330 static int efiParseDeviceString(PDEVEFIR3 pThisCC, const char *pszDeviceProps) 2263 2331 { 2264 2332 uint32_t const cbOut = (uint32_t)RTStrNLen(pszDeviceProps, RTSTR_MAX) / 2 + 1; 2265 pThis ->pbDeviceProps = (uint8_t *)PDMDevHlpMMHeapAlloc(pThis->pDevIns, cbOut);2266 if (!pThis ->pbDeviceProps)2333 pThisCC->pbDeviceProps = (uint8_t *)PDMDevHlpMMHeapAlloc(pThisCC->pDevIns, cbOut); 2334 if (!pThisCC->pbDeviceProps) 2267 2335 return VERR_NO_MEMORY; 2268 2336 … … 2279 2347 u8Value = u8Hb << 4; 2280 2348 else 2281 pThis ->pbDeviceProps[iHex++] = u8Hb | u8Value;2349 pThisCC->pbDeviceProps[iHex++] = u8Hb | u8Value; 2282 2350 2283 2351 Assert(iHex < cbOut); … … 2286 2354 2287 2355 Assert(iHex == 0 || fUpper); 2288 pThis ->cbDeviceProps = iHex;2356 pThisCC->cbDeviceProps = iHex; 2289 2357 2290 2358 return VINF_SUCCESS; … … 2297 2365 static DECLCALLBACK(int) efiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 2298 2366 { 2367 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 2368 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 2369 PDEVEFIR3 pThisCC = PDMINS_2_DATA_CC(pDevIns, PDEVEFIR3); 2370 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 2371 int rc; 2372 2299 2373 RT_NOREF(iInstance); 2300 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);2301 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI);2302 int rc;2303 2304 2374 Assert(iInstance == 0); 2305 2375 … … 2307 2377 * Initalize the basic variables so that the destructor always works. 2308 2378 */ 2309 pThis->pDevIns = pDevIns; 2310 RTListInit(&pThis->NVRAM.VarList); 2311 pThis->Lun0.IBase.pfnQueryInterface = devEfiQueryInterface; 2312 2379 pThisCC->pDevIns = pDevIns; 2380 RTListInit(&pThisCC->NVRAM.VarList); 2381 pThisCC->Lun0.IBase.pfnQueryInterface = devEfiQueryInterface; 2313 2382 2314 2383 /* 2315 2384 * Validate and read the configuration. 2316 2385 */ 2317 if (!CFGMR3AreValuesValid(pCfg, 2318 "EfiRom\0" 2319 "NumCPUs\0" 2320 "McfgBase\0" 2321 "McfgLength\0" 2322 "UUID\0" 2323 "IOAPIC\0" 2324 "APIC\0" 2325 "DmiBIOSFirmwareMajor\0" 2326 "DmiBIOSFirmwareMinor\0" 2327 "DmiBIOSReleaseDate\0" 2328 "DmiBIOSReleaseMajor\0" 2329 "DmiBIOSReleaseMinor\0" 2330 "DmiBIOSVendor\0" 2331 "DmiBIOSVersion\0" 2332 "DmiSystemFamily\0" 2333 "DmiSystemProduct\0" 2334 "DmiSystemSerial\0" 2335 "DmiSystemSKU\0" 2336 "DmiSystemUuid\0" 2337 "DmiSystemVendor\0" 2338 "DmiSystemVersion\0" 2339 "DmiBoardAssetTag\0" 2340 "DmiBoardBoardType\0" 2341 "DmiBoardLocInChass\0" 2342 "DmiBoardProduct\0" 2343 "DmiBoardSerial\0" 2344 "DmiBoardVendor\0" 2345 "DmiBoardVersion\0" 2346 "DmiChassisAssetTag\0" 2347 "DmiChassisSerial\0" 2348 "DmiChassisType\0" 2349 "DmiChassisVendor\0" 2350 "DmiChassisVersion\0" 2351 "DmiProcManufacturer\0" 2352 "DmiProcVersion\0" 2353 "DmiOEMVBoxVer\0" 2354 "DmiOEMVBoxRev\0" 2355 "DmiUseHostInfo\0" 2356 "DmiExposeMemoryTable\0" 2357 "DmiExposeProcInf\0" 2358 "64BitEntry\0" 2359 "BootArgs\0" 2360 "DeviceProps\0" 2361 "GopMode\0" // legacy 2362 "GraphicsMode\0" 2363 "UgaHorizontalResolution\0" // legacy 2364 "UgaVerticalResolution\0" // legacy 2365 "GraphicsResolution\0" 2366 "NvramFile\0")) 2367 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, 2368 N_("Configuration error: Invalid config value(s) for the EFI device")); 2386 PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, 2387 "EfiRom|" 2388 "NumCPUs|" 2389 "McfgBase|" 2390 "McfgLength|" 2391 "UUID|" 2392 "IOAPIC|" 2393 "APIC|" 2394 "DmiBIOSFirmwareMajor|" 2395 "DmiBIOSFirmwareMinor|" 2396 "DmiBIOSReleaseDate|" 2397 "DmiBIOSReleaseMajor|" 2398 "DmiBIOSReleaseMinor|" 2399 "DmiBIOSVendor|" 2400 "DmiBIOSVersion|" 2401 "DmiSystemFamily|" 2402 "DmiSystemProduct|" 2403 "DmiSystemSerial|" 2404 "DmiSystemSKU|" 2405 "DmiSystemUuid|" 2406 "DmiSystemVendor|" 2407 "DmiSystemVersion|" 2408 "DmiBoardAssetTag|" 2409 "DmiBoardBoardType|" 2410 "DmiBoardLocInChass|" 2411 "DmiBoardProduct|" 2412 "DmiBoardSerial|" 2413 "DmiBoardVendor|" 2414 "DmiBoardVersion|" 2415 "DmiChassisAssetTag|" 2416 "DmiChassisSerial|" 2417 "DmiChassisType|" 2418 "DmiChassisVendor|" 2419 "DmiChassisVersion|" 2420 "DmiProcManufacturer|" 2421 "DmiProcVersion|" 2422 "DmiOEMVBoxVer|" 2423 "DmiOEMVBoxRev|" 2424 "DmiUseHostInfo|" 2425 "DmiExposeMemoryTable|" 2426 "DmiExposeProcInf|" 2427 "64BitEntry|" 2428 "BootArgs|" 2429 "DeviceProps|" 2430 "GopMode|" // legacy 2431 "GraphicsMode|" 2432 "UgaHorizontalResolution|" // legacy 2433 "UgaVerticalResolution|" // legacy 2434 "GraphicsResolution|" 2435 "NvramFile", ""); 2369 2436 2370 2437 /* CPU count (optional). */ 2371 rc = CFGMR3QueryU32Def(pCfg, "NumCPUs", &pThis->cCpus, 1);2438 rc = pHlp->pfnCFGMQueryU32Def(pCfg, "NumCPUs", &pThisCC->cCpus, 1); 2372 2439 AssertLogRelRCReturn(rc, rc); 2373 2440 2374 rc = CFGMR3QueryU64Def(pCfg, "McfgBase", &pThis->u64McfgBase, 0);2441 rc = pHlp->pfnCFGMQueryU64Def(pCfg, "McfgBase", &pThisCC->u64McfgBase, 0); 2375 2442 if (RT_FAILURE(rc)) 2376 2443 return PDMDEV_SET_ERROR(pDevIns, rc, 2377 2444 N_("Configuration error: Querying \"\" as integer failed")); 2378 rc = CFGMR3QueryU64Def(pCfg, "McfgLength", &pThis->cbMcfgLength, 0);2445 rc = pHlp->pfnCFGMQueryU64Def(pCfg, "McfgLength", &pThisCC->cbMcfgLength, 0); 2379 2446 if (RT_FAILURE(rc)) 2380 2447 return PDMDEV_SET_ERROR(pDevIns, rc, 2381 2448 N_("Configuration error: Querying \"McfgLength\" as integer failed")); 2382 2449 2383 rc = CFGMR3QueryU8Def(pCfg, "IOAPIC", &pThis->u8IOAPIC, 1);2450 rc = pHlp->pfnCFGMQueryU8Def(pCfg, "IOAPIC", &pThisCC->u8IOAPIC, 1); 2384 2451 if (RT_FAILURE (rc)) 2385 2452 return PDMDEV_SET_ERROR(pDevIns, rc, 2386 2453 N_("Configuration error: Failed to read \"IOAPIC\"")); 2387 2454 2388 rc = CFGMR3QueryU8Def(pCfg, "APIC", &pThis->u8APIC, 1);2455 rc = pHlp->pfnCFGMQueryU8Def(pCfg, "APIC", &pThisCC->u8APIC, 1); 2389 2456 if (RT_FAILURE (rc)) 2390 2457 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2395 2462 */ 2396 2463 RTUUID uuid; 2397 rc = CFGMR3QueryBytes(pCfg, "UUID", &uuid, sizeof(uuid));2464 rc = pHlp->pfnCFGMQueryBytes(pCfg, "UUID", &uuid, sizeof(uuid)); 2398 2465 if (RT_FAILURE(rc)) 2399 2466 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2407 2474 uuid.Gen.u16TimeMid = RT_H2BE_U16(uuid.Gen.u16TimeMid); 2408 2475 uuid.Gen.u16TimeHiAndVersion = RT_H2BE_U16(uuid.Gen.u16TimeHiAndVersion); 2409 memcpy(&pThis ->aUuid, &uuid, sizeof pThis->aUuid);2476 memcpy(&pThisCC->aUuid, &uuid, sizeof pThisCC->aUuid); 2410 2477 2411 2478 /* … … 2413 2480 */ 2414 2481 #ifdef VBOX_WITH_EFI_IN_DD2 2415 rc = CFGMR3QueryStringAllocDef(pCfg, "EfiRom", &pThis->pszEfiRomFile, g_szEfiBuiltin32);2482 rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "EfiRom", &pThisCC->pszEfiRomFile, g_szEfiBuiltin32); 2416 2483 if (RT_FAILURE(rc)) 2417 2484 #else 2418 rc = CFGMR3QueryStringAlloc(pCfg, "EfiRom", &pThis->pszEfiRomFile);2485 rc = pHlp->pfnCFGMQueryStringAlloc(pCfg, "EfiRom", &pThisCC->pszEfiRomFile); 2419 2486 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 2420 2487 { 2421 pThis ->pszEfiRomFile = (char *)PDMDevHlpMMHeapAlloc(pDevIns, RTPATH_MAX);2422 AssertReturn(pThis ->pszEfiRomFile, VERR_NO_MEMORY);2423 rc = RTPathAppPrivateArchTop(pThis ->pszEfiRomFile, RTPATH_MAX);2488 pThisCC->pszEfiRomFile = (char *)PDMDevHlpMMHeapAlloc(pDevIns, RTPATH_MAX); 2489 AssertReturn(pThisCC->pszEfiRomFile, VERR_NO_MEMORY); 2490 rc = RTPathAppPrivateArchTop(pThisCC->pszEfiRomFile, RTPATH_MAX); 2424 2491 AssertRCReturn(rc, rc); 2425 rc = RTPathAppend(pThis ->pszEfiRomFile, RTPATH_MAX, "VBoxEFI32.fd");2492 rc = RTPathAppend(pThisCC->pszEfiRomFile, RTPATH_MAX, "VBoxEFI32.fd"); 2426 2493 AssertRCReturn(rc, rc); 2427 2494 } … … 2434 2501 * NVRAM processing. 2435 2502 */ 2436 rc = PDMDevHlpSSMRegister(pDevIns, EFI_SSM_VERSION, sizeof(*pThis ), efiSaveExec, efiLoadExec);2503 rc = PDMDevHlpSSMRegister(pDevIns, EFI_SSM_VERSION, sizeof(*pThisCC), efiSaveExec, efiLoadExec); 2437 2504 AssertRCReturn(rc, rc); 2438 2505 2439 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis ->Lun0.IBase, &pThis->Lun0.pDrvBase, "NvramStorage");2506 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThisCC->Lun0.IBase, &pThisCC->Lun0.pDrvBase, "NvramStorage"); 2440 2507 if (RT_SUCCESS(rc)) 2441 2508 { 2442 pThis ->Lun0.pNvramDrv = PDMIBASE_QUERY_INTERFACE(pThis->Lun0.pDrvBase, PDMINVRAMCONNECTOR);2443 AssertPtrReturn(pThis ->Lun0.pNvramDrv, VERR_PDM_MISSING_INTERFACE_BELOW);2444 2445 rc = nvramLoad(pThis );2509 pThisCC->Lun0.pNvramDrv = PDMIBASE_QUERY_INTERFACE(pThisCC->Lun0.pDrvBase, PDMINVRAMCONNECTOR); 2510 AssertPtrReturn(pThisCC->Lun0.pNvramDrv, VERR_PDM_MISSING_INTERFACE_BELOW); 2511 2512 rc = nvramLoad(pThisCC); 2446 2513 AssertRCReturn(rc, rc); 2447 2514 } 2448 2515 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 2449 2516 { 2450 pThis ->Lun0.pNvramDrv = NULL;2517 pThisCC->Lun0.pNvramDrv = NULL; 2451 2518 rc = VINF_SUCCESS; /* Missing driver is no error condition. */ 2452 2519 } … … 2457 2524 * Get boot args. 2458 2525 */ 2459 rc = CFGMR3QueryStringDef(pCfg, "BootArgs", pThis->szBootArgs, sizeof(pThis->szBootArgs), "");2526 rc = pHlp->pfnCFGMQueryStringDef(pCfg, "BootArgs", pThisCC->szBootArgs, sizeof(pThisCC->szBootArgs), ""); 2460 2527 if (RT_FAILURE(rc)) 2461 2528 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 2462 2529 N_("Configuration error: Querying \"BootArgs\" as a string failed")); 2463 2530 2464 //strcpy(pThis ->szBootArgs, "-v keepsyms=1 io=0xf debug=0x2a");2465 //strcpy(pThis ->szBootArgs, "-v keepsyms=1 debug=0x2a");2466 LogRel(("EFI: boot args = %s\n", pThis ->szBootArgs));2531 //strcpy(pThisCC->szBootArgs, "-v keepsyms=1 io=0xf debug=0x2a"); 2532 //strcpy(pThisCC->szBootArgs, "-v keepsyms=1 debug=0x2a"); 2533 LogRel(("EFI: boot args = %s\n", pThisCC->szBootArgs)); 2467 2534 2468 2535 /* … … 2470 2537 */ 2471 2538 char *pszDeviceProps; 2472 rc = CFGMR3QueryStringAllocDef(pCfg, "DeviceProps", &pszDeviceProps, NULL);2539 rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "DeviceProps", &pszDeviceProps, NULL); 2473 2540 if (RT_FAILURE(rc)) 2474 2541 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, … … 2477 2544 { 2478 2545 LogRel(("EFI: device props = %s\n", pszDeviceProps)); 2479 rc = efiParseDeviceString(pThis , pszDeviceProps);2480 MMR3HeapFree(pszDeviceProps);2546 rc = efiParseDeviceString(pThisCC, pszDeviceProps); 2547 PDMDevHlpMMHeapFree(pDevIns, pszDeviceProps); 2481 2548 if (RT_FAILURE(rc)) 2482 2549 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, … … 2485 2552 else 2486 2553 { 2487 pThis ->pbDeviceProps = NULL;2488 pThis ->cbDeviceProps = 0;2554 pThisCC->pbDeviceProps = NULL; 2555 pThisCC->cbDeviceProps = 0; 2489 2556 } 2490 2557 … … 2492 2559 * CPU frequencies. 2493 2560 */ 2494 pThis ->u64TscFrequency = TMCpuTicksPerSecond(PDMDevHlpGetVM(pDevIns));2495 pThis ->u64CpuFrequency = pThis->u64TscFrequency;2496 pThis ->u64FsbFrequency = CPUMGetGuestScalableBusFrequency(PDMDevHlpGetVM(pDevIns));2561 pThisCC->u64TscFrequency = TMCpuTicksPerSecond(PDMDevHlpGetVM(pDevIns)); 2562 pThisCC->u64CpuFrequency = pThisCC->u64TscFrequency; 2563 pThisCC->u64FsbFrequency = CPUMGetGuestScalableBusFrequency(PDMDevHlpGetVM(pDevIns)); 2497 2564 2498 2565 /* … … 2500 2567 * old EFI VGA code the only way to select the GOP mode). 2501 2568 */ 2502 rc = CFGMR3QueryU32Def(pCfg, "GraphicsMode", &pThis->u32GraphicsMode, UINT32_MAX);2569 rc = pHlp->pfnCFGMQueryU32Def(pCfg, "GraphicsMode", &pThisCC->u32GraphicsMode, UINT32_MAX); 2503 2570 if (RT_FAILURE(rc)) 2504 2571 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 2505 2572 N_("Configuration error: Querying \"GraphicsMode\" as a 32-bit int failed")); 2506 if (pThis ->u32GraphicsMode == UINT32_MAX)2573 if (pThisCC->u32GraphicsMode == UINT32_MAX) 2507 2574 { 2508 2575 /* get the legacy value if nothing else was specified */ 2509 rc = CFGMR3QueryU32Def(pCfg, "GopMode", &pThis->u32GraphicsMode, UINT32_MAX);2576 rc = pHlp->pfnCFGMQueryU32Def(pCfg, "GopMode", &pThisCC->u32GraphicsMode, UINT32_MAX); 2510 2577 if (RT_FAILURE(rc)) 2511 2578 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, 2512 2579 N_("Configuration error: Querying \"GopMode\" as a 32-bit int failed")); 2513 2580 } 2514 if (pThis ->u32GraphicsMode == UINT32_MAX)2515 pThis ->u32GraphicsMode = 2; /* 1024x768, at least typically */2581 if (pThisCC->u32GraphicsMode == UINT32_MAX) 2582 pThisCC->u32GraphicsMode = 2; /* 1024x768, at least typically */ 2516 2583 2517 2584 /* … … 2520 2587 */ 2521 2588 char szResolution[16]; 2522 rc = CFGMR3QueryStringDef(pCfg, "GraphicsResolution", szResolution, sizeof(szResolution), "");2589 rc = pHlp->pfnCFGMQueryStringDef(pCfg, "GraphicsResolution", szResolution, sizeof(szResolution), ""); 2523 2590 if (RT_FAILURE(rc)) 2524 2591 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, … … 2529 2596 if (pszX) 2530 2597 { 2531 pThis ->u32HorizontalResolution = RTStrToUInt32(szResolution);2532 pThis ->u32VerticalResolution = RTStrToUInt32(pszX + 1);2598 pThisCC->u32HorizontalResolution = RTStrToUInt32(szResolution); 2599 pThisCC->u32VerticalResolution = RTStrToUInt32(pszX + 1); 2533 2600 } 2534 2601 } … … 2536 2603 { 2537 2604 /* get the legacy values if nothing else was specified */ 2538 rc = CFGMR3QueryU32Def(pCfg, "UgaHorizontalResolution", &pThis->u32HorizontalResolution, 0);2605 rc = pHlp->pfnCFGMQueryU32Def(pCfg, "UgaHorizontalResolution", &pThisCC->u32HorizontalResolution, 0); 2539 2606 AssertRCReturn(rc, rc); 2540 rc = CFGMR3QueryU32Def(pCfg, "UgaVerticalResolution", &pThis->u32VerticalResolution, 0);2607 rc = pHlp->pfnCFGMQueryU32Def(pCfg, "UgaVerticalResolution", &pThisCC->u32VerticalResolution, 0); 2541 2608 AssertRCReturn(rc, rc); 2542 2609 } 2543 if (pThis ->u32HorizontalResolution == 0 || pThis->u32VerticalResolution == 0)2544 { 2545 pThis ->u32HorizontalResolution = 1024;2546 pThis ->u32VerticalResolution = 768;2547 } 2548 2549 pThis ->pszNvramFile = NULL;2550 rc = CFGMR3QueryStringAlloc(pCfg, "NvramFile", &pThis->pszNvramFile);2610 if (pThisCC->u32HorizontalResolution == 0 || pThisCC->u32VerticalResolution == 0) 2611 { 2612 pThisCC->u32HorizontalResolution = 1024; 2613 pThisCC->u32VerticalResolution = 768; 2614 } 2615 2616 pThisCC->pszNvramFile = NULL; 2617 rc = pHlp->pfnCFGMQueryStringAlloc(pCfg, "NvramFile", &pThisCC->pszNvramFile); 2551 2618 if (RT_FAILURE(rc) && rc != VERR_CFGM_VALUE_NOT_FOUND) 2552 2619 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2556 2623 * Load firmware volume and thunk ROM. 2557 2624 */ 2558 rc = efiLoadRom(p This, pCfg);2625 rc = efiLoadRom(pDevIns, pThis, pThisCC, pCfg); 2559 2626 if (RT_FAILURE(rc)) 2560 2627 return rc; … … 2572 2639 * Plant DMI and MPS tables in the ROM region. 2573 2640 */ 2574 rc = FwCommonPlantDMITable(pDevIns, pThis ->au8DMIPage, VBOX_DMI_TABLE_SIZE, &pThis->aUuid,2575 pDevIns->pCfg, pThis ->cCpus, &pThis->cbDmiTables, &pThis->cNumDmiTables);2641 rc = FwCommonPlantDMITable(pDevIns, pThisCC->au8DMIPage, VBOX_DMI_TABLE_SIZE, &pThisCC->aUuid, 2642 pDevIns->pCfg, pThisCC->cCpus, &pThisCC->cbDmiTables, &pThisCC->cNumDmiTables); 2576 2643 AssertRCReturn(rc, rc); 2577 2644 … … 2580 2647 * the SMBIOS header. The header must be placed in a range that EFI will scan. 2581 2648 */ 2582 FwCommonPlantSmbiosAndDmiHdrs(pDevIns, pThis ->au8DMIPage + VBOX_DMI_TABLE_SIZE,2583 pThis ->cbDmiTables, pThis->cNumDmiTables);2584 2585 if (pThis ->u8IOAPIC)2649 FwCommonPlantSmbiosAndDmiHdrs(pDevIns, pThisCC->au8DMIPage + VBOX_DMI_TABLE_SIZE, 2650 pThisCC->cbDmiTables, pThisCC->cNumDmiTables); 2651 2652 if (pThisCC->u8IOAPIC) 2586 2653 { 2587 2654 FwCommonPlantMpsTable(pDevIns, 2588 pThis ->au8DMIPage /* aka VBOX_DMI_TABLE_BASE */ + VBOX_DMI_TABLE_SIZE + VBOX_DMI_HDR_SIZE,2589 _4K - VBOX_DMI_TABLE_SIZE - VBOX_DMI_HDR_SIZE, pThis ->cCpus);2655 pThisCC->au8DMIPage /* aka VBOX_DMI_TABLE_BASE */ + VBOX_DMI_TABLE_SIZE + VBOX_DMI_HDR_SIZE, 2656 _4K - VBOX_DMI_TABLE_SIZE - VBOX_DMI_HDR_SIZE, pThisCC->cCpus); 2590 2657 FwCommonPlantMpsFloatPtr(pDevIns, VBOX_DMI_TABLE_BASE + VBOX_DMI_TABLE_SIZE + VBOX_DMI_HDR_SIZE); 2591 2658 } 2592 2659 2593 rc = PDMDevHlpROMRegister(pDevIns, VBOX_DMI_TABLE_BASE, _4K, pThis ->au8DMIPage, _4K,2660 rc = PDMDevHlpROMRegister(pDevIns, VBOX_DMI_TABLE_BASE, _4K, pThisCC->au8DMIPage, _4K, 2594 2661 PGMPHYS_ROM_FLAGS_PERMANENT_BINARY, "DMI tables"); 2595 2662 … … 2610 2677 } 2611 2678 2679 #else /* IN_RING3 */ 2680 2681 2682 /** 2683 * @callback_method_impl{PDMDEVREGR0,pfnConstruct} 2684 */ 2685 static DECLCALLBACK(int) efiRZConstruct(PPDMDEVINS pDevIns) 2686 { 2687 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 2688 PDEVEFI pThis = PDMINS_2_DATA(pDevIns, PDEVEFI); 2689 2690 # if 0 2691 int rc = PDMDevHlpMmioSetUpContext(pDevIns, pThis->hMmioFlash, efiR3NvMmioWrite, efiR3NvMmioRead, NULL /*pvUser*/); 2692 AssertRCReturn(rc, rc); 2693 # else 2694 RT_NOREF(pDevIns, pThis); 2695 # endif 2696 2697 return VINF_SUCCESS; 2698 } 2699 2700 2701 #endif /* IN_RING3 */ 2612 2702 2613 2703 /** … … 2619 2709 /* .uReserved0 = */ 0, 2620 2710 /* .szName = */ "efi", 2621 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS ,2711 /* .fFlags = */ PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_R0 | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_NEW_STYLE, 2622 2712 /* .fClass = */ PDM_DEVREG_CLASS_ARCH_BIOS, 2623 2713 /* .cMaxInstances = */ 1, 2624 2714 /* .uSharedVersion = */ 42, 2625 2715 /* .cbInstanceShared = */ sizeof(DEVEFI), 2626 /* .cbInstanceCC = */ 0,2627 /* .cbInstanceRC = */ 0,2716 /* .cbInstanceCC = */ sizeof(DEVEFICC), 2717 /* .cbInstanceRC = */ sizeof(DEVEFIRC), 2628 2718 /* .cMaxPciDevices = */ 0, 2629 2719 /* .cMaxMsixVectors = */ 0, … … 2631 2721 "LUN#0 - NVRAM port", 2632 2722 #if defined(IN_RING3) 2633 /* .pszRCMod = */ " ",2634 /* .pszR0Mod = */ " ",2723 /* .pszRCMod = */ "VBoxDDRC.rc", 2724 /* .pszR0Mod = */ "VBoxDDR0.r0", 2635 2725 /* .pfnConstruct = */ efiConstruct, 2636 2726 /* .pfnDestruct = */ efiDestruct, … … 2657 2747 #elif defined(IN_RING0) 2658 2748 /* .pfnEarlyConstruct = */ NULL, 2659 /* .pfnConstruct = */ NULL,2749 /* .pfnConstruct = */ efiRZConstruct, 2660 2750 /* .pfnDestruct = */ NULL, 2661 2751 /* .pfnFinalDestruct = */ NULL, … … 2670 2760 /* .pfnReserved7 = */ NULL, 2671 2761 #elif defined(IN_RC) 2672 /* .pfnConstruct = */ NULL,2762 /* .pfnConstruct = */ efiRZConstruct, 2673 2763 /* .pfnReserved0 = */ NULL, 2674 2764 /* .pfnReserved1 = */ NULL, -
trunk/src/VBox/Devices/EFI/DevFlash.cpp
r81250 r81502 75 75 RT_NOREF1(pvUser); 76 76 77 return flashWrite(&pThis->Core, GCPhysAddr - pThis->GCPhysFlashBase, pv, cb);77 return VBOXSTRICTRC_TODO(flashWrite(&pThis->Core, GCPhysAddr - pThis->GCPhysFlashBase, pv, cb)); 78 78 } 79 79 … … 85 85 RT_NOREF1(pvUser); 86 86 87 return flashRead(&pThis->Core, GCPhysAddr - pThis->GCPhysFlashBase, pv, cb);87 return VBOXSTRICTRC_TODO(flashRead(&pThis->Core, GCPhysAddr - pThis->GCPhysFlashBase, pv, cb)); 88 88 } 89 89 … … 97 97 PDEVFLASH pThis = PDMINS_2_DATA(pDevIns, PDEVFLASH); 98 98 99 int rc = flashR3S smSaveExec(&pThis->Core, pSSM);99 int rc = flashR3SaveExec(&pThis->Core, pDevIns, pSSM); 100 100 if (RT_SUCCESS(rc)) 101 101 pThis->fStateSaved = true; … … 115 115 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 116 116 117 return flashR3 SsmLoadExec(&pThis->Core, pSSM);117 return flashR3LoadExec(&pThis->Core, pDevIns, pSSM); 118 118 } 119 119 … … 138 138 if (!pThis->fStateSaved) 139 139 { 140 rc = flashR3SaveToFile(&pThis->Core, p This->pszFlashFile);140 rc = flashR3SaveToFile(&pThis->Core, pDevIns, pThis->pszFlashFile); 141 141 if (RT_FAILURE(rc)) 142 142 LogRel(("Flash: Failed to save flash file")); … … 149 149 } 150 150 151 flashR3Destruct(&pThis->Core );151 flashR3Destruct(&pThis->Core, pDevIns); 152 152 return VINF_SUCCESS; 153 153 } … … 210 210 211 211 /* Try to load the flash content from file. */ 212 rc = flashR3LoadFromFile(&pThis->Core, p This->pszFlashFile);212 rc = flashR3LoadFromFile(&pThis->Core, pDevIns, pThis->pszFlashFile); 213 213 if (RT_FAILURE(rc)) 214 214 return PDMDEV_SET_ERROR(pDevIns, rc, -
trunk/src/VBox/Devices/EFI/FlashCore.cpp
r81485 r81502 71 71 72 72 73 #ifdef IN_RING3 /* for now */ 74 73 74 /** 75 * Worker for flashWrite that deals with a single byte. 76 * 77 * @retval VINF_SUCCESS on success, which is always the case in ring-3. 78 * @retval VINF_IOM_R3_MMIO_WRITE can be returned when not in ring-3. 79 */ 75 80 static int flashMemWriteByte(PFLASHCORE pThis, uint32_t off, uint8_t bCmd) 76 81 { 77 int rc = VINF_SUCCESS;78 unsigned uOffset;79 80 82 /* NB: Older datasheets (e.g. 28F008SA) suggest that for two-cycle commands like byte write or 81 83 * erase setup, the address is significant in both cycles, but do not explain what happens … … 121 123 case FLASH_CMD_WRITE: 122 124 case FLASH_CMD_ALT_WRITE: 123 uOffset = off; 124 if (uOffset < pThis->cbFlashSize) 125 if (off < pThis->cbFlashSize) 125 126 { 126 pThis->pbFlash[uOffset] = bCmd; 127 #ifdef IN_RING3 128 pThis->pbFlash[off] = bCmd; 127 129 /* NB: Writes are instant and never fail. */ 128 130 LogFunc(("wrote byte to flash at %08RX32: %02X\n", off, bCmd)); 131 #else 132 return VINF_IOM_R3_MMIO_WRITE; 133 #endif 129 134 } 130 135 else … … 134 139 if (bCmd == FLASH_CMD_ERASE_CONFIRM) 135 140 { 141 #ifdef IN_RING3 136 142 /* The current address determines the block to erase. */ 137 u Offset = off & ~(pThis->cbBlockSize - 1);143 unsigned uOffset = off & ~(pThis->cbBlockSize - 1); 138 144 memset(pThis->pbFlash + uOffset, 0xff, pThis->cbBlockSize); 139 145 LogFunc(("Erasing block at offset %u\n", uOffset)); 146 #else 147 return VINF_IOM_R3_MMIO_WRITE; 148 #endif 140 149 } 141 150 else … … 153 162 pThis->cBusCycle = 0; 154 163 } 155 LogFlow(("flashMemWriteByte: write access at %08RX32: %#x rc=%Rrc\n", off, bCmd, rc)); 156 return rc; 157 } 158 159 164 LogFlow(("flashMemWriteByte: write access at %08RX32: %#x\n", off, bCmd)); 165 return VINF_SUCCESS; 166 } 167 168 /** 169 * Performs a write to the given flash offset. 170 * 171 * Parent device calls this from its MMIO write callback. 172 * 173 * @returns Strict VBox status code. 174 * @retval VINF_SUCCESS on success, which is always the case in ring-3. 175 * @retval VINF_IOM_R3_MMIO_WRITE can be returned when not in ring-3. 176 * 177 * @param pThis The UART core instance. 178 * @param off Offset to start writing to. 179 * @param pv The value to write. 180 * @param cb Number of bytes to write. 181 */ 182 DECLHIDDEN(VBOXSTRICTRC) flashWrite(PFLASHCORE pThis, uint32_t off, const void *pv, size_t cb) 183 { 184 const uint8_t *pbSrc = (const uint8_t *)pv; 185 186 #ifndef IN_RING3 187 /* 188 * If multiple bytes are written, just go to ring-3 and do it there as it's 189 * too much trouble to validate the sequence in adanvce and it is usually 190 * not restartable as device state changes. 191 */ 192 VBOXSTRICTRC rcStrict; 193 if (cb == 1) 194 { 195 rcStrict = flashMemWriteByte(pThis, off, *pbSrc); 196 if (rcStrict == VINF_SUCCESS) 197 LogFlow(("flashWrite: completed write at %08RX32 (LB %u)\n", off, cb)); 198 else 199 LogFlow(("flashWrite: incomplete write at %08RX32 (LB %u): rc=%Rrc bCmd=%#x cBusCycle=%u\n", 200 off, cb, VBOXSTRICTRC_VAL(rcStrict), *pbSrc, pThis->cBusCycle)); 201 } 202 else 203 { 204 LogFlow(("flashWrite: deferring multi-byte write at %08RX32 (LB %u) to ring-3\n", off, cb)); 205 rcStrict = VINF_IOM_R3_IOPORT_WRITE; 206 } 207 return rcStrict; 208 209 #else /* IN_RING3 */ 210 211 for (uint32_t offWrite = 0; offWrite < cb; ++offWrite) 212 flashMemWriteByte(pThis, off + offWrite, pbSrc[offWrite]); 213 214 LogFlow(("flashWrite: completed write at %08RX32 (LB %u)\n", off, cb)); 215 return VINF_SUCCESS; 216 #endif /* IN_RING3 */ 217 } 218 219 /** 220 * Worker for flashRead that deals with a single byte. 221 * 222 * @retval VINF_SUCCESS on success, which is always the case in ring-3. 223 * @retval VINF_IOM_R3_MMIO_READ can be returned when not in ring-3. 224 */ 160 225 static int flashMemReadByte(PFLASHCORE pThis, uint32_t off, uint8_t *pbData) 161 226 { 162 227 uint8_t bValue; 163 int rc = VINF_SUCCESS;164 228 165 229 /* … … 171 235 case FLASH_CMD_ARRAY_READ: 172 236 if (off < pThis->cbFlashSize) 237 #ifdef IN_RING3 173 238 bValue = pThis->pbFlash[off]; 239 #else 240 return VINF_IOM_R3_MMIO_READ; 241 #endif 174 242 else 175 243 bValue = 0xff; /* Play safe and return the default value of non initialized flash. */ … … 188 256 *pbData = bValue; 189 257 190 LogFlow(("flashMemReadByte: read access at %08RX32: %02X (cmd=%02X) rc=%Rrc\n", off, bValue, pThis->bCmd, rc)); 191 return rc; 192 } 193 194 DECLHIDDEN(int) flashWrite(PFLASHCORE pThis, uint32_t off, const void *pv, size_t cb) 195 { 196 int rc = VINF_SUCCESS; 197 const uint8_t *pu8Mem = (const uint8_t *)pv; 198 199 #ifndef IN_RING3 200 if (cb > 1) 201 return VINF_IOM_R3_IOPORT_WRITE; 258 LogFlow(("flashMemReadByte: read access at %08RX32: %02X (cmd=%02X)\n", off, bValue, pThis->bCmd)); 259 return VINF_SUCCESS; 260 } 261 262 /** 263 * Performs a read from the given flash offset. 264 * 265 * Parent device calls this from its MMIO read callback. 266 * 267 * @returns Strict VBox status code. 268 * @retval VINF_SUCCESS on success, which is always the case in ring-3. 269 * @retval VINF_IOM_R3_MMIO_READ can be returned when not in ring-3. 270 * 271 * @param pThis The UART core instance. 272 * @param off Offset to start reading from. 273 * @param pv Where to store the read data. 274 * @param cb Number of bytes to read. 275 */ 276 DECLHIDDEN(VBOXSTRICTRC) flashRead(PFLASHCORE pThis, uint32_t off, void *pv, size_t cb) 277 { 278 uint8_t *pbDst = (uint8_t *)pv; 279 280 /* 281 * Reads do not change the device state, so we don't need to take any 282 * precautions when we're not in ring-3 as the read can always be restarted. 283 */ 284 for (uint32_t offRead = 0; offRead < cb; ++offRead) 285 { 286 #ifdef IN_RING3 287 flashMemReadByte(pThis, off + offRead, &pbDst[offRead]); 288 #else 289 VBOXSTRICTRC rcStrict = flashMemReadByte(pThis, off + offRead, &pbDst[offRead]); 290 if (rcStrict != VINF_SUCCESS) 291 { 292 LogFlow(("flashRead: incomplete read at %08RX32+%#x (LB %u): rc=%Rrc bCmd=%#x\n", 293 off, offRead, cb, VBOXSTRICTRC_VAL(rcStrict), pThis->bCmd)); 294 return rcStrict; 295 } 202 296 #endif 203 204 for (uint32_t uOffset = 0; uOffset < cb; ++uOffset) 205 { 206 rc = flashMemWriteByte(pThis, off + uOffset, pu8Mem[uOffset]); 207 if (!RT_SUCCESS(rc)) 208 break; 209 } 210 211 LogFlow(("flashWrite: completed write at %08RX32 (LB %u): rc=%Rrc\n", off, cb, rc)); 212 return rc; 213 } 214 215 DECLHIDDEN(int) flashRead(PFLASHCORE pThis, uint32_t off, void *pv, size_t cb) 216 { 217 int rc = VINF_SUCCESS; 218 uint8_t *pu8Mem = (uint8_t *)pv; 219 220 /* 221 * Reading can always be done witout going back to R3. Reads do not 222 * change the device state and we always have the data. 223 */ 224 for (uint32_t uOffset = 0; uOffset < cb; ++uOffset, ++pu8Mem) 225 { 226 rc = flashMemReadByte(pThis, off + uOffset, pu8Mem); 227 if (!RT_SUCCESS(rc)) 228 break; 229 } 230 231 LogFlow(("flashRead: completed read at %08RX32 (LB %u): rc=%Rrc\n", off, cb, rc)); 232 return rc; 233 } 234 235 #endif /* IN_RING3 for now */ 297 } 298 299 LogFlow(("flashRead: completed read at %08RX32 (LB %u)\n", off, cb)); 300 return VINF_SUCCESS; 301 } 236 302 237 303 #ifdef IN_RING3 238 304 305 /** 306 * Initialiizes the given flash device instance. 307 * 308 * @returns VBox status code. 309 * @param pThis The flash device core instance. 310 * @param pDevIns Pointer to the owning device instance. 311 * @param idFlashDev The flash device ID. 312 * @param GCPhysFlashBase Base MMIO address where the flash is located. 313 * @param cbFlash Size of the flash device in bytes. 314 * @param cbBlock Size of a flash block. 315 */ 239 316 DECLHIDDEN(int) flashR3Init(PFLASHCORE pThis, PPDMDEVINS pDevIns, uint16_t idFlashDev, uint32_t cbFlash, uint16_t cbBlock) 240 317 { 241 pThis->pDevIns = pDevIns;242 318 pThis->u16FlashId = idFlashDev; 243 319 pThis->cbBlockSize = cbBlock; … … 257 333 } 258 334 259 DECLHIDDEN(void) flashR3Destruct(PFLASHCORE pThis) 335 /** 336 * Destroys the given flash device instance. 337 * 338 * @returns nothing. 339 * @param pDevIns The parent device instance. 340 * @param pThis The flash device core instance. 341 */ 342 DECLHIDDEN(void) flashR3Destruct(PFLASHCORE pThis, PPDMDEVINS pDevIns) 260 343 { 261 344 if (pThis->pbFlash) 262 345 { 263 PDMDevHlpMMHeapFree(p This->pDevIns, pThis->pbFlash);346 PDMDevHlpMMHeapFree(pDevIns, pThis->pbFlash); 264 347 pThis->pbFlash = NULL; 265 348 } 266 349 } 267 350 268 DECLHIDDEN(int) flashR3LoadFromFile(PFLASHCORE pThis, const char *pszFilename) 351 /** 352 * Loads the flash content from the given file. 353 * 354 * @returns VBox status code. 355 * @param pThis The flash device core instance. 356 * @param pDevIns The parent device instance. 357 * @param pszFilename The file to load the flash content from. 358 */ 359 DECLHIDDEN(int) flashR3LoadFromFile(PFLASHCORE pThis, PPDMDEVINS pDevIns, const char *pszFilename) 269 360 { 270 361 RTFILE hFlashFile = NIL_RTFILE; … … 272 363 int rc = RTFileOpen(&hFlashFile, pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 273 364 if (RT_FAILURE(rc)) 274 return PDMDEV_SET_ERROR(p This->pDevIns, rc, N_("Failed to open flash file"));365 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to open flash file")); 275 366 276 367 size_t cbRead = 0; 277 368 rc = RTFileRead(hFlashFile, pThis->pbFlash, pThis->cbFlashSize, &cbRead); 278 369 if (RT_FAILURE(rc)) 279 return PDMDEV_SET_ERROR(p This->pDevIns, rc, N_("Failed to read flash file"));370 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to read flash file")); 280 371 Log(("Read %zu bytes from file (asked for %u)\n.", cbRead, pThis->cbFlashSize)); 281 372 … … 284 375 } 285 376 377 /** 378 * Loads the flash content from the given buffer. 379 * 380 * @returns VBox status code. 381 * @param pThis The flash device core instance. 382 * @param pvBuf The buffer to load the content from. 383 * @param cbBuf Size of the buffer in bytes. 384 */ 286 385 DECLHIDDEN(int) flashR3LoadFromBuf(PFLASHCORE pThis, void const *pvBuf, size_t cbBuf) 287 386 { … … 292 391 } 293 392 294 DECLHIDDEN(int) flashR3SaveToFile(PFLASHCORE pThis, const char *pszFilename) 393 /** 394 * Saves the flash content to the given file. 395 * 396 * @returns VBox status code. 397 * @param pThis The flash device core instance. 398 * @param pDevIns The parent device instance. 399 * @param pszFilename The file to save the flash content to. 400 */ 401 DECLHIDDEN(int) flashR3SaveToFile(PFLASHCORE pThis, PPDMDEVINS pDevIns, const char *pszFilename) 295 402 { 296 403 RTFILE hFlashFile = NIL_RTFILE; … … 298 405 int rc = RTFileOpen(&hFlashFile, pszFilename, RTFILE_O_READWRITE | RTFILE_O_OPEN_CREATE | RTFILE_O_DENY_WRITE); 299 406 if (RT_FAILURE(rc)) 300 return PDMDEV_SET_ERROR(p This->pDevIns, rc, N_("Failed to open flash file"));407 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to open flash file")); 301 408 302 409 rc = RTFileWrite(hFlashFile, pThis->pbFlash, pThis->cbFlashSize, NULL); 410 RTFileClose(hFlashFile); 303 411 if (RT_FAILURE(rc)) 304 return PDMDEV_SET_ERROR(pThis->pDevIns, rc, N_("Failed to write flash file")); 305 306 RTFileClose(hFlashFile); 307 return VINF_SUCCESS; 308 } 309 412 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Failed to write flash file")); 413 414 return VINF_SUCCESS; 415 } 416 417 /** 418 * Saves the flash content to the given buffer. 419 * 420 * @returns VBox status code. 421 * @param pThis The flash device core instance. 422 * @param pvBuf The buffer to save the content to. 423 * @param cbBuf Size of the buffer in bytes. 424 */ 310 425 DECLHIDDEN(int) flashR3SaveToBuf(PFLASHCORE pThis, void *pvBuf, size_t cbBuf) 311 426 { … … 316 431 } 317 432 433 /** 434 * Resets the dynamic part of the flash device state. 435 * 436 * @returns nothing. 437 * @param pThis The flash device core instance. 438 */ 318 439 DECLHIDDEN(void) flashR3Reset(PFLASHCORE pThis) 319 440 { … … 326 447 } 327 448 328 DECLHIDDEN(int) flashR3SsmSaveExec(PFLASHCORE pThis, PSSMHANDLE pSSM) 329 { 330 SSMR3PutU32(pSSM, FLASH_SAVED_STATE_VERSION); 449 /** 450 * Saves the flash device state to the given SSM handle. 451 * 452 * @returns VBox status code. 453 * @param pThis The flash device core instance. 454 * @param pDevIns The parent device instance. 455 * @param pSSM The SSM handle to save to. 456 */ 457 DECLHIDDEN(int) flashR3SaveExec(PFLASHCORE pThis, PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 458 { 459 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 460 461 pHlp->pfnSSMPutU32(pSSM, FLASH_SAVED_STATE_VERSION); 331 462 332 463 /* Save the device state. */ 333 SSMR3PutU8(pSSM, pThis->bCmd);334 SSMR3PutU8(pSSM, pThis->bStatus);335 SSMR3PutU8(pSSM, pThis->cBusCycle);464 pHlp->pfnSSMPutU8(pSSM, pThis->bCmd); 465 pHlp->pfnSSMPutU8(pSSM, pThis->bStatus); 466 pHlp->pfnSSMPutU8(pSSM, pThis->cBusCycle); 336 467 337 468 /* Save the current configuration for validation purposes. */ 338 SSMR3PutU16(pSSM, pThis->cbBlockSize);339 SSMR3PutU16(pSSM, pThis->u16FlashId);469 pHlp->pfnSSMPutU16(pSSM, pThis->cbBlockSize); 470 pHlp->pfnSSMPutU16(pSSM, pThis->u16FlashId); 340 471 341 472 /* Save the current flash contents. */ 342 SSMR3PutU32(pSSM, pThis->cbFlashSize); 343 SSMR3PutMem(pSSM, pThis->pbFlash, pThis->cbFlashSize); 344 345 return VINF_SUCCESS; 346 } 347 348 DECLHIDDEN(int) flashR3SsmLoadExec(PFLASHCORE pThis, PSSMHANDLE pSSM) 349 { 473 pHlp->pfnSSMPutU32(pSSM, pThis->cbFlashSize); 474 return pHlp->pfnSSMPutMem(pSSM, pThis->pbFlash, pThis->cbFlashSize); 475 } 476 477 /** 478 * Loads the flash device state from the given SSM handle. 479 * 480 * @returns VBox status code. 481 * @param pThis The flash device core instance. 482 * @param pDevIns The parent device instance. 483 * @param pSSM The SSM handle to load from. 484 */ 485 DECLHIDDEN(int) flashR3LoadExec(PFLASHCORE pThis, PPDMDEVINS pDevIns, PSSMHANDLE pSSM) 486 { 487 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 488 350 489 uint32_t uVersion = FLASH_SAVED_STATE_VERSION; 351 int rc = SSMR3GetU32(pSSM, &uVersion);490 int rc = pHlp->pfnSSMGetU32(pSSM, &uVersion); 352 491 AssertRCReturn(rc, rc); 353 492 … … 360 499 uint32_t u32Val; 361 500 362 SSMR3GetU8(pSSM, &pThis->bCmd);363 SSMR3GetU8(pSSM, &pThis->bStatus);364 SSMR3GetU8(pSSM, &pThis->cBusCycle);501 pHlp->pfnSSMGetU8(pSSM, &pThis->bCmd); 502 pHlp->pfnSSMGetU8(pSSM, &pThis->bStatus); 503 pHlp->pfnSSMGetU8(pSSM, &pThis->cBusCycle); 365 504 366 505 /* Make sure configuration didn't change behind our back. */ 367 rc = SSMR3GetU16(pSSM, &u16Val);506 rc = pHlp->pfnSSMGetU16(pSSM, &u16Val); 368 507 AssertRCReturn(rc, rc); 369 508 if (u16Val != pThis->cbBlockSize) 370 509 return VERR_SSM_LOAD_CONFIG_MISMATCH; 371 rc = SSMR3GetU16(pSSM, &u16Val);510 rc = pHlp->pfnSSMGetU16(pSSM, &u16Val); 372 511 AssertRCReturn(rc, rc); 373 512 if (u16Val != pThis->u16FlashId) 374 513 return VERR_SSM_LOAD_CONFIG_MISMATCH; 375 rc = SSMR3GetU32(pSSM, &u32Val);514 rc = pHlp->pfnSSMGetU32(pSSM, &u32Val); 376 515 AssertRCReturn(rc, rc); 377 516 if (u32Val != pThis->cbFlashSize) … … 379 518 380 519 /* Suck in the flash contents. */ 381 rc = SSMR3GetMem(pSSM, pThis->pbFlash, pThis->cbFlashSize);520 rc = pHlp->pfnSSMGetMem(pSSM, pThis->pbFlash, pThis->cbFlashSize); 382 521 } 383 522 else -
trunk/src/VBox/Devices/EFI/FlashCore.h
r81458 r81502 57 57 typedef struct FLASHCORE 58 58 { 59 /** Owning device instance. */60 PPDMDEVINS pDevIns;61 59 /** The current command. */ 62 uint8_t bCmd;60 uint8_t bCmd; 63 61 /** The status register. */ 64 uint8_t bStatus;62 uint8_t bStatus; 65 63 /** Current bus cycle. */ 66 uint8_t cBusCycle;64 uint8_t cBusCycle; 67 65 68 uint8_t uPadding0; 69 70 /* The following state does not change at runtime.*/ 66 /** @name The following state does not change at runtime 67 * @{ */ 68 /** When set, indicates the state was saved. */ 69 bool fStateSaved; 71 70 /** Manufacturer (high byte) and device (low byte) ID. */ 72 uint16_t u16FlashId;71 uint16_t u16FlashId; 73 72 /** The configured block size of the device. */ 74 uint16_t cbBlockSize;73 uint16_t cbBlockSize; 75 74 /** The flash memory region size. */ 76 uint32_t cbFlashSize;75 uint32_t cbFlashSize; 77 76 /** The actual flash memory data. */ 78 uint8_t *pbFlash; 79 /** When set, indicates the state was saved. */ 80 bool fStateSaved; 77 R3PTRTYPE(uint8_t *) pbFlash; 78 /** @} */ 81 79 } FLASHCORE; 82 80 … … 86 84 #ifndef VBOX_DEVICE_STRUCT_TESTCASE 87 85 88 /** 89 * Performs a write to the given flash offset. 90 * 91 * @returns VBox status code. 92 * @param pThis The UART core instance. 93 * @param off Offset to start writing to. 94 * @param pv The value to write. 95 * @param cb Number of bytes to write. 96 */ 97 DECLHIDDEN(int) flashWrite(PFLASHCORE pThis, uint32_t off, const void *pv, size_t cb); 98 99 /** 100 * Performs a read from the given flash offset. 101 * 102 * @returns VBox status code. 103 * @param pThis The UART core instance. 104 * @param off Offset to start reading from. 105 * @param pv Where to store the read data. 106 * @param cb Number of bytes to read. 107 */ 108 DECLHIDDEN(int) flashRead(PFLASHCORE pThis, uint32_t off, void *pv, size_t cb); 86 DECLHIDDEN(VBOXSTRICTRC) flashWrite(PFLASHCORE pThis, uint32_t off, const void *pv, size_t cb); 87 DECLHIDDEN(VBOXSTRICTRC) flashRead(PFLASHCORE pThis, uint32_t off, void *pv, size_t cb); 109 88 110 89 # ifdef IN_RING3 111 112 /**113 * Initialiizes the given flash device instance.114 *115 * @returns VBox status code.116 * @param pThis The flash device core instance.117 * @param pDevIns Pointer to the owning device instance.118 * @param idFlashDev The flash device ID.119 * @param GCPhysFlashBase Base MMIO address where the flash is located.120 * @param cbFlash Size of the flash device in bytes.121 * @param cbBlock Size of a flash block.122 */123 90 DECLHIDDEN(int) flashR3Init(PFLASHCORE pThis, PPDMDEVINS pDevIns, uint16_t idFlashDev, uint32_t cbFlash, uint16_t cbBlock); 124 125 /** 126 * Destroys the given flash device instance. 127 * 128 * @returns nothing. 129 * @param pThis The flash device core instance. 130 */ 131 DECLHIDDEN(void) flashR3Destruct(PFLASHCORE pThis); 132 133 /** 134 * Loads the flash content from the given file. 135 * 136 * @returns VBox status code. 137 * @param pThis The flash device core instance. 138 * @param pszFilename The file to load the flash content from. 139 */ 140 DECLHIDDEN(int) flashR3LoadFromFile(PFLASHCORE pThis, const char *pszFilename); 141 142 /** 143 * Loads the flash content from the given buffer. 144 * 145 * @returns VBox status code. 146 * @param pThis The flash device core instance. 147 * @param pvBuf The buffer to load the content from. 148 * @param cbBuf Size of the buffer in bytes. 149 */ 91 DECLHIDDEN(void) flashR3Destruct(PFLASHCORE pThis, PPDMDEVINS pDevIns); 92 DECLHIDDEN(int) flashR3LoadFromFile(PFLASHCORE pThis, PPDMDEVINS pDevIns, const char *pszFilename); 150 93 DECLHIDDEN(int) flashR3LoadFromBuf(PFLASHCORE pThis, void const *pvBuf, size_t cbBuf); 151 152 /** 153 * Saves the flash content to the given file. 154 * 155 * @returns VBox status code. 156 * @param pThis The flash device core instance. 157 * @param pszFilename The file to save the flash content to. 158 */ 159 DECLHIDDEN(int) flashR3SaveToFile(PFLASHCORE pThis, const char *pszFilename); 160 161 /** 162 * Saves the flash content to the given buffer. 163 * 164 * @returns VBox status code. 165 * @param pThis The flash device core instance. 166 * @param pvBuf The buffer to save the content to. 167 * @param cbBuf Size of the buffer in bytes. 168 */ 94 DECLHIDDEN(int) flashR3SaveToFile(PFLASHCORE pThis, PPDMDEVINS pDevIns, const char *pszFilename); 169 95 DECLHIDDEN(int) flashR3SaveToBuf(PFLASHCORE pThis, void *pvBuf, size_t cbBuf); 170 171 /**172 * Resets the dynamic part of the flash device state.173 *174 * @returns nothing.175 * @param pThis The flash device core instance.176 */177 96 DECLHIDDEN(void) flashR3Reset(PFLASHCORE pThis); 178 179 /** 180 * Saves the flash device state to the given SSM handle. 181 * 182 * @returns VBox status code. 183 * @param pThis The flash device core instance. 184 * @param pSSM The SSM handle to save to. 185 */ 186 DECLHIDDEN(int) flashR3SsmSaveExec(PFLASHCORE pThis, PSSMHANDLE pSSM); 187 188 /** 189 * Loads the flash device state from the given SSM handle. 190 * 191 * @returns VBox status code. 192 * @param pThis The flash device core instance. 193 * @param pSSM The SSM handle to load from. 194 */ 195 DECLHIDDEN(int) flashR3SsmLoadExec(PFLASHCORE pThis, PSSMHANDLE pSSM); 196 97 DECLHIDDEN(int) flashR3SaveExec(PFLASHCORE pThis, PPDMDEVINS pDevIns, PSSMHANDLE pSSM); 98 DECLHIDDEN(int) flashR3LoadExec(PFLASHCORE pThis, PPDMDEVINS pDevIns, PSSMHANDLE pSSM); 197 99 # endif /* IN_RING3 */ 198 100 -
trunk/src/VBox/Devices/Makefile.kmk
r81458 r81502 1180 1180 endif 1181 1181 1182 ifdef VBOX_WITH_EFI 1183 VBoxDDR0_DEFS += VBOX_WITH_EFI 1184 VBoxDDR0_SOURCES += \ 1185 EFI/DevEFI.cpp \ 1186 EFI/FlashCore.cpp 1187 endif 1188 1182 1189 if defined(VBOX_WITH_PCI_PASSTHROUGH_IMPL) && !defined(VBOX_WITH_EXTPACK_PUEL) 1183 1190 VBoxDDR0_SOURCES += \ -
trunk/src/VBox/Devices/build/VBoxDDR0.cpp
r80537 r81502 92 92 &g_DeviceNVMe, 93 93 #endif 94 #ifdef VBOX_WITH_EFI 95 &g_DeviceEFI, 96 #endif 94 97 #ifdef VBOX_WITH_VIRTIO_SCSI 95 98 &g_DeviceVirtioSCSI,
Note:
See TracChangeset
for help on using the changeset viewer.