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