Verify kernel and boot loader compatibility
This commit is contained in:
parent
c66ea77a8b
commit
d8403d01f5
|
@ -16,6 +16,9 @@
|
|||
/* Version number of the current kernel initialization block */
|
||||
#define INITIALIZATION_BLOCK_VERSION 1
|
||||
|
||||
/* Version number of the current XTOS loader protocol */
|
||||
#define BOOT_PROTOCOL_VERSION 1
|
||||
|
||||
/* Memory allocation structures */
|
||||
typedef enum _LOADER_MEMORY_TYPE
|
||||
{
|
||||
|
@ -115,11 +118,12 @@ typedef struct _LOADER_MEMORY_MAPPING
|
|||
/* Loader provided information needed by the kernel to initialize */
|
||||
typedef struct _KERNEL_INITIALIZATION_BLOCK
|
||||
{
|
||||
ULONG BlockSize;
|
||||
ULONG BlockVersion;
|
||||
ULONG ProtocolVersion;
|
||||
LIST_ENTRY LoadOrderListHead;
|
||||
LIST_ENTRY MemoryDescriptorListHead;
|
||||
LIST_ENTRY BootDriverListHead;
|
||||
ULONG Size;
|
||||
ULONG Version;
|
||||
LOADER_INFORMATION_BLOCK LoaderInformation;
|
||||
FIRMWARE_INFORMATION_BLOCK FirmwareInformation;
|
||||
} KERNEL_INITIALIZATION_BLOCK, *PKERNEL_INITIALIZATION_BLOCK;
|
||||
|
|
|
@ -352,8 +352,9 @@ XtpInitializeLoaderBlock(IN PLIST_ENTRY MemoryMappings,
|
|||
RtlZeroMemory(LoaderBlock, sizeof(KERNEL_INITIALIZATION_BLOCK));
|
||||
|
||||
/* Set basic loader block properties */
|
||||
LoaderBlock->Size = sizeof(KERNEL_INITIALIZATION_BLOCK);
|
||||
LoaderBlock->Version = INITIALIZATION_BLOCK_VERSION;
|
||||
LoaderBlock->BlockSize = sizeof(KERNEL_INITIALIZATION_BLOCK);
|
||||
LoaderBlock->BlockVersion = INITIALIZATION_BLOCK_VERSION;
|
||||
LoaderBlock->ProtocolVersion = BOOT_PROTOCOL_VERSION;
|
||||
|
||||
/* Set LoaderInformation block properties */
|
||||
LoaderBlock->LoaderInformation.DbgPrint = XtLdrProtocol->DbgPrint;
|
||||
|
|
|
@ -82,9 +82,6 @@ XTAPI
|
|||
VOID
|
||||
KepStartKernel(VOID)
|
||||
{
|
||||
/* Print debug message */
|
||||
DebugPrint(L"Starting ExectOS ...\n");
|
||||
|
||||
/* Initialize XTOS kernel */
|
||||
KepInitializeKernel();
|
||||
|
||||
|
|
|
@ -82,9 +82,6 @@ XTAPI
|
|||
VOID
|
||||
KepStartKernel(VOID)
|
||||
{
|
||||
/* Print debug message */
|
||||
DebugPrint(L"Starting ExectOS ...\n");
|
||||
|
||||
/* Initialize XTOS kernel */
|
||||
KepInitializeKernel();
|
||||
|
||||
|
|
|
@ -23,29 +23,36 @@ XTAPI
|
|||
VOID
|
||||
KeStartXtSystem(IN PKERNEL_INITIALIZATION_BLOCK Parameters)
|
||||
{
|
||||
/* Check if debugging enabled and if boot loader provided routine for debug printing */
|
||||
if(DEBUG && Parameters->LoaderInformation.DbgPrint)
|
||||
{
|
||||
/* Use loader's provided DbgPrint() routine for early printing to serial console */
|
||||
KeDbgPrint = Parameters->LoaderInformation.DbgPrint;
|
||||
}
|
||||
|
||||
|
||||
/* Print some message to serial console and test kernel parameters */
|
||||
DebugPrint(L"Hello world from ExectOS kernel!\n");
|
||||
DebugPrint(L"\n\n------ Kernel parameters block ------\n"
|
||||
L"Loader block size: %lu\n"
|
||||
L"Loader block version: %lu\n"
|
||||
L"EFI Revision: %lu\n",
|
||||
Parameters->Size,
|
||||
Parameters->Version,
|
||||
Parameters->FirmwareInformation.EfiFirmware.EfiVersion
|
||||
);
|
||||
|
||||
|
||||
/* Save the kernel initialization block */
|
||||
KeInitializationBlock = Parameters;
|
||||
|
||||
/* Verify kernel and boot loader compatibility */
|
||||
if(KeInitializationBlock->BlockSize != sizeof(KERNEL_INITIALIZATION_BLOCK) ||
|
||||
KeInitializationBlock->BlockVersion != INITIALIZATION_BLOCK_VERSION ||
|
||||
KeInitializationBlock->ProtocolVersion != BOOT_PROTOCOL_VERSION)
|
||||
{
|
||||
/* Kernel and boot loader version mismatch */
|
||||
for(;;)
|
||||
{
|
||||
/* Halt system */
|
||||
ArClearInterruptFlag();
|
||||
ArHalt();
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if debugging enabled and if boot loader provided routine for debug printing */
|
||||
if(DEBUG && KeInitializationBlock->LoaderInformation.DbgPrint)
|
||||
{
|
||||
/* Use loader's provided DbgPrint() routine for early printing to serial console */
|
||||
KeDbgPrint = KeInitializationBlock->LoaderInformation.DbgPrint;
|
||||
}
|
||||
|
||||
/* Announce kernel startup */
|
||||
DebugPrint(L"Starting ExectOS v%d.%d (%s-%s-%s-%s / %s %s)\n",
|
||||
XTOS_VERSION_MAJOR, XTOS_VERSION_MINOR, XTOS_VERSION_DATE,
|
||||
XTOS_VERSION_BUILD, XTOS_VERSION_ARCH, XTOS_VERSION_HASH,
|
||||
XTOS_COMPILER_NAME, XTOS_COMPILER_VERSION);
|
||||
|
||||
/* Initialize boot CPU */
|
||||
ArInitializeProcessor();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user