mp_machdep.c (234208) | mp_machdep.c (235622) |
---|---|
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 --- 10 unchanged lines hidden (view full) --- 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 26#include <sys/cdefs.h> | 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 --- 10 unchanged lines hidden (view full) --- 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 26#include <sys/cdefs.h> |
27__FBSDID("$FreeBSD: head/sys/i386/i386/mp_machdep.c 234208 2012-04-13 07:18:19Z avg $"); | 27__FBSDID("$FreeBSD: head/sys/i386/i386/mp_machdep.c 235622 2012-05-18 18:55:58Z iwasaki $"); |
28 29#include "opt_apic.h" 30#include "opt_cpu.h" 31#include "opt_kstack_pages.h" 32#include "opt_pmap.h" 33#include "opt_sched.h" 34#include "opt_smp.h" 35 --- 105 unchanged lines hidden (view full) --- 141char *bootSTK; 142static int bootAP; 143 144/* Free these after use */ 145void *bootstacks[MAXCPU]; 146static void *dpcpu; 147 148struct pcb stoppcbs[MAXCPU]; | 28 29#include "opt_apic.h" 30#include "opt_cpu.h" 31#include "opt_kstack_pages.h" 32#include "opt_pmap.h" 33#include "opt_sched.h" 34#include "opt_smp.h" 35 --- 105 unchanged lines hidden (view full) --- 141char *bootSTK; 142static int bootAP; 143 144/* Free these after use */ 145void *bootstacks[MAXCPU]; 146static void *dpcpu; 147 148struct pcb stoppcbs[MAXCPU]; |
149struct pcb **susppcbs = NULL; |
|
149 150/* Variables needed for SMP tlb shootdown. */ 151vm_offset_t smp_tlb_addr1; 152vm_offset_t smp_tlb_addr2; 153volatile int smp_tlb_wait; 154 155#ifdef COUNT_IPIS 156/* Interrupt counts. */ --- 425 unchanged lines hidden (view full) --- 582 /* Install generic inter-CPU IPI handler */ 583 setidt(IPI_BITMAP_VECTOR, IDTVEC(ipi_intr_bitmap_handler), 584 SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); 585 586 /* Install an inter-CPU IPI for CPU stop/restart */ 587 setidt(IPI_STOP, IDTVEC(cpustop), 588 SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); 589 | 150 151/* Variables needed for SMP tlb shootdown. */ 152vm_offset_t smp_tlb_addr1; 153vm_offset_t smp_tlb_addr2; 154volatile int smp_tlb_wait; 155 156#ifdef COUNT_IPIS 157/* Interrupt counts. */ --- 425 unchanged lines hidden (view full) --- 583 /* Install generic inter-CPU IPI handler */ 584 setidt(IPI_BITMAP_VECTOR, IDTVEC(ipi_intr_bitmap_handler), 585 SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); 586 587 /* Install an inter-CPU IPI for CPU stop/restart */ 588 setidt(IPI_STOP, IDTVEC(cpustop), 589 SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); 590 |
591 /* Install an inter-CPU IPI for CPU suspend/resume */ 592 setidt(IPI_SUSPEND, IDTVEC(cpususpend), 593 SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL)); |
|
590 591 /* Set boot_cpu_id if needed. */ 592 if (boot_cpu_id == -1) { 593 boot_cpu_id = PCPU_GET(apic_id); 594 cpu_info[boot_cpu_id].cpu_bsp = 1; 595 } else 596 KASSERT(boot_cpu_id == PCPU_GET(apic_id), 597 ("BSP's APIC ID doesn't match boot_cpu_id")); --- 895 unchanged lines hidden (view full) --- 1493 1494 if (cpu == 0 && cpustop_restartfunc != NULL) { 1495 cpustop_restartfunc(); 1496 cpustop_restartfunc = NULL; 1497 } 1498} 1499 1500/* | 594 595 /* Set boot_cpu_id if needed. */ 596 if (boot_cpu_id == -1) { 597 boot_cpu_id = PCPU_GET(apic_id); 598 cpu_info[boot_cpu_id].cpu_bsp = 1; 599 } else 600 KASSERT(boot_cpu_id == PCPU_GET(apic_id), 601 ("BSP's APIC ID doesn't match boot_cpu_id")); --- 895 unchanged lines hidden (view full) --- 1497 1498 if (cpu == 0 && cpustop_restartfunc != NULL) { 1499 cpustop_restartfunc(); 1500 cpustop_restartfunc = NULL; 1501 } 1502} 1503 1504/* |
1505 * Handle an IPI_SUSPEND by saving our current context and spinning until we 1506 * are resumed. 1507 */ 1508void 1509cpususpend_handler(void) 1510{ 1511 u_int cpu; 1512 1513 cpu = PCPU_GET(cpuid); 1514 1515 if (suspendctx(susppcbs[cpu])) { 1516 wbinvd(); 1517 CPU_SET_ATOMIC(cpu, &stopped_cpus); 1518 } else { 1519 pmap_init_pat(); 1520 PCPU_SET(switchtime, 0); 1521 PCPU_SET(switchticks, ticks); 1522 susppcbs[cpu]->pcb_eip = 0; 1523 } 1524 1525 /* Wait for resume */ 1526 while (!CPU_ISSET(cpu, &started_cpus)) 1527 ia32_pause(); 1528 1529 CPU_CLR_ATOMIC(cpu, &started_cpus); 1530 CPU_CLR_ATOMIC(cpu, &stopped_cpus); 1531 1532 /* Resume MCA and local APIC */ 1533 mca_resume(); 1534 lapic_setup(0); 1535} 1536/* |
|
1501 * This is called once the rest of the system is up and running and we're 1502 * ready to let the AP's out of the pen. 1503 */ 1504static void 1505release_aps(void *dummy __unused) 1506{ 1507 1508 if (mp_ncpus == 1) --- 40 unchanged lines hidden --- | 1537 * This is called once the rest of the system is up and running and we're 1538 * ready to let the AP's out of the pen. 1539 */ 1540static void 1541release_aps(void *dummy __unused) 1542{ 1543 1544 if (mp_ncpus == 1) --- 40 unchanged lines hidden --- |