kernel: Make SMP support default (and non-optional).
[dragonfly.git] / sys / platform / vkernel / 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  */
11
12 #ifndef _MACHINE_SMP_H_
13 #define _MACHINE_SMP_H_
14
15 #ifdef _KERNEL
16
17 #ifndef LOCORE
18
19 #if 0
20
21 /*
22  * For sending values to POST displays.
23  * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
24  */
25 extern int current_postcode;  /** XXX currently in mp_machdep.c */
26 #define POSTCODE(X)     current_postcode = (X), \
27                         outb(0x80, current_postcode)
28 #define POSTCODE_LO(X)  current_postcode &= 0xf0, \
29                         current_postcode |= ((X) & 0x0f), \
30                         outb(0x80, current_postcode)
31 #define POSTCODE_HI(X)  current_postcode &= 0x0f, \
32                         current_postcode |= (((X) << 4) & 0xf0), \
33                         outb(0x80, current_postcode)
34
35
36 #include <machine_base/apic/apicreg.h>
37 #include <machine/pcb.h>
38
39 /* global data in mpboot.s */
40 extern int                      bootMP_size;
41
42 /* functions in mpboot.s */
43 void    bootMP                  (void);
44
45 #endif
46
47 /* global data in apic_vector.s */
48 extern volatile cpumask_t       stopped_cpus;
49 extern int                      optcpus;        /* from main() */
50 extern int                      vkernel_b_arg;  /* arg from main() */
51 extern int                      vkernel_B_arg;  /* arg from main() */
52
53 #if 0
54 extern volatile cpumask_t       started_cpus;
55
56 extern volatile cpumask_t       checkstate_probed_cpus;
57 extern void (*cpustop_restartfunc) (void);
58
59 /* functions in apic_ipl.s */
60 u_int   io_apic_read            (int, int);
61 void    io_apic_write           (int, int, u_int);
62
63 #endif
64
65 #if 0
66 /* global data in mp_machdep.c */
67 extern int                      bsp_apic_ready;
68 extern int                      mp_naps;
69 extern int                      mp_nbusses;
70 extern int                      mp_napics;
71 extern int                      boot_cpu_id;
72 extern vm_offset_t              cpu_apic_address;
73 extern vm_offset_t              io_apic_address[];
74 extern u_int32_t                cpu_apic_versions[];
75 extern u_int32_t                *io_apic_versions;
76 extern int                      cpu_num_to_apic_id[];
77 extern int                      io_num_to_apic_id[];
78 extern int                      apic_id_to_logical[];
79 #endif
80
81 #if 0
82 #define APIC_INTMAPSIZE 24
83 struct apic_intmapinfo {
84         int ioapic;
85         int int_pin;
86         volatile void *apic_address;
87         int redirindex;
88 };
89 extern struct apic_intmapinfo   int_to_apicintpin[];
90 extern struct pcb               stoppcbs[];
91
92 #endif
93
94 #if 0
95 /* functions in mp_machdep.c */
96 void    *permanent_io_mapping(vm_paddr_t);
97 u_int   mp_bootaddress          (u_int);
98 int     mp_probe                (void);
99 #endif
100 void    mp_start                (void);
101 void    mp_announce             (void);
102 #if 0
103 u_int   isa_apic_mask           (u_int);
104 int     isa_apic_irq            (int);
105 int     pci_apic_irq            (int, int, int);
106 int     apic_irq                (int, int);
107 int     next_apic_irq           (int);
108 int     undirect_isa_irq        (int);
109 int     undirect_pci_irq        (int);
110 int     apic_bus_type           (int);
111 int     apic_src_bus_id         (int, int);
112 int     apic_src_bus_irq        (int, int);
113 int     apic_int_type           (int, int);
114 int     apic_trigger            (int, int);
115 int     apic_polarity           (int, int);
116 void    assign_apic_irq         (int apic, int intpin, int irq);
117 void    revoke_apic_irq         (int irq);
118 void    init_secondary          (void);
119 #endif
120 int     stop_cpus               (cpumask_t);
121 void    ap_init                 (void);
122 int     restart_cpus            (cpumask_t);
123 #if 0
124 void    forward_signal          (struct proc *);
125
126 #endif
127
128 #if 0
129 /* global data in mpapic.c */
130 extern volatile lapic_t         lapic;
131 extern volatile ioapic_t        **ioapic;
132 #endif
133
134 /* functions in mpapic.c */
135 #if 0
136 void    apic_dump               (char*);
137 void    apic_initialize         (void);
138 void    imen_dump               (void);
139 int     apic_ipi                (int, int, int);
140 void    selected_apic_ipi       (cpumask_t, int, int);
141 void    single_apic_ipi(int cpu, int vector, int delivery_mode);
142 int     single_apic_ipi_passive(int cpu, int vector, int delivery_mode);
143 int     io_apic_setup           (int);
144 void    io_apic_setup_intpin    (int, int);
145 void    io_apic_set_id          (int, int);
146 int     io_apic_get_id          (int);
147 int     ext_int_setup           (int, int);
148 #endif
149
150 #if 0
151 void    clr_io_apic_mask24      (int, u_int32_t);
152 void    set_io_apic_mask24      (int, u_int32_t);
153 #endif
154
155 #if 0
156 void    set_apic_timer          (int);
157 int     read_apic_timer         (void);
158 void    u_sleep                 (int);
159 #endif
160 void    cpu_send_ipiq           (int);
161 int     cpu_send_ipiq_passive   (int);
162
163 /* global data in init_smp.c */
164 extern cpumask_t                smp_active_mask;
165
166 /* Detect CPU topology bits */
167 void detect_cpu_topology(void);
168
169 /* Interface functions for IDs calculation */
170 int get_chip_ID(int cpuid);
171 int get_core_number_within_chip(int cpuid);
172 int get_logical_CPU_number_within_core(int cpuid);
173
174 /* Assume that APICID = CPUID for virtual processors */
175 #define get_cpuid_from_apicid(cpuid) cpuid
176 #define get_apicid_from_cpuid(cpuid) cpuid
177
178 #endif /* !LOCORE */
179
180 #endif /* _KERNEL */
181 #endif /* _MACHINE_SMP_H_ */