XenevaOS
Loading...
Searching...
No Matches
Macros | Functions | Variables
virtgpu.cpp File Reference
#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"
Include dependency graph for virtgpu.cpp:

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 ()
 
VirtioCommonCfggpu_get_config_pointer ()
 gpu_get_config_pointer – return the pointer virtio common config descriptor from pcie
 

Variables

AuVFSNodefsnode
 

Detailed Description

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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

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.

Macro Definition Documentation

◆ VIRTIO_GPU_F_CONTEXT_INIT

#define VIRTIO_GPU_F_CONTEXT_INIT   (1ULL << 4)

◆ VIRTIO_GPU_F_EDID

#define VIRTIO_GPU_F_EDID   (1ULL << 1)

◆ VIRTIO_GPU_F_RESOURCE_BLOB

#define VIRTIO_GPU_F_RESOURCE_BLOB   (1ULL << 3)

◆ VIRTIO_GPU_F_RESOURCE_UUID

#define VIRTIO_GPU_F_RESOURCE_UUID   (1ULL << 2)

◆ VIRTIO_GPU_F_VIRGL

#define VIRTIO_GPU_F_VIRGL   (1ULL << 0)

feature bits

◆ VIRTIO_PCI_CAP_COMMON_CFG

#define VIRTIO_PCI_CAP_COMMON_CFG   1

◆ VIRTIO_PCI_CAP_DEVICE_CFG

#define VIRTIO_PCI_CAP_DEVICE_CFG   4

◆ VIRTIO_PCI_CAP_ID

#define VIRTIO_PCI_CAP_ID   0x09

◆ VIRTIO_STATUS_ACKNOWLEDGE

#define VIRTIO_STATUS_ACKNOWLEDGE   1

◆ VIRTIO_STATUS_DRIVER

#define VIRTIO_STATUS_DRIVER   2

◆ VIRTIO_STATUS_DRIVER_OK

#define VIRTIO_STATUS_DRIVER_OK   4

◆ VIRTIO_STATUS_FEATURES_OK

#define VIRTIO_STATUS_FEATURES_OK   8

◆ VIRTQ_DESC_F_NEXT

#define VIRTQ_DESC_F_NEXT   1

◆ VIRTQ_DESC_F_WRITE

#define VIRTQ_DESC_F_WRITE   2

Function Documentation

◆ AuDriverMain()

AU_EXTERN AU_EXPORT int AuDriverMain ( )

reset the device first

negotiate features

initialize both queues

initialize the screen data and start scanout 0

◆ AuDriverUnload()

AU_EXTERN AU_EXPORT int AuDriverUnload ( )

◆ gpu_allocate_resource_id()

int gpu_allocate_resource_id ( )

gpu_allocate_resource_id – allocates resource for commands

Returns
newly allocated resource id

◆ gpu_attach_back_cmd()

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

Parameters
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

◆ gpu_execute_command()

void gpu_execute_command ( VirtioCommonCfg cfg,
void *  cmd,
size_t  len 
)

gpu_execute_command – submit a command to gpu

Parameters
cfg– pointer to virtio common config
cmd– Pointer to command struct
len– total length of the command

◆ gpu_feature_negotiate()

void gpu_feature_negotiate ( VirtioCommonCfg cfg)

gpu_feature_negotiate – check available features of host device and enable only those supported by the driver

Parameters
cfg– pointer to virtio common config

examine the supported feature step by step

◆ gpu_get_config_pointer()

VirtioCommonCfg * gpu_get_config_pointer ( )

gpu_get_config_pointer – return the pointer virtio common config descriptor from pcie

Returns
system config descriptor from pcie config space

◆ gpu_initialize_controlq()

void gpu_initialize_controlq ( VirtioCommonCfg cfg)

gpu_initialize_controlq – initialize the control queue

Parameters
cfg- Pointer to virtio common config

◆ gpu_initialize_cursorq()

void gpu_initialize_cursorq ( VirtioCommonCfg cfg)

gpu_initialize_cursorq – initialize the cursor queue

Parameters
cfg– Pointer to virtio common config

◆ gpu_is_edid_supported()

bool gpu_is_edid_supported ( )

gpu_is_edid_supported – returns if edid blob is supported by host

Returns
true if supported, false if not supported

◆ gpu_is_virgl_supported()

bool gpu_is_virgl_supported ( )

gpu_is_virgl_supported – returns if virgl is supported by host

Returns
true if supported, false if not supported

◆ gpu_notify_queue()

void gpu_notify_queue ( VirtioCommonCfg cfg,
uint16_t  queueIdx 
)

gpu_notify_queue – notify host that new command is present

Parameters
queueIdx– queue number, zero for controlq and one for cursorq

◆ gpu_reset_device()

void gpu_reset_device ( VirtioCommonCfg cfg)

gpu_reset_device – reset the virtio gpu device

Parameters
cfg– pointer to virtio common config

◆ gpu_virt_interrupt()

void gpu_virt_interrupt ( int  spinum)

Virtio-keyboard interrupt handler.

shoud read the status register

but skipping it for now

◆ virtio_gpu_iocontrol()

int virtio_gpu_iocontrol ( AuVFSNode file,
int  code,
void *  arg 
)

virtio_gpu_iocontrol – io control for virtio gpu

Parameters
file– Pointer to gpu file struct
code– code number
arg– data struct passed to this driver

Variable Documentation

◆ fsnode

AuVFSNode* fsnode