123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473 |
- /*++
- Copyright (c) 2014 Minoca Corp. All Rights Reserved
- Module Name:
- rtlib.h
- Abstract:
- This header contains internal definitions for the UEFI runtime library.
- Author:
- Evan Green 18-Mar-2014
- --*/
- //
- // ------------------------------------------------------------------- Includes
- //
- #include <uefifw.h>
- #include "shortcut.h"
- //
- // ---------------------------------------------------------------- Definitions
- //
- //
- // ------------------------------------------------------ Data Type Definitions
- //
- //
- // -------------------------------------------------------------------- Globals
- //
- //
- // -------------------------------------------------------- Function Prototypes
- //
- //
- // Variable services
- //
- EFIAPI
- EFI_STATUS
- EfiCoreSetVariable (
- CHAR16 *VariableName,
- EFI_GUID *VendorGuid,
- UINT32 Attributes,
- UINTN DataSize,
- VOID *Data
- );
- /*++
- Routine Description:
- This routine sets the value of a variable.
- Arguments:
- VariableName - Supplies a pointer to a null-terminated string containing
- the name of the vendor's variable. Each variable name is unique for a
- particular vendor GUID. A variable name must be at least one character
- in length.
- VendorGuid - Supplies a pointer to the unique GUID for the vendor.
- Attributes - Supplies the attributes for this variable. See EFI_VARIABLE_*
- definitions.
- DataSize - Supplies the size of the data buffer. Unless the
- EFI_VARIABLE_APPEND_WRITE, EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS, or
- EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS attribute is set, a
- size of zero causes the variable to be deleted. When the
- EFI_VARIABLE_APPEND_WRITE attribute is set, then a set variable call
- with a data size of zero will not cause any change to the variable
- value (the timestamp associated with the variable may be updated
- however even if no new data value is provided,see the description of
- the EFI_VARIABLE_AUTHENTICATION_2 descriptor below. In this case the
- data size will not be zero since the EFI_VARIABLE_AUTHENTICATION_2
- descriptor will be populated).
- Data - Supplies the contents of the variable.
- Return Value:
- EFI_SUCCESS on success.
- EFI_NOT_FOUND if the variable being updated or deleted was not found.
- EFI_INVALID_PARAMETER if an invalid combination of attribute bits, name,
- and GUID was suplied, data size exceeds the maximum, or the variable name
- is an empty string.
- EFI_DEVICE_ERROR if a hardware error occurred trying to access the variable.
- EFI_WRITE_PROTECTED if the variable is read-only or cannot be deleted.
- EFI_SECURITY_VIOLATION if variable could not be written due to
- EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS or
- EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the
- authorization information does NOT pass the validation check carried out by
- the firmware.
- --*/
- EFIAPI
- EFI_STATUS
- EfiCoreGetNextVariableName (
- UINTN *VariableNameSize,
- CHAR16 *VariableName,
- EFI_GUID *VendorGuid
- );
- /*++
- Routine Description:
- This routine enumerates the current variable names.
- Arguments:
- VariableNameSize - Supplies a pointer that on input contains the size of
- the variable name buffer. On output, will contain the size of the
- variable name.
- VariableName - Supplies a pointer that on input contains the last variable
- name that was returned. On output, returns the null terminated string
- of the current variable.
- VendorGuid - Supplies a pointer that on input contains the last vendor GUID
- returned by this routine. On output, returns the vendor GUID of the
- current variable.
- Return Value:
- EFI_SUCCESS on success.
- EFI_NOT_FOUND if the next variable was not found.
- EFI_BUFFER_TOO_SMALL if the supplied buffer is not big enough.
- EFI_INVALID_PARAMETER if the variable name, vendor GUID, or data size is
- NULL.
- EFI_DEVICE_ERROR if a hardware error occurred trying to read the variable.
- --*/
- EFIAPI
- EFI_STATUS
- EfiCoreGetVariable (
- CHAR16 *VariableName,
- EFI_GUID *VendorGuid,
- UINT32 *Attributes,
- UINTN *DataSize,
- VOID *Data
- );
- /*++
- Routine Description:
- This routine returns the value of a variable.
- Arguments:
- VariableName - Supplies a pointer to a null-terminated string containing
- the name of the vendor's variable.
- VendorGuid - Supplies a pointer to the unique GUID for the vendor.
- Attributes - Supplies an optional pointer where the attribute mask for the
- variable will be returned.
- DataSize - Supplies a pointer that on input contains the size of the data
- buffer. On output, the actual size of the data will be returned.
- Data - Supplies a pointer where the variable value will be returned.
- Return Value:
- EFI_SUCCESS on success.
- EFI_NOT_FOUND if the variable was not found.
- EFI_BUFFER_TOO_SMALL if the supplied buffer is not big enough.
- EFI_INVALID_PARAMETER if the variable name, vendor GUID, or data size is
- NULL.
- EFI_DEVICE_ERROR if a hardware error occurred trying to read the variable.
- EFI_SECURITY_VIOLATION if the variable could not be retrieved due to an
- authentication failure.
- --*/
- EFIAPI
- EFI_STATUS
- EfiCoreQueryVariableInfo (
- UINT32 Attributes,
- UINT64 *MaximumVariableStorageSize,
- UINT64 *RemainingVariableStorageSize,
- UINT64 *MaximumVariableSize
- );
- /*++
- Routine Description:
- This routine returns information about EFI variables.
- Arguments:
- Attributes - Supplies a bitmask of attributes specifying the type of
- variables on which to return information.
- MaximumVariableStorageSize - Supplies a pointer where the maximum size of
- storage space for EFI variables with the given attributes will be
- returned.
- RemainingVariableStorageSize - Supplies a pointer where the remaining size
- of the storage space available for EFI variables associated with the
- attributes specified will be returned.
- MaximumVariableSize - Supplies a pointer where the maximum size of an
- individual variable will be returned on success.
- Return Value:
- EFI_SUCCESS if a valid answer was returned.
- EFI_UNSUPPORTED if the attribute is not supported on this platform.
- EFI_INVALID_PARAMETER if an invalid combination of attributes was supplied.
- --*/
- EFI_STATUS
- EfipCoreInitializeVariableServices (
- VOID
- );
- /*++
- Routine Description:
- This routine initialize core variable services.
- Arguments:
- None.
- Return Value:
- EFI Status code.
- --*/
- VOID
- EfipCoreVariableHandleExitBootServices (
- VOID
- );
- /*++
- Routine Description:
- This routine is called when leaving boot services.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- VOID
- EfipCoreVariableHandleVirtualAddressChange (
- VOID
- );
- /*++
- Routine Description:
- This routine is called to change from physical to virtual mode.
- Arguments:
- None.
- Return Value:
- None.
- --*/
- //
- // Utility functions
- //
- EFIAPI
- VOID
- EfiCoreCopyMemory (
- VOID *Destination,
- VOID *Source,
- UINTN Length
- );
- /*++
- Routine Description:
- This routine copies the contents of one buffer to another.
- Arguments:
- Destination - Supplies a pointer to the destination of the copy.
- Source - Supplies a pointer to the source of the copy.
- Length - Supplies the number of bytes to copy.
- Return Value:
- None.
- --*/
- EFIAPI
- VOID
- EfiCoreSetMemory (
- VOID *Buffer,
- UINTN Size,
- UINT8 Value
- );
- /*++
- Routine Description:
- This routine fills a buffer with a specified value.
- Arguments:
- Buffer - Supplies a pointer to the buffer to fill.
- Size - Supplies the size of the buffer in bytes.
- Value - Supplies the value to fill the buffer with.
- Return Value:
- None.
- --*/
- INTN
- EfiCoreCompareMemory (
- VOID *FirstBuffer,
- VOID *SecondBuffer,
- UINTN Length
- );
- /*++
- Routine Description:
- This routine compares the contents of two buffers for equality.
- Arguments:
- FirstBuffer - Supplies a pointer to the first buffer to compare.
- SecondBuffer - Supplies a pointer to the second buffer to compare.
- Length - Supplies the number of bytes to compare.
- Return Value:
- 0 if the buffers are identical.
- Returns the first mismatched byte as
- First[MismatchIndex] - Second[MismatchIndex].
- --*/
- BOOLEAN
- EfiCoreCompareGuids (
- EFI_GUID *FirstGuid,
- EFI_GUID *SecondGuid
- );
- /*++
- Routine Description:
- This routine compares two GUIDs.
- Arguments:
- FirstGuid - Supplies a pointer to the first GUID.
- SecondGuid - Supplies a pointer to the second GUID.
- Return Value:
- TRUE if the GUIDs are equal.
- FALSE if the GUIDs are different.
- --*/
- UINTN
- EfiCoreStringLength (
- CHAR16 *String
- );
- /*++
- Routine Description:
- This routine returns the length of the given string, in characters (not
- bytes).
- Arguments:
- String - Supplies a pointer to the string.
- Return Value:
- Returns the number of characters in the string.
- --*/
- EFIAPI
- EFI_STATUS
- EfiCoreCalculateCrc32 (
- VOID *Data,
- UINTN DataSize,
- UINT32 *Crc32
- );
- /*++
- Routine Description:
- This routine computes the 32-bit CRC for a data buffer.
- Arguments:
- Data - Supplies a pointer to the buffer to compute the CRC on.
- DataSize - Supplies the size of the data buffer in bytes.
- Crc32 - Supplies a pointer where the 32-bit CRC will be returned.
- Return Value:
- EFI_SUCCESS on success.
- EFI_INVALID_PARAMETER if any parameter is NULL, or the data size is zero.
- --*/
|