root/src/simh/sim_tape.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * sim_tape.h: simulator tape support library definitions
   3  *
   4  * vim: filetype=c:tabstop=4:ai:expandtab
   5  * SPDX-License-Identifier: X11
   6  * scspell-id: d97f7d4a-f62a-11ec-baa0-80ee73e9b8e7
   7  *
   8  * ---------------------------------------------------------------------------
   9  *
  10  * Copyright (c) 1993-2008 Robert M. Supnik
  11  * Copyright (c) 2021-2022 The DPS8M Development Team
  12  *
  13  * Permission is hereby granted, free of charge, to any person obtaining a
  14  * copy of this software and associated documentation files (the "Software"),
  15  * to deal in the Software without restriction, including without limitation
  16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  17  * and/or sell copies of the Software, and to permit persons to whom the
  18  * Software is furnished to do so, subject to the following conditions:
  19  *
  20  * The above copyright notice and this permission notice shall be included
  21  * in all copies or substantial portions of the Software.
  22  *
  23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  26  * IN NO EVENT SHALL ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR
  27  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  28  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  29  * OTHER DEALINGS IN THE SOFTWARE.
  30  *
  31  * Except as contained in this notice, the name of Robert M. Supnik shall
  32  * not be used in advertising or otherwise to promote the sale, use or
  33  * other dealings in this Software without prior written authorization from
  34  * Robert M. Supnik.
  35  *
  36  * ---------------------------------------------------------------------------
  37  */
  38 
  39 #ifndef SIM_TAPE_H_
  40 # define SIM_TAPE_H_    0
  41 
  42 /* SIMH/E11 tape format */
  43 
  44 typedef uint32          t_mtrlnt;                       /* magtape rec lnt */
  45 
  46 # define MTR_TMK         0x00000000                      /* tape mark */
  47 # define MTR_EOM         0xFFFFFFFF                      /* end of medium */
  48 # define MTR_GAP         0xFFFFFFFE                      /* primary gap */
  49 # define MTR_RRGAP       0xFFFFFFFF                      /* reverse read half gap */
  50 # define MTR_FHGAP       0xFFFEFFFF                      /* fwd half gap (overwrite) */
  51 # define MTR_RHGAP       0xFFFF0000                      /* rev half gap (overwrite) */
  52 # define MTR_M_RHGAP     (~0x000080FF)                   /* range mask for rev gap */
  53 # define MTR_MAXLEN      0x00FFFFFF                      /* max len is 24b */
  54 # define MTR_ERF         0x80000000                      /* error flag */
  55 # define MTR_F(x)        ((x) & MTR_ERF)                 /* record error flg */
  56 # define MTR_L(x)        ((x) & ~MTR_ERF)                /* record length */
  57 
  58 /* TPC tape format */
  59 
  60 typedef uint16          t_tpclnt;                       /* magtape rec lnt */
  61 
  62 /* P7B tape format */
  63 
  64 # define P7B_SOR         0x80                            /* start of record */
  65 # define P7B_PAR         0x40                            /* parity */
  66 # define P7B_DATA        0x3F                            /* data */
  67 # define P7B_DPAR        (P7B_PAR|P7B_DATA)              /* data and parity */
  68 # define P7B_EOF         0x0F                            /* eof character */
  69 
  70 # define TPC_TMK         0x0000                          /* tape mark */
  71 
  72 /* Unit flags */
  73 
  74 # define MTUF_V_PNU      (UNIT_V_UF + 0)                 /* position not upd */
  75 # define MTUF_V_WLK      (UNIT_V_UF + 1)                 /* write locked */
  76 # define MTUF_V_FMT      (UNIT_V_UF + 2)                 /* tape file format */
  77 # define MTUF_W_FMT      3                               /* 3b of formats */
  78 # define MTUF_N_FMT      (1u << MTUF_W_FMT)              /* number of formats */
  79 # define MTUF_M_FMT      ((1u << MTUF_W_FMT) - 1)
  80 # define MTUF_F_STD       0                              /* SIMH format */
  81 # define MTUF_F_E11       1                              /* E11 format */
  82 # define MTUF_F_TPC       2                              /* TPC format */
  83 # define MTUF_F_P7B       3                              /* P7B format */
  84 # define MUTF_F_TDF       4                              /* TDF format */
  85 # define MTUF_V_UF       (MTUF_V_FMT + MTUF_W_FMT)
  86 # define MTUF_PNU        (1u << MTUF_V_PNU)
  87 # define MTUF_WLK        (1u << MTUF_V_WLK)
  88 # define MTUF_FMT        (MTUF_M_FMT << MTUF_V_FMT)
  89 # define MTUF_WRP        (MTUF_WLK | UNIT_RO)
  90 
  91 # define MT_F_STD        (MTUF_F_STD << MTUF_V_FMT)
  92 # define MT_F_E11        (MTUF_F_E11 << MTUF_V_FMT)
  93 # define MT_F_TPC        (MTUF_F_TPC << MTUF_V_FMT)
  94 # define MT_F_P7B        (MTUF_F_P7B << MTUF_V_FMT)
  95 # define MT_F_TDF        (MTUF_F_TDF << MTUF_V_FMT)
  96 
  97 # define MT_SET_PNU(u)   (u)->flags = (u)->flags | MTUF_PNU
  98 # define MT_CLR_PNU(u)   (u)->flags = (u)->flags & ~MTUF_PNU
  99 # define MT_TST_PNU(u)   ((u)->flags & MTUF_PNU)
 100 # define MT_GET_FMT(u)   (((u)->flags >> MTUF_V_FMT) & MTUF_M_FMT)
 101 
 102 /* sim_tape_position Position Flags */
 103 # define MTPOS_V_REW     3
 104 # define MTPOS_M_REW     (1u << MTPOS_V_REW)            /* Rewind First */
 105 # define MTPOS_V_REV     2
 106 # define MTPOS_M_REV     (1u << MTPOS_V_REV)            /* Reverse Direction */
 107 # define MTPOS_V_OBJ     1
 108 # define MTPOS_M_OBJ     (1u << MTPOS_V_OBJ)            /* Objects vs Records/Files */
 109 # define MTPOS_V_DLE     4
 110 # define MTPOS_M_DLE     (1u << MTPOS_V_DLE)            /* Detect LEOT */
 111 
 112 /* Tape density values */
 113 
 114 # define MT_DENS_NONE    0                               /* density not set */
 115 # define MT_DENS_200     1                               /* 200 bpi NRZI */
 116 # define MT_DENS_556     2                               /* 556 bpi NRZI */
 117 # define MT_DENS_800     3                               /* 800 bpi NRZI */
 118 # define MT_DENS_1600    4                               /* 1600 bpi PE */
 119 # define MT_DENS_6250    5                               /* 6250 bpi GCR */
 120 
 121 # define MTVF_DENS_MASK  (((1u << UNIT_S_DF_TAPE) - 1) << UNIT_V_DF_TAPE)
 122 # define MT_DENS(f)      (((f) & MTVF_DENS_MASK) >> UNIT_V_DF_TAPE)
 123 
 124 # define MT_NONE_VALID   (1u << MT_DENS_NONE)            /* density not set is valid */
 125 # define MT_200_VALID    (1u << MT_DENS_200)             /* 200 bpi is valid */
 126 # define MT_556_VALID    (1u << MT_DENS_556)             /* 556 bpi is valid */
 127 # define MT_800_VALID    (1u << MT_DENS_800)             /* 800 bpi is valid */
 128 # define MT_1600_VALID   (1u << MT_DENS_1600)            /* 1600 bpi is valid */
 129 # define MT_6250_VALID   (1u << MT_DENS_6250)            /* 6250 bpi is valid */
 130 
 131 /* Return status codes */
 132 
 133 # define MTSE_OK         0                               /* no error */
 134 # define MTSE_TMK        1                               /* tape mark */
 135 # define MTSE_UNATT      2                               /* unattached */
 136 # define MTSE_IOERR      3                               /* IO error */
 137 # define MTSE_INVRL      4                               /* invalid rec lnt */
 138 # define MTSE_FMT        5                               /* invalid format */
 139 # define MTSE_BOT        6                               /* beginning of tape */
 140 # define MTSE_EOM        7                               /* end of medium */
 141 # define MTSE_RECE       8                               /* error in record */
 142 # define MTSE_WRP        9                               /* write protected */
 143 # define MTSE_LEOT       10                              /* Logical End Of Tape */
 144 # define MTSE_RUNAWAY    11                              /* tape runaway */
 145 
 146 typedef void (*TAPE_PCALLBACK)(UNIT *unit, t_stat status);
 147 
 148 /* Tape Internal Debug flags */
 149 
 150 # define MTSE_DBG_DAT   0x0400000                        /* Debug Data */
 151 # define MTSE_DBG_POS   0x0800000                        /* Debug Positioning activities */
 152 # define MTSE_DBG_STR   0x1000000                        /* Debug Tape Structure */
 153 
 154 /* Prototypes */
 155 
 156 t_stat sim_tape_attach_ex (UNIT *uptr, const char *cptr, uint32 dbit, int completion_delay);
 157 t_stat sim_tape_attach (UNIT *uptr, CONST char *cptr);
 158 t_stat sim_tape_detach (UNIT *uptr);
 159 t_stat sim_tape_attach_help(FILE *st, DEVICE *dptr, const UNIT *uptr, int32 flag, const char *cptr);
 160 t_stat sim_tape_rdrecf (UNIT *uptr, uint8 *buf, t_mtrlnt *bc, t_mtrlnt max);
 161 t_stat sim_tape_rdrecf_a (UNIT *uptr, uint8 *buf, t_mtrlnt *bc, t_mtrlnt max, TAPE_PCALLBACK callback);
 162 t_stat sim_tape_rdrecr (UNIT *uptr, uint8 *buf, t_mtrlnt *bc, t_mtrlnt max);
 163 t_stat sim_tape_rdrecr_a (UNIT *uptr, uint8 *buf, t_mtrlnt *bc, t_mtrlnt max, TAPE_PCALLBACK callback);
 164 t_stat sim_tape_wrrecf (UNIT *uptr, uint8 *buf, t_mtrlnt bc);
 165 t_stat sim_tape_wrrecf_a (UNIT *uptr, uint8 *buf, t_mtrlnt bc, TAPE_PCALLBACK callback);
 166 t_stat sim_tape_wrtmk (UNIT *uptr);
 167 t_stat sim_tape_wrtmk_a (UNIT *uptr, TAPE_PCALLBACK callback);
 168 t_stat sim_tape_wreom (UNIT *uptr);
 169 t_stat sim_tape_wreom_a (UNIT *uptr, TAPE_PCALLBACK callback);
 170 t_stat sim_tape_wreomrw (UNIT *uptr);
 171 t_stat sim_tape_wreomrw_a (UNIT *uptr, TAPE_PCALLBACK callback);
 172 t_stat sim_tape_wrgap (UNIT *uptr, uint32 gaplen);
 173 t_stat sim_tape_wrgap_a (UNIT *uptr, uint32 gaplen, TAPE_PCALLBACK callback);
 174 t_stat sim_tape_sprecf (UNIT *uptr, t_mtrlnt *bc);
 175 t_stat sim_tape_sprecf_a (UNIT *uptr, t_mtrlnt *bc, TAPE_PCALLBACK callback);
 176 t_stat sim_tape_sprecsf (UNIT *uptr, uint32 count, uint32 *skipped);
 177 t_stat sim_tape_sprecsf_a (UNIT *uptr, uint32 count, uint32 *skipped, TAPE_PCALLBACK callback);
 178 t_stat sim_tape_spfilef (UNIT *uptr, uint32 count, uint32 *skipped);
 179 t_stat sim_tape_spfilef_a (UNIT *uptr, uint32 count, uint32 *skipped, TAPE_PCALLBACK callback);
 180 t_stat sim_tape_spfilebyrecf (UNIT *uptr, uint32 count, uint32 *skipped, uint32 *recsskipped, t_bool check_leot);
 181 t_stat sim_tape_spfilebyrecf_a (UNIT *uptr, uint32 count, uint32 *skipped, uint32 *recsskipped, t_bool check_leot, TAPE_PCALLBACK callback);
 182 t_stat sim_tape_sprecr (UNIT *uptr, t_mtrlnt *bc);
 183 t_stat sim_tape_sprecr_a (UNIT *uptr, t_mtrlnt *bc, TAPE_PCALLBACK callback);
 184 t_stat sim_tape_sprecsr (UNIT *uptr, uint32 count, uint32 *skipped);
 185 t_stat sim_tape_sprecsr_a (UNIT *uptr, uint32 count, uint32 *skipped, TAPE_PCALLBACK callback);
 186 t_stat sim_tape_spfiler (UNIT *uptr, uint32 count, uint32 *skipped);
 187 t_stat sim_tape_spfiler_a (UNIT *uptr, uint32 count, uint32 *skipped, TAPE_PCALLBACK callback);
 188 t_stat sim_tape_spfilebyrecr (UNIT *uptr, uint32 count, uint32 *skipped, uint32 *recsskipped);
 189 t_stat sim_tape_spfilebyrecr_a (UNIT *uptr, uint32 count, uint32 *skipped, uint32 *recsskipped, TAPE_PCALLBACK callback);
 190 t_stat sim_tape_rewind (UNIT *uptr);
 191 t_stat sim_tape_rewind_a (UNIT *uptr, TAPE_PCALLBACK callback);
 192 t_stat sim_tape_position (UNIT *uptr, uint32 flags, uint32 recs, uint32 *recskipped, uint32 files, uint32 *fileskipped, uint32 *objectsskipped);
 193 t_stat sim_tape_position_a (UNIT *uptr, uint32 flags, uint32 recs, uint32 *recsskipped, uint32 files, uint32 *filesskipped, uint32 *objectsskipped, TAPE_PCALLBACK callback);
 194 t_stat sim_tape_reset (UNIT *uptr);
 195 t_bool sim_tape_bot (UNIT *uptr);
 196 t_bool sim_tape_wrp (UNIT *uptr);
 197 t_bool sim_tape_eot (UNIT *uptr);
 198 t_stat sim_tape_set_fmt (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
 199 t_stat sim_tape_show_fmt (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
 200 t_stat sim_tape_set_capac (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
 201 t_stat sim_tape_show_capac (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
 202 t_stat sim_tape_set_dens (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
 203 t_stat sim_tape_show_dens (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
 204 
 205 #endif

/* [previous][next][first][last][top][bottom][index][help] */