Module Name:    src
Committed By:   tsutsui
Date:           Fri Mar 19 15:59:22 UTC 2010

Modified Files:
        src/sys/dev/ic: we.c wereg.h

Log Message:
Replace some magic numbers with macro. Tested on SMC_TT on atari.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ic/we.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/wereg.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/dev/ic/we.c
diff -u src/sys/dev/ic/we.c:1.16 src/sys/dev/ic/we.c:1.17
--- src/sys/dev/ic/we.c:1.16	Fri Mar 19 14:57:52 2010
+++ src/sys/dev/ic/we.c	Fri Mar 19 15:59:22 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: we.c,v 1.16 2010/03/19 14:57:52 tsutsui Exp $	*/
+/*	$NetBSD: we.c,v 1.17 2010/03/19 15:59:22 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: we.c,v 1.16 2010/03/19 14:57:52 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: we.c,v 1.17 2010/03/19 15:59:22 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -190,21 +190,23 @@
 	 * Set address and enable interface shared memory.
 	 */
 	if (sc->is790) {
-		/* XXX MAGIC CONSTANTS XXX */
-		x = bus_space_read_1(wsc->sc_asict, wsc->sc_asich, 0x04);
-		bus_space_write_1(wsc->sc_asict, wsc->sc_asich, 0x04, x | 0x80);
-		bus_space_write_1(wsc->sc_asict, wsc->sc_asich, 0x0b,
-		    ((wsc->sc_maddr >> 13) & 0x0f) |
-		    ((wsc->sc_maddr >> 11) & 0x40) |
-		    (bus_space_read_1(wsc->sc_asict, wsc->sc_asich, 0x0b) &
-		     0xb0));
-		bus_space_write_1(wsc->sc_asict, wsc->sc_asich, 0x04, x);
+		x = bus_space_read_1(wsc->sc_asict, wsc->sc_asich, WE790_HWR);
+		bus_space_write_1(wsc->sc_asict, wsc->sc_asich,
+		    WE790_HWR, x | WE790_HWR_SWH);
+		bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE790_RAR,
+		    ((wsc->sc_maddr >> WE790_RAR_OFF_SHIFT) & WE790_RAR_OFF) |
+		    ((wsc->sc_maddr & (1 << WE790_RAR_BASE_SHIFT)) != 0 ?
+		     WE790_RAR_BASE1 : WE790_RAR_BASE0) |
+		    (bus_space_read_1(wsc->sc_asict, wsc->sc_asich, WE790_RAR) &
+		     ~(WE790_RAR_OFF | WE790_RAR_BASE)));
+		bus_space_write_1(wsc->sc_asict, wsc->sc_asich, WE790_HWR, x);
 		wsc->sc_msr_proto = 0x00;
 		sc->cr_proto = 0x00;
 	} else {
 #ifdef TOSH_ETHER
 		if (wsc->sc_type == WE_TYPE_TOSHIBA1 ||
 		    wsc->sc_type == WE_TYPE_TOSHIBA4) {
+			/* XXX MAGIC CONSTANTS XXX */
 			bus_space_write_1(wsc->sc_asict, wsc->sc_asich,
 			    WE_MSR + 1,
 			    ((wsc->sc_maddr >> 8) & 0xe0) | 0x04);

Index: src/sys/dev/ic/wereg.h
diff -u src/sys/dev/ic/wereg.h:1.2 src/sys/dev/ic/wereg.h:1.3
--- src/sys/dev/ic/wereg.h:1.2	Wed Jul  4 11:14:10 2001
+++ src/sys/dev/ic/wereg.h	Fri Mar 19 15:59:22 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: wereg.h,v 1.2 2001/07/04 11:14:10 jdolecek Exp $	*/
+/*	$NetBSD: wereg.h,v 1.3 2010/03/19 15:59:22 tsutsui Exp $	*/
 
 /*
  * National Semiconductor DS8390 NIC register definitions.
@@ -135,10 +135,21 @@
 
 #define WE790_RAR	0x0b
 
+#define WE790_RAR_OFF	0x0f	/* memory address offset */
+#define WE790_RAR_SZ	0x30	/* mask of memory buffer size */
 #define WE790_RAR_SZ8	0x00	/* 8k memory buffer */
 #define WE790_RAR_SZ16	0x10	/* 16k memory buffer */
 #define WE790_RAR_SZ32	0x20	/* 32k memory buffer */
 #define WE790_RAR_SZ64	0x30	/* 64k memory buffer */
+#define WE790_RAR_BASE	0x40	/* mask of memory base address */
+#define WE790_RAR_BASE0	0x00	/* base is 0x0C0000 */
+#define WE790_RAR_BASE1	0x40	/* base is 0x0E0000 */
+#if 0
+#define WE790_RAR_BASE2	0x80	/* base is 0xFC0000 */
+#define WE790_RAR_BASE3	0xc0	/* base is 0xFE0000 */
+#endif
+#define WE790_RAR_BASE_SHIFT	17	/* base is switched by A17 */
+#define WE790_RAR_OFF_SHIFT	13	/* offset is specified by A16-A13 */
 
 /*
  * General Control Register (GCR)

Reply via email to