summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/jedparse.cpp
diff options
context:
space:
mode:
author Joakim Larsson Edström <joakimlarsson42@gmail.com>2020-01-31 09:50:18 +0100
committer GitHub <noreply@github.com>2020-01-31 09:50:18 +0100
commit7d5c59f6e507c3ee855014cbbf9a2e6f212057fd (patch)
tree5636d7e1ddd7f37ab43f8273397edbfd67ad3b92 /src/lib/util/jedparse.cpp
parentaecb7fa019c12f24fccd5d06c07bfb45c7acd214 (diff)
parent8f9e9c9e84f863527f1502f0a8b0ee46a659d227 (diff)
Merge pull request #6068 from JoakimLarsson/alfaskop_pla
Alfaskop improvements
Diffstat (limited to 'src/lib/util/jedparse.cpp')
-rw-r--r--src/lib/util/jedparse.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/util/jedparse.cpp b/src/lib/util/jedparse.cpp
index d25b35c3328..14cc503f18f 100644
--- a/src/lib/util/jedparse.cpp
+++ b/src/lib/util/jedparse.cpp
@@ -391,9 +391,24 @@ int jedbin_parse(const void *data, size_t length, jed_data *result)
/* first unpack the number of fuses */
result->numfuses = (cursrc[0] << 24) | (cursrc[1] << 16) | (cursrc[2] << 8) | cursrc[3];
cursrc += 4;
+
if (result->numfuses == 0 || result->numfuses > JED_MAX_FUSES)
return JEDERR_INVALID_DATA;
+ /* Detect DataIO binary format and prepare for conversion. This transformation is based on observation of an 82S100 dump */
+ if (result->numfuses == ((cursrc[0] << 24) | (cursrc[1] << 16) | (cursrc[2] << 8) | cursrc[3]))
+ {
+ result->numfuses = (result->numfuses - 9) * 8; // Double 32 bit byte file size header + trailing byte to Single 32 byte fuse count
+ cursrc = cursrc + 4; // Adjust start of buffer, trailing byte will not be copied below
+ result->binfmt = DATAIO; // DataIO also has swapped inverted/non-inverted line fuses so remember origin
+ if (LOG_PARSE) printf("DATAIO format detected\n");
+ }
+ else
+ {
+ result->binfmt = MAXLOADER; // This is the old format just set for completeness.
+ if (LOG_PARSE) printf("MAXLOADER format detected\n");
+ }
+
/* now make sure we have enough data in the source */
if (length < 4 + (result->numfuses + 7) / 8)
return JEDERR_INVALID_DATA;