mirror of
https://github.com/ole00/afterburner.git
synced 2024-06-17 13:29:37 +00:00
sparse fusemap: optimise access when block bits are all 1
This commit is contained in:
parent
7ff02e0a8d
commit
dc16f92a2e
|
@ -90,16 +90,17 @@ static uint16_t getFusePositionAndType(uint16_t bitPos) {
|
||||||
//calculate fusemap offset
|
//calculate fusemap offset
|
||||||
while (1) {
|
while (1) {
|
||||||
uint8_t rec = fuseType[i];
|
uint8_t rec = fuseType[i];
|
||||||
// speed optimised special case: all 8 bits are 0 (4 * 32 bits)
|
// speed optimised special case: all 8 bits are 0 or all are 1 (4 * 32 bits)
|
||||||
if (rec == 0) {
|
if (rec == 0 || rec == 0xFF) {
|
||||||
counter += 128;
|
counter += 128;
|
||||||
if (counter > bitPos) {
|
if (counter > bitPos) {
|
||||||
return (fuseOffset << 2); // type is 0
|
return (fuseOffset << 2) | (rec & 0b11); // type is 0 or 3
|
||||||
}
|
}
|
||||||
sparseCacheBitPos = counter;
|
sparseCacheBitPos = counter;
|
||||||
sparseCacheOffset = fuseOffset;
|
sparseCacheOffset = fuseOffset;
|
||||||
sparseCacheIndex = i + 1;
|
sparseCacheIndex = i + 1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
uint8_t j = 0;
|
uint8_t j = 0;
|
||||||
//4 fuse types per byte
|
//4 fuse types per byte
|
||||||
while (j < 4) {
|
while (j < 4) {
|
||||||
|
@ -152,6 +153,7 @@ static void sparseCompactFuseMap(void) {
|
||||||
sparseCompactRun++; //statistics
|
sparseCompactRun++; //statistics
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
i = total - 1;
|
i = total - 1;
|
||||||
while(i) {
|
while(i) {
|
||||||
// remove 4 fusemap bytes at a position when the bits are all 1's
|
// remove 4 fusemap bytes at a position when the bits are all 1's
|
||||||
|
@ -176,6 +178,13 @@ static void sparseCompactFuseMap(void) {
|
||||||
sparseCacheBitPos = 0;
|
sparseCacheBitPos = 0;
|
||||||
sparseCacheOffset = 0;
|
sparseCacheOffset = 0;
|
||||||
sparseCacheIndex = 0;
|
sparseCacheIndex = 0;
|
||||||
|
#if COMPACT_STAT
|
||||||
|
Serial.print(F("sp comp:"));
|
||||||
|
Serial.print(sparseCompactRun, DEC);
|
||||||
|
Serial.print(F(" total:"));
|
||||||
|
Serial.println(sparseFusemapStat & 0x7FF, DEC);
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint16_t sparseSetFuseBit(uint16_t bitPos) {
|
static inline uint16_t sparseSetFuseBit(uint16_t bitPos) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user