diff --git a/xtoskrnl/hl/x86/pic.c b/xtoskrnl/hl/x86/pic.c index 018a347..a189365 100644 --- a/xtoskrnl/hl/x86/pic.c +++ b/xtoskrnl/hl/x86/pic.c @@ -133,6 +133,26 @@ HlpCheckX2ApicSupport(VOID) return TRUE; } +/** + * Gets the local APIC ID of the current processor. + * + * @return This routine returns the current processor's local APIC ID. + * + * @since XT 1.0 + */ +XTAPI +ULONG +HlpGetCpuApicId(VOID) +{ + ULONG ApicId; + + /* Read APIC ID register */ + ApicId = HlReadApicRegister(APIC_ID); + + /* Return logical CPU ID depending on current APIC mode */ + return (HlpApicMode == APIC_MODE_COMPAT) ? ((ApicId & 0xFFFFFFFF) >> APIC_XAPIC_LDR_SHIFT) : ApicId; +} + /** * Allows an APIC spurious interrupts to end up. * diff --git a/xtoskrnl/includes/amd64/hli.h b/xtoskrnl/includes/amd64/hli.h index a90eaa7..bc4a268 100644 --- a/xtoskrnl/includes/amd64/hli.h +++ b/xtoskrnl/includes/amd64/hli.h @@ -34,6 +34,10 @@ XTAPI BOOLEAN HlpCheckX2ApicSupport(VOID); +XTAPI +ULONG +HlpGetCpuApicId(VOID); + XTCDECL VOID HlpHandleApicSpuriousService(VOID); diff --git a/xtoskrnl/includes/i686/hli.h b/xtoskrnl/includes/i686/hli.h index cd41c00..3ce4df4 100644 --- a/xtoskrnl/includes/i686/hli.h +++ b/xtoskrnl/includes/i686/hli.h @@ -34,6 +34,10 @@ XTAPI BOOLEAN HlpCheckX2ApicSupport(VOID); +XTAPI +ULONG +HlpGetCpuApicId(VOID); + XTCDECL VOID HlpHandleApicSpuriousService(VOID);