mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-26 15:14:02 +02:00
Ring3: Added Ring3AllocatePool() and Ring3FreePool().
This commit is contained in:
parent
10cb3149cd
commit
b71accf0db
@ -26,8 +26,8 @@ EFI_BOOT_SERVICES mBootServices = {
|
|||||||
(EFI_ALLOCATE_PAGES)Ring3AllocatePages, // AllocatePages
|
(EFI_ALLOCATE_PAGES)Ring3AllocatePages, // AllocatePages
|
||||||
(EFI_FREE_PAGES)Ring3FreePages, // FreePages
|
(EFI_FREE_PAGES)Ring3FreePages, // FreePages
|
||||||
(EFI_GET_MEMORY_MAP)Ring3GetMemoryMap, // GetMemoryMap
|
(EFI_GET_MEMORY_MAP)Ring3GetMemoryMap, // GetMemoryMap
|
||||||
(EFI_ALLOCATE_POOL)CoreAllocatePool, // AllocatePool
|
(EFI_ALLOCATE_POOL)Ring3AllocatePool, // AllocatePool
|
||||||
(EFI_FREE_POOL)CoreFreePool, // FreePool
|
(EFI_FREE_POOL)Ring3FreePool, // FreePool
|
||||||
(EFI_CREATE_EVENT)Ring3CreateEvent, // CreateEvent
|
(EFI_CREATE_EVENT)Ring3CreateEvent, // CreateEvent
|
||||||
(EFI_SET_TIMER)Ring3SetTimer, // SetTimer
|
(EFI_SET_TIMER)Ring3SetTimer, // SetTimer
|
||||||
(EFI_WAIT_FOR_EVENT)Ring3WaitForEvent, // WaitForEvent
|
(EFI_WAIT_FOR_EVENT)Ring3WaitForEvent, // WaitForEvent
|
||||||
|
@ -132,6 +132,44 @@ Ring3GetMemoryMap (
|
|||||||
OUT UINT32 *DescriptorVersion
|
OUT UINT32 *DescriptorVersion
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allocate pool of a particular type.
|
||||||
|
|
||||||
|
@param PoolType Type of pool to allocate
|
||||||
|
@param Size The amount of pool to allocate
|
||||||
|
@param Buffer The address to return a pointer to the allocated
|
||||||
|
pool
|
||||||
|
|
||||||
|
@retval EFI_INVALID_PARAMETER Buffer is NULL.
|
||||||
|
PoolType is in the range EfiMaxMemoryType..0x6FFFFFFF.
|
||||||
|
PoolType is EfiPersistentMemory.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
|
||||||
|
@retval EFI_SUCCESS Pool successfully allocated.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
Ring3AllocatePool (
|
||||||
|
IN EFI_MEMORY_TYPE PoolType,
|
||||||
|
IN UINTN Size,
|
||||||
|
OUT VOID **Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Frees pool.
|
||||||
|
|
||||||
|
@param Buffer The allocated pool entry to free
|
||||||
|
|
||||||
|
@retval EFI_INVALID_PARAMETER Buffer is not a valid value.
|
||||||
|
@retval EFI_SUCCESS Pool successfully freed.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
Ring3FreePool (
|
||||||
|
IN VOID *Buffer
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates an event.
|
Creates an event.
|
||||||
|
|
||||||
|
@ -18,6 +18,34 @@
|
|||||||
|
|
||||||
BOOLEAN mOnGuarding = FALSE;
|
BOOLEAN mOnGuarding = FALSE;
|
||||||
|
|
||||||
|
STATIC UINTN mMemoryTypes[EfiMaxMemoryType];
|
||||||
|
STATIC UINTN mNumberOfUsers = 0;
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
UINTN
|
||||||
|
EFIAPI
|
||||||
|
GetMemoryType (
|
||||||
|
IN UINTN UserPageTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN Index;
|
||||||
|
|
||||||
|
for (Index = 0; Index < mNumberOfUsers; ++Index) {
|
||||||
|
if (mMemoryTypes[Index] == UserPageTable) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Index == mNumberOfUsers) {
|
||||||
|
++mNumberOfUsers;
|
||||||
|
mMemoryTypes[Index] = UserPageTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (mNumberOfUsers <= EfiMaxMemoryType);
|
||||||
|
|
||||||
|
return Index;
|
||||||
|
}
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -179,6 +207,32 @@ Ring3GetMemoryMap (
|
|||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
Ring3AllocatePool (
|
||||||
|
IN EFI_MEMORY_TYPE PoolType,
|
||||||
|
IN UINTN Size,
|
||||||
|
OUT VOID **Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN CurrentUser;
|
||||||
|
|
||||||
|
CurrentUser = (UINTN)SysCall (SysCallGetUserPageTable, 0);
|
||||||
|
|
||||||
|
PoolType = GetMemoryType (CurrentUser);
|
||||||
|
|
||||||
|
return CoreAllocatePool (PoolType, Size, Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
Ring3FreePool (
|
||||||
|
IN VOID *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return CoreFreePool (Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
Ring3CreateEvent (
|
Ring3CreateEvent (
|
||||||
@ -606,7 +660,7 @@ Ring3LocateHandleBuffer (
|
|||||||
&& (Buffer != NULL) && (*Buffer != NULL)) {
|
&& (Buffer != NULL) && (*Buffer != NULL)) {
|
||||||
PoolSize = *NumberHandles * sizeof (EFI_HANDLE *);
|
PoolSize = *NumberHandles * sizeof (EFI_HANDLE *);
|
||||||
|
|
||||||
Status = CoreAllocatePool (EfiRing3MemoryType, PoolSize, &Pool);
|
Status = Ring3AllocatePool (EfiRing3MemoryType, PoolSize, &Pool);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@ -672,7 +726,7 @@ Ring3InstallMultipleProtocolInterfaces (
|
|||||||
}
|
}
|
||||||
VA_END (Marker);
|
VA_END (Marker);
|
||||||
|
|
||||||
Status = CoreAllocatePool (
|
Status = Ring3AllocatePool (
|
||||||
EfiRing3MemoryType,
|
EfiRing3MemoryType,
|
||||||
NumberOfArguments * sizeof (VOID *),
|
NumberOfArguments * sizeof (VOID *),
|
||||||
(VOID **)&Arguments
|
(VOID **)&Arguments
|
||||||
@ -695,8 +749,8 @@ Ring3InstallMultipleProtocolInterfaces (
|
|||||||
Arguments
|
Arguments
|
||||||
);
|
);
|
||||||
|
|
||||||
CoreFreePool (Arguments);
|
Ring3FreePool (Arguments);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
@ -63,6 +63,7 @@ EFI_MEMORY_TYPE_STATISTICS mMemoryTypeStatistics[EfiMaxMemoryType + 1] = {
|
|||||||
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiPalCode
|
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiPalCode
|
||||||
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiPersistentMemory
|
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiPersistentMemory
|
||||||
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiUnacceptedMemoryType
|
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiUnacceptedMemoryType
|
||||||
|
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiRing3MemoryType
|
||||||
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // EfiMaxMemoryType
|
{ 0, MAX_ALLOC_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // EfiMaxMemoryType
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -86,6 +87,7 @@ EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1] = {
|
|||||||
{ EfiPalCode, 0 },
|
{ EfiPalCode, 0 },
|
||||||
{ EfiPersistentMemory, 0 },
|
{ EfiPersistentMemory, 0 },
|
||||||
{ EfiGcdMemoryTypeUnaccepted, 0 },
|
{ EfiGcdMemoryTypeUnaccepted, 0 },
|
||||||
|
{ EfiRing3MemoryType, 0 },
|
||||||
{ EfiMaxMemoryType, 0 }
|
{ EfiMaxMemoryType, 0 }
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
|
@ -317,12 +317,11 @@ FreeUserSpaceDriver (
|
|||||||
UserDriver = BASE_CR (Link, USER_SPACE_DRIVER, Link);
|
UserDriver = BASE_CR (Link, USER_SPACE_DRIVER, Link);
|
||||||
|
|
||||||
if (UserDriver->CoreWrapper == CoreWrapper) {
|
if (UserDriver->CoreWrapper == CoreWrapper) {
|
||||||
break;
|
RemoveEntryList (&UserDriver->Link);
|
||||||
|
FreePool (UserDriver);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveEntryList (&UserDriver->Link);
|
|
||||||
FreePool (UserDriver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -1457,6 +1456,13 @@ CallBootService (
|
|||||||
FreePool ((VOID *)Argument5);
|
FreePool ((VOID *)Argument5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SysCallGetUserPageTable:
|
||||||
|
//
|
||||||
|
// No Arguments
|
||||||
|
//
|
||||||
|
Status = (EFI_STATUS)gUserPageTable;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DEBUG ((DEBUG_ERROR, "Ring0: Unknown syscall type.\n"));
|
DEBUG ((DEBUG_ERROR, "Ring0: Unknown syscall type.\n"));
|
||||||
|
@ -2060,6 +2060,10 @@ typedef enum {
|
|||||||
SysCallUnicodeStrUpr,
|
SysCallUnicodeStrUpr,
|
||||||
SysCallUnicodeFatToStr,
|
SysCallUnicodeFatToStr,
|
||||||
SysCallUnicodeStrToFat,
|
SysCallUnicodeStrToFat,
|
||||||
|
//
|
||||||
|
// Helper functions
|
||||||
|
//
|
||||||
|
SysCallGetUserPageTable,
|
||||||
SysCallMax
|
SysCallMax
|
||||||
} SYS_CALL_TYPE;
|
} SYS_CALL_TYPE;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user