summaryrefslogtreecommitdiff
path: root/src/satmkboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/satmkboot.c')
-rw-r--r--src/satmkboot.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/src/satmkboot.c b/src/satmkboot.c
index 7faaf4c..d3b5958 100644
--- a/src/satmkboot.c
+++ b/src/satmkboot.c
@@ -14,7 +14,7 @@ static struct systemid sysid = {
.reldate = "20000101",
.device = "CD-1/1 ",
.regions = " ",
- .peripherals = "J ",
+ .peripherals = " ",
.bootsize = 0xe00,
.stack_master = 0,
.stack_slave = 0,
@@ -130,19 +130,22 @@ static void usage(const char *progname)
const int width = 20;
fprintf(stderr, "usage: %s -h\n", progname);
- fprintf(stderr, " %s -io[r]\n\n", progname);
+ fprintf(stderr, " %s -io[pr]\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):");
+ fprintf(stderr, "\t%-*s%s\n", width, "-p peripherals", "Supported peripherals (default: control pad):");
+ print_symbols(stderr, width, peripheraldefs);
+ 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
+#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
+#define ERR_PERIPHERAL_OVERFLOW 5
static const char *errmsgs[] = {
"Unknown extra argument",
@@ -150,6 +153,7 @@ static const char *errmsgs[] = {
"Duplicate -i parameter",
"Duplicate -o parameter",
"Too many regions specified (max 10)",
+ "Too many peripherals specified (max 16)",
};
static int show_arg_error(const char *progname, int prev_errors, int error)
@@ -159,6 +163,16 @@ static int show_arg_error(const char *progname, int prev_errors, int error)
return prev_errors | 1 << error;
}
+static void process_symbols(const char *progname, char *list, size_t size, const char *arg, int *errors, int overflow)
+{
+ for (; *arg; arg++) {
+ if (append_symbol(list, size, *arg)) {
+ *errors = show_arg_error(progname, *errors, overflow);
+ return;
+ }
+ }
+}
+
static int process_args(int argc, char **argv)
{
int errors = 0, fail = 0, help = 0;
@@ -166,7 +180,7 @@ static int process_args(int argc, char **argv)
extern char *optarg;
extern int optind, optopt;
- while ((opt = getopt(argc, argv, "hi:o:r:")) != -1) {
+ while ((opt = getopt(argc, argv, "hi:o:r:p:")) != -1) {
switch (opt) {
case 'h':
help = 1;
@@ -186,13 +200,12 @@ static int process_args(int argc, char **argv)
outfile = optarg;
break;
+ case 'p':
+ process_symbols(argv[0], sysid.peripherals, sizeof sysid.peripherals, optarg, &errors, ERR_PERIPHERAL_OVERFLOW);
+ 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;
- }
- }
+ process_symbols(argv[0], sysid.regions, sizeof sysid.regions, optarg, &errors, ERR_REGION_OVERFLOW);
break;
default:
@@ -227,7 +240,9 @@ int main(int argc, char **argv)
return 1;
}
- if (sysid.regions[0] == ' ') strcpy(sysid.regions, "JTUBKAEL");
+ if (sysid.regions[0] == ' ') strcpy(sysid.regions, "JTUBKAEL");
+ if (sysid.peripherals[0] == ' ') sysid.peripherals[0] = 'J';
+
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);