summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2021-05-31 10:38:45 +0300
committerKyösti Mälkki <kyosti.malkki@gmail.com>2021-06-10 17:46:48 +0000
commit0cfa9110b6d004777cca991771d74ed8dcf5c0e4 (patch)
treed174a52293212da73fa5b4fbcdb99959c1ecc46e /src/cpu
parent41e6216df394b729e8a696464f574c4d89317930 (diff)
cpu/x86/lapic: Add lapic_update32() helper
Change-Id: I57c5d85d3098f9d59f26f427fe16829e4e769194 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/55187 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Wonkyu Kim <wonkyu.kim@intel.com> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/x86/lapic/lapic.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/src/cpu/x86/lapic/lapic.c b/src/cpu/x86/lapic/lapic.c
index 09dd00397e..468a5dc256 100644
--- a/src/cpu/x86/lapic/lapic.c
+++ b/src/cpu/x86/lapic/lapic.c
@@ -2,10 +2,7 @@
#include <cpu/x86/lapic.h>
#include <console/console.h>
-
-#if !CONFIG(XAPIC_ONLY)
-#error "BUG: lapic_write_around() needs to be fixed for X2APIC."
-#endif
+#include <stdint.h>
void lapic_virtual_wire_mode_init(void)
{
@@ -25,31 +22,20 @@ void lapic_virtual_wire_mode_init(void)
/*
* Set Task Priority to 'accept all'.
*/
- lapic_write_around(LAPIC_TASKPRI,
- lapic_read_around(LAPIC_TASKPRI) & ~LAPIC_TPRI_MASK);
+ lapic_update32(LAPIC_TASKPRI, ~LAPIC_TPRI_MASK, 0);
/* Put the local APIC in virtual wire mode */
- lapic_write_around(LAPIC_SPIV,
- (lapic_read_around(LAPIC_SPIV) & ~(LAPIC_VECTOR_MASK))
- | LAPIC_SPIV_ENABLE);
- lapic_write_around(LAPIC_LVT0,
- (lapic_read_around(LAPIC_LVT0) &
- ~(LAPIC_LVT_MASKED | LAPIC_LVT_LEVEL_TRIGGER |
- LAPIC_LVT_REMOTE_IRR | LAPIC_INPUT_POLARITY |
- LAPIC_SEND_PENDING | LAPIC_LVT_RESERVED_1 |
- LAPIC_DELIVERY_MODE_MASK))
- | (LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING |
- LAPIC_DELIVERY_MODE_EXTINT)
- );
- lapic_write_around(LAPIC_LVT1,
- (lapic_read_around(LAPIC_LVT1) &
- ~(LAPIC_LVT_MASKED | LAPIC_LVT_LEVEL_TRIGGER |
- LAPIC_LVT_REMOTE_IRR | LAPIC_INPUT_POLARITY |
- LAPIC_SEND_PENDING | LAPIC_LVT_RESERVED_1 |
- LAPIC_DELIVERY_MODE_MASK))
- | (LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING |
- LAPIC_DELIVERY_MODE_NMI)
- );
+ lapic_update32(LAPIC_SPIV, ~LAPIC_VECTOR_MASK, LAPIC_SPIV_ENABLE);
+
+ uint32_t mask = LAPIC_LVT_MASKED | LAPIC_LVT_LEVEL_TRIGGER | LAPIC_LVT_REMOTE_IRR |
+ LAPIC_INPUT_POLARITY | LAPIC_SEND_PENDING | LAPIC_LVT_RESERVED_1 |
+ LAPIC_DELIVERY_MODE_MASK;
+
+ lapic_update32(LAPIC_LVT0, ~mask, LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING |
+ LAPIC_DELIVERY_MODE_EXTINT);
+
+ lapic_update32(LAPIC_LVT1, ~mask, LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING |
+ LAPIC_DELIVERY_MODE_NMI);
printk(BIOS_DEBUG, " apic_id: 0x%x ", lapicid());
printk(BIOS_INFO, "done.\n");