@@ -383,7 +383,7 @@ EbcCreateThunks (
return EFI_INVALID_PARAMETER;
}
- InstructionBuffer = AllocatePool (sizeof (EBC_INSTRUCTION_BUFFER));
+ InstructionBuffer = EbcAllocatePoolForThunk (sizeof (EBC_INSTRUCTION_BUFFER));
if (InstructionBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1410,3 +1410,26 @@ EbcVmTestUnsupported (
return EFI_UNSUPPORTED;
}
+/**
+ Allocates a buffer of type EfiBootServicesCode.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+EbcAllocatePoolForThunk (
+ IN UINTN AllocationSize
+ )
+{
+ VOID *Buffer;
+ EFI_STATUS Status;
+
+ Status = gBS->AllocatePool (EfiBootServicesCode, AllocationSize, &Buffer);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+ return Buffer;
+}
@@ -246,4 +246,18 @@ typedef struct {
CR(a, EBC_PROTOCOL_PRIVATE_DATA, EbcProtocol, EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE)
+/**
+ Allocates a buffer of type EfiBootServicesCode.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+EbcAllocatePoolForThunk (
+ IN UINTN AllocationSize
+ );
+
#endif // #ifndef _EBC_INT_H_
@@ -484,7 +484,7 @@ EbcCreateThunks (
ThunkSize = sizeof(mInstructionBufferTemplate);
- Ptr = AllocatePool (sizeof(mInstructionBufferTemplate));
+ Ptr = EbcAllocatePoolForThunk (sizeof(mInstructionBufferTemplate));
if (Ptr == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -403,7 +403,7 @@ EbcCreateThunks (
//
Size = EBC_THUNK_SIZE + EBC_THUNK_ALIGNMENT - 1;
ThunkSize = Size;
- Ptr = AllocatePool (Size);
+ Ptr = EbcAllocatePoolForThunk (Size);
if (Ptr == NULL) {
return EFI_OUT_OF_RESOURCES;
@@ -441,7 +441,7 @@ EbcCreateThunks (
ThunkSize = sizeof(mInstructionBufferTemplate);
- Ptr = AllocatePool (sizeof(mInstructionBufferTemplate));
+ Ptr = EbcAllocatePoolForThunk (sizeof(mInstructionBufferTemplate));
if (Ptr == NULL) {
return EFI_OUT_OF_RESOURCES;