Skip to content

WIP: Illumos support#1

Draft
labbott wants to merge 13 commits intomainfrom
rebase_v0.2.3
Draft

WIP: Illumos support#1
labbott wants to merge 13 commits intomainfrom
rebase_v0.2.3

Conversation

@labbott
Copy link
Copy Markdown
Collaborator

@labbott labbott commented Apr 8, 2026

No description provided.

@labbott labbott marked this pull request as draft April 8, 2026 13:51
Comment thread src/platform/illumos_ugen/enumeration.rs Outdated
Comment thread src/platform/illumos_ugen/hotplug.rs Outdated
Comment thread src/platform/illumos_ugen/device.rs
Comment on lines +439 to +452
#[allow(unused)]
pub(crate) fn set_configuration(
&self,
configuration: u8,
) -> impl MaybeFuture<Output = Result<(), Error>> {
// It doesn't look like libusb does this either since the model
// of how ugen works doesn't match this
Blocking::new(move || todo!("Not supported"))
}

pub(crate) fn reset(&self) -> impl MaybeFuture<Output = Result<(), Error>> {
// Another API that isn't as easily exposed via ugen
Blocking::new(move || todo!("Not supported"))
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I didn't find either of these in ugen

Comment on lines +586 to +596
pub fn set_alt_setting(
self: Arc<Self>,
_alt_setting: u8,
) -> impl MaybeFuture<Output = Result<(), Error>> {
// doesn't work exactly the same here
Blocking::new(move || todo!("Not implemented"))
}

pub fn get_alt_setting(&self) -> u8 {
self.state.lock().unwrap().alt_setting
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Another case where I don't think this works the same way with ugen?

Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/mod.rs
Comment thread src/lib.rs Outdated
Comment thread Cargo.toml Outdated
Copy link
Copy Markdown

@jamesmunns jamesmunns left a comment

Choose a reason for hiding this comment

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

First pass over things, I'm gunna take a closer look at transfer.rs, as there's a lot of unsafe going on there.

I'm not super familiar with ugen or nusb (platform-wise, at least), so take my comments with the appropriate grain(s) of salt.

Comment thread src/enumeration.rs Outdated
Comment thread src/enumeration.rs
Comment thread src/enumeration.rs Outdated
Comment thread src/platform/illumos_ugen/device.rs Outdated
Comment thread src/platform/illumos_ugen/device.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Copy link
Copy Markdown

@jamesmunns jamesmunns left a comment

Choose a reason for hiding this comment

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

Some more notes

Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/transfer.rs Outdated
Comment thread src/platform/illumos_ugen/enumeration.rs Outdated
Ok(n) => {
use crate::transfer::SETUP_PACKET_SIZE;
// TODO(AJM): Is this:
// 1. `SETUP_PACKET_SIZE..(SETUP_PACKET_SIZE + n)`, OR
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@labbott I could probably use help figuring out what the right thing is for this (and probably some other places where we do similar slicing)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I have been bitten by this while attempting to work on this code. The intention is that the buffer is allocated to contain the setup packet SETUP_PACKET_SIZE plus space for the expected data in size. n is the total number of bytes actually read so SETUP_PACKET_SIZE..(SETUP_PACKET_SIZE+n) would be correct.

I also don't love this setup and would almost rather model this as two separate buffers simply to make it clearer (I suspect the single buffer model is a hold over from ye olde C style things)

Comment thread src/platform/illumos_ugen/device.rs Outdated

pub(crate) max_packet_size: usize,

/// A queue of pending transfers, expected to complete in order
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's minor, but here is a doc comment in a private struct member, but not on the other members (or the struct). In particular max_packet_size is crate-pub, and should probably be documented.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This matches what the other platforms have but I'll clean it up

Comment thread src/platform/illumos_ugen/device.rs
Comment thread src/platform/illumos_ugen/device.rs Outdated
Comment thread src/platform/illumos_ugen/device.rs Outdated
Comment thread src/platform/illumos_ugen/device.rs
pub(crate) fn control_in(
self: Arc<Self>,
data: ControlIn,
_timeout: Duration,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

My guess here would be that you open the device in non-blocking mode (or put it into that mode with fcntl) and then use something like poll or select on it.

Comment thread src/platform/illumos_ugen/transfer.rs
fds.insert(
ep.address,
IllumosUsbFds {
fd: Arc::new(fd),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's a lot of Arcs inside of Arcs, it seems. I don't know that it makes a lot of sense to try and peel some of the layers of that onion off; it's just something I noticed.

Comment thread src/platform/illumos_ugen/device.rs Outdated
Comment thread src/platform/illumos_ugen/device.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants