From: acevest Date: Wed, 18 Oct 2023 01:35:51 +0000 (+0800) Subject: ... X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=faeb9951cce0870fa8f7cef25558e96d7ec60d3b;p=kernel.git ... --- diff --git a/drivers/block.c b/drivers/block.c index baacea9..674e57e 100644 --- a/drivers/block.c +++ b/drivers/block.c @@ -7,22 +7,13 @@ * ------------------------------------------------------------------------ */ +#include #include #include #include -#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 index 0000000..ecc4efd --- /dev/null +++ b/fs/buffer.c @@ -0,0 +1,22 @@ +/* + * ------------------------------------------------------------------------ + * File Name: buffer.c + * Author: Zhao Yanbai + * 2023-06-20 19:30:33 Tuesday CST + * Description: none + * ------------------------------------------------------------------------ + */ + +#include + +#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() {} diff --git a/include/buffer.h b/include/buffer.h index fe84e13..1299ba9 100644 --- a/include/buffer.h +++ b/include/buffer.h @@ -8,3 +8,15 @@ */ #pragma once + +#include + +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; diff --git a/include/fs.h b/include/fs.h index b84216f..7750690 100644 --- a/include/fs.h +++ b/include/fs.h @@ -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 index 18b7c9b..0000000 --- a/kernel/buffer.c +++ /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() {}