This patch adds some hooks for firmware debugging.
Signed-off-by: Michael Buesch <[email protected]>
---
John, this is for 2.6.27
Index: wireless-testing/drivers/net/wireless/b43/b43.h
===================================================================
--- wireless-testing.orig/drivers/net/wireless/b43/b43.h 2008-05-15 23:31:37.000000000 +0200
+++ wireless-testing/drivers/net/wireless/b43/b43.h 2008-05-17 20:22:56.000000000 +0200
@@ -419,12 +419,18 @@ enum {
B43_IRQ_TXFIFO_FLUSH_OK | \
B43_IRQ_NOISESAMPLE_OK | \
B43_IRQ_UCODE_DEBUG | \
B43_IRQ_RFKILL | \
B43_IRQ_TX_OK)
+/* Debug-IRQ reasons. */
+#define B43_DEBUGIRQ_PANIC 0 /* The firmware panic'ed */
+#define B43_DEBUGIRQ_DUMP_SHM 1 /* Dump shared SHM */
+#define B43_DEBUGIRQ_DUMP_REGS 2 /* Dump the microcode registers */
+#define B43_DEBUGIRQ_ACK 0xFFFF /* The host writes that to ACK the IRQ */
+
/* Device specific rate values.
* The actual values defined here are (rate_in_mbps * 2).
* Some code depends on this. Don't change it. */
#define B43_CCK_RATE_1MB 0x02
#define B43_CCK_RATE_2MB 0x04
#define B43_CCK_RATE_5MB 0x0B
@@ -763,12 +769,15 @@ struct b43_firmware {
struct b43_firmware_file initvals_band;
/* Firmware revision */
u16 rev;
/* Firmware patchlevel */
u16 patch;
+
+ /* Set to true, if we are using an opensource firmware. */
+ bool opensource;
};
/* Device (802.11 core) initialization status. */
enum {
B43_STAT_UNINIT = 0, /* Uninitialized. */
B43_STAT_INITIALIZED = 1, /* Initialized, but not started, yet. */
Index: wireless-testing/drivers/net/wireless/b43/main.c
===================================================================
--- wireless-testing.orig/drivers/net/wireless/b43/main.c 2008-05-15 23:31:37.000000000 +0200
+++ wireless-testing/drivers/net/wireless/b43/main.c 2008-05-17 22:35:00.000000000 +0200
@@ -1663,13 +1663,70 @@ static void b43_set_beacon_int(struct b4
b43_time_unlock(dev);
b43dbg(dev->wl, "Set beacon interval to %u\n", beacon_int);
}
static void handle_irq_ucode_debug(struct b43_wldev *dev)
{
- //TODO
+ unsigned int i, cnt;
+ u16 reason;
+ __le16 *buf;
+
+ /* The proprietary firmware doesn't have this IRQ. */
+ if (!dev->fw.opensource)
+ return;
+
+ /* Microcode register 63 contains the debug-IRQ reason. */
+ reason = b43_shm_read16(dev, B43_SHM_SCRATCH, 63);
+ switch (reason) {
+ case B43_DEBUGIRQ_PANIC:
+ /* The reason for the panic is in register 3. */
+ reason = b43_shm_read16(dev, B43_SHM_SCRATCH, 3);
+ b43err(dev->wl, "Whoopsy, the microcode panic'ed! Reason: %u\n",
+ reason);
+ b43_controller_restart(dev, "Microcode panic");
+ break;
+ case B43_DEBUGIRQ_DUMP_SHM:
+ if (!B43_DEBUG)
+ break; /* Only with driver debugging enabled. */
+ buf = kmalloc(4096, GFP_ATOMIC);
+ if (!buf) {
+ b43dbg(dev->wl, "SHM-dump: Failed to allocate memory\n");
+ goto out;
+ }
+ for (i = 0; i < 4096; i += 2) {
+ u16 tmp = b43_shm_read16(dev, B43_SHM_SHARED, i);
+ buf[i / 2] = cpu_to_le16(tmp);
+ }
+ b43info(dev->wl, "Shared memory dump:\n");
+ print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET,
+ 16, 2, buf, 4096, 1);
+ kfree(buf);
+ break;
+ case B43_DEBUGIRQ_DUMP_REGS:
+ if (!B43_DEBUG)
+ break; /* Only with driver debugging enabled. */
+ b43info(dev->wl, "Microcode register dump:\n");
+ for (i = 0, cnt = 0; i < 64; i++) {
+ u16 tmp = b43_shm_read16(dev, B43_SHM_SCRATCH, i);
+ if (cnt == 0)
+ printk(KERN_INFO);
+ printk("r%02u: 0x%04X ", i, tmp);
+ cnt++;
+ if (cnt == 6) {
+ printk("\n");
+ cnt = 0;
+ }
+ }
+ printk("\n");
+ break;
+ default:
+ b43dbg(dev->wl, "Debug-IRQ triggered for unknown reason: %u\n",
+ reason);
+ }
+out:
+ b43_shm_write16(dev, B43_SHM_SCRATCH, 63, B43_DEBUGIRQ_ACK);
}
/* Interrupt handler bottom-half */
static void b43_interrupt_tasklet(struct b43_wldev *dev)
{
u32 reason;
@@ -2121,20 +2178,28 @@ static int b43_upload_microcode(struct b
"binary drivers older than version 4.x is unsupported. "
"You must upgrade your firmware files.\n");
b43_print_fw_helptext(dev->wl, 1);
err = -EOPNOTSUPP;
goto error;
}
- b43info(dev->wl, "Loading firmware version %u.%u "
- "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n",
- fwrev, fwpatch,
- (fwdate >> 12) & 0xF, (fwdate >> 8) & 0xF, fwdate & 0xFF,
- (fwtime >> 11) & 0x1F, (fwtime >> 5) & 0x3F, fwtime & 0x1F);
-
dev->fw.rev = fwrev;
dev->fw.patch = fwpatch;
+ dev->fw.opensource = (fwdate == 0xFFFF);
+
+ if (dev->fw.opensource) {
+ /* Patchlevel info is encoded in the "time" field. */
+ dev->fw.patch = fwtime;
+ b43info(dev->wl, "Loading OpenSource firmware version %u.%u\n",
+ dev->fw.rev, dev->fw.patch);
+ } else {
+ b43info(dev->wl, "Loading firmware version %u.%u "
+ "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n",
+ fwrev, fwpatch,
+ (fwdate >> 12) & 0xF, (fwdate >> 8) & 0xF, fwdate & 0xFF,
+ (fwtime >> 11) & 0x1F, (fwtime >> 5) & 0x3F, fwtime & 0x1F);
+ }
if (b43_is_old_txhdr_format(dev)) {
b43warn(dev->wl, "You are using an old firmware image. "
"Support for old firmware will be removed in July 2008.\n");
b43_print_fw_helptext(dev->wl, 0);
}
On Sat, May 17, 2008 at 10:44 PM, Michael Buesch <[email protected]> wrote:
> This patch adds some hooks for firmware debugging.
>
> Signed-off-by: Michael Buesch <[email protected]>
>
> ---
>
> John, this is for 2.6.27
>
>
> Index: wireless-testing/drivers/net/wireless/b43/b43.h
> ===================================================================
> --- wireless-testing.orig/drivers/net/wireless/b43/b43.h 2008-05-15 23:31:37.000000000 +0200
> +++ wireless-testing/drivers/net/wireless/b43/b43.h 2008-05-17 20:22:56.000000000 +0200
> @@ -419,12 +419,18 @@ enum {
> B43_IRQ_TXFIFO_FLUSH_OK | \
> B43_IRQ_NOISESAMPLE_OK | \
> B43_IRQ_UCODE_DEBUG | \
> B43_IRQ_RFKILL | \
> B43_IRQ_TX_OK)
>
> +/* Debug-IRQ reasons. */
> +#define B43_DEBUGIRQ_PANIC 0 /* The firmware panic'ed */
> +#define B43_DEBUGIRQ_DUMP_SHM 1 /* Dump shared SHM */
> +#define B43_DEBUGIRQ_DUMP_REGS 2 /* Dump the microcode registers */
> +#define B43_DEBUGIRQ_ACK 0xFFFF /* The host writes that to ACK the IRQ */
> +
> /* Device specific rate values.
> * The actual values defined here are (rate_in_mbps * 2).
> * Some code depends on this. Don't change it. */
> #define B43_CCK_RATE_1MB 0x02
> #define B43_CCK_RATE_2MB 0x04
> #define B43_CCK_RATE_5MB 0x0B
> @@ -763,12 +769,15 @@ struct b43_firmware {
> struct b43_firmware_file initvals_band;
>
> /* Firmware revision */
> u16 rev;
> /* Firmware patchlevel */
> u16 patch;
> +
> + /* Set to true, if we are using an opensource firmware. */
> + bool opensource;
> };
>
> /* Device (802.11 core) initialization status. */
> enum {
> B43_STAT_UNINIT = 0, /* Uninitialized. */
> B43_STAT_INITIALIZED = 1, /* Initialized, but not started, yet. */
> Index: wireless-testing/drivers/net/wireless/b43/main.c
> ===================================================================
> --- wireless-testing.orig/drivers/net/wireless/b43/main.c 2008-05-15 23:31:37.000000000 +0200
> +++ wireless-testing/drivers/net/wireless/b43/main.c 2008-05-17 22:35:00.000000000 +0200
> @@ -1663,13 +1663,70 @@ static void b43_set_beacon_int(struct b4
> b43_time_unlock(dev);
> b43dbg(dev->wl, "Set beacon interval to %u\n", beacon_int);
> }
>
> static void handle_irq_ucode_debug(struct b43_wldev *dev)
> {
> - //TODO
> + unsigned int i, cnt;
> + u16 reason;
> + __le16 *buf;
> +
> + /* The proprietary firmware doesn't have this IRQ. */
> + if (!dev->fw.opensource)
> + return;
> +
> + /* Microcode register 63 contains the debug-IRQ reason. */
> + reason = b43_shm_read16(dev, B43_SHM_SCRATCH, 63);
> + switch (reason) {
> + case B43_DEBUGIRQ_PANIC:
> + /* The reason for the panic is in register 3. */
> + reason = b43_shm_read16(dev, B43_SHM_SCRATCH, 3);
> + b43err(dev->wl, "Whoopsy, the microcode panic'ed! Reason: %u\n",
> + reason);
> + b43_controller_restart(dev, "Microcode panic");
> + break;
> + case B43_DEBUGIRQ_DUMP_SHM:
> + if (!B43_DEBUG)
> + break; /* Only with driver debugging enabled. */
> + buf = kmalloc(4096, GFP_ATOMIC);
> + if (!buf) {
> + b43dbg(dev->wl, "SHM-dump: Failed to allocate memory\n");
> + goto out;
> + }
> + for (i = 0; i < 4096; i += 2) {
> + u16 tmp = b43_shm_read16(dev, B43_SHM_SHARED, i);
> + buf[i / 2] = cpu_to_le16(tmp);
> + }
> + b43info(dev->wl, "Shared memory dump:\n");
> + print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET,
> + 16, 2, buf, 4096, 1);
> + kfree(buf);
> + break;
> + case B43_DEBUGIRQ_DUMP_REGS:
> + if (!B43_DEBUG)
> + break; /* Only with driver debugging enabled. */
> + b43info(dev->wl, "Microcode register dump:\n");
> + for (i = 0, cnt = 0; i < 64; i++) {
> + u16 tmp = b43_shm_read16(dev, B43_SHM_SCRATCH, i);
> + if (cnt == 0)
> + printk(KERN_INFO);
> + printk("r%02u: 0x%04X ", i, tmp);
> + cnt++;
> + if (cnt == 6) {
> + printk("\n");
> + cnt = 0;
> + }
> + }
> + printk("\n");
> + break;
> + default:
> + b43dbg(dev->wl, "Debug-IRQ triggered for unknown reason: %u\n",
> + reason);
> + }
> +out:
> + b43_shm_write16(dev, B43_SHM_SCRATCH, 63, B43_DEBUGIRQ_ACK);
> }
>
> /* Interrupt handler bottom-half */
> static void b43_interrupt_tasklet(struct b43_wldev *dev)
> {
> u32 reason;
> @@ -2121,20 +2178,28 @@ static int b43_upload_microcode(struct b
> "binary drivers older than version 4.x is unsupported. "
> "You must upgrade your firmware files.\n");
> b43_print_fw_helptext(dev->wl, 1);
> err = -EOPNOTSUPP;
> goto error;
> }
> - b43info(dev->wl, "Loading firmware version %u.%u "
> - "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n",
> - fwrev, fwpatch,
> - (fwdate >> 12) & 0xF, (fwdate >> 8) & 0xF, fwdate & 0xFF,
> - (fwtime >> 11) & 0x1F, (fwtime >> 5) & 0x3F, fwtime & 0x1F);
> -
> dev->fw.rev = fwrev;
> dev->fw.patch = fwpatch;
> + dev->fw.opensource = (fwdate == 0xFFFF);
> +
> + if (dev->fw.opensource) {
> + /* Patchlevel info is encoded in the "time" field. */
> + dev->fw.patch = fwtime;
> + b43info(dev->wl, "Loading OpenSource firmware version %u.%u\n",
> + dev->fw.rev, dev->fw.patch);
> + } else {
> + b43info(dev->wl, "Loading firmware version %u.%u "
> + "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n",
> + fwrev, fwpatch,
> + (fwdate >> 12) & 0xF, (fwdate >> 8) & 0xF, fwdate & 0xFF,
> + (fwtime >> 11) & 0x1F, (fwtime >> 5) & 0x3F, fwtime & 0x1F);
> + }
>
> if (b43_is_old_txhdr_format(dev)) {
> b43warn(dev->wl, "You are using an old firmware image. "
> "Support for old firmware will be removed in July 2008.\n");
> b43_print_fw_helptext(dev->wl, 0);
> }
> _______________________________________________
> Bcm43xx-dev mailing list
> [email protected]
> https://lists.berlios.de/mailman/listinfo/bcm43xx-dev
>
Hmm... what's this? Are we planning something along the lines of
prism54's FreeMAC?
--
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)
On Saturday 17 May 2008 23:21:22 Stefanik G=E1bor wrote:
> Hmm... what's this? Are we planning something along the lines of
> prism54's FreeMAC?
http://bu3sch.de/gitweb?p=3Db43-ucode.git;a=3Dsummary
Doesn't work, yet. So you don't need to try. ;)
--=20
Greetings Michael.
Stefanik G=E1bor wrote:
>=20
> Another question: is this legal in the US? AFAIK this might conflict
> with FCC regulations. (Not sure about EU.)
>=20
Although I don't claim to be a lawyer, I found this information from=20
http://www.softwarefreedom.org/resources/2007/fcc-sdr-whitepaper.html,=20
which is a translation of the FCC's rules regarding software defined=20
radios (including 802.11 chips).
Snippet 1:
The rules require any manufacturer certifying a device under the new=20
process to take steps to prevent =93unauthorized=94 changes to the soft=
ware=20
on the device that might alter its radio frequency and power parameters=
=20
in a way that takes it out of compliance with the regulations known as=20
=46CC Part 15 regulations.2 The specific technology implemented to=20
accomplish this task is left to the manufacturers seeking certification=
,=20
although the FCC suggests several possible mechanisms that can serve as=
=20
such =93security measures.=943
Snippet 2:
Since software is a representation of a mathematical algorithm, it is=20
not a =93device=94, =93home electronic equipment=94 or a =93home electr=
onic ...=20
system.=9417 Further, there is no precedent for applying the device=20
certification rules to software except as installed as a component of a=
=20
specific hardware device. Indeed, the FCC has explicitly limited the=20
certification requirements to =93hardware-based device[s].=9418 Both of=
=20
these facts make it clear that the FCC rules do not apply to software b=
y=20
itself, but only to hardware-based devices.
What I get out of this, and out of poking in the legal babble, is that=20
as long as our firmware doesn't cause the hardware itself to violate FC=
C=20
specs, we're in the clear. According to Snippet 1, it shouldn't even be=
=20
possible to violate the specifications, but we all know how good=20
manufacturers are at stuff like that ;P.
-Andrew/Zappacky
(IANAL, Proceed at your own risk, etc)
On Sat, May 17, 2008 at 11:24 PM, Michael Buesch <[email protected]> wrote:
> On Saturday 17 May 2008 23:21:22 Stefanik G=E1bor wrote:
>> Hmm... what's this? Are we planning something along the lines of
>> prism54's FreeMAC?
>
> http://bu3sch.de/gitweb?p=3Db43-ucode.git;a=3Dsummary
>
> Doesn't work, yet. So you don't need to try. ;)
>
> --
> Greetings Michael.
>
Hmm, are we calling this "Broadcom BCM43xx Microcode" instead of
"Broadcom AirForce One Microcode" for licensing/trademark reasons? The
official name of these cards is AirForce One.
--=20
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)
On Sun, May 18, 2008 at 12:35 AM, Michael Buesch <[email protected]> wrote:
> On Sunday 18 May 2008 00:27:49 Stefanik G=E1bor wrote:
>> On Sat, May 17, 2008 at 11:24 PM, Michael Buesch <[email protected]> wrot=
e:
>> Hmm, are we calling this "Broadcom BCM43xx Microcode" instead of
>> "Broadcom AirForce One Microcode" for licensing/trademark reasons? T=
he
>> official name of these cards is AirForce One.
>
> That's the first time I hear that, so it's most likely not _that_ off=
icial. ;)
>
> And quite honestly, I don't care at all playing bullshit-bingo with b=
uzzwords.
> The device has the product number 43XX, so we identify it that way.
>
> --
> Greetings Michael.
>
Another question: is this legal in the US? AFAIK this might conflict
with FCC regulations. (Not sure about EU.)
--=20
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)
On Sunday 18 May 2008 00:27:49 Stefanik G=E1bor wrote:
> On Sat, May 17, 2008 at 11:24 PM, Michael Buesch <[email protected]> wrote=
:
> > On Saturday 17 May 2008 23:21:22 Stefanik G=E1bor wrote:
> >> Hmm... what's this? Are we planning something along the lines of
> >> prism54's FreeMAC?
> >
> > http://bu3sch.de/gitweb?p=3Db43-ucode.git;a=3Dsummary
> >
> > Doesn't work, yet. So you don't need to try. ;)
> >
> > --
> > Greetings Michael.
> >
>=20
> Hmm, are we calling this "Broadcom BCM43xx Microcode" instead of
> "Broadcom AirForce One Microcode" for licensing/trademark reasons? Th=
e
> official name of these cards is AirForce One.
That's the first time I hear that, so it's most likely not _that_ offic=
ial. ;)
And quite honestly, I don't care at all playing bullshit-bingo with buz=
zwords.
The device has the product number 43XX, so we identify it that way.
--=20
Greetings Michael.
Stefanik G=E1bor wrote:
>=20
> Hmm, are we calling this "Broadcom BCM43xx Microcode" instead of
> "Broadcom AirForce One Microcode" for licensing/trademark reasons? Th=
e
> official name of these cards is AirForce One.
>=20
Some of these cards may be called AirForce One; however, I have 7 diffe=
rent=20
cards of varying form factor, and none of them have that name!
Larry
MjAwOC81LzE3LCBNaWNoYWVsIEJ1ZXNjaCA8bWJAYnUzc2NoLmRlPjoKPiBPbiBTYXR1cmRheSAx
NyBNYXkgMjAwOCAyMzoyMToyMiBTdGVmYW5payBHw6Fib3Igd3JvdGU6Cj4gID4gSG1tLi4uIHdo
YXQncyB0aGlzPyBBcmUgd2UgcGxhbm5pbmcgc29tZXRoaW5nIGFsb25nIHRoZSBsaW5lcyBvZgo+
ICA+IHByaXNtNTQncyBGcmVlTUFDPwo+Cj4KPiBodHRwOi8vYnUzc2NoLmRlL2dpdHdlYj9wPWI0
My11Y29kZS5naXQ7YT1zdW1tYXJ5Cj4KPiAgRG9lc24ndCB3b3JrLCB5ZXQuIFNvIHlvdSBkb24n
dCBuZWVkIHRvIHRyeS4gOykKCk9oIG1hbiwgb3BlbiBzb3VyY2UgZnc/IFRoYXQncyBzbyBuaWNl
IHRvIGhlYXIgdGhhdCEgSSBleHRyZW1seSBob3BlCnlvdSB3aWxsIGFibGUgdG8gbWFrZSB0aGlz
IHdvcmtpbmchCgpPcGVuIGZ3IGNvdWxkIGJlIGluY2x1ZGVkIGluIGFueSBkaXN0cm8sIHJpZ2h0
PwoKLS0gClJhZmHFgiBNacWCZWNraQo=