Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64 ACPI support. Wakeup code still to be done.



details:   https://anonhg.NetBSD.org/src/rev/7817279eab82
branches:  trunk
changeset: 547045:7817279eab82
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Sun May 11 21:39:00 2003 +0000

description:
ACPI support. Wakeup code still to be done.

diffstat:

 sys/arch/amd64/amd64/mainbus.c        |  78 +++++++++++++++++++++++++++++-----
 sys/arch/amd64/conf/files.amd64       |   8 ++-
 sys/arch/amd64/include/acpi_func.h    |  44 +++++++++++++++++++
 sys/arch/amd64/include/acpi_machdep.h |   3 +
 sys/arch/amd64/include/mpacpi.h       |   3 +
 5 files changed, 120 insertions(+), 16 deletions(-)

diffs (224 lines):

diff -r f8dc5e96982a -r 7817279eab82 sys/arch/amd64/amd64/mainbus.c
--- a/sys/arch/amd64/amd64/mainbus.c    Sun May 11 21:21:16 2003 +0000
+++ b/sys/arch/amd64/amd64/mainbus.c    Sun May 11 21:39:00 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mainbus.c,v 1.1 2003/04/26 18:39:29 fvdl Exp $ */
+/*     $NetBSD: mainbus.c,v 1.2 2003/05/11 21:39:00 fvdl Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -43,13 +43,21 @@
 
 #include "pci.h"
 #include "isa.h"
+#include "isadma.h"
+#include "acpi.h"
 
+#include "opt_mpacpi.h"
 #include "opt_mpbios.h"
 
 #include <machine/cpuvar.h>
 #include <machine/i82093var.h>
 #include <machine/mpbiosvar.h>
 
+#if NACPI > 0
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpi_madt.h>
+#endif
+
 /*
  * XXXfvdl ACPI
  */
@@ -67,6 +75,7 @@
        struct pcibus_attach_args mba_pba;
        struct isabus_attach_args mba_iba;
        struct cpu_attach_args mba_caa;
+       struct acpibus_attach_args mba_acpi;
        struct apic_attach_args aaa_caa;
 };
 
@@ -126,9 +135,13 @@
 #if NPCI > 0
        union mainbus_attach_args mba;
 #endif
+#if NACPI > 0
+       int acpi_present = 0;
+#endif
 #ifdef MPBIOS
        int mpbios_present = 0;
 #endif
+       int mpacpi_active = 0;
 
        printf("\n");
 
@@ -140,23 +153,62 @@
        pci_mode = pci_mode_detect();
 #endif
 
+#if NACPI > 0
+       acpi_present = acpi_probe();
+#ifdef MPACPI
+       /*
+        * First, see if the MADT contains CPUs, and possibly I/O APICs.
+        * Building the interrupt routing structures can only
+        * be done later (via a callback).
+        */
+       if (acpi_present)
+               mpacpi_active = mpacpi_scan_apics(self);
+#endif
+#endif
+
+       if (!mpacpi_active) {
 #ifdef MPBIOS
-       if (mpbios_present)
-               mpbios_scan(self);
-       else
+               if (mpbios_present)
+                       mpbios_scan(self);
+               else
 #endif
-       {
-               struct cpu_attach_args caa;
+               {
+                       struct cpu_attach_args caa;
+                        
+                       memset(&caa, 0, sizeof(caa));
+                       caa.caa_name = "cpu";
+                       caa.cpu_number = 0;
+                       caa.cpu_role = CPU_ROLE_SP;
+                       caa.cpu_func = 0;
                         
-               memset(&caa, 0, sizeof(caa));
-               caa.caa_name = "cpu";
-               caa.cpu_number = 0;
-               caa.cpu_role = CPU_ROLE_SP;
-               caa.cpu_func = 0;
-                        
-               config_found(self, &caa, mainbus_print);
+                       config_found(self, &caa, mainbus_print);
+               }
        }
 
+#if NISADMA > 0 && NACPI > 0
+       /*
+        * ACPI needs ISA DMA initialized before they start probing.
+        */
+       isa_dmainit(&x86_isa_chipset, X86_BUS_SPACE_IO, &isa_bus_dma_tag,
+           self);
+#endif
+
+
+#if NACPI > 0
+       if (acpi_present) {
+               mba.mba_acpi.aa_busname = "acpi";
+               mba.mba_acpi.aa_iot = X86_BUS_SPACE_IO;
+               mba.mba_acpi.aa_memt = X86_BUS_SPACE_MEM;
+               mba.mba_acpi.aa_pc = NULL;
+               mba.mba_acpi.aa_pciflags =
+                   PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
+                   PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |
+                   PCI_FLAGS_MWI_OKAY;
+               mba.mba_acpi.aa_ic = &x86_isa_chipset;
+               config_found(self, &mba.mba_acpi, mainbus_print);
+       }
+#endif
+
 #if NPCI > 0
        if (pci_mode != 0) {
                mba.mba_pba.pba_busname = "pci";
diff -r f8dc5e96982a -r 7817279eab82 sys/arch/amd64/conf/files.amd64
--- a/sys/arch/amd64/conf/files.amd64   Sun May 11 21:21:16 2003 +0000
+++ b/sys/arch/amd64/conf/files.amd64   Sun May 11 21:39:00 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amd64,v 1.2 2003/05/03 14:24:52 fvdl Exp $
+#      $NetBSD: files.amd64,v 1.3 2003/05/11 21:39:01 fvdl Exp $
 #
 # new style config file for amd64 architecture
 #
@@ -25,7 +25,6 @@
 
 defflag                        USER_LDT
 defflag                        VM86
-defflag opt_mpacpi.h MPACPI
 defflag eisa.h EISA
 
 file   arch/amd64/amd64/autoconf.c
@@ -91,7 +90,7 @@
 #
 
 # XXX BIOS32 only if something that uses it is configured!
-device mainbus: isabus, pcibus, mainbus, bios32
+device mainbus: isabus, pcibus, mainbus, bios32, acpibus
 attach mainbus at root
 file   arch/amd64/amd64/mainbus.c              mainbus
 
@@ -181,4 +180,7 @@
 
 include        "dev/ieee1394/files.ieee1394"
 
+include "dev/acpi/files.acpi"
+file   arch/amd64/acpi/acpi_wakeup.c   acpi
+
 include        "arch/amd64/conf/majors.amd64"
diff -r f8dc5e96982a -r 7817279eab82 sys/arch/amd64/include/acpi_func.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amd64/include/acpi_func.h        Sun May 11 21:39:00 2003 +0000
@@ -0,0 +1,44 @@
+/*     $NetBSD: acpi_func.h,v 1.1 2003/05/11 21:39:02 fvdl Exp $       */
+
+#include <machine/cpufunc.h>
+
+#if 0
+#define        ACPI_DISABLE_IRQS()             disable_intr()
+#define        ACPI_ENABLE_IRQS()              enable_intr()
+#endif
+
+#define        ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \
+do { \
+       unsigned long dummy; \
+       __asm __volatile( \
+       "1:     movl (%1),%%eax         ;" \
+       "       movl %%eax,%%edx        ;" \
+       "       andq %2,%%rdx           ;" \
+       "       btsl $0x1,%%edx         ;" \
+       "       adcl $0x0,%%edx         ;" \
+       "       lock                    ;" \
+       "       cmpxchgl %%edx,(%1)     ;" \
+       "       jnz 1b                  ;" \
+       "       cmpb $0x3,%%dl          ;" \
+       "       sbbl %%eax,%%eax        " \
+       : "=a" (Acq), "=c" (dummy) \
+       : "c" (GLptr), "i" (~1L) \
+       : "dx"); \
+} while (0)
+
+#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \
+do { \
+       unsigned long dummy; \
+       __asm __volatile( \
+       "1:     movl (%1),%%eax         ;" \
+       "       andq %2,%%rdx           ;" \
+       "       lock                    ;" \
+       "       cmpxchgl %%edx,(%1)     ;" \
+       "       jnz 1b                  ;" \
+       "       andl $0x1,%%eax         ;" \
+       : "=a" (Acq), "=c" (dummy) \
+       : "c" (GLptr), "i" (~3L) \
+       : "dx"); \
+} while (0)
+
+#define        ACPI_FLUSH_CPU_CACHE()          wbinvd()
diff -r f8dc5e96982a -r 7817279eab82 sys/arch/amd64/include/acpi_machdep.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amd64/include/acpi_machdep.h     Sun May 11 21:39:00 2003 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: acpi_machdep.h,v 1.1 2003/05/11 21:39:02 fvdl Exp $    */
+
+#include <x86/acpi_machdep.h>
diff -r f8dc5e96982a -r 7817279eab82 sys/arch/amd64/include/mpacpi.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amd64/include/mpacpi.h   Sun May 11 21:39:00 2003 +0000
@@ -0,0 +1,3 @@
+/*     $NetBSD: mpacpi.h,v 1.1 2003/05/11 21:39:02 fvdl Exp $  */
+
+#include <x86/mpacpi.h>



Home | Main Index | Thread Index | Old Index