summaryrefslogtreecommitdiff
path: root/sys/arch/vax/stand/boot/if_qe.c
diff options
context:
space:
mode:
authorHugh Graham <hugh@cvs.openbsd.org>2002-06-11 09:36:25 +0000
committerHugh Graham <hugh@cvs.openbsd.org>2002-06-11 09:36:25 +0000
commit10ca5e5818bb80e596db244327a2663b6703bb18 (patch)
treec7ac330b34d73ea4e0c78d17a9eed0a3b6df63aa /sys/arch/vax/stand/boot/if_qe.c
parent180b34af9885b092bee0f67c5b2ac8577d972cfe (diff)
New boot code, mostly from ragge's work in NetBSD.
Some header syncing and a couple network drivers came along for the ride. Assembly files have been renamed from .s to .S to facilitate diffs. Kernel is backwards compat - with manual interaction. OpenBSD features have been preserved.
Diffstat (limited to 'sys/arch/vax/stand/boot/if_qe.c')
-rw-r--r--sys/arch/vax/stand/boot/if_qe.c177
1 files changed, 80 insertions, 97 deletions
diff --git a/sys/arch/vax/stand/boot/if_qe.c b/sys/arch/vax/stand/boot/if_qe.c
index a1c1c248907..36a6b30d376 100644
--- a/sys/arch/vax/stand/boot/if_qe.c
+++ b/sys/arch/vax/stand/boot/if_qe.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_qe.c,v 1.2 2002/03/14 03:16:02 millert Exp $ */
-/* $NetBSD: if_qe.c,v 1.2 1999/06/30 18:19:26 ragge Exp $ */
+/* $OpenBSD: if_qe.c,v 1.3 2002/06/11 09:36:23 hugh Exp $ */
+/* $NetBSD: if_qe.c,v 1.3 2000/05/20 13:30:03 ragge Exp $ */
/*
* Copyright (c) 1998 Roar Thronęs. All rights reserved.
@@ -39,116 +39,103 @@
#include <netinet/in_systm.h>
#include <lib/libsa/netif.h>
+#include <lib/libsa/stand.h>
#include <arch/vax/if/if_qereg.h>
-int qe_probe(), qe_match(), qe_get(), qe_put();
-void qe_init(), qe_end();
+#include "../include/rpb.h"
-struct netif_stats qe_stats;
+#include "vaxstand.h"
-struct netif_dif qe_ifs[] = {
-/* dif_unit dif_nsel dif_stats dif_private */
-{ 0, 1, &qe_stats, },
-};
-
-struct netif_stats qe_stats;
+static int qe_get(struct iodesc *desc, void *pkt, size_t, time_t timeout);
+static int qe_put(struct iodesc *desc, void *pkt, size_t);
+static void qe_init(u_char *eaddr);
struct netif_driver qe_driver = {
- "qe", qe_match, qe_probe, qe_init, qe_get, qe_put, qe_end, qe_ifs, 1,
+ 0, 0, 0, 0, qe_get, qe_put,
};
-#define PG_V 0x80000000
-#define QBAMAP 0x20088000
+#define NRCV 1 /* Receive descriptors */
+#define NXMT 1 /* Transmit descriptors */
-#define NRCV 1 /* Receive descriptors */
-#define NXMT 1 /* Transmit descriptors */
+#define QE_INTS (QE_RCV_INT | QE_XMIT_INT)
+#define MAXPACKETSIZE 0x800 /* Because of (buggy) DEQNA */
-#define QE_INTS (QE_RCV_INT | QE_XMIT_INT)
-#define MAXPACKETSIZE 0x800 /* Because of (buggy) DEQNA */
-
-struct qe_softc {
- struct qe_ring rring[NRCV+2]; /* Receive ring descriptors */
- struct qe_ring tring[NXMT+2]; /* Xmit ring descriptors */
- u_char setup_pkt[16][8]; /* Setup packet */
+static struct qe_softc {
+ struct qe_ring rring[NRCV+2]; /* Receive ring descriptors */
+ struct qe_ring tring[NXMT+2]; /* Xmit ring descriptors */
+ u_char setup_pkt[16][8]; /* Setup packet */
char qein[2048], qeout[2048];/* Packet buffers */
-};
+} qe_softc;
-static volatile struct qe_softc *sc;
+static struct qe_softc *sc = &qe_softc;
static int addr;
#define QE_WCSR(csr, val) \
- (*((volatile u_short *)(addr + (csr))) = (val))
+ (*((volatile u_short *)(addr + (csr))) = (val))
#define QE_RCSR(csr) \
- *((volatile u_short *)(addr + (csr)))
-#define DELAY(x) {volatile int i = x;while (--i);}
-#define LOWORD(x) ((int)(x) & 0xffff)
-#define HIWORD(x) (((int)(x) >> 16) & 0x3f)
+ *((volatile u_short *)(addr + (csr)))
+#define DELAY(x) {volatile int i = x;while (--i);}
+#define LOWORD(x) ((int)(x) & 0xffff)
+#define HIWORD(x) (((int)(x) >> 16) & 0x3f)
+#define qereg(x) ((x) & 017777)
int
-qe_match(nif, machdep_hint)
- struct netif *nif;
- void *machdep_hint;
-{
- return strcmp(machdep_hint, "qe") == 0;
-}
+qeopen(struct open_file *f, int adapt, int ctlr, int unit, int part) {
+ u_char eaddr[6];
+
+ if (askname == 0)
+ addr = bootrpb.csrphy; /* Autoboot; use RPB instead */
+ else {
+ addr = 0x20000000;
+ if (unit == 0)
+ addr += qereg(0774440); /* XQA0 */
+ else if (unit == 1)
+ addr += qereg(0174460); /* XQB0 */
+ else
+ return ECTLR;
+ }
-int
-qe_probe(nif, machdep_hint)
- struct netif *nif;
- void *machdep_hint;
-{
+ qe_init(eaddr);
+
+ net_devinit(f, &qe_driver, eaddr);
return 0;
}
void
-qe_init(desc, machdep_hint)
- struct iodesc *desc;
- void *machdep_hint;
+qe_init(u_char *eaddr)
{
-
int i,j;
- u_int *qm=(u_int *) QBAMAP;
-
- sc = (void *)alloc(sizeof(struct qe_softc));
-
- bzero(sc,sizeof(struct qe_softc));
-
- for(i = 0; i < 8192; i++)
- qm[i] = PG_V | i;
-
- /* XXX hardcoded addr */
- addr = (0x20000000 + (0774440 & 017777));
QE_WCSR(QE_CSR_CSR, QE_RESET);
QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RESET);
- for (i = 0; i < 6; i++) {
- sc->setup_pkt[i][1] = QE_RCSR(i * 2);
- sc->setup_pkt[i+8][1] = QE_RCSR(i * 2);
+ for (i = 0; i < 6; i++) {
+ sc->setup_pkt[i][1] = QE_RCSR(i * 2);
+ sc->setup_pkt[i+8][1] = QE_RCSR(i * 2);
sc->setup_pkt[i][2] = 0xff;
- sc->setup_pkt[i+8][2] = QE_RCSR(i * 2);
+ sc->setup_pkt[i+8][2] = QE_RCSR(i * 2);
for (j=3; j < 8; j++) {
- sc->setup_pkt[i][j] = QE_RCSR(i * 2);
- sc->setup_pkt[i+8][j] = QE_RCSR(i * 2);
+ sc->setup_pkt[i][j] = QE_RCSR(i * 2);
+ sc->setup_pkt[i+8][j] = QE_RCSR(i * 2);
}
- desc->myea[i] = QE_RCSR(i * 2);
+ eaddr[i] = QE_RCSR(i * 2);
}
bzero((caddr_t)sc->rring, sizeof(struct qe_ring));
- sc->rring->qe_buf_len = -64;
- sc->rring->qe_addr_lo = (short)((int)sc->setup_pkt);
- sc->rring->qe_addr_hi = (short)((int)sc->setup_pkt >> 16);
+ sc->rring->qe_buf_len = -64;
+ sc->rring->qe_addr_lo = (short)((int)sc->setup_pkt);
+ sc->rring->qe_addr_hi = (short)((int)sc->setup_pkt >> 16);
bzero((caddr_t)sc->tring, sizeof(struct qe_ring));
- sc->tring->qe_buf_len = -64;
- sc->tring->qe_addr_lo = (short)((int)sc->setup_pkt);
- sc->tring->qe_addr_hi = (short)((int)sc->setup_pkt >> 16);
+ sc->tring->qe_buf_len = -64;
+ sc->tring->qe_addr_lo = (short)((int)sc->setup_pkt);
+ sc->tring->qe_addr_hi = (short)((int)sc->setup_pkt >> 16);
- sc->rring[0].qe_flag = sc->rring[0].qe_status1 = QE_NOTYET;
+ sc->rring[0].qe_flag = sc->rring[0].qe_status1 = QE_NOTYET;
sc->rring->qe_addr_hi |= QE_VALID;
- sc->tring[0].qe_flag = sc->tring[0].qe_status1 = QE_NOTYET;
+ sc->tring[0].qe_flag = sc->tring[0].qe_status1 = QE_NOTYET;
sc->tring->qe_addr_hi |= QE_VALID | QE_SETUP | QE_EOMSG;
QE_WCSR(QE_CSR_CSR, QE_XMIT_INT | QE_RCV_INT);
@@ -164,8 +151,8 @@ qe_init(desc, machdep_hint)
QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~(QE_INT_ENABLE|QE_ELOOP));
QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) | QE_ILOOP);
- sc->rring[0].qe_addr_lo = (short)((int)sc->qein & 0xffff);
- sc->rring[0].qe_addr_hi = (short)((int)sc->qein >> 16);
+ sc->rring[0].qe_addr_lo = (short)((int)sc->qein & 0xffff);
+ sc->rring[0].qe_addr_hi = (short)((int)sc->qein >> 16);
sc->rring[0].qe_buf_len=-MAXPACKETSIZE/2;
sc->rring[0].qe_addr_hi |= QE_VALID;
sc->rring[0].qe_flag=sc->rring[0].qe_status1=QE_NOTYET;
@@ -176,8 +163,8 @@ qe_init(desc, machdep_hint)
sc->rring[1].qe_flag=sc->rring[1].qe_status1=QE_NOTYET;
sc->rring[1].qe_status2=1;
- sc->tring[0].qe_addr_lo = (short)((int)sc->qeout & 0xffff);
- sc->tring[0].qe_addr_hi = (short)((int)sc->qeout >> 16);
+ sc->tring[0].qe_addr_lo = (short)((int)sc->qeout & 0xffff);
+ sc->tring[0].qe_addr_hi = (short)((int)sc->qeout >> 16);
sc->tring[0].qe_buf_len=0;
sc->tring[0].qe_flag=sc->tring[0].qe_status1=QE_NOTYET;
sc->tring[0].qe_addr_hi |= QE_EOMSG|QE_VALID;
@@ -192,12 +179,7 @@ qe_init(desc, machdep_hint)
}
int
-qe_get(desc, pkt, maxlen, timeout)
- struct iodesc *desc;
- void *pkt;
- int maxlen;
- time_t timeout;
-{
+qe_get(struct iodesc *desc, void *pkt, size_t maxlen, time_t timeout) {
int len, j;
retry:
@@ -215,10 +197,10 @@ retry:
if (sc->rring[0].qe_status1 & 0xc000)
goto fail;
- if (len == 0)
+ if (len == 0)
goto retry;
- bcopy((void *)sc->qein,pkt,len);
+ bcopy((void*)sc->qein,pkt,len);
end:
@@ -236,17 +218,13 @@ fail: len = -1;
}
int
-qe_put(desc, pkt, len)
- struct iodesc *desc;
- void *pkt;
- int len;
-{
+qe_put(struct iodesc *desc, void *pkt, size_t len) {
int j;
- bcopy(pkt,sc->qeout,len);
- sc->tring[0].qe_buf_len=-len/2;
- sc->tring[0].qe_flag=sc->tring[0].qe_status1=QE_NOTYET;
- sc->tring[1].qe_flag=sc->tring[1].qe_status1=QE_NOTYET;
+ bcopy(pkt, (char *)sc->qeout, len);
+ sc->tring[0].qe_buf_len=-len/2;
+ sc->tring[0].qe_flag=sc->tring[0].qe_status1=QE_NOTYET;
+ sc->tring[1].qe_flag=sc->tring[1].qe_status1=QE_NOTYET;
QE_WCSR(QE_CSR_XMTL, LOWORD(sc->tring));
QE_WCSR(QE_CSR_XMTH, HIWORD(sc->tring));
@@ -255,22 +233,27 @@ qe_put(desc, pkt, len)
;
if ((QE_RCSR(QE_CSR_CSR) & QE_XMIT_INT) == 0) {
- qe_init(desc,0);
+ char eaddr[6];
+
+ qe_init(eaddr);
return -1;
}
QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RCV_INT);
if (sc->tring[0].qe_status1 & 0xc000) {
- qe_init(desc,0);
+ char eaddr[6];
+
+ qe_init(eaddr);
return -1;
}
return len;
}
-void
-qe_end(nif)
- struct netif *nif;
+int
+qeclose(struct open_file *nif)
{
QE_WCSR(QE_CSR_CSR, QE_RESET);
QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RESET);
+
+ return 0;
}