61 lines
2.0 KiB
Rust
61 lines
2.0 KiB
Rust
//! Device data structures and options
|
|
|
|
use crate::{io::terminal, process::ProcessGroupId};
|
|
|
|
/// Represents a video device framebuffer
|
|
#[derive(Clone, Copy, Debug)]
|
|
#[repr(C)]
|
|
pub struct Framebuffer {
|
|
/// Width in pixels
|
|
pub width: u32,
|
|
/// Height in pixels
|
|
pub height: u32,
|
|
/// Amount of bytes to add to move from one row to the next
|
|
pub stride: usize,
|
|
/// Size of the framebuffer in bytes
|
|
pub size: usize,
|
|
}
|
|
|
|
request_group!(
|
|
#[doc = "Terminal device requests"]
|
|
pub enum TerminalRequestVariant<'de> {
|
|
#[doc = "Update the terminal options"]
|
|
0x1000: SetTerminalOptions(terminal::TerminalOptions, ()),
|
|
#[doc = "Query the terminal options"]
|
|
0x1001: GetTerminalOptions((), terminal::TerminalOptions),
|
|
#[doc = "Update the terminal size"]
|
|
0x1002: SetTerminalSize(terminal::TerminalSize, ()),
|
|
#[doc = "Query the terminal size"]
|
|
0x1003: GetTerminalSize((), terminal::TerminalSize),
|
|
#[doc = "Update the terminal's foreground process group ID"]
|
|
0x1004: SetTerminalGroup(ProcessGroupId, ()),
|
|
#[doc = "Dummy option to test if a device is a terminal"]
|
|
0x1005: IsTerminal((), ()),
|
|
}
|
|
);
|
|
|
|
request_group!(
|
|
#[doc = "Common device requests"]
|
|
pub enum DeviceRequestVariant<'de> {
|
|
#[doc = "\"Acquire\" ownership of the device, preventing others from accessing it"]
|
|
0x0001: AcquireDevice((), ()),
|
|
#[doc = "\"Releases\" ownership of the device"]
|
|
0x0002: ReleaseDevice((), ()),
|
|
}
|
|
);
|
|
|
|
request_group!(
|
|
#[doc = "Video/graphics device requests"]
|
|
pub enum VideoRequestVariant<'de> {
|
|
#[doc = "Retrieves the display's currently active framebuffer info"]
|
|
0x2000: GetActiveFramebuffer((), Framebuffer),
|
|
// TODO allow flushing a region of the display
|
|
#[doc = "Tells the display driver to send the framebuffer data to the display"]
|
|
0x2001: FlushDisplay((), ()),
|
|
}
|
|
);
|
|
|
|
abi_serde::impl_struct_serde!(Framebuffer: [
|
|
width, height, stride, size
|
|
]);
|