diff --git a/system/drivers/ps2-bus/ps2-bus.zig b/system/drivers/ps2-bus/ps2-bus.zig index 490f565..2438a92 100644 --- a/system/drivers/ps2-bus/ps2-bus.zig +++ b/system/drivers/ps2-bus/ps2-bus.zig @@ -118,8 +118,8 @@ pub fn main() void { maybe_controller = controller; maybe_interrupt_index = findInterruptResourceIndex(controller_device_descriptor); - controller.disablePort(.One); - controller.disablePort(.Two); + controller.disablePort(.one); + controller.disablePort(.two); controller.flushOutputBuffer(); const current = controller.readConfigurationByte() orelse { @@ -154,20 +154,20 @@ pub fn main() void { if (has_two_channels) { _ = runtime.system.write("system/drivers/ps2-bus: has two channels\n"); // keep the bus quiet until we have tested the ports and are ready to use them - controller.disablePort(.Two); + controller.disablePort(.two); } else { _ = runtime.system.write("system/drivers/ps2-bus: has one channel\n"); } // interface tests: always test port 1, test port 2 only if it exists - const port_one_works = (controller.testPort(.One) orelse { + const port_one_works = (controller.testPort(.one) orelse { _ = runtime.system.write("system/drivers/ps2-bus: port 1 test timed out\n"); return; }) == ps2.response_port_test_passed; var port_two_works = false; if (has_two_channels) { - port_two_works = (controller.testPort(.Two) orelse { + port_two_works = (controller.testPort(.two) orelse { _ = runtime.system.write("system/drivers/ps2-bus: port 2 test timed out\n"); return; }) == ps2.response_port_test_passed; @@ -181,20 +181,20 @@ pub fn main() void { // Enable the working ports. Their interrupts stay off until IRQ1 is bound // below — reset and identify use polled reads, which must never race the // interrupt-driven drain loop for bytes. - controller.enablePort(.One); - if (port_two_works) controller.enablePort(.Two); + controller.enablePort(.one); + if (port_two_works) controller.enablePort(.two); // reset each working device; a failing device is logged but does not // abort bring-up of the other one if (port_one_works) { - if (controller.resetDevice(.One)) |passed| { + if (controller.resetDevice(.one)) |passed| { if (!passed) _ = runtime.system.write("system/drivers/ps2-bus: port 1 device reset failed\n"); } else { _ = runtime.system.write("system/drivers/ps2-bus: port 1 device reset timed out\n"); } } if (port_two_works) { - if (controller.resetDevice(.Two)) |passed| { + if (controller.resetDevice(.two)) |passed| { if (!passed) _ = runtime.system.write("system/drivers/ps2-bus: port 2 device reset failed\n"); } else { _ = runtime.system.write("system/drivers/ps2-bus: port 2 device reset timed out\n"); @@ -204,8 +204,8 @@ pub fn main() void { // Identify the device on each working port and hand it off to the driver // that matches what it reported — a port is not assumed to be a keyboard // or a mouse by its number. - if (port_one_works) port_device_types[@intFromEnum(ps2.Port.One)] = spawnIdentifiedDriver(controller, .One); - if (port_two_works) port_device_types[@intFromEnum(ps2.Port.Two)] = spawnIdentifiedDriver(controller, .Two); + if (port_one_works) port_device_types[@intFromEnum(ps2.Port.one)] = spawnIdentifiedDriver(controller, .one); + if (port_two_works) port_device_types[@intFromEnum(ps2.Port.two)] = spawnIdentifiedDriver(controller, .two); } else { _ = runtime.system.write("system/drivers/ps2-bus: no PS/2 controller found\n"); return; @@ -243,7 +243,7 @@ pub fn main() void { // claim that node too and route its IRQ to the same endpoint. The IRQ belongs // to the *port*, whatever device identify found on it. var maybe_auxiliary_interrupt: ?struct { device_id: u64, interrupt_index: u64, gsi: u64 } = null; - if (port_device_types[@intFromEnum(ps2.Port.Two)] != null) { + if (port_device_types[@intFromEnum(ps2.Port.two)] != null) { if (device.findDeviceDescriptorByHid(buffer, acpi_ids.HardwareId.ps2_mouse.hid())) |descriptor| { if (findInterruptResourceIndex(descriptor)) |auxiliary_index| { if (device.claim(descriptor.id) and device.irqBind(descriptor.id, auxiliary_index, endpoint)) { @@ -263,8 +263,8 @@ pub fn main() void { _ = runtime.system.write("system/drivers/ps2-bus: controller configuration timed out\n"); return; }; - if (port_device_types[@intFromEnum(ps2.Port.One)] != null) configuration |= ps2.Port.One.interruptBit(); - if (maybe_auxiliary_interrupt != null) configuration |= ps2.Port.Two.interruptBit(); + if (port_device_types[@intFromEnum(ps2.Port.one)] != null) configuration |= ps2.Port.one.interruptBit(); + if (maybe_auxiliary_interrupt != null) configuration |= ps2.Port.two.interruptBit(); _ = controller.writeConfigurationByte(configuration); _ = runtime.system.write("system/drivers/ps2-bus: ok\n"); @@ -284,7 +284,7 @@ pub fn main() void { const current_status = ps2.status(controller.device_id, controller.status_index); if (current_status & ps2.status_output_buffer_full == 0) break; const byte = device.ioRead(controller.device_id, controller.data_index, 0, 1) orelse break; - const port: ps2.Port = if (current_status & ps2.status_auxiliary_output != 0) .Two else .One; + const port: ps2.Port = if (current_status & ps2.status_auxiliary_output != 0) .two else .one; if (port_endpoints[@intFromEnum(port)]) |child| { const forwarded = ps2.ForwardedByte{ .port = @intFromEnum(port), .byte = byte }; _ = ipc.send(child, std.mem.asBytes(&forwarded)); diff --git a/system/drivers/ps2-bus/ps2-library.zig b/system/drivers/ps2-bus/ps2-library.zig index 944a091..0eeac4d 100644 --- a/system/drivers/ps2-bus/ps2-library.zig +++ b/system/drivers/ps2-bus/ps2-library.zig @@ -153,46 +153,46 @@ pub fn writeData(id: u64, status_index: u64, data_index: u64, byte: u8, timeout_ } pub const Port = enum(u2) { - One, - Two, + one, + two, /// Command register byte that disables this port. fn disableCommand(self: Port) u8 { return switch (self) { - .One => cmd_disable_first_port, - .Two => cmd_disable_second_port, + .one => cmd_disable_first_port, + .two => cmd_disable_second_port, }; } /// Command register byte that enables this port (and its clock). fn enableCommand(self: Port) u8 { return switch (self) { - .One => cmd_enable_first_port, - .Two => cmd_enable_second_port, + .one => cmd_enable_first_port, + .two => cmd_enable_second_port, }; } /// Command register byte that runs this port's interface test. fn testCommand(self: Port) u8 { return switch (self) { - .One => cmd_test_first_port, - .Two => cmd_test_second_port, + .one => cmd_test_first_port, + .two => cmd_test_second_port, }; } /// Configuration-byte bit that, when set, disables this port's clock. pub fn clockDisabledBit(self: Port) u8 { return switch (self) { - .One => configuration_first_port_clock_disabled, - .Two => configuration_second_port_clock_disabled, + .one => configuration_first_port_clock_disabled, + .two => configuration_second_port_clock_disabled, }; } /// Configuration-byte bit that, when set, enables this port's interrupt. pub fn interruptBit(self: Port) u8 { return switch (self) { - .One => configuration_first_port_interrupt, - .Two => configuration_second_port_interrupt, + .one => configuration_first_port_interrupt, + .two => configuration_second_port_interrupt, }; } @@ -200,8 +200,8 @@ pub const Port = enum(u2) { /// output buffer (makes a byte appear as if it came from the device). pub fn writeOutputBufferCommand(self: Port) u8 { return switch (self) { - .One => cmd_write_first_port_output, - .Two => cmd_write_second_port_output, + .one => cmd_write_first_port_output, + .two => cmd_write_second_port_output, }; } @@ -210,24 +210,24 @@ pub const Port = enum(u2) { /// prefix (null); port 2 requires the "write second port input" command. pub fn deviceInputCommand(self: Port) ?u8 { return switch (self) { - .One => null, - .Two => cmd_write_second_port_input, + .one => null, + .two => cmd_write_second_port_input, }; } /// Controller output-port bit driving this port's clock line. pub fn outputPortClockBit(self: Port) u8 { return switch (self) { - .One => output_port_first_port_clock, - .Two => output_port_second_port_clock, + .one => output_port_first_port_clock, + .two => output_port_second_port_clock, }; } /// Controller output-port bit driving this port's data line. pub fn outputPortDataBit(self: Port) u8 { return switch (self) { - .One => output_port_first_port_data, - .Two => output_port_second_port_data, + .one => output_port_first_port_data, + .two => output_port_second_port_data, }; } @@ -235,8 +235,8 @@ pub const Port = enum(u2) { /// (wired to the port's IRQ line). pub fn outputPortBufferFullBit(self: Port) u8 { return switch (self) { - .One => output_port_first_port_output_full, - .Two => output_port_second_port_output_full, + .one => output_port_first_port_output_full, + .two => output_port_second_port_output_full, }; } }; @@ -393,9 +393,9 @@ pub const Controller = struct { /// enabled; the caller should disable it again to keep the bus quiet until /// device bring-up. pub fn hasTwoChannels(self: Controller) ?bool { - self.enablePort(.Two); + self.enablePort(.two); const configuration = self.readConfigurationByte() orelse return null; - return (configuration & Port.Two.clockDisabledBit()) == 0; + return (configuration & Port.two.clockDisabledBit()) == 0; } /// Reset the device attached to `port` (device command 0xFF) and wait for