From d4e2fbd306bf9f847fed16b9a9112eb6d8f56c8e Mon Sep 17 00:00:00 2001 From: fulivi Date: Mon, 9 Sep 2019 22:05:41 +0200 Subject: HP9845: TACO driver re-written (#5601) * hp9825: fixed a bug in 9825t * hp9845: TACO driver re-written from scratch, DC100 tape separated into a new device, various adaptations * hp9845: "new TACO" renamed to just "TACO" --- src/tools/imgtool/modules/hp85_tape.cpp | 36 ++++++++++++++++--------------- src/tools/imgtool/modules/hp9845_tape.cpp | 16 ++++++++------ 2 files changed, 29 insertions(+), 23 deletions(-) (limited to 'src/tools') diff --git a/src/tools/imgtool/modules/hp85_tape.cpp b/src/tools/imgtool/modules/hp85_tape.cpp index 599a2a43a92..dada87e290a 100644 --- a/src/tools/imgtool/modules/hp85_tape.cpp +++ b/src/tools/imgtool/modules/hp85_tape.cpp @@ -43,8 +43,8 @@ static constexpr tape_pos_t FMT_IFG_SIZE = 2.5 * hti_format_t::ONE_INCH_POS; // Formatted size of IRGs: 1" static constexpr tape_pos_t FMT_IRG_SIZE = hti_format_t::ONE_INCH_POS; -// Formatted size of records: 2.85" -static constexpr tape_pos_t FMT_REC_SIZE = 2.85 * hti_format_t::ONE_INCH_POS; +// Formatted size of records: 2.67" +static constexpr tape_pos_t FMT_REC_SIZE = 2.67 * hti_format_t::ONE_INCH_POS; // Starting position on tracks: 74" from beginning of tape static constexpr tape_pos_t TRACK_START = 74 * hti_format_t::ONE_INCH_POS; @@ -145,6 +145,7 @@ typedef struct { tape_image_85::tape_image_85(void) : dirty(false) { + image.set_bits_per_word(16); } void tape_image_85::format_img(void) @@ -263,22 +264,24 @@ bool tape_image_85::load_sif_file(file_no_t file_no , sif_file_t& out) if (!image.next_data(track , pos , true , false , it)) { break; } - // 0 Sync word - // 1 File word - // 2 Record word - // 3 Length word - // 4 Checksum - tape_word_t hdr[ 5 ]; - auto res = hti_format_t::ADV_CONT_DATA; - for (unsigned i = 0; i < 5; i++) { + unsigned bit_idx = 15; + if (!image.sync_with_record(track , it , bit_idx)) { + // Couldn't align + return false; + } + + // 0 File word + // 1 Record word + // 2 Length word + // 3 Checksum + tape_word_t hdr[ 4 ]; + for (unsigned i = 0; i < 4; i++) { + auto res = image.next_word(track , it , bit_idx , hdr[ i ]); if (res != hti_format_t::ADV_CONT_DATA) { return false; } - hdr[ i ] = it->second; - res = image.adv_it(track , true , it); } - if (hdr[ 0 ] != SYNC_WORD || - checksum(&hdr[ 1 ] , 3) != hdr[ 4 ]) { + if (checksum(&hdr[ 0 ] , 3) != hdr[ 3 ]) { return false; } @@ -287,7 +290,7 @@ bool tape_image_85::load_sif_file(file_no_t file_no , sif_file_t& out) bool hdr_has_body; unsigned hdr_body_len; - if (!dec_rec_header(&hdr[ 1 ] , hdr_file_no , hdr_rec_no , hdr_has_body , hdr_body_len)) { + if (!dec_rec_header(&hdr[ 0 ] , hdr_file_no , hdr_rec_no , hdr_has_body , hdr_body_len)) { return false; } @@ -304,11 +307,10 @@ bool tape_image_85::load_sif_file(file_no_t file_no , sif_file_t& out) tape_word_t body[ MAX_RECORD_SIZE / 2 + 1 ]; unsigned word_no = (hdr_body_len + 1) / 2 + 1; for (unsigned i = 0; i < word_no; i++) { + auto res = image.next_word(track , it , bit_idx , body[ i ]); if (res != hti_format_t::ADV_CONT_DATA) { return false; } - body[ i ] = it->second; - res = image.adv_it(track , true , it); } if (checksum(&body[ 0 ] , word_no - 1) != body[ word_no - 1 ]) { return false; diff --git a/src/tools/imgtool/modules/hp9845_tape.cpp b/src/tools/imgtool/modules/hp9845_tape.cpp index b7edf371f88..d3416deaefd 100644 --- a/src/tools/imgtool/modules/hp9845_tape.cpp +++ b/src/tools/imgtool/modules/hp9845_tape.cpp @@ -148,10 +148,10 @@ #define BYTES_AVAILABLE_MASK 0xff00 // Mask of "bytes available" field #define BYTES_USED 0x00ff // "bytes used" field = 256 #define BYTES_USED_MASK 0x00ff // Mask of "bytes used" field -#define FORMAT_SECT_SIZE ((tape_pos_t)(2.85 * hti_format_t::ONE_INCH_POS)) // Size of sectors including padding: 2.85" -#define PREAMBLE_WORD 0 // Value of preamble word +#define FORMAT_SECT_SIZE ((tape_pos_t)(2.67 * hti_format_t::ONE_INCH_POS)) // Size of sectors including padding: 2.67" +#define PREAMBLE_WORD 0x0001 // Value of preamble word #define WORDS_PER_HEADER_N_SECTOR (WORDS_PER_SECTOR + 5) -#define MIN_IRG_SIZE ((tape_pos_t)(0.066 * hti_format_t::ONE_INCH_POS)) // Minimum size of IRG gaps: 0.066" +#define MIN_IRG_SIZE ((tape_pos_t)(16 * 1024)) // Minimum size of IRG gaps: 0.017" // File types #define BKUP_FILETYPE 0 @@ -324,6 +324,7 @@ static const struct io_procs my_stream_procs = { imgtoolerr_t tape_image_t::load_from_file(imgtool::stream *stream) { hti_format_t inp_image; + inp_image.set_bits_per_word(16); io_generic io; io.file = (void *)stream; @@ -357,16 +358,19 @@ imgtoolerr_t tape_image_t::load_from_file(imgtool::stream *stream) } if (state == 1) { // Extract record data - if (it->second != PREAMBLE_WORD) { + + // The top 8 bits are ignored by TACO when aligning with preamble + unsigned bit_idx = 7; + if (!inp_image.sync_with_record(track , it , bit_idx)) { + // Couldn't align return IMGTOOLERR_CORRUPTIMAGE; } tape_word_t buffer[ WORDS_PER_HEADER_N_SECTOR ]; for (unsigned i = 0; i < WORDS_PER_HEADER_N_SECTOR; i++) { - auto res = inp_image.adv_it(track , true , it); + auto res = inp_image.next_word(track , it , bit_idx , buffer[ i ]); if (res != hti_format_t::ADV_CONT_DATA) { return IMGTOOLERR_CORRUPTIMAGE; } - buffer[ i ] = it->second; } if (buffer[ 3 ] != checksum(&buffer[ 0 ], 3) || buffer[ 4 + WORDS_PER_SECTOR ] != checksum(&buffer[ 4 ], WORDS_PER_SECTOR)) { -- cgit v1.2.3