Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Driver Registry RFC #28

Merged
merged 25 commits into from
Jul 25, 2022

Conversation

jamesmunns
Copy link
Contributor

@jamesmunns jamesmunns commented Jul 22, 2022

Provides an implementation of #25.

There aren't any major conceptual changes here, but some implementation tweaks were made.

Additionally, I've gone ahead and "fully broken" userspace comms (the existing structures don't totally fit, and fixing them would require fixing some other underlying details, which I will do as a follow-up in a later RFC to restore userspace comms). The largest pre-req for this fix is deciding how to do async/await notifications across the ABI barrier.

@jamesmunns jamesmunns requested a review from hawkw July 22, 2022 16:44
@jamesmunns jamesmunns marked this pull request as ready for review July 22, 2022 16:44
@jamesmunns
Copy link
Contributor Author

As a note, this is what the current demo main now looks like, which I think is much closer to what I want to be possible:

let k = unsafe { Kernel::new(settings).unwrap().leak().as_ref() };
// First let's make a dummy driver just to make sure some stuff happens
let initialization_future = async move {
// Delay for one second, just for funsies
Delay::new(Duration::from_secs(1)).await;
// Set up the bidirectional, async bbqueue channel between the TCP port
// (acting as a serial port) and the virtual serial port mux.
//
// Create the buffer, and spawn the worker task, giving it one of the
// queue handles
TcpSerial::register(k, opts.serial_addr, 4096, 4096).await.unwrap();
// Now, right now this is a little awkward, but what I'm doing here is spawning
// a new virtual mux, and configuring it with:
// * Up to 4 virtual ports max
// * Framed messages up to 512 bytes max each
SerialMux::register(k, 4, 512).await.unwrap();
let mux_hdl = SerialMuxHandle::from_registry(k).await.unwrap();
let p0 = mux_hdl.open_port(0, 1024).await.unwrap();
let p1 = mux_hdl.open_port(1, 1024).await.unwrap();
drop(mux_hdl);
k.spawn(async move {
loop {
let rgr = p0.consumer().read_grant().await;
let len = rgr.len();
p0.send(&rgr).await;
rgr.release(len);
}
}
.instrument(tracing::info_span!("Loopback")))
.await;
// Now we just send out data every second
k.spawn(async move {
loop {
Delay::new(Duration::from_secs(1)).await;
p1.send(b"hello\r\n").await;
}
}
.instrument(tracing::info_span!("Hello Loop")))
.await;
}
.instrument(tracing::info_span!("Initialize"));
k.initialize(initialization_future).unwrap();

Adds CI based on Mycelium's CI setup, fix a couple docs/check/fmt items that would cause the CI to fail.
@jamesmunns jamesmunns force-pushed the rfc/driver-registry_pre-impl branch from 4687d91 to 9050b8c Compare July 22, 2022 20:47
Copy link
Contributor

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall, this looks solid! i commented on some very minor nits; i'd like to look a little more closely at some of the implementation, but it looks good to me!

Comment on lines 22 to 31
/// A reusable One-Shot channel.
///
/// A `Rosc<T>` can be used to hand out single-use [Sender] items, which can
/// be used to make a single reply.
///
/// A given `Rosc<T>` can only ever have zero or one `Sender<T>`s live at any
/// given time, and a response can be received through a call to [Rosc::receive].
pub struct Rosc<T> {
inner: HeapArc<Inner<T>>,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be cool to have in maitake's synchronization primitives, but...i'm not sure if there's a nice way to implement it without being tightly coupled to mnemos' HeapArc type. we could do another "generic over allocation" thing but that's probably not worth the effort...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was thinking about this. I don't have a great answer, but would be open to porting it if it makes sense in the future.

source/kernel/src/comms/rosc.rs Outdated Show resolved Hide resolved
source/kernel/src/lib.rs Outdated Show resolved Hide resolved
source/kernel/src/lib.rs Show resolved Hide resolved
source/kernel/src/lib.rs Show resolved Hide resolved
source/kernel/src/registry/mod.rs Outdated Show resolved Hide resolved
source/kernel/src/registry/mod.rs Outdated Show resolved Hide resolved
source/kernel/src/registry/mod.rs Outdated Show resolved Hide resolved
source/kernel/src/registry/mod.rs Show resolved Hide resolved
source/kernel/src/registry/mod.rs Show resolved Hide resolved
@jamesmunns jamesmunns merged commit 71209fd into rfc/driver-registry Jul 25, 2022
@jamesmunns jamesmunns deleted the rfc/driver-registry_pre-impl branch July 25, 2022 11:22
@jamesmunns jamesmunns added area: kernel Related to the cross-platform kernel area: drivers Related to driver implementation for hardware devices. labels Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: drivers Related to driver implementation for hardware devices. area: kernel Related to the cross-platform kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants