diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-01-02 00:47:16 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-01-02 00:58:45 +0800 |
| commit | d8eaa13f2efc1eeca4e5f230d5a2d535aaf27338 (patch) | |
| tree | 6ca02e2a2d1b1121620431059e322724a3c94a33 /include/kernel/buf.h | |
| parent | 2dde56422dcfb94affee2baffc8d240ad16ad4b2 (diff) | |
| download | lume-d8eaa13f2efc1eeca4e5f230d5a2d535aaf27338.tar.gz lume-d8eaa13f2efc1eeca4e5f230d5a2d535aaf27338.tar.xz | |
dev(file-system): establish VFS and Read-only FAT32 File System
Diffstat (limited to 'include/kernel/buf.h')
| -rw-r--r-- | include/kernel/buf.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/kernel/buf.h b/include/kernel/buf.h new file mode 100644 index 0000000..099523d --- /dev/null +++ b/include/kernel/buf.h @@ -0,0 +1,30 @@ +#pragma once +#include "common/types.h" +#include "kernel/spinlock.h" + +#define BSIZE 1024 +#define NBUF 30 + +struct Buf +{ + int valid; // Whether the data has been read from the disk (1=valid, 0=invalid) + int disk; // Whether it has been held by the driver (dirty bit/write-back flag is usually extended here) + uint32 dev; // Device Number + uint32 blockno; // Block number + uint32 refcnt; // Reference Counting + struct Buf *prev; // LRU linked list + struct Buf *next; + uchar data[BSIZE]; + + Mutex lock; // Sleep Lock +}; + +namespace BufferCache +{ + void init(); + struct Buf *bread(uint32 dev, uint32 blockno); + void bwrite(struct Buf *b); + void brelse(struct Buf *b); + void bpin(struct Buf *b); + void bunpin(struct Buf *b); +} // namespace BufferCache |
