Implement BlCreateStack()
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Rafal Kupiec 2022-12-07 19:46:36 +01:00
parent 43c16d054d
commit d50fb7c37d
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 32 additions and 0 deletions

View File

@ -9,6 +9,33 @@
#include <xtbl.h>
VOID
BlCreateStack(IN PVOID *StackPtr,
IN ULONG StackSize,
IN PVOID Callback)
{
EFI_PHYSICAL_ADDRESS Address;
PVOID StackEnd;
/* Allocate pages for new stack and calculate its end */
BlEfiMemoryAllocatePages(StackSize, &Address);
*StackPtr = (PVOID)(UINT_PTR)Address;
StackEnd = (PUINT8)*StackPtr + (StackSize * EFI_PAGE_SIZE) - EFI_PAGE_SIZE;
/* Create new stack and switch to it immediatelly by calling callback function */
asm volatile("mov %1, %%rax\n"
"mov %%rsp, %%rbx\n"
"mov %0, %%rsp\n"
"push %%rbp\n"
"mov %%rsp, %%rbp\n"
"push %%rbx\n"
"sub $32, %%rsp\n"
"call *%%rax\n"
:
: "m" (StackEnd), "m" (Callback)
: "rax", "rbx");
}
/**
* This routine does the actual virtual memory mapping.
*

View File

@ -54,6 +54,11 @@ BlConsoleInitialize();
VOID
BlConsolePutChar(IN USHORT Character);
VOID
BlCreateStack(IN PVOID *StackPtr,
IN ULONG StackSize,
IN PVOID Callback);
VOID
BlDbgPrint(IN PUINT16 Format,
IN ...);