home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Boot_Images / 2.11_on_rl02 / pdpsim.tz / pdpsim / nova_tt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-29  |  5.1 KB  |  190 lines

  1. /* nova_tt.c: NOVA console terminal simulator
  2.  
  3.    Copyright (c) 1993, 1994, 1995,
  4.    Robert M Supnik, Digital Equipment Corporation
  5.    Commercial use prohibited
  6.  
  7.    tti        terminal input
  8.    tto        terminal output
  9. */
  10.  
  11. #include "nova_defs.h"
  12.  
  13. #define    UNIT_V_DASHER    (UNIT_V_UF + 0)            /* Dasher mode */
  14. #define UNIT_DASHER    (1 << UNIT_V_DASHER)
  15. extern int int_req, dev_busy, dev_done, dev_disable;
  16. int tti_svc (UNIT *uptr);
  17. int tto_svc (UNIT *uptr);
  18. int tti_reset (DEVICE *dptr);
  19. int tto_reset (DEVICE *dptr);
  20. int ttx_setmod (UNIT *uptr, int value);
  21. extern int sim_activate (UNIT *uptr, int interval);
  22. extern int sim_cancel (UNIT *uptr);
  23. extern int sim_poll_kbd (void);
  24. extern int sim_type_tty (char out);
  25.  
  26. /* TTI data structures
  27.  
  28.    tti_dev    TTI device descriptor
  29.    tti_unit    TTI unit descriptor
  30.    tti_reg    TTI register list
  31.    ttx_mod    TTI/TTO modifiers list
  32. */
  33.  
  34. UNIT tti_unit = { UDATA (&tti_svc, 0, 0), KBD_POLL_WAIT };
  35.  
  36. REG tti_reg[] = {
  37.     { ORDATA (BUF, tti_unit.buf, 8) },
  38.     { FLDATA (BUSY, dev_busy, INT_V_TTI) },
  39.     { FLDATA (DONE, dev_done, INT_V_TTI) },
  40.     { FLDATA (DISABLE, dev_disable, INT_V_TTI) },
  41.     { FLDATA (INT, int_req, INT_V_TTI) },
  42.     { DRDATA (POS, tti_unit.pos, 32), PV_LEFT },
  43.     { DRDATA (TIME, tti_unit.wait, 24), REG_NZ + PV_LEFT },
  44.     { FLDATA (MODE, tti_unit.flags, UNIT_V_DASHER), REG_HRO },
  45.     { NULL }  };
  46.  
  47. MTAB ttx_mod[] = {
  48.     { UNIT_DASHER, 0, "ANSI", "ANSI", &ttx_setmod },
  49.     { UNIT_DASHER, UNIT_DASHER, "Dasher", "DASHER", &ttx_setmod },
  50.     { 0 }  };
  51.  
  52. DEVICE tti_dev = {
  53.     "TTI", &tti_unit, tti_reg, ttx_mod,
  54.     1, 10, 32, 1, 8, 8,
  55.     NULL, NULL, &tti_reset,
  56.     NULL, NULL, NULL };
  57.  
  58. /* TTO data structures
  59.  
  60.    tto_dev    TTO device descriptor
  61.    tto_unit    TTO unit descriptor
  62.    tto_reg    TTO register list
  63. */
  64.  
  65. UNIT tto_unit = { UDATA (&tto_svc, 0, 0), SERIAL_OUT_WAIT };
  66.  
  67. REG tto_reg[] = {
  68.     { ORDATA (BUF, tto_unit.buf, 8) },
  69.     { FLDATA (BUSY, dev_busy, INT_V_TTO) },
  70.     { FLDATA (DONE, dev_done, INT_V_TTO) },
  71.     { FLDATA (DISABLE, dev_disable, INT_V_TTO) },
  72.     { FLDATA (INT, int_req, INT_V_TTO) },
  73.     { DRDATA (POS, tto_unit.pos, 32), PV_LEFT },
  74.     { DRDATA (TIME, tto_unit.wait, 24), PV_LEFT },
  75.     { FLDATA (MODE, tto_unit.flags, UNIT_V_DASHER), REG_HRO },
  76.     { NULL }  };
  77.  
  78. DEVICE tto_dev = {
  79.     "TTO", &tto_unit, tto_reg, ttx_mod,
  80.     1, 10, 32, 1, 8, 8,
  81.     NULL, NULL, &tto_reset,
  82.     NULL, NULL, NULL };
  83.  
  84. /* Terminal input: IOT routine */
  85.  
  86. int tti (int pulse, int code, int AC)
  87. {
  88. int iodata;
  89.  
  90. iodata = (code == ioDIA)? tti_unit.buf & 0377: 0;
  91. switch (pulse) {                    /* decode IR<8:9> */
  92. case iopS:                         /* start */
  93.     dev_busy = dev_busy | INT_TTI;            /* set busy */
  94.     dev_done = dev_done & ~INT_TTI;            /* clear done, int */
  95.     int_req = int_req & ~INT_TTI;
  96.     break;
  97. case iopC:                        /* clear */
  98.     dev_busy = dev_busy & ~INT_TTI;            /* clear busy */
  99.     dev_done = dev_done & ~INT_TTI;            /* clear done, int */
  100.     int_req = int_req & ~INT_TTI;
  101.     break;  }                    /* end switch */
  102. return iodata;
  103. }
  104.  
  105. /* Unit service */
  106.  
  107. int tti_svc (UNIT *uptr)
  108. {
  109. int temp;
  110.  
  111. sim_activate (&tti_unit, tti_unit.wait);        /* continue poll */
  112. if ((temp = sim_poll_kbd ()) < SCPE_KFLAG) return temp;    /* no char or error? */
  113. tti_unit.buf = temp & 0177;
  114. if ((tti_unit.flags & UNIT_DASHER) && (tti_unit.buf == '\r'))
  115.     tti_unit.buf = '\n';                /* Dasher: cr -> nl */
  116. dev_busy = dev_busy & ~INT_TTI;                /* clear busy */
  117. dev_done = dev_done | INT_TTI;                /* set done */
  118. int_req = (int_req & ~INT_DEV) | (dev_done & ~dev_disable);
  119. tti_unit.pos = tti_unit.pos + 1;
  120. return SCPE_OK;
  121. }
  122.  
  123. /* Reset routine */
  124.  
  125. int tti_reset (DEVICE *dptr)
  126. {
  127. tti_unit.buf = 0;
  128. dev_busy = dev_busy & ~INT_TTI;                /* clear busy */
  129. dev_done = dev_done & ~INT_TTI;                /* clear done, int */
  130. int_req = int_req & ~INT_TTI;
  131. sim_activate (&tti_unit, tti_unit.wait);        /* activate unit */
  132. return SCPE_OK;
  133. }
  134.  
  135. /* Terminal output: IOT routine */
  136.  
  137. int tto (int pulse, int code, int AC)
  138. {
  139. if (code == ioDOA) tto_unit.buf = AC & 0377;
  140. switch (pulse) {                    /* decode IR<8:9> */
  141. case iopS:                         /* start */
  142.     dev_busy = dev_busy | INT_TTO;            /* set busy */
  143.     dev_done = dev_done & ~INT_TTO;            /* clear done, int */
  144.     int_req = int_req & ~INT_TTO;
  145.     sim_activate (&tto_unit, tto_unit.wait);    /* activate unit */
  146.     break;
  147. case iopC:                        /* clear */
  148.     dev_busy = dev_busy & ~INT_TTO;            /* clear busy */
  149.     dev_done = dev_done & ~INT_TTO;            /* clear done, int */
  150.     int_req = int_req & ~INT_TTO;
  151.     sim_cancel (&tto_unit);                /* deactivate unit */
  152.     break;  }                    /* end switch */
  153. return 0;
  154. }
  155.  
  156. /* Unit service */
  157.  
  158. int tto_svc (UNIT *uptr)
  159. {
  160. int c, temp;
  161.  
  162. dev_busy = dev_busy & ~INT_TTO;                /* clear busy */
  163. dev_done = dev_done | INT_TTO;                /* set done */
  164. int_req = (int_req & ~INT_DEV) | (dev_done & ~dev_disable);
  165. c = tto_unit.buf & 0177;
  166. if ((tto_unit.flags & UNIT_DASHER) && (c == 031)) c = '\b';
  167. if ((temp = sim_type_tty (c)) != SCPE_OK) return temp;
  168. tto_unit.pos = tto_unit.pos + 1;
  169. return SCPE_OK;
  170. }
  171.  
  172. /* Reset routine */
  173.  
  174. int tto_reset (DEVICE *dptr)
  175. {
  176. tto_unit.buf = 0;
  177. dev_busy = dev_busy & ~INT_TTO;                /* clear busy */
  178. dev_done = dev_done & ~INT_TTO;                /* clear done, int */
  179. int_req = int_req & ~INT_TTO;
  180. sim_cancel (&tto_unit);                    /* deactivate unit */
  181. return SCPE_OK;
  182. }
  183.  
  184. int ttx_setmod (UNIT *uptr, int value)
  185. {
  186. tti_unit.flags = (tti_unit.flags & ~UNIT_DASHER) | value;
  187. tto_unit.flags = (tto_unit.flags & ~UNIT_DASHER) | value;
  188. return SCPE_OK;
  189. }
  190.