Skip to content

Structure of XHCI driver

Salmelu edited this page Jan 19, 2018 · 3 revisions

This page explains, what you can find in the uspace/drv/bus/usb/xhci directory, and the rationale behind spliting it this way.

main.c
Initialization as a DDF driver, using libusbhost. Contains adaptors for libusbhost to inner event handlers.
hc.h, hc.c
Main implementation of HC driver. Contains generic code such as HC initialization, IRQ handling, scheduling. In general, contains code that did'nt fit anywhere more specific.
bus.h, bus.c
Implementation of bus operations. Contains code to handle device add (enumeration) or removal.
commands.h, commands.c
xHCI defines both direct register writing and commands written on a ring for communication with the host. These files create a thin abstraction for placing commands on the command ring and accessing the result.
endpoint.h, endpoint.c
Code related to setting up and tearing down endpoints.
rh.h, rh.c
Roothub operation. XHCI, on contrary to older HC drivers, does not use a virtual roothub. Roothub in XHCI simply requires special handling.
scratchpad.h, scratchpad.c
Allocation and deallocation of scratchpad buffers.
streams.h, streams.c
Setup of bulk stream contexts.
transfers.h, transfers.c
Scheduling of transfers and specifics of different transfer types.
trb_ring.h, trb_ring.c
Data structures and operation functions for handling TRB rings, as a common structure for exchanging information with the controller.
debug.h
Various debug functions to dump data structures and convert constants to strings.
hw_struct/common.h
Common functions for communication with controller. Files in this directory shall reflect what host controllers expect from the driver, and as such they shall be append-only.
hw_struct/regs.h, test/reg-ops.c
Utility macros to access registers both conveniently and safely. Registers are defined in a declarative way using macros, and can be then accessed without knowing what is their precise location. The header file then contains definitions of all registers in the register interface of XHCI.
hw_struct/context.h
Data structures and access macros of structures shared between host and controller, usually referred to as various contexts.
hw_struct/trb.h
Definition of TRB structure and constants, access macros for TRBs.
Makefile, xhci.ma
Driver boilerplate.

Clone this wiki locally