From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/ki/kzrdmt.x | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 sys/ki/kzrdmt.x (limited to 'sys/ki/kzrdmt.x') diff --git a/sys/ki/kzrdmt.x b/sys/ki/kzrdmt.x new file mode 100644 index 00000000..7fdaf517 --- /dev/null +++ b/sys/ki/kzrdmt.x @@ -0,0 +1,63 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include +include +include "ki.h" + +# KZRDMT -- Asynchronous read from a magtape file. + +procedure kzrdmt (chan, obuf, max_bytes, offset) + +int chan #I magtape channel +char obuf[ARB] #O buffer to receive data +int max_bytes #I max bytes to read +long offset #I file offset + +pointer bd +int server, status +int ki_send(), ki_receive() +include "kichan.com" +include "kii.com" + +begin + server = k_node[chan] + + if (server == NULL) { + call zzrdmt (k_oschan[chan], obuf, max_bytes, offset) + return + } + + # Ignore zero reads and requests on a node closed by an error. + if (max_bytes <= 0) { + k_status[chan] = 0 + return + } + + # Send the request to initiate the read. + p_arg[1] = k_oschan[chan] + p_arg[2] = max_bytes + p_arg[3] = offset + + if (ki_send (server, KI_ZFIOMT, MT_RD) == ERR) { + status = ERR + } else { + bd = k_bufp[chan] + + # Wait for the ZAWT packet. + if (ki_receive (server, KI_ZFIOMT, MT_WT) == ERR) + status = ERR + else { + status = p_arg[1] + call amovi (p_arg[2], Memi[bd], LEN_MTDEVPOS) + } + + # Read the data block (if any) directly into caller's buffer. + if (status > 0) { + call ks_aread (server, obuf, status) + call ks_await (server, status) + } + } + + k_status[chan] = status +end -- cgit