~ubuntu-branches/ubuntu/utopic/simh/utopic

« back to all changes in this revision

Viewing changes to nova_lp.c

  • Committer: Bazaar Package Importer
  • Author(s): Vince Mulhollon
  • Date: 2004-04-20 20:01:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040420200126-ehsuleda8xcgi51h
Tags: 3.2.0-1
New upstream 3.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* nova_lp.c: NOVA line printer simulator
2
 
 
3
 
   Copyright (c) 1993-1997,
4
 
   Robert M Supnik, Digital Equipment Corporation
5
 
   Commercial use prohibited
6
 
 
7
 
   lpt          line printer
8
 
*/
9
 
 
10
 
#include "nova_defs.h"
11
 
 
12
 
extern int32 int_req, dev_busy, dev_done, dev_disable;
13
 
int32 lpt_stopioe = 0;                                  /* stop on error */
14
 
t_stat lpt_svc (UNIT *uptr);
15
 
t_stat lpt_reset (DEVICE *dptr);
16
 
extern t_stat sim_activate (UNIT *uptr, int32 delay);
17
 
extern t_stat sim_cancel (UNIT *uptr);
18
 
 
19
 
/* LPT data structures
20
 
 
21
 
   lpt_dev      LPT device descriptor
22
 
   lpt_unit     LPT unit descriptor
23
 
   lpt_reg      LPT register list
24
 
*/
25
 
 
26
 
UNIT lpt_unit = {
27
 
        UDATA (&lpt_svc, UNIT_SEQ+UNIT_ATTABLE, 0), SERIAL_OUT_WAIT };
28
 
 
29
 
REG lpt_reg[] = {
30
 
        { ORDATA (BUF, lpt_unit.buf, 8) },
31
 
        { FLDATA (BUSY, dev_busy, INT_V_LPT) },
32
 
        { FLDATA (DONE, dev_done, INT_V_LPT) },
33
 
        { FLDATA (DISABLE, dev_disable, INT_V_LPT) },
34
 
        { FLDATA (INT, int_req, INT_V_LPT) },
35
 
        { DRDATA (POS, lpt_unit.pos, 31), PV_LEFT },
36
 
        { DRDATA (TIME, lpt_unit.wait, 24), PV_LEFT },
37
 
        { FLDATA (STOP_IOE, lpt_stopioe, 0) },
38
 
        { NULL }  };
39
 
 
40
 
DEVICE lpt_dev = {
41
 
        "LPT", &lpt_unit, lpt_reg, NULL,
42
 
        1, 10, 31, 1, 8, 8,
43
 
        NULL, NULL, &lpt_reset,
44
 
        NULL, NULL, NULL };
45
 
 
46
 
/* IOT routine */
47
 
 
48
 
int32 lpt (int32 pulse, int32 code, int32 AC)
49
 
{
50
 
 
51
 
if (code == ioDOA) lpt_unit.buf = AC & 0177;
52
 
switch (pulse) {                                        /* decode IR<8:9> */
53
 
case iopS:                                              /* start */
54
 
        dev_busy = dev_busy | INT_LPT;                  /* set busy */
55
 
        dev_done = dev_done & ~INT_LPT;                 /* clear done, int */
56
 
        int_req = int_req & ~INT_LPT;
57
 
        if ((lpt_unit.buf != 015) && (lpt_unit.buf != 014) &&
58
 
            (lpt_unit.buf != 012))
59
 
                return (lpt_svc (&lpt_unit) << IOT_V_REASON);
60
 
        sim_activate (&lpt_unit, lpt_unit.wait);
61
 
        break;
62
 
case iopC:                                              /* clear */
63
 
        dev_busy = dev_busy & ~INT_LPT;                 /* clear busy */
64
 
        dev_done = dev_done & ~INT_LPT;                 /* clear done, int */
65
 
        int_req = int_req & ~INT_LPT;
66
 
        sim_cancel (&lpt_unit);                         /* deactivate unit */
67
 
        break;  }                                       /* end switch */
68
 
return 0;
69
 
}
70
 
 
71
 
/* Unit service */
72
 
 
73
 
t_stat lpt_svc (UNIT *uptr)
74
 
{
75
 
dev_busy = dev_busy & ~INT_LPT;                         /* clear busy */
76
 
dev_done = dev_done | INT_LPT;                          /* set done */
77
 
int_req = (int_req & ~INT_DEV) | (dev_done & ~dev_disable);
78
 
if ((lpt_unit.flags & UNIT_ATT) == 0)                   /* attached? */
79
 
        return IORETURN (lpt_stopioe, SCPE_UNATT);
80
 
if (putc (lpt_unit.buf, lpt_unit.fileref) == EOF) {
81
 
        perror ("LPT I/O error");
82
 
        clearerr (lpt_unit.fileref);
83
 
        return SCPE_IOERR;  }
84
 
lpt_unit.pos = ftell (lpt_unit.fileref);
85
 
return SCPE_OK;
86
 
}
87
 
 
88
 
/* Reset routine */
89
 
 
90
 
t_stat lpt_reset (DEVICE *dptr)
91
 
{
92
 
lpt_unit.buf = 0;
93
 
dev_busy = dev_busy & ~INT_LPT;                         /* clear busy */
94
 
dev_done = dev_done & ~INT_LPT;                         /* clear done, int */
95
 
int_req = int_req & ~INT_LPT;
96
 
sim_cancel (&lpt_unit);                                 /* deactivate unit */
97
 
return SCPE_OK;
98
 
}