summaryrefslogtreecommitdiffstats
path: root/src/lib/util/jedparse.cpp
diff options
context:
space:
mode:
author Joakim Larsson Edstrom <Joakim.Edstrom@edstromious.se>2019-12-18 12:45:01 +0100
committer Joakim Larsson Edstrom <Joakim.Edstrom@edstromious.se>2019-12-18 12:45:01 +0100
commit88b532d28a58092ab67108b91f2f780819b01d4f (patch)
tree4ad8bc3944ca57dc6c5b7accac40c4e66b0bbf0c /src/lib/util/jedparse.cpp
parente1c7a3b69be7d6fbf6c5b1c649af841179e9076c (diff)
pla.cpp, jedparse, jedutil: Added recognition and some support for alternative PLA binary format DataIO
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 c2c9a139a6a..f7b252861a2 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;