Minor code enhancement.
[mirror_edk2.git] / IntelFrameworkPkg / Include / Ppi / ReadOnlyVariable.h
1 /** @file
2 This file declares the Read-only Variable Service PPI, which is required by the framework spec.
3
4 These services provide a lightweight, read-only variant of the full EFI variable services. The
5 reason that these services are read-only is to reduce the complexity of flash management. Also,
6 some implementation of the PEI may use the same physical flash part for variable and PEIM
7 storage; as such, a write command to certain technologies would alter the contents of the entire part,
8 thus making the in situ PEIM execution not follow the required flow.
9
10 Copyright (c) 2006 - 2009, Intel Corporation
11 All rights reserved. This program and the accompanying materials
12 are licensed and made available under the terms and conditions of the BSD License
13 which accompanies this distribution. The full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
15
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18
19 @par Revision Reference:
20 This PPI is defined in PEI CIS
21 Version 0.91.
22 **/
23
24 #ifndef __PEI_READ_ONLY_VARIABLE_PPI_H__
25 #define __PEI_READ_ONLY_VARIABLE_PPI_H__
26
27 #define EFI_PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID \
28 { \
29 0x3cdc90c6, 0x13fb, 0x4a75, {0x9e, 0x79, 0x59, 0xe9, 0xdd, 0x78, 0xb9, 0xfa } \
30 }
31
32 typedef struct _EFI_PEI_READ_ONLY_VARIABLE_PPI EFI_PEI_READ_ONLY_VARIABLE_PPI;
33
34 ///
35 /// Variable attributes
36 ///@{
37 #define EFI_VARIABLE_NON_VOLATILE 0x00000001
38 #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
39 #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
40 ///
41 /// Inconsistent with specification here:
42 /// In Framework Spec, PeiCis0.91, neither the macro or its value is defined.
43 /// Keeping this inconsistancy for backward compatibility.
44 ///
45 #define EFI_VARIABLE_READ_ONLY 0x00000008
46 ///@}
47
48 /**
49 Get Variable value by Name and GUID pair
50
51 @param[in] PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
52 @param[in] VariableName A NULL-terminated Unicode string that is the name of the vendor's variable.
53 @param[in] VendorGuid A unique identifier for the vendor.
54 @param[out] Attributes This OPTIONAL parameter may be either NULL or
55 a pointer to the location in which to return
56 the attributes bitmask for the variable.
57 @param[in,out] DataSize On input, the size in bytes of the return Data buffer.
58 On output, the size of data returned in Data.
59 @param[out] Data The buffer to return the contents of the variable.
60
61 @retval EFI_SUCCESS The function completed successfully.
62 @retval EFI_NOT_FOUND The variable was not found.
63 @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small for the result.
64 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
65 @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
66
67 **/
68 typedef
69 EFI_STATUS
70 (EFIAPI *EFI_PEI_GET_VARIABLE)(
71 IN EFI_PEI_SERVICES **PeiServices,
72 IN CHAR16 *VariableName,
73 IN EFI_GUID *VendorGuid,
74 OUT UINT32 *Attributes OPTIONAL,
75 IN OUT UINTN *DataSize,
76 OUT VOID *Data
77 );
78
79 /**
80 This function can be called multiple times to retrieve the VariableName
81 and VendorGuid of all variables currently available in the system. On each call
82 to GetNextVariableName(), the previous results are passed into the interface,
83 and on output the interface returns the next variable name data. When the
84 entire variable list has been returned, the error EFI_NOT_FOUND is returned.
85
86 @param[in] PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
87 @param[in] VariableNameSize The size of the VariableName buffer.
88 @param[in] VariableName On input, supplies the last VariableName that was
89 returned by GetNextVariableName(). On output, returns the Null-terminated
90 Unicode string of the current variable.
91 @param[in] VendorGuid On input, supplies the last VendorGuid that was
92 returned by GetNextVariableName(). On output, returns the VendorGuid
93 of the current variable.
94
95 @retval EFI_SUCCESS The function completed successfully.
96 @retval EFI_NOT_FOUND The next variable was not found.
97 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.
98 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
99 @retval EFI_DEVICE_ERROR The variable name could not be retrieved due to a hardware error.
100
101 **/
102 typedef
103 EFI_STATUS
104 (EFIAPI *EFI_PEI_GET_NEXT_VARIABLE_NAME)(
105 IN EFI_PEI_SERVICES **PeiServices,
106 IN OUT UINTN *VariableNameSize,
107 IN OUT CHAR16 *VariableName,
108 IN OUT EFI_GUID *VendorGuid
109 );
110
111 ///
112 /// This PPI provides a lightweight, read-only variant of the full EFI
113 /// variable services.
114 ///
115 struct _EFI_PEI_READ_ONLY_VARIABLE_PPI {
116 ///
117 /// Inconsistent with specification here:
118 /// In Framework Spec, PeiCis0.91, the field is named as GetVariable and GetNextVariableName.
119 /// Keeping this inconsistance is for backward compatibility.
120 ///
121 EFI_PEI_GET_VARIABLE PeiGetVariable; ///< A service to ascertain a given variable name.
122 EFI_PEI_GET_NEXT_VARIABLE_NAME PeiGetNextVariableName; ///< A service to ascertain a variable based upon a given, known variable
123 };
124
125 extern EFI_GUID gEfiPeiReadOnlyVariablePpiGuid;
126
127 #endif /* __PEI_READ_ONLY_VARIABLE_PPI_H__ */
128