The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
block_cache.h File Reference

a sector cache in front of a block device. More...

Go to the source code of this file.

Data Structures

struct  block_cache_slot_t
struct  block_cache_t

Macros

#define BLOCK_CACHE_SETS   256
#define BLOCK_CACHE_WAYS   4
#define BLOCK_CACHE_SECTOR   512

Functions

kerr_t block_cache_init (block_cache_t *cache, block_device_t *backing)
 put a cache in front of a device with 512-byte sectors.

Variables

block_cache_t * block_cache_root
 the cache that serves the root filesystem, for /proc/meminfo (NULL before it is set up).

Detailed Description

a sector cache in front of a block device.

a block_cache_t is itself a block device: reads are served from memory when the sectors are cached; writes go to the device at once (write through) and update the cached copies, so the disk is never behind.

the cache holds BLOCK_CACHE_SETS * BLOCK_CACHE_WAYS sectors. a sector can be in one of the BLOCK_CACHE_WAYS slots of its set (lba % sets); a miss replaces the least recently used slot of the set.

Macro Definition Documentation

◆ BLOCK_CACHE_SETS

#define BLOCK_CACHE_SETS   256

◆ BLOCK_CACHE_WAYS

#define BLOCK_CACHE_WAYS   4

◆ BLOCK_CACHE_SECTOR

#define BLOCK_CACHE_SECTOR   512

Function Documentation

◆ block_cache_init()

kerr_t block_cache_init ( block_cache_t * cache,
block_device_t * backing )

put a cache in front of a device with 512-byte sectors.

Parameters
cachethe cache (lives as long as the device is used).
backingthe device to cache.
Returns
KERR_OK, KERR_INVAL for another sector size, or KERR_NOMEM.

Variable Documentation

◆ block_cache_root

block_cache_t* block_cache_root
extern

the cache that serves the root filesystem, for /proc/meminfo (NULL before it is set up).