37 lines
882 B
C
37 lines
882 B
C
|
|
#ifndef SOCKS_BLOCK_H_
|
||
|
|
#define SOCKS_BLOCK_H_
|
||
|
|
|
||
|
|
#include <socks/types.h>
|
||
|
|
#include <socks/btree.h>
|
||
|
|
#include <socks/locks.h>
|
||
|
|
#include <socks/status.h>
|
||
|
|
#include <stdbool.h>
|
||
|
|
|
||
|
|
enum block_device_flags {
|
||
|
|
BLOCK_DEVICE_NO_BCACHE = 0x01u,
|
||
|
|
};
|
||
|
|
|
||
|
|
struct bcache {
|
||
|
|
unsigned int b_sector_size;
|
||
|
|
unsigned int b_sectors_per_page;
|
||
|
|
struct btree b_pagetree;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct bcache_sector {
|
||
|
|
struct vm_page *sect_page;
|
||
|
|
unsigned int sect_index;
|
||
|
|
void *sect_buf;
|
||
|
|
bool sect_present;
|
||
|
|
};
|
||
|
|
|
||
|
|
extern struct bcache *bcache_create(unsigned int block_size);
|
||
|
|
extern void bcache_destroy(struct bcache *cache);
|
||
|
|
|
||
|
|
extern kern_status_t bcache_init(struct bcache *cache, unsigned int block_size);
|
||
|
|
extern void bcache_deinit(struct bcache *cache);
|
||
|
|
|
||
|
|
extern kern_status_t bcache_get(struct bcache *cache, sectors_t at, bool create, struct bcache_sector *out);
|
||
|
|
extern void bcache_mark_present(struct bcache_sector *sect);
|
||
|
|
|
||
|
|
#endif
|