x86_64: Remove old IOAPIC code
[dragonfly.git] / sys / platform / pc64 / include / smp.h
1 /*
2  * ----------------------------------------------------------------------------
3  * "THE BEER-WARE LICENSE" (Revision 42):
4  * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
5  * can do whatever you want with this stuff. If we meet some day, and you think
6  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
7  * ----------------------------------------------------------------------------
8  *
9  * $FreeBSD: src/sys/i386/include/smp.h,v 1.50.2.5 2001/02/13 22:32:45 tegge Exp $
10  * $DragonFly: src/sys/platform/pc32/include/smp.h,v 1.20 2006/11/07 06:43:24 dillon Exp $
11  *
12  */
13
14 #ifndef _MACHINE_SMP_H_
15 #define _MACHINE_SMP_H_
16
17 #ifdef _KERNEL
18
19 #ifndef LOCORE
20
21 /* XXX wrong header */
22 void    initializecpu(void);
23
24 #endif  /* LOCORE */
25
26 #if defined(SMP)
27
28 #ifndef LOCORE
29
30 /*
31  * For sending values to POST displays.
32  * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
33  */
34 extern int current_postcode;  /** XXX currently in mp_machdep.c */
35 #define POSTCODE(X)     current_postcode = (X), \
36                         outb(0x80, current_postcode)
37 #define POSTCODE_LO(X)  current_postcode &= 0xf0, \
38                         current_postcode |= ((X) & 0x0f), \
39                         outb(0x80, current_postcode)
40 #define POSTCODE_HI(X)  current_postcode &= 0x0f, \
41                         current_postcode |= (((X) << 4) & 0xf0), \
42                         outb(0x80, current_postcode)
43
44
45 #include <machine_base/apic/apicreg.h>
46 #include <machine/pcb.h>
47
48 /* global symbols in mpboot.S */
49 extern char                     mptramp_start[];
50 extern char                     mptramp_end[];
51 extern u_int32_t                mptramp_pagetables;
52
53 /* functions in mpboot.s */
54 void    bootMP                  (void);
55
56 /* global data in apic_vector.s */
57 extern volatile cpumask_t       stopped_cpus;
58 extern volatile cpumask_t       started_cpus;
59
60 extern volatile u_int           checkstate_probed_cpus;
61 extern void (*cpustop_restartfunc) (void);
62
63 /* functions in apic_ipl.s */
64 u_int   ioapic_read             (volatile void *, int);
65 void    ioapic_write            (volatile void *, int, u_int);
66
67 /* global data in mp_machdep.c */
68 extern int                      imcr_present;
69 extern int                      apic_io_enable;
70 extern int                      mp_naps;
71 extern int                      mp_napics;
72 extern vm_offset_t              io_apic_address[];
73 extern u_int32_t                cpu_apic_versions[];
74 extern u_int32_t                *io_apic_versions;
75 extern int                      cpu_num_to_apic_id[];
76 extern int                      io_num_to_apic_id[];
77 extern int                      apic_id_to_logical[];
78 #define APIC_INTMAPSIZE 192
79 /*
80  * NOTE:
81  * - Keep size of apic_intmapinfo power of 2
82  * - Update IOAPIC_IM_SZSHIFT after changing apic_intmapinfo size
83  */
84 struct apic_intmapinfo {
85         int ioapic;
86         int int_pin;
87         volatile void *apic_address;
88         int redirindex;
89         uint32_t flags;         /* IOAPIC_IM_FLAG_ */
90         uint32_t pad[2];
91 };
92 #define IOAPIC_IM_SZSHIFT       5
93
94 #define IOAPIC_IM_FLAG_LEVEL    0x1     /* default to edge trigger */
95 #define IOAPIC_IM_FLAG_MASKED   0x2
96
97 extern struct apic_intmapinfo   int_to_apicintpin[];
98 extern struct pcb               stoppcbs[];
99
100 /* functions in mp_machdep.c */
101 void    *ioapic_map(vm_paddr_t);
102 u_int   mp_bootaddress          (u_int);
103 void    mp_start                (void);
104 void    mp_announce             (void);
105 void    mp_set_cpuids           (int, int);
106 u_int   isa_apic_mask           (u_int);
107 int     isa_apic_irq            (int);
108 int     pci_apic_irq            (int, int, int);
109 int     apic_irq                (int, int);
110 int     next_apic_irq           (int);
111 int     undirect_isa_irq        (int);
112 int     undirect_pci_irq        (int);
113 int     apic_bus_type           (int);
114 int     apic_src_bus_id         (int, int);
115 int     apic_src_bus_irq        (int, int);
116 int     apic_int_type           (int, int);
117 int     apic_trigger            (int, int);
118 int     apic_polarity           (int, int);
119 void    assign_apic_irq         (int apic, int intpin, int irq);
120 void    revoke_apic_irq         (int irq);
121 void    init_secondary          (void);
122 int     stop_cpus               (cpumask_t);
123 void    ap_init                 (void);
124 int     restart_cpus            (cpumask_t);
125 void    forward_signal          (struct proc *);
126 int     mptable_pci_int_route(int, int, int, int);
127 void    mptable_pci_int_dump(void);
128
129 #ifndef _SYS_QUEUE_H_
130 #include <sys/queue.h>
131 #endif
132
133 struct lapic_enumerator {
134         int     lapic_prio;
135         TAILQ_ENTRY(lapic_enumerator) lapic_link;
136         int     (*lapic_probe)(struct lapic_enumerator *);
137         void    (*lapic_enumerate)(struct lapic_enumerator *);
138 };
139
140 #define LAPIC_ENUM_PRIO_MPTABLE         20
141 #define LAPIC_ENUM_PRIO_MADT            40
142
143 struct ioapic_enumerator {
144         int     ioapic_prio;
145         TAILQ_ENTRY(ioapic_enumerator) ioapic_link;
146         int     (*ioapic_probe)(struct ioapic_enumerator *);
147         void    (*ioapic_enumerate)(struct ioapic_enumerator *);
148 };
149
150 #define IOAPIC_ENUM_PRIO_MPTABLE        20
151 #define IOAPIC_ENUM_PRIO_MADT           40
152
153 /* global data in mpapic.c */
154 extern volatile lapic_t         *lapic;
155 extern volatile ioapic_t        **ioapic;
156 extern int                      lapic_id_max;
157
158 #ifndef _SYS_BUS_H_
159 #include <sys/bus.h>
160 #endif
161
162 /* functions in mpapic.c */
163 void    apic_dump               (char*);
164 void    lapic_init              (boolean_t);
165 void    imen_dump               (void);
166 int     apic_ipi                (int, int, int);
167 void    selected_apic_ipi       (cpumask_t, int, int);
168 void    single_apic_ipi(int cpu, int vector, int delivery_mode);
169 int     single_apic_ipi_passive(int cpu, int vector, int delivery_mode);
170 int     io_apic_setup           (int);
171 void    io_apic_setup_intpin    (int, int);
172 void    io_apic_set_id          (int, int);
173 int     io_apic_get_id          (int);
174 int     ext_int_setup           (int, int);
175 void    lapic_config(void);
176 void    lapic_enumerator_register(struct lapic_enumerator *);
177 void    ioapic_config(void);
178 void    ioapic_enumerator_register(struct ioapic_enumerator *);
179 void    ioapic_add(void *, int, int);
180 void    ioapic_intsrc(int, int, enum intr_trigger, enum intr_polarity);
181 void    *ioapic_gsi_ioaddr(int);
182 int     ioapic_gsi_pin(int);
183 void    ioapic_pin_setup(void *, int, int,
184             enum intr_trigger, enum intr_polarity);
185 void    ioapic_extpin_setup(void *, int, int);
186 int     ioapic_extpin_gsi(void);
187 int     ioapic_gsi(int, int);
188
189 #if defined(READY)
190 void    clr_io_apic_mask24      (int, u_int32_t);
191 void    set_io_apic_mask24      (int, u_int32_t);
192 #endif /* READY */
193
194 void    set_apic_timer          (int);
195 int     get_apic_timer_frequency(void);
196 int     read_apic_timer         (void);
197 void    u_sleep                 (int);
198 void    cpu_send_ipiq           (int);
199 int     cpu_send_ipiq_passive   (int);
200
201 /* global data in init_smp.c */
202 extern cpumask_t                smp_active_mask;
203
204 #endif /* !LOCORE */
205 #else   /* !SMP */
206
207 #define smp_active_mask 1       /* smp_active_mask always 1 on UP machines */
208
209 #endif
210
211 #endif /* _KERNEL */
212 #endif /* _MACHINE_SMP_H_ */