Sets NVRAM variable. Does nothing if variable with the same name already exists. */
| 231 | |
| 232 | /** Sets NVRAM variable. Does nothing if variable with the same name already exists. */ |
| 233 | EFI_STATUS |
| 234 | AddNvramVariable ( |
| 235 | IN CONST CHAR16 *VariableName, |
| 236 | IN EFI_GUID *VendorGuid, |
| 237 | IN UINT32 Attributes, |
| 238 | IN UINTN DataSize, |
| 239 | IN VOID *Data |
| 240 | ) |
| 241 | { |
| 242 | VOID *OldData; |
| 243 | |
| 244 | //DBG("SetNvramVariable (%ls, guid, 0x%X, %d):\n", VariableName, Attributes, DataSize); |
| 245 | OldData = (__typeof__(OldData))GetNvramVariable(VariableName, VendorGuid, NULL, NULL); |
| 246 | if (OldData == NULL) |
| 247 | { |
| 248 | // set new value |
| 249 | return gRT->SetVariable(VariableName, VendorGuid, Attributes, DataSize, Data); |
| 250 | // DBG(" -> writing new (%s)\n", efiStrError(Status)); |
| 251 | } else { |
| 252 | FreePool(OldData); |
| 253 | return EFI_ABORTED; |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | EFI_STATUS |
| 258 | AddNvramXString8( |
no test coverage detected