As mentioned above, all Pascal level I/O requests are eventually mapped by the compiler and operating system into calls on a group of UCSD pre-declared procedures known as the unit I/O procedures. The Pascal programmer may call the Unit I/O procedures directly or he may use standard Pascal I/O procedures such as READ, WRITE, GET and PUT. The exact details of how this mapping is accomplished do not concern us here. The Unit I/O procedures are not written in Pascal but, in facts are the native code procedures comprising the I/O section of the Run-Time Support Package. The mechanism by which they are called is described next.
PROCEDURE UNITREAD(UNITNUMBER: INTEGER; VAR DATAAREA: PACKED ARRAY [0..BYTESTOTRANSFER-1] OF 0..255; BYTESTOTRANSFER: INTEGERS; [ LOGICALELOCK: INTEGER; [ CONTROL: INTEGER ]] ); PROCEDURE UNITWRITE(UNITNUMBER: INTEGER; VAR DATAAREA: PACKED ARRAY [0..BYTESTOTRANSFER-1] OF 0..255; BYTESTOTRANSFER: INTEGERS; [ LOGICALELOCK: INTEGER; [ CONTROL: INTEGER ]] ); FUNCTION UNITBUSY(UNITNUMBER: INTEGER): BOOLEAN; PROCEDURE UNITWAIT(UNITNUMBER: INTEGER); PROCEDURE UNITCLEAR(UNITNUMBER: INTEGER; UINITPTR: ^UIR);
(Note that UINITPTR is being introduced for the level 2 release.)
Remember that no such declarations actually exist in the system. They are intended to model the parameters passed and returned by the native code RSP/IO routines. Some of these routines are useful only in an asynchronous environment; under the synchronous system described here they are mere dummies.
Unit Number | Volume Name |
---|---|
0 | (must not be used) |
1 | CONSOLE: |
2 | SYSTERM: |
3 | (no current assignment) |
4 | disk O |
5 | disk 1 |
6 | PRINTER: |
7 | (no current assignment) |
8 | REMOTE: |
9 | disk 2 |
10 | disk 3 |
11 | disk 4 |
12 | disk 5 |
Figure 2.0 — Unit Numbers |
15 4 3 2 1 0 +---------------+----------+----------+----------+----------+ | (un-assigned) | CRLF | NOSPEC | PHYSSECT | ASYNC | +---------------+----------+----------+----------+----------+ MSB LSB
Unassigned (3..15) The contents of bits 4..15 are ignored. CRLF (bit 2) If set, do not do CR LF mapping. NOSPEC (bit 2) If set, implies “no special character handling”, i.e. no DLE expansion or LFs appended to CRs. PHYSSECT (bit 1) If set, implies “Physical Sector Mode” for disk I/O. ASYNC (bit 0) Ignored in this implementation. Figure 2. — CONTROL word format
The standard completion codes for release level 2.0 of the UCSD Pascal System are given in figure 2.2.
Code | Meaning |
---|---|
0 | No error |
1 | CRC error |
2 | Illegal unit number |
3 | Illegal operation on unit |
4 | (no longer used) |
5 | Lost unit; unit no longer on line |
6 | Lost file; file name no longer in directory |
7 | Illegal file name |
8 | No room; insufficient space on disk |
9 | Unit not on line; no such volume on line |
10 | No file; no such file name in directory |
11 | Duplicate file |
12 | Not closed; attempt to open an open file |
13 | Not open; attempt to access a closed file |
14 | Bad format; error reading real or integer |
15 | Ring Buffer Overflow |
16 | Write protect; write attempt to protected disk |
17 | Illegal block number |
18 | Non-zero byte count (in physical sector mode) |
19 | Invalid UIR settings |
100..199 | Codes 100 through 199 are reserved for non-predefined device-dependent errors. |
Figure 2.2 — I/O Completion Codes (Level 2.0) |
To provide enhanced flexibility for systems programming at a machine-specific level, a mechanism has been provided for directly accessing the physical sectors of the disk. When the PHYSSECT bit of the CONTROL word is set on a call to UNITREAD or UNITWRITE involving a disk unit. the I/O is performed in physical sector mode. This has the following effects:
type BYTE = 0..255; SECTOR = array [0..(BYTES_PER_SECTOR-1)] of BYTE; TRACK = array [1..SECTORS_PER_TRACK] of SECTOR; DISK = array [O..(TRACKS_PER_DISK-1)] of TRACK;(Note that we are using the convention that track numbers are zero-based but sector numbers start from one. )
We can convert the type DISK into a linear array of SECTOR as follows:
type DISK = array [0..(TRACKS_PER_DISK*SECTORS_PERTRACK)-1] of SECTOR;
We use this linear representation for addressing the disk by physical sector number (PSN). The relations between the PSN and track and sector numbers are:
PSN = (TRACK_NUM * sectors_per_track) + SECTOR_NUM - 1; TRACK_NUM = PSN div sectors_per_track; SECTOR_NUM = (PSN mod sectors_per_track) + 1;
Programs written using physical sector mode are not expected to be portable to different disk hardware without some modification.