Use the new scheme format in most places
The graphics subsystem still uses the old format as orbital manually parses the fpath result.
This commit is contained in:
@@ -46,12 +46,12 @@ This section cover the interfaces used by Redox drivers.
|
||||
|
||||
### Schemes
|
||||
|
||||
- `memory:physical` - allows mapping physical memory frames to driver-accessible virtual memory pages, with various available memory types:
|
||||
- `memory:physical`: default memory type (currently writeback)
|
||||
- `memory:physical@wb` writeback cached memory
|
||||
- `memory:physical@uc`: uncacheable memory
|
||||
- `memory:physical@wc`: write-combining memory
|
||||
- `irq:` - allows getting events from interrupts. It is used primarily by listening for its file descriptors using the `event:` scheme.
|
||||
- `/scheme/memory/physical` - allows mapping physical memory frames to driver-accessible virtual memory pages, with various available memory types:
|
||||
- `/scheme/memory/physical`: default memory type (currently writeback)
|
||||
- `/scheme/memory/physical@wb` writeback cached memory
|
||||
- `/scheme/memory/physical@uc`: uncacheable memory
|
||||
- `/scheme/memory/physical@wc`: write-combining memory
|
||||
- `/scheme/irq` - allows getting events from interrupts. It is used primarily by listening for its file descriptors using the `/scheme/event` scheme.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
+5
-5
@@ -81,8 +81,8 @@ fn setup_logging() -> Option<&'static RedoxLogger> {
|
||||
fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
setup_logging();
|
||||
|
||||
let rxsdt_raw_data: Arc<[u8]> = std::fs::read("kernel.acpi:rxsdt")
|
||||
.expect("acpid: failed to read `kernel.acpi:rxsdt`")
|
||||
let rxsdt_raw_data: Arc<[u8]> = std::fs::read("/scheme/kernel.acpi/rxsdt")
|
||||
.expect("acpid: failed to read `/scheme/kernel.acpi/rxsdt`")
|
||||
.into();
|
||||
|
||||
let sdt = self::acpi::Sdt::new(rxsdt_raw_data)
|
||||
@@ -116,14 +116,14 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
// TODO: I/O permission bitmap?
|
||||
common::acquire_port_io_rights().expect("acpid: failed to set I/O privilege level to Ring 3");
|
||||
|
||||
let shutdown_pipe = File::open("kernel.acpi:kstop")
|
||||
.expect("acpid: failed to open `kernel.acpi:kstop`");
|
||||
let shutdown_pipe = File::open("/scheme/kernel.acpi/kstop")
|
||||
.expect("acpid: failed to open `/scheme/kernel.acpi/kstop`");
|
||||
|
||||
let mut event_queue = OpenOptions::new()
|
||||
.write(true)
|
||||
.read(true)
|
||||
.create(false)
|
||||
.open("event:")
|
||||
.open("/scheme/event")
|
||||
.expect("acpid: failed to open event queue");
|
||||
|
||||
let mut scheme_socket = OpenOptions::new()
|
||||
|
||||
@@ -113,7 +113,7 @@ fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> File {
|
||||
log::debug!("Legacy IRQ {}", irq);
|
||||
|
||||
// legacy INTx# interrupt pins.
|
||||
File::open(format!("irq:{}", irq)).expect("ihdad: failed to open legacy IRQ file")
|
||||
irq.irq_handle("ihdad")
|
||||
} else {
|
||||
panic!("ihdad: no interrupts supported at all")
|
||||
}
|
||||
@@ -126,7 +126,7 @@ fn get_int_method(pcid_handle: &mut PciFunctionHandle) -> File {
|
||||
|
||||
if let Some(irq) = pci_config.func.legacy_interrupt_line {
|
||||
// legacy INTx# interrupt pins.
|
||||
File::open(format!("irq:{}", irq)).expect("ihdad: failed to open legacy IRQ file")
|
||||
irq.irq_handle("ihdad")
|
||||
} else {
|
||||
panic!("ihdad: no interrupts supported at all")
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ fn main() {
|
||||
|
||||
//TODO: error on multiple IRQs?
|
||||
let irq_file = match device.irqs.first() {
|
||||
Some(irq) => Fd::open(&format!("irq:{}", irq), flag::O_RDWR, 0).expect("sb16d: failed to open IRQ file"),
|
||||
Some(irq) => Fd::open(&format!("/scheme/irq/{}", irq), flag::O_RDWR, 0).expect("sb16d: failed to open IRQ file"),
|
||||
None => panic!("sb16d: no IRQs found"),
|
||||
};
|
||||
user_data! {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ const DMA_MEMTY: MemoryType = {
|
||||
|
||||
pub(crate) fn phys_contiguous_fd() -> Result<Fd> {
|
||||
Fd::open(
|
||||
&format!("memory:zeroed@{DMA_MEMTY}?phys_contiguous"),
|
||||
&format!("/scheme/memory/zeroed@{DMA_MEMTY}?phys_contiguous"),
|
||||
flag::O_CLOEXEC,
|
||||
0,
|
||||
)
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ pub unsafe fn physmap(
|
||||
) -> Result<*mut ()> {
|
||||
// TODO: arraystring?
|
||||
let path = format!(
|
||||
"memory:physical@{}",
|
||||
"/scheme/memory/physical@{}",
|
||||
match ty {
|
||||
MemoryType::Writeback => "wb",
|
||||
MemoryType::Uncacheable => "uc",
|
||||
|
||||
@@ -35,7 +35,7 @@ fn main() {
|
||||
|
||||
let mut scheme = BgaScheme {
|
||||
bga,
|
||||
display: File::open("input:producer").ok(),
|
||||
display: File::open("/scheme/input/producer").ok(),
|
||||
};
|
||||
|
||||
scheme.update_size();
|
||||
|
||||
@@ -56,7 +56,7 @@ impl Display {
|
||||
let input_handle = OpenOptions::new()
|
||||
.read(true)
|
||||
.custom_flags(O_NONBLOCK as i32)
|
||||
.open(format!("input:consumer/{vt}"))?;
|
||||
.open(format!("/scheme/input/consumer/{vt}"))?;
|
||||
let fd = input_handle.as_raw_fd();
|
||||
|
||||
let written = libredox::call::fpath(fd as usize, &mut buffer)
|
||||
|
||||
@@ -41,7 +41,7 @@ fn inner(daemon: redox_daemon::Daemon, vt_ids: &[usize]) -> ! {
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.custom_flags(O_NONBLOCK as i32)
|
||||
.open(":fbcon")
|
||||
.open("/scheme/fbcon")
|
||||
.expect("fbcond: failed to create fbcon scheme");
|
||||
event_queue
|
||||
.subscribe(
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ pub struct Handle(File);
|
||||
|
||||
impl Handle {
|
||||
pub fn new<S: Into<String>>(device_name: S) -> Result<Self, Error> {
|
||||
let path = format!("input:handle/display/{}", device_name.into());
|
||||
let path = format!("/scheme/input/handle/display/{}", device_name.into());
|
||||
Ok(Self(File::open(path)?))
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -73,7 +73,7 @@ impl Vt {
|
||||
|
||||
pub fn inner(&self) -> &Mutex<VtInner> {
|
||||
self.inner.call_once(|| {
|
||||
let handle_file = File::open(format!("{}:handle", self.display)).unwrap();
|
||||
let handle_file = File::open(format!("/scheme/{}/handle", self.display)).unwrap();
|
||||
Mutex::new(VtInner {
|
||||
handle_file,
|
||||
mode: VtMode::Default,
|
||||
@@ -531,7 +531,7 @@ pub fn main() {
|
||||
"-A" => {
|
||||
let vt = args.next().unwrap().parse::<usize>().unwrap();
|
||||
|
||||
let handle = File::open(format!("input:consumer/{vt}"))
|
||||
let handle = File::open(format!("/scheme/input/consumer/{vt}"))
|
||||
.expect("inputd: failed to open consumer handle");
|
||||
let mut display_path = [0; 4096];
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ fn main() {
|
||||
|
||||
daemon.ready().expect("alxd: failed to signal readiness");
|
||||
|
||||
let mut irq_file = File::open(format!("irq:{}", irq)).expect("alxd: failed to open IRQ file");
|
||||
let mut irq_file = File::open(format!("/scheme/irq/{}", irq)).expect("alxd: failed to open IRQ file");
|
||||
|
||||
let address = unsafe { common::physmap(bar, 128*1024, common::Prot::RW, common::MemoryType::Uncacheable).expect("alxd: failed to map address") as usize };
|
||||
{
|
||||
|
||||
@@ -95,7 +95,7 @@ fn deamon(daemon: redox_daemon::Daemon) -> Result<(), Box<dyn std::error::Error>
|
||||
let device = VirtioNet::new(mac_address, rx_queue, tx_queue);
|
||||
let mut scheme = NetworkScheme::new(device, format!("network.{name}"));
|
||||
|
||||
let mut event_queue = File::open("event:")?;
|
||||
let mut event_queue = File::open("/scheme/event")?;
|
||||
event_queue.write(&syscall::Event {
|
||||
id: scheme.event_handle() as usize,
|
||||
flags: syscall::EVENT_READ,
|
||||
|
||||
@@ -126,7 +126,7 @@ struct PcieAllocs<'a>(&'a [PcieAlloc]);
|
||||
|
||||
impl Mcfg {
|
||||
fn with<T>(f: impl FnOnce(PcieAllocs<'_>) -> io::Result<T>) -> io::Result<T> {
|
||||
let table_dir = fs::read_dir("acpi:tables")?;
|
||||
let table_dir = fs::read_dir("/scheme/acpi/tables")?;
|
||||
|
||||
// TODO: validate/print MCFG?
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! IRQ helpers.
|
||||
//!
|
||||
//! This module allows easy handling of the `irq:` scheme, and allocating interrupt vectors for use
|
||||
//! by INTx#, MSI, or MSI-X.
|
||||
//! This module allows easy handling of the `/scheme/irq` scheme, and allocating interrupt vectors
|
||||
//! for use by INTx#, MSI, or MSI-X.
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::fs::{self, File};
|
||||
@@ -14,7 +14,7 @@ use crate::driver_interface::msi::MsiAddrAndData;
|
||||
pub fn read_bsp_apic_id() -> io::Result<usize> {
|
||||
let mut buffer = [0u8; 8];
|
||||
|
||||
let mut file = File::open("irq:bsp")?;
|
||||
let mut file = File::open("/scheme/irq/bsp")?;
|
||||
let bytes_read = file.read(&mut buffer)?;
|
||||
|
||||
(if bytes_read == 8 {
|
||||
@@ -25,7 +25,7 @@ pub fn read_bsp_apic_id() -> io::Result<usize> {
|
||||
]))
|
||||
} else {
|
||||
panic!(
|
||||
"`irq:` scheme responded with {} bytes, expected {}",
|
||||
"`/scheme/irq` scheme responded with {} bytes, expected {}",
|
||||
bytes_read,
|
||||
std::mem::size_of::<usize>()
|
||||
);
|
||||
@@ -41,7 +41,7 @@ pub fn read_bsp_apic_id() -> io::Result<usize> {
|
||||
/// capability structs or MSI-X tables.
|
||||
pub fn cpu_ids() -> io::Result<impl Iterator<Item = io::Result<usize>> + 'static> {
|
||||
Ok(
|
||||
fs::read_dir("irq:")?.filter_map(|entry| -> Option<io::Result<_>> {
|
||||
fs::read_dir("/scheme/irq")?.filter_map(|entry| -> Option<io::Result<_>> {
|
||||
match entry {
|
||||
Ok(e) => {
|
||||
let path = e.path();
|
||||
@@ -88,7 +88,7 @@ pub fn allocate_aligned_interrupt_vectors(
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let available_irqs = fs::read_dir(format!("irq:cpu-{:02x}", cpu_id))?;
|
||||
let available_irqs = fs::read_dir(format!("/scheme/irq/cpu-{:02x}", cpu_id))?;
|
||||
let mut available_irq_numbers = available_irqs.filter_map(|entry| -> Option<io::Result<_>> {
|
||||
let entry = match entry {
|
||||
Ok(e) => e,
|
||||
@@ -113,7 +113,7 @@ pub fn allocate_aligned_interrupt_vectors(
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: fcntl F_SETLK on `irq:/`?
|
||||
// TODO: fcntl F_SETLK on `/scheme/irq/`?
|
||||
|
||||
let mut handles = Vec::with_capacity(usize::from(count));
|
||||
|
||||
@@ -137,7 +137,7 @@ pub fn allocate_aligned_interrupt_vectors(
|
||||
}
|
||||
|
||||
// if found, reserve the irq
|
||||
let irq_handle = match File::create(format!("irq:cpu-{:02x}/{}", cpu_id, irq_number)) {
|
||||
let irq_handle = match File::create(format!("/scheme/irq/cpu-{:02x}/{}", cpu_id, irq_number)) {
|
||||
Ok(handle) => handle,
|
||||
|
||||
// return early if the entire range couldn't be allocated
|
||||
|
||||
@@ -26,7 +26,7 @@ pub struct LegacyInterruptLine(#[doc(hidden)] pub u8);
|
||||
impl LegacyInterruptLine {
|
||||
/// Get an IRQ handle for this interrupt line.
|
||||
pub fn irq_handle(self, driver: &str) -> File {
|
||||
File::open(format!("irq:{}", self.0))
|
||||
File::open(format!("/scheme/irq/{}", self.0))
|
||||
.unwrap_or_else(|err| panic!("{driver}: failed to open IRQ file: {err}"))
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -45,40 +45,40 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
|
||||
let input = OpenOptions::new()
|
||||
.write(true)
|
||||
.open("input:producer")
|
||||
.expect("ps2d: failed to open input:producer");
|
||||
.open("/scheme/input/producer")
|
||||
.expect("ps2d: failed to open /scheme/input/producer");
|
||||
|
||||
let mut event_file = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.open("event:")
|
||||
.expect("ps2d: failed to open event:");
|
||||
.open("/scheme/event")
|
||||
.expect("ps2d: failed to open /scheme/event");
|
||||
|
||||
let mut key_file = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.custom_flags(syscall::O_NONBLOCK as i32)
|
||||
.open("serio:0")
|
||||
.expect("ps2d: failed to open serio:0");
|
||||
.open("/scheme/serio/0")
|
||||
.expect("ps2d: failed to open /scheme/serio/0");
|
||||
|
||||
event_file.write(&syscall::Event {
|
||||
id: key_file.as_raw_fd() as usize,
|
||||
flags: syscall::EVENT_READ,
|
||||
data: 0
|
||||
}).expect("ps2d: failed to event serio:0");
|
||||
}).expect("ps2d: failed to event /scheme/serio/0");
|
||||
|
||||
let mut mouse_file = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.custom_flags(syscall::O_NONBLOCK as i32)
|
||||
.open("serio:1")
|
||||
.expect("ps2d: failed to open serio:1");
|
||||
.open("/scheme/serio/1")
|
||||
.expect("ps2d: failed to open /scheme/serio/1");
|
||||
|
||||
event_file.write(&syscall::Event {
|
||||
id: mouse_file.as_raw_fd() as usize,
|
||||
flags: syscall::EVENT_READ,
|
||||
data: 1
|
||||
}).expect("ps2d: failed to event irq:12");
|
||||
}).expect("ps2d: failed to event /scheme/serio/1");
|
||||
|
||||
libredox::call::setrens(0, 0).expect("ps2d: failed to enter null namespace");
|
||||
|
||||
|
||||
@@ -238,14 +238,14 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
.expect("ided: failed to create disk scheme");
|
||||
|
||||
let primary_irq_fd = libredox::call::open(
|
||||
&format!("irq:{}", primary_irq),
|
||||
&format!("/scheme/irq/{}", primary_irq),
|
||||
flag::O_RDWR | flag::O_NONBLOCK,
|
||||
0,
|
||||
).expect("ided: failed to open irq file");
|
||||
let mut primary_irq_file = unsafe { File::from_raw_fd(primary_irq_fd as RawFd) };
|
||||
|
||||
let secondary_irq_fd = libredox::call::open(
|
||||
&format!("irq:{}", secondary_irq),
|
||||
&format!("/scheme/irq/{}", secondary_irq),
|
||||
flag::O_RDWR | flag::O_NONBLOCK,
|
||||
0,
|
||||
).expect("ided: failed to open irq file");
|
||||
|
||||
@@ -46,7 +46,7 @@ impl DiskScheme {
|
||||
let mut size = 0;
|
||||
|
||||
// TODO: handle error
|
||||
for line in std::fs::read_to_string("sys:env").context("failed to read env")?.lines() {
|
||||
for line in std::fs::read_to_string("/scheme/sys/env").context("failed to read env")?.lines() {
|
||||
let mut parts = line.splitn(2, '=');
|
||||
let name = parts.next().unwrap_or("");
|
||||
let value = parts.next().unwrap_or("");
|
||||
@@ -69,7 +69,7 @@ impl DiskScheme {
|
||||
let size = end - start;
|
||||
|
||||
let the_data = unsafe {
|
||||
let file = File::open("memory:physical")?;
|
||||
let file = File::open("/scheme/memory/physical")?;
|
||||
let base = libredox::call::mmap(MmapArgs {
|
||||
fd: file.as_raw_fd() as usize,
|
||||
addr: core::ptr::null_mut(),
|
||||
|
||||
@@ -66,7 +66,7 @@ struct CqReactor {
|
||||
impl CqReactor {
|
||||
fn create_event_queue(int_sources: &mut InterruptSources) -> Result<File> {
|
||||
use libredox::flag::*;
|
||||
let fd = libredox::call::open("event:", O_CLOEXEC | O_RDWR, 0)?;
|
||||
let fd = libredox::call::open("/scheme/event", O_CLOEXEC | O_RDWR, 0)?;
|
||||
let mut file = unsafe { File::from_raw_fd(fd as RawFd) };
|
||||
|
||||
for (num, irq_handle) in int_sources.iter_mut() {
|
||||
|
||||
+1
-1
@@ -313,7 +313,7 @@ fn main() {
|
||||
let report_id = 0;
|
||||
|
||||
let mut display =
|
||||
File::open("input:producer").expect("Failed to open orbital input socket");
|
||||
File::open("/scheme/input/producer").expect("Failed to open orbital input socket");
|
||||
let mut endpoint_opt = match endpoint_num_opt {
|
||||
Some(endpoint_num) => match handle.open_endpoint(endpoint_num as u8) {
|
||||
Ok(ok) => Some(ok),
|
||||
|
||||
@@ -414,7 +414,7 @@ impl XhciClientHandle {
|
||||
}
|
||||
|
||||
pub fn get_standard_descs(&self) -> result::Result<DevDesc, XhciClientHandleError> {
|
||||
let path = format!("{}:port{}/descriptors", self.scheme, self.port);
|
||||
let path = format!("/scheme/{}/port{}/descriptors", self.scheme, self.port);
|
||||
let json = std::fs::read(path)?;
|
||||
Ok(serde_json::from_slice(&json)?)
|
||||
}
|
||||
@@ -422,7 +422,7 @@ impl XhciClientHandle {
|
||||
&self,
|
||||
req: &ConfigureEndpointsReq,
|
||||
) -> result::Result<(), XhciClientHandleError> {
|
||||
let path = format!("{}:port{}/configure", self.scheme, self.port);
|
||||
let path = format!("/scheme/{}/port{}/configure", self.scheme, self.port);
|
||||
let json = serde_json::to_vec(req)?;
|
||||
let mut file = OpenOptions::new().read(false).write(true).open(path)?;
|
||||
let json_bytes_written = file.write(&json)?;
|
||||
@@ -434,16 +434,16 @@ impl XhciClientHandle {
|
||||
Ok(())
|
||||
}
|
||||
pub fn port_state(&self) -> result::Result<PortState, XhciClientHandleError> {
|
||||
let path = format!("{}:port{}/state", self.scheme, self.port);
|
||||
let path = format!("/scheme/{}/port{}/state", self.scheme, self.port);
|
||||
let string = std::fs::read_to_string(path)?;
|
||||
Ok(string.parse()?)
|
||||
}
|
||||
pub fn open_endpoint_ctl(&self, num: u8) -> result::Result<File, XhciClientHandleError> {
|
||||
let path = format!("{}:port{}/endpoints/{}/ctl", self.scheme, self.port, num);
|
||||
let path = format!("/scheme/{}/port{}/endpoints/{}/ctl", self.scheme, self.port, num);
|
||||
Ok(File::open(path)?)
|
||||
}
|
||||
pub fn open_endpoint_data(&self, num: u8) -> result::Result<File, XhciClientHandleError> {
|
||||
let path = format!("{}:port{}/endpoints/{}/data", self.scheme, self.port, num);
|
||||
let path = format!("/scheme/{}/port{}/endpoints/{}/data", self.scheme, self.port, num);
|
||||
Ok(File::open(path)?)
|
||||
}
|
||||
pub fn open_endpoint(&self, num: u8) -> result::Result<XhciEndpHandle, XhciClientHandleError> {
|
||||
@@ -476,7 +476,7 @@ impl XhciClientHandle {
|
||||
};
|
||||
let json = serde_json::to_vec(&req)?;
|
||||
|
||||
let path = format!("{}:port{}/request", self.scheme, self.port);
|
||||
let path = format!("/scheme/{}/port{}/request", self.scheme, self.port);
|
||||
let mut file = File::open(path)?;
|
||||
|
||||
let json_bytes_written = file.write(&json)?;
|
||||
|
||||
Reference in New Issue
Block a user