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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
#include "stdio.h" /* ;AN000; */
#include "stdlib.h" /* ;AN000; */
#include "string.h" /* ;AN000; */
#include "dos.h" /* ;AN000; */
#include "get_stat.h" /* ;AN000; */
#include "extern.h" /* ;AN000; */
/* ;AN000; */
char read_boot_record(unsigned,unsigned char,unsigned char,unsigned char); /* ;AN000; */
void DiskIo(union REGS *,union REGS *, struct SREGS *); /* ;AN000; */
unsigned cylinders_to_mbytes(unsigned,unsigned char,unsigned char); /* ;AN000; */
char get_drive_parameters(unsigned char); /* ;AN000; */
char get_disk_info(void); /* ;AN000; */
/* ;AN000; */
/* */ /* ;AN000; */
char get_disk_info() /* ;AN000; */
/* ;AN000; */
BEGIN /* ;AN000; */
/* ;AN000; */
unsigned char i; /* ;AN000; */
/* ;AN000; */
/* Initialize values */ /* ;AN000; */
number_of_drives = uc(0); /* ;AN000; */
for (i=uc(0); i < uc(2); i++) /* ;AN000; */
BEGIN /* ;AN000; */
total_disk[i] = u(0); /* ;AN000; */
total_mbytes[i] = f(0); /* ;AN000; */
max_sector[i] = uc(0); /* ;AN000; */
max_head[0] = uc(0); /* ;AN000; */
END /* ;AN000; */
/* ;AN000; */
/* See how many drives there are */ /* ;AN000; */
if (get_drive_parameters(uc(0x80))) /* ;AN000; */
/* ;AN000; */
BEGIN /* ;AN000; */
/* Get the drive parameters for all drives */ /* ;AN000; */
for (i = uc(0); i < number_of_drives;i++) /* ;AN000; */
/* ;AN000; */
BEGIN /* ;AN000; */
if (get_drive_parameters(uc(0x80)+i)) /* ;AN000; */
/* ;AN000; */
BEGIN /* ;AN000; */
/* Save drive parameters */ /* ;AN000; */
max_sector[i] = ((unsigned char)(regs.h.cl & 0x3F)); /* ;AN000; */
max_head[i] = ((unsigned char)(regs.h.dh +1)); /* ;AN000; */
total_disk[i] = ((((unsigned)(regs.h.cl & 0xC0 )) & 0x00C0) << 2)+ ((unsigned)regs.h.ch) +1; /* ;AN000; */
total_mbytes[i] = cylinders_to_mbytes(total_disk[i], max_sector[i], max_head[i]); /* ;AN000; */
END /* ;AN000; */
else /* ;AN000; */
BEGIN /* ;AN000; */
good_disk[i] = FALSE; /* ;AN000; */
return(FALSE); /* ;AN000; */
END /* ;AN000; */
END /* ;AN000; */
return(TRUE); /* ;AN000; */
END /* ;AN000; */
else /* ;AN000; */
/* No drives present */ /* ;AN000; */
BEGIN /* ;AN000; */
no_fatal_error = FALSE; /* ;AN000; */
return(FALSE); /* ;AN000; */
END /* ;AN000; */
END /* ;AN000; */
/* ;AN000; */
/* ;AN000; */
/* ;AN000; */
/* ;AN000; */
/* */ /* ;AN000; */
char get_drive_parameters(drive) /* ;AN000; */
/* ;AN000; */
unsigned char drive; /* ;AN000; */
/* ;AN000; */
BEGIN /* ;AN000; */
/* See how many drives there are */ /* ;AN000; */
regs.h.ah = uc(DISK_INFO); /* ;AN000; */
regs.h.dl = drive; /* ;AN000; */
DiskIo(®s,®s,&segregs); /* ;AN000; */
/* ;AN000; */
/* See if any drives exist */ /* ;AN000; */
if ((regs.h.dl == uc(0)) || ((regs.x.cflag & 1) == u(1))) /* ;AN000; */
BEGIN /* ;AN000; */
return(FALSE); /* ;AN000; */
END /* ;AN000; */
else /* ;AN000; */
BEGIN /* ;AN000; */
/* Save the number of drives */ /* ;AN000; */
number_of_drives = regs.h.dl; /* ;AN000; */
if (number_of_drives < 2) good_disk[1] = FALSE; /* ;AN000; */
if (number_of_drives < 1) good_disk[0] = FALSE; /* ;AN000; */
return(TRUE); /* ;AN000; */
END /* ;AN000; */
/* ;AN000; */
END /* ;AN000; */
/* ;AN000; */
/* */ /* ;AN000; */
char read_boot_record(cylinder,which_disk,which_head,which_sector) /* ;AN000; */
/* ;AN000; */
unsigned cylinder; /* ;AN000; */
unsigned char which_disk; /* ;AN000; */
unsigned char which_head; /* ;AN000; */
unsigned char which_sector; /* ;AN000; */
/* ;AN000; */
BEGIN /* ;AN000; */
/* ;AN000; */
char far *buffer_pointer = boot_record; /* ;AN000; */
/* ;AN000; */
/* Setup read, always on a cylinder boundary */ /* ;AN000; */
regs.h.ah = uc(READ_DISK); /* ;AN000; */
regs.h.al = uc(1); /* ;AN000; */
regs.h.dh = which_head; /* ;AN000; */
regs.h.cl = which_sector; /* ;AN000; */
/* ;AN000; */
/* Specify the disk */ /* ;AN000; */
regs.h.dl = which_disk + 0x80; /* ;AN000; */
/* ;AN000; */
/* Need to scramble CX so that sectors and cyl's are in INT 13 format */ /* ;AN000; */
/* ;AN000; */
if (cylinder > u(255)) /* ;AN000; */
BEGIN /* ;AN000; */
regs.h.cl = regs.h.cl | ((char)((cylinder /256) << 6)); /* ;AN000; */
END /* ;AN000; */
regs.h.ch = (unsigned char)(cylinder & 0xFF); /* ;AN000; */
/* ;AN000; */
/* Point at the place to write the boot record */ /* ;AN000; */
regs.x.bx = FP_OFF(buffer_pointer); /* ;AN000; */
segregs.es = FP_SEG(buffer_pointer); /* ;AN000; */
/* ;AN000; */
/* read in the boot record */ /* ;AN000; */
DiskIo(®s,®s,&segregs); /* ;AN000; */
/* Check for error reading it */ /* ;AN000; */
if ((regs.x.cflag & 1) != u(1)) /* ;AN000; */
BEGIN /* ;AN000; */
return(TRUE); /* ;AN000; */
END /* ;AN000; */
else /* ;AN000; */
BEGIN /* ;AN000; */
/* Tell user there was an error */ /* ;AN000; */
good_disk[which_disk] = FALSE; /* ;AN000; */
return(FALSE); /* ;AN000; */
END /* ;AN000; */
END /* ;AN000; */
/* ;AN000; */
/* */ /* ;AN000; */
void DiskIo(InRegs,OutRegs,SegRegs) /* ;AN000; */
union REGS *InRegs; /* ;AN000; */
union REGS *OutRegs; /* ;AN000; */
struct SREGS *SegRegs; /* ;AN000; */
/* ;AN000; */
BEGIN /* ;AN000; */
/* ;AN000; */
char *WritePtr; /* ;AN000; */
/* ;AN000; */
#ifdef DEBUG /* ;AN000; */
/* ;AN000; */
switch(InRegs->h.ah) /* ;AN000; */
{ /* ;AN000; */
case 0: /* ;AN000; */
case 1: /* ;AN000; */
case 2: /* ;AN000; */
case 4: /* ;AN000; */
case 8: /* ;AN000; */
case 15: /* ;AN000; */
case 16: /* ;AN000; */
int86x((int)DISK,InRegs,OutRegs,SegRegs); /* ;AN000; */
break; /* ;AN000; */
/* ;AN000; */
default: /* ;AN000; */
WritePtr = getenv("WRITE"); /* ;AN000; */
if (strcmpi(WritePtr,"ON") != 0) /* ;AN000; */
BEGIN /* ;AN000; */
printf("\nDisallowing Disk I/O Request\n"); /* ;AN000; */
printf("AX:%04X BX:%04X CX:%04X DX:%04X ES:%04X\n", /* ;AN000; */
InRegs->x.ax,InRegs->x.bx,InRegs->x.cx,InRegs->x.dx,SegRegs->es); /* ;AN000; */
/* ;AN000; */
OutRegs->h.ah = (unsigned char) 0; /* ;AN000; */
OutRegs->x.cflag = (unsigned) 0; /* ;AN000; */
END /* ;AN000; */
else int86x((int)DISK,InRegs,OutRegs,SegRegs); /* ;AN000; */
/* ;AN000; */
break; /* ;AN000; */
/* ;AN000; */
} /* ;AN000; */
/* ;AN000; */
#else /* ;AN000; */
/* ;AN000; */
int86x((int)DISK,InRegs,OutRegs,SegRegs); /* ;AN000; */
/* ;AN000; */
#endif /* ;AN000; */
/* ;AN000; */
return; /* ;AN000; */
/* ;AN000; */
END /* ;AN000; */
/* ;AN000; */
|