Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/tc - Use volatile designations for memory writes to ...
details: https://anonhg.NetBSD.org/src/rev/526fa288bee9
branches: trunk
changeset: 556545:526fa288bee9
user: nisimura <nisimura%NetBSD.org@localhost>
date: Sat Dec 20 06:41:14 2003 +0000
description:
- Use volatile designations for memory writes to prevent compiler
change fallouts.
- De-__P() this time.
Tested valid with DEC3000/300 and 4MAXINE.
diffstat:
sys/dev/tc/sfb.c | 320 ++++++++++++++++++++++++++++--------------------------
1 files changed, 164 insertions(+), 156 deletions(-)
diffs (truncated from 566 to 300 lines):
diff -r b5558f7ec5a5 -r 526fa288bee9 sys/dev/tc/sfb.c
--- a/sys/dev/tc/sfb.c Sat Dec 20 06:26:47 2003 +0000
+++ b/sys/dev/tc/sfb.c Sat Dec 20 06:41:14 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sfb.c,v 1.62 2003/12/17 03:59:33 ad Exp $ */
+/* $NetBSD: sfb.c,v 1.63 2003/12/20 06:41:14 nisimura Exp $ */
/*
* Copyright (c) 1998, 1999 Tohru Nishimura. All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sfb.c,v 1.62 2003/12/17 03:59:33 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sfb.c,v 1.63 2003/12/20 06:41:14 nisimura Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -85,17 +85,25 @@
* };
*/
-/* 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 SFBWRITE32(p,i,v) do { \
+ *(volatile u_int32_t *)((p) + (i)) = (v); \
+ } while (0)
+#define MEMWRITE32(p,v) do { \
+ *(volatile u_int32_t *)(p) = (v); \
+ } while (0)
+
+#define VDACSELECT(p,r) do { \
+ REGWRITE32(p, bt_lo, 0xff & (r)); \
+ REGWRITE32(p, bt_hi, 0x0f & ((r)>>8)); \
} while (0)
struct hwcmap256 {
@@ -133,23 +141,23 @@
#define HX_MAGIC_X 368
#define HX_MAGIC_Y 38
-static int sfbmatch __P((struct device *, struct cfdata *, void *));
-static void sfbattach __P((struct device *, struct device *, void *));
+static int sfbmatch(struct device *, struct cfdata *, void *);
+static void sfbattach(struct device *, struct device *, void *);
CFATTACH_DECL(sfb, sizeof(struct sfb_softc),
sfbmatch, sfbattach, NULL, NULL);
-static void sfb_common_init __P((struct rasops_info *));
+static void sfb_common_init(struct rasops_info *);
static struct rasops_info sfb_console_ri;
static tc_addr_t sfb_consaddr;
-static void sfb_putchar __P((void *, int, int, u_int, long));
-static void sfb_erasecols __P((void *, int, int, int, long));
-static void sfb_eraserows __P((void *, int, int, long));
-static void sfb_copyrows __P((void *, int, int, int));
-static void sfb_do_cursor __P((struct rasops_info *));
+static void sfb_putchar(void *, int, int, u_int, long);
+static void sfb_erasecols(void *, int, int, int, long);
+static void sfb_eraserows(void *, int, int, long);
+static void sfb_copyrows(void *, int, int, int);
+static void sfb_do_cursor(struct rasops_info *);
#if 0
-static void sfb_copycols __P((void *, int, int, int, int));
+static void sfb_copycols(void *, int, int, int, int);
#endif
static struct wsscreen_descr sfb_stdscreen = {
@@ -167,14 +175,14 @@
sizeof(_sfb_scrlist) / sizeof(struct wsscreen_descr *), _sfb_scrlist
};
-static int sfbioctl __P((void *, u_long, caddr_t, int, struct proc *));
-static paddr_t sfbmmap __P((void *, off_t, int));
+static int sfbioctl(void *, u_long, caddr_t, int, struct proc *);
+static paddr_t sfbmmap(void *, off_t, int);
-static int sfb_alloc_screen __P((void *, const struct wsscreen_descr *,
- void **, int *, int *, long *));
-static void sfb_free_screen __P((void *, void *));
-static int sfb_show_screen __P((void *, void *, int,
- void (*) (void *, int, int), void *));
+static int sfb_alloc_screen(void *, const struct wsscreen_descr *,
+ void **, int *, int *, long *);
+static void sfb_free_screen(void *, void *);
+static int sfb_show_screen(void *, void *, int,
+ void (*) (void *, int, int), void *);
static const struct wsdisplay_accessops sfb_accessops = {
sfbioctl,
@@ -185,17 +193,17 @@
0 /* load_font */
};
-int sfb_cnattach __P((tc_addr_t));
-static int sfbintr __P((void *));
-static void sfbhwinit __P((caddr_t));
-static void sfb_cmap_init __P((struct sfb_softc *));
-static void sfb_screenblank __P((struct sfb_softc *, int));
+int sfb_cnattach(tc_addr_t);
+static int sfbintr(void *);
+static void sfbhwinit(caddr_t);
+static void sfb_cmap_init(struct sfb_softc *);
+static void sfb_screenblank(struct sfb_softc *, int);
-static int get_cmap __P((struct sfb_softc *, struct wsdisplay_cmap *));
-static int set_cmap __P((struct sfb_softc *, struct wsdisplay_cmap *));
-static int set_cursor __P((struct sfb_softc *, struct wsdisplay_cursor *));
-static int get_cursor __P((struct sfb_softc *, struct wsdisplay_cursor *));
-static void set_curpos __P((struct sfb_softc *, struct wsdisplay_curpos *));
+static int get_cmap(struct sfb_softc *, struct wsdisplay_cmap *);
+static int set_cmap(struct sfb_softc *, struct wsdisplay_cmap *);
+static int set_cursor(struct sfb_softc *, struct wsdisplay_cursor *);
+static int get_cursor(struct sfb_softc *, struct wsdisplay_cursor *);
+static void set_curpos(struct sfb_softc *, struct wsdisplay_curpos *);
/*
* Compose 2 bit/pixel cursor image. Bit order will be reversed.
@@ -294,8 +302,9 @@
tc_intr_establish(parent, ta->ta_cookie, IPL_TTY, sfbintr, sc);
asic = (caddr_t)ri->ri_hw + SFB_ASIC_OFFSET;
- *(u_int32_t *)(asic + SFB_ASIC_CLEAR_INTR) = 0;
- *(u_int32_t *)(asic + SFB_ASIC_ENABLE_INTR) = 1;
+
+ SFBWRITE32(asic, SFB_ASIC_CLEAR_INTR, 0);
+ SFBWRITE32(asic, SFB_ASIC_ENABLE_INTR, 1);
waa.console = console;
waa.scrdata = &sfb_screenlist;
@@ -334,12 +343,13 @@
hsetup = *(u_int32_t *)(asic + SFB_ASIC_VIDEO_HSETUP);
vsetup = *(u_int32_t *)(asic + SFB_ASIC_VIDEO_VSETUP);
- *(u_int32_t *)(asic + SFB_ASIC_VIDEO_BASE) = vbase = 1;
- *(u_int32_t *)(asic + SFB_ASIC_PLANEMASK) = ~0;
- *(u_int32_t *)(asic + SFB_ASIC_PIXELMASK) = ~0;
- *(u_int32_t *)(asic + SFB_ASIC_MODE) = 0; /* MODE_SIMPLE */
- *(u_int32_t *)(asic + SFB_ASIC_ROP) = 3; /* ROP_COPY */
- *(u_int32_t *)(asic + 0x180000) = 0; /* Bt459 reset */
+ vbase = 1;
+ SFBWRITE32(asic, SFB_ASIC_VIDEO_BASE, vbase);
+ SFBWRITE32(asic, SFB_ASIC_PLANEMASK, ~0);
+ SFBWRITE32(asic, SFB_ASIC_PIXELMASK, ~0);
+ SFBWRITE32(asic, SFB_ASIC_MODE, 0); /* MODE_SIMPLE */
+ SFBWRITE32(asic, SFB_ASIC_ROP, 3); /* ROP_COPY */
+ SFBWRITE32(asic, 0x180000, 0); /* Bt459 reset */
/* initialize colormap and cursor hardware */
sfbhwinit(base);
@@ -538,7 +548,7 @@
void *v;
void *cookie;
int waitok;
- void (*cb) __P((void *, int, int));
+ void (*cb)(void *, int, int);
void *cbarg;
{
@@ -571,8 +581,8 @@
base = (caddr_t)sc->sc_ri->ri_hw;
asic = base + SFB_ASIC_OFFSET;
- *(u_int32_t *)(asic + SFB_ASIC_CLEAR_INTR) = 0;
- /* *(u_int32_t *)(asic + SFB_ASIC_ENABLE_INTR) = 1; */
+ SFBWRITE32(asic, SFB_ASIC_CLEAR_INTR, 0);
+ /* SFBWRITE32(asic, SFB_ASIC_ENABLE_INTR, 1); */
if (sc->sc_changed == 0)
goto done;
@@ -580,8 +590,11 @@
vdac = base + SFB_RAMDAC_OFFSET;
v = sc->sc_changed;
if (v & WSDISPLAY_CURSOR_DOCUR) {
- SELECT(vdac, BT459_IREG_CCR);
- REG(vdac, bt_reg) = (sc->sc_curenb) ? 0xc0 : 0x00;
+ int onoff;
+
+ onoff = (sc->sc_curenb) ? 0xc0 : 0x00;
+ VDACSELECT(vdac, BT459_IREG_CCR);
+ REGWRITE32(vdac, bt_reg, onoff);
}
if (v & (WSDISPLAY_CURSOR_DOPOS | WSDISPLAY_CURSOR_DOHOT)) {
int x, y;
@@ -591,23 +604,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;
@@ -618,29 +631,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;
}
}
@@ -648,11 +661,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;
@@ -668,65 +681,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();
Home |
Main Index |
Thread Index |
Old Index