1
10
13
14
20
21
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
110
111
112
113
114
115
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
155
156
157
158
159
160
161
162
163
164
170
171
172
173
174
175
176
177
178
179
180
186
187
190
191
192
193
199
200
202
203
204
205
206
207
...
...
...
#define FX_SOURCE_CODE
#include "fx_api.h"
#include "fx_fault_tolerant.h"
#include "fx_utility.h"
#ifdef FX_ENABLE_FAULT_TOLERANT...
...
UINT _fx_fault_tolerant_transaction_end(FX_MEDIA *media_ptr)
{
ULONG relative_sector;
UINT status;
USHORT checksum;
UINT offset;
FX_FAULT_TOLERANT_LOG_HEADER *log_header;
FX_FAULT_TOLERANT_LOG_CONTENT *log_content;
if (media_ptr -> fx_media_fault_tolerant_enabled == FX_FALSE)
{
return(FX_SUCCESS);
}if (media_ptr -> fx_media_fault_tolerant_enabled == FX_FALSE) { ... }
media_ptr -> fx_media_fault_tolerant_transaction_count--;
if (media_ptr -> fx_media_fault_tolerant_transaction_count != 0)
{
return(FX_SUCCESS);
}if (media_ptr -> fx_media_fault_tolerant_transaction_count != 0) { ... }
media_ptr -> fx_media_fault_tolerant_state = FX_FAULT_TOLERANT_STATE_IDLE;
log_header = (FX_FAULT_TOLERANT_LOG_HEADER *)media_ptr -> fx_media_fault_tolerant_memory_buffer;
log_content = (FX_FAULT_TOLERANT_LOG_CONTENT *)(media_ptr -> fx_media_fault_tolerant_memory_buffer +
FX_FAULT_TOLERANT_LOG_CONTENT_OFFSET);
_fx_utility_16_unsigned_write((UCHAR *)&log_content -> fx_fault_tolerant_log_content_checksum, 0);
_fx_utility_16_unsigned_write((UCHAR *)&log_content -> fx_fault_tolerant_log_content_count,
media_ptr -> fx_media_fault_tolerant_total_logs);
checksum = _fx_fault_tolerant_calculate_checksum((media_ptr -> fx_media_fault_tolerant_memory_buffer +
FX_FAULT_TOLERANT_LOG_CONTENT_OFFSET),
(media_ptr -> fx_media_fault_tolerant_file_size -
FX_FAULT_TOLERANT_LOG_CONTENT_OFFSET));
_fx_utility_16_unsigned_write((UCHAR *)&log_content -> fx_fault_tolerant_log_content_checksum, checksum);
_fx_utility_16_unsigned_write((UCHAR *)&log_header -> fx_fault_tolerant_log_header_total_size,
media_ptr -> fx_media_fault_tolerant_file_size);
_fx_utility_16_unsigned_write((UCHAR *)&log_header -> fx_fault_tolerant_log_header_checksum, 0);
checksum = _fx_fault_tolerant_calculate_checksum((UCHAR *)log_header, FX_FAULT_TOLERANT_LOG_HEADER_SIZE);
_fx_utility_16_unsigned_write((UCHAR *)&log_header -> fx_fault_tolerant_log_header_checksum, checksum);
/* ... */
relative_sector = 1;
offset = media_ptr -> fx_media_bytes_per_sector;
while (offset < media_ptr -> fx_media_fault_tolerant_file_size)
{
status = _fx_fault_tolerant_write_log_file(media_ptr, relative_sector);
if (status != FX_SUCCESS)
{
return(status);
}if (status != FX_SUCCESS) { ... }
relative_sector++;
offset += media_ptr -> fx_media_bytes_per_sector;
}while (offset < media_ptr -> fx_media_fault_tolerant_file_size) { ... }
status = _fx_fault_tolerant_write_log_file(media_ptr, 0);
if (status != FX_SUCCESS)
{
return(status);
}if (status != FX_SUCCESS) { ... }
/* ... */
status = _fx_fault_tolerant_apply_logs(media_ptr);
if (status != FX_SUCCESS)
{
return(status);
}if (status != FX_SUCCESS) { ... }
/* ... */
status = _fx_fault_tolerant_reset_log_file(media_ptr);
return(status);
}_fx_fault_tolerant_transaction_end (FX_MEDIA *media_ptr) { ... }
/* ... */#endif