i386: Remove more old IOAPIC code
[dragonfly.git] / sys / platform / pc32 / include / smp.h
CommitLineData
984263bc
MD
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 $
a9295349 10 * $DragonFly: src/sys/platform/pc32/include/smp.h,v 1.20 2006/11/07 06:43:24 dillon Exp $
984263bc
MD
11 *
12 */
13
14#ifndef _MACHINE_SMP_H_
15#define _MACHINE_SMP_H_
16
17#ifdef _KERNEL
18
97359a5b 19#if defined(SMP)
984263bc
MD
20
21#ifndef LOCORE
22
23/*
24 * For sending values to POST displays.
25 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
26 */
27extern int current_postcode; /** XXX currently in mp_machdep.c */
28#define POSTCODE(X) current_postcode = (X), \
29 outb(0x80, current_postcode)
30#define POSTCODE_LO(X) current_postcode &= 0xf0, \
31 current_postcode |= ((X) & 0x0f), \
32 outb(0x80, current_postcode)
33#define POSTCODE_HI(X) current_postcode &= 0x0f, \
34 current_postcode |= (((X) << 4) & 0xf0), \
35 outb(0x80, current_postcode)
36
37
a9295349 38#include <machine_base/apic/apicreg.h>
7949232e 39#include <machine/pcb.h>
984263bc
MD
40
41/* global data in mpboot.s */
42extern int bootMP_size;
43
44/* functions in mpboot.s */
3ae0cd58 45void bootMP (void);
984263bc 46
984263bc 47/* global data in apic_vector.s */
da23a592
MD
48extern volatile cpumask_t stopped_cpus;
49extern volatile cpumask_t started_cpus;
984263bc
MD
50
51extern volatile u_int checkstate_probed_cpus;
3ae0cd58 52extern void (*cpustop_restartfunc) (void);
984263bc
MD
53
54/* functions in apic_ipl.s */
e17120aa
SZ
55u_int ioapic_read (volatile void *, int);
56void ioapic_write (volatile void *, int, u_int);
984263bc
MD
57
58/* global data in mp_machdep.c */
9d758cc4 59extern int imcr_present;
984263bc 60extern int mp_naps;
984263bc 61extern u_int32_t cpu_apic_versions[];
984263bc 62extern int cpu_num_to_apic_id[];
984263bc 63extern int apic_id_to_logical[];
3d28c65a 64
c571da4a 65#define APIC_INTMAPSIZE 192
3d911e0a
SZ
66/*
67 * NOTE:
68 * - Keep size of apic_intmapinfo power of 2
69 * - Update IOAPIC_IM_SZSHIFT after changing apic_intmapinfo size
70 */
984263bc
MD
71struct apic_intmapinfo {
72 int ioapic;
73 int int_pin;
74 volatile void *apic_address;
75 int redirindex;
0f546930
SZ
76 uint32_t flags; /* IOAPIC_IM_FLAG_ */
77 uint32_t pad[3];
984263bc 78};
0f546930
SZ
79#define IOAPIC_IM_SZSHIFT 5
80
81#define IOAPIC_IM_FLAG_LEVEL 0x1 /* default to edge trigger */
ea689d1c 82#define IOAPIC_IM_FLAG_MASKED 0x2
0f546930 83
984263bc 84extern struct apic_intmapinfo int_to_apicintpin[];
984263bc
MD
85extern struct pcb stoppcbs[];
86
87/* functions in mp_machdep.c */
01616f8b 88void *ioapic_map(vm_paddr_t);
3ae0cd58 89u_int mp_bootaddress (u_int);
3ae0cd58
RG
90void mp_start (void);
91void mp_announce (void);
a9112655 92void mp_set_cpuids (int, int);
3ae0cd58 93void init_secondary (void);
da23a592 94int stop_cpus (cpumask_t);
3ae0cd58 95void ap_init (void);
da23a592 96int restart_cpus (cpumask_t);
3ae0cd58 97void forward_signal (struct proc *);
e90e7ac4
SZ
98int mptable_pci_int_route(int, int, int, int);
99void mptable_pci_int_dump(void);
984263bc 100
281d9482
SZ
101#ifndef _SYS_QUEUE_H_
102#include <sys/queue.h>
103#endif
104
105struct lapic_enumerator {
106 int lapic_prio;
107 TAILQ_ENTRY(lapic_enumerator) lapic_link;
108 int (*lapic_probe)(struct lapic_enumerator *);
109 void (*lapic_enumerate)(struct lapic_enumerator *);
110};
111
65b2387f
SZ
112#define LAPIC_ENUM_PRIO_MPTABLE 20
113#define LAPIC_ENUM_PRIO_MADT 40
114
115struct ioapic_enumerator {
116 int ioapic_prio;
117 TAILQ_ENTRY(ioapic_enumerator) ioapic_link;
118 int (*ioapic_probe)(struct ioapic_enumerator *);
119 void (*ioapic_enumerate)(struct ioapic_enumerator *);
120};
121
122#define IOAPIC_ENUM_PRIO_MPTABLE 20
8589df2b 123#define IOAPIC_ENUM_PRIO_MADT 40
281d9482 124
984263bc
MD
125/* global data in mpapic.c */
126extern volatile lapic_t lapic;
c5c405ff 127extern int lapic_id_max;
984263bc 128
ecec8ddc
SZ
129#ifndef _SYS_BUS_H_
130#include <sys/bus.h>
131#endif
132
984263bc 133/* functions in mpapic.c */
3ae0cd58 134void apic_dump (char*);
5ddeabb9 135void lapic_init (boolean_t);
3ae0cd58 136int apic_ipi (int, int, int);
da23a592 137void selected_apic_ipi (cpumask_t, int, int);
41a01a4d
MD
138void single_apic_ipi(int cpu, int vector, int delivery_mode);
139int single_apic_ipi_passive(int cpu, int vector, int delivery_mode);
281d9482
SZ
140void lapic_config(void);
141void lapic_enumerator_register(struct lapic_enumerator *);
65b2387f
SZ
142void ioapic_config(void);
143void ioapic_enumerator_register(struct ioapic_enumerator *);
ebf4f417 144void ioapic_add(void *, int, int);
ae80be10 145void ioapic_intsrc(int, int, enum intr_trigger, enum intr_polarity);
23b08e03
SZ
146void *ioapic_gsi_ioaddr(int);
147int ioapic_gsi_pin(int);
ecec8ddc
SZ
148void ioapic_pin_setup(void *, int, int,
149 enum intr_trigger, enum intr_polarity);
150void ioapic_extpin_setup(void *, int, int);
6b809ec7 151int ioapic_extpin_gsi(void);
e90e7ac4 152int ioapic_gsi(int, int);
23b08e03 153
30c5f287 154extern int apic_io_enable;
85fd9f87 155
984263bc 156#if defined(READY)
3ae0cd58
RG
157void clr_io_apic_mask24 (int, u_int32_t);
158void set_io_apic_mask24 (int, u_int32_t);
984263bc
MD
159#endif /* READY */
160
3ae0cd58 161void set_apic_timer (int);
bb467734 162int get_apic_timer_frequency(void);
3ae0cd58
RG
163int read_apic_timer (void);
164void u_sleep (int);
165void cpu_send_ipiq (int);
41a01a4d 166int cpu_send_ipiq_passive (int);
984263bc
MD
167
168/* global data in init_smp.c */
0f7a3396 169extern cpumask_t smp_active_mask;
984263bc
MD
170
171#endif /* !LOCORE */
97359a5b 172#else /* !SMP */
984263bc 173
0f7a3396 174#define smp_active_mask 1 /* smp_active_mask always 1 on UP machines */
75cdbe6c 175
984263bc
MD
176#endif
177
178#endif /* _KERNEL */
179#endif /* _MACHINE_SMP_H_ */