[kernel] r10733 - in dists/trunk/firmware-nonfree/bnx2: . fwcutter

Bastian Blank waldi at alioth.debian.org
Thu Mar 6 11:03:59 UTC 2008


Author: waldi
Date: Thu Mar  6 11:03:58 2008
New Revision: 10733

Log:
bnx2: Add.


Added:
   dists/trunk/firmware-nonfree/bnx2/
   dists/trunk/firmware-nonfree/bnx2/LICENSE
   dists/trunk/firmware-nonfree/bnx2/defines
   dists/trunk/firmware-nonfree/bnx2/fwcutter/
   dists/trunk/firmware-nonfree/bnx2/fwcutter/Makefile
   dists/trunk/firmware-nonfree/bnx2/fwcutter/bnx2_fw_file.h
   dists/trunk/firmware-nonfree/bnx2/fwcutter/bnx2_fwcutter.c
   dists/trunk/firmware-nonfree/bnx2/fwcutter/bnx2_fwcutter_2.6.25.c

Added: dists/trunk/firmware-nonfree/bnx2/LICENSE
==============================================================================
--- (empty file)
+++ dists/trunk/firmware-nonfree/bnx2/LICENSE	Thu Mar  6 11:03:58 2008
@@ -0,0 +1,7 @@
+This file contains firmware data derived from proprietary unpublished
+source code, Copyright (c) 2004, 2005, 2006, 2007 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.
+

Added: dists/trunk/firmware-nonfree/bnx2/defines
==============================================================================
--- (empty file)
+++ dists/trunk/firmware-nonfree/bnx2/defines	Thu Mar  6 11:03:58 2008
@@ -0,0 +1,15 @@
+[base]
+desc: Broadcom NetXtremeII
+files:
+ bnx2-06-4.0.5.fw
+ bnx2-09-4.0.5.fw
+longdesc: Broadcom NetXtremeII network adapters
+uri: http://ftp.debian.org/debian/pool/non-free/f/firmware-nonfree
+
+[bnx2-06-4.0.5.fw_base]
+desc: Broadcom NetXtremeII 5706 firmware
+version: Linux 2.6.25
+
+[bnx2-09-4.0.5.fw_base]
+desc: Broadcom NetXtremeII 5709 firmware
+version: Linux 2.6.25

Added: dists/trunk/firmware-nonfree/bnx2/fwcutter/Makefile
==============================================================================
--- (empty file)
+++ dists/trunk/firmware-nonfree/bnx2/fwcutter/Makefile	Thu Mar  6 11:03:58 2008
@@ -0,0 +1,15 @@
+ifndef KERNEL_SOURCE
+$(error Please define KERNEL_SOURCE)
+endif
+ifndef KERNEL_VERSION
+$(error Please define KERNEL_VERSION)
+endif
+
+CFLAGS += -I$(KERNEL_SOURCE)/drivers/net
+CFLAGS += --std=gnu99
+LDFLAGS += -lz
+
+all: bnx2_fwcutter_$(KERNEL_VERSION)
+
+bnx2_fwcutter_$(KERNEL_VERSION): bnx2_fwcutter_$(KERNEL_VERSION).c
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^

Added: dists/trunk/firmware-nonfree/bnx2/fwcutter/bnx2_fw_file.h
==============================================================================
--- (empty file)
+++ dists/trunk/firmware-nonfree/bnx2/fwcutter/bnx2_fw_file.h	Thu Mar  6 11:03:58 2008
@@ -0,0 +1,25 @@
+struct bnx2_fw_file_section {
+  uint32_t addr;
+  uint32_t len;
+  uint32_t offset;
+};
+
+struct bnx2_fw_file_entry {
+  uint32_t start_addr;
+  struct bnx2_fw_file_section text;
+  struct bnx2_fw_file_section data;
+  struct bnx2_fw_file_section sbss;
+  struct bnx2_fw_file_section bss;
+  struct bnx2_fw_file_section rodata;
+};
+
+struct bnx2_fw_file {
+  struct bnx2_fw_file_entry com;
+  struct bnx2_fw_file_entry cp;
+  struct bnx2_fw_file_entry rxp;
+  struct bnx2_fw_file_entry tpat;
+  struct bnx2_fw_file_entry txp;
+  struct bnx2_fw_file_section rv2p_proc1;
+  struct bnx2_fw_file_section rv2p_proc2;
+};
+

