]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h
Use SmmMemLib to check communication buffer.
[mirror_edk2.git] / MdeModulePkg / Library / PiSmmCoreMemoryAllocationLib / PiSmmCoreMemoryAllocationServices.h
1 /** @file
2 Contains function prototypes for Memory Services in the SMM Core.
3
4 This header file borrows the PiSmmCore Memory Allocation services as the primitive
5 for memory allocation.
6
7 Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef _PI_SMM_CORE_MEMORY_ALLOCATION_SERVICES_H_
19 #define _PI_SMM_CORE_MEMORY_ALLOCATION_SERVICES_H_
20
21 typedef struct {
22 UINTN Signature;
23 ///
24 /// The ImageHandle passed into the entry point of the SMM IPL. This ImageHandle
25 /// is used by the SMM Core to fill in the ParentImageHandle field of the Loaded
26 /// Image Protocol for each SMM Driver that is dispatched by the SMM Core.
27 ///
28 EFI_HANDLE SmmIplImageHandle;
29 ///
30 /// The number of SMRAM ranges passed from the SMM IPL to the SMM Core. The SMM
31 /// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
32 ///
33 UINTN SmramRangeCount;
34 ///
35 /// A table of SMRAM ranges passed from the SMM IPL to the SMM Core. The SMM
36 /// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
37 ///
38 EFI_SMRAM_DESCRIPTOR *SmramRanges;
39 } SMM_CORE_PRIVATE_DATA;
40
41 /**
42 Called to initialize the memory service.
43
44 @param SmramRangeCount Number of SMRAM Regions
45 @param SmramRanges Pointer to SMRAM Descriptors
46
47 **/
48 VOID
49 SmmInitializeMemoryServices (
50 IN UINTN SmramRangeCount,
51 IN EFI_SMRAM_DESCRIPTOR *SmramRanges
52 );
53
54 /**
55 Allocates pages from the memory map.
56
57 @param Type The type of allocation to perform
58 @param MemoryType The type of memory to turn the allocated pages
59 into
60 @param NumberOfPages The number of pages to allocate
61 @param Memory A pointer to receive the base allocated memory
62 address
63
64 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
65 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
66 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
67 @retval EFI_SUCCESS Pages successfully allocated.
68
69 **/
70 EFI_STATUS
71 EFIAPI
72 SmmAllocatePages (
73 IN EFI_ALLOCATE_TYPE Type,
74 IN EFI_MEMORY_TYPE MemoryType,
75 IN UINTN NumberOfPages,
76 OUT EFI_PHYSICAL_ADDRESS *Memory
77 );
78
79 /**
80 Frees previous allocated pages.
81
82 @param Memory Base address of memory being freed
83 @param NumberOfPages The number of pages to free
84
85 @retval EFI_NOT_FOUND Could not find the entry that covers the range
86 @retval EFI_INVALID_PARAMETER Address not aligned
87 @return EFI_SUCCESS Pages successfully freed.
88
89 **/
90 EFI_STATUS
91 EFIAPI
92 SmmFreePages (
93 IN EFI_PHYSICAL_ADDRESS Memory,
94 IN UINTN NumberOfPages
95 );
96
97 /**
98 Allocate pool of a particular type.
99
100 @param PoolType Type of pool to allocate
101 @param Size The amount of pool to allocate
102 @param Buffer The address to return a pointer to the allocated
103 pool
104
105 @retval EFI_INVALID_PARAMETER PoolType not valid
106 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
107 @retval EFI_SUCCESS Pool successfully allocated.
108
109 **/
110 EFI_STATUS
111 EFIAPI
112 SmmAllocatePool (
113 IN EFI_MEMORY_TYPE PoolType,
114 IN UINTN Size,
115 OUT VOID **Buffer
116 );
117
118 /**
119 Frees pool.
120
121 @param Buffer The allocated pool entry to free
122
123 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
124 @retval EFI_SUCCESS Pool successfully freed.
125
126 **/
127 EFI_STATUS
128 EFIAPI
129 SmmFreePool (
130 IN VOID *Buffer
131 );
132
133 #endif