aboutsummaryrefslogtreecommitdiff
path: root/unix/gdev/iism75/zwrm75.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /unix/gdev/iism75/zwrm75.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'unix/gdev/iism75/zwrm75.x')
-rw-r--r--unix/gdev/iism75/zwrm75.x76
1 files changed, 76 insertions, 0 deletions
diff --git a/unix/gdev/iism75/zwrm75.x b/unix/gdev/iism75/zwrm75.x
new file mode 100644
index 00000000..38bb0f3c
--- /dev/null
+++ b/unix/gdev/iism75/zwrm75.x
@@ -0,0 +1,76 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "m75.h"
+include "iis.h"
+
+# ZWRM75 -- Initiate an asynchronous write to the IIS. We are called to
+# output the header of all instructions sent to the IIS. There are 3 types
+# of instructions; those which consist only of a header write, those which
+# consist of a header write followed by a data write, and those which
+# consist of a header write followed by a data read. Translation of an M70
+# instruction into an M75 instruction may involve moving information between
+# the header and data block, hence we must save the headers of the read and
+# write instructions until the data has been read or written. The STATE
+# variable in the channel descriptor is used to keep track of the instruction
+# processing state.
+
+procedure zwrm75 (ifcb, buf, nbytes, offset)
+
+int ifcb # pointer to channel descriptor passed as int
+char buf[ARB] # input buffer
+int nbytes # number of bytes to write
+long offset # not used for this device
+
+pointer fcb
+int xferid, and()
+
+begin
+ fcb = ifcb
+
+ if (FCB_STATE(fcb) == READY) {
+ # Start a new instruction.
+
+ if (nbytes != SZB_IISHDR) {
+ FCB_STATUS(fcb) = ERR
+ return
+ }
+
+ # Save the M70 header in the descriptor.
+ call amovs (buf, FCB_IISHDR(fcb), LEN_IISHDR)
+ xferid = XFERID(buf)
+
+ # Determine the state for the new instruction.
+
+ if (THINGCT(buf) == 0)
+ FCB_STATE(fcb) = READY
+ else if (and (xferid, IREAD) != 0)
+ FCB_STATE(fcb) = DATA_READ
+ else
+ FCB_STATE(fcb) = DATA_WRITE
+
+ # If the new state is READY, no data read or write is needed,
+ # so just translate and output the header.
+
+ if (FCB_STATE(fcb) == READY)
+ call m75put (fcb, buf, nbytes, offset)
+ else {
+ # Set up a channel status as if we had just written the new
+ # header, so that the next ZWTM75 will not return an error.
+
+ FCB_STATUS(fcb) = IIS_INACTIVE
+ FCB_NBYTES(fcb) = SZB_IISHDR
+ }
+
+ } else if (FCB_STATE(fcb) == DATA_WRITE) {
+ # This is the second zwrm75 call for a hdr+data output
+ # instruction.
+
+ call m75put (fcb, buf, nbytes, offset)
+ FCB_STATE(fcb) = READY
+
+ } else {
+ # ZRDM75 should have been called, set error on the channel.
+ FCB_STATUS(fcb) = ERR
+ }
+end