| 1 |
(* RTgenif.def provide a generic device interface mechanism used by RTgen. |
| 2 |
|
| 3 |
Copyright (C) 2008-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
Under Section 7 of GPL version 3, you are granted additional |
| 19 |
permissions described in the GCC Runtime Library Exception, version |
| 20 |
3.1, as published by the Free Software Foundation. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License and |
| 23 |
a copy of the GCC Runtime Library Exception along with this program; |
| 24 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 25 |
<http://www.gnu.org/licenses/>. *) |
| 26 |
|
| 27 |
DEFINITION MODULE RTgenif ; |
| 28 |
|
| 29 |
(* |
| 30 |
Title : RTgenif |
| 31 |
Author : Gaius Mulley |
| 32 |
System : GNU Modula-2 |
| 33 |
Date : Mon Sep 22 17:13:45 2008 |
| 34 |
Revision : $Version$ |
| 35 |
Description: provides a generic interface mechanism used |
| 36 |
by RTgen. This is not an ISO module but rather |
| 37 |
a runtime support module. |
| 38 |
*) |
| 39 |
|
| 40 |
FROM SYSTEM IMPORT ADDRESS ; |
| 41 |
FROM IOLink IMPORT DeviceId, DeviceTablePtr ; |
| 42 |
|
| 43 |
TYPE |
| 44 |
GenDevIF ; |
| 45 |
readchar = PROCEDURE (GenDevIF, DeviceTablePtr) : CHAR ; |
| 46 |
unreadchar = PROCEDURE (GenDevIF, DeviceTablePtr, CHAR) : CHAR ; |
| 47 |
geterrno = PROCEDURE (GenDevIF, DeviceTablePtr) : INTEGER ; |
| 48 |
readbytes = PROCEDURE (GenDevIF, DeviceTablePtr, ADDRESS, CARDINAL, VAR CARDINAL) : BOOLEAN ; |
| 49 |
writebytes = PROCEDURE (GenDevIF, DeviceTablePtr, ADDRESS, CARDINAL, VAR CARDINAL) : BOOLEAN ; |
| 50 |
writeln = PROCEDURE (GenDevIF, DeviceTablePtr) : BOOLEAN ; |
| 51 |
iseof = PROCEDURE (GenDevIF, DeviceTablePtr) : BOOLEAN ; |
| 52 |
iseoln = PROCEDURE (GenDevIF, DeviceTablePtr) : BOOLEAN ; |
| 53 |
iserror = PROCEDURE (GenDevIF, DeviceTablePtr) : BOOLEAN ; |
| 54 |
|
| 55 |
|
| 56 |
(* |
| 57 |
InitGenDevIF - initializes a generic device. |
| 58 |
*) |
| 59 |
|
| 60 |
PROCEDURE InitGenDevIF (d : DeviceId; |
| 61 |
rc : readchar; |
| 62 |
urc : unreadchar; |
| 63 |
geterr: geterrno; |
| 64 |
rbytes: readbytes; |
| 65 |
wbytes: writebytes; |
| 66 |
wl : writeln; |
| 67 |
eof : iseof; |
| 68 |
eoln : iseoln; |
| 69 |
iserr : iserror) : GenDevIF ; |
| 70 |
|
| 71 |
|
| 72 |
(* |
| 73 |
getDID - returns the device id this generic interface. |
| 74 |
*) |
| 75 |
|
| 76 |
PROCEDURE getDID (g: GenDevIF) : DeviceId ; |
| 77 |
|
| 78 |
|
| 79 |
(* |
| 80 |
doReadChar - returns the next character from the generic |
| 81 |
device. |
| 82 |
*) |
| 83 |
|
| 84 |
PROCEDURE doReadChar (g: GenDevIF; d: DeviceTablePtr) : CHAR ; |
| 85 |
|
| 86 |
|
| 87 |
(* |
| 88 |
doUnReadChar - pushes back a character to the generic device. |
| 89 |
*) |
| 90 |
|
| 91 |
PROCEDURE doUnReadChar (g: GenDevIF; d: DeviceTablePtr; ch: CHAR) : CHAR ; |
| 92 |
|
| 93 |
|
| 94 |
(* |
| 95 |
doGetErrno - returns the errno relating to the generic device. |
| 96 |
*) |
| 97 |
|
| 98 |
PROCEDURE doGetErrno (g: GenDevIF; d: DeviceTablePtr) : INTEGER ; |
| 99 |
|
| 100 |
|
| 101 |
(* |
| 102 |
doRBytes - attempts to read, n, bytes from the generic device. |
| 103 |
It set the actual amount read and returns a boolean |
| 104 |
to determine whether an error occurred. |
| 105 |
*) |
| 106 |
|
| 107 |
PROCEDURE doRBytes (g: GenDevIF; d: DeviceTablePtr; |
| 108 |
to: ADDRESS; max: CARDINAL; |
| 109 |
VAR actual: CARDINAL) : BOOLEAN ; |
| 110 |
|
| 111 |
|
| 112 |
(* |
| 113 |
doWBytes - attempts to write, n, bytes to the generic device. |
| 114 |
It sets the actual amount written and returns a |
| 115 |
boolean to determine whether an error occurred. |
| 116 |
*) |
| 117 |
|
| 118 |
PROCEDURE doWBytes (g: GenDevIF; d: DeviceTablePtr; |
| 119 |
from: ADDRESS; max: CARDINAL; |
| 120 |
VAR actual: CARDINAL) : BOOLEAN ; |
| 121 |
|
| 122 |
|
| 123 |
(* |
| 124 |
doWrLn - writes an end of line marker and returns |
| 125 |
TRUE if successful. |
| 126 |
*) |
| 127 |
|
| 128 |
PROCEDURE doWrLn (g: GenDevIF; d: DeviceTablePtr) : BOOLEAN ; |
| 129 |
|
| 130 |
|
| 131 |
(* |
| 132 |
isEOF - returns true if the end of file was reached. |
| 133 |
*) |
| 134 |
|
| 135 |
PROCEDURE isEOF (g: GenDevIF; d: DeviceTablePtr) : BOOLEAN ; |
| 136 |
|
| 137 |
|
| 138 |
(* |
| 139 |
isEOLN - returns true if the end of line was reached. |
| 140 |
*) |
| 141 |
|
| 142 |
PROCEDURE isEOLN (g: GenDevIF; d: DeviceTablePtr) : BOOLEAN ; |
| 143 |
|
| 144 |
|
| 145 |
(* |
| 146 |
isError - returns true if an error was seen in the device. |
| 147 |
*) |
| 148 |
|
| 149 |
PROCEDURE isError (g: GenDevIF; d: DeviceTablePtr) : BOOLEAN ; |
| 150 |
|
| 151 |
|
| 152 |
(* |
| 153 |
KillGenDevIF - deallocates a generic device. |
| 154 |
*) |
| 155 |
|
| 156 |
PROCEDURE KillGenDevIF (g: GenDevIF) : GenDevIF ; |
| 157 |
|
| 158 |
|
| 159 |
END RTgenif. |