MP Implementation 1/2: Get the APIC code working again, sweetly integrate the
[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 $
8a8d5d85 10 * $DragonFly: src/sys/platform/pc32/include/smp.h,v 1.3 2003/07/06 21:23:49 dillon Exp $
984263bc
MD
11 *
12 */
13
14#ifndef _MACHINE_SMP_H_
15#define _MACHINE_SMP_H_
16
17#ifdef _KERNEL
18
19#if defined(SMP) && !defined(APIC_IO)
20# error APIC_IO required for SMP, add "options APIC_IO" to your config file.
21#endif /* SMP && !APIC_IO */
22
23#if defined(SMP) || defined(APIC_IO)
24
25#ifndef LOCORE
26
27/*
28 * For sending values to POST displays.
29 * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
30 */
31extern int current_postcode; /** XXX currently in mp_machdep.c */
32#define POSTCODE(X) current_postcode = (X), \
33 outb(0x80, current_postcode)
34#define POSTCODE_LO(X) current_postcode &= 0xf0, \
35 current_postcode |= ((X) & 0x0f), \
36 outb(0x80, current_postcode)
37#define POSTCODE_HI(X) current_postcode &= 0x0f, \
38 current_postcode |= (((X) << 4) & 0xf0), \
39 outb(0x80, current_postcode)
40
41
42#include <machine/apic.h>
43
44/* global data in mpboot.s */
45extern int bootMP_size;
46
47/* functions in mpboot.s */
48void bootMP __P((void));
49
984263bc
MD
50/* global data in apic_vector.s */
51extern volatile u_int stopped_cpus;
52extern volatile u_int started_cpus;
53
54extern volatile u_int checkstate_probed_cpus;
55extern volatile u_int checkstate_need_ast;
56extern volatile u_int resched_cpus;
57extern void (*cpustop_restartfunc) __P((void));
58
59/* functions in apic_ipl.s */
60void apic_eoi __P((void));
61u_int io_apic_read __P((int, int));
62void io_apic_write __P((int, int, u_int));
63
64/* global data in mp_machdep.c */
65extern int bsp_apic_ready;
984263bc
MD
66extern int mp_naps;
67extern int mp_nbusses;
68extern int mp_napics;
69extern int mp_picmode;
70extern int boot_cpu_id;
71extern vm_offset_t cpu_apic_address;
72extern vm_offset_t io_apic_address[];
73extern u_int32_t cpu_apic_versions[];
74extern u_int32_t *io_apic_versions;
75extern int cpu_num_to_apic_id[];
76extern int io_num_to_apic_id[];
77extern int apic_id_to_logical[];
78#define APIC_INTMAPSIZE 24
79struct apic_intmapinfo {
80 int ioapic;
81 int int_pin;
82 volatile void *apic_address;
83 int redirindex;
84};
85extern struct apic_intmapinfo int_to_apicintpin[];
86extern u_int all_cpus;
87extern struct pcb stoppcbs[];
88
89/* functions in mp_machdep.c */
90u_int mp_bootaddress __P((u_int));
91int mp_probe __P((void));
92void mp_start __P((void));
93void mp_announce __P((void));
94u_int isa_apic_mask __P((u_int));
95int isa_apic_irq __P((int));
96int pci_apic_irq __P((int, int, int));
97int apic_irq __P((int, int));
98int next_apic_irq __P((int));
99int undirect_isa_irq __P((int));
100int undirect_pci_irq __P((int));
101int apic_bus_type __P((int));
102int apic_src_bus_id __P((int, int));
103int apic_src_bus_irq __P((int, int));
104int apic_int_type __P((int, int));
105int apic_trigger __P((int, int));
106int apic_polarity __P((int, int));
107void assign_apic_irq __P((int apic, int intpin, int irq));
108void revoke_apic_irq __P((int irq));
109void bsp_apic_configure __P((void));
110void init_secondary __P((void));
984263bc 111int stop_cpus __P((u_int));
8a8d5d85 112void ap_init __P((void));
984263bc
MD
113int restart_cpus __P((u_int));
114#ifdef BETTER_CLOCK
115void forward_statclock __P((int pscnt));
116void forward_hardclock __P((int pscnt));
117#endif /* BETTER_CLOCK */
118void forward_signal __P((struct proc *));
119void forward_roundrobin __P((void));
120#ifdef APIC_INTR_REORDER
121void set_lapic_isrloc __P((int, int));
122#endif /* APIC_INTR_REORDER */
123void smp_rendezvous_action __P((void));
124void smp_rendezvous __P((void (*)(void *),
125 void (*)(void *),
126 void (*)(void *),
127 void *arg));
128
129/* global data in mpapic.c */
130extern volatile lapic_t lapic;
131extern volatile ioapic_t **ioapic;
132
133/* functions in mpapic.c */
134void apic_dump __P((char*));
135void apic_initialize __P((void));
136void imen_dump __P((void));
137int apic_ipi __P((int, int, int));
138int selected_apic_ipi __P((u_int, int, int));
139int io_apic_setup __P((int));
140void io_apic_setup_intpin __P((int, int));
141void io_apic_set_id __P((int, int));
142int io_apic_get_id __P((int));
143int ext_int_setup __P((int, int));
144
145#if defined(READY)
146void clr_io_apic_mask24 __P((int, u_int32_t));
147void set_io_apic_mask24 __P((int, u_int32_t));
148#endif /* READY */
149
150void set_apic_timer __P((int));
151int read_apic_timer __P((void));
152void u_sleep __P((int));
153
154/* global data in init_smp.c */
155extern int invltlb_ok;
156extern int smp_active;
157extern int smp_started;
158extern volatile int smp_idle_loops;
159
160#endif /* !LOCORE */
161#else /* !SMP && !APIC_IO */
162
984263bc
MD
163#endif
164
165#endif /* _KERNEL */
166#endif /* _MACHINE_SMP_H_ */