2 * From coreboot file of same name
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2014 Google, Inc
7 * SPDX-License-Identifier: GPL-2.0
13 #include <asm/lapic.h>
16 void lapic_setup(void)
19 /* Only Pentium Pro and later have those MSR stuff */
20 debug("Setting up local apic: ");
22 /* Enable the local apic */
26 * Set Task Priority to 'accept all'.
28 lapic_write_around(LAPIC_TASKPRI,
29 lapic_read_around(LAPIC_TASKPRI) & ~LAPIC_TPRI_MASK);
31 /* Put the local apic in virtual wire mode */
32 lapic_write_around(LAPIC_SPIV, (lapic_read_around(LAPIC_SPIV) &
33 ~(LAPIC_VECTOR_MASK)) | LAPIC_SPIV_ENABLE);
34 lapic_write_around(LAPIC_LVT0, (lapic_read_around(LAPIC_LVT0) &
35 ~(LAPIC_LVT_MASKED | LAPIC_LVT_LEVEL_TRIGGER |
36 LAPIC_LVT_REMOTE_IRR | LAPIC_INPUT_POLARITY |
37 LAPIC_SEND_PENDING | LAPIC_LVT_RESERVED_1 |
38 LAPIC_DELIVERY_MODE_MASK)) |
39 (LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING |
40 LAPIC_DELIVERY_MODE_EXTINT));
41 lapic_write_around(LAPIC_LVT1, (lapic_read_around(LAPIC_LVT1) &
42 ~(LAPIC_LVT_MASKED | LAPIC_LVT_LEVEL_TRIGGER |
43 LAPIC_LVT_REMOTE_IRR | LAPIC_INPUT_POLARITY |
44 LAPIC_SEND_PENDING | LAPIC_LVT_RESERVED_1 |
45 LAPIC_DELIVERY_MODE_MASK)) |
46 (LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING |
47 LAPIC_DELIVERY_MODE_NMI));
49 debug("apic_id: 0x%02lx, ", lapicid());
50 #else /* !NEED_LLAPIC */
51 /* Only Pentium Pro and later have those MSR stuff */
52 debug("Disabling local apic: ");
54 #endif /* !NEED_LAPIC */
56 post_code(POST_LAPIC);