From 9d211eb10403b899571ca239c00a90f6fcc8b65e Mon Sep 17 00:00:00 2001 From: Salvatore Benedetto Date: Fri, 26 Oct 2007 12:55:16 +0000 Subject: [PATCH] * Removed endpoint and descriptor wrappers, everything is in the related structure like it's done in the uhci driver. * Clean up continues git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22733 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/busses/usb/ohci.h | 59 ++++--------------- src/add-ons/kernel/busses/usb/ohci_hardware.h | 28 ++++++--- 2 files changed, 31 insertions(+), 56 deletions(-) diff --git a/src/add-ons/kernel/busses/usb/ohci.h b/src/add-ons/kernel/busses/usb/ohci.h index f087052fac..5c06b751ed 100644 --- a/src/add-ons/kernel/busses/usb/ohci.h +++ b/src/add-ons/kernel/busses/usb/ohci.h @@ -18,9 +18,6 @@ struct pci_info; struct pci_module_info; class OHCIRootHub; -struct Endpoint; -struct TransferDescriptor; - // -------------------------------------- // OHCI:: Software isonchronous // transfer descriptor @@ -38,45 +35,10 @@ typedef struct hcd_soft_itransfer #endif }hcd_soft_itransfer; -#define OHCI_SITD_SIZE ((sizeof (struct hcd_soft_itransfer) + OHCI_ITD_ALIGN - 1) / OHCI_ITD_ALIGN * OHCI_ITD_ALIGN) -#define OHCI_SITD_CHUNK 64 +#define OHCI_SITD_SIZE ((sizeof (struct hcd_soft_itransfer) + OHCI_ITD_ALIGN - 1) / OHCI_ITD_ALIGN * OHCI_ITD_ALIGN) +#define OHCI_SITD_CHUNK 64 -// ------------------------------------------ -// OHCI:: Number of enpoint descriptors (63) -// ------------------------------------------ - -#define OHCI_NO_EDS (2 * OHCI_NUMBER_OF_INTERRUPTS - 1) - -// -// Endpoint: wrapper around the hardware endpoints -// - -struct Endpoint -{ - addr_t physical_address;//Point to the physical address - ohci_endpoint_descriptor *ed; //Logical 'endpoint' - Endpoint *next; //Pointer to the 'next' endpoint - TransferDescriptor *head, *tail; //Pointers to the 'head' and 'tail' transfer descriptors - - //Utility functions - void SetNext(Endpoint *end) { - next = end; - if (end == 0) - ed->next_endpoint = 0; - else - ed->next_endpoint = end->physical_address; - }; - - //Constructor (or better: initialiser) - Endpoint() : physical_address(0), ed(0), next(0), head(0), tail(0) {}; -}; - - -struct TransferDescriptor -{ - addr_t physical_address; - ohci_general_transfer_descriptor *td; -}; +#define OHCI_NUMBER_OF_ENDPOINTS (2 * OHCI_NUMBER_OF_INTERRUPTS - 1) class OHCI : public BusManager @@ -104,8 +66,8 @@ static status_t AddTo(Stack *stack); private: // Register functions -inline void WriteReg(uint32 reg, uint32 value); -inline uint32 ReadReg(uint32 reg); +inline void _WriteReg(uint32 reg, uint32 value); +inline uint32 _ReadReg(uint32 reg); // Global static pci_module_info *sPCIModule; @@ -116,22 +78,23 @@ static pci_module_info *sPCIModule; area_id fRegisterArea; - // HCCA + // Host Controller Communication Area related stuff area_id fHccaArea; - struct ohci_hcca *fHcca; - Endpoint *fInterruptEndpoints[OHCI_NO_EDS]; + struct ohci_hcca *fHcca; + Endpoint *fInterruptEndpoints[OHCI_NUMBER_OF_ENDPOINTS]; // Dummy endpoints Endpoint *fDummyControl; Endpoint *fDummyBulk; Endpoint *fDummyIsochronous; - // functions + + // Endpoint related methods Endpoint *_AllocateEndpoint(); void _FreeEndpoint(Endpoint *end); TransferDescriptor *_AllocateTransfer(); void _FreeTransfer(TransferDescriptor *trans); - status_t _InsertEndpointForPipe(Pipe *p); + void _SetNext(ohci_endpoint_descriptor *endpoint); // Root Hub OHCIRootHub *fRootHub; diff --git a/src/add-ons/kernel/busses/usb/ohci_hardware.h b/src/add-ons/kernel/busses/usb/ohci_hardware.h index 1ca15776d8..2d4dd9dd03 100644 --- a/src/add-ons/kernel/busses/usb/ohci_hardware.h +++ b/src/add-ons/kernel/busses/usb/ohci_hardware.h @@ -297,10 +297,16 @@ typedef struct ohci_hcca typedef struct ohci_endpoint_descriptor { - uint32 flags; - uint32 tail_pointer; // Queue tail pointer - uint32 head_pointer; // Queue head pointer - uint32 next_endpoint; // Next endpoint in the list + // Hardware part + uint32 flags; // Flags field + uint32 tail_physical_descriptor; // Queue tail physical pointer + uint32 head_physical_descriptor; // Queue head physical pointer + uint32 next_physical_endpoint; // Physical pointer to the next endpoint + // Software part + addr_t this_physical; // Physical pointer to this address + void *tail_logical_descriptor; // Queue tail logical pointer + void *head_logical_descriptor; // Queue head logical pointer + void *next_logical_endpoint; // Logical pointer to the next endpoint }; #define OHCI_ENDPOINT_ADDRESS_MASK 0x0000007f @@ -330,10 +336,16 @@ typedef struct ohci_endpoint_descriptor typedef struct ohci_general_transfer_descriptor { - uint32 flags; - uint32 buffer_phy; // Physical buffer pointer - uint32 next_descriptor; // Next transfer descriptor - uint32 last_byte_address; // Physical buffer end + // Hardware part + uint32 flags; // Flags field + uint32 buffer_physical; // Physical buffer pointer + uint32 next_physical_descriptor; // Physical pointer next descriptor + uint32 last_physical_byte_address; // Physical pointer to buffer end + // Software part + addr_t this_physical; // Physical pointer to this address + void *buffer_logical; // Logical pointer to the buffer + void *next_logical_descriptor; // Logical pointer next descriptor + void *last_logical_byte_address; // Logical pointer buffer end }; #define OHCI_BUFFER_ROUNDING 0x00040000