Skip to content
Snippets Groups Projects
Commit 03a7b336 authored by Dor Laor's avatar Dor Laor
Browse files

Remember to erase the empty page used for the block testing by

pushing it into a dummy bio structure. In addition, expand the test some more
parent aa2cef85
No related branches found
No related tags found
No related merge requests found
...@@ -87,6 +87,7 @@ struct driver virtio_blk_driver = { ...@@ -87,6 +87,7 @@ struct driver virtio_blk_driver = {
virtio_blk::~virtio_blk() virtio_blk::~virtio_blk()
{ {
//TODO: In theory maintain the list of free instances and gc it //TODO: In theory maintain the list of free instances and gc it
// including the thread objects and their stack
} }
bool virtio_blk::load(void) bool virtio_blk::load(void)
...@@ -117,7 +118,11 @@ struct driver virtio_blk_driver = { ...@@ -117,7 +118,11 @@ struct driver virtio_blk_driver = {
prv = reinterpret_cast<struct virtio_blk_priv*>(dev->private_data); prv = reinterpret_cast<struct virtio_blk_priv*>(dev->private_data);
prv->drv = this; prv->drv = this;
test(); for (int i=0;i<2000;i++) {
debug(fmt("Running test %d") % i);
test();
//sched::thread::current()->yield();
}
} }
return true; return true;
...@@ -128,6 +133,14 @@ struct driver virtio_blk_driver = { ...@@ -128,6 +133,14 @@ struct driver virtio_blk_driver = {
return (true); return (true);
} }
//temporal hack for the local version of virtio tests
extern "C" {
static void blk_bio_done(struct bio*bio) {
free(bio->bio_data);
destroy_bio(bio);
};
}
// to be removed soon once we move the test from here to the vfs layer // to be removed soon once we move the test from here to the vfs layer
virtio_blk::virtio_blk_req* virtio_blk::make_virtio_req(u64 sector, virtio_blk_request_type type, int val) virtio_blk::virtio_blk_req* virtio_blk::make_virtio_req(u64 sector, virtio_blk_request_type type, int val)
{ {
...@@ -136,6 +149,14 @@ struct driver virtio_blk_driver = { ...@@ -136,6 +149,14 @@ struct driver virtio_blk_driver = {
memset(buf, val, page_size); memset(buf, val, page_size);
sg->add(mmu::virt_to_phys(buf), page_size); sg->add(mmu::virt_to_phys(buf), page_size);
struct bio* bio = alloc_bio();
if (!bio) {
debug("bio_alloc failed");
return nullptr;
}
bio->bio_data = buf;
bio->bio_done = blk_bio_done;
virtio_blk_outhdr* hdr = new virtio_blk_outhdr; virtio_blk_outhdr* hdr = new virtio_blk_outhdr;
hdr->type = type; hdr->type = type;
hdr->ioprio = 0; hdr->ioprio = 0;
...@@ -144,11 +165,11 @@ struct driver virtio_blk_driver = { ...@@ -144,11 +165,11 @@ struct driver virtio_blk_driver = {
//push 'output' buffers to the beginning of the sg list //push 'output' buffers to the beginning of the sg list
sg->add(mmu::virt_to_phys(hdr), sizeof(struct virtio_blk_outhdr), true); sg->add(mmu::virt_to_phys(hdr), sizeof(struct virtio_blk_outhdr), true);
virtio_blk_res* res = reinterpret_cast<virtio_blk_res*>(malloc(sizeof(virtio_blk_res))); virtio_blk_res* res = new virtio_blk_res;
res->status = 0; res->status = 0;
sg->add(mmu::virt_to_phys(res), sizeof (struct virtio_blk_res)); sg->add(mmu::virt_to_phys(res), sizeof (struct virtio_blk_res));
virtio_blk_req* req = new virtio_blk_req(hdr, sg, res); virtio_blk_req* req = new virtio_blk_req(hdr, sg, res, bio);
return req; return req;
} }
...@@ -179,7 +200,7 @@ struct driver virtio_blk_driver = { ...@@ -179,7 +200,7 @@ struct driver virtio_blk_driver = {
if (!queue->add_buf(req->payload,1,2,req)) { if (!queue->add_buf(req->payload,1,2,req)) {
break; break;
} }
queue->kick(); // should be out of the loop but I like plenty of irqs for the test if (i%2) queue->kick(); // should be out of the loop but I like plenty of irqs for the test
} }
...@@ -279,7 +300,7 @@ struct driver virtio_blk_driver = { ...@@ -279,7 +300,7 @@ struct driver virtio_blk_driver = {
//push 'output' buffers to the beginning of the sg list //push 'output' buffers to the beginning of the sg list
sg->add(mmu::virt_to_phys(hdr), sizeof(struct virtio_blk_outhdr), true); sg->add(mmu::virt_to_phys(hdr), sizeof(struct virtio_blk_outhdr), true);
virtio_blk_res* res = reinterpret_cast<virtio_blk_res*>(malloc(sizeof(virtio_blk_res))); virtio_blk_res* res = new virtio_blk_res;
res->status = 0; res->status = 0;
sg->add(mmu::virt_to_phys(res), sizeof (struct virtio_blk_res)); sg->add(mmu::virt_to_phys(res), sizeof (struct virtio_blk_res));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment