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

Method InitializeProtocols

Kernel/src/usb/xhci.cpp:296–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294 }
295
296 void XHCIController::InitializeProtocols(){
297 auto initializeProto = [&](xhci_ext_cap_supported_protocol_t* cap){
298 if(debugLevelXHCI){
299 Log::Info("[XHCI] Initializing protocol \"%c%c%c%c\", Version: %u%u.%u%u, Port Range: %u-%u", cap->name[0], cap->name[1], cap->name[2], cap->name[3], (cap->majorRevision >> 4), (cap->majorRevision & 0xF), (cap->minorRevision >> 4), (cap->minorRevision & 0xF), cap->portOffset, (cap->portOffset + cap->portCount));
300 }
301
302 protocols.add_back(cap);
303
304 for(unsigned i = cap->portOffset; i < cap->portOffset + cap->portCount && i < capRegs->MaxPorts(); i++){
305 ports[i].protocol = cap;
306 }
307 };
308
309 xhci_ext_cap_supported_protocol_t* cap = reinterpret_cast<xhci_ext_cap_supported_protocol_t*>(extCapabilities);
310 for(;;){
311 if(cap->capID == XHCIExtendedCapabilities::XHCIExtCapSupportedProtocol){
312 initializeProto(cap);
313 }
314
315 if(!cap->nextCap){
316 break; // Last capability
317 }
318
319 cap = reinterpret_cast<xhci_ext_cap_supported_protocol_t*>(reinterpret_cast<uintptr_t>(cap) + (cap->nextCap << 2));
320 }
321
322 if(!protocols.get_length()){
323 Log::Error("[XHCI] Could not find any protocols!");
324 }
325 }
326
327 void XHCIController::InitializePorts(){
328 for(xhci_ext_cap_supported_protocol_t* protocol : protocols){ // Check both protocols as some share ports

Callers

nothing calls this directly

Calls 5

InfoFunction · 0.85
ErrorFunction · 0.85
MaxPortsMethod · 0.80
add_backMethod · 0.45
get_lengthMethod · 0.45

Tested by

no test coverage detected