Attach CPU only of the pretense.
This commit is contained in:
parent
e23571f7e8
commit
8f2b8d16b7
|
@ -1,4 +1,4 @@
|
|||
/* $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.
|
||||
|
@ -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>
|
||||
|
||||
struct cpu_info cpu_info_primary;
|
||||
#include <dev/acpi/acpica.h>
|
||||
#include <dev/acpi/acpivar.h>
|
||||
|
||||
int cpu_match(device_t, cfdata_t, void *);
|
||||
void cpu_attach(device_t, device_t, void *);
|
||||
|
||||
struct cpu_info cpu_info_primary __aligned(CACHE_LINE_SIZE);
|
||||
|
||||
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 @@ CFATTACH_DECL_NEW(cpu, sizeof(struct cpu_softc),
|
|||
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;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.7 2010/01/23 06:13:20 kiyohara Exp $")
|
|||
#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 @@ mainbus_attach(device_t parent, device_t self, void *aux)
|
|||
#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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue