MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / SetStartupDiskVolume

Function SetStartupDiskVolume

rEFIt_UEFI/Platform/Nvram.cpp:1382–1452  ·  view source on GitHub ↗

Sets efi-boot-device-data RT var to currently selected Volume and LoadePath. */

Source from the content-addressed store, hash-verified

1380
1381/** Sets efi-boot-device-data RT var to currently selected Volume and LoadePath. */
1382EFI_STATUS SetStartupDiskVolume (
1383 IN REFIT_VOLUME *Volume,
1384 IN CONST XStringW& LoaderPath
1385 )
1386{
1387 EFI_STATUS Status;
1388 EFI_DEVICE_PATH_PROTOCOL *DevPath;
1389 EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
1390 EFI_GUID *Guid;
1391// CHAR8 *EfiBootDevice;
1392// CONST CHAR8 *EfiBootDeviceTmpl;
1393// UINTN Size;
1394 UINT32 Attributes;
1395
1396
1397 DBG("SetStartupDiskVolume:\n");
1398 DBG(" * Volume: '%ls'\n", Volume->VolName.wc_str());
1399 DBG(" * LoaderPath: '%ls'\n", LoaderPath.wc_str());
1400
1401 //
1402 // construct dev path for Volume/LoaderPath
1403 //
1404 DevPath = Volume->DevicePath;
1405 if (LoaderPath.notEmpty()) {
1406 FileDevPath = FileDevicePath (NULL, LoaderPath);
1407 DevPath = AppendDevicePathNode (DevPath, FileDevPath);
1408 }
1409 DBG(" * DevPath: %ls\n", Volume->VolName.wc_str()/*, FileDevicePathToStr (DevPath)*/);
1410
1411 Guid = FindGPTPartitionGuidInDevicePath (Volume->DevicePath);
1412 DBG(" * GUID = %s\n", strguid(Guid));
1413
1414 //
1415 // let's save it without EFI_VARIABLE_NON_VOLATILE in CloverEFI like other vars so far
1416 //
1417 if (!gFirmwareClover && !gDriversFlags.EmuVariableLoaded) {
1418 Attributes = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
1419 } else {
1420 Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
1421 }
1422
1423 //
1424 // set efi-boot-device-data to volume dev path
1425 //
1426 Status = SetNvramVariable (L"efi-boot-device-data", &gEfiAppleBootGuid, Attributes, GetDevicePathSize(DevPath), DevPath);
1427
1428 if (EFI_ERROR(Status)) {
1429 return Status;
1430 }
1431
1432 //
1433 // set efi-boot-device to XML string
1434 // (probably not needed at all)
1435 //
1436 if (Guid != NULL) {
1437 XString8 EfiBootDevice;
1438 EfiBootDevice.S8Printf(
1439 "<array><dict>"

Callers 2

StartLoaderMethod · 0.85
StartLegacyMethod · 0.85

Calls 11

AppendDevicePathNodeFunction · 0.85
strguidFunction · 0.85
SetNvramVariableFunction · 0.85
SetNvramXString8Function · 0.85
S8PrintfMethod · 0.80
FileDevicePathFunction · 0.50
GetDevicePathSizeFunction · 0.50
wc_strMethod · 0.45
notEmptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected