⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

VirtioGpuDriver

Struct VirtioGpuDriver 

Source
pub struct VirtioGpuDriver { /* private fields */ }
Expand description

VirtIO GPU Driver

Manages a single virtio-gpu device including its control and cursor virtqueues, display configuration, and framebuffer resources.

Implementations§

Source§

impl VirtioGpuDriver

Source

pub fn new(mmio_base: usize) -> Result<Self, KernelError>

Create and initialize a new VirtIO GPU driver at the given MMIO base.

Source

pub fn get_display_info(&mut self) -> Result<VirtioGpuDisplayOne, KernelError>

Query display information from the device.

Returns the first enabled display mode (scanout 0 is preferred).

Source

pub fn create_resource_2d( &mut self, resource_id: u32, format: u32, width: u32, height: u32, ) -> Result<(), KernelError>

Create a 2D resource on the host.

Source

pub fn resource_unref(&mut self, resource_id: u32) -> Result<(), KernelError>

Destroy a 2D resource on the host.

Source

pub fn attach_backing( &mut self, resource_id: u32, addr: u64, length: u32, ) -> Result<(), KernelError>

Attach backing store (guest memory) to a resource.

The command includes a VirtioGpuMemEntry that describes the physical address and length of the backing memory.

Source

pub fn detach_backing(&mut self, resource_id: u32) -> Result<(), KernelError>

Detach backing store from a resource.

Source

pub fn set_scanout( &mut self, scanout_id: u32, resource_id: u32, rect: VirtioGpuRect, ) -> Result<(), KernelError>

Set scanout: bind a resource (or region of it) to a display output.

Source

pub fn transfer_to_host_2d( &mut self, resource_id: u32, rect: VirtioGpuRect, ) -> Result<(), KernelError>

Transfer data from guest backing store to host resource.

Source

pub fn resource_flush( &mut self, resource_id: u32, rect: VirtioGpuRect, ) -> Result<(), KernelError>

Flush a resource region to the display.

Source

pub fn setup_framebuffer(&mut self) -> Result<(), KernelError>

Set up the primary framebuffer: create a 2D resource, attach a backing pixel buffer, and bind it to scanout 0.

Source

pub fn flush_framebuffer(&mut self) -> Result<(), KernelError>

Flush the framebuffer to the display.

Transfers the entire backing buffer to the host and triggers a display refresh. Call this after modifying the framebuffer pixels.

Source

pub fn flush_region(&mut self, rect: VirtioGpuRect) -> Result<(), KernelError>

Flush a sub-region of the framebuffer.

More efficient than flushing the entire framebuffer when only a small area has changed.

Source

pub fn get_framebuffer_mut(&mut self) -> Option<&mut [u32]>

Get mutable access to the framebuffer pixel buffer.

Returns a slice of BGRX pixels. Modify the pixels, then call flush_framebuffer() or flush_region() to push changes to the display.

Source

pub fn get_framebuffer(&self) -> Option<&[u32]>

Get read-only access to the framebuffer pixel buffer.

Source

pub fn width(&self) -> u32

Get the display width in pixels.

Source

pub fn height(&self) -> u32

Get the display height in pixels.

Source

pub fn is_ready(&self) -> bool

Check if the driver is initialized and ready.

Source

pub fn supports_edid(&self) -> bool

Check if EDID is supported.

Source

pub fn supports_virgl(&self) -> bool

Check if 3D (VIRGL) is supported.

Source

pub fn framebuffer_resource_id(&self) -> u32

Get the framebuffer resource ID.

Source

pub fn alloc_resource_id(&mut self) -> u32

Allocate a new resource ID.

Source

pub fn set_pixel( &mut self, x: u32, y: u32, color: u32, ) -> Result<(), KernelError>

Set a pixel in the framebuffer (BGRX format).

Does NOT flush automatically – call flush_framebuffer() after modifying pixels.

Source

pub fn fill_rect( &mut self, x: u32, y: u32, w: u32, h: u32, color: u32, ) -> Result<(), KernelError>

Fill a rectangle in the framebuffer with a solid color.

Does NOT flush automatically.

Source

pub fn blit( &mut self, buffer: &[u32], x: u32, y: u32, w: u32, h: u32, ) -> Result<(), KernelError>

Blit a buffer of pixels into the framebuffer.

The buffer must contain w * h BGRX pixels. Does NOT flush automatically.

Source

pub fn clear(&mut self, color: u32)

Clear the framebuffer with a solid color.

Does NOT flush automatically.

Auto Trait Implementations§

§

impl Freeze for VirtioGpuDriver

§

impl RefUnwindSafe for VirtioGpuDriver

§

impl Send for VirtioGpuDriver

§

impl Sync for VirtioGpuDriver

§

impl Unpin for VirtioGpuDriver

§

impl !UnwindSafe for VirtioGpuDriver

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.