Deleted Added
full compact
mptable.c (82309) mptable.c (83366)
1/*
2 * Copyright (c) 1996, by Steve Passe
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 *
1/*
2 * Copyright (c) 1996, by Steve Passe
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 *
25 * $FreeBSD: head/sys/i386/i386/mptable.c 82309 2001-08-25 02:20:02Z peter $
25 * $FreeBSD: head/sys/i386/i386/mptable.c 83366 2001-09-12 08:38:13Z julian $
26 */
27
28#include "opt_cpu.h"
26 */
27
28#include "opt_cpu.h"
29#include "opt_upages.h"
29#include "opt_kstack_pages.h"
30
31#ifdef SMP
32#include <machine/smptests.h>
33#else
34#error
35#endif
36
37#include <sys/param.h>

--- 1917 unchanged lines hidden (view full) ---

1955
1956 /* allocate a new private data page */
1957 gd = (struct globaldata *)kmem_alloc(kernel_map, PAGE_SIZE);
1958
1959 /* wire it into the private page table page */
1960 SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
1961
1962 /* allocate and set up an idle stack data page */
30
31#ifdef SMP
32#include <machine/smptests.h>
33#else
34#error
35#endif
36
37#include <sys/param.h>

--- 1917 unchanged lines hidden (view full) ---

