From 1a0b297432349ca1ad02461f962dc805da1e6949 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sun, 18 Nov 2007 15:10:24 +0100 Subject: [PATCH] dasm: Move some definitions around. Signed-off-by: Michael Buesch --- disassembler/Makefile | 2 ++ disassembler/main.c | 19 +++---------------- disassembler/main.h | 22 ++++++++++++++++++++++ disassembler/util.h | 8 ++++++++ 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/disassembler/Makefile b/disassembler/Makefile index e664722..efb4125 100644 --- a/disassembler/Makefile +++ b/disassembler/Makefile @@ -15,6 +15,8 @@ main.o: main.h util.h list.h args.h util.o: util.h +args.o: args.h main.h util.h + $(BIN): $(OBJECTS) $(CC) $(CFLAGS) -o $(BIN) $(OBJECTS) $(LDFLAGS) diff --git a/disassembler/main.c b/disassembler/main.c index 8ae8040..7fc8536 100644 --- a/disassembler/main.c +++ b/disassembler/main.c @@ -11,6 +11,7 @@ * GNU General Public License for more details. */ +#include "main.h" #include "list.h" #include "util.h" #include "args.h" @@ -20,20 +21,6 @@ #include #include -#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) - -/* The header that fwcutter puts in to every .fw file */ -struct fw_header { - /* Type of the firmware data */ - uint8_t type; - /* Version number of the firmware data format */ - uint8_t ver; - uint8_t __padding[2]; - /* Size of the data. For ucode and PCM this is in bytes. - * For IV this is in number-of-ivs. */ - uint32_t size; -} __attribute__ ((__packed__)); - struct bin_instruction { unsigned int opcode; @@ -699,11 +686,11 @@ static int read_input(struct disassembler_context *ctx) fprintf(stderr, "Corrupt input file (not fwcutter output)\n"); goto err_close; } - if (hdr.type != 'u') { + if (hdr.type != FW_TYPE_UCODE) { fprintf(stderr, "Corrupt input file. Not a microcode image.\n"); goto err_close; } - if (hdr.ver != 1) { + if (hdr.ver != FW_HDR_VER) { fprintf(stderr, "Invalid input file header version.\n"); goto err_close; } diff --git a/disassembler/main.h b/disassembler/main.h index d3ceb37..354d001 100644 --- a/disassembler/main.h +++ b/disassembler/main.h @@ -3,6 +3,28 @@ #include +#include "util.h" + + +/* The header that fwcutter also puts in to every .fw file */ +struct fw_header { + /* Type of the firmware data */ + uint8_t type; + /* Version number of the firmware data format */ + uint8_t ver; + uint8_t __padding[2]; + /* Size of the data. For ucode and PCM this is in bytes. + * For IV this is in number-of-ivs. (big-endian!) */ + be32_t size; +} __attribute__ ((__packed__)); + +/* struct fw_header -> type */ +#define FW_TYPE_UCODE 'u' +#define FW_TYPE_PCM 'p' +#define FW_TYPE_IV 'i' +/* struct fw_header -> ver */ +#define FW_HDR_VER 0x01 + FILE *infile; FILE *outfile; diff --git a/disassembler/util.h b/disassembler/util.h index 843d347..72dedf4 100644 --- a/disassembler/util.h +++ b/disassembler/util.h @@ -2,6 +2,10 @@ #define BCM43xx_DASM_UTIL_H_ #include +#include + + +#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) void dump(const char *data, @@ -13,4 +17,8 @@ void * xmalloc(size_t size); char * xstrdup(const char *str); void * xrealloc(void *in, size_t size); +typedef _Bool bool; + +typedef uint32_t be32_t; + #endif /* BCM43xx_DASM_UTIL_H_ */ -- 2.31.1