Do not create new bootloader stack as it is not needed any longer and kernel will use its own stack
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
b22303003c
commit
f19afbddb7
@ -9,50 +9,6 @@
|
|||||||
#include <xtbl.h>
|
#include <xtbl.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and switches to a new stack.
|
|
||||||
*
|
|
||||||
* @param StackPtr
|
|
||||||
* Supplies a pointer to memory area, where the stack will be created.
|
|
||||||
*
|
|
||||||
* @param StackSize
|
|
||||||
* Specifies a size (in bytes) of the new stack.
|
|
||||||
*
|
|
||||||
* @param Callback
|
|
||||||
* Supplies a pointer to a callback function that will be executed on top of new stack.
|
|
||||||
*
|
|
||||||
* @return This routine does not return any value.
|
|
||||||
*
|
|
||||||
* @since XT 1.0
|
|
||||||
*/
|
|
||||||
XTCDECL
|
|
||||||
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(EFI_SIZE_TO_PAGES(StackSize), &Address);
|
|
||||||
*StackPtr = (PVOID)(UINT_PTR)Address;
|
|
||||||
StackEnd = (PUINT8)*StackPtr + (StackSize - 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");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the actual memory mapping page table and enables paging. This routine exits EFI boot services as well.
|
* Builds the actual memory mapping page table and enables paging. This routine exits EFI boot services as well.
|
||||||
*
|
*
|
||||||
@ -84,7 +40,6 @@ BlEnablePaging(IN PLIST_ENTRY MemoryMappings,
|
|||||||
PEFI_MEMORY_MAP MemoryMap;
|
PEFI_MEMORY_MAP MemoryMap;
|
||||||
PLIST_ENTRY ListEntry;
|
PLIST_ENTRY ListEntry;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
PVOID Stack;
|
|
||||||
|
|
||||||
/* Allocate and zero-fill buffer for EFI memory map */
|
/* Allocate and zero-fill buffer for EFI memory map */
|
||||||
BlEfiMemoryAllocatePool(sizeof(EFI_MEMORY_MAP), (PVOID*)&MemoryMap);
|
BlEfiMemoryAllocatePool(sizeof(EFI_MEMORY_MAP), (PVOID*)&MemoryMap);
|
||||||
@ -110,16 +65,6 @@ BlEnablePaging(IN PLIST_ENTRY MemoryMappings,
|
|||||||
*PtePointer = (PVOID)(UINT_PTR)Address;
|
*PtePointer = (PVOID)(UINT_PTR)Address;
|
||||||
RtlZeroMemory(*PtePointer, EFI_PAGE_SIZE);
|
RtlZeroMemory(*PtePointer, EFI_PAGE_SIZE);
|
||||||
|
|
||||||
/* Map the stack */
|
|
||||||
BlGetStackPointer(&Stack);
|
|
||||||
Status = BlAddVirtualMemoryMapping(MemoryMappings, Stack, Stack, EFI_SIZE_TO_PAGES(KERNEL_STACK_SIZE),
|
|
||||||
LoaderOsloaderStack);
|
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Mapping the stack failed */
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Map XTLDR code */
|
/* Map XTLDR code */
|
||||||
Status = BlAddVirtualMemoryMapping(MemoryMappings, ImageProtocol->ImageBase, ImageProtocol->ImageBase,
|
Status = BlAddVirtualMemoryMapping(MemoryMappings, ImageProtocol->ImageBase, ImageProtocol->ImageBase,
|
||||||
EFI_SIZE_TO_PAGES(ImageProtocol->ImageSize), LoaderFirmwareTemporary);
|
EFI_SIZE_TO_PAGES(ImageProtocol->ImageSize), LoaderFirmwareTemporary);
|
||||||
|
@ -9,50 +9,6 @@
|
|||||||
#include <xtbl.h>
|
#include <xtbl.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and switches to a new stack.
|
|
||||||
*
|
|
||||||
* @param StackPtr
|
|
||||||
* Supplies a pointer to memory area, where the stack will be created.
|
|
||||||
*
|
|
||||||
* @param StackSize
|
|
||||||
* Specifies a size (in bytes) of the new stack.
|
|
||||||
*
|
|
||||||
* @param Callback
|
|
||||||
* Supplies a pointer to a callback function that will be executed on top of new stack.
|
|
||||||
*
|
|
||||||
* @return This routine does not return any value.
|
|
||||||
*
|
|
||||||
* @since XT 1.0
|
|
||||||
*/
|
|
||||||
XTCDECL
|
|
||||||
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(EFI_SIZE_TO_PAGES(StackSize), &Address);
|
|
||||||
*StackPtr = (PVOID)(UINT_PTR)Address;
|
|
||||||
StackEnd = (PUINT8)*StackPtr + (StackSize - EFI_PAGE_SIZE);
|
|
||||||
|
|
||||||
/* Create new stack and switch to it immediatelly by calling callback function */
|
|
||||||
asm volatile("mov %1, %%eax\n"
|
|
||||||
"mov %%esp, %%ebx\n"
|
|
||||||
"mov %0, %%esp\n"
|
|
||||||
"push %%ebp\n"
|
|
||||||
"mov %%esp, %%ebp\n"
|
|
||||||
"push %%ebx\n"
|
|
||||||
"sub $32, %%esp\n"
|
|
||||||
"call *%%eax\n"
|
|
||||||
:
|
|
||||||
: "m" (StackEnd), "m" (Callback)
|
|
||||||
: "eax", "ebx");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the actual memory mapping page table and enables paging. This routine exits EFI boot services as well.
|
* Builds the actual memory mapping page table and enables paging. This routine exits EFI boot services as well.
|
||||||
*
|
*
|
||||||
@ -87,7 +43,6 @@ BlEnablePaging(IN PLIST_ENTRY MemoryMappings,
|
|||||||
PEFI_MEMORY_MAP MemoryMap;
|
PEFI_MEMORY_MAP MemoryMap;
|
||||||
PLIST_ENTRY ListEntry;
|
PLIST_ENTRY ListEntry;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
PVOID Stack;
|
|
||||||
UINT Index;
|
UINT Index;
|
||||||
|
|
||||||
/* Prepare CPUID registers */
|
/* Prepare CPUID registers */
|
||||||
@ -196,16 +151,6 @@ BlEnablePaging(IN PLIST_ENTRY MemoryMappings,
|
|||||||
Address += EFI_PAGE_SIZE;
|
Address += EFI_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Map the stack */
|
|
||||||
BlGetStackPointer(&Stack);
|
|
||||||
Status = BlAddVirtualMemoryMapping(MemoryMappings, Stack, Stack, EFI_SIZE_TO_PAGES(KERNEL_STACK_SIZE),
|
|
||||||
LoaderOsloaderStack);
|
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Mapping the stack failed */
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Map XTLDR code */
|
/* Map XTLDR code */
|
||||||
Status = BlAddVirtualMemoryMapping(MemoryMappings, ImageProtocol->ImageBase, ImageProtocol->ImageBase,
|
Status = BlAddVirtualMemoryMapping(MemoryMappings, ImageProtocol->ImageBase, ImageProtocol->ImageBase,
|
||||||
EFI_SIZE_TO_PAGES(ImageProtocol->ImageSize), LoaderFirmwareTemporary);
|
EFI_SIZE_TO_PAGES(ImageProtocol->ImageSize), LoaderFirmwareTemporary);
|
||||||
|
@ -43,7 +43,6 @@ typedef struct _XT_BOOT_LOADER_PROTOCOL
|
|||||||
PBL_GET_VIRTUAL_ADDRESS GetVirtualAddress;
|
PBL_GET_VIRTUAL_ADDRESS GetVirtualAddress;
|
||||||
PBL_INIT_VIRTUAL_MEMORY InitializeVirtualMemory;
|
PBL_INIT_VIRTUAL_MEMORY InitializeVirtualMemory;
|
||||||
PBL_MAP_VIRTUAL_MEMORY MapVirtualMemory;
|
PBL_MAP_VIRTUAL_MEMORY MapVirtualMemory;
|
||||||
PBL_GET_STACK GetStack;
|
|
||||||
PBL_DBG_PRINT DbgPrint;
|
PBL_DBG_PRINT DbgPrint;
|
||||||
PBL_EFI_PRINT EfiPrint;
|
PBL_EFI_PRINT EfiPrint;
|
||||||
PBL_CLOSE_VOLUME CloseVolume;
|
PBL_CLOSE_VOLUME CloseVolume;
|
||||||
|
@ -72,12 +72,6 @@ XTCDECL
|
|||||||
LOADER_MEMORY_TYPE
|
LOADER_MEMORY_TYPE
|
||||||
BlConvertEfiMemoryType(IN EFI_MEMORY_TYPE EfiMemoryType);
|
BlConvertEfiMemoryType(IN EFI_MEMORY_TYPE EfiMemoryType);
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
VOID
|
|
||||||
BlCreateStack(IN PVOID *StackPtr,
|
|
||||||
IN ULONG StackSize,
|
|
||||||
IN PVOID Callback);
|
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
BlDbgPrint(IN PUINT16 Format,
|
BlDbgPrint(IN PUINT16 Format,
|
||||||
@ -137,10 +131,6 @@ XTCDECL
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
BlGetMemoryMap(OUT PEFI_MEMORY_MAP MemoryMap);
|
BlGetMemoryMap(OUT PEFI_MEMORY_MAP MemoryMap);
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
VOID
|
|
||||||
BlGetStackPointer(OUT PVOID *Stack);
|
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
BlGetVirtualAddress(IN PLIST_ENTRY MemoryMappings,
|
BlGetVirtualAddress(IN PLIST_ENTRY MemoryMappings,
|
||||||
@ -185,10 +175,6 @@ XTCDECL
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
BlRegisterXtLoaderProtocol();
|
BlRegisterXtLoaderProtocol();
|
||||||
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
BlStartNewStack();
|
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
||||||
|
@ -28,23 +28,6 @@ PVOID EfiLoaderStack;
|
|||||||
CPPORT EfiSerialPort;
|
CPPORT EfiSerialPort;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a pointer to the stack address.
|
|
||||||
*
|
|
||||||
* @param Stack
|
|
||||||
* Supplies a pointer to the memory area where address to the current stack will be stored.
|
|
||||||
*
|
|
||||||
* @return This routine does not return any value.
|
|
||||||
*
|
|
||||||
* @since XT 1.0
|
|
||||||
*/
|
|
||||||
XTCDECL
|
|
||||||
VOID
|
|
||||||
BlGetStackPointer(OUT PVOID *Stack)
|
|
||||||
{
|
|
||||||
*Stack = EfiLoaderStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine loads XTLDR EFI modules.
|
* This routine loads XTLDR EFI modules.
|
||||||
*
|
*
|
||||||
@ -351,7 +334,6 @@ BlRegisterXtLoaderProtocol()
|
|||||||
EfiLdrProtocol.GetVirtualAddress = BlGetVirtualAddress;
|
EfiLdrProtocol.GetVirtualAddress = BlGetVirtualAddress;
|
||||||
EfiLdrProtocol.InitializeVirtualMemory = BlInitializeVirtualMemory;
|
EfiLdrProtocol.InitializeVirtualMemory = BlInitializeVirtualMemory;
|
||||||
EfiLdrProtocol.MapVirtualMemory = BlMapVirtualMemory;
|
EfiLdrProtocol.MapVirtualMemory = BlMapVirtualMemory;
|
||||||
EfiLdrProtocol.GetStack = BlGetStackPointer;
|
|
||||||
EfiLdrProtocol.DbgPrint = BlDbgPrint;
|
EfiLdrProtocol.DbgPrint = BlDbgPrint;
|
||||||
EfiLdrProtocol.EfiPrint = BlEfiPrint;
|
EfiLdrProtocol.EfiPrint = BlEfiPrint;
|
||||||
EfiLdrProtocol.CloseVolume = BlCloseVolume;
|
EfiLdrProtocol.CloseVolume = BlCloseVolume;
|
||||||
@ -363,39 +345,6 @@ BlRegisterXtLoaderProtocol()
|
|||||||
&EfiLdrProtocol);
|
&EfiLdrProtocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback routine called right after new stack is created.
|
|
||||||
*
|
|
||||||
* @return This routine returns a status code.
|
|
||||||
*
|
|
||||||
* @since XT 1.0
|
|
||||||
*/
|
|
||||||
XTCDECL
|
|
||||||
EFI_STATUS
|
|
||||||
BlStartNewStack()
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
|
|
||||||
/* Boot XTOS */
|
|
||||||
Status = BlLoadXtSystem();
|
|
||||||
if(Status != STATUS_EFI_SUCCESS)
|
|
||||||
{
|
|
||||||
/* Boot process failed */
|
|
||||||
BlEfiPrint(L"Failed to start XT OS (Status code: %lx)!\n", Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Infinite bootloader loop */
|
|
||||||
BlEfiPrint(L"System halted!");
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
HlClearInterruptFlag();
|
|
||||||
HlHalt();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return success */
|
|
||||||
return STATUS_EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine is the entry point of the XT EFI boot loader.
|
* This routine is the entry point of the XT EFI boot loader.
|
||||||
*
|
*
|
||||||
@ -469,11 +418,15 @@ BlStartXtLoader(IN EFI_HANDLE ImageHandle,
|
|||||||
/* Discover and enumerate EFI block devices */
|
/* Discover and enumerate EFI block devices */
|
||||||
BlEnumerateEfiBlockDevices();
|
BlEnumerateEfiBlockDevices();
|
||||||
|
|
||||||
/* Create new bootloader stack */
|
/* Boot XTOS */
|
||||||
BlCreateStack(&EfiLoaderStack, KERNEL_STACK_SIZE, &BlStartNewStack);
|
Status = BlLoadXtSystem();
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Boot process failed */
|
||||||
|
BlEfiPrint(L"Failed to start XT OS (Status code: %lx)!\n", Status);
|
||||||
|
}
|
||||||
|
|
||||||
/* Infinite bootloader loop */
|
/* Infinite bootloader loop */
|
||||||
BlDbgPrint(L"ERROR: Unexpected exception occurred, probably did not create a new stack\n");
|
|
||||||
BlEfiPrint(L"System halted!");
|
BlEfiPrint(L"System halted!");
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user