summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/cpu/lapic.c12
-rw-r--r--sys/inc/arch/amd64/lapic.h5
2 files changed, 17 insertions, 0 deletions
diff --git a/sys/arch/amd64/cpu/lapic.c b/sys/arch/amd64/cpu/lapic.c
index 7f1c9f2..acf2573 100644
--- a/sys/arch/amd64/cpu/lapic.c
+++ b/sys/arch/amd64/cpu/lapic.c
@@ -337,6 +337,18 @@ lapic_enable(struct mcb *mcb)
lapic_write(mcb, LAPIC_REG_SVR, svr | 0xFF);
}
+uint32_t
+lapic_read_id(struct mcb *mcb)
+{
+ uint32_t id;
+
+ if (!mcb->has_x2apic) {
+ return (lapic_read(mcb, LAPIC_REG_ID) >> 24) & 0xF;
+ } else {
+ return lapic_read(mcb, LAPIC_REG_ID);
+ }
+}
+
void
lapic_init(void)
{
diff --git a/sys/inc/arch/amd64/lapic.h b/sys/inc/arch/amd64/lapic.h
index ba3b333..35ba778 100644
--- a/sys/inc/arch/amd64/lapic.h
+++ b/sys/inc/arch/amd64/lapic.h
@@ -91,6 +91,11 @@ struct lapic_ipi {
};
/*
+ * Read the current local APIC id
+ */
+uint32_t lapic_read_id(struct mcb *mcb);
+
+/*
* Send an interprocessor interrupt
*
* Returns zero on success