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
|
|
|
|
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 */
|
1997-05-06 21:29:57 +00:00
|
|
|
|
1997-07-28 03:59:54 +00:00
|
|
|
/* Number of CPUs. */
|
1997-04-26 11:46:25 +00:00
|
|
|
#if defined(SMP) && !defined(NCPU)
|
|
|
|
# define NCPU 2
|
|
|
|
#endif /* SMP && NCPU */
|
|
|
|
|
1997-07-28 03:59:54 +00:00
|
|
|
/* Number of IO APICs. */
|
|
|
|
#if defined(APIC_IO) && !defined(NAPIC)
|
|
|
|
# define NAPIC 1
|
|
|
|
#endif /* SMP && NAPIC */
|
|
|
|
|
|
|
|
|
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
|
|
|
|
1997-05-29 05:57:43 +00:00
|
|
|
#include <machine/apic.h>
|
|
|
|
|
1997-04-26 11:46:25 +00:00
|
|
|
/* global data in mpboot.s */
|
|
|
|
extern int bootMP_size;
|
|
|
|
|
|
|
|
/* functions in mpboot.s */
|
|
|
|
void bootMP __P((void));
|
|
|
|
|
|
|
|
/* global data in mplock.s */
|
|
|
|
extern u_int mp_lock;
|
1997-08-20 05:22:33 +00:00
|
|
|
extern u_int isr_lock;
|
1997-08-30 08:08:10 +00:00
|
|
|
#ifdef RECURSIVE_MPINTRLOCK
|
|
|
|
extern u_int mpintr_lock;
|
|
|
|
#endif /* RECURSIVE_MPINTRLOCK */
|
1997-04-26 11:46:25 +00:00
|
|
|
|
|
|
|
/* functions in mplock.s */
|
|
|
|
void get_mplock __P((void));
|
|
|
|
void rel_mplock __P((void));
|
This mega-commit is meant to fix numerous interrelated problems. There
has been some bitrot and incorrect assumptions in the vfs_bio code. These
problems have manifest themselves worse on NFS type filesystems, but can
still affect local filesystems under certain circumstances. Most of
the problems have involved mmap consistancy, and as a side-effect broke
the vfs.ioopt code. This code might have been committed seperately, but
almost everything is interrelated.
1) Allow (pmap_object_init_pt) prefaulting of buffer-busy pages that
are fully valid.
2) Rather than deactivating erroneously read initial (header) pages in
kern_exec, we now free them.
3) Fix the rundown of non-VMIO buffers that are in an inconsistent
(missing vp) state.
4) Fix the disassociation of pages from buffers in brelse. The previous
code had rotted and was faulty in a couple of important circumstances.
5) Remove a gratuitious buffer wakeup in vfs_vmio_release.
6) Remove a crufty and currently unused cluster mechanism for VBLK
files in vfs_bio_awrite. When the code is functional, I'll add back
a cleaner version.
7) The page busy count wakeups assocated with the buffer cache usage were
incorrectly cleaned up in a previous commit by me. Revert to the
original, correct version, but with a cleaner implementation.
8) The cluster read code now tries to keep data associated with buffers
more aggressively (without breaking the heuristics) when it is presumed
that the read data (buffers) will be soon needed.
9) Change to filesystem lockmgr locks so that they use LK_NOPAUSE. The
delay loop waiting is not useful for filesystem locks, due to the
length of the time intervals.
10) Correct and clean-up spec_getpages.
11) Implement a fully functional nfs_getpages, nfs_putpages.
12) Fix nfs_write so that modifications are coherent with the NFS data on
the server disk (at least as well as NFS seems to allow.)
13) Properly support MS_INVALIDATE on NFS.
14) Properly pass down MS_INVALIDATE to lower levels of the VM code from
vm_map_clean.
15) Better support the notion of pages being busy but valid, so that
fewer in-transit waits occur. (use p->busy more for pageouts instead
of PG_BUSY.) Since the page is fully valid, it is still usable for
reads.
16) It is possible (in error) for cached pages to be busy. Make the
page allocation code handle that case correctly. (It should probably
be a printf or panic, but I want the system to handle coding errors
robustly. I'll probably add a printf.)
17) Correct the design and usage of vm_page_sleep. It didn't handle
consistancy problems very well, so make the design a little less
lofty. After vm_page_sleep, if it ever blocked, it is still important
to relookup the page (if the object generation count changed), and
verify it's status (always.)
18) In vm_pageout.c, vm_pageout_clean had rotted, so clean that up.
19) Push the page busy for writes and VM_PROT_READ into vm_pageout_flush.
20) Fix vm_pager_put_pages and it's descendents to support an int flag
instead of a boolean, so that we can pass down the invalidate bit.
1998-03-07 21:37:31 +00:00
|
|
|
int try_mplock __P((void));
|
1997-08-30 08:08:10 +00:00
|
|
|
#ifdef RECURSIVE_MPINTRLOCK
|
|
|
|
void get_mpintrlock __P((void));
|
|
|
|
void rel_mpintrlock __P((void));
|
This mega-commit is meant to fix numerous interrelated problems. There
has been some bitrot and incorrect assumptions in the vfs_bio code. These
problems have manifest themselves worse on NFS type filesystems, but can
still affect local filesystems under certain circumstances. Most of
the problems have involved mmap consistancy, and as a side-effect broke
the vfs.ioopt code. This code might have been committed seperately, but
almost everything is interrelated.
1) Allow (pmap_object_init_pt) prefaulting of buffer-busy pages that
are fully valid.
2) Rather than deactivating erroneously read initial (header) pages in
kern_exec, we now free them.
3) Fix the rundown of non-VMIO buffers that are in an inconsistent
(missing vp) state.
4) Fix the disassociation of pages from buffers in brelse. The previous
code had rotted and was faulty in a couple of important circumstances.
5) Remove a gratuitious buffer wakeup in vfs_vmio_release.
6) Remove a crufty and currently unused cluster mechanism for VBLK
files in vfs_bio_awrite. When the code is functional, I'll add back
a cleaner version.
7) The page busy count wakeups assocated with the buffer cache usage were
incorrectly cleaned up in a previous commit by me. Revert to the
original, correct version, but with a cleaner implementation.
8) The cluster read code now tries to keep data associated with buffers
more aggressively (without breaking the heuristics) when it is presumed
that the read data (buffers) will be soon needed.
9) Change to filesystem lockmgr locks so that they use LK_NOPAUSE. The
delay loop waiting is not useful for filesystem locks, due to the
length of the time intervals.
10) Correct and clean-up spec_getpages.
11) Implement a fully functional nfs_getpages, nfs_putpages.
12) Fix nfs_write so that modifications are coherent with the NFS data on
the server disk (at least as well as NFS seems to allow.)
13) Properly support MS_INVALIDATE on NFS.
14) Properly pass down MS_INVALIDATE to lower levels of the VM code from
vm_map_clean.
15) Better support the notion of pages being busy but valid, so that
fewer in-transit waits occur. (use p->busy more for pageouts instead
of PG_BUSY.) Since the page is fully valid, it is still usable for
reads.
16) It is possible (in error) for cached pages to be busy. Make the
page allocation code handle that case correctly. (It should probably
be a printf or panic, but I want the system to handle coding errors
robustly. I'll probably add a printf.)
17) Correct the design and usage of vm_page_sleep. It didn't handle
consistancy problems very well, so make the design a little less
lofty. After vm_page_sleep, if it ever blocked, it is still important
to relookup the page (if the object generation count changed), and
verify it's status (always.)
18) In vm_pageout.c, vm_pageout_clean had rotted, so clean that up.
19) Push the page busy for writes and VM_PROT_READ into vm_pageout_flush.
20) Fix vm_pager_put_pages and it's descendents to support an int flag
instead of a boolean, so that we can pass down the invalidate bit.
1998-03-07 21:37:31 +00:00
|
|
|
int try_mpintrlock __P((void));
|
1997-08-30 08:08:10 +00:00
|
|
|
#endif /* RECURSIVE_MPINTRLOCK */
|
1997-04-26 11:46:25 +00:00
|
|
|
|
1997-06-27 23:12:31 +00:00
|
|
|
/* global data in apic_vector.s */
|
|
|
|
extern volatile u_int stopped_cpus;
|
|
|
|
extern volatile u_int started_cpus;
|
|
|
|
|
1998-04-01 20:38:28 +00:00
|
|
|
extern volatile u_int checkstate_probed_cpus;
|
|
|
|
extern volatile u_int checkstate_need_ast;
|
1998-05-17 22:12:14 +00:00
|
|
|
extern volatile u_int resched_cpus;
|
|
|
|
extern void (*cpustop_restartfunc) __P((void));
|
1997-12-08 23:00:24 +00:00
|
|
|
|
1997-07-22 20:12:32 +00:00
|
|
|
/* functions in apic_ipl.s */
|
|
|
|
void apic_eoi __P((void));
|
|
|
|
u_int io_apic_read __P((int, int));
|
|
|
|
void io_apic_write __P((int, int, u_int));
|
|
|
|
|
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_ncpus;
|
|
|
|
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[];
|
|
|
|
extern u_int32_t io_apic_versions[];
|
|
|
|
extern int cpu_num_to_apic_id[];
|
|
|
|
extern int io_num_to_apic_id[];
|
|
|
|
extern int apic_id_to_logical[];
|
1998-09-06 22:41:42 +00:00
|
|
|
#define APIC_INTMAPSIZE 24
|
|
|
|
struct apic_intmapinfo {
|
|
|
|
int ioapic;
|
|
|
|
int int_pin;
|
|
|
|
volatile void *apic_address;
|
|
|
|
int redirindex;
|
|
|
|
};
|
|
|
|
extern struct apic_intmapinfo int_to_apicintpin[];
|
1997-06-27 23:12:31 +00:00
|
|
|
extern u_int all_cpus;
|
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 */
|
|
|
|
u_int mp_bootaddress __P((u_int));
|
1997-05-28 18:44:11 +00:00
|
|
|
int mp_probe __P((void));
|
1997-04-26 11:46:25 +00:00
|
|
|
void mp_start __P((void));
|
|
|
|
void mp_announce __P((void));
|
1997-06-25 20:59:15 +00:00
|
|
|
u_int isa_apic_mask __P((u_int));
|
1998-09-06 22:41:42 +00:00
|
|
|
int isa_apic_irq __P((int));
|
|
|
|
int pci_apic_irq __P((int, int, int));
|
|
|
|
int apic_irq __P((int, int));
|
|
|
|
int next_apic_irq __P((int));
|
1997-05-05 22:56:37 +00:00
|
|
|
int undirect_isa_irq __P((int));
|
1997-04-26 11:46:25 +00:00
|
|
|
int undirect_pci_irq __P((int));
|
|
|
|
int apic_bus_type __P((int));
|
|
|
|
int apic_src_bus_id __P((int, int));
|
|
|
|
int apic_src_bus_irq __P((int, int));
|
|
|
|
int apic_int_type __P((int, int));
|
|
|
|
int apic_trigger __P((int, int));
|
|
|
|
int apic_polarity __P((int, int));
|
1997-07-08 23:32:58 +00:00
|
|
|
void bsp_apic_configure __P((void));
|
1997-04-26 11:46:25 +00:00
|
|
|
void init_secondary __P((void));
|
|
|
|
void smp_invltlb __P((void));
|
1997-06-27 23:12:31 +00:00
|
|
|
int stop_cpus __P((u_int));
|
|
|
|
int restart_cpus __P((u_int));
|
1998-03-03 19:44:34 +00:00
|
|
|
#ifdef BETTER_CLOCK
|
|
|
|
void forward_statclock __P((int pscnt));
|
|
|
|
void forward_hardclock __P((int pscnt));
|
|
|
|
#endif /* BETTER_CLOCK */
|
1998-03-03 20:55:26 +00:00
|
|
|
void forward_signal __P((struct proc *));
|
1998-05-17 22:12:14 +00:00
|
|
|
void forward_roundrobin __P((void));
|
1998-03-03 22:56:30 +00:00
|
|
|
#ifdef APIC_INTR_REORDER
|
|
|
|
void set_lapic_isrloc __P((int, int));
|
|
|
|
#endif /* APIC_INTR_REORDER */
|
1999-07-20 06:52:35 +00:00
|
|
|
void smp_rendezvous_action __P((void));
|
|
|
|
void smp_rendezvous __P((void (*)(void *),
|
|
|
|
void (*)(void *),
|
|
|
|
void (*)(void *),
|
|
|
|
void *arg));
|
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;
|
|
|
|
extern volatile ioapic_t *ioapic[];
|
1997-04-26 11:46:25 +00:00
|
|
|
|
|
|
|
/* functions in mpapic.c */
|
1997-07-20 18:02:19 +00:00
|
|
|
void apic_dump __P((char*));
|
1997-07-08 23:32:58 +00:00
|
|
|
void apic_initialize __P((void));
|
1997-07-22 20:12:32 +00:00
|
|
|
void imen_dump __P((void));
|
1997-05-01 19:33:12 +00:00
|
|
|
int apic_ipi __P((int, int, int));
|
1997-04-26 11:46:25 +00:00
|
|
|
int selected_apic_ipi __P((u_int, int, int));
|
|
|
|
int io_apic_setup __P((int));
|
|
|
|
int ext_int_setup __P((int, int));
|
|
|
|
|
|
|
|
#if defined(READY)
|
|
|
|
void clr_io_apic_mask24 __P((int, u_int32_t));
|
|
|
|
void set_io_apic_mask24 __P((int, u_int32_t));
|
|
|
|
#endif /* READY */
|
|
|
|
|
|
|
|
void set_apic_timer __P((int));
|
|
|
|
int read_apic_timer __P((void));
|
|
|
|
void u_sleep __P((int));
|
|
|
|
|
|
|
|
/* global data in init_smp.c */
|
1997-04-28 00:25:00 +00:00
|
|
|
extern int invltlb_ok;
|
1997-08-15 02:34:32 +00:00
|
|
|
extern int smp_active;
|
1999-09-25 18:36:31 +00:00
|
|
|
extern int smp_started;
|
1997-08-15 02:34:32 +00:00
|
|
|
extern volatile int smp_idle_loops;
|
1997-04-26 11:46:25 +00:00
|
|
|
|
1997-07-28 03:59:54 +00:00
|
|
|
#endif /* !LOCORE */
|
1997-04-26 11:46:25 +00:00
|
|
|
#endif /* SMP || APIC_IO */
|
1999-12-29 04:46:21 +00:00
|
|
|
#endif /* _KERNEL */
|
1997-04-26 11:46:25 +00:00
|
|
|
#endif /* _MACHINE_SMP_H_ */
|