microsoft/mu_feature_ffa

Public

mirrored fromhttps://github.com/microsoft/mu_feature_ffaAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ef8c8ffe3e9cd9f6fd3732ade9463d4841c3472e

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

FfaFeaturePkg/Library/SecurePartitionMemoryAllocationLib/SecurePartitionMemoryAllocationLib.h

166lines · modecode

1/** @file
2 Support routines for memory allocation routines based on Standalone MM Core internal functions.
3
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2016 - 2021, ARM Limited. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9**/
10
11#ifndef SECURE_PARTITION_MEM_ALLOC_LIB_H_
12#define SECURE_PARTITION_MEM_ALLOC_LIB_H_
13
14/**
15 Allocates pages from the memory map.
16
17 @param Type The type of allocation to perform.
18 @param MemoryType The type of memory to turn the allocated pages
19 into.
20 @param NumberOfPages The number of pages to allocate.
21 @param Memory A pointer to receive the base allocated memory
22 address.
23
24 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
25 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
26 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
27 @retval EFI_SUCCESS Pages successfully allocated.
28
29**/
30EFI_STATUS
31EFIAPI
32MmAllocatePages (
33 IN EFI_ALLOCATE_TYPE Type,
34 IN EFI_MEMORY_TYPE MemoryType,
35 IN UINTN NumberOfPages,
36 OUT EFI_PHYSICAL_ADDRESS *Memory
37 );
38
39/**
40 Frees previous allocated pages.
41
42 @param Memory Base address of memory being freed.
43 @param NumberOfPages The number of pages to free.
44
45 @retval EFI_NOT_FOUND Could not find the entry that covers the range.
46 @retval EFI_INVALID_PARAMETER Address not aligned.
47 @return EFI_SUCCESS Pages successfully freed.
48
49**/
50EFI_STATUS
51EFIAPI
52MmFreePages (
53 IN EFI_PHYSICAL_ADDRESS Memory,
54 IN UINTN NumberOfPages
55 );
56
57/**
58 Allocate pool of a particular type.
59
60 @param PoolType Type of pool to allocate.
61 @param Size The amount of pool to allocate.
62 @param Buffer The address to return a pointer to the allocated
63 pool.
64
65 @retval EFI_INVALID_PARAMETER PoolType not valid.
66 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
67 @retval EFI_SUCCESS Pool successfully allocated.
68
69**/
70EFI_STATUS
71EFIAPI
72MmAllocatePool (
73 IN EFI_MEMORY_TYPE PoolType,
74 IN UINTN Size,
75 OUT VOID **Buffer
76 );
77
78/**
79 Frees pool.
80
81 @param Buffer The allocated pool entry to free.
82
83 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
84 @retval EFI_SUCCESS Pool successfully freed.
85
86**/
87EFI_STATUS
88EFIAPI
89MmFreePool (
90 IN VOID *Buffer
91 );
92
93/**
94 Allocates pages from the memory map.
95
96 @param Type The type of allocation to perform.
97 @param MemoryType The type of memory to turn the allocated pages
98 into.
99 @param NumberOfPages The number of pages to allocate.
100 @param Memory A pointer to receive the base allocated memory
101 address.
102
103 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
104 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
105 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
106 @retval EFI_SUCCESS Pages successfully allocated.
107
108**/
109EFI_STATUS
110EFIAPI
111MmInternalAllocatePages (
112 IN EFI_ALLOCATE_TYPE Type,
113 IN EFI_MEMORY_TYPE MemoryType,
114 IN UINTN NumberOfPages,
115 OUT EFI_PHYSICAL_ADDRESS *Memory
116 );
117
118/**
119 Frees previous allocated pages.
120
121 @param Memory Base address of memory being freed.
122 @param NumberOfPages The number of pages to free.
123
124 @retval EFI_NOT_FOUND Could not find the entry that covers the range.
125 @retval EFI_INVALID_PARAMETER Address not aligned.
126 @return EFI_SUCCESS Pages successfully freed.
127
128**/
129EFI_STATUS
130EFIAPI
131MmInternalFreePages (
132 IN EFI_PHYSICAL_ADDRESS Memory,
133 IN UINTN NumberOfPages
134 );
135
136/**
137 Add free MMRAM region for use by memory service.
138
139 @param MemBase Base address of memory region.
140 @param MemLength Length of the memory region.
141 @param Type Memory type.
142 @param Attributes Memory region state.
143
144**/
145VOID
146MmAddMemoryRegion (
147 IN EFI_PHYSICAL_ADDRESS MemBase,
148 IN UINT64 MemLength,
149 IN EFI_MEMORY_TYPE Type,
150 IN UINT64 Attributes
151 );
152
153/**
154 Called to initialize the memory service.
155
156 @param MmramRangeCount Number of MMRAM Regions
157 @param MmramRanges Pointer to MMRAM Descriptors
158
159**/
160VOID
161MmInitializeMemoryServices (
162 IN UINTN MmramRangeCount,
163 IN EFI_MMRAM_DESCRIPTOR *MmramRanges
164 );
165
166#endif // SECURE_PARTITION_MEM_ALLOC_LIB_H_
167