exectos/xtoskrnl/ke/i686/krnlinit.c
belliash a761d3125a
All checks were successful
ci/woodpecker/push/build Pipeline was successful
Architecture specific initialization prior to processor structures initialization
2023-01-30 20:34:05 +01:00

73 lines
1.7 KiB
C

/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtoskrnl/ke/i686/krnlinit.c
* DESCRIPTION: CPU architecture specific kernel initialization
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#include <xtos.h>
/**
* Performs architecture-specific initialization for the kernel executive.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
KepArchInitialize(VOID)
{
/* Clear EFLAGS register */
ArWriteEflagsRegister(0);
/* Enable write-protection */
ArWriteControlRegister(0, ArReadControlRegister(0) | CR0_WP);
/* Re-enable IDE interrupts */
HlIoPortOutByte(0x376, 0);
HlIoPortOutByte(0x3F6, 0);
}
/**
* This routine starts up the XT kernel. It is called after switching boot stack.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
KepStartKernel(VOID)
{
LdrPrint(L"Hello from new kernel stack!\n");
for(;;);
}
/**
* Switches to a new kernel boot stack.
*
* @return This routine does not return any value
*
* @since XT 1.0
*/
XTAPI
VOID
KepSwitchBootStack(IN ULONG_PTR Stack)
{
/* Discard old stack frame, switch stack, make space for NPX and jump to KepStartKernel() */
asm volatile("mov %0, %%edx\n"
"xor %%ebp, %%ebp\n"
"mov %%edx, %%esp\n"
"sub %1, %%esp\n"
"push %2\n"
"jmp _KepStartKernel@0\n"
:
: "m" (Stack),
"i" (KTRAP_FRAME_ALIGN | KTRAP_FRAME_SIZE | NPX_FRAME_SIZE),
"i" (CR0_EM | CR0_MP | CR0_TS),
"p" (KepStartKernel));
}