Rework code to scan for monarch CPU. (cpu0 at mainbus0)

CPU detection now works on E-class machines. (tested on E55)
This commit is contained in:
jkunz 2004-08-02 11:53:02 +00:00
parent 401d92a0c0
commit a4573e2f18
1 changed files with 59 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mainbus.c,v 1.18 2004/07/27 22:16:40 jkunz Exp $ */
/* $NetBSD: mainbus.c,v 1.19 2004/08/02 11:53:02 jkunz Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.18 2004/07/27 22:16:40 jkunz Exp $");
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.19 2004/08/02 11:53:02 jkunz Exp $");
#undef BTLBDEBUG
@ -1440,13 +1440,6 @@ mb_module_callback(struct device *self, struct confargs *ca)
config_found_sm(self, ca, mbprint, mbsubmatch);
}
static void
mb_monarch_cpu_callback(struct device *self, struct confargs *ca)
{
if (ca->ca_hpa == pdc_hpa.hpa)
config_found_sm(self, ca, mbprint, mbsubmatch);
}
static void
mb_cpu_mem_callback(struct device *self, struct confargs *ca)
{
@ -1460,10 +1453,13 @@ void
mbattach(struct device *parent, struct device *self, void *aux)
{
struct mainbus_softc *sc = (struct mainbus_softc *)self;
struct pdc_system_map_find_mod pdc_find_mod PDC_ALIGNMENT;
struct device_path path PDC_ALIGNMENT;
struct pdc_iodc_read pdc_iodc_read PDC_ALIGNMENT;
struct pdc_system_map_find_mod pdc_find_mod PDC_ALIGNMENT;
struct pdc_memmap pdc_memmap PDC_ALIGNMENT;
struct confargs nca;
bus_space_handle_t ioh;
int i;
/* fetch the "default" cpu hpa */
if (pdc_call((iodcio_t)pdc, 0, PDC_HPA, PDC_HPA_DFLT, &pdc_hpa) < 0)
@ -1489,7 +1485,7 @@ mbattach(struct device *parent, struct device *self, void *aux)
(void *)((pdc_hpa.hpa & FLEX_MASK) | DMA_ENABLE);
sc->sc_hpa = pdc_hpa.hpa;
printf (" [flex %lx]\n", pdc_hpa.hpa & FLEX_MASK);
aprint_normal(" [flex %lx]\n", pdc_hpa.hpa & FLEX_MASK);
/* PDC first */
memset(&nca, 0, sizeof(nca));
@ -1500,28 +1496,69 @@ mbattach(struct device *parent, struct device *self, void *aux)
config_found(self, &nca, mbprint);
/*
* Scan mainbus for monarch CPU and attach it.
*
* How to do device scaning? Try to use PDC_SYSTEM_MAP.
* We are on a "new" system if it succedes, so use PDC_SYSTEM_MAP.
* Otherwise we must be on an "old" system, so use PDC_MEMMAP.
*/
memset(&nca, 0, sizeof(nca));
if (pdc_call((iodcio_t)pdc, 0, PDC_SYSTEM_MAP, PDC_SYSTEM_MAP_FIND_MOD,
&pdc_find_mod, &path, 0) == 0) {
pdc_scanbus = pdc_scanbus_system_map;
for (i = 0; i <= 64; i++) {
nca.ca_dp.dp_bc[0] = nca.ca_dp.dp_bc[1] =
nca.ca_dp.dp_bc[2] = nca.ca_dp.dp_bc[3] =
nca.ca_dp.dp_bc[4] = nca.ca_dp.dp_bc[5] = -1;
nca.ca_dp.dp_mod = i;
if (pdc_call((iodcio_t)pdc, 0, PDC_SYSTEM_MAP,
PDC_SYSTEM_MAP_TRANS_PATH, &pdc_find_mod,
&nca.ca_dp) != 0)
continue;
nca.ca_hpa = pdc_find_mod.hpa;
nca.ca_hpasz = pdc_find_mod.size << PGSHIFT;
if (pdc_hpa.hpa == pdc_find_mod.hpa)
break;
}
} else {
pdc_scanbus = pdc_scanbus_memory_map;
for (i = 0; i < 16; i++) {
nca.ca_dp.dp_bc[0] = nca.ca_dp.dp_bc[1] =
nca.ca_dp.dp_bc[2] = nca.ca_dp.dp_bc[3] =
nca.ca_dp.dp_bc[4] = nca.ca_dp.dp_bc[5] = -1;
nca.ca_dp.dp_mod = i;
if (pdc_call((iodcio_t)pdc, 0, PDC_MEMMAP,
PDC_MEMMAP_HPA, &pdc_memmap, &nca.ca_dp) < 0)
continue;
nca.ca_hpa = pdc_memmap.hpa;
if (pdc_hpa.hpa == pdc_memmap.hpa)
break;
}
}
/* Search and attach monarch CPU. */
memset(&nca, 0, sizeof(nca));
nca.ca_name = "mainbus";
nca.ca_hpa = 0;
nca.ca_irq = HP700CF_IRQ_UNDEF;
if ((i = pdc_call((iodcio_t)pdc, 0, PDC_IODC, PDC_IODC_READ,
&pdc_iodc_read, pdc_hpa.hpa, IODC_DATA, &nca.ca_type,
sizeof(nca.ca_type))) != 0) {
aprint_normal("mbattach: PDC_IODC_READ monarch CPU HPA "
"faild err=%d\n", i);
nca.ca_name = "PA-RISC";
} else {
nca.ca_pdc_iodc_read = &pdc_iodc_read;
nca.ca_name = hppa_mod_info(nca.ca_type.iodc_type,
nca.ca_type.iodc_sv_model);
}
if (nca.ca_hpa != pdc_hpa.hpa) {
/* Didn't find the CPU in the device tree. Attach hard. */
nca.ca_hpa = pdc_hpa.hpa;
nca.ca_dp.dp_bc[0] = nca.ca_dp.dp_bc[1] =
nca.ca_dp.dp_bc[2] = nca.ca_dp.dp_bc[3] =
nca.ca_dp.dp_bc[4] = nca.ca_dp.dp_bc[5] = -1;
nca.ca_dp.dp_mod = -1;
}
nca.ca_mod = nca.ca_dp.dp_mod;
nca.ca_iot = &hppa_bustag;
nca.ca_dmatag = &hppa_dmatag;
nca.ca_dp.dp_bc[0] = nca.ca_dp.dp_bc[1] = nca.ca_dp.dp_bc[2] =
nca.ca_dp.dp_bc[3] = nca.ca_dp.dp_bc[4] = nca.ca_dp.dp_bc[5] = -1;
nca.ca_dp.dp_mod = -1;
pdc_scanbus(self, &nca, mb_monarch_cpu_callback);
nca.ca_irq = 31;
config_found(self, &nca, mbprint);
/* Search and attach additional CPUs and memory controller. */
memset(&nca, 0, sizeof(nca));
@ -1576,7 +1613,7 @@ mbprint(void *aux, const char *pnp)
if ( ca->ca_dp.dp_bc[n] >= 0)
printf( "%d/", ca->ca_dp.dp_bc[n]);
}
printf( "%d", ca->ca_dp.dp_mod);
aprint_normal( "%d", ca->ca_dp.dp_mod);
if (!pnp && ca->ca_irq >= 0) {
aprint_normal(" irq %d", ca->ca_irq);
if (ca->ca_type.iodc_type != HPPA_TYPE_BHA)