Added: dists/trunk/firmware-nonfree/bnx2/fwcutter/bnx2_fwcutter.c
==============================================================================
--- (empty file)
+++ dists/trunk/firmware-nonfree/bnx2/fwcutter/bnx2_fwcutter.c	Thu Mar  6 11:03:58 2008
@@ -0,0 +1,177 @@
+#include <assert.h>
+#include <byteswap.h>
+#include <endian.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <zlib.h>
+
+#include "bnx2_fw_file.h"
+
+struct fw_info {
+  const uint32_t ver_major;
+  const uint32_t ver_minor;
+  const uint32_t ver_fix;
+
+  const uint32_t start_addr;
+
+  /* Text section. */
+  const uint32_t text_addr;
+  const uint32_t text_len;
+  const uint32_t text_index;
+  void *text;
+  const void *gz_text;
+  const uint32_t gz_text_len;
+
+  /* Data section. */
+  const uint32_t data_addr;
+  const uint32_t data_len;
+  const uint32_t data_index;
+  const uint32_t *data;
+
+  /* SBSS section. */
+  const uint32_t sbss_addr;
+  const uint32_t sbss_len;
+  const uint32_t sbss_index;
+
+  /* BSS section. */
+  const uint32_t bss_addr;
+  const uint32_t bss_len;
+  const uint32_t bss_index;
+
+  /* Read-only section. */
+  const uint32_t rodata_addr;
+  const uint32_t rodata_len;
+  const uint32_t rodata_index;
+  const uint32_t *rodata;
+};
+
+typedef uint8_t u8;
+typedef uint32_t u32;
+
+#include "bnx2_fw.h"
+#include "bnx2_fw2.h"
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define cpu_to_be32(x) bswap_32(x)
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#define cpu_to_be32(x) (x)
+#endif
+#define le32_to_be32(x) bswap_32(x)
+
+void set_firmware_image_part(struct bnx2_fw_file_section *s, uint32_t addr, uint32_t len)
+{
+    s->addr = cpu_to_be32(addr);
+    s->len = cpu_to_be32(len);
+}
+
+void write_firmware_flat(int fd, struct bnx2_fw_file_section *out, void *data, int len)
+{
+  off_t offset = lseek(fd, 0, SEEK_CUR);
+
+  uint32_t buf[0x10000];
+  struct z_stream_s strm;
+  memset(&strm, 0, sizeof strm);
+
+  strm.next_in = (void *)data;
+  strm.avail_in = len;
+  strm.next_out = (void *)buf;
+  strm.avail_out = sizeof buf;
+
+  int ret = inflateInit2(&strm, -MAX_WBITS);
+  assert(ret == Z_OK);
+  ret = inflate(&strm, Z_FINISH);
+  assert(ret == Z_STREAM_END);
+  unsigned int l = strm.total_out;
+
+  out->len = cpu_to_be32(l);
+  out->offset = cpu_to_be32(offset);
+
+  inflateEnd(&strm);
+
+  for (unsigned int j = 0; j < (l / 4); j++)
+    buf[j] = le32_to_be32(buf[j]);
+  write(fd, buf, l);
+}
+
+void write_firmware_image(int fd, struct bnx2_fw_file_entry *out, struct fw_info *fw)
+{
+  off_t offset = lseek(fd, 0, SEEK_CUR);
+
+  out->start_addr = cpu_to_be32(fw->start_addr);
+
+  set_firmware_image_part(&out->text, fw->text_addr, fw->text_len);
+  out->text.offset = cpu_to_be32(offset);
+
+  uint32_t buf[0x10000];
+  struct z_stream_s strm;
+  memset(&strm, 0, sizeof strm);
+
+  strm.next_in = (void *)fw->gz_text;
+  strm.avail_in = fw->gz_text_len;
+  strm.next_out = (void *)buf;
+  strm.avail_out = sizeof buf;
+
+  int ret = inflateInit2(&strm, -MAX_WBITS);
+  assert(ret == Z_OK);
+  ret = inflate(&strm, Z_FINISH);
+  assert(ret == Z_STREAM_END);
+  inflateEnd(&strm);
+
+  for (unsigned int j = 0; j < (fw->text_len / 4); j++)
+    buf[j] = le32_to_be32(buf[j]);
+  offset += write(fd, buf, fw->text_len);
+
+  if (fw->data_addr)
+  {
+    set_firmware_image_part(&out->data, fw->data_addr, fw->data_len);
+    out->data.offset = cpu_to_be32(offset);
+    for (unsigned int j = 0; j < (fw->data_len / 4); j++)
+      buf[j] = cpu_to_be32(fw->data[j]);
+    offset += write(fd, buf, fw->data_len);
+  }
+
+  if (fw->sbss_len)
+    set_firmware_image_part(&out->sbss, fw->sbss_addr, fw->sbss_len);
+
+  if (fw->bss_len)
+    set_firmware_image_part(&out->bss, fw->bss_addr, fw->bss_len);
+
+  if (fw->rodata_addr)
+  {
+    set_firmware_image_part(&out->rodata, fw->rodata_addr, fw->rodata_len);
+    out->rodata.offset = cpu_to_be32(offset);
+    for (unsigned int j = 0; j < (fw->rodata_len / 4); j++)
+      buf[j] = cpu_to_be32(fw->rodata[j]);
+    offset += write(fd, buf, fw->rodata_len);
+  }
+}
+
+void write_firmware(const char *filename, struct fw_info *com_fw, struct fw_info *cp_fw, struct fw_info *rxp_fw, struct fw_info *tpat_fw, struct fw_info *txp_fw, void *rv2p_proc1, int rv2p_proc1_len, void *rv2p_proc2, int rv2p_proc2_len)
+{
+  struct bnx2_fw_file out;
+  memset(&out, 0, sizeof out);
+
+  int fd = open(filename, O_WRONLY | O_CREAT, 0666);
+
+  lseek(fd, sizeof out, SEEK_SET);
+
+  write_firmware_image(fd, &out.com, com_fw);
+  write_firmware_image(fd, &out.cp, cp_fw);
+  write_firmware_image(fd, &out.rxp, rxp_fw);
+  write_firmware_image(fd, &out.tpat, tpat_fw);
+  write_firmware_image(fd, &out.txp, txp_fw);
+  write_firmware_flat(fd, &out.rv2p_proc1, rv2p_proc1, rv2p_proc1_len);
+  write_firmware_flat(fd, &out.rv2p_proc2, rv2p_proc2, rv2p_proc2_len);
+
+  lseek(fd, 0, SEEK_SET);
+
+  write(fd, &out, sizeof out);
+
+  close(fd);
+}
+

