summaryrefslogtreecommitdiff
path: root/system/dos/1.8.7/src/block i-o
blob: 554fcca9642126a6d704b98053851ab19978d05f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
PACKET disk block io DEFINES                    (* Copyright (C) 1986 *)
                                                (* Frank Klapper      *)
                                                (* 05.01.87           *)
  read disk block,
  read disk block and close work if error,
  read disk cluster, 
  write disk block,
  write disk block and close work if error,
  write disk cluster,
  first non dummy ds page,

  block no dump modus:

BOOL VAR block no dump flag := FALSE;
 
LET write normal = 0;

INT CONST first non dummy ds page := 2;

INT VAR error;

PROC read disk block (DATASPACE VAR ds,
                      INT CONST ds page no, 
                      INT CONST block no):
  IF block no dump flag THEN dump ("READ ", block no) FI;
  check rerun;
  read block (ds, ds page no, eublock (block no), error); 
  IF error > 0
    THEN lesefehler (error)
  FI.
 
END PROC read disk block;
 
PROC read disk block (DATASPACE VAR ds,
                      INT CONST ds page no, 
                      REAL CONST block no):
  IF block no dump flag THEN dump ("READ ", block no) FI;
  check rerun;
  read block (ds, ds page no, eublock (block no), error); 
  IF error > 0
    THEN lesefehler (error)
  FI.
 
END PROC read disk block;
 
PROC read disk block and close work if error (DATASPACE VAR ds,
                                              INT CONST ds page no, 
                                              INT CONST block no):
  IF block no dump flag THEN dump ("READ ", block no) FI;
  check rerun;
  read block (ds, ds page no, eublock (block no), error); 
  IF error > 0
    THEN close work;
         lesefehler (error)
  FI.
 
END PROC read disk block and close work if error;
 
PROC read disk block and close work if error (DATASPACE VAR ds,
                                              INT CONST ds page no, 
                                              REAL CONST block no):
  IF block no dump flag THEN dump ("READ ", block no) FI;
  check rerun;
  read block (ds, ds page no, eublock (block no), error); 
  IF error > 0
    THEN close work;
         lesefehler (error)
  FI.
 
END PROC read disk block and close work if error;

PROC read disk cluster (DATASPACE VAR ds, 
                        INT CONST first ds page no,
                        REAL CONST cluster no): 
  IF block no dump flag THEN dump ("CLUSTER ", cluster no) FI;
  INT VAR i;
  FOR i FROM 0 UPTO  sectors per cluster - 1 REP
    read disk block (ds, first ds page no + i, block no + real (i))
  PER.
 
block no:
  begin of cluster (cluster no).
 
END PROC read disk cluster; 
 
PROC lesefehler (INT CONST fehler code):
  error stop (fehlertext).

fehlertext:
  SELECT fehler code OF
    CASE 1: "Diskettenlaufwerk nicht betriebsbereit"
    CASE 2: "Lesefehler"
    OTHERWISE "Lesefehler " + text (fehler code)
  END SELECT.

END PROC lesefehler;

PROC write disk block (DATASPACE CONST ds,
                      INT CONST ds page no, 
                      INT CONST block no):
  IF block no dump flag THEN dump ("WRITE", block no) FI;
  check rerun;
  write block (ds, ds page no, write normal, eublock (block no), error); 
  IF error > 0
    THEN schreibfehler (error)
  FI.
 
END PROC write disk block;
 
PROC write disk block (DATASPACE CONST ds,
                      INT CONST ds page no, 
                      REAL CONST block no):
  IF block no dump flag THEN dump ("WRITE", block no) FI;
  check rerun;
  write block (ds, ds page no, write normal, eublock (block no), error); 
  IF error > 0
    THEN schreibfehler (error)
  FI.
 
END PROC write disk block;
 
PROC write disk block and close work if error (DATASPACE CONST ds,
                                              INT CONST ds page no, 
                                              INT CONST block no):
  IF block no dump flag THEN dump ("WRITE", block no) FI;
  check rerun;
  write block (ds, ds page no, write normal, eublock (block no), error); 
  IF error > 0
    THEN close work;
         schreibfehler (error)
  FI.
 
END PROC write disk block and close work if error;
 
PROC write disk block and close work if error (DATASPACE CONST ds,
                                              INT CONST ds page no, 
                                              REAL CONST block no):
  IF block no dump flag THEN dump ("WRITE", block no) FI;
  check rerun;
  write block (ds, ds page no, write normal, eublock (block no), error); 
  IF error > 0
    THEN close work;
         schreibfehler (error)
  FI.
 
END PROC write disk block and close work if error;

PROC write disk cluster (DATASPACE CONST ds,
                        INT CONST first ds page no,
                        REAL CONST cluster no): 
  IF block no dump flag THEN dump ("CLUSTER ", cluster no) FI;
  INT VAR i;
  FOR i FROM 0 UPTO sectors per cluster - 1 REP
    write disk block (ds, first ds page no + i, block no + real (i))
  PER.
 
block no:
  begin of cluster (cluster no).
 
END PROC write disk cluster; 
 
PROC schreibfehler (INT CONST fehler code):
  error stop (fehlertext).

fehlertext:
  SELECT fehler code OF
    CASE 1: "Diskettenlaufwerk nicht betriebsbereit"
    CASE 2: "Schreibfehler"
    OTHERWISE "Schreibfehler " + text (fehler code)
  END SELECT.

END PROC schreibfehler;

PROC block no dump modus (BOOL CONST status):
  block no dump flag := status

END PROC block no dump modus;

END PACKET disk block io;