Schemes
Within Redox, a scheme may be thought of in a few ways. It is all of these things.
- It is the type of a resource, such as "file", "M.2 drive", "tcp connection", etc. (Note that these are not valid scheme names, they are just given by way of example.)
- It is the starting point for locating the resource, i.e. it is the root of the path to the resource, which the system can then use in establishing a connection to the resource.
- It is a uniquely named service that is provided by some driver or daemon program, with the full URL identifying a specific resource accessed via that service.
Kernel vs. Userspace Schemes
Schemes are implemented by scheme providers. A userspace scheme is implemented by a program running in user space, currently requiring root
permission. A kernel scheme is implemented by the kernel directly. When possible, schemes should be implemented in userspace. Only critical schemes are implemented in kernel space.
Accessing Resources
In order to provide "virtual file" behavior, schemes generally implement file-like operations. However, it is up to the scheme provider to determine what each file-like operation means. For example, seek
to an SSD driver scheme might simply add to a file offset, but to a floppy disk controller scheme, it might cause the physical movement of disk read-write heads.
Typical scheme operations include:
open
- Create a handle (file descriptor) to a resource provided by the scheme. e.g.File::create("tcp:127.0.0.1:3000")
in a regular program would be converted by the kernel intoopen("127.0.0.1:3000")
and sent to the "tcp:" scheme provider. The "tcp:" scheme provider would parse the name, establish a connection to Internet address "127.0.0.1", port "3000", and return a handle that represents that connection.read
- get some data from the thing represented by the handle, normally consuming that data so the nextread
will return new data.write
- send some data to the thing represented by the handle to be saved, sent or written.seek
- change the logical location that the nextread
orwrite
will occur. This may or may not cause some action by the scheme provider.
Schemes may choose to provide other standard operations, such as mkdir
, but the meaning of the operation is up to the scheme. mkdir
might create a directory entry, or it might create some type of substructure or container relevant to that particular scheme.
Some schemes implement fmap
, which creates a memory-mapped area that is shared between the scheme resource and the scheme user. It allows direct memory operations on the resource, rather than reading and writing to a file descriptor. The most common use case for fmap
is for a device driver to access the physical addresses of a memory-mapped device, using the memory:
kernel scheme. It is also used for frame buffers in the graphics subsystem.
TODO add F-operations.
TODO Explain file-like vs. socket-like schemes.
Userspace Schemes
Redox creates user-space schemes during initialization, starting various daemon-style programs, each of which can provide one or more schemes.
Name | Daemon | Description |
---|---|---|
disk.*: | ided , ahcid , nvmed | Storage drivers |
disk.live: | lived | RAM-disk driver that loads the bootable USB data into RAM |
disk.usb-{id}+{port}-scsi: | usbscsid | USB SCSI driver |
logging: | ramfs | Error logging scheme, using an in-memory temporary filesystem |
initfs: | bootstrap | Startup filesystem |
file: | redoxfs | Main filesystem |
network: | e1000d , rtl8168d | Link-level network send/receive |
ip: | smolnetd | Raw IP packet send/receive |
tcp: | smolnetd | TCP sockets |
udp: | smolnetd | UDP sockets |
icmp: | smolnetd | ICMP protocol |
netcfg: | smolnetd | Network configuration |
dns: | dnsd | DNS protocol |
display.vesa: | vesad | VESA driver |
display.virtio-gpu: | virtio-gpud | VirtIO GPU driver |
orbital: | orbital | Windowing system (window manager and virtual driver) |
pty: | ptyd | Pseudoterminals, used by terminal emulators |
audiorw: | sb16d, ac97d, ihdad | Sound drivers |
audio: | audiod | Audio manager and virtual device |
usb.*: | usb*d | USB interfaces |
pcspkr: | pcspkrd | PC speaker driver |
acpi: | acpid | ACPI driver |
input: | inputd | Virtual device |
escalate: | escalated | Privilege manager |
chan: | ipcd | Inter-process communication |
shm: | ipcd | Shared memory manager |
log: | logd | Logging |
rand: | randd | Pseudo-random number generator |
zero: | zerod | Discard all writes, and always fill read buffers with zeroes |
null: | nulld | Discard all writes, and read no bytes |
Kernel Schemes
The kernel provides a small number of schemes in order to support userspace.
Name | Documentation | Description |
---|---|---|
: | root.rs | Namespace manager |
user: | user.rs | Dispatch for user-space schemes |
debug: | debug.rs | Debug messages that can't use the log: scheme |
event: | event.rs | epoll-like file descriptor read/write "ready" events |
irq: | irq.rs | Interrupt manager (converts interrupts to messages) |
pipe: | pipe.rs | Kernel manager for pipes |
proc: | proc.rs | Process context manager |
thisproc: | proc.rs | Process context manager |
sys: | mod.rs | System hardware resources information |
kernel.acpi: | acpi.rs | Read the CPU configuration (number of cores, etc) |
memory: | memory.rs | Physical memory mapping manager |
time: | time.rs | Real-time clock timer |
itimer: | time.rs | Interval timer |
serio: | serio.rs | Serial I/O (PS/2) driver (must stay in the kernel due to PS/2 protocol issues) |