Commit ef147b31 authored by 某某某's avatar 某某某
Browse files

read

Showing with 52 additions and 1 deletion
+52 -1
......@@ -11,6 +11,7 @@
struct bio {
struct bio_vec *bi_io_vec;
uint8 bi_rw;
struct bio *next;
};
......@@ -24,3 +25,9 @@ struct bio_vec {
struct bio_vec *next;/* the pointer of next bio segment */
void *buff; /* the address to begin read/write */
};
struct request_queue {
struct bio *queue_head;
spinlock_t rq_lock;
};
\ No newline at end of file
......@@ -22,6 +22,7 @@
#include "defs.h"
#include "fs/fs.h"
#include "fs/blk_device.h"
#include "bio.h"
#ifdef K210
extern uint8_t sd_read_sector_dma(uint8_t *data_buff, uint32_t sector, uint32_t count);
......@@ -200,3 +201,46 @@ bunpin(struct buf *b) {
}
/*************************new add func**************************/
struct request_queue rq = {.queue_head = NULL};
void submit_bio(uint8 rw, struct bio *bio){
acquire(&rq.rq_lock);
bio->next = rq.queue_head;
rq.queue_head = bio;
make_request(rw);
release(&rq.rq_lock);
}
void make_request(uint8 rw){
struct bio *cur_bio;
struct bio_vec *cur_bio_vec;
cur_bio = rq.queue_head;
while(cur_bio){
cur_bio_vec = cur_bio->bi_io_vec;
/* 对于一次请求的每个段 */
while(cur_bio_vec){
for(int i = 0; i < cur_bio_vec->count; i++){
#if defined K210
panic("make_request: not implementation!");
#elif defined QEMU
struct buf *b;
b->blockno = cur_bio_vec->bv_start_num + i;
b->data = cur_bio_vec->buff + i*BSIZE;
virtio_disk_rw(b, rw);)
#else
panic("no defined platform");
#endif
}
cur_bio_vec = cur_bio_vec->next;
}
cur_bio = cur_bio->next;
}
}
\ No newline at end of file
......@@ -31,7 +31,7 @@ int readpage(entry_t *entry, uint64 buff, uint32 flpgnum){
struct bio *bio = do_readpage(entry, buff, flpgnum);
if(bio)
submit_bio(bio);
submit_bio(READ, bio);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment