forked from xt-sys/exectos
		
	Reorganize early debug printing; initialize kernel stacks when needed
This commit is contained in:
		
							
								
								
									
										20
									
								
								sdk/xtdk/xtdebug.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								sdk/xtdk/xtdebug.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| /** | ||||
|  * PROJECT:         ExectOS | ||||
|  * COPYRIGHT:       See COPYING.md in the top level directory | ||||
|  * FILE:            sdk/xtdk/xtdebug.h | ||||
|  * DESCRIPTION:     XT debugging support | ||||
|  * DEVELOPERS:      Rafal Kupiec <belliash@codingworkshop.eu.org> | ||||
|  */ | ||||
|  | ||||
| #ifndef __XTDK_XTDEBUG_H | ||||
| #define __XTDK_XTDEBUG_H | ||||
|  | ||||
|  | ||||
| /* XTOS platform debugging macros */ | ||||
| #ifdef DBG | ||||
|     #define LDRPRINT(Format, ...)       if(LdrPrint) LdrPrint(Format, __VA_ARGS__); | ||||
| #else | ||||
|     #define LDRPRINT(Format, ...)       ((VOID)NULL) | ||||
| #endif | ||||
|  | ||||
| #endif /* __XTDK_XTDEBUG_H */ | ||||
| @@ -104,7 +104,8 @@ typedef struct _KERNEL_INITIALIZATION_BLOCK | ||||
|     LIST_ENTRY BootDriverListHead; | ||||
|     ULONG Size; | ||||
|     ULONG Version; | ||||
|     ULONG_PTR KernelStack; | ||||
|     ULONG_PTR KernelBootStack; | ||||
|     ULONG_PTR KernelFaultStack; | ||||
|     LOADER_INFORMATION_BLOCK LoaderInformation; | ||||
|     FIRMWARE_INFORMATION_BLOCK FirmwareInformation; | ||||
| } KERNEL_INITIALIZATION_BLOCK, *PKERNEL_INITIALIZATION_BLOCK; | ||||
|   | ||||
| @@ -20,6 +20,7 @@ | ||||
|  | ||||
| /* Architecture-independent XT API */ | ||||
| #include "xtcommon.h" | ||||
| #include "xtdebug.h" | ||||
| #include "xtimage.h" | ||||
| #include "xtuefi.h" | ||||
| #include "xtfw.h" | ||||
|   | ||||
| @@ -283,8 +283,9 @@ XtpInitializeLoaderBlock(IN PLIST_ENTRY MemoryMappings, | ||||
|     LoaderBlock->Size = sizeof(KERNEL_INITIALIZATION_BLOCK); | ||||
|     LoaderBlock->Version = INITIALIZATION_BLOCK_VERSION; | ||||
|  | ||||
|     /* No kernel stack available now */ | ||||
|     LoaderBlock->KernelStack = (ULONG_PTR)NULL; | ||||
|     /* No kernel boot, nor fault stacks available now */ | ||||
|     LoaderBlock->KernelBootStack = (ULONG_PTR)NULL; | ||||
|     LoaderBlock->KernelFaultStack = (ULONG_PTR)NULL; | ||||
|  | ||||
|     /* Set LoaderInformation block properties */ | ||||
|     LoaderBlock->LoaderInformation.DbgPrint = XtLdrProtocol->DbgPrint; | ||||
|   | ||||
| @@ -3,12 +3,14 @@ PROJECT(XTOSKRNL) | ||||
|  | ||||
| # Specify include directories | ||||
| include_directories( | ||||
|     ${EXECTOS_SOURCE_DIR}/sdk/xtdk) | ||||
|     ${EXECTOS_SOURCE_DIR}/sdk/xtdk | ||||
|     ${XTOSKRNL_SOURCE_DIR}/includes) | ||||
|  | ||||
| # Specify list of source code files | ||||
| list(APPEND XTOSKRNL_SOURCE | ||||
|     ${XTOSKRNL_SOURCE_DIR}/hl/cport.c | ||||
|     ${XTOSKRNL_SOURCE_DIR}/hl/${ARCH}/cpufunc.c | ||||
|     ${XTOSKRNL_SOURCE_DIR}/ke/globals.c | ||||
|     ${XTOSKRNL_SOURCE_DIR}/ke/krnlinit.c | ||||
|     ${XTOSKRNL_SOURCE_DIR}/rtl/memory.c | ||||
|     ${XTOSKRNL_SOURCE_DIR}/rtl/plist.c | ||||
|   | ||||
							
								
								
									
										24
									
								
								xtoskrnl/includes/globals.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								xtoskrnl/includes/globals.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| /** | ||||
|  * PROJECT:         ExectOS | ||||
|  * COPYRIGHT:       See COPYING.md in the top level directory | ||||
|  * FILE:            xtoskrnl/includes/globals.h | ||||
|  * DESCRIPTION:     XT kernel global variables | ||||
|  * DEVELOPERS:      Rafal Kupiec <belliash@codingworkshop.eu.org> | ||||
|  */ | ||||
|  | ||||
| #ifndef __XTOSKRNL_GLOBALS_H | ||||
| #define __XTOSKRNL_GLOBALS_H | ||||
|  | ||||
| #include <xtkmapi.h> | ||||
|  | ||||
|  | ||||
| /* Kernel own boot stack */ | ||||
| EXTERN UCHAR KepKernelBootStackData[KERNEL_STACK_SIZE]; | ||||
|  | ||||
| /* Kernel own fault stack */ | ||||
| EXTERN UCHAR KepKernelFaultStackData[KERNEL_STACK_SIZE]; | ||||
|  | ||||
| /* Pointer to boot loader provided DbgPrint() routine */ | ||||
| EXTERN VOID (*LdrPrint)(IN PWCHAR Format, IN ...); | ||||
|  | ||||
| #endif /* __XTOSKRNL_GLOBALS_H */ | ||||
							
								
								
									
										13
									
								
								xtoskrnl/includes/xtos.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								xtoskrnl/includes/xtos.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| /** | ||||
|  * PROJECT:         ExectOS | ||||
|  * COPYRIGHT:       See COPYING.md in the top level directory | ||||
|  * FILE:            xtoskrnl/includes/xtos.h | ||||
|  * DESCRIPTION:     Top level header for the XT kernel | ||||
|  * DEVELOPERS:      Rafal Kupiec <belliash@codingworkshop.eu.org> | ||||
|  */ | ||||
|  | ||||
| /* XT Development Kit */ | ||||
| #include <xtkmapi.h> | ||||
|  | ||||
| /* Kernel specific headers */ | ||||
| #include "globals.h" | ||||
							
								
								
									
										19
									
								
								xtoskrnl/ke/globals.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								xtoskrnl/ke/globals.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| /** | ||||
|  * PROJECT:         ExectOS | ||||
|  * COPYRIGHT:       See COPYING.md in the top level directory | ||||
|  * FILE:            xtoskrnl/ke/globals.c | ||||
|  * DESCRIPTION:     XT kernel global variables | ||||
|  * DEVELOPERS:      Rafal Kupiec <belliash@codingworkshop.eu.org> | ||||
|  */ | ||||
|  | ||||
| #include <xtos.h> | ||||
|  | ||||
|  | ||||
| /* Kernel own boot stack */ | ||||
| UCHAR KepKernelBootStackData[KERNEL_STACK_SIZE] = {0}; | ||||
|  | ||||
| /* Kernel own fault stack */ | ||||
| UCHAR KepKernelFaultStackData[KERNEL_STACK_SIZE] = {0}; | ||||
|  | ||||
| /* Pointer to boot loader provided DbgPrint() routine */ | ||||
| VOID (*LdrPrint)(IN PWCHAR Format, IN ...) = NULL; | ||||
| @@ -6,7 +6,7 @@ | ||||
|  * DEVELOPERS:      Rafal Kupiec <belliash@codingworkshop.eu.org> | ||||
|  */ | ||||
|  | ||||
| #include <xtkmapi.h> | ||||
| #include <xtos.h> | ||||
|  | ||||
|  | ||||
| /** | ||||
| @@ -23,14 +23,34 @@ XTAPI | ||||
| VOID | ||||
| KeStartXtSystem(IN PKERNEL_INITIALIZATION_BLOCK Parameters) | ||||
| { | ||||
|     /* Use XTLDR provided DbgPrint() routine for early printing to serial console */ | ||||
|     VOID (*DbgPrint)(IN PWCHAR Format, IN ...) = Parameters->LoaderInformation.DbgPrint; | ||||
|     /* Check if debugging enabled and if boot loader provided routine for debug printing */ | ||||
|     if(DBG && Parameters->LoaderInformation.DbgPrint) | ||||
|     { | ||||
|         /* Use loader's provided DbgPrint() routine for early printing to serial console */ | ||||
|         LdrPrint = Parameters->LoaderInformation.DbgPrint; | ||||
|     } | ||||
|  | ||||
|     /* Make sure kernel boot stack is initialized */ | ||||
|     if(!Parameters->KernelBootStack) | ||||
|     { | ||||
|         /* Initialize kernel boot stack */ | ||||
|         LDRPRINT(L"Initializing kernel boot stack\n"); | ||||
|         Parameters->KernelBootStack = (ULONG_PTR)&KepKernelBootStackData[KERNEL_STACK_SIZE]; | ||||
|     } | ||||
|  | ||||
|     /* Make sure kernel fault stack is initialized */ | ||||
|     if(!Parameters->KernelFaultStack) | ||||
|     { | ||||
|         /* Initialize kernel fault stack */ | ||||
|         LDRPRINT(L"Initializing kernel fault stack\n"); | ||||
|         Parameters->KernelFaultStack = (ULONG_PTR)&KepKernelFaultStackData[KERNEL_STACK_SIZE]; | ||||
|     } | ||||
|  | ||||
|     /* Print some message to serial console */ | ||||
|     DbgPrint(L"Hello world from ExectOS kernel!\n"); | ||||
|     LDRPRINT(L"Hello world from ExectOS kernel!\n"); | ||||
|  | ||||
|     /* Test kernel parameters */ | ||||
|     DbgPrint(L"\n\n------ Kernel parameters block ------\n" | ||||
|     LDRPRINT(L"\n\n------ Kernel parameters block ------\n" | ||||
|              L"Loader block size: %lu\n" | ||||
|              L"Loader block version: %lu\n" | ||||
|              L"EFI Revision: %lu\n" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user