Name the attach reply statuses instead of magic numbers
Add an AttachStatus enum to ps2-library.zig for AttachReply.status, distinguishing the three failure causes handleAttach previously collapsed into a bare -1: invalid_request (message too short), missing_endpoint (no capability passed), and no_such_device (no port identified the requested device type). The keyboard and mouse drivers check against AttachStatus.ok rather than a literal 0.
This commit is contained in:
@@ -285,7 +285,18 @@ pub const AttachRequest = extern struct {
|
||||
device_type: u32,
|
||||
};
|
||||
|
||||
/// Reply to an `AttachRequest`. `status` is 0 on success or a negative errno.
|
||||
/// How the bus answered an `AttachRequest` (`AttachReply.status`).
|
||||
pub const AttachStatus = enum(i32) {
|
||||
ok = 0,
|
||||
/// The request was malformed (too short to be an `AttachRequest`).
|
||||
invalid_request = -1,
|
||||
/// The call carried no endpoint capability to forward to.
|
||||
missing_endpoint = -2,
|
||||
/// No port identified a device of the requested type.
|
||||
no_such_device = -3,
|
||||
};
|
||||
|
||||
/// Reply to an `AttachRequest`. `status` is an `AttachStatus` value.
|
||||
pub const AttachReply = extern struct {
|
||||
status: i32,
|
||||
_padding: u32 = 0,
|
||||
|
||||
Reference in New Issue
Block a user