Signed-off-by: Michael Buesch <mb@bu3sch.de>
int _debug;
bool arg_print_sizes;
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
#define ARG_MATCH 0
#define ARG_NOMATCH 1
static int do_cmp_arg(char **argv, int *pos,
const char *template,
int allow_merged,
static int do_cmp_arg(char **argv, int *pos,
const char *template,
int allow_merged,
{
char *arg;
char *next_arg;
{
char *arg;
char *next_arg;
static int cmp_arg(char **argv, int *pos,
const char *long_template,
const char *short_template,
static int cmp_arg(char **argv, int *pos,
const char *long_template,
const char *short_template,
static void usage(int argc, char **argv)
{
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)
}
int parse_args(int argc, char **argv)
_debug++;
} else if ((res = cmp_arg(argv, &i, "--psize", "-s", 0)) == ARG_MATCH) {
arg_print_sizes = 1;
_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;
}
}
} 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);
return 0;
out_usage:
usage(argc, argv);
extern int _debug;
extern bool arg_print_sizes;
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)
#define IS_DEBUG (_debug > 0)
#define IS_VERBOSE_DEBUG (_debug > 1)
-$CPP -x c++ -traditional-cpp "$infile" | $B43_ASM "-" "$outfile" $@
+$CPP -x c++ -traditional-cpp "$infile" | $B43_ASM "-" "$outfile" --__real_infile "$infile" $@
hdr.ver = FW_HDR_VER;
hdr.size = cpu_to_be32(ctx->ivals_count);
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;
- 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);
fd = fopen(fn, "w+");
if (!fd) {
fprintf(stderr, "Could not open initval output file \"%s\"\n", fn);
static void emit_code(struct assembler_context *ctx)
{
FILE *fd;
static void emit_code(struct assembler_context *ctx)
{
FILE *fd;
- char *fn;
- size_t fn_len;
struct code_output *c;
uint64_t code;
unsigned char outbuf[8];
unsigned int insn_count = 0;
struct fw_header hdr;
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);
fd = fopen(fn, "w+");
if (!fd) {
fprintf(stderr, "Could not open microcode output file \"%s\"\n", fn);
fd = fopen(fn, "w+");
if (!fd) {
fprintf(stderr, "Could not open microcode output file \"%s\"\n", fn);
exit(1);
}
if (IS_VERBOSE_DEBUG)
exit(1);
}
if (IS_VERBOSE_DEBUG)
}
static void assemble(void)
}
static void assemble(void)