Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/tc - Minor coding modifications for VDAC register ac...



details:   https://anonhg.NetBSD.org/src/rev/7f7e1732abcb
branches:  trunk
changeset: 556547:7f7e1732abcb
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Sat Dec 20 07:10:00 2003 +0000

description:
- Minor coding modifications for VDAC register access.
- De-__P() this time.
Tested valid with 4MAXINE.

diffstat:

 sys/dev/tc/cfb.c  |  201 +++++++++++++++++++++++-----------------------
 sys/dev/tc/mfb.c  |  184 +++++++++++++++++++++---------------------
 sys/dev/tc/tfb.c  |  233 ++++++++++++++++++++++++-----------------------------
 sys/dev/tc/xcfb.c |   63 +++++++-------
 4 files changed, 330 insertions(+), 351 deletions(-)

diffs (truncated from 1154 to 300 lines):

diff -r 4119a6c2d739 -r 7f7e1732abcb sys/dev/tc/cfb.c
--- a/sys/dev/tc/cfb.c  Sat Dec 20 06:57:03 2003 +0000
+++ b/sys/dev/tc/cfb.c  Sat Dec 20 07:10:00 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cfb.c,v 1.43 2003/12/17 03:59:32 ad Exp $ */
+/* $NetBSD: cfb.c,v 1.44 2003/12/20 07:10:00 nisimura Exp $ */
 
 /*
  * Copyright (c) 1998, 1999 Tohru Nishimura.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cfb.c,v 1.43 2003/12/17 03:59:32 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cfb.c,v 1.44 2003/12/20 07:10:00 nisimura Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -84,17 +84,18 @@
  *     };
  */
 
-/* Bt459 hardware registers */
-#define        bt_lo   0
-#define        bt_hi   1
-#define        bt_reg  2
-#define        bt_cmap 3
+/* Bt459 hardware registers, memory-mapped in 32bit stride */
+#define        bt_lo   0x0
+#define        bt_hi   0x4
+#define        bt_reg  0x8
+#define        bt_cmap 0xc
 
-#define        REG(base, index)        *((u_int32_t *)(base) + (index))
-#define        SELECT(vdac, regno) do {                        \
-       REG(vdac, bt_lo) = ((regno) & 0x00ff);          \
-       REG(vdac, bt_hi) = ((regno) & 0x0f00) >> 8;     \
-       tc_wmb();                                       \
+#define        REGWRITE32(p,i,v) do {                                  \
+       *(volatile u_int32_t *)((p) + (i)) = (v); tc_wmb();     \
+    } while (0)
+#define        VDACSELECT(p,r) do {                                    \
+       REGWRITE32(p, bt_lo, 0xff & (r));                       \
+       REGWRITE32(p, bt_hi, 0x0f & ((r)>>8));                  \
    } while (0)
 
 struct hwcmap256 {
@@ -137,13 +138,13 @@
 #define        CX_BT459_OFFSET 0x200000
 #define        CX_OFFSET_IREQ  0x300000        /* Interrupt req. control */
 
-static int  cfbmatch __P((struct device *, struct cfdata *, void *));
-static void cfbattach __P((struct device *, struct device *, void *));
+static int  cfbmatch(struct device *, struct cfdata *, void *);
+static void cfbattach(struct device *, struct device *, void *);
 
 CFATTACH_DECL(cfb, sizeof(struct cfb_softc),
     cfbmatch, cfbattach, NULL, NULL);
 
-static void cfb_common_init __P((struct rasops_info *));
+static void cfb_common_init(struct rasops_info *);
 static struct rasops_info cfb_console_ri;
 static tc_addr_t cfb_consaddr;
 
@@ -162,14 +163,14 @@
        sizeof(_cfb_scrlist) / sizeof(struct wsscreen_descr *), _cfb_scrlist
 };
 
-static int     cfbioctl __P((void *, u_long, caddr_t, int, struct proc *));
-static paddr_t cfbmmap __P((void *, off_t, int));
+static int     cfbioctl(void *, u_long, caddr_t, int, struct proc *);
+static paddr_t cfbmmap(void *, off_t, int);
 
-static int     cfb_alloc_screen __P((void *, const struct wsscreen_descr *,
-                                     void **, int *, int *, long *));
-static void    cfb_free_screen __P((void *, void *));
-static int     cfb_show_screen __P((void *, void *, int,
-                                    void (*) (void *, int, int), void *));
+static int     cfb_alloc_screen(void *, const struct wsscreen_descr *,
+                                     void **, int *, int *, long *);
+static void    cfb_free_screen(void *, void *);
+static int     cfb_show_screen(void *, void *, int,
+                                    void (*) (void *, int, int), void *);
 
 static const struct wsdisplay_accessops cfb_accessops = {
        cfbioctl,
@@ -180,16 +181,16 @@
        0 /* load_font */
 };
 
-int  cfb_cnattach __P((tc_addr_t));
-static int  cfbintr __P((void *));
-static void cfbhwinit __P((caddr_t));
-static void cfb_cmap_init __P((struct cfb_softc *));
+int  cfb_cnattach(tc_addr_t);
+static int  cfbintr(void *);
+static void cfbhwinit(caddr_t);
+static void cfb_cmap_init(struct cfb_softc *);
 
-static int  get_cmap __P((struct cfb_softc *, struct wsdisplay_cmap *));
-static int  set_cmap __P((struct cfb_softc *, struct wsdisplay_cmap *));
-static int  set_cursor __P((struct cfb_softc *, struct wsdisplay_cursor *));
-static int  get_cursor __P((struct cfb_softc *, struct wsdisplay_cursor *));
-static void set_curpos __P((struct cfb_softc *, struct wsdisplay_curpos *));
+static int  get_cmap(struct cfb_softc *, struct wsdisplay_cmap *);
+static int  set_cmap(struct cfb_softc *, struct wsdisplay_cmap *);
+static int  set_cursor(struct cfb_softc *, struct wsdisplay_cursor *);
+static int  get_cursor(struct cfb_softc *, struct wsdisplay_cursor *);
+static void set_curpos(struct cfb_softc *, struct wsdisplay_curpos *);
 
 /*
  * Compose 2 bit/pixel cursor image.  Bit order will be reversed.
@@ -288,7 +289,7 @@
        tc_intr_establish(parent, ta->ta_cookie, IPL_TTY, cfbintr, sc);
 
        /* clear any pending interrupts */
-       *(u_int8_t *)((caddr_t)ri->ri_hw + CX_OFFSET_IREQ) = 0;
+       *(volatile u_int8_t *)((caddr_t)ri->ri_hw + CX_OFFSET_IREQ) = 0;
 
        waa.console = console;
        waa.scrdata = &cfb_screenlist;
@@ -501,7 +502,7 @@
        void *v;
        void *cookie;
        int waitok;
-       void (*cb) __P((void *, int, int));
+       void (*cb)(void *, int, int);
        void *cbarg;
 {
 
@@ -540,8 +541,8 @@
        vdac = base + CX_BT459_OFFSET;
        v = sc->sc_changed;
        if (v & WSDISPLAY_CURSOR_DOCUR) {
-               SELECT(vdac, BT459_IREG_CCR);
-               REG(vdac, bt_reg) = (sc->sc_curenb) ? 0xc0 : 0x00;
+               VDACSELECT(vdac, BT459_IREG_CCR);
+               REGWRITE32(vdac, bt_reg, (sc->sc_curenb) ? 0xc0 : 0x00);
        }
        if (v & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) {
                int x, y;
@@ -552,23 +553,23 @@
                x += sc->sc_cursor.cc_magic.x;
                y += sc->sc_cursor.cc_magic.y;
 
-               SELECT(vdac, BT459_IREG_CURSOR_X_LOW);
-               REG(vdac, bt_reg) = x;          tc_wmb();
-               REG(vdac, bt_reg) = x >> 8;     tc_wmb();
-               REG(vdac, bt_reg) = y;          tc_wmb();
-               REG(vdac, bt_reg) = y >> 8;     tc_wmb();
+               VDACSELECT(vdac, BT459_IREG_CURSOR_X_LOW);
+               REGWRITE32(vdac, bt_reg, x);    
+               REGWRITE32(vdac, bt_reg, x >> 8);
+               REGWRITE32(vdac, bt_reg, y);
+               REGWRITE32(vdac, bt_reg, y >> 8);
        }
        if (v & WSDISPLAY_CURSOR_DOCMAP) {
                u_int8_t *cp = sc->sc_cursor.cc_color;
 
-               SELECT(vdac, BT459_IREG_CCOLOR_2);
-               REG(vdac, bt_reg) = cp[1];      tc_wmb();
-               REG(vdac, bt_reg) = cp[3];      tc_wmb();
-               REG(vdac, bt_reg) = cp[5];      tc_wmb();
+               VDACSELECT(vdac, BT459_IREG_CCOLOR_2);
+               REGWRITE32(vdac, bt_reg, cp[1]);
+               REGWRITE32(vdac, bt_reg, cp[3]);
+               REGWRITE32(vdac, bt_reg, cp[5]);
 
-               REG(vdac, bt_reg) = cp[0];      tc_wmb();
-               REG(vdac, bt_reg) = cp[2];      tc_wmb();
-               REG(vdac, bt_reg) = cp[4];      tc_wmb();
+               REGWRITE32(vdac, bt_reg, cp[0]);
+               REGWRITE32(vdac, bt_reg, cp[2]);
+               REGWRITE32(vdac, bt_reg, cp[4]);
        }
        if (v & WSDISPLAY_CURSOR_DOSHAPE) {
                u_int8_t *ip, *mp, img, msk;
@@ -579,29 +580,29 @@
                mp = (u_int8_t *)sc->sc_cursor.cc_mask;
 
                bcnt = 0;
-               SELECT(vdac, BT459_IREG_CRAM_BASE+0);
+               VDACSELECT(vdac, BT459_IREG_CRAM_BASE+0);
                /* 64 pixel scan line is consisted with 16 byte cursor ram */
                while (bcnt < sc->sc_cursor.cc_size.y * 16) {
                        /* pad right half 32 pixel when smaller than 33 */
                        if ((bcnt & 0x8) && sc->sc_cursor.cc_size.x < 33) {
-                               REG(vdac, bt_reg) = 0; tc_wmb();
-                               REG(vdac, bt_reg) = 0; tc_wmb();
+                               REGWRITE32(vdac, bt_reg, 0);
+                               REGWRITE32(vdac, bt_reg, 0);
                        }
                        else {
                                img = *ip++;
                                msk = *mp++;
                                img &= msk;     /* cookie off image */
                                u = (msk & 0x0f) << 4 | (img & 0x0f);
-                               REG(vdac, bt_reg) = shuffle[u]; tc_wmb();
+                               REGWRITE32(vdac, bt_reg, shuffle[u]);
                                u = (msk & 0xf0) | (img & 0xf0) >> 4;
-                               REG(vdac, bt_reg) = shuffle[u]; tc_wmb();
+                               REGWRITE32(vdac, bt_reg, shuffle[u]);
                        }
                        bcnt += 2;
                }
                /* pad unoccupied scan lines */
                while (bcnt < CURSOR_MAX_SIZE * 16) {
-                       REG(vdac, bt_reg) = 0; tc_wmb();
-                       REG(vdac, bt_reg) = 0; tc_wmb();
+                       REGWRITE32(vdac, bt_reg, 0);
+                       REGWRITE32(vdac, bt_reg, 0);
                        bcnt += 2;
                }
        }
@@ -609,11 +610,11 @@
                struct hwcmap256 *cm = &sc->sc_cmap;
                int index;
 
-               SELECT(vdac, 0);
+               VDACSELECT(vdac, 0);
                for (index = 0; index < CMAP_SIZE; index++) {
-                       REG(vdac, bt_cmap) = cm->r[index];      tc_wmb();
-                       REG(vdac, bt_cmap) = cm->g[index];      tc_wmb();
-                       REG(vdac, bt_cmap) = cm->b[index];      tc_wmb();
+                       REGWRITE32(vdac, bt_cmap, cm->r[index]);
+                       REGWRITE32(vdac, bt_cmap, cm->g[index]);
+                       REGWRITE32(vdac, bt_cmap, cm->b[index]);
                }
        }
        sc->sc_changed = 0;
