projects
/
b43-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
b43-asm: Fix some dependency issues
[b43-tools.git]
/
fwcutter
/
fwcutter.c
diff --git
a/fwcutter/fwcutter.c
b/fwcutter/fwcutter.c
index ae1c63a48c18c40416a0b3104f3a8fd54e0729ee..20337589192761ae17b351f9bbd4d488d242f85e 100644
(file)
--- a/
fwcutter/fwcutter.c
+++ b/
fwcutter/fwcutter.c
@@
-2,7
+2,7
@@
* firmware cutter for broadcom 43xx wireless driver files
*
* Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
* firmware cutter for broadcom 43xx wireless driver files
*
* Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
- * 2005-2007 Michael Buesch <m
b@bu3sch.de
>
+ * 2005-2007 Michael Buesch <m
@bues.ch
>
* 2005 Alex Beregszaszi
* 2007 Johannes Berg <johannes@sipsolutions.net>
*
* 2005 Alex Beregszaszi
* 2007 Johannes Berg <johannes@sipsolutions.net>
*
@@
-38,7
+38,7
@@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
-#if
def __DragonFly__
+#if
defined(__DragonFly__) || defined(__FreeBSD__)
#include <sys/endian.h>
#else
#include <byteswap.h>
#include <sys/endian.h>
#else
#include <byteswap.h>
@@
-48,7
+48,7
@@
#include "fwcutter.h"
#include "fwcutter_list.h"
#include "fwcutter.h"
#include "fwcutter_list.h"
-#if
def __DragonFly__
+#if
defined(__DragonFly__) || defined(__FreeBSD__)
#define V3_FW_DIRNAME "v3"
#define V4_FW_DIRNAME "v4"
#else
#define V3_FW_DIRNAME "v3"
#define V4_FW_DIRNAME "v4"
#else
@@
-65,18
+65,6
@@
static int file_ok(const struct file *f)
return !(f->flags & FW_FLAG_UNSUPPORTED) || cmdargs.unsupported;
}
return !(f->flags & FW_FLAG_UNSUPPORTED) || cmdargs.unsupported;
}
-/* Convert a CPU-endian 16bit integer to Big-Endian */
-static be16_t to_be16(uint16_t v)
-{
- uint8_t ret[2];
-
- ret[0] = (v & 0xFF00) >> 8;
- ret[1] = (v & 0x00FF);
-
- return *((be16_t *)ret);
-}
-
-#if 0
/* Convert a Big-Endian 16bit integer to CPU-endian */
static uint16_t from_be16(be16_t v)
{
/* Convert a Big-Endian 16bit integer to CPU-endian */
static uint16_t from_be16(be16_t v)
{
@@
-87,19
+75,11
@@
static uint16_t from_be16(be16_t v)
return ret;
}
return ret;
}
-#endif
-/* Convert a CPU-endian
32
bit integer to Big-Endian */
-static be
32_t to_be32(uint32
_t v)
+/* Convert a CPU-endian
16
bit integer to Big-Endian */
+static be
16_t to_be16(uint16
_t v)
{
{
- uint8_t ret[4];
-
- ret[0] = (v & 0xFF000000) >> 24;
- ret[1] = (v & 0x00FF0000) >> 16;
- ret[2] = (v & 0x0000FF00) >> 8;
- ret[3] = (v & 0x000000FF);
-
- return *((be32_t *)ret);
+ return (be16_t)from_be16((be16_t)v);
}
/* Convert a Big-Endian 32bit integer to CPU-endian */
}
/* Convert a Big-Endian 32bit integer to CPU-endian */
@@
-115,6
+95,12
@@
static uint32_t from_be32(be32_t v)
return ret;
}
return ret;
}
+/* Convert a CPU-endian 32bit integer to Big-Endian */
+static be32_t to_be32(uint32_t v)
+{
+ return (be32_t)from_be32((be32_t)v);
+}
+
/* tiny disassembler */
static void print_ucode_version(struct insn *insn)
{
/* tiny disassembler */
static void print_ucode_version(struct insn *insn)
{
@@
-448,16
+434,17
@@
static void print_supported_files(void)
print_banner();
printf("\nExtracting firmware is possible "
print_banner();
printf("\nExtracting firmware is possible "
- "from these binary driver files:\n\n");
+ "from these binary driver files.\n"
+ "Please read http://linuxwireless.org/en/users/Drivers/b43#devicefirmware\n\n");
printf("<driver>\t"
"<filename>\t\t"
"<microcode>\t"
"<MD5 checksum>\n\n");
/* print for legacy driver first */
printf("<driver>\t"
"<filename>\t\t"
"<microcode>\t"
"<MD5 checksum>\n\n");
/* print for legacy driver first */
- for (i = 0; i <
FILES
; i++)
+ for (i = 0; i <
ARRAY_SIZE(files)
; i++)
if (file_ok(&files[i]) && !(files[i].flags & FW_FLAG_V4))
print_file(&files[i]);
if (file_ok(&files[i]) && !(files[i].flags & FW_FLAG_V4))
print_file(&files[i]);
- for (i = 0; i <
FILES
; i++)
+ for (i = 0; i <
ARRAY_SIZE(files)
; i++)
if (file_ok(&files[i]) && files[i].flags & FW_FLAG_V4)
print_file(&files[i]);
printf("\n");
if (file_ok(&files[i]) && files[i].flags & FW_FLAG_V4)
print_file(&files[i]);
printf("\n");
@@
-483,7
+470,7
@@
static const struct file *find_file(FILE *fd)
signature[8], signature[9], signature[10], signature[11],
signature[12], signature[13], signature[14], signature[15]);
signature[8], signature[9], signature[10], signature[11],
signature[12], signature[13], signature[14], signature[15]);
- for (i = 0; i <
FILES; ++i
) {
+ for (i = 0; i <
ARRAY_SIZE(files); i++
) {
if (file_ok(&files[i]) &&
strcasecmp(md5sig, files[i].md5) == 0) {
printf("This file is recognised as:\n");
if (file_ok(&files[i]) &&
strcasecmp(md5sig, files[i].md5) == 0) {
printf("This file is recognised as:\n");
@@
-503,7
+490,9
@@
static const struct file *find_file(FILE *fd)
static void print_usage(int argc, char *argv[])
{
print_banner();
static void print_usage(int argc, char *argv[])
{
print_banner();
- printf("\nUsage: %s [OPTION] [driver.sys]\n", argv[0]);
+ printf("\nA tool to extract firmware for a Broadcom 43xx device\n");
+ printf("from a proprietary Broadcom 43xx device driver file.\n");
+ printf("\nUsage: %s [OPTION] [proprietary-driver-file]\n", argv[0]);
printf(" --unsupported "
"Allow working on extractable but unsupported drivers\n");
printf(" -l|--list "
printf(" --unsupported "
"Allow working on extractable but unsupported drivers\n");
printf(" -l|--list "
@@
-516,8
+505,9
@@
static void print_usage(int argc, char *argv[])
"Print b43-fwcutter version\n");
printf(" -h|--help "
"Print this help\n");
"Print b43-fwcutter version\n");
printf(" -h|--help "
"Print this help\n");
- printf("\nExample: %s bcmwl5.sys\n"
- " to extract the firmware blobs from bcmwl5.sys\n",
+ printf("\nExample: %s -w /lib/firmware wl_apsta.o\n"
+ " to extract the firmware blobs from wl_apsta.o and store\n"
+ " the resulting firmware in /lib/firmware\n",
argv[0]);
}
argv[0]);
}
@@
-553,7
+543,7
@@
static int do_cmp_arg(char **argv, int *pos,
if (param) {
/* Skip the parameter on the next iteration. */
(*pos)++;
if (param) {
/* Skip the parameter on the next iteration. */
(*pos)++;
- if (
*param == 0
) {
+ if (
!*param
) {
printf("%s needs a parameter\n", arg);
return ARG_ERROR;
}
printf("%s needs a parameter\n", arg);
return ARG_ERROR;
}
@@
-591,34
+581,34
@@
static int parse_args(int argc, char *argv[])
if (argc < 2)
goto out_usage;
for (i = 1; i < argc; i++) {
if (argc < 2)
goto out_usage;
for (i = 1; i < argc; i++) {
- res = cmp_arg(argv, &i, "--list", "-l",
0
);
+ res = cmp_arg(argv, &i, "--list", "-l",
NULL
);
if (res == ARG_MATCH) {
cmdargs.mode = FWCM_LIST;
continue;
} else if (res == ARG_ERROR)
goto out;
if (res == ARG_MATCH) {
cmdargs.mode = FWCM_LIST;
continue;
} else if (res == ARG_ERROR)
goto out;
- res = cmp_arg(argv, &i, "--version", "-v",
0
);
+ res = cmp_arg(argv, &i, "--version", "-v",
NULL
);
if (res == ARG_MATCH) {
print_banner();
return 1;
} else if (res == ARG_ERROR)
goto out;
if (res == ARG_MATCH) {
print_banner();
return 1;
} else if (res == ARG_ERROR)
goto out;
- res = cmp_arg(argv, &i, "--help", "-h",
0
);
+ res = cmp_arg(argv, &i, "--help", "-h",
NULL
);
if (res == ARG_MATCH)
goto out_usage;
else if (res == ARG_ERROR)
goto out;
if (res == ARG_MATCH)
goto out_usage;
else if (res == ARG_ERROR)
goto out;
- res = cmp_arg(argv, &i, "--identify", "-i",
0
);
+ res = cmp_arg(argv, &i, "--identify", "-i",
NULL
);
if (res == ARG_MATCH) {
cmdargs.mode = FWCM_IDENTIFY;
continue;
} else if (res == ARG_ERROR)
goto out;
if (res == ARG_MATCH) {
cmdargs.mode = FWCM_IDENTIFY;
continue;
} else if (res == ARG_ERROR)
goto out;
- res = cmp_arg(argv, &i, "--unsupported", NULL,
0
);
+ res = cmp_arg(argv, &i, "--unsupported", NULL,
NULL
);
if (res == ARG_MATCH) {
cmdargs.unsupported = 1;
continue;
if (res == ARG_MATCH) {
cmdargs.unsupported = 1;
continue;