25 #include "modules/system/usb/Usb.h" 26 #include "modules/system/usb/UsbHub.h" 27 #include "pedigree/kernel/Spinlock.h" 28 #include "pedigree/kernel/compiler.h" 29 #include "pedigree/kernel/machine/IrqHandler.h" 30 #include "pedigree/kernel/machine/TimerHandler.h" 31 #include "pedigree/kernel/machine/types.h" 32 #include "pedigree/kernel/process/Mutex.h" 33 #include "pedigree/kernel/process/Semaphore.h" 34 #include "pedigree/kernel/processor/MemoryRegion.h" 35 #include "pedigree/kernel/processor/state_forward.h" 36 #include "pedigree/kernel/processor/types.h" 37 #include "pedigree/kernel/utilities/ExtensibleBitmap.h" 38 #include "pedigree/kernel/utilities/List.h" 39 #include "pedigree/kernel/utilities/RequestQueue.h" 40 #include "pedigree/kernel/utilities/String.h" 41 #include "pedigree/kernel/utilities/new" 58 uint32_t bNextInvalid : 1;
60 uint32_t bNextDepth : 1;
63 uint32_t nActLen : 11;
67 uint32_t bIsochronus : 1;
68 uint32_t bLoSpeed : 1;
73 uint32_t nAddress : 7;
74 uint32_t nEndpoint : 4;
75 uint32_t bDataToggle : 1;
77 uint32_t nMaxLen : 11;
82 bool bShortTransferTD;
95 inline UsbError getError()
99 else if (nStatus & Nak)
101 else if (nStatus & Babble)
103 else if (nStatus & Timeout)
106 return TransactionError;
112 uint32_t bNextInvalid : 1;
113 uint32_t bNextQH : 1;
116 uint32_t bElemInvalid : 1;
117 uint32_t bElemQH : 1;
123 void (*pCallback)(uintptr_t, ssize_t);
152 uintptr_t pTransaction,
bool bToggle, UsbPid pid, uintptr_t pBuffer,
157 uintptr_t pTransaction,
void (*pCallback)(uintptr_t, ssize_t) = 0,
158 uintptr_t pParam = 0);
160 UsbEndpoint endpointInfo, uintptr_t pBuffer, uint16_t nBytes,
161 void (*pCallback)(uintptr_t, ssize_t), uintptr_t pParam = 0);
164 virtual bool irq(irq_id_t number, InterruptState &state);
169 void timer(uint64_t delta, InterruptState &state);
171 virtual bool portReset(uint8_t nPort,
bool bErrorResponse =
false);
175 uint64_t p1 = 0, uint64_t p2 = 0, uint64_t p3 = 0, uint64_t p4 = 0,
176 uint64_t p5 = 0, uint64_t p6 = 0, uint64_t p7 = 0, uint64_t p8 = 0);
194 UHCI_CMD_GRES = 0x04,
195 UHCI_CMD_HCRES = 0x02,
198 UHCI_STS_HALT = 0x20,
202 UHCI_PORTSC_PRES = 0x200,
203 UHCI_PORTSC_LOSPEED = 0x100,
204 UHCI_PORTSC_EDCH = 0x8,
205 UHCI_PORTSC_ENABLE = 0x4,
206 UHCI_PORTSC_CSCH = 0x2,
207 UHCI_PORTSC_CONN = 0x1,
216 Spinlock m_AsyncQueueListChangeLock;
218 uint32_t *m_pFrameList;
219 uintptr_t m_pFrameListPhys;
222 uintptr_t m_pTDListPhys;
229 uintptr_t m_pQHListPhys;
255 void operator=(
const Uhci &);
QH * m_pCurrentAsyncQueueHead
virtual bool portReset(uint8_t nPort, bool bErrorResponse=false)
Gets a UsbDevice from a given vendor:product pair.
void start()
Starts the UHCI controller.
virtual void addInterruptInHandler(UsbEndpoint endpointInfo, uintptr_t pBuffer, uint16_t nBytes, void(*pCallback)(uintptr_t, ssize_t), uintptr_t pParam=0)
Adds a new handler for an interrupt IN transaction.
Abstrace base class for hardware I/O capabilities.
virtual uintptr_t createTransaction(UsbEndpoint endpointInfo)
Creates a new transaction with the given endpoint data.
void timer(uint64_t delta, InterruptState &state)
Timer callback to handle port status changes.
Semaphore m_DequeueCount
Semaphore for the dequeue list.
virtual bool irq(irq_id_t number, InterruptState &state)
IRQ handler.
Special memory entity in the kernel's virtual address space.
QH * m_pCurrentAsyncQueueTail
virtual void getName(String &str)
List< QH * > m_DequeueList
List of QHs ready for dequeue.
List< QH * > m_AsyncSchedule
List of QHs in the active asynchronous schedule.
void stop()
Stops the UHCI controller.
virtual uint64_t executeRequest(uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0)
virtual void addTransferToTransaction(uintptr_t pTransaction, bool bToggle, UsbPid pid, uintptr_t pBuffer, size_t nBytes)
Adds a new transfer to an existent transaction.
uint64_t m_nPortCheckTicks
The time passed since last port check.
virtual void doAsync(uintptr_t pTransaction, void(*pCallback)(uintptr_t, ssize_t)=0, uintptr_t pParam=0)