Allow to specify CPU number when initializing (A)PIC
This commit is contained in:
parent
2c384d780f
commit
ac0b8ab36a
@ -12,17 +12,19 @@
|
|||||||
/**
|
/**
|
||||||
* Initializes the processor.
|
* Initializes the processor.
|
||||||
*
|
*
|
||||||
|
* @param CpuNumber
|
||||||
|
* Supplies the number of the CPU, that is being initialized.
|
||||||
|
*
|
||||||
* @return This routine does not return any value.
|
* @return This routine does not return any value.
|
||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*/
|
*/
|
||||||
XTAPI
|
XTAPI
|
||||||
VOID
|
VOID
|
||||||
HlInitializeProcessor(VOID)
|
HlInitializeProcessor(IN ULONG CpuNumber)
|
||||||
{
|
{
|
||||||
PKPROCESSOR_BLOCK ProcessorBlock;
|
PKPROCESSOR_BLOCK ProcessorBlock;
|
||||||
KAFFINITY Affinity;
|
KAFFINITY Affinity;
|
||||||
ULONG CpuNumber = 0;
|
|
||||||
|
|
||||||
/* Get current processor block */
|
/* Get current processor block */
|
||||||
ProcessorBlock = KeGetCurrentProcessorBlock();
|
ProcessorBlock = KeGetCurrentProcessorBlock();
|
||||||
@ -40,7 +42,7 @@ HlInitializeProcessor(VOID)
|
|||||||
HlpActiveProcessors |= Affinity;
|
HlpActiveProcessors |= Affinity;
|
||||||
|
|
||||||
/* Initialize APIC for this processor */
|
/* Initialize APIC for this processor */
|
||||||
HlpInitializeApic();
|
HlpInitializePic(CpuNumber);
|
||||||
|
|
||||||
/* Set the APIC running level */
|
/* Set the APIC running level */
|
||||||
HlSetRunLevel(KeGetCurrentProcessorBlock()->RunLevel);
|
HlSetRunLevel(KeGetCurrentProcessorBlock()->RunLevel);
|
||||||
|
@ -178,20 +178,20 @@ HlpHandlePicSpuriousService(VOID)
|
|||||||
/**
|
/**
|
||||||
* Initializes the APIC interrupt controller.
|
* Initializes the APIC interrupt controller.
|
||||||
*
|
*
|
||||||
|
* @param CpuNumber
|
||||||
|
* Supplies the number of the CPU, that is being initialized.
|
||||||
|
*
|
||||||
* @return This routine does not return any value.
|
* @return This routine does not return any value.
|
||||||
*
|
*
|
||||||
* @since XT 1.0
|
* @since XT 1.0
|
||||||
*
|
|
||||||
* @todo Register interrupt handlers for spurious vectors.
|
|
||||||
*/
|
*/
|
||||||
XTAPI
|
XTAPI
|
||||||
VOID
|
VOID
|
||||||
HlpInitializeApic(VOID)
|
HlpInitializeApic(IN ULONG CpuNumber)
|
||||||
{
|
{
|
||||||
APIC_BASE_REGISTER BaseRegister;
|
APIC_BASE_REGISTER BaseRegister;
|
||||||
APIC_LVT_REGISTER LvtRegister;
|
APIC_LVT_REGISTER LvtRegister;
|
||||||
APIC_SPURIOUS_REGISTER SpuriousRegister;
|
APIC_SPURIOUS_REGISTER SpuriousRegister;
|
||||||
ULONG CpuNumber = 0;
|
|
||||||
|
|
||||||
/* Check if this is an x2APIC compatible machine */
|
/* Check if this is an x2APIC compatible machine */
|
||||||
if(HlpCheckX2ApicSupport())
|
if(HlpCheckX2ApicSupport())
|
||||||
@ -209,7 +209,7 @@ HlpInitializeApic(VOID)
|
|||||||
BaseRegister.LongLong = ArReadModelSpecificRegister(APIC_LAPIC_MSR_BASE);
|
BaseRegister.LongLong = ArReadModelSpecificRegister(APIC_LAPIC_MSR_BASE);
|
||||||
BaseRegister.Enable = 1;
|
BaseRegister.Enable = 1;
|
||||||
BaseRegister.ExtendedMode = (HlpApicMode == APIC_MODE_X2APIC);
|
BaseRegister.ExtendedMode = (HlpApicMode == APIC_MODE_X2APIC);
|
||||||
BaseRegister.BootStrapProcessor = 1;
|
BaseRegister.BootStrapProcessor = (CpuNumber == 0) ? 1 : 0;
|
||||||
ArWriteModelSpecificRegister(APIC_LAPIC_MSR_BASE, BaseRegister.LongLong);
|
ArWriteModelSpecificRegister(APIC_LAPIC_MSR_BASE, BaseRegister.LongLong);
|
||||||
|
|
||||||
/* xAPIC compatibility mode specific initialization */
|
/* xAPIC compatibility mode specific initialization */
|
||||||
@ -266,3 +266,24 @@ HlpInitializeApic(VOID)
|
|||||||
KeSetInterruptHandler(APIC_VECTOR_SPURIOUS, HlpHandleApicSpuriousService);
|
KeSetInterruptHandler(APIC_VECTOR_SPURIOUS, HlpHandleApicSpuriousService);
|
||||||
KeSetInterruptHandler(PIC1_VECTOR_SPURIOUS, HlpHandlePicSpuriousService);
|
KeSetInterruptHandler(PIC1_VECTOR_SPURIOUS, HlpHandlePicSpuriousService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the (A)PIC interrupt controller.
|
||||||
|
*
|
||||||
|
* @param CpuNumber
|
||||||
|
* Supplies the number of the CPU, that is being initialized.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*
|
||||||
|
* @todo Initialize APIC only when supported, otherwise fall back to legacy PIC.
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
VOID
|
||||||
|
HlpInitializePic(IN ULONG CpuNumber)
|
||||||
|
{
|
||||||
|
/* Disable legacy PIC and initialize APIC */
|
||||||
|
HlDisableLegacyPic();
|
||||||
|
HlpInitializeApic(CpuNumber);
|
||||||
|
}
|
||||||
|
@ -48,7 +48,11 @@ HlpHandlePicSpuriousService(VOID);
|
|||||||
|
|
||||||
XTAPI
|
XTAPI
|
||||||
VOID
|
VOID
|
||||||
HlpInitializeApic(VOID);
|
HlpInitializeApic(IN ULONG CpuNumber);
|
||||||
|
|
||||||
|
XTAPI
|
||||||
|
VOID
|
||||||
|
HlpInitializePic(IN ULONG CpuNumber);
|
||||||
|
|
||||||
XTFASTCALL
|
XTFASTCALL
|
||||||
KRUNLEVEL
|
KRUNLEVEL
|
||||||
|
@ -68,6 +68,6 @@ HlSetRunLevel(IN KRUNLEVEL RunLevel);
|
|||||||
|
|
||||||
XTAPI
|
XTAPI
|
||||||
VOID
|
VOID
|
||||||
HlInitializeProcessor(VOID);
|
HlInitializeProcessor(IN ULONG CpuNumber);
|
||||||
|
|
||||||
#endif /* __XTOSKRNL_HLI_H */
|
#endif /* __XTOSKRNL_HLI_H */
|
||||||
|
@ -48,7 +48,11 @@ HlpHandlePicSpuriousService(VOID);
|
|||||||
|
|
||||||
XTAPI
|
XTAPI
|
||||||
VOID
|
VOID
|
||||||
HlpInitializeApic(VOID);
|
HlpInitializeApic(IN ULONG CpuNumber);
|
||||||
|
|
||||||
|
XTAPI
|
||||||
|
VOID
|
||||||
|
HlpInitializePic(IN ULONG CpuNumber);
|
||||||
|
|
||||||
XTFASTCALL
|
XTFASTCALL
|
||||||
KRUNLEVEL
|
KRUNLEVEL
|
||||||
|
@ -73,14 +73,11 @@ KepInitializeMachine(VOID)
|
|||||||
HlIoPortOutByte(0x376, 0);
|
HlIoPortOutByte(0x376, 0);
|
||||||
HlIoPortOutByte(0x3F6, 0);
|
HlIoPortOutByte(0x3F6, 0);
|
||||||
|
|
||||||
/* Disable the legacy PIC */
|
|
||||||
HlDisableLegacyPic();
|
|
||||||
|
|
||||||
/* Initialize frame buffer */
|
/* Initialize frame buffer */
|
||||||
HlInitializeFrameBuffer();
|
HlInitializeFrameBuffer();
|
||||||
|
|
||||||
/* Initialize processor */
|
/* Initialize processor */
|
||||||
HlInitializeProcessor();
|
HlInitializeProcessor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,14 +73,11 @@ KepInitializeMachine(VOID)
|
|||||||
HlIoPortOutByte(0x376, 0);
|
HlIoPortOutByte(0x376, 0);
|
||||||
HlIoPortOutByte(0x3F6, 0);
|
HlIoPortOutByte(0x3F6, 0);
|
||||||
|
|
||||||
/* Disable the legacy PIC */
|
|
||||||
HlDisableLegacyPic();
|
|
||||||
|
|
||||||
/* Initialize frame buffer */
|
/* Initialize frame buffer */
|
||||||
HlInitializeFrameBuffer();
|
HlInitializeFrameBuffer();
|
||||||
|
|
||||||
/* Initialize processor */
|
/* Initialize processor */
|
||||||
HlInitializeProcessor();
|
HlInitializeProcessor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user