microsoft/mu_feature_ffa

Public

mirrored from https://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 · modeblame

734c30acKun Qin1 years ago1/** @file
2Support routines for memory allocation routines based on Standalone MM Core internal functions.
3
4Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5Copyright (c) 2016 - 2021, ARM Limited. All rights reserved.<BR>
6
7SPDX-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/**
15Allocates 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
19into.
20@param NumberOfPages The number of pages to allocate.
21@param Memory A pointer to receive the base allocated memory
22address.
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 (
33IN EFI_ALLOCATE_TYPE Type,
34IN EFI_MEMORY_TYPE MemoryType,
35IN UINTN NumberOfPages,
36OUT EFI_PHYSICAL_ADDRESS *Memory
37);
38
39/**
40Frees 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 (
53IN EFI_PHYSICAL_ADDRESS Memory,
54IN UINTN NumberOfPages
55);
56
57/**
58Allocate 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
63pool.
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 (
73IN EFI_MEMORY_TYPE PoolType,
74IN UINTN Size,
75OUT VOID **Buffer
76);
77
78/**
79Frees 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 (
90IN VOID *Buffer
91);
92
93/**
94Allocates 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
98into.
99@param NumberOfPages The number of pages to allocate.
100@param Memory A pointer to receive the base allocated memory
101address.
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 (
112IN EFI_ALLOCATE_TYPE Type,
113IN EFI_MEMORY_TYPE MemoryType,
114IN UINTN NumberOfPages,
115OUT EFI_PHYSICAL_ADDRESS *Memory
116);
117
118/**
119Frees 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 (
132IN EFI_PHYSICAL_ADDRESS Memory,
133IN UINTN NumberOfPages
134);
135
136/**
137Add 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 (
147IN EFI_PHYSICAL_ADDRESS MemBase,
148IN UINT64 MemLength,
149IN EFI_MEMORY_TYPE Type,
150IN UINT64 Attributes
151);
152
153/**
154Called to initialize the memory service.
155
156@param MmramRangeCount Number of MMRAM Regions
157@param MmramRanges Pointer to MMRAM Descriptors
158
159**/
160VOID
161MmInitializeMemoryServices (
162IN UINTN MmramRangeCount,
163IN EFI_MMRAM_DESCRIPTOR *MmramRanges
164);
165
166#endif // SECURE_PARTITION_MEM_ALLOC_LIB_H_