Basic processor initialization code
Some checks failed
Builds / ExectOS (amd64) (push) Failing after 16s
Builds / ExectOS (i686) (push) Failing after 15s

This commit is contained in:
2023-11-28 22:31:39 +01:00
parent d4ee87fd62
commit f6c621c2a6
7 changed files with 90 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ list(APPEND XTOSKRNL_SOURCE
${XTOSKRNL_SOURCE_DIR}/ar/${ARCH}/traps.c
${XTOSKRNL_SOURCE_DIR}/ex/rundown.c
${XTOSKRNL_SOURCE_DIR}/hl/cport.c
${XTOSKRNL_SOURCE_DIR}/hl/cpu.c
${XTOSKRNL_SOURCE_DIR}/hl/efifb.c
${XTOSKRNL_SOURCE_DIR}/hl/globals.c
${XTOSKRNL_SOURCE_DIR}/hl/pic.c

47
xtoskrnl/hl/cpu.c Normal file
View File

@@ -0,0 +1,47 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtoskrnl/hl/cpu.c
* DESCRIPTION: HAL Processor support
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#include <xtos.h>
/**
* Initializes the processor.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
HlInitializeProcessor(VOID)
{
PKPROCESSOR_BLOCK ProcessorBlock;
KAFFINITY Affinity;
ULONG CpuNumber = 0;
/* Get current processor block */
ProcessorBlock = KeGetCurrentProcessorBlock();
/* Set initial stall factor */
ProcessorBlock->StallScaleFactor = INITIAL_STALL_FACTOR;
/* Record processor block in the processors table */
HlpProcessorsIdentity[CpuNumber].ProcessorBlock = ProcessorBlock;
/* Set processor affinity */
Affinity = (KAFFINITY) 1 << CpuNumber;
/* Apply affinity to a set of processors */
HlpActiveProcessors |= Affinity;
/* Initialize APIC for this processor */
HlpInitializeApic();
/* Set the APIC running level */
HlSetRunLevel(KeGetCurrentProcessorBlock()->RunLevel);
}

View File

@@ -9,8 +9,14 @@
#include <xtos.h>
/* Active processors count */
KAFFINITY HlpActiveProcessors;
/* APIC mode */
HAL_APIC_MODE HlpApicMode;
/* FrameBuffer information */
HAL_FRAMEBUFFER_DATA HlpFrameBufferData;
/* Processors identity table */
HAL_PROCESSOR_IDENTITY HlpProcessorsIdentity[MAXIMUM_PROCESSORS] = {{0}};

View File

@@ -12,12 +12,18 @@
#include <xtos.h>
/* Active processors count */
EXTERN KAFFINITY HlpActiveProcessors;
/* APIC mode */
EXTERN HAL_APIC_MODE HlpApicMode;
/* FrameBuffer information */
EXTERN HAL_FRAMEBUFFER_DATA HlpFrameBufferData;
/* Processors identity table */
EXTERN HAL_PROCESSOR_IDENTITY HlpProcessorsIdentity[MAXIMUM_PROCESSORS];
/* Pointer to boot loader provided DbgPrint() routine */
EXTERN VOID (*KeDbgPrint)(IN PWCHAR Format, IN ...);

View File

@@ -85,6 +85,10 @@ XTAPI
VOID
HlpInitializeApic(VOID);
XTAPI
VOID
HlInitializeProcessor(VOID);
XTFASTCALL
KRUNLEVEL
HlpTransformApicTprToRunLevel(IN UCHAR Tpr);