* Getting familiar with the existing code

* Cleanup (whitespace, nameing, code style)
* Move around methods so they match the header order
* Fix some obvious stuff
* Initialize all members
* Sync roothub code (this will be reworked to a common roothub)
* Only minor functional changes (to the worse for now)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25527 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-05-17 12:39:46 +00:00
parent 25d0a0841f
commit fd1e6f2b37
4 changed files with 857 additions and 845 deletions
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -105,13 +105,13 @@ static int32 _InterruptHandler(void *data);
status_t _UnlinkTransfer(transfer_data *transfer); status_t _UnlinkTransfer(transfer_data *transfer);
static int32 _FinishThread(void *data); static int32 _FinishThread(void *data);
void _FinishTransfer(); void _FinishTransfers();
status_t _SubmitControlRequest(Transfer *transfer); status_t _SubmitControlTransfer(Transfer *transfer);
status_t _SubmitBulkTransfer(Transfer *transfer); status_t _SubmitBulkTransfer(Transfer *transfer);
status_t _SubmitPeriodicTransfer(Transfer *transfer); status_t _SubmitPeriodicTransfer(Transfer *transfer);
status_t _AppendChainDescriptorsToEndpoint( status_t _AppendDescriptorChainToEndpoint(
ohci_endpoint_descriptor *endpoint, ohci_endpoint_descriptor *endpoint,
ohci_general_td *first, ohci_general_td *first,
ohci_general_td *last); ohci_general_td *last);
@@ -129,17 +129,22 @@ static int32 _FinishThread(void *data);
// Transfer descriptor related methods // Transfer descriptor related methods
ohci_general_td *_CreateGeneralDescriptor( ohci_general_td *_CreateGeneralDescriptor(
size_t bufferSize); size_t bufferSize);
void _FreeGeneralDescriptor(
ohci_general_td *descriptor);
status_t _CreateDescriptorChain( status_t _CreateDescriptorChain(
ohci_general_td **firstDescriptor, ohci_general_td **firstDescriptor,
ohci_general_td **lastDescriptor, ohci_general_td **lastDescriptor,
uint8 direction, uint8 direction,
size_t bufferSize); size_t bufferSize);
void _FreeGeneralDescriptor(
ohci_general_td *descriptor);
void _FreeDescriptorChain( void _FreeDescriptorChain(
ohci_general_td *topDescriptor); ohci_general_td *topDescriptor);
size_t _WriteDescriptorChain(
ohci_general_td *topDescriptor,
iovec *vector,
size_t vectorCount);
void _LinkDescriptors(ohci_general_td *first, void _LinkDescriptors(ohci_general_td *first,
ohci_general_td *second); ohci_general_td *second);
@@ -147,11 +152,6 @@ static int32 _FinishThread(void *data);
void _FreeIsochronousDescriptor( void _FreeIsochronousDescriptor(
ohci_isochronous_td *descriptor); ohci_isochronous_td *descriptor);
size_t _WriteDescriptorChain(
ohci_general_td *topDescriptor,
iovec *vector,
size_t vectorCount);
// Hash tables related methods // Hash tables related methods
void _AddDescriptorToHash( void _AddDescriptorToHash(
ohci_general_td *descriptor); ohci_general_td *descriptor);
@@ -7,8 +7,8 @@
* Salvatore Benedetto <[email protected]> * Salvatore Benedetto <[email protected]>
*/ */
#ifndef OHCI_HARD_H #ifndef OHCI_HARDWARE_H
#define OHCI_HARD_H #define OHCI_HARDWARE_H
// -------------------------------- // --------------------------------
// The OHCI registers // The OHCI registers
@@ -433,4 +433,4 @@ typedef struct ohci_isochronous_td
#define OHCI_ENABLE_POWER_DELAY 5000 #define OHCI_ENABLE_POWER_DELAY 5000
#define OHCI_READ_DESC_DELAY 5000 #define OHCI_READ_DESC_DELAY 5000
#endif // OHCI_HARD_H #endif // OHCI_HARDWARE_H
+39 -36
View File
@@ -5,23 +5,24 @@
* Authors: * Authors:
* Jan-Rixt Van Hoye * Jan-Rixt Van Hoye
* Salvatore Benedetto <[email protected]> * Salvatore Benedetto <[email protected]>
* Michael Lotz <[email protected]>
*/ */
#include "ohci.h" #include "ohci.h"
static usb_device_descriptor sOHCIRootHubDevice = static usb_device_descriptor sOHCIRootHubDevice =
{ {
0x12, // Descriptor size 18, // Descriptor length
USB_DESCRIPTOR_DEVICE, // Type of descriptor USB_DESCRIPTOR_DEVICE, // Descriptor type
0x110, // USB 1.1 0x110, // USB 1.1
0x09, // Hub type 0x09, // Class (9 = Hub)
0, // Subclass 0, // Subclass
0, // Protocol 0, // Protocol
64, // Max packet size 64, // Max packet size on endpoint 0
0, // Vendor 0, // Vendor ID
0, // Product 0, // Product ID
0x110, // Version 0x110, // Version
1, // Index of manufacture string 1, // Index of manufacturer string
2, // Index of product string 2, // Index of product string
0, // Index of serial number string 0, // Index of serial number string
1 // Number of configurations 1 // Number of configurations
@@ -41,48 +42,50 @@ static ohci_root_hub_configuration_s sOHCIRootHubConfig =
{ // configuration descriptor { // configuration descriptor
9, // Descriptor length 9, // Descriptor length
USB_DESCRIPTOR_CONFIGURATION, // Descriptor type USB_DESCRIPTOR_CONFIGURATION, // Descriptor type
34, // Total size of the configuration 34, // Total length of configuration (including
1, // Number interfaces // interface, endpoint and hub descriptors)
1, // Value of configuration 1, // Number of interfaces
0, // Number of configuration 1, // Value of this configuration
0x40, // Self powered 0, // Index of configuration string
0 // Max power (0, because of self power) 0x40, // Attributes (0x40 = self powered)
0 // Max power (0, since self powered)
}, },
{ // interface descriptor { // interface descriptor
9, // Size 9, // Descriptor length
USB_DESCRIPTOR_INTERFACE, // Type USB_DESCRIPTOR_INTERFACE, // Descriptor type
0, // Interface number 0, // Interface number
0, // Alternate setting 0, // Alternate setting
1, // Num endpoints 1, // Number of endpoints
0x09, // Interface class 0x09, // Interface class (9 = Hub)
0, // Interface subclass 0, // Interface subclass
0, // Interface protocol 0, // Interface protocol
0 // Interface 0 // Index of interface string
}, },
{ // endpoint descriptor { // endpoint descriptor
7, // Size 7, // Descriptor length
USB_DESCRIPTOR_ENDPOINT, // Type USB_DESCRIPTOR_ENDPOINT, // Descriptor type
USB_REQTYPE_DEVICE_IN | 1, // Endpoint address (first in IN endpoint) USB_REQTYPE_DEVICE_IN | 1, // Endpoint address (first in IN endpoint)
0x03, // Attributes (0x03 = interrupt endpoint) 0x03, // Attributes (0x03 = interrupt endpoint)
8, // Max packet size 8, // Max packet size
0xFF // Interval 256 0xff // Interval 256
}, },
{ // hub descriptor { // hub descriptor
9, // Lenght (including deprecated power 9, // Descriptor length (including
// control mask) // deprecated power control mask)
USB_DESCRIPTOR_HUB, // Type USB_DESCRIPTOR_HUB, // Descriptor type
0, // Number of ports 2, // Number of ports
0x0000, // Hub characteristics 0x0000, // Hub characteristics
0, // Power on to power good 0, // Power on to power good (in 2ms units)
0, // Current 0, // Maximum current (in mA)
0x00, // Both ports are removable 0x00, // Both ports are removable
0xff // Depricated power control mask 0xff // Depricated power control mask
} }
}; };
struct ohci_root_hub_string_s { struct ohci_root_hub_string_s {
uint8 length; uint8 length;
uint8 descriptor_type; uint8 descriptor_type;
@@ -126,6 +129,7 @@ OHCIRootHub::OHCIRootHub(Object *rootObject, int8 deviceAddress)
{ {
} }
status_t status_t
OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer) OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
{ {
@@ -133,8 +137,7 @@ OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
return B_ERROR; return B_ERROR;
usb_request_data *request = transfer->RequestData(); usb_request_data *request = transfer->RequestData();
TRACE(("usb_ohci_roothub: request: %d\n", request->Request));
TRACE(("usb_ohci_roothub(): request: %d\n", request->Request));
status_t status = B_TIMED_OUT; status_t status = B_TIMED_OUT;
size_t actualLength = 0; size_t actualLength = 0;
@@ -147,7 +150,6 @@ OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
// the hub reports whether the local power failed (bit 0) // the hub reports whether the local power failed (bit 0)
// and if there is a over-current condition (bit 1). // and if there is a over-current condition (bit 1).
// everything as 0 means all is ok. // everything as 0 means all is ok.
// TODO (?) actually check for the value
memset(transfer->Data(), 0, actualLength); memset(transfer->Data(), 0, actualLength);
status = B_OK; status = B_OK;
break; break;
@@ -159,6 +161,7 @@ OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
memcpy(transfer->Data(), (void *)&portStatus, actualLength); memcpy(transfer->Data(), (void *)&portStatus, actualLength);
status = B_OK; status = B_OK;
} }
break; break;
} }
@@ -168,12 +171,12 @@ OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
break; break;
} }
TRACE(("usb_ohci_roothub(): set address: %d\n", request->Value)); TRACE(("usb_ohci_roothub: set address: %d\n", request->Value));
status = B_OK; status = B_OK;
break; break;
case USB_REQUEST_GET_DESCRIPTOR: case USB_REQUEST_GET_DESCRIPTOR:
TRACE(("usb_ohci_roothub(): get descriptor: %d\n", request->Value >> 8)); TRACE(("usb_ohci_roothub: get descriptor: %d\n", request->Value >> 8));
switch (request->Value >> 8) { switch (request->Value >> 8) {
case USB_DESCRIPTOR_DEVICE: { case USB_DESCRIPTOR_DEVICE: {
@@ -227,11 +230,11 @@ OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
case USB_REQUEST_CLEAR_FEATURE: { case USB_REQUEST_CLEAR_FEATURE: {
if (request->Index == 0) { if (request->Index == 0) {
// we don't support any hub changes // we don't support any hub changes
TRACE_ERROR(("usb_ohci_roothub(): clear feature: no hub changes\n")); TRACE_ERROR(("usb_ohci_roothub: clear feature: no hub changes\n"));
break; break;
} }
TRACE(("usb_ohci_roothub(): clear feature: %d\n", request->Value)); TRACE(("usb_ohci_roothub: clear feature: %d\n", request->Value));
if (ohci->ClearPortFeature(request->Index - 1, request->Value) >= B_OK) if (ohci->ClearPortFeature(request->Index - 1, request->Value) >= B_OK)
status = B_OK; status = B_OK;
break; break;
@@ -240,11 +243,11 @@ OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
case USB_REQUEST_SET_FEATURE: { case USB_REQUEST_SET_FEATURE: {
if (request->Index == 0) { if (request->Index == 0) {
// we don't support any hub changes // we don't support any hub changes
TRACE_ERROR(("usb_ohci_roothub(): set feature: no hub changes\n")); TRACE_ERROR(("usb_ohci_roothub: set feature: no hub changes\n"));
break; break;
} }
TRACE(("usb_ohci_roothub(): set feature: %d\n", request->Value)); TRACE(("usb_ohci_roothub: set feature: %d\n", request->Value));
if (ohci->SetPortFeature(request->Index - 1, request->Value) >= B_OK) if (ohci->SetPortFeature(request->Index - 1, request->Value) >= B_OK)
status = B_OK; status = B_OK;
break; break;