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:
@@ -109,7 +109,7 @@ pub fn main(init: runtime.process.Init) void {
|
||||
return;
|
||||
};
|
||||
if (attached.len < @sizeOf(ps2.AttachReply) or
|
||||
std.mem.bytesToValue(ps2.AttachReply, attach_reply[0..@sizeOf(ps2.AttachReply)]).status != 0)
|
||||
std.mem.bytesToValue(ps2.AttachReply, attach_reply[0..@sizeOf(ps2.AttachReply)]).status != @intFromEnum(ps2.AttachStatus.ok))
|
||||
{
|
||||
_ = runtime.system.write("system/drivers/ps2-bus/keyboard: attach refused\n");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user