Added: dists/trunk/firmware-nonfree/bnx2/fwcutter/bnx2_fwcutter_2.6.25.c
==============================================================================
--- (empty file)
+++ dists/trunk/firmware-nonfree/bnx2/fwcutter/bnx2_fwcutter_2.6.25.c	Thu Mar  6 11:03:58 2008
@@ -0,0 +1,24 @@
+#include "bnx2_fwcutter.c"
+
+int main()
+{
+  write_firmware("bnx2-06-4.0.5.fw",
+      &bnx2_com_fw_06,
+      &bnx2_cp_fw_06,
+      &bnx2_rxp_fw_06,
+      &bnx2_tpat_fw_06,
+      &bnx2_txp_fw_06,
+      bnx2_rv2p_proc1, sizeof bnx2_rv2p_proc1,
+      bnx2_rv2p_proc2, sizeof bnx2_rv2p_proc2);
+  write_firmware("bnx2-09-4.0.5.fw",
+      &bnx2_com_fw_09,
+      &bnx2_cp_fw_09,
+      &bnx2_rxp_fw_09,
+      &bnx2_tpat_fw_09,
+      &bnx2_txp_fw_09,
+      bnx2_xi_rv2p_proc1, sizeof bnx2_xi_rv2p_proc2,
+      bnx2_xi_rv2p_proc2, sizeof bnx2_xi_rv2p_proc2);
+
+  return EXIT_SUCCESS;
+}
+



More information about the Kernel-svn-changes mailing list