Styling adjustments (PR#2668 & PR#2670)
Keep "astyled" reformatting
This commit is contained in:
committed by
Richard Wackerbarth
parent
b5fb7075b9
commit
0c7f7ebcfb
@ -23,12 +23,12 @@
|
||||
#include "SdVolume.h"
|
||||
//------------------------------------------------------------------------------
|
||||
#if !USE_MULTIPLE_CARDS
|
||||
// raw block cache
|
||||
uint32_t SdVolume::cacheBlockNumber_; // current block number
|
||||
cache_t SdVolume::cacheBuffer_; // 512 byte cache for Sd2Card
|
||||
Sd2Card* SdVolume::sdCard_; // pointer to SD card object
|
||||
bool SdVolume::cacheDirty_; // cacheFlush() will write block if true
|
||||
uint32_t SdVolume::cacheMirrorBlock_; // mirror block for second FAT
|
||||
// raw block cache
|
||||
uint32_t SdVolume::cacheBlockNumber_; // current block number
|
||||
cache_t SdVolume::cacheBuffer_; // 512 byte cache for Sd2Card
|
||||
Sd2Card* SdVolume::sdCard_; // pointer to SD card object
|
||||
bool SdVolume::cacheDirty_; // cacheFlush() will write block if true
|
||||
uint32_t SdVolume::cacheMirrorBlock_; // mirror block for second FAT
|
||||
#endif // USE_MULTIPLE_CARDS
|
||||
//------------------------------------------------------------------------------
|
||||
// find a contiguous group of clusters
|
||||
@ -50,7 +50,8 @@ bool SdVolume::allocContiguous(uint32_t count, uint32_t* curCluster) {
|
||||
|
||||
// don't save new start location
|
||||
setStart = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// start at likely place for free cluster
|
||||
bgnCluster = allocSearchStart_;
|
||||
|
||||
@ -75,7 +76,8 @@ bool SdVolume::allocContiguous(uint32_t count, uint32_t* curCluster) {
|
||||
if (f != 0) {
|
||||
// cluster in use try next cluster as bgnCluster
|
||||
bgnCluster = endCluster + 1;
|
||||
} else if ((endCluster - bgnCluster + 1) == count) {
|
||||
}
|
||||
else if ((endCluster - bgnCluster + 1) == count) {
|
||||
// done - found space
|
||||
break;
|
||||
}
|
||||
@ -99,8 +101,7 @@ bool SdVolume::allocContiguous(uint32_t count, uint32_t* curCluster) {
|
||||
if (setStart) allocSearchStart_ = bgnCluster + 1;
|
||||
|
||||
return true;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@ -119,8 +120,7 @@ bool SdVolume::cacheFlush() {
|
||||
cacheDirty_ = 0;
|
||||
}
|
||||
return true;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@ -132,8 +132,7 @@ bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) {
|
||||
}
|
||||
if (dirty) cacheDirty_ = true;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@ -146,8 +145,7 @@ bool SdVolume::chainSize(uint32_t cluster, uint32_t* size) {
|
||||
} while (!isEOC(cluster));
|
||||
*size = s;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@ -173,9 +171,11 @@ bool SdVolume::fatGet(uint32_t cluster, uint32_t* value) {
|
||||
}
|
||||
if (fatType_ == 16) {
|
||||
lba = fatStartBlock_ + (cluster >> 8);
|
||||
} else if (fatType_ == 32) {
|
||||
}
|
||||
else if (fatType_ == 32) {
|
||||
lba = fatStartBlock_ + (cluster >> 7);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
goto fail;
|
||||
}
|
||||
if (lba != cacheBlockNumber_) {
|
||||
@ -183,12 +183,12 @@ bool SdVolume::fatGet(uint32_t cluster, uint32_t* value) {
|
||||
}
|
||||
if (fatType_ == 16) {
|
||||
*value = cacheBuffer_.fat16[cluster & 0XFF];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
*value = cacheBuffer_.fat32[cluster & 0X7F] & FAT32MASK;
|
||||
}
|
||||
return true;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@ -231,23 +231,25 @@ bool SdVolume::fatPut(uint32_t cluster, uint32_t value) {
|
||||
}
|
||||
if (fatType_ == 16) {
|
||||
lba = fatStartBlock_ + (cluster >> 8);
|
||||
} else if (fatType_ == 32) {
|
||||
}
|
||||
else if (fatType_ == 32) {
|
||||
lba = fatStartBlock_ + (cluster >> 7);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
goto fail;
|
||||
}
|
||||
if (!cacheRawBlock(lba, CACHE_FOR_WRITE)) goto fail;
|
||||
// store entry
|
||||
if (fatType_ == 16) {
|
||||
cacheBuffer_.fat16[cluster & 0XFF] = value;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cacheBuffer_.fat32[cluster & 0X7F] = value;
|
||||
}
|
||||
// mirror second FAT
|
||||
if (fatCount_ > 1) cacheMirrorBlock_ = lba + blocksPerFat_;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@ -268,8 +270,7 @@ bool SdVolume::freeChain(uint32_t cluster) {
|
||||
} while (!isEOC(cluster));
|
||||
|
||||
return true;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@ -284,9 +285,11 @@ int32_t SdVolume::freeClusterCount() {
|
||||
|
||||
if (fatType_ == 16) {
|
||||
n = 256;
|
||||
} else if (fatType_ == 32) {
|
||||
}
|
||||
else if (fatType_ == 32) {
|
||||
n = 128;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// put FAT12 here
|
||||
return -1;
|
||||
}
|
||||
@ -298,7 +301,8 @@ int32_t SdVolume::freeClusterCount() {
|
||||
for (uint16_t i = 0; i < n; i++) {
|
||||
if (cacheBuffer_.fat16[i] == 0) free++;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (uint16_t i = 0; i < n; i++) {
|
||||
if (cacheBuffer_.fat32[i] == 0) free++;
|
||||
}
|
||||
@ -338,10 +342,10 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
|
||||
if (part) {
|
||||
if (part > 4)goto fail;
|
||||
if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) goto fail;
|
||||
part_t* p = &cacheBuffer_.mbr.part[part-1];
|
||||
if ((p->boot & 0X7F) !=0 ||
|
||||
p->totalSectors < 100 ||
|
||||
p->firstSector == 0) {
|
||||
part_t* p = &cacheBuffer_.mbr.part[part - 1];
|
||||
if ((p->boot & 0X7F) != 0 ||
|
||||
p->totalSectors < 100 ||
|
||||
p->firstSector == 0) {
|
||||
// not a valid partition
|
||||
goto fail;
|
||||
}
|
||||
@ -350,11 +354,11 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
|
||||
if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) goto fail;
|
||||
fbs = &cacheBuffer_.fbs32;
|
||||
if (fbs->bytesPerSector != 512 ||
|
||||
fbs->fatCount == 0 ||
|
||||
fbs->reservedSectorCount == 0 ||
|
||||
fbs->sectorsPerCluster == 0) {
|
||||
// not valid FAT volume
|
||||
goto fail;
|
||||
fbs->fatCount == 0 ||
|
||||
fbs->reservedSectorCount == 0 ||
|
||||
fbs->sectorsPerCluster == 0) {
|
||||
// not valid FAT volume
|
||||
goto fail;
|
||||
}
|
||||
fatCount_ = fbs->fatCount;
|
||||
blocksPerCluster_ = fbs->sectorsPerCluster;
|
||||
@ -365,7 +369,7 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
|
||||
if (clusterSizeShift_++ > 7) goto fail;
|
||||
}
|
||||
blocksPerFat_ = fbs->sectorsPerFat16 ?
|
||||
fbs->sectorsPerFat16 : fbs->sectorsPerFat32;
|
||||
fbs->sectorsPerFat16 : fbs->sectorsPerFat32;
|
||||
|
||||
fatStartBlock_ = volumeStartBlock + fbs->reservedSectorCount;
|
||||
|
||||
@ -376,11 +380,12 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
|
||||
rootDirStart_ = fatStartBlock_ + fbs->fatCount * blocksPerFat_;
|
||||
|
||||
// data start for FAT16 and FAT32
|
||||
dataStartBlock_ = rootDirStart_ + ((32 * fbs->rootDirEntryCount + 511)/512);
|
||||
dataStartBlock_ = rootDirStart_ + ((32 * fbs->rootDirEntryCount + 511) / 512);
|
||||
|
||||
// total blocks for FAT16 or FAT32
|
||||
totalBlocks = fbs->totalSectors16 ?
|
||||
fbs->totalSectors16 : fbs->totalSectors32;
|
||||
fbs->totalSectors16 : fbs->totalSectors32;
|
||||
|
||||
// total data blocks
|
||||
clusterCount_ = totalBlocks - (dataStartBlock_ - volumeStartBlock);
|
||||
|
||||
@ -391,15 +396,16 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
|
||||
if (clusterCount_ < 4085) {
|
||||
fatType_ = 12;
|
||||
if (!FAT12_SUPPORT) goto fail;
|
||||
} else if (clusterCount_ < 65525) {
|
||||
}
|
||||
else if (clusterCount_ < 65525) {
|
||||
fatType_ = 16;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rootDirStart_ = fbs->fat32RootCluster;
|
||||
fatType_ = 32;
|
||||
}
|
||||
return true;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user