From 6f77ff7ba50c88100934e30576f1c56f164ac8de Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Fri, 21 May 2021 09:32:45 +0200 Subject: cpu/x86/lapic: Add lapic_send_ipi() helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7207a9aadd987b4307ce8b3dd8dbfd47d0a5768e Signed-off-by: Arthur Heymans Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/55190 Reviewed-by: Angel Pons Reviewed-by: Wonkyu Kim Tested-by: build bot (Jenkins) --- src/include/cpu/x86/lapic.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/include/cpu') diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h index a3d0fcbf89..1db0ff46d1 100644 --- a/src/include/cpu/x86/lapic.h +++ b/src/include/cpu/x86/lapic.h @@ -29,10 +29,15 @@ static inline void xapic_write_atomic(unsigned long reg, uint32_t v) : : "memory", "cc"); } +static __always_inline void xapic_send_ipi(uint32_t icrlow, uint32_t apicid) +{ + xapic_write_atomic(LAPIC_ICR2, SET_LAPIC_DEST_FIELD(apicid)); + xapic_write_atomic(LAPIC_ICR, icrlow); +} + #define lapic_read_around(x) lapic_read(x) #define lapic_write_around(x, y) xapic_write_atomic((x), (y)) - static __always_inline uint32_t x2apic_read(unsigned int reg) { uint32_t value, index; @@ -111,6 +116,14 @@ static __always_inline void lapic_update32(unsigned int reg, uint32_t mask, uint } } +static __always_inline void lapic_send_ipi(uint32_t icrlow, uint32_t apicid) +{ + if (is_x2apic_mode()) + x2apic_send_ipi(icrlow, apicid); + else + xapic_send_ipi(icrlow, apicid); +} + static __always_inline void lapic_wait_icr_idle(void) { do { } while (lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY); -- cgit v1.2.3