HFE, QD: Subdivide long NFA regions so that the 16-bit timer does not overflow

This commit is contained in:
Keir Fraser 2023-05-31 17:32:24 +01:00
parent 82aaae8bf5
commit 9521a79ad9
2 changed files with 20 additions and 0 deletions

View file

@ -294,6 +294,16 @@ static uint16_t hfe_rdata_flux(struct image *im, uint16_t *tbuf, uint16_t nr)
}
x >>= 1;
}
/* Subdivide a long flux gap which would overflow the 16-bit timer.
* This mishandles long No Flux Areas slightly, by regularly emitting
* a flux-reversal pulse every 2^16 ticks. */
if (unlikely((ticks >> 20) != 0)) {
*tbuf++ = 0xffff;
ticks -= 1u << 20;
if (!--todo)
goto out;
}
}
out:

View file

@ -188,6 +188,16 @@ static uint16_t qd_rdata_flux(struct image *im, uint16_t *tbuf, uint16_t nr)
}
x >>= 1;
}
/* Subdivide a long flux gap which would overflow the 16-bit timer.
* This mishandles long No Flux Areas slightly, by regularly emitting
* a flux-reversal pulse every 2^16 ticks. */
if (unlikely((ticks >> 16) != 0)) {
*tbuf++ = 0xffff;
ticks -= 1u << 16;
if (!--todo)
goto out;
}
}
out: