Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386 add MD support for ACPI sleep/wakeup.
details: https://anonhg.NetBSD.org/src/rev/69313137eda1
branches: trunk
changeset: 532951:69313137eda1
user: tshiozak <tshiozak%NetBSD.org@localhost>
date: Tue Jun 18 07:56:12 2002 +0000
description:
add MD support for ACPI sleep/wakeup.
diffstat:
sys/arch/i386/conf/files.i386 | 3 +-
sys/arch/i386/i386/machdep.c | 121 +++++++++++++++++++++++++++++++---
sys/arch/i386/include/acpi_machdep.h | 9 ++-
sys/arch/i386/include/isa_machdep.h | 8 ++-
sys/arch/i386/isa/isa_machdep.c | 22 +++++-
5 files changed, 144 insertions(+), 19 deletions(-)
diffs (truncated from 301 to 300 lines):
diff -r 941d1e4ba526 -r 69313137eda1 sys/arch/i386/conf/files.i386
--- a/sys/arch/i386/conf/files.i386 Tue Jun 18 07:53:05 2002 +0000
+++ b/sys/arch/i386/conf/files.i386 Tue Jun 18 07:56:12 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.i386,v 1.207 2002/06/17 22:38:31 christos Exp $
+# $NetBSD: files.i386,v 1.208 2002/06/18 07:56:12 tshiozak Exp $
#
# new style config file for i386 architecture
#
@@ -431,6 +431,7 @@
include "dev/acpi/files.acpi"
file arch/i386/i386/acpi_machdep.c acpi
+file arch/i386/acpi/acpi_wakeup.c acpi
# Toshiba VALD
device vald
diff -r 941d1e4ba526 -r 69313137eda1 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Tue Jun 18 07:53:05 2002 +0000
+++ b/sys/arch/i386/i386/machdep.c Tue Jun 18 07:56:12 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.472 2002/05/31 17:46:51 thorpej Exp $ */
+/* $NetBSD: machdep.c,v 1.473 2002/06/18 07:56:13 tshiozak Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.472 2002/05/31 17:46:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.473 2002/06/18 07:56:13 tshiozak Exp $");
#include "opt_cputype.h"
#include "opt_ddb.h"
@@ -152,6 +152,7 @@
#include <machine/vm86.h>
#endif
+#include "acpi.h"
#include "apm.h"
#include "bioscall.h"
@@ -159,6 +160,12 @@
#include <machine/bioscall.h>
#endif
+#if NACPI > 0
+#include <dev/acpi/acpivar.h>
+#define ACPI_MACHDEP_PRIVATE
+#include <machine/acpi_machdep.h>
+#endif
+
#if NAPM > 0
#include <machine/apmvar.h>
#endif
@@ -2186,6 +2193,13 @@
doshutdownhooks();
if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
+#if 0
+#if NACPI > 0
+ delay(500000);
+ acpi_enter_sleep_state(acpi_softc, ACPI_STATE_S5);
+ printf("WARNING: powerdown failed!\n");
+#endif
+#endif
#if NAPM > 0 && !defined(APM_NO_POWEROFF)
/* turn off, if we can. But try to turn disk off and
* wait a bit first--some disk drives are slow to clean up
@@ -2684,6 +2698,9 @@
int x, first16q;
u_int64_t seg_start, seg_end;
u_int64_t seg_start1, seg_end1;
+ paddr_t realmode_reserved_start;
+ psize_t realmode_reserved_size;
+ int needs_earlier_install_pte0;
#if NBIOSCALL > 0
extern int biostramp_image_size;
extern u_char biostramp_image[];
@@ -2721,13 +2738,36 @@
*/
uvmexp.ncolors = 2;
+ /*
+ * BIOS leaves data in low memory
+ * and VM system doesn't work with phys 0
+ */
+ avail_start = PAGE_SIZE;
+
+ /*
+ * reserve memory for real-mode call
+ */
+ needs_earlier_install_pte0 = 0;
+ realmode_reserved_start = 0;
+ realmode_reserved_size = 0;
#if NBIOSCALL > 0
- avail_start = 3*PAGE_SIZE; /* save us a page for trampoline code and
- one additional PT page! */
-#else
- avail_start = PAGE_SIZE; /* BIOS leaves data in low memory */
- /* and VM system doesn't work with phys 0 */
+ /* save us a page for trampoline code */
+ realmode_reserved_size += PAGE_SIZE;
+ needs_earlier_install_pte0 = 1;
+#endif
+#if NACPI > 0
+ /* trampoline code for wake handler */
+ realmode_reserved_size += ptoa(acpi_md_get_npages_of_wakecode()+1);
+ needs_earlier_install_pte0 = 1;
#endif
+ if (needs_earlier_install_pte0) {
+ /* page table for directory entry 0 */
+ realmode_reserved_size += PAGE_SIZE;
+ }
+ if (realmode_reserved_size>0) {
+ realmode_reserved_start = avail_start;
+ avail_start += realmode_reserved_size;
+ }
/*
* Call pmap initialization to make new kernel address space.
@@ -3018,18 +3058,37 @@
"in last cluster (%ld used)\n", reqsz, sz);
}
+ /*
+ * install PT page for the first 4M if needed.
+ */
+ if (needs_earlier_install_pte0) {
+ paddr_t paddr;
+#ifdef DIAGNOSTIC
+ if (realmode_reserved_size < PAGE_SIZE) {
+ panic("cannot steal memory for first 4M PT page.");
+ }
+#endif
+ paddr=realmode_reserved_start+realmode_reserved_size-PAGE_SIZE;
+ pmap_enter(pmap_kernel(), (vaddr_t)vtopte(0), paddr,
+ VM_PROT_READ|VM_PROT_WRITE,
+ PMAP_WIRED|VM_PROT_READ|VM_PROT_WRITE);
+ pmap_update(pmap_kernel());
+ /* make sure it is clean before using */
+ memset(vtopte(0), 0, PAGE_SIZE);
+ realmode_reserved_size -= PAGE_SIZE;
+ }
+
#if NBIOSCALL > 0
- /* install page 2 (reserved above) as PT page for first 4M */
- pmap_enter(pmap_kernel(), (vaddr_t)vtopte(0), 2*PAGE_SIZE,
- VM_PROT_READ|VM_PROT_WRITE, PMAP_WIRED|VM_PROT_READ|VM_PROT_WRITE);
- pmap_update(pmap_kernel());
- memset(vtopte(0), 0, PAGE_SIZE);/* make sure it is clean before using */
-
/*
* this should be caught at kernel build time, but put it here
* in case someone tries to fake it out...
*/
#ifdef DIAGNOSTIC
+ if (realmode_reserved_start > BIOSTRAMP_BASE ||
+ (realmode_reseved_start+realmode_reserved_size) < (BIOSTRAMP_BASE+
+ PAGE_SIZE)) {
+ panic("cannot steal memory for PT page of bioscall.");
+ }
if (biostramp_image_size > PAGE_SIZE)
panic("biostramp_image_size too big: %x vs. %x\n",
biostramp_image_size, PAGE_SIZE);
@@ -3042,6 +3101,42 @@
#ifdef DEBUG_BIOSCALL
printf("biostramp installed @ %x\n", BIOSTRAMP_BASE);
#endif
+ realmode_reserved_size -= PAGE_SIZE;
+ realmode_reserved_start += PAGE_SIZE;
+#endif
+
+#if NACPI > 0
+ /*
+ * Steal memory for the acpi wake code
+ */
+ {
+ paddr_t paddr, p;
+ psize_t sz;
+ int npg;
+
+ paddr = realmode_reserved_start;
+ npg = acpi_md_get_npages_of_wakecode();
+ sz = ptoa(npg);
+#ifdef DIAGNOSTIC
+ if (realmode_reserved_size < sz) {
+ panic("cannot steal memory for ACPI wake code.");
+ }
+#endif
+
+ /* identical mapping */
+ p = paddr;
+ for (x=0; x<npg; x++) {
+ printf("kenter: 0x%08X\n", (unsigned)p);
+ pmap_kenter_pa((vaddr_t)p, p, VM_PROT_ALL);
+ p += PAGE_SIZE;
+ }
+ pmap_update(pmap_kernel());
+
+ acpi_md_install_wakecode(paddr);
+
+ realmode_reserved_size -= sz;
+ realmode_reserved_start += sz;
+ }
#endif
pmap_enter(pmap_kernel(), idt_vaddr, idt_paddr,
diff -r 941d1e4ba526 -r 69313137eda1 sys/arch/i386/include/acpi_machdep.h
--- a/sys/arch/i386/include/acpi_machdep.h Tue Jun 18 07:53:05 2002 +0000
+++ b/sys/arch/i386/include/acpi_machdep.h Tue Jun 18 07:56:12 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.h,v 1.3 2002/06/15 18:01:05 thorpej Exp $ */
+/* $NetBSD: acpi_machdep.h,v 1.4 2002/06/18 07:56:14 tshiozak Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -65,3 +65,10 @@
BOOLEAN acpi_md_OsReadable(void *, UINT32);
BOOLEAN acpi_md_OsWritable(void *, UINT32);
+
+int acpi_md_sleep(int);
+
+#ifdef ACPI_MACHDEP_PRIVATE
+u_int32_t acpi_md_get_npages_of_wakecode(void);
+void acpi_md_install_wakecode(paddr_t);
+#endif
diff -r 941d1e4ba526 -r 69313137eda1 sys/arch/i386/include/isa_machdep.h
--- a/sys/arch/i386/include/isa_machdep.h Tue Jun 18 07:53:05 2002 +0000
+++ b/sys/arch/i386/include/isa_machdep.h Tue Jun 18 07:56:12 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isa_machdep.h,v 1.18 2000/11/15 19:30:10 thorpej Exp $ */
+/* $NetBSD: isa_machdep.h,v 1.19 2002/06/18 07:56:14 tshiozak Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -164,6 +164,12 @@
_isa_mappage((m), (o), (p))
/*
+ * for ACPI code
+ */
+
+void isa_reinit_irq(void);
+
+/*
* ALL OF THE FOLLOWING ARE MACHINE-DEPENDENT, AND SHOULD NOT BE USED
* BY PORTABLE CODE.
*/
diff -r 941d1e4ba526 -r 69313137eda1 sys/arch/i386/isa/isa_machdep.c
--- a/sys/arch/i386/isa/isa_machdep.c Tue Jun 18 07:53:05 2002 +0000
+++ b/sys/arch/i386/isa/isa_machdep.c Tue Jun 18 07:56:12 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isa_machdep.c,v 1.53 2001/11/18 13:48:00 jdolecek Exp $ */
+/* $NetBSD: isa_machdep.c,v 1.54 2002/06/18 07:56:15 tshiozak Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.53 2001/11/18 13:48:00 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.54 2002/06/18 07:56:15 tshiozak Exp $");
#define ISA_DMA_STATS
@@ -159,6 +159,8 @@
#define ID_BUFTYPE_UIO 3
#define ID_BUFTYPE_RAW 4
+static void init_i8259 __P((void));
+
int _isa_bus_dmamap_create __P((bus_dma_tag_t, bus_size_t, int,
bus_size_t, bus_size_t, int, bus_dmamap_t *));
void _isa_bus_dmamap_destroy __P((bus_dma_tag_t, bus_dmamap_t));
@@ -216,7 +218,21 @@
for (i = 0; i < ICU_LEN; i++)
setgate(&idt[ICU_OFFSET + i].gd, IDTVEC(intr)[i], 0,
SDT_SYS386IGT, SEL_KPL);
-
+ init_i8259();
+}
+
+void
+isa_reinit_irq()
+{
+ init_i8259();
+ SET_ICUS();
+}
+
+/* initialize i8259s */
+
+static void
+init_i8259(void)
+{
/* initialize 8259's */
#if NMCA > 0
Home |
Main Index |
Thread Index |
Old Index