Lines Matching refs:pcache

38 static inline void lfs_cache_zero(lfs_t *lfs, lfs_cache_t *pcache) {
40 memset(pcache->buffer, 0xff, lfs->cfg->cache_size);
41 pcache->block = LFS_BLOCK_NULL;
45 const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
57 if (pcache && block == pcache->block &&
58 off < pcache->off + pcache->size) {
59 if (off >= pcache->off) {
60 // is already in pcache?
61 diff = lfs_min(diff, pcache->size - (off-pcache->off));
62 memcpy(data, &pcache->buffer[off-pcache->off], diff);
70 // pcache takes priority
71 diff = lfs_min(diff, pcache->off-off);
128 const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
139 pcache, rcache, hint-i,
155 const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
163 pcache, rcache, hint-i,
177 lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate) {
178 if (pcache->block != LFS_BLOCK_NULL && pcache->block != LFS_BLOCK_INLINE) {
179 LFS_ASSERT(pcache->block < lfs->block_count);
180 lfs_size_t diff = lfs_alignup(pcache->size, lfs->cfg->prog_size);
181 int err = lfs->cfg->prog(lfs->cfg, pcache->block,
182 pcache->off, pcache->buffer, diff);
193 pcache->block, pcache->off, pcache->buffer, diff);
203 lfs_cache_zero(lfs, pcache);
212 lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate) {
215 int err = lfs_bd_flush(lfs, pcache, rcache, validate);
228 lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate,
236 if (block == pcache->block &&
237 off >= pcache->off &&
238 off < pcache->off + lfs->cfg->cache_size) {
239 // already fits in pcache?
241 lfs->cfg->cache_size - (off-pcache->off));
242 memcpy(&pcache->buffer[off-pcache->off], data, diff);
248 pcache->size = lfs_max(pcache->size, off - pcache->off);
249 if (pcache->size == lfs->cfg->cache_size) {
250 // eagerly flush out pcache if we fill up
251 int err = lfs_bd_flush(lfs, pcache, rcache, validate);
260 // pcache must have been flushed, either by programming and
261 // entire block or manually flushing the pcache
262 LFS_ASSERT(pcache->block == LFS_BLOCK_NULL);
264 // prepare pcache, first condition can no longer fail
265 pcache->block = block;
266 pcache->off = lfs_aligndown(off, lfs->cfg->prog_size);
267 pcache->size = 0;
756 const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
767 if (pcache && pcache->block == LFS_BLOCK_INLINE &&
768 off < pcache->off + pcache->size) {
769 if (off >= pcache->off) {
770 // is already in pcache?
771 diff = lfs_min(diff, pcache->size - (off-pcache->off));
772 memcpy(data, &pcache->buffer[off-pcache->off], diff);
780 // pcache takes priority
781 diff = lfs_min(diff, pcache->off-off);
1556 &lfs->pcache, &lfs->rcache, false,
1699 &lfs->pcache, &lfs->rcache, false,
1719 if (noff >= end || noff >= lfs->pcache.off + lfs->cfg->cache_size) {
1721 int err = lfs_bd_sync(lfs, &lfs->pcache, &lfs->rcache, false);
2047 lfs_cache_drop(lfs, &lfs->pcache);
2290 lfs_cache_drop(lfs, &lfs->pcache);
2829 const lfs_cache_t *pcache, lfs_cache_t *rcache,
2847 pcache, rcache, sizeof(head),
2864 lfs_cache_t *pcache, lfs_cache_t *rcache,
2906 pcache, rcache, true,
2927 err = lfs_bd_prog(lfs, pcache, rcache, true,
2957 lfs_cache_drop(lfs, pcache);
2963 const lfs_cache_t *pcache, lfs_cache_t *rcache,
2985 pcache, rcache, count*sizeof(head),
3242 &lfs->pcache, &lfs->rcache, true,
3253 memcpy(file->cache.buffer, lfs->pcache.buffer, lfs->cfg->cache_size);
3254 file->cache.block = lfs->pcache.block;
3255 file->cache.off = lfs->pcache.off;
3256 file->cache.size = lfs->pcache.size;
3257 lfs_cache_zero(lfs, &lfs->pcache);
3267 lfs_cache_drop(lfs, &lfs->pcache);
4170 lfs->pcache.buffer = lfs->cfg->prog_buffer;
4172 lfs->pcache.buffer = lfs_malloc(lfs->cfg->cache_size);
4173 if (!lfs->pcache.buffer) {
4181 lfs_cache_zero(lfs, &lfs->pcache);
4244 lfs_free(lfs->pcache.buffer);
4698 &lfs->pcache, &lfs->rcache, lfs->cfg->block_size,
5178 // this may need to consider pcache
5179 return lfs_bd_read(lfs, &lfs->pcache, &lfs->rcache, size,
5667 &lfs->pcache, &lfs->rcache, true,
5674 err = lfs_bd_flush(lfs, &lfs->pcache, &lfs->rcache, true);