diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-07-28 07:20:29 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-07-28 07:20:29 +0000 |
commit | 6367e65c8eba42345584f505a9a9c42e785110fc (patch) | |
tree | c29bb069087c9ded0a36d49a3d0139d89d528446 /sys | |
parent | 91b609484f4b8d3135cdb26cb6db6f7c4cdc97fc (diff) |
The firmware is an array of u_int32_t and differs between architectures.
From now on install the tigon firmware in little endian byte order and swap
it acordingly in the driver. Correctly calculate the length of the FW in the
build tool -- now my fiber cards no longer have issues to establish link on
bootup. Please put this in deraadt@
On big endian archs (sparc64, macppc) the firmware file needs to be updated.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/microcode/tigon/build.c | 14 | ||||
-rw-r--r-- | sys/dev/pci/if_ti.c | 11 |
2 files changed, 19 insertions, 6 deletions
diff --git a/sys/dev/microcode/tigon/build.c b/sys/dev/microcode/tigon/build.c index 7e9a519dc43..02dd9085a79 100644 --- a/sys/dev/microcode/tigon/build.c +++ b/sys/dev/microcode/tigon/build.c @@ -1,4 +1,4 @@ -/* $OpenBSD: build.c,v 1.3 2005/05/17 18:48:52 jason Exp $ */ +/* $OpenBSD: build.c,v 1.4 2009/07/28 07:20:28 claudio Exp $ */ /* * Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org> @@ -37,11 +37,12 @@ output(const char *name, const u_int32_t *FwData, int sizedata) { struct tigon_firmware tfproto, *tf; - int len, fd, i; + int len, fd, i, cnt; + u_int32_t *b; ssize_t rlen; - len = sizeof tf - sizeof(tfproto.data) + sizetext + sizerodata + - sizedata; + len = sizeof(tfproto) - sizeof(tfproto.data) + sizetext + + sizerodata + sizedata; tf = (struct tigon_firmware *)malloc(len); bzero(tf, len); @@ -73,6 +74,11 @@ output(const char *name, bcopy(FwRodata, &tf->data[tf->FwRodataOffset], FwRodataLen); bcopy(FwData, &tf->data[tf->FwDataOffset], FwDataLen); + b = (u_int32_t *)tf; + cnt = len / sizeof(u_int32_t); + for (i = 0; i < cnt; i++) + b[i] = htole32(b[i]); + printf("creating %s length %d [%d+%d+%d] [%d+%d+%d]\n", name, len, FwTextLen, FwRodataLen, FwDataLen, sizetext, sizerodata, sizedata); diff --git a/sys/dev/pci/if_ti.c b/sys/dev/pci/if_ti.c index da5a66a8083..ca65a4d22a4 100644 --- a/sys/dev/pci/if_ti.c +++ b/sys/dev/pci/if_ti.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ti.c,v 1.94 2008/11/28 02:44:18 brad Exp $ */ +/* $OpenBSD: if_ti.c,v 1.95 2009/07/28 07:20:28 claudio Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -427,7 +427,8 @@ ti_loadfw(struct ti_softc *sc) { struct tigon_firmware *tf; u_char *buf = NULL; - size_t buflen; + u_int32_t *b; + size_t buflen, i, cnt; char *name; int error; @@ -447,6 +448,12 @@ ti_loadfw(struct ti_softc *sc) error = loadfirmware(name, &buf, &buflen); if (error) return; + /* convert firmware to host byte order */ + b = (u_int32_t *)buf; + cnt = buflen / sizeof(u_int32_t); + for (i = 0; i < cnt; i++) + b[i] = letoh32(b[i]); + tf = (struct tigon_firmware *)buf; if (tf->FwReleaseMajor != TI_FIRMWARE_MAJOR || tf->FwReleaseMinor != TI_FIRMWARE_MINOR || |