1 | /** @file
|
---|
2 |
|
---|
3 | EFI Memory Attribute Protocol provides retrieval and update service
|
---|
4 | for memory attributes in EFI environment.
|
---|
5 |
|
---|
6 | Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
|
---|
7 | Copyright (c) 2023, Google LLC. All rights reserved.<BR>
|
---|
8 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
9 |
|
---|
10 | **/
|
---|
11 |
|
---|
12 | #ifndef EFI_MEMORY_ATTRIBUTE_H_
|
---|
13 | #define EFI_MEMORY_ATTRIBUTE_H_
|
---|
14 |
|
---|
15 | #define EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID \
|
---|
16 | { \
|
---|
17 | 0xf4560cf6, 0x40ec, 0x4b4a, { 0xa1, 0x92, 0xbf, 0x1d, 0x57, 0xd0, 0xb1, 0x89 } \
|
---|
18 | }
|
---|
19 |
|
---|
20 | typedef struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL EFI_MEMORY_ATTRIBUTE_PROTOCOL;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | This function set given attributes of the memory region specified by
|
---|
24 | BaseAddress and Length.
|
---|
25 |
|
---|
26 | The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and EFI_MEMORY_RO.
|
---|
27 |
|
---|
28 | @param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
---|
29 | @param BaseAddress The physical address that is the start address of
|
---|
30 | a memory region.
|
---|
31 | @param Length The size in bytes of the memory region.
|
---|
32 | @param Attributes The bit mask of attributes to set for the memory
|
---|
33 | region.
|
---|
34 |
|
---|
35 | @retval EFI_SUCCESS The attributes were set for the memory region.
|
---|
36 | @retval EFI_INVALID_PARAMETER Length is zero.
|
---|
37 | Attributes specified an illegal combination of
|
---|
38 | attributes that cannot be set together.
|
---|
39 | @retval EFI_UNSUPPORTED The processor does not support one or more
|
---|
40 | bytes of the memory resource range specified
|
---|
41 | by BaseAddress and Length.
|
---|
42 | The bit mask of attributes is not supported for
|
---|
43 | the memory resource range specified by
|
---|
44 | BaseAddress and Length.
|
---|
45 | @retval EFI_OUT_OF_RESOURCES Requested attributes cannot be applied due to
|
---|
46 | lack of system resources.
|
---|
47 | @retval EFI_ACCESS_DENIED Attributes for the requested memory region are
|
---|
48 | controlled by system firmware and cannot be
|
---|
49 | updated via the protocol.
|
---|
50 |
|
---|
51 | **/
|
---|
52 | typedef
|
---|
53 | EFI_STATUS
|
---|
54 | (EFIAPI *EFI_SET_MEMORY_ATTRIBUTES)(
|
---|
55 | IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
---|
56 | IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
---|
57 | IN UINT64 Length,
|
---|
58 | IN UINT64 Attributes
|
---|
59 | );
|
---|
60 |
|
---|
61 | /**
|
---|
62 | This function clears given attributes of the memory region specified by
|
---|
63 | BaseAddress and Length.
|
---|
64 |
|
---|
65 | The valid Attributes is EFI_MEMORY_RP, EFI_MEMORY_XP, and EFI_MEMORY_RO.
|
---|
66 |
|
---|
67 | @param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
---|
68 | @param BaseAddress The physical address that is the start address of
|
---|
69 | a memory region.
|
---|
70 | @param Length The size in bytes of the memory region.
|
---|
71 | @param Attributes The bit mask of attributes to clear for the memory
|
---|
72 | region.
|
---|
73 |
|
---|
74 | @retval EFI_SUCCESS The attributes were cleared for the memory region.
|
---|
75 | @retval EFI_INVALID_PARAMETER Length is zero.
|
---|
76 | Attributes specified an illegal combination of
|
---|
77 | attributes that cannot be cleared together.
|
---|
78 | @retval EFI_UNSUPPORTED The processor does not support one or more
|
---|
79 | bytes of the memory resource range specified
|
---|
80 | by BaseAddress and Length.
|
---|
81 | The bit mask of attributes is not supported for
|
---|
82 | the memory resource range specified by
|
---|
83 | BaseAddress and Length.
|
---|
84 | @retval EFI_OUT_OF_RESOURCES Requested attributes cannot be applied due to
|
---|
85 | lack of system resources.
|
---|
86 | @retval EFI_ACCESS_DENIED Attributes for the requested memory region are
|
---|
87 | controlled by system firmware and cannot be
|
---|
88 | updated via the protocol.
|
---|
89 |
|
---|
90 | **/
|
---|
91 | typedef
|
---|
92 | EFI_STATUS
|
---|
93 | (EFIAPI *EFI_CLEAR_MEMORY_ATTRIBUTES)(
|
---|
94 | IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
---|
95 | IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
---|
96 | IN UINT64 Length,
|
---|
97 | IN UINT64 Attributes
|
---|
98 | );
|
---|
99 |
|
---|
100 | /**
|
---|
101 | This function retrieves the attributes of the memory region specified by
|
---|
102 | BaseAddress and Length. If different attributes are obtained from different
|
---|
103 | parts of the memory region, EFI_NO_MAPPING will be returned.
|
---|
104 |
|
---|
105 | @param This The EFI_MEMORY_ATTRIBUTE_PROTOCOL instance.
|
---|
106 | @param BaseAddress The physical address that is the start address of
|
---|
107 | a memory region.
|
---|
108 | @param Length The size in bytes of the memory region.
|
---|
109 | @param Attributes Pointer to attributes returned.
|
---|
110 |
|
---|
111 | @retval EFI_SUCCESS The attributes got for the memory region.
|
---|
112 | @retval EFI_INVALID_PARAMETER Length is zero.
|
---|
113 | Attributes is NULL.
|
---|
114 | @retval EFI_NO_MAPPING Attributes are not consistent cross the memory
|
---|
115 | region.
|
---|
116 | @retval EFI_UNSUPPORTED The processor does not support one or more
|
---|
117 | bytes of the memory resource range specified
|
---|
118 | by BaseAddress and Length.
|
---|
119 |
|
---|
120 | **/
|
---|
121 | typedef
|
---|
122 | EFI_STATUS
|
---|
123 | (EFIAPI *EFI_GET_MEMORY_ATTRIBUTES)(
|
---|
124 | IN EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,
|
---|
125 | IN EFI_PHYSICAL_ADDRESS BaseAddress,
|
---|
126 | IN UINT64 Length,
|
---|
127 | OUT UINT64 *Attributes
|
---|
128 | );
|
---|
129 |
|
---|
130 | ///
|
---|
131 | /// EFI Memory Attribute Protocol provides services to retrieve or update
|
---|
132 | /// attribute of memory in the EFI environment.
|
---|
133 | ///
|
---|
134 | struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL {
|
---|
135 | EFI_GET_MEMORY_ATTRIBUTES GetMemoryAttributes;
|
---|
136 | EFI_SET_MEMORY_ATTRIBUTES SetMemoryAttributes;
|
---|
137 | EFI_CLEAR_MEMORY_ATTRIBUTES ClearMemoryAttributes;
|
---|
138 | };
|
---|
139 |
|
---|
140 | extern EFI_GUID gEfiMemoryAttributeProtocolGuid;
|
---|
141 |
|
---|
142 | #endif
|
---|