|
XenevaOS
|
#include <aurora.h>#include <aucon.h>#include <Drivers/uart.h>#include <pcie.h>#include <Drivers/virtio.h>#include <Mm/vmmngr.h>#include <Mm/pmmngr.h>#include <Mm/kmalloc.h>#include <Hal/AA64/aa64lowlevel.h>#include <string.h>#include "virtiogpu.h"#include "virtscreen.h"#include <Hal/AA64/gic.h>#include <Fs/vfs.h>#include <Fs/Dev/devfs.h>#include "cmd2d.h"
Macros | |
| #define | VIRTIO_PCI_CAP_ID 0x09 |
| #define | VIRTIO_PCI_CAP_COMMON_CFG 1 |
| #define | VIRTIO_PCI_CAP_DEVICE_CFG 4 |
| #define | VIRTIO_STATUS_ACKNOWLEDGE 1 |
| #define | VIRTIO_STATUS_DRIVER 2 |
| #define | VIRTIO_STATUS_DRIVER_OK 4 |
| #define | VIRTIO_STATUS_FEATURES_OK 8 |
| #define | VIRTIO_GPU_F_VIRGL (1ULL << 0) |
| #define | VIRTIO_GPU_F_EDID (1ULL << 1) |
| #define | VIRTIO_GPU_F_RESOURCE_UUID (1ULL << 2) |
| #define | VIRTIO_GPU_F_RESOURCE_BLOB (1ULL << 3) |
| #define | VIRTIO_GPU_F_CONTEXT_INIT (1ULL << 4) |
| #define | VIRTQ_DESC_F_NEXT 1 |
| #define | VIRTQ_DESC_F_WRITE 2 |
Functions | |
| AU_EXTERN AU_EXPORT int | AuDriverUnload () |
| void | gpu_reset_device (VirtioCommonCfg *cfg) |
| gpu_reset_device – reset the virtio gpu device | |
| void | gpu_feature_negotiate (VirtioCommonCfg *cfg) |
| gpu_feature_negotiate – check available features of host device and enable only those supported by the driver | |
| bool | gpu_is_virgl_supported () |
| gpu_is_virgl_supported – returns if virgl is supported by host | |
| bool | gpu_is_edid_supported () |
| gpu_is_edid_supported – returns if edid blob is supported by host | |
| void | gpu_initialize_controlq (VirtioCommonCfg *cfg) |
| void | gpu_initialize_cursorq (VirtioCommonCfg *cfg) |
| gpu_initialize_cursorq – initialize the cursor queue | |
| void | gpu_notify_queue (VirtioCommonCfg *cfg, uint16_t queueIdx) |
| gpu_notify_queue – notify host that new command is present | |
| void | gpu_execute_command (VirtioCommonCfg *cfg, void *cmd, size_t len) |
| gpu_execute_command – submit a command to gpu | |
| void | gpu_attach_back_cmd (VirtioCommonCfg *cfg, void *req, uint32_t len1, void *req2, uint32_t len2) |
| gpu_attach_back_cmd – attach backing stroe command needs two descriptor previous gpu_execute_command won't satisfy this | |
| int | gpu_allocate_resource_id () |
| gpu_allocate_resource_id – allocates resource for commands | |
| void | gpu_virt_interrupt (int spinum) |
| Virtio-keyboard interrupt handler. | |
| int | virtio_gpu_iocontrol (AuVFSNode *file, int code, void *arg) |
| virtio_gpu_iocontrol – io control for virtio gpu | |
| AU_EXTERN AU_EXPORT int | AuDriverMain () |
| VirtioCommonCfg * | gpu_get_config_pointer () |
| gpu_get_config_pointer – return the pointer virtio common config descriptor from pcie | |
Variables | |
| AuVFSNode * | fsnode |
BSD 2-Clause License
Copyright (c) 2022-2023, Manas Kamal Choudhury All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| #define VIRTIO_GPU_F_CONTEXT_INIT (1ULL << 4) |
| #define VIRTIO_GPU_F_EDID (1ULL << 1) |
| #define VIRTIO_GPU_F_RESOURCE_BLOB (1ULL << 3) |
| #define VIRTIO_GPU_F_RESOURCE_UUID (1ULL << 2) |
| #define VIRTIO_GPU_F_VIRGL (1ULL << 0) |
feature bits
| #define VIRTIO_PCI_CAP_COMMON_CFG 1 |
| #define VIRTIO_PCI_CAP_DEVICE_CFG 4 |
| #define VIRTIO_PCI_CAP_ID 0x09 |
| #define VIRTIO_STATUS_ACKNOWLEDGE 1 |
| #define VIRTIO_STATUS_DRIVER 2 |
| #define VIRTIO_STATUS_DRIVER_OK 4 |
| #define VIRTIO_STATUS_FEATURES_OK 8 |
| #define VIRTQ_DESC_F_NEXT 1 |
| #define VIRTQ_DESC_F_WRITE 2 |
reset the device first
negotiate features
initialize both queues
initialize the screen data and start scanout 0
| int gpu_allocate_resource_id | ( | ) |
gpu_allocate_resource_id – allocates resource for commands
| void gpu_attach_back_cmd | ( | VirtioCommonCfg * | cfg, |
| void * | req, | ||
| uint32_t | len1, | ||
| void * | req2, | ||
| uint32_t | len2 | ||
| ) |
gpu_attach_back_cmd – attach backing stroe command needs two descriptor previous gpu_execute_command won't satisfy this
| cfg | – pointer to virtio common config |
| req | – pointer to request command one |
| len1 | – request command one length |
| req2 | – pointer to request command two |
| len2 | – request command two length |
| void gpu_execute_command | ( | VirtioCommonCfg * | cfg, |
| void * | cmd, | ||
| size_t | len | ||
| ) |
gpu_execute_command – submit a command to gpu
| cfg | – pointer to virtio common config |
| cmd | – Pointer to command struct |
| len | – total length of the command |
| void gpu_feature_negotiate | ( | VirtioCommonCfg * | cfg | ) |
gpu_feature_negotiate – check available features of host device and enable only those supported by the driver
| cfg | – pointer to virtio common config |
examine the supported feature step by step
| VirtioCommonCfg * gpu_get_config_pointer | ( | ) |
gpu_get_config_pointer – return the pointer virtio common config descriptor from pcie
| void gpu_initialize_controlq | ( | VirtioCommonCfg * | cfg | ) |
gpu_initialize_controlq – initialize the control queue
| cfg | - Pointer to virtio common config |
| void gpu_initialize_cursorq | ( | VirtioCommonCfg * | cfg | ) |
gpu_initialize_cursorq – initialize the cursor queue
| cfg | – Pointer to virtio common config |
| bool gpu_is_edid_supported | ( | ) |
gpu_is_edid_supported – returns if edid blob is supported by host
| bool gpu_is_virgl_supported | ( | ) |
gpu_is_virgl_supported – returns if virgl is supported by host
| void gpu_notify_queue | ( | VirtioCommonCfg * | cfg, |
| uint16_t | queueIdx | ||
| ) |
gpu_notify_queue – notify host that new command is present
| queueIdx | – queue number, zero for controlq and one for cursorq |
| void gpu_reset_device | ( | VirtioCommonCfg * | cfg | ) |
gpu_reset_device – reset the virtio gpu device
| cfg | – pointer to virtio common config |
| void gpu_virt_interrupt | ( | int | spinum | ) |
Virtio-keyboard interrupt handler.
shoud read the status register
but skipping it for now
| int virtio_gpu_iocontrol | ( | AuVFSNode * | file, |
| int | code, | ||
| void * | arg | ||
| ) |
virtio_gpu_iocontrol – io control for virtio gpu
| file | – Pointer to gpu file struct |
| code | – code number |
| arg | – data struct passed to this driver |
| AuVFSNode* fsnode |