Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hp700 Centralise the PDC procedure calls into one f...



details:   https://anonhg.NetBSD.org/src/rev/d069a3f130ad
branches:  trunk
changeset: 760412:d069a3f130ad
user:      skrll <skrll%NetBSD.org@localhost>
date:      Tue Jan 04 10:42:33 2011 +0000

description:
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.

diffstat:

 sys/arch/hp700/dev/apic.c         |   29 +-
 sys/arch/hp700/dev/astro.c        |    4 +-
 sys/arch/hp700/dev/lasi.c         |   11 +-
 sys/arch/hp700/dev/lcd.c          |    4 +-
 sys/arch/hp700/dev/mem.c          |   10 +-
 sys/arch/hp700/dev/pdc.c          |  473 ++++++++++++++++++++++++++++++++++++-
 sys/arch/hp700/dev/power.c        |   16 +-
 sys/arch/hp700/gsc/oosiop_gsc.c   |    6 +-
 sys/arch/hp700/gsc/osiop_gsc.c    |    6 +-
 sys/arch/hp700/hp700/autoconf.c   |   43 +-
 sys/arch/hp700/hp700/machdep.c    |  115 ++++-----
 sys/arch/hp700/hp700/mainbus.c    |   44 +-
 sys/arch/hp700/include/autoconf.h |   17 +-
 sys/arch/hp700/include/pdc.h      |   84 ++++--
 14 files changed, 657 insertions(+), 205 deletions(-)

diffs (truncated from 1655 to 300 lines):

diff -r 9593a43e3096 -r d069a3f130ad sys/arch/hp700/dev/apic.c
--- a/sys/arch/hp700/dev/apic.c Tue Jan 04 10:40:17 2011 +0000
+++ b/sys/arch/hp700/dev/apic.c Tue Jan 04 10:42:33 2011 +0000
@@ -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
diff -r 9593a43e3096 -r d069a3f130ad sys/arch/hp700/dev/astro.c
--- a/sys/arch/hp700/dev/astro.c        Tue Jan 04 10:40:17 2011 +0000
+++ b/sys/arch/hp700/dev/astro.c        Tue Jan 04 10:42:33 2011 +0000
@@ -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. */
diff -r 9593a43e3096 -r d069a3f130ad sys/arch/hp700/dev/lasi.c
--- a/sys/arch/hp700/dev/lasi.c Tue Jan 04 10:40:17 2011 +0000
+++ b/sys/arch/hp700/dev/lasi.c Tue Jan 04 10:42:33 2011 +0000
@@ -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);
        }
 }
 
diff -r 9593a43e3096 -r d069a3f130ad sys/arch/hp700/dev/lcd.c
--- a/sys/arch/hp700/dev/lcd.c  Tue Jan 04 10:40:17 2011 +0000
+++ b/sys/arch/hp700/dev/lcd.c  Tue Jan 04 10:42:33 2011 +0000
@@ -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;
diff -r 9593a43e3096 -r d069a3f130ad sys/arch/hp700/dev/mem.c
--- a/sys/arch/hp700/dev/mem.c  Tue Jan 04 10:40:17 2011 +0000
+++ b/sys/arch/hp700/dev/mem.c  Tue Jan 04 10:42:33 2011 +0000
@@ -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);
diff -r 9593a43e3096 -r d069a3f130ad sys/arch/hp700/dev/pdc.c
--- a/sys/arch/hp700/dev/pdc.c  Tue Jan 04 10:40:17 2011 +0000
+++ b/sys/arch/hp700/dev/pdc.c  Tue Jan 04 10:42:33 2011 +0000
@@ -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,
+           tvp->tv_sec, tvp->tv_usec);
 
-       error = pdc_call((iodcio_t)pdc, 1, PDC_TOD, PDC_TOD_WRITE,
-           tod.sec, tod.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)
+{



Home | Main Index | Thread Index | Old Index