MCPcopy Create free account
hub / github.com/Bananymous/banan-os / update_command_queue

Method update_command_queue

kernel/kernel/Input/PS2/Controller.cpp:137–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

updateMethod · 0.80
updateMethod · 0.80

Calls 7

errorMethod · 0.80
emptyMethod · 0.45
frontMethod · 0.45
ms_since_bootMethod · 0.45
command_timedoutMethod · 0.45
popMethod · 0.45
is_errorMethod · 0.45

Tested by

no test coverage detected