Implement BlCreateStack()

Este commit está contenido en:
2022-12-07 19:46:36 +01:00
padre 43c16d054d
commit d50fb7c37d
Se han modificado 2 ficheros con 32 adiciones y 0 borrados

Ver fichero

@@ -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.
*