aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2021-06-03 13:25:47 -0700
committerH. Peter Anvin <hpa@zytor.com>2021-06-03 13:28:59 -0700
commit5bdcb3b9271e7145ce08ee04de3d0ecfd202cf48 (patch)
tree8345d1c0426edd7fae782e43fa2e9369c2b9b086
parentb72a4361929c4167a33dda04f4c7796d5c542f26 (diff)
downloadabc80sim-5bdcb3b9271e7145ce08ee04de3d0ecfd202cf48.tar.gz
abc80sim-5bdcb3b9271e7145ce08ee04de3d0ecfd202cf48.tar.xz
abc80sim-5bdcb3b9271e7145ce08ee04de3d0ecfd202cf48.zip
meg80: better options handling, default to 16K
Use "flash" and "system" just like the switch says. In a meg80 system it is probably more common to have 16K, so make that the default.
-rw-r--r--abcmem.c21
-rw-r--r--compiler.h4
2 files changed, 15 insertions, 10 deletions
diff --git a/abcmem.c b/abcmem.c
index 168a0f7..edd695b 100644
--- a/abcmem.c
+++ b/abcmem.c
@@ -781,7 +781,7 @@ void abc80_sram_out(uint16_t addr, uint8_t val)
}
/*
- * Initialize SRAM/flash card if present
+ * Initialize MEG80 SRAM/flash card if present
*/
static int init_sram(void)
{
@@ -826,16 +826,17 @@ static int init_sram(void)
kb[ikb++] = 0;
else
err = true;
- } else if (olen == 4 && !memcmp(srp, "boot", 4)) {
+ } else if (isstr("flash", srp, olen)) {
bootmap = 17; /* Flash boot */
- } else if ((olen == 5 && !memcmp(srp, "flash", 5)) ||
- (olen == 2 && !memcmp(srp, "we", 2))) {
+ } else if (isstr("system", srp, olen)) {
+ bootmap = 0; /* System boot */
+ } else if (isstr("we", srp, olen)) {
sram_ic3 = IC3_FLASH;
- } else if ((olen == 3 && !memcmp(srp, "rom", 3)) ||
- (olen == 2 && !memcmp(srp, "wp", 2))) {
+ } else if (isstr("rom", srp, olen) ||
+ isstr("wp", srp, olen)) {
sram_ic3 = IC3_ROM;
- } else if ((olen == 3 && !memcmp(srp, "ram", 3)) ||
- (olen == 4 && !memcmp(srp, "sram", 4))) {
+ } else if (isstr("ram", srp, olen) ||
+ isstr("sram", srp, olen)) {
sram_ic3 = IC3_RAM;
} else {
err = true;
@@ -1013,8 +1014,8 @@ void mem_init(unsigned int flags, const char *memfile)
if (sram_status < 0) {
opts.sram = false;
} else {
- if (opts.kb > 32)
- opts.kb = 32;
+ if (opts.kb == 64)
+ opts.kb = 16;
init_map = sram_status;
}
}
diff --git a/compiler.h b/compiler.h
index af902a8..716a1a4 100644
--- a/compiler.h
+++ b/compiler.h
@@ -298,4 +298,8 @@ static inline uint64_t umulh(uint64_t a, uint64_t b)
}
#endif
+/* Handy macro for comparing a partial string against a string constant */
+#define isstr(str,ptr,len) \
+ ((size_t)(len) == sizeof(str)-1 && !memcmp(str, (ptr), sizeof(str)-1))
+
#endif /* COMPILER_H */