summaryrefslogtreecommitdiff
path: root/src/satmkboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/satmkboot.c')
-rw-r--r--src/satmkboot.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/satmkboot.c b/src/satmkboot.c
index 2b7f308..7faaf4c 100644
--- a/src/satmkboot.c
+++ b/src/satmkboot.c
@@ -13,7 +13,7 @@ static struct systemid sysid = {
.version = "V0.001",
.reldate = "20000101",
.device = "CD-1/1 ",
- .regions = "JTUBKAEL ",
+ .regions = " ",
.peripherals = "J ",
.bootsize = 0xe00,
.stack_master = 0,
@@ -107,27 +107,49 @@ fail:
return -1;
}
+static int append_symbol(char *list, size_t size, char symbol)
+{
+ for (size_t i = 0; i < size; i++) {
+ if (list[i] == ' ')
+ list[i] = symbol;
+ if (list[i] == symbol)
+ return 0;
+ }
+ return -1;
+}
+
+static void print_symbols(FILE *fp, int width, const struct symbolname *symbols)
+{
+ for (; symbols->symbol; symbols++) {
+ fprintf(fp, "\t%*s%c: %s\n", width+4, "", symbols->symbol, symbols->name);
+ }
+}
+
static void usage(const char *progname)
{
const int width = 20;
- fprintf(stderr, "usage: %s -h\n", progname);
- fprintf(stderr, " %s -io\n\n", progname);
+ fprintf(stderr, "usage: %s -h\n", progname);
+ fprintf(stderr, " %s -io[r]\n\n", progname);
fprintf(stderr, "\t%-*s%s\n", width, "-h", "Show this help text");
fprintf(stderr, "\t%-*s%s\n", width, "-i ip.bin", "Initial program code file");
fprintf(stderr, "\t%-*s%s\n", width, "-o output", "Output file");
+ fprintf(stderr, "\t%-*s%s\n", width, "-r regions", "Geographical regions (default all):");
+ print_symbols(stderr, width, regiondefs);
}
#define ERR_UNKNOWN_OPTION 0
#define ERR_MISSING_OPTION 1
#define ERR_DUPLICATE_INPUT 2
#define ERR_DUPLICATE_OUTPUT 3
+#define ERR_REGION_OVERFLOW 4
static const char *errmsgs[] = {
"Unknown extra argument",
"Missing required option",
"Duplicate -i parameter",
"Duplicate -o parameter",
+ "Too many regions specified (max 10)",
};
static int show_arg_error(const char *progname, int prev_errors, int error)
@@ -144,7 +166,7 @@ static int process_args(int argc, char **argv)
extern char *optarg;
extern int optind, optopt;
- while ((opt = getopt(argc, argv, "hi:o:")) != -1) {
+ while ((opt = getopt(argc, argv, "hi:o:r:")) != -1) {
switch (opt) {
case 'h':
help = 1;
@@ -164,6 +186,14 @@ static int process_args(int argc, char **argv)
outfile = optarg;
break;
+ case 'r':
+ for (; *optarg; optarg++) {
+ if (append_symbol(sysid.regions, sizeof sysid.regions, *optarg)) {
+ errors = show_arg_error(argv[0], errors, ERR_REGION_OVERFLOW);
+ break;
+ }
+ }
+ break;
default:
fail = 1;
@@ -197,6 +227,7 @@ int main(int argc, char **argv)
return 1;
}
+ if (sysid.regions[0] == ' ') strcpy(sysid.regions, "JTUBKAEL");
for (int i = 0; i < 10 && sysid.regions[i] != ' '; i++) {
const struct symbolname *region = find_symbol(regiondefs, sysid.regions[i]);
if (region) ipout = serialize_region_code(ipout, region);