diff options
| author | Ian Moffett <ian@osmora.org> | 2025-11-17 16:48:35 -0500 |
|---|---|---|
| committer | Ian Moffett <ian@osmora.org> | 2025-11-17 16:48:35 -0500 |
| commit | 22c42d69367e9ab98622e204801223b0c8de5b43 (patch) | |
| tree | 455e5858747eb11324eb72fae9ac39b7f0838c50 | |
| parent | c0875764f2a30ea8c9d7f628f2fe0ab2e66589f8 (diff) | |
kern/amd64: lapic: Add lapic_read_id() function
Signed-off-by: Ian Moffett <ian@osmora.org>
| -rw-r--r-- | sys/arch/amd64/cpu/lapic.c | 12 | ||||
| -rw-r--r-- | sys/inc/arch/amd64/lapic.h | 5 |
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 |
