XenevaOS
Loading...
Searching...
No Matches
Macros | Functions
usb3.cpp File Reference
#include "usb3.h"
#include "xhci.h"
#include "xhci_cmd.h"
#include <Mm\pmmngr.h>
#include <Mm\vmmngr.h>
#include <Mm\kmalloc.h>
#include <aucon.h>
#include <Hal\serial.h>
#include <string.h>
#include <_null.h>
#include "classes\hid.h"
#include "classes\hub.h"
Include dependency graph for usb3.cpp:

Macros

#define USB_SLOT_CTX_DWORD0(entries, hub, multi_tt, speed, route_string)    (((entries & 0x1F) << 27) | ((hub & 1) << 26) | ((multi_tt & 1) << 25) | ((speed & 0xF) << 20) | (route_string & ((1 << 20) - 1)))
 
#define USB_SLOT_CTX_DWORD1(num_ports, root_hub_port, max_exit_latency)    (((num_ports & 0xFF) << 24) | ((root_hub_port & 0xFF) << 16) | (max_exit_latency & 0xFFFF))
 
#define USB_ENDPOINT_CTX_DWORD0(max_esit_high, interval, lsa, max_p_streams, mult, ep_state)    (((max_esit_high & 0xFF) << 24) | ((interval & 0xFF) << 16) | ((lsa & 1) << 15) | ((max_p_streams & 0x1F) << 10) | ((mult & 0x3) << 8) | (ep_state & 0x7))
 
#define USB_ENDPOINT_CTX_DWORD1(max_packet_size, max_burst_size, hid, ep_type, cerr)    (((max_packet_size & 0xFFFF) << 16) | ((max_burst_size & 0xFF) << 8) | ((hid & 1) << 7) | ((ep_type & 0x7) << 3) | ((cerr & 0x3) << 1))
 
#define USB_ENDPOINT_CTX_DWORD2(trdp, dcs)    ((trdp & 0xFFFFFFFF) | (dcs & 1))
 
#define USB_ENDPOINT_CTX_DWORD3(trdp)    ((trdp >> 32) & 0xFFFFFFFF)
 
#define USB_ENDPOINT_CTX_DWORD4(max_esit_lo, average_trb_len)    (((max_esit_lo & 0xFFFF) << 16) | (average_trb_len & 0xFFFF))
 
#define PORT_CHANGE_CLEAR_BIT   (1<<9) | (1<<17) | (1<<18) | (1<<20) | (1<<21) | (1<<22)
 

Functions

void XHCIReset (USBDevice *dev)
 
void XHCIDeviceContextInit (USBDevice *dev)
 
void XHCICommandRingInit (USBDevice *dev)
 
size_t XHCIGetMaxPacketSize (uint8_t speed)
 
void XHCIAddSlot (USBDevice *dev, XHCISlot *slot)
 
void XHCISlotRemove (USBDevice *dev, uint8_t slot_id)
 
XHCISlotXHCIGetSlot (USBDevice *dev, uint8_t port_num)
 
XHCISlotXHCIGetSlotByID (USBDevice *dev, uint8_t slot_id)
 
XHCIEndpointXHCISlotGetEP (XHCISlot *slot, uint8_t endp_num)
 
XHCIEndpointXHCISlotGetEP_DCI (XHCISlot *slot, uint8_t endp_num)
 
XHCISlotXHCICreateDeviceCtx (USBDevice *dev, uint8_t slot_num, uint8_t port_speed, uint8_t root_port_num)
 
void XHCIProtocolInit (USBDevice *dev)
 
void XHCIEventRingInit (USBDevice *dev)
 
void XHCISendCommand (USBDevice *dev, uint32_t param1, uint32_t param2, uint32_t status, uint32_t ctrl)
 
void XHCISendCommandSlot (XHCISlot *slot, uint32_t param1, uint32_t param2, uint32_t status, uint32_t ctrl)
 
void XHCISendCommandEndpoint (XHCISlot *slot, uint8_t endp_num, uint32_t param1, uint32_t param2, uint32_t status, uint32_t ctrl)
 
void XHCIRingDoorbell (USBDevice *dev)
 
void XHCIRingDoorbellSlot (USBDevice *dev, uint8_t slot, uint32_t endpoint)
 
void XHCISendCommandMultiple (USBDevice *dev, xhci_trb_t *trb, int num_count)
 
int XHCIPollEvent (USBDevice *usb_device, int trb_type)
 
char * XHCIGetPortSpeed (uint8_t port_speed)
 
void XHCIPortReset (xhci_port_regs_t *this_port)
 
void XHCIPortInitialize (USBDevice *dev, unsigned int port)
 
void XHCIStartDefaultPorts (USBDevice *dev)
 

Macro Definition Documentation

◆ PORT_CHANGE_CLEAR_BIT

#define PORT_CHANGE_CLEAR_BIT   (1<<9) | (1<<17) | (1<<18) | (1<<20) | (1<<21) | (1<<22)

◆ USB_ENDPOINT_CTX_DWORD0

#define USB_ENDPOINT_CTX_DWORD0 (   max_esit_high,
  interval,
  lsa,
  max_p_streams,
  mult,
  ep_state 
)     (((max_esit_high & 0xFF) << 24) | ((interval & 0xFF) << 16) | ((lsa & 1) << 15) | ((max_p_streams & 0x1F) << 10) | ((mult & 0x3) << 8) | (ep_state & 0x7))

◆ USB_ENDPOINT_CTX_DWORD1

#define USB_ENDPOINT_CTX_DWORD1 (   max_packet_size,
  max_burst_size,
  hid,
  ep_type,
  cerr 
)     (((max_packet_size & 0xFFFF) << 16) | ((max_burst_size & 0xFF) << 8) | ((hid & 1) << 7) | ((ep_type & 0x7) << 3) | ((cerr & 0x3) << 1))

◆ USB_ENDPOINT_CTX_DWORD2

#define USB_ENDPOINT_CTX_DWORD2 (   trdp,
  dcs 
)     ((trdp & 0xFFFFFFFF) | (dcs & 1))

◆ USB_ENDPOINT_CTX_DWORD3

#define USB_ENDPOINT_CTX_DWORD3 (   trdp)     ((trdp >> 32) & 0xFFFFFFFF)

◆ USB_ENDPOINT_CTX_DWORD4

#define USB_ENDPOINT_CTX_DWORD4 (   max_esit_lo,
  average_trb_len 
)     (((max_esit_lo & 0xFFFF) << 16) | (average_trb_len & 0xFFFF))

◆ USB_SLOT_CTX_DWORD0

#define USB_SLOT_CTX_DWORD0 (   entries,
  hub,
  multi_tt,
  speed,
  route_string 
)     (((entries & 0x1F) << 27) | ((hub & 1) << 26) | ((multi_tt & 1) << 25) | ((speed & 0xF) << 20) | (route_string & ((1 << 20) - 1)))

BSD 2-Clause License

Copyright (c) 2022-2023, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

◆ USB_SLOT_CTX_DWORD1

#define USB_SLOT_CTX_DWORD1 (   num_ports,
  root_hub_port,
  max_exit_latency 
)     (((num_ports & 0xFF) << 24) | ((root_hub_port & 0xFF) << 16) | (max_exit_latency & 0xFFFF))

Function Documentation

◆ XHCIAddSlot()

void XHCIAddSlot ( USBDevice dev,
XHCISlot slot 
)

◆ XHCICommandRingInit()

void XHCICommandRingInit ( USBDevice dev)

◆ XHCICreateDeviceCtx()

XHCISlot * XHCICreateDeviceCtx ( USBDevice dev,
uint8_t  slot_num,
uint8_t  port_speed,
uint8_t  root_port_num 
)

◆ XHCIDeviceContextInit()

void XHCIDeviceContextInit ( USBDevice dev)

◆ XHCIEventRingInit()

void XHCIEventRingInit ( USBDevice dev)

◆ XHCIGetMaxPacketSize()

size_t XHCIGetMaxPacketSize ( uint8_t  speed)

◆ XHCIGetPortSpeed()

char * XHCIGetPortSpeed ( uint8_t  port_speed)

◆ XHCIGetSlot()

XHCISlot * XHCIGetSlot ( USBDevice dev,
uint8_t  port_num 
)

◆ XHCIGetSlotByID()

XHCISlot * XHCIGetSlotByID ( USBDevice dev,
uint8_t  slot_id 
)

◆ XHCIPollEvent()

int XHCIPollEvent ( USBDevice usb_device,
int  trb_type 
)
  • here we need a delay, while using VirtualBox *‍/

◆ XHCIPortInitialize()

void XHCIPortInitialize ( USBDevice dev,
unsigned int  port 
)

◆ XHCIPortReset()

void XHCIPortReset ( xhci_port_regs_t this_port)

◆ XHCIProtocolInit()

void XHCIProtocolInit ( USBDevice dev)

◆ XHCIReset()

void XHCIReset ( USBDevice dev)

◆ XHCIRingDoorbell()

void XHCIRingDoorbell ( USBDevice dev)

◆ XHCIRingDoorbellSlot()

void XHCIRingDoorbellSlot ( USBDevice dev,
uint8_t  slot,
uint32_t  endpoint 
)

◆ XHCISendCommand()

void XHCISendCommand ( USBDevice dev,
uint32_t  param1,
uint32_t  param2,
uint32_t  status,
uint32_t  ctrl 
)

◆ XHCISendCommandEndpoint()

void XHCISendCommandEndpoint ( XHCISlot slot,
uint8_t  endp_num,
uint32_t  param1,
uint32_t  param2,
uint32_t  status,
uint32_t  ctrl 
)

◆ XHCISendCommandMultiple()

void XHCISendCommandMultiple ( USBDevice dev,
xhci_trb_t trb,
int  num_count 
)

◆ XHCISendCommandSlot()

void XHCISendCommandSlot ( XHCISlot slot,
uint32_t  param1,
uint32_t  param2,
uint32_t  status,
uint32_t  ctrl 
)

◆ XHCISlotGetEP()

XHCIEndpoint * XHCISlotGetEP ( XHCISlot slot,
uint8_t  endp_num 
)

◆ XHCISlotGetEP_DCI()

XHCIEndpoint * XHCISlotGetEP_DCI ( XHCISlot slot,
uint8_t  endp_num 
)

◆ XHCISlotRemove()

void XHCISlotRemove ( USBDevice dev,
uint8_t  slot_id 
)

◆ XHCIStartDefaultPorts()

void XHCIStartDefaultPorts ( USBDevice dev)