| 224 | } |
| 225 | |
| 226 | s32 CARDCheckExAsync(s32 chan, s32* xferBytes, CARDCallback callback) |
| 227 | { |
| 228 | CARDControl* card; |
| 229 | CARDDir* dir[2]; |
| 230 | u16* fat[2]; |
| 231 | u16* map; |
| 232 | s32 result; |
| 233 | int errors; |
| 234 | int currentFat; |
| 235 | int currentDir; |
| 236 | s32 fileNo; |
| 237 | u16 iBlock; |
| 238 | u16 cBlock; |
| 239 | u16 cFree; |
| 240 | BOOL updateFat = FALSE; |
| 241 | BOOL updateDir = FALSE; |
| 242 | BOOL updateOrphan = FALSE; |
| 243 | |
| 244 | if (xferBytes) |
| 245 | { |
| 246 | *xferBytes = 0; |
| 247 | } |
| 248 | |
| 249 | result = __CARDGetControlBlock(chan, &card); |
| 250 | if (result < 0) |
| 251 | { |
| 252 | return result; |
| 253 | } |
| 254 | |
| 255 | result = VerifyID(card); |
| 256 | if (result < 0) |
| 257 | { |
| 258 | return __CARDPutControlBlock(card, result); |
| 259 | } |
| 260 | |
| 261 | errors = VerifyDir(card, ¤tDir); |
| 262 | errors += VerifyFAT(card, ¤tFat); |
| 263 | if (1 < errors) |
| 264 | { |
| 265 | return __CARDPutControlBlock(card, CARD_RESULT_BROKEN); |
| 266 | } |
| 267 | |
| 268 | dir[0] = (CARDDir*)((u8*)card->workArea + (1 + 0) * CARD_SYSTEM_BLOCK_SIZE); |
| 269 | dir[1] = (CARDDir*)((u8*)card->workArea + (1 + 1) * CARD_SYSTEM_BLOCK_SIZE); |
| 270 | fat[0] = (u16*)((u8*)card->workArea + (3 + 0) * CARD_SYSTEM_BLOCK_SIZE); |
| 271 | fat[1] = (u16*)((u8*)card->workArea + (3 + 1) * CARD_SYSTEM_BLOCK_SIZE); |
| 272 | |
| 273 | switch (errors) |
| 274 | { |
| 275 | case 0: |
| 276 | break; |
| 277 | case 1: |
| 278 | if (!card->currentDir) |
| 279 | { |
| 280 | card->currentDir = dir[currentDir]; |
| 281 | memcpy(dir[currentDir], dir[currentDir ^ 1], CARD_SYSTEM_BLOCK_SIZE); |
| 282 | updateDir = TRUE; |
| 283 | } |
no test coverage detected