-
Notifications
You must be signed in to change notification settings - Fork 9
/
init.c
105 lines (85 loc) · 2.45 KB
/
init.c
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
/*
// Program: Format
// Version: 0.91k
// (0.90b/c/d - DMA friendly buffer movement - Eric Auer - May 2003)
// (0.91k ... Eric Auer 2004)
// Written By: Brian E. Reifsnyder
// Copyright: 2002-2004 under the terms of the GNU GPL, Version 2
// Module Name: init.c
// Module Description: Program initialization functions.
*/
#include <stdlib.h>
#include "format.h"
#include "driveio.h" /* sector buffers */
void Setup_DDPT(void);
void Initialization(void)
{
int bad_sector_map_pointer;
unsigned long int where;
bad_sector_map_pointer = 0;
sector_buffer = §or_buffer_0[0];
where = FP_SEG(sector_buffer);
where <<= 4;
where += FP_OFF(sector_buffer);
if ((where & 0xffff) > (0xffff - 512)) {
sector_buffer = §or_buffer_1[0];
where = FP_SEG(sector_buffer);
where <<= 4;
where += FP_OFF(sector_buffer);
if (debug_prog==TRUE) printf("DMA tuning: using alternative sector_buffer\n");
}
if ((where & 0xffff) > (0xffff - 512)) {
if (debug_prog==TRUE) printf("DMA tuning: CANNOT move sector buffer away from boundary!?\n");
}
huge_sector_buffer = &huge_sector_buffer_0[0];
where = FP_SEG(huge_sector_buffer);
where <<= 4;
where += FP_OFF(huge_sector_buffer);
if ( (where & 0xffff) > (0xffff - sizeof(huge_sector_buffer_0)) ) {
huge_sector_buffer = &huge_sector_buffer_1[0];
where = FP_SEG(sector_buffer);
where <<= 4;
where += FP_OFF(sector_buffer);
if (debug_prog==TRUE) printf("DMA tuning: using alternative huge_sector_buffer\n");
}
param.drive_letter[0]='\0';
param.volume_label[0]='\0';
param.drive_type=0; /* not NULL; */
param.drive_number=0; /* not NULL; */
param.fat_type=0; /* not NULL; */
param.media_type=UNKNOWN;
param.force_yes=FALSE;
param.verify=TRUE;
param.v=FALSE;
param.q=FALSE;
param.u=FALSE;
param.f=FALSE;
param.b=FALSE;
param.s=FALSE;
param.t=FALSE;
param.n=FALSE;
param.one=FALSE;
param.four=FALSE;
param.eight=FALSE;
param.size=UNKNOWN;
param.cylinders=0;
param.sectors=0;
drive_statistics.bad_sectors = 0;
drive_statistics.bytes_per_sector = 512;
segread(&sregs);
/* Clear bad_sector_map[]. */
do
{
bad_sector_map[bad_sector_map_pointer]=0;
bad_sector_map_pointer++;
} while (bad_sector_map_pointer<MAX_BAD_SECTORS);
Setup_DDPT();
}
void Setup_DDPT(void)
{
/* Get the location of the DDPT */
regs.h.ah =0x35;
regs.h.al =0x1e;
intdosx(®s, ®s, &sregs);
ddpt = MK_FP(sregs.es, regs.x.bx);
}