浏览了一下OHCI代码和WINCE USB构架,总结一下,怕以后忘记了。
host ----- function
client driver (Mass storage, rndis...) ----- client driver(Mass storage, rndis...)
controller driver(OHCI,UHCI...) ----- controller driver(ufn ctrolller)
controller find usb hardware device and load client driver.
Bus manage and service drivers under bus
About OHCI:
MDD
entery : hcddrv.cpp --> hcd_init hcd_open ...
PDD
entery: s3c6410_ohci.c -->HcdPdd_Init HcdPdd_Open ...
Cdevice.cpp:
// This file manages the USB devices
//
// CDevice (ADT)
// / /
// CFunction CHub (ADT)
// / /
// CRootHub CExternalHub
We Create CRootHub when init in HcdMdd_CreateHcdObject()--->Create a COhcd object-->call COhcd::DeviceInitialize()-->
CRootHub::EnterOperationalState() create a HubStatusChangeThreadStub to run for detect hubport state change
---> in the thread we call WaitForPortStatusChange() to get if any port state change go on to AttachDevice() , if
no port state change check if there is no device on the port suspend the port and go on WaitForPortStatusChange()....
Notes: the port state is defined in OHCI registers , we read the register in WaitForPortStatusChange() funciton
Others about code:
CHW.cpp:
class CHW : public CHcd ---> class CHcd : public LockObject, public CDeviceGlobal
Cohcd.cpp:
class COhcd : public CHW, public CHCCAera
when Cohcd::DeviceInitialize() is called by HcdMdd_CreateHcdObject() when driver init,we create a root hub and
set it to m_pCRootHub by CHcd::SetRootHub()
the hcd_init function return a SOhcdPdd struct object and the struct is initialized in HcdPdd_Init,
SOhcdPdd::lpvOhcdMddObject = pobOhcd(this is the Cohcd object we created ).when we call
hcd_poweron or hcd_deinit and etc , the struct object will be send for us to use.