Commit ff7327cd authored by Michael Büsch's avatar Michael Büsch

b43-asm: Change the filenames of the binaries.

Signed-off-by: Michael Büsch's avatarMichael Buesch <mb@bu3sch.de>
parent e882e360
......@@ -24,6 +24,9 @@
int _debug;
bool arg_print_sizes;
const char *initvals_fn_extension = ".initvals";
const char *real_infile_name;
#define ARG_MATCH 0
#define ARG_NOMATCH 1
......@@ -32,7 +35,7 @@ bool arg_print_sizes;
static int do_cmp_arg(char **argv, int *pos,
const char *template,
int allow_merged,
char **param)
const char **param)
{
char *arg;
char *next_arg;
......@@ -76,7 +79,7 @@ static int do_cmp_arg(char **argv, int *pos,
static int cmp_arg(char **argv, int *pos,
const char *long_template,
const char *short_template,
char **param)
const char **param)
{
int err;
......@@ -93,11 +96,12 @@ static int cmp_arg(char **argv, int *pos,
static void usage(int argc, char **argv)
{
fprintf(stderr, "Usage: %s INPUT_FILE OUTPUT_FILE [OPTIONS]\n", argv[0]);
fprintf(stderr, " -h|--help Print this help\n");
fprintf(stderr, " -d|--debug Print verbose debugging info\n");
fprintf(stderr, " Repeat for more verbose debugging\n");
fprintf(stderr, " -s|--psize Print the size of the code after assembling\n");
printf("Usage: %s INPUT_FILE OUTPUT_FILE [OPTIONS]\n", argv[0]);
printf(" -h|--help Print this help\n");
printf(" -d|--debug Print verbose debugging info\n");
printf(" Repeat for more verbose debugging\n");
printf(" -s|--psize Print the size of the code after assembling\n");
printf(" -e|--ivalext EXT Filename extension for the initvals\n");
}
int parse_args(int argc, char **argv)
......@@ -118,11 +122,22 @@ int parse_args(int argc, char **argv)
_debug++;
} else if ((res = cmp_arg(argv, &i, "--psize", "-s", 0)) == ARG_MATCH) {
arg_print_sizes = 1;
} else if ((res = cmp_arg(argv, &i, "--ivalext", "-e", &initvals_fn_extension)) == ARG_MATCH) {
/* initvals_fn_extension is set to the extension. */
} else if ((res = cmp_arg(argv, &i, "--__real_infile", 0, &real_infile_name)) == ARG_MATCH) {
/* real_infile_name is set. */
} else {
fprintf(stderr, "Unrecognized argument: %s\n", argv[i]);
goto out_usage;
}
}
if (!real_infile_name)
real_infile_name = infile_name;
if (strcmp(real_infile_name, outfile_name) == 0) {
fprintf(stderr, "Error: INPUT and OUTPUT filename must not be the same\n");
goto out_usage;
}
return 0;
out_usage:
usage(argc, argv);
......
......@@ -10,6 +10,7 @@ void close_input_file(void);
extern int _debug;
extern bool arg_print_sizes;
extern const char *initvals_fn_extension;
#define IS_DEBUG (_debug > 0)
#define IS_VERBOSE_DEBUG (_debug > 1)
......
......@@ -48,4 +48,4 @@ if [ "$infile" != "-" ]; then
fi
fi
$CPP -x c++ -traditional-cpp "$infile" | $B43_ASM "-" "$outfile" $@
$CPP -x c++ -traditional-cpp "$infile" | $B43_ASM "-" "$outfile" --__real_infile "$infile" $@
......@@ -283,9 +283,9 @@ static void emit_ival_section(struct ivals_context *ctx)
hdr.ver = FW_HDR_VER;
hdr.size = cpu_to_be32(ctx->ivals_count);
fn_len = strlen(outfile_name) + 512;
fn_len = strlen(ctx->sect->name) + strlen(initvals_fn_extension ? : "") + 1;
fn = xmalloc(fn_len);
snprintf(fn, fn_len, "%s.%s.initvals", outfile_name, ctx->sect->name);
snprintf(fn, fn_len, "%s%s", ctx->sect->name, initvals_fn_extension ? : "");
fd = fopen(fn, "w+");
if (!fd) {
fprintf(stderr, "Could not open initval output file \"%s\"\n", fn);
......
......@@ -1026,21 +1026,17 @@ does_not_exist:
static void emit_code(struct assembler_context *ctx)
{
FILE *fd;
char *fn;
size_t fn_len;
const char *fn;
struct code_output *c;
uint64_t code;
unsigned char outbuf[8];
unsigned int insn_count = 0;
struct fw_header hdr;
fn_len = strlen(outfile_name) + 20;
fn = xmalloc(fn_len);
snprintf(fn, fn_len, "%s.ucode", outfile_name);
fn = outfile_name;
fd = fopen(fn, "w+");
if (!fd) {
fprintf(stderr, "Could not open microcode output file \"%s\"\n", fn);
free(fn);
exit(1);
}
if (IS_VERBOSE_DEBUG)
......@@ -1132,7 +1128,6 @@ static void emit_code(struct assembler_context *ctx)
}
fclose(fd);
free(fn);
}
static void assemble(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment