Deleted Added
full compact
acpi_wakeup.c (236772) acpi_wakeup.c (236938)
1/*-
2 * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org>
3 * Copyright (c) 2001-2012 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
4 * Copyright (c) 2003 Peter Wemm
5 * Copyright (c) 2008-2012 Jung-uk Kim <jkim@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org>
3 * Copyright (c) 2001-2012 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
4 * Copyright (c) 2003 Peter Wemm
5 * Copyright (c) 2008-2012 Jung-uk Kim <jkim@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/x86/acpica/acpi_wakeup.c 236772 2012-06-09 00:37:26Z iwasaki $");
31__FBSDID("$FreeBSD: head/sys/x86/acpica/acpi_wakeup.c 236938 2012-06-12 00:14:54Z iwasaki $");
32
33#include <sys/param.h>
34#include <sys/bus.h>
35#include <sys/eventhandler.h>
36#include <sys/kernel.h>
37#include <sys/malloc.h>
38#include <sys/memrange.h>
39#include <sys/smp.h>

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

113 int apic_id = cpu_apic_ids[cpu];
114 int ms;
115
116 WAKECODE_FIXUP(wakeup_pcb, struct pcb *, susppcbs[cpu]);
117 WAKECODE_FIXUP(wakeup_gdt, uint16_t, susppcbs[cpu]->pcb_gdt.rd_limit);
118 WAKECODE_FIXUP(wakeup_gdt + 2, uint64_t,
119 susppcbs[cpu]->pcb_gdt.rd_base);
120
32
33#include <sys/param.h>
34#include <sys/bus.h>
35#include <sys/eventhandler.h>
36#include <sys/kernel.h>
37#include <sys/malloc.h>
38#include <sys/memrange.h>
39#include <sys/smp.h>

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

113 int apic_id = cpu_apic_ids[cpu];
114 int ms;
115
116 WAKECODE_FIXUP(wakeup_pcb, struct pcb *, susppcbs[cpu]);
117 WAKECODE_FIXUP(wakeup_gdt, uint16_t, susppcbs[cpu]->pcb_gdt.rd_limit);
118 WAKECODE_FIXUP(wakeup_gdt + 2, uint64_t,
119 susppcbs[cpu]->pcb_gdt.rd_base);
120
121 /* do an INIT IPI: assert RESET */
122 lapic_ipi_raw(APIC_DEST_DESTFLD | APIC_TRIGMOD_EDGE |
123 APIC_LEVEL_ASSERT | APIC_DESTMODE_PHY | APIC_DELMODE_INIT, apic_id);
121 ipi_startup(apic_id, vector);
124
122
125 /* wait for pending status end */
126 lapic_ipi_wait(-1);
127
128 /* do an INIT IPI: deassert RESET */
129 lapic_ipi_raw(APIC_DEST_ALLESELF | APIC_TRIGMOD_LEVEL |
130 APIC_LEVEL_DEASSERT | APIC_DESTMODE_PHY | APIC_DELMODE_INIT, 0);
131
132 /* wait for pending status end */
133 DELAY(10000); /* wait ~10mS */
134 lapic_ipi_wait(-1);
135
136 /*
137 * next we do a STARTUP IPI: the previous INIT IPI might still be
138 * latched, (P5 bug) this 1st STARTUP would then terminate
139 * immediately, and the previously started INIT IPI would continue. OR
140 * the previous INIT IPI has already run. and this STARTUP IPI will
141 * run. OR the previous INIT IPI was ignored. and this STARTUP IPI
142 * will run.
143 */
144
145 /* do a STARTUP IPI */
146 lapic_ipi_raw(APIC_DEST_DESTFLD | APIC_TRIGMOD_EDGE |
147 APIC_LEVEL_DEASSERT | APIC_DESTMODE_PHY | APIC_DELMODE_STARTUP |
148 vector, apic_id);
149 lapic_ipi_wait(-1);
150 DELAY(200); /* wait ~200uS */
151
152 /*
153 * finally we do a 2nd STARTUP IPI: this 2nd STARTUP IPI should run IF
154 * the previous STARTUP IPI was cancelled by a latched INIT IPI. OR
155 * this STARTUP IPI will be ignored, as only ONE STARTUP IPI is
156 * recognized after hardware RESET or INIT IPI.
157 */
158
159 lapic_ipi_raw(APIC_DEST_DESTFLD | APIC_TRIGMOD_EDGE |
160 APIC_LEVEL_DEASSERT | APIC_DESTMODE_PHY | APIC_DELMODE_STARTUP |
161 vector, apic_id);
162 lapic_ipi_wait(-1);
163 DELAY(200); /* wait ~200uS */
164
165 /* Wait up to 5 seconds for it to resume. */
166 for (ms = 0; ms < 5000; ms++) {
167 if (!CPU_ISSET(cpu, &suspended_cpus))
168 return (1); /* return SUCCESS */
169 DELAY(1000);
170 }
171 return (0); /* return FAILURE */
172}

--- 262 unchanged lines hidden ---
123 /* Wait up to 5 seconds for it to resume. */
124 for (ms = 0; ms < 5000; ms++) {
125 if (!CPU_ISSET(cpu, &suspended_cpus))
126 return (1); /* return SUCCESS */
127 DELAY(1000);
128 }
129 return (0); /* return FAILURE */
130}

--- 262 unchanged lines hidden ---