From 0cfa9110b6d004777cca991771d74ed8dcf5c0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Mon, 31 May 2021 10:38:45 +0300 Subject: cpu/x86/lapic: Add lapic_update32() helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I57c5d85d3098f9d59f26f427fe16829e4e769194 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/55187 Reviewed-by: Angel Pons Reviewed-by: Wonkyu Kim Reviewed-by: Arthur Heymans Tested-by: build bot (Jenkins) --- src/include/cpu/x86/lapic.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/include') diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h index e19458f06c..cf048a883e 100644 --- a/src/include/cpu/x86/lapic.h +++ b/src/include/cpu/x86/lapic.h @@ -92,6 +92,25 @@ static __always_inline void lapic_write(unsigned int reg, uint32_t v) xapic_write(reg, v); } +static __always_inline void lapic_update32(unsigned int reg, uint32_t mask, uint32_t or) +{ + if (is_x2apic_mode()) { + uint32_t index; + msr_t msr; + index = X2APIC_MSR_BASE_ADDRESS + (uint32_t)(reg >> 4); + msr = rdmsr(index); + msr.lo &= mask; + msr.lo |= or; + wrmsr(index, msr); + } else { + uint32_t value; + value = xapic_read(reg); + value &= mask; + value |= or; + xapic_write_atomic(reg, value); + } +} + static __always_inline void lapic_wait_icr_idle(void) { do { } while (lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY); -- cgit v1.2.3