miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
block_layer.c File Reference
#include <miniOS/io.h>
#include <miniOS/drivers/block_layer.h>
#include <miniOS/drivers/ata.h>
#include <miniOS/mm/pmm.h>
#include <miniOS/mm/vmm.h>
#include <miniOS/mm/heap.h>
#include <miniOS/arch/x86_64/spinlock.h>
#include <string.h>
Include dependency graph for block_layer.c:

Classes

struct  cache_entry_t
struct  block_cache_t

Macros

#define BLOCK_SIZE   512
#define CACHE_SIZE_BLOCKS   64

Functions

static cache_entry_tblock_cache_lookup_locked (uint64_t lba)
static cache_entry_tblock_cache_evict_locked (void)
void block_layer_init (void)
 Called once during kernel startup to allocate memory for the cache and prepare the block layer for use.
int block_read (uint64_t lba, uint16_t count, void *buf)
 Reads count blocks starting at lba into buf. If count is 1, this operation will be serviced by the cache. Multi-block reads currently bypass the cache and read directly from the disk.
int block_write (uint64_t lba, uint16_t count, const void *buf)
 Writes count blocks starting at lba. This is a write-through operation. The data is written to the underlying disk, and if a cached copy of the block exists, it is updated.

Variables

static block_cache_t g_block_cache
static spinlock_t g_cache_lock

Macro Definition Documentation

◆ BLOCK_SIZE

#define BLOCK_SIZE   512

◆ CACHE_SIZE_BLOCKS

#define CACHE_SIZE_BLOCKS   64

Function Documentation

◆ block_cache_evict_locked()

cache_entry_t * block_cache_evict_locked ( void )
static
Here is the caller graph for this function:

◆ block_cache_lookup_locked()

cache_entry_t * block_cache_lookup_locked ( uint64_t lba)
static
Here is the caller graph for this function:

Variable Documentation

◆ g_block_cache

block_cache_t g_block_cache
static

◆ g_cache_lock

spinlock_t g_cache_lock
static