| 135 | }); |
| 136 | return true; |
| 137 | } |
| 138 | |
| 139 | void PS2Controller::update_command_queue() |
| 140 | { |
| 141 | Command command_copy; |
| 142 | |
| 143 | { |
| 144 | SpinLockGuard _(m_command_lock); |
| 145 | |
| 146 | if (m_command_queue.empty()) |
| 147 | return; |
| 148 | auto& command = m_command_queue.front(); |
| 149 | if (command.state == Command::State::WaitingResponse || command.state == Command::State::WaitingAck) |
| 150 | { |
| 151 | if (SystemTimer::get().ms_since_boot() >= m_command_send_time + s_ps2_timeout_ms) |
| 152 | { |
| 153 | dwarnln_if(DEBUG_PS2, "Command timedout"); |
| 154 | m_devices[command.device_index]->command_timedout(command.out_data, command.out_count); |
| 155 | m_command_queue.pop(); |
| 156 | } |
| 157 | return; |
| 158 | } |
| 159 | ASSERT(command.send_index < command.out_count); |
| 160 | command.state = Command::State::WaitingAck; |
| 161 | |
| 162 | command_copy = command; |
| 163 | } |
| 164 | |
| 165 | m_command_send_time = SystemTimer::get().ms_since_boot(); |
| 166 | if (auto ret = device_send_byte(command_copy.device_index, command_copy.out_data[command_copy.send_index]); ret.is_error()) |
| 167 | dwarnln_if(DEBUG_PS2, "PS/2 send command byte: {}", ret.error()); |
| 168 | } |
| 169 |
no test coverage detected