Volatile variable is read-only in runtime.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2170 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2007-01-04 09:21:03 +00:00
parent 3088e81137
commit f53a07320e
2 changed files with 69 additions and 56 deletions

View File

@ -506,38 +506,40 @@ Returns:
if (Status == EFI_INVALID_PARAMETER) {
return Status;
}
} else if (!EFI_ERROR (Status) && Variable.Volatile && EfiAtRuntime()) {
//
// If EfiAtRuntime and the variable is Volatile and Runtime Access,
// the volatile is ReadOnly, and SetVariable should be aborted and
// return EFI_WRITE_PROTECTED.
//
return EFI_WRITE_PROTECTED;
} else if (sizeof (VARIABLE_HEADER) + (ArrayLength (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {
//
// The size of the VariableName, including the Unicode Null in bytes plus
// the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.
//
else if (sizeof (VARIABLE_HEADER) + (ArrayLength (VariableName) + DataSize) > MAX_VARIABLE_SIZE) {
return EFI_INVALID_PARAMETER;
}
} else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS
) {
//
// Make sure if runtime bit is set, boot service bit is set also
//
else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS
) {
return EFI_INVALID_PARAMETER;
}
} else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {
//
// Runtime but Attribute is not Runtime
//
else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {
return EFI_INVALID_PARAMETER;
}
} else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {
//
// Cannot set volatile variable in Runtime
//
else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {
return EFI_INVALID_PARAMETER;
}
} else if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {
//
// Setting a data variable with no access, or zero DataSize attributes
// specified causes it to be deleted.
//
else if (DataSize == 0 || Attributes == 0) {
if (!EFI_ERROR (Status)) {
Variable.CurrPtr->State &= VAR_DELETED;
return EFI_SUCCESS;
@ -692,6 +694,11 @@ Returns:
// Make sure RT Attribute is set if we are in Runtime phase.
//
return EFI_INVALID_PARAMETER;
} else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {
//
// Cannot Query volatile variable in Runtime
//
return EFI_INVALID_PARAMETER;
}
if((Attributes & EFI_VARIABLE_NON_VOLATILE) == 0) {

View File

@ -810,39 +810,45 @@ Returns:
if (Status == EFI_INVALID_PARAMETER) {
return Status;
}
} else if (!EFI_ERROR (Status) && Variable.Volatile && EfiAtRuntime()) {
//
// If EfiAtRuntime and the variable is Volatile and Runtime Access,
// the volatile is ReadOnly, and SetVariable should be aborted and
// return EFI_WRITE_PROTECTED.
//
return EFI_WRITE_PROTECTED;
} else if (sizeof (VARIABLE_HEADER) + ArrayLength (VariableName) + DataSize > MAX_VARIABLE_SIZE) {
//
// The size of the VariableName, including the Unicode Null in bytes plus
// the DataSize is limited to maximum size of MAX_VARIABLE_SIZE (1024) bytes.
//
else if ((DataSize > MAX_VARIABLE_SIZE) ||
(sizeof (VARIABLE_HEADER) + ArrayLength (VariableName) + DataSize > MAX_VARIABLE_SIZE)) {
return EFI_INVALID_PARAMETER;
}
} else if (Attributes == EFI_VARIABLE_NON_VOLATILE) {
//
// Make sure not only EFI_VARIABLE_NON_VOLATILE is set
//
return EFI_INVALID_PARAMETER;
} else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) ==
EFI_VARIABLE_RUNTIME_ACCESS) {
//
// Make sure if runtime bit is set, boot service bit is set also
//
else if ((Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == EFI_VARIABLE_RUNTIME_ACCESS
) {
return EFI_INVALID_PARAMETER;
}
} else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {
//
// Runtime but Attribute is not Runtime
//
else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_RUNTIME_ACCESS)) {
return EFI_INVALID_PARAMETER;
}
} else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {
//
// Cannot set volatile variable in Runtime
//
else if (EfiAtRuntime () && Attributes && !(Attributes & EFI_VARIABLE_NON_VOLATILE)) {
return EFI_INVALID_PARAMETER;
}
} else if (DataSize == 0 || (Attributes & (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)) == 0) {
//
// Setting a data variable with no access, or zero DataSize attributes
// specified causes it to be deleted.
//
else if (DataSize == 0 || Attributes == 0) {
if (!EFI_ERROR (Status)) {
State = Variable.CurrPtr->State;
State &= VAR_DELETED;