@@ -628,65 +629,65 @@
        const u_int8_t *p;
        int i;
 
-       SELECT(vdac, BT459_IREG_COMMAND_0);
-       REG(vdac, bt_reg) = 0x40; /* CMD0 */    tc_wmb();
-       REG(vdac, bt_reg) = 0x0;  /* CMD1 */    tc_wmb();
-       REG(vdac, bt_reg) = 0xc0; /* CMD2 */    tc_wmb();
-       REG(vdac, bt_reg) = 0xff; /* PRM */     tc_wmb();
-       REG(vdac, bt_reg) = 0;    /* 205 */     tc_wmb();
-       REG(vdac, bt_reg) = 0x0;  /* PBM */     tc_wmb();
-       REG(vdac, bt_reg) = 0;    /* 207 */     tc_wmb();
-       REG(vdac, bt_reg) = 0x0;  /* ORM */     tc_wmb();
-       REG(vdac, bt_reg) = 0x0;  /* OBM */     tc_wmb();
-       REG(vdac, bt_reg) = 0x0;  /* ILV */     tc_wmb();
-       REG(vdac, bt_reg) = 0x0;  /* TEST */    tc_wmb();
+       VDACSELECT(vdac, BT459_IREG_COMMAND_0);
+       REGWRITE32(vdac, bt_reg, 0x40); /* CMD0 */
+       REGWRITE32(vdac, bt_reg, 0x0);  /* CMD1 */
+       REGWRITE32(vdac, bt_reg, 0xc0); /* CMD2 */
+       REGWRITE32(vdac, bt_reg, 0xff); /* PRM */
+       REGWRITE32(vdac, bt_reg, 0);    /* 205 */
+       REGWRITE32(vdac, bt_reg, 0x0);  /* PBM */
+       REGWRITE32(vdac, bt_reg, 0);    /* 207 */
+       REGWRITE32(vdac, bt_reg, 0x0);  /* ORM */
+       REGWRITE32(vdac, bt_reg, 0x0);  /* OBM */
+       REGWRITE32(vdac, bt_reg, 0x0);  /* ILV */
+       REGWRITE32(vdac, bt_reg, 0x0);  /* TEST */
 
-       SELECT(vdac, BT459_IREG_CCR);
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
-       REG(vdac, bt_reg) = 0x0;        tc_wmb();
+       VDACSELECT(vdac, BT459_IREG_CCR);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
+       REGWRITE32(vdac, bt_reg, 0x0);
 
        /* build sane colormap */
-       SELECT(vdac, 0);
+       VDACSELECT(vdac, 0);
        p = rasops_cmap;
        for (i = 0; i < CMAP_SIZE; i++, p += 3) {
-               REG(vdac, bt_cmap) = p[0];      tc_wmb();
-               REG(vdac, bt_cmap) = p[1];      tc_wmb();
-               REG(vdac, bt_cmap) = p[2];      tc_wmb();
+               REGWRITE32(vdac, bt_cmap, p[0]);
+               REGWRITE32(vdac, bt_cmap, p[1]);
+               REGWRITE32(vdac, bt_cmap, p[2]);
        }



Home | Main Index | Thread Index | Old Index