6a2cd50136b3e9a919effca35fd0092c3ddce068
[mirror_edk2.git] / MdePkg / Include / Ppi / ReadOnlyVariable2.h
1 /** @file
2 This file declares Read-only Variable Service2 PPI.
3 This ppi permits read-only access to the UEFI variable store during the PEI phase.
4
5 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 @par Revision Reference:
15 This PPI is introduced in PI Version 1.0.
16
17 **/
18
19 #ifndef __PEI_READ_ONLY_VARIABLE2_PPI_H__
20 #define __PEI_READ_ONLY_VARIABLE2_PPI_H__
21
22 #define EFI_PEI_READ_ONLY_VARIABLE2_PPI_GUID \
23 { 0x2ab86ef5, 0xecb5, 0x4134, { 0xb5, 0x56, 0x38, 0x54, 0xca, 0x1f, 0xe1, 0xb4 } }
24
25
26 typedef struct _EFI_PEI_READ_ONLY_VARIABLE2_PPI EFI_PEI_READ_ONLY_VARIABLE2_PPI;
27
28 /**
29 This service retrieves a variable's value using its name and GUID.
30
31 Read the specified variable from the UEFI variable store. If the Data
32 buffer is too small to hold the contents of the variable,
33 the error EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the
34 required buffer size to obtain the data.
35
36 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.
37 @param VariableName A pointer to a null-terminated string that is the variable's name.
38 @param VariableGuid A pointer to an EFI_GUID that is the variable's GUID. The combination of
39 VariableGuid and VariableName must be unique.
40 @param Attributes If non-NULL, on return, points to the variable's attributes.
41 @param DataSize On entry, points to the size in bytes of the Data buffer.
42 On return, points to the size of the data returned in Data.
43 @param Data Points to the buffer which will hold the returned variable value.
44
45 @retval EFI_SUCCESS The variable was read successfully.
46 @retval EFI_NOT_FOUND The variable could not be found.
47 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the resulting data.
48 DataSize is updated with the size required for
49 the specified variable.
50 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.
51 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.
52
53 **/
54 typedef
55 EFI_STATUS
56 (EFIAPI *EFI_PEI_GET_VARIABLE2)(
57 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
58 IN CONST CHAR16 *VariableName,
59 IN CONST EFI_GUID *VariableGuid,
60 OUT UINT32 *Attributes,
61 IN OUT UINTN *DataSize,
62 OUT VOID *Data
63 );
64
65
66 /**
67 Return the next variable name and GUID.
68
69 This function is called multiple times to retrieve the VariableName
70 and VariableGuid of all variables currently available in the system.
71 On each call, the previous results are passed into the interface,
72 and, on return, the interface returns the data for the next
73 interface. When the entire variable list has been returned,
74 EFI_NOT_FOUND is returned.
75
76 @param This A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.
77
78 @param VariableNameSize On entry, points to the size of the buffer pointed to by VariableName.
79 On return, the size of the variable name buffer.
80 @param VariableName On entry, a pointer to a null-terminated string that is the variable's name.
81 On return, points to the next variable's null-terminated name string.
82
83 @param VariableGuid On entry, a pointer to an EFI_GUID that is the variable's GUID.
84 On return, a pointer to the next variable's GUID.
85
86 @retval EFI_SUCCESS The variable was read successfully.
87 @retval EFI_NOT_FOUND The variable could not be found.
88 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the resulting
89 data. VariableNameSize is updated with the size
90 required for the specified variable.
91 @retval EFI_INVALID_PARAMETER VariableName, VariableGuid or
92 VariableNameSize is NULL.
93 @retval EFI_DEVICE_ERROR The variable could not be retrieved because of a device error.
94
95 **/
96 typedef
97 EFI_STATUS
98 (EFIAPI *EFI_PEI_GET_NEXT_VARIABLE_NAME2)(
99 IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
100 IN OUT UINTN *VariableNameSize,
101 IN OUT CHAR16 *VariableName,
102 IN OUT EFI_GUID *VariableGuid
103 );
104
105 ///
106 /// This PPI provides a lightweight, read-only variant of the full EFI
107 /// variable services.
108 ///
109 struct _EFI_PEI_READ_ONLY_VARIABLE2_PPI {
110 EFI_PEI_GET_VARIABLE2 GetVariable;
111 EFI_PEI_GET_NEXT_VARIABLE_NAME2 NextVariableName;
112 };
113
114 extern EFI_GUID gEfiPeiReadOnlyVariable2PpiGuid;
115
116 #endif