Module Name: src
Committed By: skrll
Date: Tue Jan 4 10:42:34 UTC 2011
Modified Files:
src/sys/arch/hp700/dev: apic.c astro.c lasi.c lcd.c mem.c pdc.c power.c
src/sys/arch/hp700/gsc: oosiop_gsc.c osiop_gsc.c
src/sys/arch/hp700/hp700: autoconf.c machdep.c mainbus.c
src/sys/arch/hp700/include: autoconf.h pdc.h
Log Message:
Centralise the PDC procedure calls into one file and use a minimal set of
kernel data for PDC results.
Remove the filler components from the PDC structures as a result.
Other tidyups while here.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hp700/dev/apic.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/hp700/dev/astro.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/hp700/dev/lasi.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/hp700/dev/lcd.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/hp700/dev/mem.c
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/hp700/dev/pdc.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hp700/dev/power.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/hp700/gsc/oosiop_gsc.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/hp700/gsc/osiop_gsc.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/hp700/hp700/autoconf.c
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/hp700/hp700/machdep.c
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/hp700/hp700/mainbus.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/hp700/include/autoconf.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/hp700/include/pdc.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/hp700/dev/apic.c
diff -u src/sys/arch/hp700/dev/apic.c:1.8 src/sys/arch/hp700/dev/apic.c:1.9
--- src/sys/arch/hp700/dev/apic.c:1.8 Sun Dec 5 12:19:09 2010
+++ src/sys/arch/hp700/dev/apic.c Tue Jan 4 10:42:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: apic.c,v 1.8 2010/12/05 12:19:09 skrll Exp $ */
+/* $NetBSD: apic.c,v 1.9 2011/01/04 10:42:33 skrll Exp $ */
/* $OpenBSD: apic.c,v 1.7 2007/10/06 23:50:54 krw Exp $ */
@@ -256,35 +256,24 @@
return (claimed);
}
-/* Maximum number of supported interrupt routing entries. */
-#define MAX_INT_TBL_SZ 16
-
void
apic_get_int_tbl(struct elroy_softc *sc)
{
- static struct pdc_pat_io_num int_tbl_sz PDC_ALIGNMENT;
- static struct pdc_pat_pci_rt int_tbl[MAX_INT_TBL_SZ] PDC_ALIGNMENT;
+ int nentries;
size_t size;
+ int err;
- if (pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL_SZ,
- &int_tbl_sz, 0, 0, 0, 0, 0))
+ err = pdcproc_pci_inttblsz(&nentries);
+ if (err)
return;
-
- if (int_tbl_sz.num > MAX_INT_TBL_SZ)
- panic("interrupt routing table too big (%d entries)",
- int_tbl_sz.num);
-
- size = int_tbl_sz.num * sizeof(struct pdc_pat_pci_rt);
- sc->sc_int_tbl_sz = int_tbl_sz.num;
+
+ size = nentries * sizeof(struct pdc_pat_pci_rt);
+ sc->sc_int_tbl_sz = nentries;
sc->sc_int_tbl = malloc(size, M_DEVBUF, M_NOWAIT);
if (sc->sc_int_tbl == NULL)
return;
- if (pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL,
- &int_tbl_sz, 0, &int_tbl, 0, 0, 0))
- return;
-
- memcpy(sc->sc_int_tbl, int_tbl, size);
+ pdcproc_pci_gettable(nentries, size, sc->sc_int_tbl);
}
uint32_t
Index: src/sys/arch/hp700/dev/astro.c
diff -u src/sys/arch/hp700/dev/astro.c:1.11 src/sys/arch/hp700/dev/astro.c:1.12
--- src/sys/arch/hp700/dev/astro.c:1.11 Sat Dec 11 19:32:05 2010
+++ src/sys/arch/hp700/dev/astro.c Tue Jan 4 10:42:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: astro.c,v 1.11 2010/12/11 19:32:05 skrll Exp $ */
+/* $NetBSD: astro.c,v 1.12 2011/01/04 10:42:33 skrll Exp $ */
/* $OpenBSD: astro.c,v 1.8 2007/10/06 23:50:54 krw Exp $ */
@@ -315,7 +315,7 @@
*/
pagezero_cookie = hp700_pagezero_map();
if (PAGE0->mem_cons.pz_class != PCL_DUPLEX)
- pdc_call((iodcio_t)pdc, 0, PDC_IO, PDC_IO_RESET_DEVICES);
+ pdcproc_ioreset();
hp700_pagezero_unmap(pagezero_cookie);
/* Enable iova space. */
Index: src/sys/arch/hp700/dev/lasi.c
diff -u src/sys/arch/hp700/dev/lasi.c:1.17 src/sys/arch/hp700/dev/lasi.c:1.18
--- src/sys/arch/hp700/dev/lasi.c:1.17 Sat Dec 11 19:32:05 2010
+++ src/sys/arch/hp700/dev/lasi.c Tue Jan 4 10:42:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: lasi.c,v 1.17 2010/12/11 19:32:05 skrll Exp $ */
+/* $NetBSD: lasi.c,v 1.18 2011/01/04 10:42:33 skrll Exp $ */
/* $OpenBSD: lasi.c,v 1.4 2001/06/09 03:57:19 mickey Exp $ */
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lasi.c,v 1.17 2010/12/11 19:32:05 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lasi.c,v 1.18 2011/01/04 10:42:33 skrll Exp $");
#undef LASIDEBUG
@@ -96,7 +96,6 @@
{
struct lasi_softc *sc = _sc;
hppa_hpa_t module_offset;
- struct pdc_lan_station_id pdc_mac PDC_ALIGNMENT;
/*
* Determine this module's interrupt bit.
@@ -119,10 +118,8 @@
* If this is the Ethernet adapter, get its Ethernet address.
*/
if (module_offset == 0x7000) {
- if (pdc_call((iodcio_t)pdc, 0, PDC_LAN_STATION_ID,
- PDC_LAN_STATION_ID_READ, &pdc_mac, ga->ga_hpa) == 0)
- memcpy(ga->ga_ether_address, pdc_mac.addr,
- sizeof(ga->ga_ether_address));
+ pdcproc_lan_station_id(ga->ga_ether_address,
+ sizeof(ga->ga_ether_address), ga->ga_hpa);
}
}
Index: src/sys/arch/hp700/dev/lcd.c
diff -u src/sys/arch/hp700/dev/lcd.c:1.3 src/sys/arch/hp700/dev/lcd.c:1.4
--- src/sys/arch/hp700/dev/lcd.c:1.3 Fri Dec 24 15:29:08 2010
+++ src/sys/arch/hp700/dev/lcd.c Tue Jan 4 10:42:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: lcd.c,v 1.3 2010/12/24 15:29:08 skrll Exp $ */
+/* $NetBSD: lcd.c,v 1.4 2011/01/04 10:42:33 skrll Exp $ */
/* OpenBSD: lcd.c,v 1.2 2007/07/20 22:13:45 kettenis Exp */
/*
@@ -72,7 +72,7 @@
{
struct lcd_softc *sc = device_private(self);
struct confargs *ca = aux;
- struct pdc_chassis_lcd *pdc_lcd = (void *)ca->ca_pdc_iodc_read;
+ struct pdc_chassis_lcd *pdc_lcd = &ca->ca_pcl;
int i;
sc->sc_dv = self;
Index: src/sys/arch/hp700/dev/mem.c
diff -u src/sys/arch/hp700/dev/mem.c:1.26 src/sys/arch/hp700/dev/mem.c:1.27
--- src/sys/arch/hp700/dev/mem.c:1.26 Sun Dec 12 08:23:14 2010
+++ src/sys/arch/hp700/dev/mem.c Tue Jan 4 10:42:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: mem.c,v 1.26 2010/12/12 08:23:14 skrll Exp $ */
+/* $NetBSD: mem.c,v 1.27 2011/01/04 10:42:33 skrll Exp $ */
/* $OpenBSD: mem.c,v 1.30 2007/09/22 16:21:32 krw Exp $ */
/*
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.26 2010/12/12 08:23:14 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mem.c,v 1.27 2011/01/04 10:42:33 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -182,7 +182,7 @@
void
memattach(device_t parent, device_t self, void *aux)
{
- struct pdc_iodc_minit pdc_minit PDC_ALIGNMENT;
+ struct pdc_iodc_minit pdc_minit;
struct confargs *ca = aux;
struct mem_softc *sc = device_private(self);
int err, pagezero_cookie;
@@ -255,8 +255,8 @@
} else
sc->sc_vp = NULL;
- if ((err = pdc_call((iodcio_t)pdc, 0, PDC_IODC, PDC_IODC_NINIT,
- &pdc_minit, ca->ca_hpa, PAGE0->imm_spa_size)) < 0)
+ err = pdcproc_iodc_ninit(&pdc_minit, ca->ca_hpa, PAGE0->imm_spa_size);
+ if (err < 0)
pdc_minit.max_spa = PAGE0->imm_max_mem;
hp700_pagezero_unmap(pagezero_cookie);
Index: src/sys/arch/hp700/dev/pdc.c
diff -u src/sys/arch/hp700/dev/pdc.c:1.36 src/sys/arch/hp700/dev/pdc.c:1.37
--- src/sys/arch/hp700/dev/pdc.c:1.36 Wed Feb 10 20:45:35 2010
+++ src/sys/arch/hp700/dev/pdc.c Tue Jan 4 10:42:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pdc.c,v 1.36 2010/02/10 20:45:35 skrll Exp $ */
+/* $NetBSD: pdc.c,v 1.37 2011/01/04 10:42:33 skrll Exp $ */
/* $OpenBSD: pdc.c,v 1.14 2001/04/29 21:05:43 mickey Exp $ */
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pdc.c,v 1.36 2010/02/10 20:45:35 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pdc.c,v 1.37 2011/01/04 10:42:33 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -57,7 +57,10 @@
} pdcsoftc_t;
pdcio_t pdc;
-int pdcret[32] PDC_ALIGNMENT;
+
+static struct pdc_result pdcret1 PDC_ALIGNMENT;
+static struct pdc_result pdcret2 PDC_ALIGNMENT;
+
char pdc_consbuf[IODC_MINIOSIZ] PDC_ALIGNMENT;
iodcio_t pdc_cniodc, pdc_kbdiodc;
pz_device_t *pz_kbd, *pz_cons;
@@ -96,8 +99,6 @@
static int pdcgettod(todr_chip_handle_t, struct timeval *);
static int pdcsettod(todr_chip_handle_t, struct timeval *);
-static struct pdc_tod tod PDC_ALIGNMENT;
-
void
pdc_init(void)
{
@@ -121,9 +122,9 @@
/* XXX should we reset the console/kbd here?
well, /boot did that for us anyway */
if ((err = pdc_call((iodcio_t)pdc, 0, PDC_IODC, PDC_IODC_READ,
- pdcret, pz_cons->pz_hpa, IODC_IO, cn_iodc, IODC_MAXSIZE)) < 0 ||
+ &pdcret1, pz_cons->pz_hpa, IODC_IO, cn_iodc, IODC_MAXSIZE)) < 0 ||
(err = pdc_call((iodcio_t)pdc, 0, PDC_IODC, PDC_IODC_READ,
- pdcret, pz_kbd->pz_hpa, IODC_IO, kbd_iodc, IODC_MAXSIZE)) < 0) {
+ &pdcret1, pz_kbd->pz_hpa, IODC_IO, kbd_iodc, IODC_MAXSIZE)) < 0) {
#ifdef DEBUG
printf("pdc_init: failed reading IODC (%d)\n", err);
#endif
@@ -388,8 +389,8 @@
s = splhigh();
pagezero_cookie = hp700_pagezero_map();
err = pdc_call(pdc_kbdiodc, 0, pz_kbd->pz_hpa, IODC_IO_CONSIN,
- pz_kbd->pz_spa, pz_kbd->pz_layers, pdcret, 0, pdc_consbuf, 1, 0);
- l = pdcret[0];
+ pz_kbd->pz_spa, pz_kbd->pz_layers, &pdcret1, 0, pdc_consbuf, 1, 0);
+ l = pdcret1.result[0];
*cp = pdc_consbuf[0];
hp700_pagezero_unmap(pagezero_cookie);
splx(s);
@@ -422,7 +423,7 @@
pagezero_cookie = hp700_pagezero_map();
*pdc_consbuf = c;
err = pdc_call(pdc_cniodc, 0, pz_cons->pz_hpa, IODC_IO_CONSOUT,
- pz_cons->pz_spa, pz_cons->pz_layers, pdcret, 0, pdc_consbuf, 1, 0);
+ pz_cons->pz_spa, pz_cons->pz_layers, &pdcret1, 0, pdc_consbuf, 1, 0);
hp700_pagezero_unmap(pagezero_cookie);
splx(s);
@@ -449,14 +450,15 @@
static int
pdcgettod(todr_chip_handle_t tch, struct timeval *tvp)
{
+ struct pdc_tod *tod = (struct pdc_tod *)&pdcret1;
int error;
error = pdc_call((iodcio_t)pdc, 1, PDC_TOD, PDC_TOD_READ,
- &tod, 0, 0, 0, 0, 0);
+ &pdcret1);
if (error == 0) {
- tvp->tv_sec = tod.sec;
- tvp->tv_usec = tod.usec;
+ tvp->tv_sec = tod->sec;
+ tvp->tv_usec = tod->usec;
}
return error;
}
@@ -466,10 +468,447 @@
{
int error;
- tod.sec = tvp->tv_sec;
- tod.usec = tvp->tv_usec;
-
error = pdc_call((iodcio_t)pdc, 1, PDC_TOD, PDC_TOD_WRITE,
- tod.sec, tod.usec);
+ tvp->tv_sec, tvp->tv_usec);
+
return error;
}
+
+
+int
+pdcproc_chassis_display(unsigned long disp)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_CHASSIS, PDC_CHASSIS_DISP, disp);
+
+ return err;
+}
+
+int
+pdcproc_chassis_info(struct pdc_chassis_info *pci, struct pdc_chassis_lcd *pcl)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_CHASSIS, PDC_CHASSIS_INFO,
+ &pdcret1, &pdcret2);
+ if (err < 0)
+ return err;
+
+ memcpy(pci, &pdcret1, sizeof(*pci));
+ memcpy(pcl, &pdcret2, sizeof(*pcl));
+
+ return err;
+}
+
+int
+pdcproc_pim(int type, struct pdc_pim *pp, void **buf, size_t *sz)
+{
+ static char data[896] __attribute__((__aligned__(8)));
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_PIM, type, &pdcret1, data,
+ sizeof(data));
+ if (err < 0)
+ return err;
+
+ memcpy(pp, &pdcret1, sizeof(*pp));
+ *buf = data;
+ *sz = sizeof(data);
+
+ return err;
+}
+
+int
+pdcproc_model_info(struct pdc_model *pm)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_MODEL, PDC_MODEL_INFO, &pdcret1);
+ if (err < 0)
+ return err;
+
+ memcpy(pm, &pdcret1, sizeof(*pm));
+
+ return err;
+}
+
+int
+pdcproc_model_cpuid(struct pdc_cpuid *pc)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_MODEL, PDC_MODEL_CPUID, &pdcret1);
+ if (err < 0)
+ return err;
+
+ memcpy(pc, &pdcret1, sizeof(*pc));
+
+ return err;
+}
+
+int
+pdcproc_cache(struct pdc_cache *pc)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_DFLT, &pdcret1);
+
+ if (err < 0)
+ return err;
+
+ memcpy(pc, &pdcret1, sizeof(*pc));
+
+ return err;
+}
+
+
+int
+pdcproc_cache_spidbits(struct pdc_spidb *pcs)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_GETSPIDB,
+ &pdcret1);
+
+ if (err < 0)
+ return err;
+
+ memcpy(pcs, &pdcret1, sizeof(*pcs));
+
+ return err;
+}
+
+int
+pdcproc_hpa_processor(hppa_hpa_t *hpa)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_HPA, PDC_HPA_DFLT, &pdcret1);
+ if (err < 0)
+ return err;
+
+ *hpa = pdcret1.result[0];
+
+ return err;
+}
+
+int
+pdcproc_coproc(struct pdc_coproc *pc)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_COPROC, PDC_COPROC_DFLT, &pdcret1);
+ if (err < 0)
+ return err;
+
+ memcpy(pc, &pdcret1, sizeof(*pc));
+
+ return err;
+}
+
+int
+pdcproc_iodc_read(hppa_hpa_t hpa, int command, int *actcnt,
+ struct pdc_iodc_read *buf1, size_t sz1, struct iodc_data *buf2,
+ size_t sz2)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_IODC, PDC_IODC_READ,
+ &pdcret1, hpa, command, &pdcret2, sizeof(pdcret2));
+
+ if (err < 0)
+ return err;
+
+ if (actcnt != NULL) {
+ struct pdc_iodc_read *pir = (struct pdc_iodc_read *)&pdcret1;
+
+ *actcnt = pir->size;
+ }
+
+ memcpy(buf1, &pdcret1, sz1);
+ memcpy(buf2, &pdcret2, sz2);
+
+ return err;
+}
+
+int
+pdcproc_iodc_ninit(struct pdc_iodc_minit *pimi, hppa_hpa_t hpa, int sz)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_IODC, PDC_IODC_NINIT, &pdcret1,
+ hpa, sz);
+
+ if (err < 0)
+ return err;
+
+ memcpy(pimi, &pdcret1, sizeof(*pimi));
+
+ return err;
+}
+
+int
+pdcproc_instr(unsigned int *mem)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_INSTR, PDC_INSTR_DFLT, &pdcret1);
+ if (err < 0)
+ return err;
+
+ memcpy(mem, &pdcret1, sizeof(*mem));
+
+ return err;
+}
+
+int
+pdcproc_block_tlb(struct pdc_btlb *pb)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, PDC_BTLB_DEFAULT,
+ &pdcret1);
+ if (err < 0)
+ return err;
+
+ memcpy(pb, &pdcret1, sizeof(*pb));
+
+ return err;
+}
+
+int
+pdcproc_btlb_insert(pa_space_t sp, vaddr_t va, paddr_t pa, vsize_t sz,
+ u_int prot, int index)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, PDC_BTLB_INSERT, sp,
+ va, pa, sz, prot, index);
+
+ return err;
+}
+
+int
+pdcproc_btlb_purge(pa_space_t sp, vaddr_t va, paddr_t pa, vsize_t sz)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, PDC_BTLB_PURGE, sp, va,
+ pa, sz);
+
+ return err;
+}
+
+int
+pdcproc_btlb_purgeall(void)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, PDC_BTLB_PURGE_ALL);
+
+ return err;
+}
+
+int pdcproc_tlb_info(struct pdc_hwtlb *ph)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_TLB, PDC_TLB_INFO, &pdcret1);
+ if (err < 0)
+ return err;
+
+ memcpy(ph, &pdcret1, sizeof(*ph));
+
+ return err;
+}
+
+int
+pdcproc_tlb_config(struct pdc_hwtlb *ph, unsigned long hpt,
+ unsigned long hptsize, unsigned long type)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_TLB, PDC_TLB_CONFIG, ph, hpt,
+ hptsize, type);
+
+ return err;
+}
+
+int
+pdcproc_system_map_find_mod(struct pdc_system_map_find_mod *psm,
+ struct device_path *dev, int mod)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_SYSTEM_MAP,
+ PDC_SYSTEM_MAP_FIND_MOD, &pdcret1, &pdcret2, mod);
+ if (err < 0)
+ return err;
+
+ memcpy(psm, &pdcret1, sizeof(*psm));
+ memcpy(dev, &pdcret2, sizeof(*dev));
+
+ return err;
+}
+
+int
+pdcproc_system_map_find_addr(struct pdc_system_map_find_addr *psm, int mod,
+ int addr)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_SYSTEM_MAP,
+ PDC_SYSTEM_MAP_FIND_ADDR, &pdcret1, mod, addr);
+ if (err < 0)
+ return err;
+
+ memcpy(psm, &pdcret1, sizeof(*psm));
+
+ return err;
+
+}
+
+int
+pdcproc_system_map_trans_path(struct pdc_memmap *pmm, struct device_path *dev)
+{
+ int err;
+
+ memcpy(&pdcret2, dev, sizeof(*dev));
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_SYSTEM_MAP,
+ PDC_SYSTEM_MAP_TRANS_PATH, &pdcret1, &pdcret2);
+ if (err < 0)
+ return err;
+
+ memcpy(pmm, &pdcret1, sizeof(*pmm));
+
+ return err;
+}
+
+int
+pdcproc_soft_power_info(struct pdc_power_info *pspi)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_SOFT_POWER, PDC_SOFT_POWER_INFO,
+ &pdcret1, 0);
+ if (err < 0)
+ return err;
+
+ memcpy(pspi, &pdcret1, sizeof(*pspi));
+
+ return err;
+}
+
+int
+pdcproc_soft_power_enable(int action)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_SOFT_POWER, PDC_SOFT_POWER_ENABLE,
+ &pdcret1, action);
+
+ return err;
+}
+
+int
+pdcproc_memmap(struct pdc_memmap *pmm, struct device_path *dev)
+{
+ int err;
+
+ memcpy(&pdcret2, dev, sizeof(*dev));
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_MEMMAP, PDC_MEMMAP_HPA, &pdcret1,
+ &pdcret2);
+ if (err < 0)
+ return err;
+
+ memcpy(pmm, &pdcret1, sizeof(*pmm));
+
+ return err;
+}
+
+int
+pdcproc_ioclrerrors(void)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_IO, PDC_IO_READ_AND_CLEAR_ERRORS);
+
+ return err;
+}
+
+int
+pdcproc_ioreset(void)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_IO, PDC_IO_RESET_DEVICES);
+
+ return err;
+}
+
+int
+pdcproc_doreset(void)
+{
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_BROADCAST_RESET, PDC_DO_RESET);
+
+ return err;
+}
+
+int
+pdcproc_lan_station_id(char *addr, size_t sz, hppa_hpa_t hpa)
+{
+ struct pdc_lan_station_id *mac = (struct pdc_lan_station_id *)&pdcret1;
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_LAN_STATION_ID,
+ PDC_LAN_STATION_ID_READ, &pdcret1, hpa);
+ if (err < 0)
+ return err;
+
+ memcpy(addr, mac->addr, sz);
+
+ return 0;
+}
+
+int
+pdcproc_pci_inttblsz(int *nentries)
+{
+ struct pdc_pat_io_num *ppio = (struct pdc_pat_io_num *)&pdcret1;
+ int err;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL_SZ,
+ &pdcret1);
+
+ *nentries = ppio->num;
+
+ return err;
+}
+
+/* Maximum number of supported interrupt routing entries. */
+#define MAX_INT_TBL_SZ 16
+
+int
+pdcproc_pci_gettable(int nentries, size_t size, void *table)
+{
+ int err;
+ static struct pdc_pat_pci_rt int_tbl[MAX_INT_TBL_SZ] PDC_ALIGNMENT;
+
+ if (nentries > MAX_INT_TBL_SZ)
+ panic("interrupt routing table too big (%d entries)", nentries);
+
+ pdcret1.result[0] = nentries;
+
+ err = pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL,
+ &pdcret1, 0, &int_tbl);
+ if (err < 0)
+ return err;
+
+ memcpy(table, int_tbl, size);
+
+ return err;
+}
Index: src/sys/arch/hp700/dev/power.c
diff -u src/sys/arch/hp700/dev/power.c:1.5 src/sys/arch/hp700/dev/power.c:1.6
--- src/sys/arch/hp700/dev/power.c:1.5 Sun Dec 12 08:23:14 2010
+++ src/sys/arch/hp700/dev/power.c Tue Jan 4 10:42:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: power.c,v 1.5 2010/12/12 08:23:14 skrll Exp $ */
+/* $NetBSD: power.c,v 1.6 2011/01/04 10:42:33 skrll Exp $ */
/*
* Copyright (c) 2004 Jochen Kunz.
@@ -100,7 +100,7 @@
CFATTACH_DECL_NEW(power, sizeof(struct power_softc),
powermatch, powerattach, NULL, NULL);
-static struct pdc_power_info pdc_power_info PDC_ALIGNMENT;
+static struct pdc_power_info pdc_power_info;
static bool pswitch_on; /* power switch */
static int pwr_sw_control;
static const char *pwr_sw_control_str[] = {"disabled", "enabled", "locked"};
@@ -132,14 +132,15 @@
{
struct power_softc *sc = device_private(self);
struct confargs *ca = aux;
+ int err;
sc->sc_dev = self;
sc->sc_kicker = NULL;
- if (!pdc_call((iodcio_t)pdc, 0, PDC_SOFT_POWER,
- PDC_SOFT_POWER_INFO, &pdc_power_info, 0)) {
+ err = pdcproc_soft_power_info(&pdc_power_info);
+
+ if (!err)
ca->ca_hpa = pdc_power_info.addr;
- }
switch (cpu_modelno) {
case HPPA_BOARD_HP712_60:
@@ -248,9 +249,8 @@
{
int error;
- if ((error = pdc_call((iodcio_t)pdc, 0, PDC_SOFT_POWER,
- PDC_SOFT_POWER_ENABLE, &pdc_power_info,
- on == HPPA_COLD_HOT)))
+ error = pdcproc_soft_power_enable(on == HPPA_COLD_HOT);
+ if (error)
aprint_error("PDC_SOFT_POWER_ENABLE failed (%d)\n", error);
}
Index: src/sys/arch/hp700/gsc/oosiop_gsc.c
diff -u src/sys/arch/hp700/gsc/oosiop_gsc.c:1.10 src/sys/arch/hp700/gsc/oosiop_gsc.c:1.11
--- src/sys/arch/hp700/gsc/oosiop_gsc.c:1.10 Sat Dec 11 19:32:06 2010
+++ src/sys/arch/hp700/gsc/oosiop_gsc.c Tue Jan 4 10:42:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: oosiop_gsc.c,v 1.10 2010/12/11 19:32:06 skrll Exp $ */
+/* $NetBSD: oosiop_gsc.c,v 1.11 2011/01/04 10:42:33 skrll Exp $ */
/*
* Copyright (c) 2001 Matt Fredette. All rights reserved.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: oosiop_gsc.c,v 1.10 2010/12/11 19:32:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: oosiop_gsc.c,v 1.11 2011/01/04 10:42:33 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -156,7 +156,7 @@
return;
}
- sc->sc_freq = ga->ga_ca.ca_pdc_iodc_read->filler2[14];
+ sc->sc_freq = ga->ga_ca.ca_pir.filler2[14];
if (sc->sc_freq == 0)
sc->sc_freq = 50000000;
Index: src/sys/arch/hp700/gsc/osiop_gsc.c
diff -u src/sys/arch/hp700/gsc/osiop_gsc.c:1.17 src/sys/arch/hp700/gsc/osiop_gsc.c:1.18
--- src/sys/arch/hp700/gsc/osiop_gsc.c:1.17 Sat Dec 11 19:32:06 2010
+++ src/sys/arch/hp700/gsc/osiop_gsc.c Tue Jan 4 10:42:33 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: osiop_gsc.c,v 1.17 2010/12/11 19:32:06 skrll Exp $ */
+/* $NetBSD: osiop_gsc.c,v 1.18 2011/01/04 10:42:33 skrll Exp $ */
/*
* Copyright (c) 2001 Matt Fredette. All rights reserved.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: osiop_gsc.c,v 1.17 2010/12/11 19:32:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: osiop_gsc.c,v 1.18 2011/01/04 10:42:33 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -156,7 +156,7 @@
return;
}
- sc->sc_clock_freq = ga->ga_ca.ca_pdc_iodc_read->filler2[14] / 1000000;
+ sc->sc_clock_freq = ga->ga_ca.ca_pir.filler2[14] / 1000000;
if (!sc->sc_clock_freq)
sc->sc_clock_freq = 50;
Index: src/sys/arch/hp700/hp700/autoconf.c
diff -u src/sys/arch/hp700/hp700/autoconf.c:1.34 src/sys/arch/hp700/hp700/autoconf.c:1.35
--- src/sys/arch/hp700/hp700/autoconf.c:1.34 Sat Nov 13 07:58:55 2010
+++ src/sys/arch/hp700/hp700/autoconf.c Tue Jan 4 10:42:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.34 2010/11/13 07:58:55 skrll Exp $ */
+/* $NetBSD: autoconf.c,v 1.35 2011/01/04 10:42:34 skrll Exp $ */
/* $OpenBSD: autoconf.c,v 1.15 2001/06/25 00:43:10 mickey Exp $ */
@@ -86,7 +86,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.34 2010/11/13 07:58:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.35 2011/01/04 10:42:34 skrll Exp $");
#include "opt_kgdb.h"
#include "opt_useleds.h"
@@ -105,6 +105,7 @@
#include <sys/kgdb.h>
#endif
+#include <machine/pdc.h>
#include <machine/iomod.h>
#include <machine/autoconf.h>
@@ -457,10 +458,9 @@
/*static struct device fakerdrootdev = { DV_DISK, {}, NULL, 0, "rd0", NULL };*/
#endif
-static struct pdc_memmap pdc_memmap PDC_ALIGNMENT;
-static struct pdc_iodc_read pdc_iodc_read PDC_ALIGNMENT;
-static struct pdc_system_map_find_mod pdc_find_mod PDC_ALIGNMENT;
-static struct pdc_system_map_find_addr pdc_find_addr PDC_ALIGNMENT;
+static struct pdc_memmap pdc_memmap;
+static struct pdc_system_map_find_mod pdc_find_mod;
+static struct pdc_system_map_find_addr pdc_find_addr;
void
pdc_scanbus(device_t self, struct confargs *ca,
@@ -489,18 +489,17 @@
if (ca->ca_hpabase) {
nca.ca_hpa = ca->ca_hpabase + IOMOD_HPASIZE * i;
nca.ca_dp.dp_mod = i;
- } else if ((error = pdc_call((iodcio_t)pdc, 0, PDC_MEMMAP,
- PDC_MEMMAP_HPA, &pdc_memmap, &nca.ca_dp)) == 0)
+ } else if ((error = pdcproc_memmap(&pdc_memmap,
+ &nca.ca_dp)) == 0)
nca.ca_hpa = pdc_memmap.hpa;
- else if ((error = pdc_call((iodcio_t)pdc, 0, PDC_SYSTEM_MAP,
- PDC_SYSTEM_MAP_TRANS_PATH, &pdc_memmap, &nca.ca_dp)) == 0) {
+ else if ((error = pdcproc_system_map_trans_path(&pdc_memmap,
+ &nca.ca_dp)) == 0) {
struct device_path path;
int im, ia;
nca.ca_hpa = pdc_memmap.hpa;
- for (im = 0; !(error = pdc_call((iodcio_t)pdc, 0,
- PDC_SYSTEM_MAP, PDC_SYSTEM_MAP_FIND_MOD,
+ for (im = 0; !(error = pdcproc_system_map_find_mod(
&pdc_find_mod, &path, im)) &&
pdc_find_mod.hpa != nca.ca_hpa; im++)
;
@@ -510,18 +509,21 @@
if (!error && pdc_find_mod.naddrs) {
nca.ca_naddrs = pdc_find_mod.naddrs;
- if (nca.ca_naddrs > 16) {
- nca.ca_naddrs = 16;
+ if (nca.ca_naddrs > HP700_MAXIOADDRS) {
+ nca.ca_naddrs = HP700_MAXIOADDRS;
aprint_error("WARNING: "
"too many (%d) addrs\n",
pdc_find_mod.naddrs);
}
aprint_verbose(">> ADDRS: ");
- for (ia = 0; !(error = pdc_call((iodcio_t)pdc,
- 0, PDC_SYSTEM_MAP, PDC_SYSTEM_MAP_FIND_ADDR,
- &pdc_find_addr, im, ia + 1)) && ia < nca.ca_naddrs; ia++) {
- nca.ca_addrs[ia].addr = pdc_find_addr.hpa;
+ for (ia = 0; ia < nca.ca_naddrs; ia++) {
+ error = pdcproc_system_map_find_addr(
+ &pdc_find_addr, im, ia + 1);
+ if (error)
+ break;
+ nca.ca_addrs[ia].addr =
+ pdc_find_addr.hpa;
nca.ca_addrs[ia].size =
pdc_find_addr.size << PGSHIFT;
@@ -539,8 +541,8 @@
aprint_verbose(">> HPA 0x%lx[0x%x]\n", nca.ca_hpa,
nca.ca_hpasz);
- if ((error = pdc_call((iodcio_t)pdc, 0, PDC_IODC,
- PDC_IODC_READ, &pdc_iodc_read, nca.ca_hpa, IODC_DATA,
+ if ((error = pdcproc_iodc_read(nca.ca_hpa, IODC_DATA, NULL,
+ &nca.ca_pir, sizeof(nca.ca_pir),
&nca.ca_type, sizeof(nca.ca_type))) < 0) {
aprint_verbose(">> iodc_data error %d\n", error);
continue;
@@ -557,7 +559,6 @@
nca.ca_type.iodc_type, nca.ca_type.iodc_sv_model);
nca.ca_irq = HP700CF_IRQ_UNDEF;
- 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);
Index: src/sys/arch/hp700/hp700/machdep.c
diff -u src/sys/arch/hp700/hp700/machdep.c:1.94 src/sys/arch/hp700/hp700/machdep.c:1.95
--- src/sys/arch/hp700/hp700/machdep.c:1.94 Sun Dec 12 08:54:25 2010
+++ src/sys/arch/hp700/hp700/machdep.c Tue Jan 4 10:42:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.94 2010/12/12 08:54:25 skrll Exp $ */
+/* $NetBSD: machdep.c,v 1.95 2011/01/04 10:42:34 skrll Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.94 2010/12/12 08:54:25 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.95 2011/01/04 10:42:34 skrll Exp $");
#include "opt_cputype.h"
#include "opt_ddb.h"
@@ -162,9 +162,9 @@
/*
* CPU params (should be the same for all cpus in the system)
*/
-struct pdc_cache pdc_cache PDC_ALIGNMENT;
-struct pdc_btlb pdc_btlb PDC_ALIGNMENT;
-struct pdc_model pdc_model PDC_ALIGNMENT;
+struct pdc_cache pdc_cache;
+struct pdc_btlb pdc_btlb;
+struct pdc_model pdc_model;
int usebtlb;
@@ -279,12 +279,12 @@
/*
* wide used hardware params
*/
-struct pdc_hwtlb pdc_hwtlb PDC_ALIGNMENT;
-struct pdc_coproc pdc_coproc PDC_ALIGNMENT;
-struct pdc_coherence pdc_coherence PDC_ALIGNMENT;
-struct pdc_spidb pdc_spidbits PDC_ALIGNMENT;
-struct pdc_pim pdc_pim PDC_ALIGNMENT;
-struct pdc_model pdc_model PDC_ALIGNMENT;
+struct pdc_hwtlb pdc_hwtlb;
+struct pdc_coproc pdc_coproc;
+struct pdc_coherence pdc_coherence;
+struct pdc_spidb pdc_spidbits;
+struct pdc_pim pdc_pim;
+struct pdc_model pdc_model;
/*
* Debugger info.
@@ -447,8 +447,8 @@
delay_init(); /* calculate CPU clock ratio */
/* cache parameters */
- if ((error = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_DFLT,
- &pdc_cache)) < 0) {
+ error = pdcproc_cache(&pdc_cache);
+ if (error < 0) {
#ifdef DEBUG
printf("WARNING: PDC_CACHE error %d\n", error);
#endif
@@ -459,23 +459,14 @@
icache_line_mask = pdc_cache.ic_conf.cc_line * 16 - 1;
icache_stride = pdc_cache.ic_stride;
- /* cache coherence params (pbably available for 8k only) */
- error = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_SETCS,
- &pdc_coherence, 1, 1, 1, 1);
-#ifdef DEBUG
- printf ("PDC_CACHE_SETCS: %d, %d, %d, %d (%d)\n",
- pdc_coherence.ia_cst, pdc_coherence.da_cst,
- pdc_coherence.ita_cst, pdc_coherence.dta_cst, error);
-#endif
- error = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_GETSPIDB,
- &pdc_spidbits, 0, 0, 0, 0);
+ error = pdcproc_cache_spidbits(&pdc_spidbits);
#ifdef DEBUG
printf("SPID bits: 0x%x, error = %d\n", pdc_spidbits.spidbits, error);
#endif
/* Calculate the OS_HPMC handler checksums. */
p = &os_hpmc;
- if (pdc_call((iodcio_t)pdc, 0, PDC_INSTR, PDC_INSTR_DFLT, p))
+ if (pdcproc_instr(p))
*p = 0x08000240;
p[7] = ((char *) &os_hpmc_cont_end) - ((char *) &os_hpmc_cont);
p[6] = (u_int) &os_hpmc_cont;
@@ -564,8 +555,7 @@
printf("%s: PDC_CHASSIS\n", __func__);
#endif
/* they say PDC_COPROC might turn fault light on */
- pdc_call((iodcio_t)pdc, 0, PDC_CHASSIS, PDC_CHASSIS_DISP,
- PDC_OSTAT(PDC_OSTAT_RUN) | 0xCEC0);
+ pdcproc_chassis_display(PDC_OSTAT(PDC_OSTAT_RUN) | 0xCEC0);
#ifdef DEBUG
printf("%s: intr bootstrap\n", __func__);
@@ -637,7 +627,7 @@
extern u_int trap_ep_T_ITLBMISS[];
extern u_int trap_ep_T_ITLBMISSNA[];
- struct pdc_cpuid pdc_cpuid PDC_ALIGNMENT;
+ struct pdc_cpuid pdc_cpuid;
const struct hppa_cpu_info *p = NULL;
const char *model;
u_int cpu_version, cpu_features;
@@ -650,8 +640,8 @@
cpu_version = 0;
/* identify system type */
- if ((error = pdc_call((iodcio_t)pdc, 0, PDC_MODEL, PDC_MODEL_INFO,
- &pdc_model)) < 0) {
+ error = pdcproc_model_info(&pdc_model);
+ if (error < 0) {
#ifdef DEBUG
printf("WARNING: PDC_MODEL_INFO error %d\n", error);
#endif
@@ -670,8 +660,8 @@
#endif
memset(&pdc_cpuid, 0, sizeof(pdc_cpuid));
- if ((error = pdc_call((iodcio_t)pdc, 0, PDC_MODEL, PDC_MODEL_CPUID,
- &pdc_cpuid, 0, 0, 0, 0)) < 0) {
+ error = pdcproc_model_cpuid(&pdc_cpuid);
+ if (error < 0) {
#ifdef DEBUG
printf("WARNING: PDC_MODEL_CPUID error %d. "
"Using cpu_modelno based cpu_type.\n", error);
@@ -695,8 +685,8 @@
/* locate coprocessors and SFUs */
memset(&pdc_coproc, 0, sizeof(pdc_coproc));
- if ((error = pdc_call((iodcio_t)pdc, 0, PDC_COPROC, PDC_COPROC_DFLT,
- &pdc_coproc, 0, 0, 0, 0)) < 0) { /* XXXNH 0,0,0,0 ???*/
+ error = pdcproc_coproc(&pdc_coproc);
+ if (error < 0) {
printf("WARNING: PDC_COPROC error %d\n", error);
pdc_coproc.ccr_enable = 0;
} else {
@@ -723,8 +713,8 @@
} else {
/* BTLB params */
- if ((error = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB,
- PDC_BTLB_DEFAULT, &pdc_btlb)) < 0) {
+ error = pdcproc_block_tlb(&pdc_btlb);
+ if (error < 0) {
#ifdef DEBUG
printf("WARNING: PDC_BTLB error %d\n", error);
#endif
@@ -744,8 +734,7 @@
pdc_btlb.vinfo.num_c);
#endif /* BTLBDEBUG */
/* purge TLBs and caches */
- if (pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB,
- PDC_BTLB_PURGE_ALL) < 0)
+ if (pdcproc_btlb_purgeall() < 0)
printf("WARNING: BTLB purge failed\n");
hppa_btlb_size_min = pdc_btlb.min_size;
@@ -762,7 +751,7 @@
}
usebtlb = 0;
- error = pdc_call((iodcio_t)pdc, 0, PDC_TLB, PDC_TLB_INFO, &pdc_hwtlb);
+ error = pdcproc_tlb_info(&pdc_hwtlb);
if (error == 0 && pdc_hwtlb.min_size != 0 && pdc_hwtlb.max_size != 0) {
cpu_features |= HPPA_FTRS_HVT;
if (pmap_hptsize > pdc_hwtlb.max_size)
@@ -1050,8 +1039,7 @@
hpti_g(vaddr_t hpt, vsize_t hptsize)
{
- return pdc_call((iodcio_t)pdc, 0, PDC_TLB, PDC_TLB_CONFIG,
- &pdc_hwtlb, hpt, hptsize, PDC_TLB_CURRPDE);
+ return pdcproc_tlb_config(&pdc_hwtlb, hpt, hptsize, PDC_TLB_CURRPDE);
}
int
@@ -1065,8 +1053,8 @@
{
int error;
- if ((error = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, PDC_BTLB_INSERT,
- sp, va, pa, sz, prot, i)) < 0) {
+ error = pdcproc_btlb_insert(sp, va, pa, sz, prot, i);
+ if (error < 0) {
#ifdef BTLBDEBUG
printf("WARNING: BTLB insert failed (%d)\n", error);
#endif
@@ -1118,13 +1106,14 @@
#endif
/* Insert this mapping. */
- if ((error = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, PDC_BTLB_INSERT,
+ error = pdcproc_btlb_insert(
btlb_slot->btlb_slot_va_space,
btlb_slot->btlb_slot_va_frame,
btlb_slot->btlb_slot_pa_frame,
btlb_slot->btlb_slot_frames,
btlb_slot->btlb_slot_tlbprot,
- btlb_slot->btlb_slot_number)) < 0) {
+ btlb_slot->btlb_slot_number);
+ if (error < 0) {
#ifdef BTLBDEBUG
printf("WARNING: BTLB insert failed (%d)\n", error);
#endif
@@ -1330,12 +1319,12 @@
if (btlb_slot->btlb_slot_frames != 0 &&
btlb_slot->btlb_slot_va_space == space &&
btlb_slot->btlb_slot_va_frame == va) {
- if ((error = pdc_call((iodcio_t)pdc, 0,
- PDC_BLOCK_TLB, PDC_BTLB_PURGE,
+ error = pdcproc_btlb_purge(
btlb_slot->btlb_slot_va_space,
btlb_slot->btlb_slot_va_frame,
btlb_slot->btlb_slot_number,
- btlb_slot->btlb_slot_frames)) < 0) {
+ btlb_slot->btlb_slot_frames);
+ if (error < 0) {
#ifdef BTLBDEBUG
printf("WARNING: BTLB purge failed (%d)\n",
error);
@@ -1446,7 +1435,7 @@
:: "r" (CMD_RESET), "r" (LBCAST_ADDR + iomod_command));
/* ask firmware to reset */
- pdc_call((iodcio_t)pdc, 0, PDC_BROADCAST_RESET, PDC_DO_RESET);
+ pdcproc_doreset();
/* forcably reset module if that fails */
__asm __volatile("stwas %0, 0(%1)"
:: "r" (CMD_RESET), "r" (HPPA_LBCAST + iomod_command));
@@ -1481,7 +1470,6 @@
* an LPMC, or a TOC. The check type is passed in as a trap
* type, one of T_HPMC, T_LPMC, or T_INTERRUPT (for TOC).
*/
-static char pim_data_buffer[896] __attribute__((__aligned__(8)));
static char in_check = 0;
#define PIM_WORD(name, word, bits) \
@@ -1493,7 +1481,7 @@
static inline void
-hppa_pim_dump(int check_type)
+hppa_pim_dump(int check_type, void *data, size_t size)
{
struct hp700_pim_hpmc *hpmc;
struct hp700_pim_lpmc *lpmc;
@@ -1509,16 +1497,16 @@
checks = NULL;
switch (check_type) {
case T_HPMC:
- hpmc = (struct hp700_pim_hpmc *) pim_data_buffer;
+ hpmc = (struct hp700_pim_hpmc *) data;
regs = &hpmc->pim_hpmc_regs;
checks = &hpmc->pim_hpmc_checks;
break;
case T_LPMC:
- lpmc = (struct hp700_pim_lpmc *) pim_data_buffer;
+ lpmc = (struct hp700_pim_lpmc *) data;
checks = &lpmc->pim_lpmc_checks;
break;
case T_INTERRUPT:
- toc = (struct hp700_pim_toc *) pim_data_buffer;
+ toc = (struct hp700_pim_toc *) data;
regs = &toc->pim_toc_regs;
break;
default:
@@ -1585,7 +1573,7 @@
}
static inline void
-hppa_pim64_dump(int check_type)
+hppa_pim64_dump(int check_type, void *data, size_t size)
{
struct hp700_pim64_hpmc *hpmc;
struct hp700_pim64_lpmc *lpmc;
@@ -1601,16 +1589,16 @@
checks = NULL;
switch (check_type) {
case T_HPMC:
- hpmc = (struct hp700_pim64_hpmc *) pim_data_buffer;
+ hpmc = (struct hp700_pim64_hpmc *) data;
regs = &hpmc->pim_hpmc_regs;
checks = &hpmc->pim_hpmc_checks;
break;
case T_LPMC:
- lpmc = (struct hp700_pim64_lpmc *) pim_data_buffer;
+ lpmc = (struct hp700_pim64_lpmc *) data;
checks = &lpmc->pim_lpmc_checks;
break;
case T_INTERRUPT:
- toc = (struct hp700_pim64_toc *) pim_data_buffer;
+ toc = (struct hp700_pim64_toc *) data;
regs = &toc->pim_toc_regs;
break;
default:
@@ -1686,6 +1674,8 @@
int pdc_pim_type;
const char *name;
int pimerror, error;
+ void *data;
+ size_t size;
/* Do an fcacheall(). */
fcacheall();
@@ -1709,10 +1699,9 @@
/* NOTREACHED */
}
- pimerror = pdc_call((iodcio_t)pdc, 0, PDC_PIM, pdc_pim_type,
- &pdc_pim, pim_data_buffer, sizeof(pim_data_buffer));
+ pimerror = pdcproc_pim(pdc_pim_type, &pdc_pim, &data, &size);
- KASSERT(pdc_pim.count <= sizeof(pim_data_buffer));
+ KASSERT(pdc_pim.count <= size);
/*
* Reset IO and log errors.
@@ -1721,7 +1710,7 @@
* if we take a HPMC interrupt. This PDC procedure may not be
* implemented by some machines.
*/
- error = pdc_call((iodcio_t)pdc, 0, PDC_IO, 0, 0, 0, 0);
+ error = pdcproc_ioclrerrors();
if (error != PDC_ERR_OK && error != PDC_ERR_NOPROC)
/* This seems futile if we can't print to the console. */
panic("PDC_IO failed");
@@ -1732,9 +1721,9 @@
printf(" - WARNING: could not transfer PIM info (%d)", pimerror);
} else {
if (hppa_cpu_ispa20_p())
- hppa_pim64_dump(check_type);
+ hppa_pim64_dump(check_type, data, size);
else
- hppa_pim_dump(check_type);
+ hppa_pim_dump(check_type, data, size);
}
printf("\n");
Index: src/sys/arch/hp700/hp700/mainbus.c
diff -u src/sys/arch/hp700/hp700/mainbus.c:1.74 src/sys/arch/hp700/hp700/mainbus.c:1.75
--- src/sys/arch/hp700/hp700/mainbus.c:1.74 Sun Dec 12 08:23:14 2010
+++ src/sys/arch/hp700/hp700/mainbus.c Tue Jan 4 10:42:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: mainbus.c,v 1.74 2010/12/12 08:23:14 skrll Exp $ */
+/* $NetBSD: mainbus.c,v 1.75 2011/01/04 10:42:34 skrll Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.74 2010/12/12 08:23:14 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.75 2011/01/04 10:42:34 skrll Exp $");
#include "locators.h"
#include "power.h"
@@ -83,10 +83,8 @@
#include <hp700/hp700/intr.h>
#include <hp700/dev/cpudevs.h>
-static struct pdc_hpa pdc_hpa PDC_ALIGNMENT;
#if NLCD > 0
-static struct pdc_chassis_info pdc_chassis_info PDC_ALIGNMENT;
-static struct pdc_chassis_lcd pdc_chassis_lcd PDC_ALIGNMENT;
+static struct pdc_chassis_info pdc_chassis_info;
#endif
#ifdef MBUSDEBUG
@@ -1360,13 +1358,16 @@
struct confargs nca;
bus_space_handle_t ioh;
hppa_hpa_t hpabase;
+ hppa_hpa_t prochpa;
+ int err;
sc->sc_dv = self;
-
mb_attached = 1;
/* fetch the "default" cpu hpa */
- if (pdc_call((iodcio_t)pdc, 0, PDC_HPA, PDC_HPA_DFLT, &pdc_hpa) < 0)
+
+ err = pdcproc_hpa_processor(&prochpa);
+ if (err < 0)
panic("mbattach: PDC_HPA failed");
/*
@@ -1375,20 +1376,23 @@
* end of the address space.
*/
/*
- * XXX fredette - this may be a copout, or it may
- * be a great idea. I'm not sure which yet.
+ * XXX fredette - this may be a copout, or it may be a great idea. I'm
+ * not sure which yet.
*/
- if (bus_space_map(&hppa_bustag, pdc_hpa.hpa, 0 - pdc_hpa.hpa, 0, &ioh))
- panic("mbattach: can't map mainbus IO space");
+
+ /* map all the way till the end of the memory */
+ if (bus_space_map(&hppa_bustag, prochpa, (~0LU - prochpa + 1),
+ 0, &ioh))
+ panic("%s: cannot map mainbus IO space", __func__);
/*
* Local-Broadcast the HPA to all modules on the bus
*/
- ((struct iomod *)(pdc_hpa.hpa & HPPA_FLEX_MASK))[FPA_IOMOD].io_flex =
- (void *)((pdc_hpa.hpa & HPPA_FLEX_MASK) | DMA_ENABLE);
+ ((struct iomod *)(prochpa & HPPA_FLEX_MASK))[FPA_IOMOD].io_flex =
+ (void *)((prochpa & HPPA_FLEX_MASK) | DMA_ENABLE);
- sc->sc_hpa = pdc_hpa.hpa;
- aprint_normal(" [flex %lx]\n", pdc_hpa.hpa & HPPA_FLEX_MASK);
+ sc->sc_hpa = prochpa;
+ aprint_normal(" [flex %lx]\n", prochpa & HPPA_FLEX_MASK);
/* PDC first */
memset(&nca, 0, sizeof(nca));
@@ -1408,18 +1412,16 @@
#endif
#if NLCD > 0
- if (!pdc_call((iodcio_t)pdc, 0, PDC_CHASSIS, PDC_CHASSIS_INFO,
- &pdc_chassis_info, &pdc_chassis_lcd, sizeof(pdc_chassis_lcd)) &&
- pdc_chassis_lcd.enabled) {
- memset(&nca, 0, sizeof(nca));
+ memset(&nca, 0, sizeof(nca));
+ err = pdcproc_chassis_info(&pdc_chassis_info, &nca.ca_pcl);
+ if (!err && nca.ca_pcl.enabled) {
nca.ca_name = "lcd";
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_irq = -1;
nca.ca_iot = &hppa_bustag;
- nca.ca_hpa = pdc_chassis_lcd.cmd_addr;
- nca.ca_pdc_iodc_read = (void *)&pdc_chassis_lcd;
+ nca.ca_hpa = nca.ca_pcl.cmd_addr;
config_found(self, &nca, mbprint);
}
Index: src/sys/arch/hp700/include/autoconf.h
diff -u src/sys/arch/hp700/include/autoconf.h:1.14 src/sys/arch/hp700/include/autoconf.h:1.15
--- src/sys/arch/hp700/include/autoconf.h:1.14 Mon Jan 3 19:20:11 2011
+++ src/sys/arch/hp700/include/autoconf.h Tue Jan 4 10:42:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.h,v 1.14 2011/01/03 19:20:11 skrll Exp $ */
+/* $NetBSD: autoconf.h,v 1.15 2011/01/04 10:42:34 skrll Exp $ */
/* $OpenBSD: autoconf.h,v 1.10 2001/05/05 22:33:42 art Exp $ */
@@ -33,14 +33,23 @@
#include <machine/bus.h>
#include <machine/pdc.h>
+/* 16 should be enough for anyone */
+#define HP700_MAXIOADDRS 16
+
struct confargs {
- struct iodc_data ca_type PDC_ALIGNMENT; /* iodc-specific type descrition */
+ struct iodc_data ca_type; /* iodc-specific type descrition */
struct device_path ca_dp; /* device_path as found by pdc_scan */
- struct pdc_iodc_read *ca_pdc_iodc_read;
+ union {
+ struct pdc_iodc_read uca_pir;
+ struct pdc_chassis_lcd uca_pcl;
+ } ca_u;
+#define ca_pir ca_u.uca_pir
+#define ca_pcl ca_u.uca_pcl
+
struct {
hppa_hpa_t addr;
u_int size;
- } ca_addrs[16]; /* 16 is ought to be enough */
+ } ca_addrs[HP700_MAXIOADDRS];
const char *ca_name; /* device name/description */
bus_space_tag_t ca_iot; /* io tag */
int ca_mod; /* module number on the bus */
Index: src/sys/arch/hp700/include/pdc.h
diff -u src/sys/arch/hp700/include/pdc.h:1.16 src/sys/arch/hp700/include/pdc.h:1.17
--- src/sys/arch/hp700/include/pdc.h:1.16 Sun Dec 12 08:23:15 2010
+++ src/sys/arch/hp700/include/pdc.h Tue Jan 4 10:42:34 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: pdc.h,v 1.16 2010/12/12 08:23:15 skrll Exp $ */
+/* $NetBSD: pdc.h,v 1.17 2011/01/04 10:42:34 skrll Exp $ */
/* $OpenBSD: pdc.h,v 1.35 2007/07/15 20:03:48 kettenis Exp $ */
@@ -335,13 +335,15 @@
#define PZL_ENCODE(bits, parity, speed) \
(((bits) - 5) & 0x03) | (((parity) & 0x3) << 3) | \
(((speed) & 0x0f) << 6)
+};
+struct pdc_result { /* general result buffer */
+ u_int result[32];
};
struct pdc_pim { /* PDC_PIM */
u_int count; /* actual (HPMC, LPMC) or total (SIZE) count */
u_int archsize; /* size of architected regions (see "pim.h") */
- u_int filler[30];
};
struct pdc_model { /* PDC_MODEL */
@@ -362,22 +364,18 @@
u_int arch_rev; /* architecture revision */
u_int pot_key; /* potential key */
u_int curr_key; /* current key */
- int filler1;
- u_int filler2[22];
};
struct pdc_cpuid { /* PDC_MODEL, PDC_CPUID */
u_int reserved : 20;
u_int version : 7; /* CPU version */
u_int revision : 5; /* CPU revision */
- u_int filler[31];
};
struct pdc_getbootopts { /* PDC_MODEL_GETBOOTOPTS */
u_int cur_test; /* current enabled tests */
u_int sup_test; /* supported tests */
u_int def_test; /* default enabled tests */
- u_int filler[29];
};
struct cache_cf { /* PDC_CACHE (for "struct pdc_cache") */
@@ -448,14 +446,12 @@
u_int dt_off_stride; /* offset incr per off_count iteration (flush)*/
u_int dt_off_count; /* number of dt_loop iterations/space (flush) */
u_int dt_loop; /* number of PDTLBE's per off_stride (flush) */
- u_int filler[2];
};
struct pdc_spidb { /* PDC_CACHE, PDC_CACHE_GETSPIDB */
u_int spidR1 : 4;
u_int spidbits : 12;
u_int spidR2 : 16;
- u_int filler[31];
};
struct pdc_cst {
@@ -473,13 +469,10 @@
#define ita_cst ita.cst
struct pdc_cst dta;
#define dta_cst dta.cst
- u_int filler[28];
};
struct pdc_hpa { /* PDC_HPA */
hppa_hpa_t hpa; /* HPA of processor */
- int filler1;
- u_int filler2[30];
};
struct pdc_coproc { /* PDC_COPROC */
@@ -488,13 +481,11 @@
u_int pad[15];
u_int fpu_revision;
u_int fpu_model;
- u_int filler2[13];
};
struct pdc_tod { /* PDC_TOD, PDC_TOD_READ */
u_int sec; /* elapsed time since 00:00:00 GMT, 1/1/70 */
u_int usec; /* accurate to microseconds */
- u_int filler2[30];
};
struct pdc_itimer { /* PDC_TOD_ITIMER */
@@ -502,7 +493,6 @@
u_int calib1;
u_int tod_acc; /* TOD accuracy in 1e-9 part */
u_int cr_acc; /* itmr accuracy in 1e-9 parts */
- u_int filler[28];
};
struct pdc_nvm { /* PDC_NVM */
@@ -517,8 +507,6 @@
struct pdc_instr { /* PDC_INSTR */
u_int instr; /* instruction that invokes PDC mchk entry pt */
- int filler1;
- u_int filler2[30];
};
struct pdc_iodc_read { /* PDC_IODC, PDC_IODC_READ */
@@ -532,7 +520,6 @@
u_int max_spa; /* size of SPA (in bytes) > max_mem+map_mem */
u_int max_mem; /* size of "implemented" memory (in bytes) */
u_int map_mem; /* size of "mappable-only" memory (in bytes) */
- u_int filler[28];
};
struct btlb_info { /* for "struct pdc_btlb" (PDC_BTLB) */
@@ -547,24 +534,20 @@
u_int max_size; /* Max size in pages */
struct btlb_info finfo; /* Fixed range info */
struct btlb_info vinfo; /* Variable range info */
- u_int filler[28];
};
struct pdc_hwtlb { /* PDC_TLB */
u_int min_size; /* What do these mean? */
u_int max_size;
- u_int filler[30];
};
struct pdc_power_info { /* PDC_SOFT_POWER_INFO */
u_int addr; /* power register address */
- u_int filler[31];
};
struct pdc_pat_cell_id { /* PDC_PAT_CELL_GETID */
u_long id; /* cell id */
u_long loc; /* cell location */
- u_long filler[14];
};
struct pdc_pat_cell_module { /* PDC_PAT_CELL_MODULE */
@@ -581,7 +564,6 @@
struct pdc_pat_io_num { /* PDC_PAT_IO */
u_int num;
- u_int filler[31];
};
struct pdc_pat_pci_rt { /* PDC_PAT_IO_GET_PCI_RT */
@@ -599,7 +581,6 @@
struct pdc_memmap { /* PDC_MEMMAP */
u_int hpa; /* HPA for module */
u_int morepages; /* additional IO pages */
- u_int filler[30];
};
struct pdc_system_map_find_mod { /* PDC_SYSTEM_MAP_FIND_MOD */
@@ -607,19 +588,15 @@
u_int size; /* pages */
u_int naddrs;
u_int mod_index;
- u_int filler[28];
};
struct pdc_system_map_find_addr { /* PDC_SYSTEM_MAP_FIND_ADDR */
u_int hpa;
u_int size; /* pages */
- u_int filler[30];
};
struct pdc_lan_station_id { /* PDC_LAN_STATION_ID */
uint8_t addr[6];
- uint8_t filler1[2];
- u_int filler2[30];
};
/*
@@ -665,7 +642,6 @@
struct pdc_chassis_info {
u_int size;
u_int max_size;
- u_int filler[30];
};
struct pdc_chassis_lcd {
@@ -678,7 +654,6 @@
uint8_t enabled;
uint8_t heartbeat[3];
uint8_t disk[3];
- u_int filler[25];
};
/*
@@ -788,6 +763,57 @@
int pdccngetc(dev_t);
void pdccnputc(dev_t, int);
void pdccnpollc(dev_t, int);
+
+int pdcproc_chassis_display(unsigned long);
+int pdcproc_chassis_info(struct pdc_chassis_info *, struct pdc_chassis_lcd *);
+
+int pdcproc_pim(int, struct pdc_pim *, void **, size_t *);
+
+int pdcproc_model_info(struct pdc_model *);
+int pdcproc_model_cpuid(struct pdc_cpuid *);
+
+int pdcproc_cache(struct pdc_cache *);
+int pdcproc_cache_coherence(struct pdc_coherence *);
+int pdcproc_cache_spidbits(struct pdc_spidb *);
+
+int pdcproc_hpa_processor(hppa_hpa_t *);
+
+int pdcproc_coproc(struct pdc_coproc *);
+
+int pdcproc_iodc_read(hppa_hpa_t, int, int *, struct pdc_iodc_read *, size_t,
+ struct iodc_data *, size_t);
+int pdcproc_iodc_ninit(struct pdc_iodc_minit *, hppa_hpa_t, int);
+
+int pdcproc_instr(unsigned int *);
+
+int pdcproc_block_tlb(struct pdc_btlb *);
+int pdcproc_btlb_insert(pa_space_t, vaddr_t, paddr_t, vsize_t, u_int, int);
+int pdcproc_btlb_purge(pa_space_t, vaddr_t, paddr_t, vsize_t);
+int pdcproc_btlb_purgeall(void);
+
+int pdcproc_tlb_info(struct pdc_hwtlb *);
+int pdcproc_tlb_config(struct pdc_hwtlb *, vaddr_t, vsize_t, unsigned long);
+
+int pdcproc_system_map_find_mod(struct pdc_system_map_find_mod *,
+ struct device_path *, int);
+int pdcproc_system_map_find_addr(struct pdc_system_map_find_addr *, int, int);
+int pdcproc_system_map_trans_path(struct pdc_memmap *, struct device_path *);
+
+int pdcproc_soft_power_enable(int);
+int pdcproc_soft_power_info(struct pdc_power_info *);
+
+int pdcproc_memmap(struct pdc_memmap *, struct device_path *);
+
+int pdcproc_ioclrerrors(void);
+int pdcproc_ioreset(void);
+
+int pdcproc_doreset(void);
+
+int pdcproc_lan_station_id(char *, size_t, hppa_hpa_t);
+
+int pdcproc_pci_inttblsz(int *);
+int pdcproc_pci_gettable(int, size_t, void *);
+
#endif
#endif /* !(_LOCORE) */