summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/man/man4/kue.49
-rw-r--r--sys/dev/microcode/kue/Makefile27
-rw-r--r--sys/dev/microcode/kue/build.c58
-rw-r--r--sys/dev/microcode/kue/kue-license31
-rw-r--r--sys/dev/microcode/kue/kue_fw.h14
-rw-r--r--sys/dev/usb/files.usb4
-rw-r--r--sys/dev/usb/if_kue.c37
-rw-r--r--sys/dev/usb/if_kuevar.h42
8 files changed, 202 insertions, 20 deletions
diff --git a/share/man/man4/kue.4 b/share/man/man4/kue.4
index 66fb990743a..e51db17cfc1 100644
--- a/share/man/man4/kue.4
+++ b/share/man/man4/kue.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: kue.4,v 1.10 2004/10/16 01:22:52 jsg Exp $
+.\" $OpenBSD: kue.4,v 1.11 2004/11/22 18:49:03 deraadt Exp $
.\" $NetBSD: kue.4,v 1.5 2000/03/20 01:34:22 augustss Exp $
.\"
.\" Copyright (c) 1997, 1998, 1999, 2000
@@ -95,6 +95,13 @@ before a timeout expired.
.It "kue%d: no memory for rx list"
The driver failed to allocate an mbuf for the receiver ring.
.El
+.Sh FILES
+The driver need to load a firmware files which is loaded on
+demand when the device is attached.
+.Pp
+.Bl -tag -width Ds -offset indent -compact
+.It Pa /etc/firmware/kue
+.El
.Sh SEE ALSO
.Xr arp 4 ,
.Xr intro 4 ,
diff --git a/sys/dev/microcode/kue/Makefile b/sys/dev/microcode/kue/Makefile
new file mode 100644
index 00000000000..8c6172f78e1
--- /dev/null
+++ b/sys/dev/microcode/kue/Makefile
@@ -0,0 +1,27 @@
+# $OpenBSD: Makefile,v 1.1 2004/11/22 18:49:05 deraadt Exp $
+
+NOPROG=
+NOMAN=
+
+# USB capable systems only
+.if (${MACHINE} == "i386") || (${MACHINE} == "amd64") || \
+ (${MACHINE} == "alpha") || (${MACHINE} == "sparc64") || \
+ (${MACHINE_ARCH} == "powerpc") || (${MACHINE} == "cats") || \
+ (${MACHINE} == "hppa") || (${MACHINE} == "sgi")
+
+FIRM= kue
+
+CLEANFILES+= ${FIRM} build
+
+all: build
+ ${.OBJDIR}/build
+
+afterinstall:
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
+ ${FIRM} ${DESTDIR}/etc/firmware
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
+ ${.CURDIR}/kue-license ${DESTDIR}/etc/firmware
+.endif
+
+.include <bsd.prog.mk>
+
diff --git a/sys/dev/microcode/kue/build.c b/sys/dev/microcode/kue/build.c
new file mode 100644
index 00000000000..d25a925d29c
--- /dev/null
+++ b/sys/dev/microcode/kue/build.c
@@ -0,0 +1,58 @@
+/* $OpenBSD: build.c,v 1.1 2004/11/22 18:49:05 deraadt Exp $ */
+
+/*
+ * Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <sys/types.h>
+#include <dev/usb/if_kuevar.h>
+#include <fcntl.h>
+
+#include "kue_fw.h"
+
+#define FILENAME "kue"
+
+int
+main(int argc, char *argv[])
+{
+ struct kue_firmware kfproto, *kf;
+ int len, fd, i;
+
+ len = sizeof(*kf) - sizeof(kfproto.data) +
+ sizeof(kue_code_seg) + sizeof(kue_fix_seg) +
+ sizeof(kue_trig_seg);
+
+ kf = (struct kue_firmware *)malloc(len);
+ bzero(kf, len);
+
+ kf->codeseglen = sizeof(kue_code_seg);
+ kf->fixseglen = sizeof(kue_fix_seg);
+ kf->trigseglen = sizeof(kue_trig_seg);
+
+ bcopy(kue_code_seg, &kf->data[0], kf->codeseglen);
+ bcopy(kue_fix_seg, &kf->data[kf->codeseglen], kf->fixseglen);
+ bcopy(kue_trig_seg, &kf->data[kf->codeseglen + kf->fixseglen],
+ kf->trigseglen);
+
+ printf("creating %s length %d [%d+%d+%d]\n",
+ FILENAME, len, kf->codeseglen, kf->fixseglen, kf->trigseglen);
+ fd = open(FILENAME, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ if (fd == -1)
+ err(1, FILENAME);
+
+ write(fd, kf, len);
+ free(kf);
+ close(fd);
+ return 0;
+}
diff --git a/sys/dev/microcode/kue/kue-license b/sys/dev/microcode/kue/kue-license
new file mode 100644
index 00000000000..bddbb5486b2
--- /dev/null
+++ b/sys/dev/microcode/kue/kue-license
@@ -0,0 +1,31 @@
+ * Copyright (c) 1997, 1998, 1999, 2000
+ * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Bill Paul.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+
+This license applies to the kue firmware.
diff --git a/sys/dev/microcode/kue/kue_fw.h b/sys/dev/microcode/kue/kue_fw.h
index 80189aa260c..2eacb752584 100644
--- a/sys/dev/microcode/kue/kue_fw.h
+++ b/sys/dev/microcode/kue/kue_fw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: kue_fw.h,v 1.1 2001/12/17 01:39:08 deraadt Exp $ */
+/* $OpenBSD: kue_fw.h,v 1.2 2004/11/22 18:49:05 deraadt Exp $ */
/* $NetBSD: kue_fw.h,v 1.3 2001/01/19 08:54:21 jdolecek Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -55,6 +55,9 @@
* work in the driver.
*/
+#if 0
+
+
/* QT controller data block types. */
/* Write data into specific memory location. */
#define KUE_QTBTYPE_WRITE_DATA 0x00
@@ -86,8 +89,11 @@
#define KUE_QTINTR_TRIGGER_CODE 0x3B
#define KUE_QTINTR_LOAD_CODE_HIGH 0x9C
+#endif /* 0 */
+
+
/* Firmware code segment */
-Static const unsigned char kue_code_seg[] =
+const unsigned char kue_code_seg[] =
{
/******************************************/
/* NOTE: B6/C3 is data header signature */
@@ -579,7 +585,7 @@ Static const unsigned char kue_code_seg[] =
};
/* Firmware fixup (data?) segment */
-Static const unsigned char kue_fix_seg[] =
+const unsigned char kue_fix_seg[] =
{
/******************************************/
/* NOTE: B6/C3 is data header signature */
@@ -682,6 +688,6 @@ Static const unsigned char kue_fix_seg[] =
/* Fixup command. */
#define KUE_TRIGCMD_OFFSET 5
-Static const unsigned char kue_trig_seg[] = {
+const unsigned char kue_trig_seg[] = {
0xb6, 0xc3, 0x01, 0x00, 0x06, 0x64, 0x00, 0x00
};
diff --git a/sys/dev/usb/files.usb b/sys/dev/usb/files.usb
index 150223f59e9..30f43564f22 100644
--- a/sys/dev/usb/files.usb
+++ b/sys/dev/usb/files.usb
@@ -1,4 +1,4 @@
-# $OpenBSD: files.usb,v 1.40 2004/11/17 14:13:47 deraadt Exp $
+# $OpenBSD: files.usb,v 1.41 2004/11/22 18:49:05 deraadt Exp $
# $NetBSD: files.usb,v 1.16 2000/02/14 20:29:54 augustss Exp $
#
# Config file and device description for machine-independent USB code.
@@ -136,7 +136,7 @@ attach cue at uhub
file dev/usb/if_cue.c cue
# Kawasaki LSI KL5KUSB101B
-device kue: ether, ifnet, ifmedia
+device kue: ether, ifnet, ifmedia, firmload
attach kue at uhub
file dev/usb/if_kue.c kue
diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c
index 7aea22ebdc5..38ea5483930 100644
--- a/sys/dev/usb/if_kue.c
+++ b/sys/dev/usb/if_kue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_kue.c,v 1.29 2004/11/10 10:14:48 grange Exp $ */
+/* $OpenBSD: if_kue.c,v 1.30 2004/11/22 18:49:05 deraadt Exp $ */
/* $NetBSD: if_kue.c,v 1.50 2002/07/16 22:00:31 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -132,12 +132,7 @@
#include <dev/usb/usbdevs.h>
#include <dev/usb/if_kuereg.h>
-
-#if defined(__OpenBSD__)
-#include <dev/microcode/kue/kue_fw.h>
-#else
-#include <dev/usb/kue_fw.h>
-#endif
+#include <dev/usb/if_kuevar.h>
#ifdef KUE_DEBUG
#define DPRINTF(x) do { if (kuedebug) logprintf x; } while (0)
@@ -253,6 +248,9 @@ kue_load_fw(struct kue_softc *sc)
{
usb_device_descriptor_t dd;
usbd_status err;
+ struct kue_firmware *fw;
+ u_char *buf;
+ size_t buflen;
DPRINTFN(1,("%s: %s: enter\n", USBDEVNAME(sc->kue_dev), __func__));
@@ -278,6 +276,14 @@ kue_load_fw(struct kue_softc *sc)
return (0);
}
+ err = loadfirmware("kue", &buf, &buflen);
+ if (err) {
+ printf("%s: failed loadfirmware of file %s: errno %d\n",
+ USBDEVNAME(sc->kue_dev), "kue", err);
+ return (err);
+ }
+ fw = (struct kue_firmware *)buf;
+
printf("%s: cold boot, downloading firmware\n",
USBDEVNAME(sc->kue_dev));
@@ -285,34 +291,39 @@ kue_load_fw(struct kue_softc *sc)
DPRINTFN(1,("%s: kue_load_fw: download code_seg\n",
USBDEVNAME(sc->kue_dev)));
err = kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SEND_SCAN,
- 0, (void *)kue_code_seg, sizeof(kue_code_seg));
+ 0, (void *)&fw->data[0], fw->codeseglen);
if (err) {
printf("%s: failed to load code segment: %s\n",
USBDEVNAME(sc->kue_dev), usbd_errstr(err));
- return (EIO);
+ free(buf, M_DEVBUF);
+ return (EIO);
}
/* Load fixup segment */
DPRINTFN(1,("%s: kue_load_fw: download fix_seg\n",
USBDEVNAME(sc->kue_dev)));
err = kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SEND_SCAN,
- 0, (void *)kue_fix_seg, sizeof(kue_fix_seg));
+ 0, (void *)&fw->data[fw->codeseglen], fw->fixseglen);
if (err) {
printf("%s: failed to load fixup segment: %s\n",
USBDEVNAME(sc->kue_dev), usbd_errstr(err));
- return (EIO);
+ free(buf, M_DEVBUF);
+ return (EIO);
}
/* Send trigger command. */
DPRINTFN(1,("%s: kue_load_fw: download trig_seg\n",
USBDEVNAME(sc->kue_dev)));
err = kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SEND_SCAN,
- 0, (void *)kue_trig_seg, sizeof(kue_trig_seg));
+ 0, (void *)&fw->data[fw->codeseglen + fw->fixseglen],
+ fw->trigseglen);
if (err) {
printf("%s: failed to load trigger segment: %s\n",
USBDEVNAME(sc->kue_dev), usbd_errstr(err));
- return (EIO);
+ free(buf, M_DEVBUF);
+ return (EIO);
}
+ free(buf, M_DEVBUF);
usbd_delay_ms(sc->kue_udev, 10);
diff --git a/sys/dev/usb/if_kuevar.h b/sys/dev/usb/if_kuevar.h
new file mode 100644
index 00000000000..a7028d28038
--- /dev/null
+++ b/sys/dev/usb/if_kuevar.h
@@ -0,0 +1,42 @@
+/* $OpenBSD: if_kuevar.h,v 1.1 2004/11/22 18:49:05 deraadt Exp $ */
+/* $NetBSD: if_kuereg.h,v 1.11 2001/01/21 02:35:31 augustss Exp $ */
+/*
+ * Copyright (c) 1997, 1998, 1999, 2000
+ * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Bill Paul.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD: src/sys/dev/usb/if_kuereg.h,v 1.2 2000/01/06 07:39:07 wpaul Exp $
+ */
+
+struct kue_firmware {
+ int codeseglen;
+ int fixseglen;
+ int trigseglen;
+ u_char data[4];
+};