]> Zhao Yanbai Git Server - kernel.git/commitdiff
...
authoracevest <zhaoyanbai@126.com>
Wed, 18 Oct 2023 01:35:51 +0000 (09:35 +0800)
committeracevest <zhaoyanbai@126.com>
Wed, 18 Oct 2023 01:35:51 +0000 (09:35 +0800)
drivers/block.c
fs/buffer.c [new file with mode: 0644]
include/buffer.h
include/fs.h
kernel/buffer.c [deleted file]

index baacea91fe3a94a365d6dfc6e74138aba267c38f..674e57e8243f09d801f236fe555cee998dccb833 100644 (file)
@@ -7,22 +7,13 @@
  * ------------------------------------------------------------------------
  */
 
+#include <buffer.h>
 #include <disk.h>
 #include <fs.h>
 #include <ide.h>
 
-#define BLOCK_BUFFER_HASH_TABLE_SIZE 37
-atomic_t hash_cnt;
-blk_buffer_t *block_buffer_hash_table[BLOCK_BUFFER_HASH_TABLE_SIZE] = {
-    0,
-};
-
-int hash(dev_t dev, uint32_t block) { return ((~dev) ^ block) % BLOCK_BUFFER_HASH_TABLE_SIZE; }
-
-blk_buffer_t *get_hash_block_buffer(dev_t dev, uint32_t block, uint16_t size) {}
-
-blk_buffer_t *block_read(dev_t dev, uint32_t block) {
-    blk_buffer_t *bb = 0;
+bbuffer_t *block_read(dev_t dev, uint32_t block) {
+    bbuffer_t *bb = 0;
 
     assert(DEV_MAJOR(dev) == DEV_MAJOR_DISK);
     // assert(DEV_MINOR(dev) == 1);
@@ -51,7 +42,7 @@ void ata_read_ext2_sb() {
     const int size = offset + 1024;
     const int block = 1;
 
-    blk_buffer_t *bb = block_read(system.root_dev, block);
+    bbuffer_t *bb = block_read(system.root_dev, block);
 
     ext2_sb_t *p = (ext2_sb_t *)(bb->data + offset);
     printk("inodes count %u inodes per group %u free %u\n", p->s_inodes_count, p->s_inodes_per_group,
diff --git a/fs/buffer.c b/fs/buffer.c
new file mode 100644 (file)
index 0000000..ecc4efd
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * ------------------------------------------------------------------------
+ *   File Name: buffer.c
+ *      Author: Zhao Yanbai
+ *              2023-06-20 19:30:33 Tuesday CST
+ * Description: none
+ * ------------------------------------------------------------------------
+ */
+
+#include <buffer.h>
+
+#define BLOCK_BUFFER_HASH_TABLE_SIZE 211
+// atomic_t hash_cnt;
+bbuffer_t *block_buffer_hash_table[BLOCK_BUFFER_HASH_TABLE_SIZE] = {
+    0,
+};
+
+int hash(dev_t dev, uint32_t block) { return ((~dev) ^ block) % BLOCK_BUFFER_HASH_TABLE_SIZE; }
+
+bbuffer_t *get_hash_block_buffer(dev_t dev, uint32_t block, uint16_t size) {}
+
+void init_buffer() {}
index fe84e139dd24f09bb99f8a32b557f1684e0bde3b..1299ba9bb56ca4fee2f5e207b393c33637b911bb 100644 (file)
@@ -8,3 +8,15 @@
  */
 
 #pragma once
+
+#include <fs.h>
+
+typedef struct bbuffer {
+    uint32_t block;       // block number
+    char *data;           //
+    uint16_t block_size;  // block size
+    dev_t dev;
+    page_t *page;
+    struct bbuffer *next;
+    struct bbuffer *hash_next;
+} bbuffer_t;
index b84216f5345414293888004ac2bbdff09478508f..7750690b24dacde030d4e649d3b007b6ab8a9db3 100644 (file)
@@ -109,14 +109,4 @@ static inline pInode find_empty_inode()
 
 typedef uint32_t dev_t;
 
-typedef struct blk_buffer {
-    uint32_t block;       // block number
-    char *data;           //
-    uint16_t block_size;  // block size
-    dev_t dev;
-    page_t *page;
-    struct blk_buffer *next;
-    struct blk_buffer *hash_next;
-} blk_buffer_t;
-
 #endif  //_FS_H
diff --git a/kernel/buffer.c b/kernel/buffer.c
deleted file mode 100644 (file)
index 18b7c9b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * ------------------------------------------------------------------------
- *   File Name: buffer.c
- *      Author: Zhao Yanbai
- *              2023-06-20 19:30:33 Tuesday CST
- * Description: none
- * ------------------------------------------------------------------------
- */
-
-typedef struct buffer {
-    //
-} buffer_t;
-
-void init_buffer() {}