maketbl.c
2.25 KB
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
#include<stdio.h>
int sectorsize[9]=
{
232, 216, 208, 192, 176, 160, 144, 128, 112
};
int zonesize0[9]=
{
134, 146, 137, 137, 137, 137, 137, 102, 0
};
int zonesize1[9]=
{
0, 146, 146, 137, 137, 137, 137, 137, 102
};
int main()
{
int i;
int type;
int zone;
int lba;
printf("/*\n");
printf(" * Do not edit this file. This file is automatically generated by maketable.c\n");
printf(" */\n");
printf("#include <stdio.h>\n\n");
printf("int tab[][4292] = \n");
printf("{\n");
for(type = 0; type < 6; type++)
{
printf("\t{");
lba = 0;
for(zone = 0; zone <= type + 2; zone++)
{
printf("\n");
for(i = 0; i < zonesize0[zone]*2; i++)
{
printf("\t%d,", sectorsize[zone]*85);
lba += sectorsize[zone]*85;
if( i % 10 == 9)
printf("\n");
}
}
for(zone = type + 2; zone >= 1; zone--)
{
printf("\n");
for(i = 0; i < zonesize1[zone]*2; i++)
{
printf("\t%d,", sectorsize[zone]*85);
lba += sectorsize[zone]*85;
if( i % 10 == 9)
printf("\n");
}
}
for(zone = type + 3; zone <= 7; zone++)
{
printf("\n");
for(i = 0; i < zonesize0[zone]*2; i++)
{
printf("\t%d,", sectorsize[zone]*85);
lba += sectorsize[zone]*85;
if( i % 10 == 9)
printf("\n");
}
}
for(zone = 8; zone >= type + 3; zone--)
{
printf("\n");
for(i = 0; i < zonesize1[zone]*2; i++)
{
printf("\t%d,", sectorsize[zone]*85);
lba += sectorsize[zone]*85;
if( i % 10 == 9)
printf("\n");
}
}
fprintf(stderr, "total bytes = %d\n", lba);
printf("},\n");
}
/*
* type 6 is a little bit special
*/
printf("\t{");
lba = 0;
for(zone = 0; zone <= 7; zone++)
{
printf("\n");
for(i = 0; i < zonesize0[zone]*2; i++)
{
printf("\t%d,", sectorsize[zone]*85);
lba += sectorsize[zone]*85;
if( i % 10 == 9)
printf("\n");
}
}
for(zone = 8; zone >= 1; zone--)
{
printf("\n");
for(i = 0; i < zonesize1[zone]*2; i++)
{
printf("\t%d,", sectorsize[zone]*85);
lba += sectorsize[zone]*85;
if( i % 10 == 9)
printf("\n");
}
}
fprintf(stderr, "total bytes = %d\n", lba);
printf("},\n");
printf("};\n");
exit(0);
}