summaryrefslogtreecommitdiff
path: root/sys/include
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-08-16 20:23:15 -0400
committerIan Moffett <ian@osmora.org>2025-08-16 20:35:13 -0400
commit7b0701707857a3205cbd4fc69c08429a193c5bff (patch)
tree9e12a704d9b59ddff115d0cfafee77c4ed2b938b /sys/include
parent4386cfb6490025c4d0f464e31cf4a8d90f065a1b (diff)
kernel: disk: Introduce virtual blocksmain
This commit implements the concept of virtual blocks which may be bigger than the hardware block size (e.g., 512 bytes). The virtual block size must be a multiple of the hardware blocksize. The system will panic if this condition is not met. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/include')
-rw-r--r--sys/include/sys/disk.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/include/sys/disk.h b/sys/include/sys/disk.h
index f6ed126..e503e21 100644
--- a/sys/include/sys/disk.h
+++ b/sys/include/sys/disk.h
@@ -33,9 +33,33 @@
#include <sys/syscall.h>
#include <sys/queue.h>
#include <sys/device.h>
+#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/limits.h>
#include <sys/cdefs.h>
+#if defined(_KERNEL)
+#include <dev/dcdr/cache.h>
+#endif /* _KERNEL */
+
+/*
+ * V_BSIZE is the virtual block size in bytes used
+ * by the disk framework. The virtual block size is a
+ * multiple of the hardware block size and defines
+ * how many bytes a virtual block is made up of.
+ *
+ * A virtual block is simply a unit specific to
+ * the disk framework that represents multiple
+ * hardware disk blocks.
+ */
+#if defined(__V_BSIZE)
+#define V_BSIZE __V_BSIZE
+#else
+#define V_BSIZE 4096
+#endif /* __V_BSIZE */
+
+/* Sanitize the silly human's input */
+_Static_assert(V_BSIZE > 512, "V_BSIZE must be > 512");
+_Static_assert((V_BSIZE & 1) == 0, "V_BSIZE must be a power of two");
#define DISK_PRIMARY 0 /* ID of primary disk */