Lines Matching refs:pcache

41 static inline void lfs_cache_zero(lfs_t *lfs, lfs_cache_t *pcache) {  in lfs_cache_zero()  argument
43 memset(pcache->buffer, 0xff, lfs->cfg->cache_size); in lfs_cache_zero()
44 pcache->block = LFS_BLOCK_NULL; in lfs_cache_zero()
48 const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint, in lfs_bd_read() argument
60 if (pcache && block == pcache->block && in lfs_bd_read()
61 off < pcache->off + pcache->size) { in lfs_bd_read()
62 if (off >= pcache->off) { in lfs_bd_read()
64 diff = lfs_min(diff, pcache->size - (off-pcache->off)); in lfs_bd_read()
65 memcpy(data, &pcache->buffer[off-pcache->off], diff); in lfs_bd_read()
74 diff = lfs_min(diff, pcache->off-off); in lfs_bd_read()
131 const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint, in lfs_bd_cmp() argument
142 pcache, rcache, hint-i, in lfs_bd_cmp()
158 const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint, in lfs_bd_crc() argument
166 pcache, rcache, hint-i, in lfs_bd_crc()
180 lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate) { in lfs_bd_flush() argument
181 if (pcache->block != LFS_BLOCK_NULL && pcache->block != LFS_BLOCK_INLINE) { in lfs_bd_flush()
182 LFS_ASSERT(pcache->block < lfs->block_count); in lfs_bd_flush()
183 lfs_size_t diff = lfs_alignup(pcache->size, lfs->cfg->prog_size); in lfs_bd_flush()
184 int err = lfs->cfg->prog(lfs->cfg, pcache->block, in lfs_bd_flush()
185 pcache->off, pcache->buffer, diff); in lfs_bd_flush()
196 pcache->block, pcache->off, pcache->buffer, diff); in lfs_bd_flush()
206 lfs_cache_zero(lfs, pcache); in lfs_bd_flush()
215 lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate) { in lfs_bd_sync() argument
218 int err = lfs_bd_flush(lfs, pcache, rcache, validate); in lfs_bd_sync()
231 lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate, in lfs_bd_prog() argument
239 if (block == pcache->block && in lfs_bd_prog()
240 off >= pcache->off && in lfs_bd_prog()
241 off < pcache->off + lfs->cfg->cache_size) { in lfs_bd_prog()
244 lfs->cfg->cache_size - (off-pcache->off)); in lfs_bd_prog()
245 memcpy(&pcache->buffer[off-pcache->off], data, diff); in lfs_bd_prog()
251 pcache->size = lfs_max(pcache->size, off - pcache->off); in lfs_bd_prog()
252 if (pcache->size == lfs->cfg->cache_size) { in lfs_bd_prog()
254 int err = lfs_bd_flush(lfs, pcache, rcache, validate); in lfs_bd_prog()
265 LFS_ASSERT(pcache->block == LFS_BLOCK_NULL); in lfs_bd_prog()
268 pcache->block = block; in lfs_bd_prog()
269 pcache->off = lfs_aligndown(off, lfs->cfg->prog_size); in lfs_bd_prog()
270 pcache->size = 0; in lfs_bd_prog()
761 const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint, in lfs_dir_getread() argument
772 if (pcache && pcache->block == LFS_BLOCK_INLINE && in lfs_dir_getread()
773 off < pcache->off + pcache->size) { in lfs_dir_getread()
774 if (off >= pcache->off) { in lfs_dir_getread()
776 diff = lfs_min(diff, pcache->size - (off-pcache->off)); in lfs_dir_getread()
777 memcpy(data, &pcache->buffer[off-pcache->off], diff); in lfs_dir_getread()
786 diff = lfs_min(diff, pcache->off-off); in lfs_dir_getread()
1561 &lfs->pcache, &lfs->rcache, false, in lfs_dir_commitprog()
1704 &lfs->pcache, &lfs->rcache, false, in lfs_dir_commitcrc()
1724 if (noff >= end || noff >= lfs->pcache.off + lfs->cfg->cache_size) { in lfs_dir_commitcrc()
1726 int err = lfs_bd_sync(lfs, &lfs->pcache, &lfs->rcache, false); in lfs_dir_commitcrc()
2052 lfs_cache_drop(lfs, &lfs->pcache); in lfs_dir_compact()
2295 lfs_cache_drop(lfs, &lfs->pcache); in lfs_dir_relocatingcommit()
2834 const lfs_cache_t *pcache, lfs_cache_t *rcache, in lfs_ctz_find() argument
2852 pcache, rcache, sizeof(head), in lfs_ctz_find()
2869 lfs_cache_t *pcache, lfs_cache_t *rcache, in lfs_ctz_extend() argument
2911 pcache, rcache, true, in lfs_ctz_extend()
2932 err = lfs_bd_prog(lfs, pcache, rcache, true, in lfs_ctz_extend()
2962 lfs_cache_drop(lfs, pcache); in lfs_ctz_extend()
2968 const lfs_cache_t *pcache, lfs_cache_t *rcache, in lfs_ctz_traverse() argument
2990 pcache, rcache, count*sizeof(head), in lfs_ctz_traverse()
3247 &lfs->pcache, &lfs->rcache, true,
3258 memcpy(file->cache.buffer, lfs->pcache.buffer, lfs->cfg->cache_size);
3259 file->cache.block = lfs->pcache.block;
3260 file->cache.off = lfs->pcache.off;
3261 file->cache.size = lfs->pcache.size;
3262 lfs_cache_zero(lfs, &lfs->pcache);
3272 lfs_cache_drop(lfs, &lfs->pcache);
4175 lfs->pcache.buffer = lfs->cfg->prog_buffer;
4177 lfs->pcache.buffer = lfs_malloc(lfs->cfg->cache_size);
4178 if (!lfs->pcache.buffer) {
4186 lfs_cache_zero(lfs, &lfs->pcache);
4249 lfs_free(lfs->pcache.buffer);
4703 &lfs->pcache, &lfs->rcache, lfs->cfg->block_size,
5184 return lfs_bd_read(lfs, &lfs->pcache, &lfs->rcache, size,
5672 &lfs->pcache, &lfs->rcache, true,
5679 err = lfs_bd_flush(lfs, &lfs->pcache, &lfs->rcache, true);