1997-04-26 11:46:25 +00:00
|
|
|
/*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
|
|
* <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
|
|
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
|
|
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1997-04-26 11:46:25 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MACHINE_SMP_H_
|
|
|
|
#define _MACHINE_SMP_H_
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1997-04-26 11:46:25 +00:00
|
|
|
|
2000-09-16 18:55:05 +00:00
|
|
|
#if defined(SMP) && defined(I386_CPU) && !defined(COMPILING_LINT)
|
2000-09-07 01:33:02 +00:00
|
|
|
#error SMP not supported with I386_CPU
|
|
|
|
#endif
|
1997-05-06 21:29:57 +00:00
|
|
|
#if defined(SMP) && !defined(APIC_IO)
|
|
|
|
# error APIC_IO required for SMP, add "options APIC_IO" to your config file.
|
1997-06-27 23:12:31 +00:00
|
|
|
#endif /* SMP && !APIC_IO */
|
2002-10-17 18:17:28 +00:00
|
|
|
#if defined(SMP) && defined(CPU_DISABLE_CMPXCHG) && !defined(COMPILING_LINT)
|
2002-10-17 05:51:36 +00:00
|
|
|
#error SMP not supported with CPU_DISABLE_CMPXCHG
|
|
|
|
#endif
|
1997-05-06 21:29:57 +00:00
|
|
|
|
1997-04-26 11:46:25 +00:00
|
|
|
#if defined(SMP) || defined(APIC_IO)
|
|
|
|
|
1997-07-28 03:59:54 +00:00
|
|
|
#ifndef LOCORE
|
|
|
|
|
1997-06-27 23:12:31 +00:00
|
|
|
/*
|
|
|
|
* For sending values to POST displays.
|
1997-07-06 23:40:15 +00:00
|
|
|
* XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
|
1997-06-27 23:12:31 +00:00
|
|
|
*/
|
1997-07-06 23:40:15 +00:00
|
|
|
extern int current_postcode; /** XXX currently in mp_machdep.c */
|
|
|
|
#define POSTCODE(X) current_postcode = (X), \
|
|
|
|
outb(0x80, current_postcode)
|
|
|
|
#define POSTCODE_LO(X) current_postcode &= 0xf0, \
|
|
|
|
current_postcode |= ((X) & 0x0f), \
|
|
|
|
outb(0x80, current_postcode)
|
|
|
|
#define POSTCODE_HI(X) current_postcode &= 0x0f, \
|
|
|
|
current_postcode |= (((X) << 4) & 0xf0), \
|
|
|
|
outb(0x80, current_postcode)
|
|
|
|
|
1997-06-27 23:12:31 +00:00
|
|
|
|
2001-04-27 19:28:25 +00:00
|
|
|
#include <sys/bus.h> /* XXX */
|
1997-05-29 05:57:43 +00:00
|
|
|
#include <machine/apic.h>
|
2001-04-27 19:28:25 +00:00
|
|
|
#include <machine/frame.h>
|
|
|
|
#include <i386/isa/icu.h>
|
|
|
|
#include <i386/isa/intr_machdep.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interprocessor interrupts for SMP.
|
|
|
|
*/
|
|
|
|
#define IPI_INVLTLB XINVLTLB_OFFSET
|
2002-07-12 07:56:11 +00:00
|
|
|
#define IPI_INVLPG XINVLPG_OFFSET
|
|
|
|
#define IPI_INVLRNG XINVLRNG_OFFSET
|
2003-04-02 23:53:30 +00:00
|
|
|
#define IPI_LAZYPMAP XLAZYPMAP_OFFSET
|
2001-04-27 19:28:25 +00:00
|
|
|
#define IPI_RENDEZVOUS XRENDEZVOUS_OFFSET
|
|
|
|
#define IPI_AST XCPUAST_OFFSET
|
|
|
|
#define IPI_STOP XCPUSTOP_OFFSET
|
|
|
|
#define IPI_HARDCLOCK XHARDCLOCK_OFFSET
|
|
|
|
#define IPI_STATCLOCK XSTATCLOCK_OFFSET
|
1997-05-29 05:57:43 +00:00
|
|
|
|
1997-04-26 11:46:25 +00:00
|
|
|
/* global data in mpboot.s */
|
|
|
|
extern int bootMP_size;
|
|
|
|
|
|
|
|
/* functions in mpboot.s */
|
2002-03-23 15:09:35 +00:00
|
|
|
void bootMP(void);
|
1997-04-26 11:46:25 +00:00
|
|
|
|
|
|
|
/* global data in mp_machdep.c */
|
1997-08-24 20:33:32 +00:00
|
|
|
extern int bsp_apic_ready;
|
1997-04-26 11:46:25 +00:00
|
|
|
extern int mp_naps;
|
|
|
|
extern int mp_nbusses;
|
|
|
|
extern int mp_napics;
|
|
|
|
extern int mp_picmode;
|
|
|
|
extern int boot_cpu_id;
|
|
|
|
extern vm_offset_t cpu_apic_address;
|
|
|
|
extern vm_offset_t io_apic_address[];
|
|
|
|
extern u_int32_t cpu_apic_versions[];
|
2000-09-22 23:40:10 +00:00
|
|
|
extern u_int32_t *io_apic_versions;
|
1997-04-26 11:46:25 +00:00
|
|
|
extern int cpu_num_to_apic_id[];
|
|
|
|
extern int io_num_to_apic_id[];
|
|
|
|
extern int apic_id_to_logical[];
|
2000-12-04 21:15:14 +00:00
|
|
|
#define APIC_INTMAPSIZE 32
|
1998-09-06 22:41:42 +00:00
|
|
|
struct apic_intmapinfo {
|
|
|
|
int ioapic;
|
|
|
|
int int_pin;
|
|
|
|
volatile void *apic_address;
|
|
|
|
int redirindex;
|
|
|
|
};
|
|
|
|
extern struct apic_intmapinfo int_to_apicintpin[];
|
1998-05-17 22:12:14 +00:00
|
|
|
extern struct pcb stoppcbs[];
|
1997-04-26 11:46:25 +00:00
|
|
|
|
|
|
|
/* functions in mp_machdep.c */
|
2002-03-23 15:09:35 +00:00
|
|
|
void i386_mp_probe(void);
|
|
|
|
u_int mp_bootaddress(u_int);
|
|
|
|
u_int isa_apic_mask(u_int);
|
|
|
|
int isa_apic_irq(int);
|
|
|
|
int pci_apic_irq(int, int, int);
|
|
|
|
int apic_irq(int, int);
|
|
|
|
int next_apic_irq(int);
|
|
|
|
int undirect_isa_irq(int);
|
|
|
|
int undirect_pci_irq(int);
|
|
|
|
int apic_bus_type(int);
|
|
|
|
int apic_src_bus_id(int, int);
|
|
|
|
int apic_src_bus_irq(int, int);
|
|
|
|
int apic_int_type(int, int);
|
|
|
|
int apic_trigger(int, int);
|
|
|
|
int apic_polarity(int, int);
|
2003-03-26 19:49:34 +00:00
|
|
|
int mp_grab_cpu_hlt(void);
|
2002-03-23 15:09:35 +00:00
|
|
|
void assign_apic_irq(int apic, int intpin, int irq);
|
|
|
|
void revoke_apic_irq(int irq);
|
|
|
|
void bsp_apic_configure(void);
|
|
|
|
void init_secondary(void);
|
|
|
|
void forward_statclock(void);
|
2003-02-03 17:53:15 +00:00
|
|
|
void forwarded_statclock(struct clockframe frame);
|
2002-03-23 15:09:35 +00:00
|
|
|
void forward_hardclock(void);
|
2003-02-03 17:53:15 +00:00
|
|
|
void forwarded_hardclock(struct clockframe frame);
|
2002-03-23 15:09:35 +00:00
|
|
|
void ipi_selected(u_int cpus, u_int ipi);
|
|
|
|
void ipi_all(u_int ipi);
|
|
|
|
void ipi_all_but_self(u_int ipi);
|
|
|
|
void ipi_self(u_int ipi);
|
1998-03-03 22:56:30 +00:00
|
|
|
#ifdef APIC_INTR_REORDER
|
2002-03-23 15:09:35 +00:00
|
|
|
void set_lapic_isrloc(int, int);
|
1998-03-03 22:56:30 +00:00
|
|
|
#endif /* APIC_INTR_REORDER */
|
2002-07-12 07:56:11 +00:00
|
|
|
void smp_invlpg(vm_offset_t addr);
|
|
|
|
void smp_masked_invlpg(u_int mask, vm_offset_t addr);
|
|
|
|
void smp_invlpg_range(vm_offset_t startva, vm_offset_t endva);
|
|
|
|
void smp_masked_invlpg_range(u_int mask, vm_offset_t startva,
|
|
|
|
vm_offset_t endva);
|
|
|
|
void smp_invltlb(void);
|
|
|
|
void smp_masked_invltlb(u_int mask);
|
1997-04-26 11:46:25 +00:00
|
|
|
|
|
|
|
/* global data in mpapic.c */
|
1997-06-22 16:04:22 +00:00
|
|
|
extern volatile lapic_t lapic;
|
2000-09-22 23:40:10 +00:00
|
|
|
extern volatile ioapic_t **ioapic;
|
1997-04-26 11:46:25 +00:00
|
|
|
|
|
|
|
/* functions in mpapic.c */
|
2002-03-23 15:09:35 +00:00
|
|
|
void apic_dump(char*);
|
|
|
|
void apic_initialize(void);
|
|
|
|
void imen_dump(void);
|
|
|
|
int apic_ipi(int, int, int);
|
|
|
|
int selected_apic_ipi(u_int, int, int);
|
|
|
|
int io_apic_setup(int);
|
|
|
|
void io_apic_setup_intpin(int, int);
|
|
|
|
void io_apic_set_id(int, int);
|
|
|
|
int io_apic_get_id(int);
|
|
|
|
int ext_int_setup(int, int);
|
|
|
|
|
|
|
|
void set_apic_timer(int);
|
|
|
|
int read_apic_timer(void);
|
|
|
|
void u_sleep(int);
|
|
|
|
u_int io_apic_read(int, int);
|
|
|
|
void io_apic_write(int, int, u_int);
|
2000-12-06 01:04:02 +00:00
|
|
|
|
1997-07-28 03:59:54 +00:00
|
|
|
#endif /* !LOCORE */
|
2000-09-07 01:33:02 +00:00
|
|
|
#endif /* SMP && !APIC_IO */
|
2000-03-28 18:06:49 +00:00
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#endif /* _KERNEL */
|
1997-04-26 11:46:25 +00:00
|
|
|
#endif /* _MACHINE_SMP_H_ */
|