1/**
2 * \file
3 * \brief Header file for the APIC implementation
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef APIC_H_
16#define APIC_H_
17
18#include <dev/xapic_dev.h>
19
20#define APIC_INTER_HALT_VECTOR                  248
21#define APIC_INTER_CORE_VECTOR                  249
22#define APIC_TIMER_INTERRUPT_VECTOR             250
23#define APIC_THERMAL_INTERRUPT_VECTOR           251
24#define APIC_PERFORMANCE_INTERRUPT_VECTOR       252
25#define APIC_ERROR_INTERRUPT_VECTOR             253
26#define APIC_SPURIOUS_INTERRUPT_VECTOR          254
27
28extern uint64_t apic_systime_frequency_ratio;
29
30void apic_init(void);
31void apic_send_init_assert(uint8_t destination, uint8_t destination_shorthand);
32void apic_send_init_deassert(void);
33void apic_send_start_up(uint8_t destination,
34                        uint8_t destination_shorthand,
35                        uint8_t realmode_startpage);
36extern uint8_t apic_id;
37extern bool apic_bsp;
38
39static inline bool apic_is_bsp(void)
40{
41    return apic_bsp;
42}
43
44void apic_send_std_ipi(uint8_t destination, uint8_t destination_shorthand, uint8_t vector);
45void apic_eoi(void);
46void apic_seoi(uint8_t int_nr);
47uint8_t apic_get_id(void);
48
49void apic_timer_init(bool masked, bool periodic);
50void apic_perfcnt_init(void);
51void apic_perfcnt_stop(void);
52void apic_timer_set_count(uint32_t count);
53uint32_t apic_timer_get_count(void);
54void apic_timer_set_divide(xapic_divide_t divide);
55void apic_mask_timer(void);
56void apic_unmask_timer(void);
57xapic_esr_t apic_get_esr(void);
58void apic_disable(void);
59
60#endif // APIC_H_
61