summaryrefslogtreecommitdiff
path: root/system/dos/1986/src/block i-o
blob: 433674641fce7d9444d2a72af29138470f175784 (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
PACKET disk block io DEFINES                    (* Copyright (C) 1986 *)
                                                (* Frank Klapper      *)
                                                (* 25.03.86           *)
  read disk block,
  read disk cluster, 
  write disk block,
  write disk cluster,
  io error,
  first non dummy ds page:
 
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,
                      INT VAR error):
  check rerun;
  read block (ds, ds page no, eublock (block no), error). 
 
END PROC read disk block;
 
PROC read disk block (DATASPACE VAR ds,
                      INT CONST ds page no, 
                      INT CONST block no):
  check rerun;
  read block (ds, ds page no, eublock (block no), error); 
  IF error <> 0 
    THEN io error (error)
  FI. 
 
END PROC read disk block;
 
PROC read disk block (DATASPACE VAR ds,
                      INT CONST block no):
  read disk block (ds, first non dummy ds page, block no)

END PROC read disk block; 

PROC read disk cluster (DATASPACE VAR ds, 
                        INT CONST first ds page no,
                        INT CONST cluster no): 
  INT VAR i;
  FOR i FROM 0 UPTO sectors per cluster - 1 REP
    read disk block (ds, first ds page no + i, block no + i)
  PER.
 
block no:
  first block no of cluster (cluster no).
 
END PROC read disk cluster; 
 
PROC write disk block (DATASPACE CONST ds,
                       INT CONST ds page no, 
                       INT CONST block no,
                       INT VAR error):
  check rerun;
  write block (ds, ds page no, 0,eu block (block no), error). 
 
END PROC write disk block; 
 
PROC write disk block (DATASPACE CONST ds,
                       INT CONST ds page no, 
                       INT CONST block no):
  check rerun;
  write block (ds, ds page no, 0, eu block (block no), error); 
  IF error <> 0 
    THEN io error (error)
  FI. 
 
END PROC write disk block; 
 
PROC write disk block (DATASPACE CONST ds,
                       INT CONST block no): 
  write disk block (ds, first non dummy ds page, block no)

END PROC write disk block; 

PROC write disk cluster (DATASPACE CONST ds, 
                        INT CONST first ds page no,
                        INT CONST cluster no): 
  INT VAR i;
  FOR i FROM 0 UPTO sectors per cluster - 1 REP
    write disk block (ds, first ds page no + i, block no + i)
  PER.
 
block no:
  first block no of cluster (cluster no).
 
END PROC write disk cluster; 
 
PROC io  error (INT CONST error code):
  SELECT error code OF 
    CASE 1: errorstop ("Laufwerk nicht betriebsbereit") 
    CASE 2: errorstop ("Schreib-/Lesefehler") 
    CASE 3: errorstop ("Interner Fehler (Blocknummer zu hoch)") 
    CASE 4: errorstop ("Block nicht lesbar")
    OTHERWISE errorstop ("Schreib-/Lesefehler " + text (error)) 
  END SELECT. 

END PROC io error; 
 
END PACKET disk block io;