1
10
13
14
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
89
93
97
98
99
100
101
102
103
109
110
111
112
113
114
115
119
120
121
122
123
124
125
126
127
128
129
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
154
155
156
157
158
159
160
161
162
168
169
170
171
172
...
...
...
#define FX_SOURCE_CODE
#include "fx_api.h"
#include "fx_system.h"
#include "fx_utility.h"
...
...
UINT _fx_utility_FAT_map_flush(FX_MEDIA *media_ptr)
{
ULONG FAT_sector, last_sector;
UINT i, status, FATs;
UCHAR sectors_per_bit;
/* ... */
if (media_ptr -> fx_media_sectors_per_FAT % (FX_FAT_MAP_SIZE << 3) == 0)
{
sectors_per_bit = (UCHAR)(media_ptr -> fx_media_sectors_per_FAT / (FX_FAT_MAP_SIZE << 3));
}if (media_ptr -> fx_media_sectors_per_FAT % (FX_FAT_MAP_SIZE << 3) == 0) { ... }
else
{
sectors_per_bit = (UCHAR)(media_ptr -> fx_media_sectors_per_FAT / (FX_FAT_MAP_SIZE << 3) + 1);
}else { ... }
for (i = 0; i < FX_FAT_MAP_SIZE << 3; i++)
{
if ((media_ptr -> fx_media_fat_secondary_update_map[i >> 3] & (1 << (i & 7))) == 0)
{
continue;
}if ((media_ptr -> fx_media_fat_secondary_update_map[i >> 3] & (1 << (i & 7))) == 0) { ... }
FAT_sector = i * sectors_per_bit + media_ptr -> fx_media_reserved_sectors;
last_sector = FAT_sector + sectors_per_bit;
if (last_sector > (media_ptr -> fx_media_sectors_per_FAT + media_ptr -> fx_media_reserved_sectors))
{
last_sector = media_ptr -> fx_media_sectors_per_FAT + media_ptr -> fx_media_reserved_sectors;
}if (last_sector > (media_ptr -> fx_media_sectors_per_FAT + media_ptr -> fx_media_reserved_sectors)) { ... }
for (; FAT_sector < last_sector; FAT_sector++)
{
status = _fx_utility_logical_sector_read(media_ptr, (ULONG64) FAT_sector,
media_ptr -> fx_media_memory_buffer, ((ULONG) 1), FX_FAT_SECTOR);
if (status != FX_SUCCESS)
{
return(status);
}if (status != FX_SUCCESS) { ... }
FATs = media_ptr -> fx_media_number_of_FATs - 1;
while (FATs)
{
status = _fx_utility_logical_sector_write(media_ptr,
((ULONG64) FAT_sector) + ((ULONG64)FATs * (ULONG64)(media_ptr -> fx_media_sectors_per_FAT)),
media_ptr -> fx_media_memory_buffer, ((ULONG) 1), FX_FAT_SECTOR);
if (status != FX_SUCCESS)
{
return(status);
}if (status != FX_SUCCESS) { ... }
FATs--;
}while (FATs) { ... }
}for (; FAT_sector < last_sector; FAT_sector++) { ... }
}for (i = 0; i < FX_FAT_MAP_SIZE << 3; i++) { ... }
for (i = 0; i < FX_FAT_MAP_SIZE; i++)
{
media_ptr -> fx_media_fat_secondary_update_map[i] = 0;
}for (i = 0; i < FX_FAT_MAP_SIZE; i++) { ... }
return(FX_SUCCESS);
}{ ... }