mirror of https://github.com/acidanthera/audk.git
Ring3: Refactored out MAX_LIST.
This commit is contained in:
parent
16f4111027
commit
72c747b365
|
@ -659,33 +659,44 @@ Ring3InstallMultipleProtocolInterfaces (
|
|||
...
|
||||
)
|
||||
{
|
||||
VA_LIST Marker;
|
||||
VOID *Argument;
|
||||
VOID *ArgList[MAX_LIST];
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
VA_LIST Marker;
|
||||
VOID **Arguments;
|
||||
UINTN NumberOfArguments;
|
||||
UINTN Index;
|
||||
|
||||
VA_START (Marker, Handle);
|
||||
for (Index = 0; Index < MAX_LIST; ++Index) {
|
||||
Argument = VA_ARG (Marker, VOID *);
|
||||
ArgList[Index] = Argument;
|
||||
|
||||
if (Argument == NULL) {
|
||||
break;
|
||||
}
|
||||
NumberOfArguments = 1;
|
||||
while (VA_ARG (Marker, VOID *) != NULL) {
|
||||
++NumberOfArguments;
|
||||
}
|
||||
VA_END (Marker);
|
||||
|
||||
if (Index == MAX_LIST) {
|
||||
DEBUG ((DEBUG_ERROR, "Ring3: Too many arguments\n"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
Status = CoreAllocatePool (
|
||||
EfiRing3MemoryType,
|
||||
NumberOfArguments * sizeof (VOID *),
|
||||
(VOID **)&Arguments
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
return SysCall (
|
||||
SysCallInstallMultipleProtocolInterfaces,
|
||||
2,
|
||||
Handle,
|
||||
ArgList
|
||||
);
|
||||
VA_START (Marker, Handle);
|
||||
for (Index = 0; Index < NumberOfArguments; ++Index) {
|
||||
Arguments[Index] = VA_ARG (Marker, VOID *);
|
||||
}
|
||||
VA_END (Marker);
|
||||
|
||||
Status = SysCall (
|
||||
SysCallInstallMultipleProtocolInterfaces,
|
||||
3,
|
||||
Handle,
|
||||
NumberOfArguments,
|
||||
Arguments
|
||||
);
|
||||
|
||||
CoreFreePool (Arguments);
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
|
@ -796,5 +807,5 @@ CoreFreePoolPagesWithGuard (
|
|||
IN UINTN NoPages
|
||||
)
|
||||
{
|
||||
CoreFreePoolPagesI (PoolType, Memory, NoPages);
|
||||
CoreFreePoolPagesI (EfiRing3MemoryType, Memory, NoPages);
|
||||
}
|
||||
|
|
|
@ -345,6 +345,7 @@ FreeUserSpaceDriver (
|
|||
}
|
||||
|
||||
RemoveEntryList (&UserDriver->Link);
|
||||
FreePool (UserDriver);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
|
@ -367,7 +368,7 @@ CallBootService (
|
|||
UINTN Argument6;
|
||||
UINT32 Index;
|
||||
VOID **UserArgList;
|
||||
VOID *CoreArgList[MAX_LIST];
|
||||
VOID **CoreArgList;
|
||||
EFI_HANDLE CoreHandle;
|
||||
UINT32 PagesNumber;
|
||||
EFI_PHYSICAL_ADDRESS Ring3Pages;
|
||||
|
@ -491,24 +492,25 @@ CallBootService (
|
|||
case SysCallInstallMultipleProtocolInterfaces:
|
||||
//
|
||||
// Argument 1: EFI_HANDLE *Handle
|
||||
// ...
|
||||
// Argument 2: UINTN NumberOfArguments
|
||||
// Argument 3: VOID **UserArgList
|
||||
//
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)Arguments[1], &Attributes);
|
||||
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(Arguments[1] + sizeof (EFI_HANDLE *) - 1), &Attributes);
|
||||
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)Arguments[2], &Attributes);
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)Arguments[3], &Attributes);
|
||||
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(Arguments[2] + sizeof (VOID **) - 1), &Attributes);
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(Arguments[3] + Arguments[2] * sizeof (VOID *) - 1), &Attributes);
|
||||
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
|
||||
|
||||
CoreArgList = AllocatePool (Arguments[2] * sizeof (VOID *));
|
||||
|
||||
AllowSupervisorAccessToUserMemory ();
|
||||
CoreHandle = *(EFI_HANDLE *)Arguments[1];
|
||||
UserArgList = (VOID **)Arguments[2];
|
||||
UserArgList = (VOID **)Arguments[3];
|
||||
|
||||
for (Index = 0; UserArgList[Index] != NULL; Index += 2) {
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)&UserArgList[Index + 2] - 1), &Attributes);
|
||||
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(UINTN)UserArgList[Index], &Attributes);
|
||||
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserArgList[Index] + sizeof (EFI_GUID) - 1), &Attributes);
|
||||
|
@ -524,6 +526,7 @@ CallBootService (
|
|||
Index -= 2;
|
||||
}
|
||||
|
||||
FreePool (CoreArgList);
|
||||
FreePool (Arguments);
|
||||
return Status;
|
||||
}
|
||||
|
@ -547,13 +550,10 @@ CallBootService (
|
|||
NewDriver->UserStackTop = UserDriver->UserStackTop;
|
||||
|
||||
InsertTailList (&gUserSpaceDriversHead, &NewDriver->Link);
|
||||
|
||||
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)&UserArgList[Index + 2] + sizeof (VOID *) - 1), &Attributes);
|
||||
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
|
||||
}
|
||||
ForbidSupervisorAccessToUserMemory ();
|
||||
|
||||
ASSERT (Index < MAX_LIST);
|
||||
ASSERT (Index == (Arguments[2] - 1));
|
||||
CoreArgList[Index] = NULL;
|
||||
|
||||
for (Index = 0; CoreArgList[Index] != NULL; Index += 2) {
|
||||
|
@ -593,6 +593,7 @@ CallBootService (
|
|||
(VOID *)gBS->InstallMultipleProtocolInterfaces
|
||||
);
|
||||
|
||||
FreePool (CoreArgList);
|
||||
FreePool (Arguments);
|
||||
return Status;
|
||||
|
||||
|
|
|
@ -237,6 +237,7 @@ CoreFileClose (
|
|||
|
||||
FreePool (UserDriver->CoreWrapper);
|
||||
RemoveEntryList (&UserDriver->Link);
|
||||
FreePool (UserDriver);
|
||||
|
||||
gUserPageTable = OldPageTable;
|
||||
|
||||
|
|
|
@ -2051,7 +2051,6 @@ typedef enum {
|
|||
SysCallMax
|
||||
} SYS_CALL_TYPE;
|
||||
|
||||
#define MAX_LIST 32
|
||||
#define SC_FREE_PAGES 7
|
||||
#define SC_BLOCK_IO_READ 14
|
||||
#define SC_BLOCK_IO_WRITE 15
|
||||
|
|
Loading…
Reference in New Issue