kernel tree reorganization stage 1: Major cvs repository work (not logged as
[dragonfly.git] / sys / i386 / 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/i386/include/Attic/smp.h,v 1.6 2003/08/07 21:17:22 dillon Exp $
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  */
31 extern 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 "apic.h"
43
44 /* global data in mpboot.s */
45 extern int                      bootMP_size;
46
47 /* functions in mpboot.s */
48 void    bootMP                  __P((void));
49
50 /* global data in apic_vector.s */
51 extern volatile u_int           stopped_cpus;
52 extern volatile u_int           started_cpus;
53
54 extern volatile u_int           checkstate_probed_cpus;
55 extern void (*cpustop_restartfunc) __P((void));
56
57 /* functions in apic_ipl.s */
58 void    apic_eoi                __P((void));
59 u_int   io_apic_read            __P((int, int));
60 void    io_apic_write           __P((int, int, u_int));
61
62 /* global data in mp_machdep.c */
63 extern int                      bsp_apic_ready;
64 extern int                      mp_naps;
65 extern int                      mp_nbusses;
66 extern int                      mp_napics;
67 extern int                      mp_picmode;
68 extern int                      boot_cpu_id;
69 extern vm_offset_t              cpu_apic_address;
70 extern vm_offset_t              io_apic_address[];
71 extern u_int32_t                cpu_apic_versions[];
72 extern u_int32_t                *io_apic_versions;
73 extern int                      cpu_num_to_apic_id[];
74 extern int                      io_num_to_apic_id[];
75 extern int                      apic_id_to_logical[];
76 #define APIC_INTMAPSIZE 24
77 struct apic_intmapinfo {
78         int ioapic;
79         int int_pin;
80         volatile void *apic_address;
81         int redirindex;
82 };
83 extern struct apic_intmapinfo   int_to_apicintpin[];
84 extern u_int                    all_cpus;
85 extern struct pcb               stoppcbs[];
86
87 /* functions in mp_machdep.c */
88 u_int   mp_bootaddress          __P((u_int));
89 int     mp_probe                __P((void));
90 void    mp_start                __P((void));
91 void    mp_announce             __P((void));
92 u_int   isa_apic_mask           __P((u_int));
93 int     isa_apic_irq            __P((int));
94 int     pci_apic_irq            __P((int, int, int));
95 int     apic_irq                __P((int, int));
96 int     next_apic_irq           __P((int));
97 int     undirect_isa_irq        __P((int));
98 int     undirect_pci_irq        __P((int));
99 int     apic_bus_type           __P((int));
100 int     apic_src_bus_id         __P((int, int));
101 int     apic_src_bus_irq        __P((int, int));
102 int     apic_int_type           __P((int, int));
103 int     apic_trigger            __P((int, int));
104 int     apic_polarity           __P((int, int));
105 void    assign_apic_irq         __P((int apic, int intpin, int irq));
106 void    revoke_apic_irq         __P((int irq));
107 void    bsp_apic_configure      __P((void));
108 void    init_secondary          __P((void));
109 int     stop_cpus               __P((u_int));
110 void    ap_init                 __P((void));
111 int     restart_cpus            __P((u_int));
112 #ifdef BETTER_CLOCK 
113 void    forward_statclock       __P((int pscnt));
114 void    forward_hardclock       __P((int pscnt));
115 #endif /* BETTER_CLOCK */
116 void    forward_signal          __P((struct proc *));
117 void    forward_roundrobin      __P((void));
118 #ifdef  APIC_INTR_REORDER
119 void    set_lapic_isrloc        __P((int, int));
120 #endif /* APIC_INTR_REORDER */
121 void    smp_rendezvous_action   __P((void));
122 void    smp_rendezvous          __P((void (*)(void *), 
123                                      void (*)(void *),
124                                      void (*)(void *),
125                                      void *arg));
126
127 /* global data in mpapic.c */
128 extern volatile lapic_t         lapic;
129 extern volatile ioapic_t        **ioapic;
130
131 /* functions in mpapic.c */
132 void    apic_dump               __P((char*));
133 void    apic_initialize         __P((void));
134 void    imen_dump               __P((void));
135 int     apic_ipi                __P((int, int, int));
136 int     selected_apic_ipi       __P((u_int, int, int));
137 int     io_apic_setup           __P((int));
138 void    io_apic_setup_intpin    __P((int, int));
139 void    io_apic_set_id          __P((int, int));
140 int     io_apic_get_id          __P((int));
141 int     ext_int_setup           __P((int, int));
142
143 #if defined(READY)
144 void    clr_io_apic_mask24      __P((int, u_int32_t));
145 void    set_io_apic_mask24      __P((int, u_int32_t));
146 #endif /* READY */
147
148 void    set_apic_timer          __P((int));
149 int     read_apic_timer         __P((void));
150 void    u_sleep                 __P((int));
151 void    cpu_send_ipiq           __P((int));
152
153 /* global data in init_smp.c */
154 extern int                      invltlb_ok;
155 extern int                      smp_active;
156 extern int                      smp_started;
157 extern volatile int             smp_idle_loops;
158
159 #endif /* !LOCORE */
160 #else   /* !SMP && !APIC_IO */
161
162 #endif
163
164 #endif /* _KERNEL */
165 #endif /* _MACHINE_SMP_H_ */