MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / InitializePorts

Method InitializePorts

Kernel/src/usb/xhci.cpp:327–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325 }
326
327 void XHCIController::InitializePorts(){
328 for(xhci_ext_cap_supported_protocol_t* protocol : protocols){ // Check both protocols as some share ports
329 for(unsigned i = protocol->portOffset; i < protocol->portOffset + protocol->portCount && i < capRegs->MaxPorts() + 1U; i++){
330 xhci_port_regs_t& port = portRegs[i - 1];
331 if(!port.Powered()){
332 port.PowerOn();
333
334 Timer::Wait(20); // 20ms delay
335
336 if(!port.Powered()){
337 continue; // Not powered so move on
338 }
339 }
340
341 if(protocol->majorRevision == 0x3){ // USB 3.0
342 port.WarmReset();
343 } else {
344 port.Reset();
345 }
346
347 if(!port.Enabled()){
348 int timeout = 25;
349 while(timeout-- && !(port.portSC & XHCI_PORTSC_PRC)){
350 Timer::Wait(1); // Wait for port reset change
351 }
352 }
353
354 if(port.Enabled()){
355 if(debugLevelXHCI >= DebugLevelVerbose){
356 Log::Info("Port %i is enabled!", i);
357 }
358 }
359 }
360 }
361 }
362}

Callers

nothing calls this directly

Calls 8

InfoFunction · 0.85
MaxPortsMethod · 0.80
PoweredMethod · 0.80
PowerOnMethod · 0.80
WarmResetMethod · 0.80
ResetMethod · 0.80
EnabledMethod · 0.80
WaitFunction · 0.50

Tested by

no test coverage detected