1955
1956 /* allocate a new private data page */
1957 gd = (struct globaldata *)kmem_alloc(kernel_map, PAGE_SIZE);
1958
1959 /* wire it into the private page table page */
1960 SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
1961
1962 /* allocate and set up an idle stack data page */
1963 stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE);
1964 for (i = 0; i < UPAGES; i++)
1963 stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); /* XXXKSE */
1964 for (i = 0; i < KSTACK_PAGES; i++)
1965 SMPpt[pg + 1 + i] = (pt_entry_t)
1966 (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
1967
1968 /* prime data page for it to use */
1969 gd->gd_cpuid = x;
1970 globaldata_register(gd);
1971
1972 /* setup a vector to our boot code */
1973 *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET;
1974 *((volatile u_short *) WARMBOOT_SEG) = (boot_addr >> 4);
1975#ifndef PC98
1976 outb(CMOS_REG, BIOS_RESET);
1977 outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
1978#endif
1979
1965 SMPpt[pg + 1 + i] = (pt_entry_t)
1966 (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
1967
1968 /* prime data page for it to use */
1969 gd->gd_cpuid = x;
1970 globaldata_register(gd);
1971
1972 /* setup a vector to our boot code */
1973 *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET;
1974 *((volatile u_short *) WARMBOOT_SEG) = (boot_addr >> 4);
1975#ifndef PC98
1976 outb(CMOS_REG, BIOS_RESET);
1977 outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
1978#endif
1979
1980 bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE];
1980 bootSTK = &SMP_prvspace[x].idlekstack[KSTACK_PAGES * PAGE_SIZE];
1981 bootAP = x;
1982
1983 /* attempt to start the Application Processor */
1984 CHECK_INIT(99); /* setup checkpoints */
1985 if (!start_ap(x, boot_addr)) {
1986 printf("AP #%d (PHY# %d) failed!\n", x, CPU_TO_ID(x));
1987 CHECK_PRINT("trace"); /* show checkpoints */
1988 /* better panic as the AP may be running loose */

--- 25 unchanged lines hidden (view full) ---

2014 /*
2015 * Set up the idle context for the BSP. Similar to above except
2016 * that some was done by locore, some by pmap.c and some is implicit
2017 * because the BSP is cpu#0 and the page is initially zero, and also
2018 * because we can refer to variables by name on the BSP..
2019 */
2020
2021 /* Allocate and setup BSP idle stack */
1981 bootAP = x;
1982
1983 /* attempt to start the Application Processor */
1984 CHECK_INIT(99); /* setup checkpoints */
1985 if (!start_ap(x, boot_addr)) {
1986 printf("AP #%d (PHY# %d) failed!\n", x, CPU_TO_ID(x));
1987 CHECK_PRINT("trace"); /* show checkpoints */
1988 /* better panic as the AP may be running loose */

--- 25 unchanged lines hidden (view full) ---

2014 /*
2015 * Set up the idle context for the BSP. Similar to above except
2016 * that some was done by locore, some by pmap.c and some is implicit
2017 * because the BSP is cpu#0 and the page is initially zero, and also
2018 * because we can refer to variables by name on the BSP..
2019 */
2020
2021 /* Allocate and setup BSP idle stack */
2022 stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE);
2023 for (i = 0; i < UPAGES; i++)
2022 stack = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE);
2023 for (i = 0; i < KSTACK_PAGES; i++)
2024 SMPpt[1 + i] = (pt_entry_t)
2025 (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
2026
2027 for (x = 0; x < NKPT; x++)
2028 PTD[x] = 0;
2029 pmap_set_opt();
2030
2031 /* number of APs actually started */

--- 204 unchanged lines hidden (view full) ---

2236 /* spin until all the AP's are ready */
2237 while (!aps_ready)
2238 /* spin */ ;
2239
2240 /*
2241 * Set curproc to our per-cpu idleproc so that mutexes have
2242 * something unique to lock with.
2243 */
2024 SMPpt[1 + i] = (pt_entry_t)
2025 (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
2026
2027 for (x = 0; x < NKPT; x++)
2028 PTD[x] = 0;
2029 pmap_set_opt();
2030
2031 /* number of APs actually started */

--- 204 unchanged lines hidden (view full) ---

2236 /* spin until all the AP's are ready */
2237 while (!aps_ready)
2238 /* spin */ ;
2239
2240 /*
2241 * Set curproc to our per-cpu idleproc so that mutexes have
2242 * something unique to lock with.
2243 */
2244 PCPU_SET(curproc, PCPU_GET(idleproc));
2244 PCPU_SET(curthread, PCPU_GET(idlethread));
2245 PCPU_SET(spinlocks, NULL);
2246
2247 /* lock against other AP's that are waking up */
2248 mtx_lock_spin(&ap_boot_mtx);
2249
2250 /* BSP may have changed PTD while we're waiting for the lock */
2251 cpu_invltlb();
2252

--- 65 unchanged lines hidden (view full) ---

2318 * For statclock, we send an IPI to all CPU's to have them call this
2319 * function.
2320 */
2321void
2322forwarded_statclock(struct trapframe frame)
2323{
2324
2325 mtx_lock_spin(&sched_lock);
2245 PCPU_SET(spinlocks, NULL);
2246
2247 /* lock against other AP's that are waking up */
2248 mtx_lock_spin(&ap_boot_mtx);
2249
2250 /* BSP may have changed PTD while we're waiting for the lock */
2251 cpu_invltlb();
2252

--- 65 unchanged lines hidden (view full) ---

2318 * For statclock, we send an IPI to all CPU's to have them call this
2319 * function.
2320 */
2321void
2322forwarded_statclock(struct trapframe frame)
2323{
2324
2325 mtx_lock_spin(&sched_lock);
2326 statclock_process(curproc, TRAPF_PC(&frame), TRAPF_USERMODE(&frame));
2326 statclock_process(curthread->td_kse, TRAPF_PC(&frame), TRAPF_USERMODE(&frame));
2327 mtx_unlock_spin(&sched_lock);
2328}
2329
2330void
2331forward_statclock(void)
2332{
2333 int map;
2334

--- 14 unchanged lines hidden (view full) ---

2349 * state and call hardclock_process() on the CPU receiving the clock interrupt
2350 * and then just use a simple IPI to handle any ast's if needed.
2351 */
2352void
2353forwarded_hardclock(struct trapframe frame)
2354{
2355
2356 mtx_lock_spin(&sched_lock);
2327 mtx_unlock_spin(&sched_lock);
2328}
2329
2330void
2331forward_statclock(void)
2332{
2333 int map;
2334

--- 14 unchanged lines hidden (view full) ---

2349 * state and call hardclock_process() on the CPU receiving the clock interrupt
2350 * and then just use a simple IPI to handle any ast's if needed.
2351 */
2352void
2353forwarded_hardclock(struct trapframe frame)
2354{
2355
2356 mtx_lock_spin(&sched_lock);
2357 hardclock_process(curproc, TRAPF_USERMODE(&frame));
2357 hardclock_process(curthread, TRAPF_USERMODE(&frame));
2358 mtx_unlock_spin(&sched_lock);
2359}
2360
2361void
2362forward_hardclock(void)
2363{
2364 u_int map;
2365

--- 77 unchanged lines hidden ---
2358 mtx_unlock_spin(&sched_lock);
2359}
2360
2361void
2362forward_hardclock(void)
2363{
2364 u_int map;
2365

--- 77 unchanged lines hidden ---