-
Notifications
You must be signed in to change notification settings - Fork 172
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
gateware.usb.usb2.request: add claim
to RequestHandlerInterface
#225
gateware.usb.usb2.request: add claim
to RequestHandlerInterface
#225
Conversation
d7dd849
to
9e60074
Compare
9e60074
to
161c67c
Compare
From an Orbtrace perspective, this would be a welcome improvement. We've got interface handlers that'll stall nonexistent requests on the interfaces they handle, but nothing that'll stall requests that's not directed to any of the handled interfaces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty happy with this as it stands, and it's a good improvement over the status quo, but I do see one issue:
With this change, the logic for which requests should be handled ends up appearing twice in each request handler: once in handled
, and again in elaborate
.
This seems like a bit of a recipe for trouble, because it would be easy for the two to get out of sync, such that a handler implementation is lying about which requests it does and doesn't handle. That could lead to some quite hard-to-find bugs.
Given that this is already going to be a breaking change to downstream users of USBRequestHandler
, I wonder if we should take the opportunity to change the API a little bit further, such that a request handler won't see a request at all unless its handled
precondition is met. That would require some further changes, but could make handlers simpler and less error-prone to write.
It'd be nice to have a request dispatcher that you could just register request handlers with, automatically generating both the |
Introduce a new `claim` signal to the `RequestHandlerInterface`. If a `USBRequestHandler` wants to manage an incoming request, it must assert this signal to gain control of the remaining interface outputs. Additionally, this commit simplifies the logic within `USBRequestHandlerMultiplexer` and provides a fallback mechanism for unhandled requests.
161c67c
to
fef13b8
Compare
I've just pushed a different approach for this PR. Instead of a When a It makes the logic in |
USBRequestHandler
defines managed requestsclaim
to RequestHandlerInterface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this, and it's being used successfully on the update-dependencies
branch of the Cynthion factory test.
This commit adds a
handled()
method toUSBRequestHandler
. This method takes aSetupPacket
as an argument and returns an Amaranth boolean indicating whether a request has been taken care of.These signals from the various request handlers are subsequently combined to trigger a stall for unhandled cases.