Fri Sep 19 11:15:50 2008 UTC ()
Revert previous.


(jmcneill)
diff -r1.8 -r1.9 src/sys/arch/x86/acpi/acpi_wakeup.c

cvs diff -r1.8 -r1.9 src/sys/arch/x86/acpi/acpi_wakeup.c (expand / switch to unified diff)

--- src/sys/arch/x86/acpi/acpi_wakeup.c 2008/09/10 03:56:12 1.8
+++ src/sys/arch/x86/acpi/acpi_wakeup.c 2008/09/19 11:15:50 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: acpi_wakeup.c,v 1.8 2008/09/10 03:56:12 jmcneill Exp $ */ 1/* $NetBSD: acpi_wakeup.c,v 1.9 2008/09/19 11:15:50 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc. 4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Takuya SHIOZAKI. 8 * by Takuya SHIOZAKI.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.8 2008/09/10 03:56:12 jmcneill Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.9 2008/09/19 11:15:50 jmcneill Exp $");
34 34
35/*- 35/*-
36 * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org> 36 * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org>
37 * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org> 37 * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
38 * All rights reserved. 38 * All rights reserved.
39 * 39 *
40 * Redistribution and use in source and binary forms, with or without 40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions 41 * modification, are permitted provided that the following conditions
42 * are met: 42 * are met:
43 * 1. Redistributions of source code must retain the above copyright 43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer. 44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright 45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the 46 * notice, this list of conditions and the following disclaimer in the
@@ -305,42 +305,43 @@ acpi_cpu_sleep(struct cpu_info *ci) @@ -305,42 +305,43 @@ acpi_cpu_sleep(struct cpu_info *ci)
305 lapic_initclocks(); 305 lapic_initclocks();
306#endif 306#endif
307 307
308 atomic_or_32(&ci->ci_flags, CPUF_RUNNING); 308 atomic_or_32(&ci->ci_flags, CPUF_RUNNING);
309 atomic_or_32(&cpus_running, ci->ci_cpumask); 309 atomic_or_32(&cpus_running, ci->ci_cpumask);
310 310
311 x86_enable_intr(); 311 x86_enable_intr();
312} 312}
313#endif 313#endif
314 314
315int 315int
316acpi_md_sleep(int state) 316acpi_md_sleep(int state)
317{ 317{
318 int ret = 0; 318 int s, ret = 0;
319#ifdef MULTIPROCESSOR 319#ifdef MULTIPROCESSOR
320 struct cpu_info *ci; 320 struct cpu_info *ci;
321 CPU_INFO_ITERATOR cii; 321 CPU_INFO_ITERATOR cii;
322#endif 322#endif
323 323
324 KASSERT(acpi_wakeup_paddr != 0); 324 KASSERT(acpi_wakeup_paddr != 0);
325 KASSERT(sizeof(wakecode) <= PAGE_SIZE); 325 KASSERT(sizeof(wakecode) <= PAGE_SIZE);
326 326
327 if (!CPU_IS_PRIMARY(curcpu())) { 327 if (!CPU_IS_PRIMARY(curcpu())) {
328 printf("acpi0: WARNING: ignoring sleep from secondary CPU\n"); 328 printf("acpi0: WARNING: ignoring sleep from secondary CPU\n");
329 return -1; 329 return -1;
330 } 330 }
331 331
332 AcpiSetFirmwareWakingVector(acpi_wakeup_paddr); 332 AcpiSetFirmwareWakingVector(acpi_wakeup_paddr);
333 333
 334 s = splhigh();
334#ifdef __i386__ 335#ifdef __i386__
335 npxsave_cpu(true); 336 npxsave_cpu(true);
336#else 337#else
337 fpusave_cpu(true); 338 fpusave_cpu(true);
338#endif 339#endif
339 x86_disable_intr(); 340 x86_disable_intr();
340 341
341#ifdef MULTIPROCESSOR 342#ifdef MULTIPROCESSOR
342 /* Save and suspend Application Processors */ 343 /* Save and suspend Application Processors */
343 x86_broadcast_ipi(X86_IPI_ACPI_CPU_SLEEP); 344 x86_broadcast_ipi(X86_IPI_ACPI_CPU_SLEEP);
344 while (cpus_running != curcpu()->ci_cpumask) 345 while (cpus_running != curcpu()->ci_cpumask)
345 delay(1);  346 delay(1);
346#endif 347#endif
@@ -377,26 +378,27 @@ out: @@ -377,26 +378,27 @@ out:
377 if (CPU_IS_PRIMARY(ci)) 378 if (CPU_IS_PRIMARY(ci))
378 continue; 379 continue;
379 acpi_md_sleep_patch(ci); 380 acpi_md_sleep_patch(ci);
380 381
381 CPU_STARTUP(ci, acpi_wakeup_paddr); 382 CPU_STARTUP(ci, acpi_wakeup_paddr);
382 CPU_START_CLEANUP(ci); 383 CPU_START_CLEANUP(ci);
383 384
384 while ((ci->ci_flags & CPUF_RUNNING) == 0) 385 while ((ci->ci_flags & CPUF_RUNNING) == 0)
385 x86_pause(); 386 x86_pause();
386 } 387 }
387#endif 388#endif
388 389
389 x86_enable_intr(); 390 x86_enable_intr();
 391 splx(s);
390 392
391#ifdef MTRR 393#ifdef MTRR
392 if (mtrr_funcs != NULL) 394 if (mtrr_funcs != NULL)
393 mtrr_commit(); 395 mtrr_commit();
394#endif 396#endif
395 397
396 return (ret); 398 return (ret);
397} 399}
398 400
399void 401void
400acpi_md_sleep_init(void) 402acpi_md_sleep_init(void)
401{ 403{
402 /* Map ACPI wakecode */ 404 /* Map ACPI wakecode */