-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac76612
commit 9a3fe56
Showing
9 changed files
with
141 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
|
||
#include <config.h> | ||
#include <dev.h> | ||
#include <types.h> | ||
|
||
#define VIRTIO_DESC_FLAG_NEXT 0x1 | ||
#define VIRTIO_DESC_FLAG_WRITE 0x2 | ||
#define VIRTIO_DESC_FLAG_INDIRECT 0x4 | ||
|
||
typedef struct { | ||
u64 addr; | ||
u32 len; | ||
u16 flags; | ||
u16 next; | ||
} virtio_desc_t; | ||
|
||
typedef struct { | ||
u16 flags; | ||
u16 idx; | ||
u16 ring[VIRTIO_RING_SIZE]; | ||
} virtio_avail_queue_t; | ||
|
||
typedef struct { | ||
u32 id; | ||
u32 len; | ||
} virtio_used_elem_t; | ||
|
||
typedef struct { | ||
u16 flags; | ||
u16 idx; | ||
virtio_used_elem_t ring[VIRTIO_RING_SIZE]; | ||
} virtio_used_queue_t; | ||
|
||
#define FEATURES 0x20 | ||
#define QUEUE_SEL 0x30 | ||
#define QUEUE_NUM 0x38 | ||
#define QUEUE_READY 0x44 | ||
#define NOTIFY 0x50 | ||
#define STATUS 0x70 | ||
#define QUEUE_DESC_LOW 0x80 | ||
#define QUEUE_DRIVER_LOW 0x90 | ||
#define QUEUE_DEVICE_LOW 0xA0 | ||
|
||
i32 init_virtio_gpu(const dev_node_t *node); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <drivers/virtio.h> | ||
|
||
#include <dev.h> | ||
#include <log.h> | ||
#include <module.h> | ||
|
||
MODULE_NAME("virtio"); | ||
|
||
#define REG(base, reg) *((volatile u32 *) (base + reg)) | ||
#define DEV_ID 0x8 | ||
|
||
static i32 init_dev(const dev_node_t *node) { | ||
switch (REG(node->addr, DEV_ID)) { | ||
case 16: | ||
init_virtio_gpu(node); | ||
log_info("initialized virtio-gpu at 0x%p", node->addr); | ||
break; | ||
} | ||
return 0; | ||
} | ||
|
||
dev_init("virtio", init_dev); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.