Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/ia64/ia64 Attach CPU only of the pretense.



details:   https://anonhg.NetBSD.org/src/rev/d52945c838e1
branches:  trunk
changeset: 754942:d52945c838e1
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Mon May 17 11:46:19 2010 +0000

description:
Attach CPU only of the pretense.

diffstat:

 sys/arch/ia64/ia64/cpu.c     |  57 +++++++++++++++++++++++++++++++++----------
 sys/arch/ia64/ia64/mainbus.c |  54 ++++++++++++++++++++++++++++++++++++-----
 2 files changed, 91 insertions(+), 20 deletions(-)

diffs (191 lines):

diff -r 002d7505eb1a -r d52945c838e1 sys/arch/ia64/ia64/cpu.c
--- a/sys/arch/ia64/ia64/cpu.c  Mon May 17 11:41:28 2010 +0000
+++ b/sys/arch/ia64/ia64/cpu.c  Mon May 17 11:46:19 2010 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: cpu.c,v 1.7 2009/11/21 15:36:34 rmind Exp $    */
+/*     $NetBSD: cpu.c,v 1.8 2010/05/17 11:46:19 kiyohara Exp $ */
 
 /*
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  *
- * Author: 
+ * Author:
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -30,18 +30,22 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.7 2009/11/21 15:36:34 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.8 2010/05/17 11:46:19 kiyohara Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
+
+#include <dev/acpi/acpica.h>
+#include <dev/acpi/acpivar.h>
 
-struct cpu_info cpu_info_primary;
+
+struct cpu_info cpu_info_primary __aligned(CACHE_LINE_SIZE);
 
-int     cpu_match(device_t, cfdata_t, void *);
-void    cpu_attach(device_t, device_t, void *);
+static int cpu_match(device_t, cfdata_t, void *);
+static void cpu_attach(device_t, device_t, void *);
 
 struct cpu_softc {
        device_t sc_dev;                /* device tree glue */
@@ -52,20 +56,47 @@
     cpu_match, cpu_attach, NULL, NULL);
 
 
-int
+static int
 cpu_match(device_t parent, cfdata_t match, void *aux)
 {
+
        return 1;
 }
 
-void
+static void
 cpu_attach(device_t parent, device_t self, void *aux)
 {
+       struct cpu_softc *sc = device_private(self);
+       ACPI_MADT_LOCAL_SAPIC *sapic = (ACPI_MADT_LOCAL_SAPIC *)aux;
+       struct cpu_info *ci;
+       uint64_t lid;
+       int id, eid;
 
-#if 0  /* not yet */
-       ci->ci_cpuid = id;
-       ci->ci_intrdepth = -1;  /* need ? */
+       aprint_naive("\n");
+       aprint_normal(": ProcessorID %d, Id %d, Eid %d%s\n",
+           sapic->ProcessorId, sapic->Id, sapic->Eid,
+           sapic->LapicFlags & ACPI_MADT_ENABLED ? "" : " (disabled)");
+
+       /* Get current CPU Id */
+       lid = ia64_get_lid();
+       id = (lid & 0x00000000ff000000) >> 24;
+       eid = (lid & 0x0000000000ff0000) >> 16;
+
+       sc->sc_dev = self;
+       if (id == sapic->Id && eid == sapic->Eid)
+               ci = curcpu();
+       else {
+               ci = (struct cpu_info *)kmem_zalloc(sizeof(*ci), KM_NOSLEEP);
+               if (ci == NULL) {
+                       aprint_error_dev(self, "memory alloc failed\n");
+                       return;
+               }
+       }
+       sc->sc_info = ci;
+
+       ci->ci_cpuid = sapic->ProcessorId;
+       ci->ci_intrdepth = -1;                  /* need ? */
        ci->ci_dev = self;
-#endif
+
        return;
 }
diff -r 002d7505eb1a -r d52945c838e1 sys/arch/ia64/ia64/mainbus.c
--- a/sys/arch/ia64/ia64/mainbus.c      Mon May 17 11:41:28 2010 +0000
+++ b/sys/arch/ia64/ia64/mainbus.c      Mon May 17 11:46:19 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mainbus.c,v 1.7 2010/01/23 06:13:20 kiyohara Exp $     */
+/*     $NetBSD: mainbus.c,v 1.8 2010/05/17 11:46:19 kiyohara Exp $     */
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.7 2010/01/23 06:13:20 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.8 2010/05/17 11:46:19 kiyohara Exp $");
 
 #include "acpica.h"
 
@@ -37,17 +37,15 @@
 #include <sys/device.h>
 #include <sys/errno.h>
 
-#if NACPICA > 0
+#include <dev/acpi/acpica.h>
 #include <dev/acpi/acpivar.h>
-#endif
+#include <actables.h>
 
 
 static int mainbus_match(device_t, cfdata_t, void *);
 static void mainbus_attach(device_t, device_t, void *);
 
-CFATTACH_DECL_NEW(mainbus,
-    /*sizeof(struct device): XXXXX It doesn't use it now*/ 0,
-    mainbus_match, mainbus_attach, NULL, NULL);
+CFATTACH_DECL_NEW(mainbus, 0, mainbus_match, mainbus_attach, NULL, NULL);
 
 
 /*
@@ -69,10 +67,52 @@
 #if NACPICA > 0
        struct acpibus_attach_args aaa;
 #endif
+       ACPI_PHYSICAL_ADDRESS rsdp_ptr;
+       ACPI_MADT_LOCAL_SAPIC *entry;
+       ACPI_TABLE_MADT *table;
+       ACPI_TABLE_RSDP *rsdp;
+       ACPI_TABLE_XSDT *xsdt;
+       char *end, *p;
+       int tables, i;
 
        aprint_naive("\n");
        aprint_normal("\n");
 
+       if ((rsdp_ptr = AcpiOsGetRootPointer()) == 0)
+               panic("cpu not found");
+
+       rsdp = (ACPI_TABLE_RSDP *)IA64_PHYS_TO_RR7(rsdp_ptr);
+       xsdt = (ACPI_TABLE_XSDT *)IA64_PHYS_TO_RR7(rsdp->XsdtPhysicalAddress);
+
+       tables = (UINT64 *)((char *)xsdt + xsdt->Header.Length) -
+           xsdt->TableOffsetEntry;
+
+       for (i = 0; i < tables; i++) {
+               int len;
+               char *sig;
+
+               table = (ACPI_TABLE_MADT *)
+                   IA64_PHYS_TO_RR7(xsdt->TableOffsetEntry[i]);
+
+               sig = table->Header.Signature;
+               if (strncmp(sig, ACPI_SIG_MADT, ACPI_NAME_SIZE) != 0)
+                       continue;
+               len = table->Header.Length;
+               if (ACPI_FAILURE(AcpiTbChecksum((void *)table, len)))
+                       continue;
+
+               end = (char *)table + table->Header.Length;
+               p = (char *)(table + 1);
+               while (p < end) {
+                       entry = (ACPI_MADT_LOCAL_SAPIC *)p;
+
+                       if (entry->Header.Type == ACPI_MADT_TYPE_LOCAL_SAPIC)
+                               config_found_ia(self, "cpubus", entry, 0);
+
+                       p += entry->Header.Length;
+               }
+       }
+
 #if NACPICA > 0
        acpi_probe();
 



Home | Main Index | Thread Index | Old Index