summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2006-09-20 22:16:05 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2006-09-20 22:16:05 +0000
commit2d186595d5eec8310c44e8a7a35d0a7a762429b0 (patch)
tree8a11fd55de6b6573bebaeee2336a4ccfcea529ef /sys
parent901d27dd839579369a4332191e3bf97b22732ff5 (diff)
build a bnx firmware file, for firmload
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/microcode/bnx/Makefile34
-rw-r--r--sys/dev/microcode/bnx/bnx-license40
-rw-r--r--sys/dev/microcode/bnx/build.c85
3 files changed, 159 insertions, 0 deletions
diff --git a/sys/dev/microcode/bnx/Makefile b/sys/dev/microcode/bnx/Makefile
new file mode 100644
index 00000000000..765bbf44e1b
--- /dev/null
+++ b/sys/dev/microcode/bnx/Makefile
@@ -0,0 +1,34 @@
+# $OpenBSD: Makefile,v 1.1 2006/09/20 22:16:04 deraadt Exp $
+
+NOPROG=
+NOMAN=
+
+# PCI capable systems only
+.if (${MACHINE} == "i386") || (${MACHINE} == "amd64") || \
+ (${MACHINE} == "alpha") || (${MACHINE} == "sparc64") || \
+ (${MACHINE_ARCH} == "powerpc") || (${MACHINE} == "cats") || \
+ (${MACHINE} == "hppa") || (${MACHINE} == "hppa64") || \
+ (${MACHINE} == "sgi")
+
+FIRM= bnx
+
+PROG= build
+
+CLEANFILES+= ${FIRM} ${PROG}
+
+all: ${FIRM}
+
+${FIRM}: build
+ ${.OBJDIR}/build
+
+realinstall:
+
+afterinstall:
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
+ ${FIRM} ${DESTDIR}/etc/firmware
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
+ ${.CURDIR}/bnx-license ${DESTDIR}/etc/firmware
+
+.endif
+
+.include <bsd.prog.mk>
diff --git a/sys/dev/microcode/bnx/bnx-license b/sys/dev/microcode/bnx/bnx-license
new file mode 100644
index 00000000000..ea42469fa23
--- /dev/null
+++ b/sys/dev/microcode/bnx/bnx-license
@@ -0,0 +1,40 @@
+Copyright (c) 2006 Broadcom Corporation
+ David Christensen <davidch@broadcom.com>. 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. Neither the name of Broadcom Corporation nor the name of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written consent.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT OWNER OR CONTRIBUTORS
+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 file contains firmware data derived from proprietary unpublished
+source code, Copyright (c) 2004, 2005 Broadcom Corporation.
+
+Permission is hereby granted for the distribution of this firmware data
+in hexadecimal or equivalent format, provided this copyright notice is
+accompanying it.
+
+The following files are under this license:
+
+bnx
+
+These files are needed by various models of bnx(4) devices.
+
diff --git a/sys/dev/microcode/bnx/build.c b/sys/dev/microcode/bnx/build.c
new file mode 100644
index 00000000000..5473fbd69ac
--- /dev/null
+++ b/sys/dev/microcode/bnx/build.c
@@ -0,0 +1,85 @@
+/* $OpenBSD: build.c,v 1.1 2006/09/20 22:16:04 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/pci/if_bnxreg.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <err.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include "bnxfw.h"
+
+#define FILENAME "bnx"
+
+int
+main(int argc, char *argv[])
+{
+ struct bnx_firmware_header bfproto, *bf;
+ int len, fd;
+ ssize_t rlen;
+
+ len = sizeof(*bf);
+ bf = (struct bnx_firmware_header *)malloc(len);
+ bzero(bf, len);
+
+ /* initialize the file header */
+ bf->bnx_COM_b06FwReleaseMajor = bnx_COM_b06FwReleaseMajor;
+ bf->bnx_COM_b06FwReleaseMinor = bnx_COM_b06FwReleaseMinor;
+ bf->bnx_COM_b06FwReleaseFix = bnx_COM_b06FwReleaseFix;
+ bf->bnx_COM_b06FwStartAddr = bnx_COM_b06FwStartAddr;
+ bf->bnx_COM_b06FwTextAddr = bnx_COM_b06FwTextAddr;
+ bf->bnx_COM_b06FwTextLen = bnx_COM_b06FwTextLen;
+ bf->bnx_COM_b06FwDataAddr = bnx_COM_b06FwDataAddr;
+ bf->bnx_COM_b06FwDataLen = bnx_COM_b06FwDataLen;
+ bf->bnx_COM_b06FwRodataAddr = bnx_COM_b06FwRodataAddr;
+ bf->bnx_COM_b06FwRodataLen = bnx_COM_b06FwRodataLen;
+ bf->bnx_COM_b06FwBssAddr = bnx_COM_b06FwBssAddr;
+ bf->bnx_COM_b06FwBssLen = bnx_COM_b06FwBssLen;
+ bf->bnx_COM_b06FwSbssAddr = bnx_COM_b06FwSbssAddr;
+ bf->bnx_COM_b06FwSbssLen = bnx_COM_b06FwSbssLen;
+
+ memcpy(bf->bnx_TXP_b06FwData, bnx_TXP_b06FwData, sizeof bnx_TXP_b06FwData);
+ memcpy(bf->bnx_TXP_b06FwRodata, bnx_TXP_b06FwRodata, sizeof bnx_TXP_b06FwRodata);
+ memcpy(bf->bnx_TXP_b06FwBss, bnx_TXP_b06FwBss, sizeof bnx_TXP_b06FwBss);
+ memcpy(bf->bnx_TXP_b06FwSbss, bnx_TXP_b06FwSbss, sizeof bnx_TXP_b06FwSbss);
+
+ bf->firmlength = sizeof bnx_COM_b06FwText;
+
+ printf("creating %s length %d [%d+%d]\n",
+ FILENAME, len + bf->firmlength, len, bf->firmlength);
+ fd = open(FILENAME, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ if (fd == -1)
+ err(1, FILENAME);
+
+ rlen = write(fd, bf, len);
+ if (rlen == -1)
+ err(1, "%s", FILENAME);
+ if (rlen != len)
+ errx(1, "%s: short write", FILENAME);
+
+ rlen = write(fd, bnx_COM_b06FwText, sizeof bnx_COM_b06FwText);
+ if (rlen == -1)
+ err(1, "%s", FILENAME);
+ if (rlen != sizeof bnx_COM_b06FwText)
+ errx(1, "%s: short write", FILENAME);
+
+ free(bf);
+ close(fd);
+ return 0;
+}