drivers/graphics/bgad: Remove bgad
The only thing it does it changing the size of the region that the graphics adapter sees as framebuffer. It doesn't actually tell vesad to resize the framebuffer nor does it implement an actual full graphics driver. For basic usage the bootloader setup framebuffer is sufficient and for anything more advanced, virtio-gpu is a much better option that we already have a full graphics driver for.
This commit is contained in:
Generated
-15
@@ -216,21 +216,6 @@ dependencies = [
|
||||
"redox_syscall 0.7.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bgad"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"common",
|
||||
"daemon",
|
||||
"inputd",
|
||||
"libredox",
|
||||
"log",
|
||||
"orbclient",
|
||||
"pcid",
|
||||
"redox-scheme",
|
||||
"redox_syscall 0.7.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.3.3"
|
||||
|
||||
@@ -33,7 +33,6 @@ members = [
|
||||
"drivers/audio/ihdad",
|
||||
"drivers/audio/sb16d",
|
||||
|
||||
"drivers/graphics/bgad",
|
||||
"drivers/graphics/console-draw",
|
||||
"drivers/graphics/fbbootlogd",
|
||||
"drivers/graphics/driver-graphics",
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
|
||||
### Graphics
|
||||
|
||||
- [graphics/bgad](graphics/bgad/) - Bochs video driver
|
||||
- [graphics/ihdgd](graphics/ihdgd/) - Intel graphics driver
|
||||
- [graphics/vesad](graphics/vesad/) - VESA video driver
|
||||
- [graphics/virtio-gpud](graphics/virtio-gpud/) - VirtIO-GPU device driver
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
[package]
|
||||
name = "bgad"
|
||||
description = "Bochs graphics driver"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
orbclient.workspace = true
|
||||
log.workspace = true
|
||||
redox-scheme.workspace = true
|
||||
redox_syscall.workspace = true
|
||||
|
||||
common = { path = "../../common" }
|
||||
daemon = { path = "../../../daemon" }
|
||||
inputd = { path = "../../inputd" }
|
||||
pcid = { path = "../../pcid" }
|
||||
libredox.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -1,6 +0,0 @@
|
||||
[[drivers]]
|
||||
name = "QEMU Graphics Array"
|
||||
class = 0x03
|
||||
vendor = 0x1234
|
||||
device = 0x1111
|
||||
command = ["bgad"]
|
||||
@@ -1,51 +0,0 @@
|
||||
const BGA_INDEX_XRES: u16 = 1;
|
||||
const BGA_INDEX_YRES: u16 = 2;
|
||||
const BGA_INDEX_BPP: u16 = 3;
|
||||
const BGA_INDEX_ENABLE: u16 = 4;
|
||||
|
||||
pub struct Bga {
|
||||
bar: *mut u8,
|
||||
}
|
||||
|
||||
impl Bga {
|
||||
pub unsafe fn new(bar: *mut u8) -> Bga {
|
||||
Bga { bar }
|
||||
}
|
||||
|
||||
fn bochs_dispi_addr(&mut self, index: u16) -> *mut u16 {
|
||||
assert!(index <= 0x10);
|
||||
unsafe {
|
||||
self.bar
|
||||
.byte_add(0x500)
|
||||
.cast::<u16>()
|
||||
.add(usize::from(index))
|
||||
}
|
||||
}
|
||||
|
||||
fn bochs_dispi_read(&mut self, index: u16) -> u16 {
|
||||
unsafe { self.bochs_dispi_addr(index).read_volatile() }
|
||||
}
|
||||
|
||||
fn bochs_dispi_write(&mut self, index: u16, data: u16) {
|
||||
assert!(index <= 0x10);
|
||||
unsafe {
|
||||
self.bochs_dispi_addr(index).write_volatile(data);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn width(&mut self) -> u16 {
|
||||
self.bochs_dispi_read(BGA_INDEX_XRES)
|
||||
}
|
||||
|
||||
pub fn height(&mut self) -> u16 {
|
||||
self.bochs_dispi_read(BGA_INDEX_YRES)
|
||||
}
|
||||
|
||||
pub fn set_size(&mut self, width: u16, height: u16) {
|
||||
self.bochs_dispi_write(BGA_INDEX_ENABLE, 0);
|
||||
self.bochs_dispi_write(BGA_INDEX_XRES, width);
|
||||
self.bochs_dispi_write(BGA_INDEX_YRES, height);
|
||||
self.bochs_dispi_write(BGA_INDEX_BPP, 32);
|
||||
self.bochs_dispi_write(BGA_INDEX_ENABLE, 0x41);
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
//! <https://www.qemu.org/docs/master/specs/standard-vga.html>
|
||||
|
||||
use inputd::ProducerHandle;
|
||||
use pcid_interface::PciFunctionHandle;
|
||||
use redox_scheme::{
|
||||
scheme::{register_sync_scheme, SchemeState},
|
||||
RequestKind, SignalBehavior, Socket,
|
||||
};
|
||||
|
||||
use crate::bga::Bga;
|
||||
use crate::scheme::BgaScheme;
|
||||
|
||||
mod bga;
|
||||
mod scheme;
|
||||
|
||||
// FIXME add a driver-graphics implementation
|
||||
|
||||
fn main() {
|
||||
pcid_interface::pci_daemon(daemon);
|
||||
}
|
||||
|
||||
fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! {
|
||||
let pci_config = pcid_handle.config();
|
||||
|
||||
let mut name = pci_config.func.name();
|
||||
name.push_str("_bga");
|
||||
|
||||
common::setup_logging(
|
||||
"graphics",
|
||||
"pci",
|
||||
&name,
|
||||
common::output_level(),
|
||||
common::file_level(),
|
||||
);
|
||||
|
||||
log::info!("BGA {}", pci_config.func.display());
|
||||
|
||||
let socket = Socket::create().expect("bgad: failed to create bga scheme");
|
||||
|
||||
let bar = unsafe { pcid_handle.map_bar(2) }.ptr.as_ptr();
|
||||
|
||||
let mut bga = unsafe { Bga::new(bar) };
|
||||
log::debug!("BGA {}x{}", bga.width(), bga.height());
|
||||
|
||||
let mut state = SchemeState::new();
|
||||
let mut scheme = BgaScheme {
|
||||
bga,
|
||||
display: ProducerHandle::new().ok(),
|
||||
};
|
||||
|
||||
register_sync_scheme(&socket, "bga", &mut scheme).expect("bgad: failed to register bga scheme");
|
||||
|
||||
daemon.ready();
|
||||
|
||||
libredox::call::setrens(0, 0).expect("bgad: failed to enter null namespace");
|
||||
|
||||
loop {
|
||||
let Some(request) = socket
|
||||
.next_request(SignalBehavior::Restart)
|
||||
.expect("bgad: failed to get next scheme request")
|
||||
else {
|
||||
// Scheme likely got unmounted
|
||||
std::process::exit(0);
|
||||
};
|
||||
match request.kind() {
|
||||
RequestKind::Call(call) => {
|
||||
let response = call.handle_sync(&mut scheme, &mut state);
|
||||
|
||||
socket
|
||||
.write_response(response, SignalBehavior::Restart)
|
||||
.expect("bgad: failed to write next scheme response");
|
||||
}
|
||||
RequestKind::OnClose { id } => {
|
||||
scheme.on_close(id);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
use inputd::ProducerHandle;
|
||||
use redox_scheme::scheme::SchemeSync;
|
||||
use redox_scheme::{CallerCtx, OpenResult};
|
||||
use std::str;
|
||||
use syscall::data::Stat;
|
||||
use syscall::schemev2::NewFdFlags;
|
||||
use syscall::{Error, Result, EACCES, EINVAL, MODE_CHR};
|
||||
|
||||
use crate::bga::Bga;
|
||||
|
||||
pub struct BgaScheme {
|
||||
pub bga: Bga,
|
||||
pub display: Option<ProducerHandle>,
|
||||
}
|
||||
|
||||
const SCHEME_ROOT_ID: usize = 1;
|
||||
|
||||
impl SchemeSync for BgaScheme {
|
||||
fn scheme_root(&mut self) -> Result<usize> {
|
||||
Ok(SCHEME_ROOT_ID)
|
||||
}
|
||||
fn openat(
|
||||
&mut self,
|
||||
dirfd: usize,
|
||||
_path: &str,
|
||||
_flags: usize,
|
||||
_fcntl_flags: u32,
|
||||
ctx: &CallerCtx,
|
||||
) -> Result<OpenResult> {
|
||||
if dirfd != SCHEME_ROOT_ID {
|
||||
return Err(Error::new(EACCES));
|
||||
}
|
||||
if ctx.uid == 0 {
|
||||
Ok(OpenResult::ThisScheme {
|
||||
number: 0,
|
||||
flags: NewFdFlags::empty(),
|
||||
})
|
||||
} else {
|
||||
Err(Error::new(EACCES))
|
||||
}
|
||||
}
|
||||
|
||||
fn read(
|
||||
&mut self,
|
||||
_id: usize,
|
||||
buf: &mut [u8],
|
||||
_offset: u64,
|
||||
_fcntl_flags: u32,
|
||||
_ctx: &CallerCtx,
|
||||
) -> Result<usize> {
|
||||
let mut i = 0;
|
||||
let data = format!("{},{}\n", self.bga.width(), self.bga.height()).into_bytes();
|
||||
while i < buf.len() && i < data.len() {
|
||||
buf[i] = data[i];
|
||||
i += 1;
|
||||
}
|
||||
Ok(i)
|
||||
}
|
||||
|
||||
fn write(
|
||||
&mut self,
|
||||
_id: usize,
|
||||
buf: &[u8],
|
||||
_offset: u64,
|
||||
_fcntl_flags: u32,
|
||||
_ctx: &CallerCtx,
|
||||
) -> Result<usize> {
|
||||
let string = str::from_utf8(buf).or(Err(Error::new(EINVAL)))?;
|
||||
let string = string.trim();
|
||||
|
||||
let mut parts = string.split(',');
|
||||
|
||||
let width = if let Some(part) = parts.next() {
|
||||
part.parse::<u16>().or(Err(Error::new(EINVAL)))?
|
||||
} else {
|
||||
self.bga.width()
|
||||
};
|
||||
|
||||
let height = if let Some(part) = parts.next() {
|
||||
part.parse::<u16>().or(Err(Error::new(EINVAL)))?
|
||||
} else {
|
||||
self.bga.height()
|
||||
};
|
||||
|
||||
self.bga.set_size(width, height);
|
||||
|
||||
Ok(buf.len())
|
||||
}
|
||||
|
||||
fn fpath(&mut self, _file: usize, buf: &mut [u8], _ctx: &CallerCtx) -> Result<usize> {
|
||||
let mut i = 0;
|
||||
let scheme_path = b"bga";
|
||||
while i < buf.len() && i < scheme_path.len() {
|
||||
buf[i] = scheme_path[i];
|
||||
i += 1;
|
||||
}
|
||||
Ok(i)
|
||||
}
|
||||
|
||||
fn fstat(&mut self, _id: usize, stat: &mut Stat, _ctx: &CallerCtx) -> Result<()> {
|
||||
*stat = Stat {
|
||||
st_mode: MODE_CHR | 0o666,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn fcntl(&mut self, _id: usize, _cmd: usize, _arg: usize, _ctx: &CallerCtx) -> Result<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl BgaScheme {
|
||||
pub fn on_close(&mut self, _id: usize) {}
|
||||
}
|
||||
Reference in New Issue
Block a user