1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2005, Jan-Rixt Van Hoye 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 //------------------------------------------------------------------------------- 22 23 24 #ifndef OHCI_H 25 #define OHCI_H 26 27 // --------------------------- 28 // OHCI:: Includes 29 // --------------------------- 30 31 #include <usb_p.h> 32 #include "ohci_software.h" 33 34 struct pci_info; 35 struct pci_module_info; 36 class OHCIRootHub; 37 38 // -------------------------------- 39 // OHCI: The OHCI class derived 40 // from the BusManager 41 // -------------------------------- 42 43 class OHCI : public BusManager 44 { 45 friend class OHCIRootHub; 46 public: 47 48 OHCI( pci_info *info , Stack *stack ); 49 status_t SubmitTransfer( Transfer *t ); //Override from BusManager. 50 static pci_module_info *pci_module; // Global data for the module. 51 52 private: 53 // Global 54 pci_info *m_pcii; // pci-info struct 55 Stack *m_stack; // Pointer to the stack 56 addr_t m_opreg_base; // Base address of the operational registers 57 uint32 m_revision; // The revision of the host controller 58 char *m_product_descr; // The product description (can be moved to the Busmanager Class) 59 // HCCA 60 area_id m_hcca_area; 61 struct hc_hcca *hcca; // The HCCA structure for the interupt communication 62 addr_t m_hcca_base; // Base address of the HCCA 63 hcd_soft_endpoint *sc_eds[OHCI_NO_EDS]; // number of interupt endpiont descriptors 64 // Registers 65 struct hcd_soft_endpoint *ed_bulk_tail; // last in the bulk list 66 struct hcd_soft_endpoint *ed_control_tail; // last in the control list 67 struct hcd_soft_endpoint *ed_isoch_tail; // lest in the isochrnonous list 68 struct hcd_soft_endpoint *ed_periodic[32]; // shadow of the interupt table 69 // free list structures 70 struct hcd_soft_endpoint *sc_freeeds; // list of free endpoint descriptors 71 struct hcd_soft_transfer *sc_freetds; // list of free general transfer descriptors 72 struct hcd_soft_itransfer *sc_freeitds; // list of free isonchronous transfer descriptors 73 // Done queue 74 struct hcd_soft_transfer *sc_sdone; // list of done general transfer descriptors 75 struct hcd_soft_itransfer *sc_sidone; // list of done isonchronous transefer descriptors 76 // memory management for queue data structures. 77 struct hcd_soft_transfer sc_hash_tds[OHCI_HASH_SIZE]; 78 struct hcd_soft_itransfer sc_hash_itds[OHCI_HASH_SIZE]; 79 // Root Hub 80 OHCIRootHub *m_roothub; // the root hub 81 addr_t m_roothub_base; // Base address of the root hub 82 // functions 83 hcd_soft_endpoint *ohci_alloc_soft_endpoint(); // allocate memory for an endpoint 84 }; 85 86 // -------------------------------- 87 // OHCI: The root hub of the OHCI 88 // controller derived from 89 // the Hub class 90 // -------------------------------- 91 92 class OHCIRootHub : public Hub 93 { 94 public: 95 OHCIRootHub( OHCI *ohci , int8 devicenum ); 96 status_t SubmitTransfer( Transfer *t ); 97 void UpdatePortStatus(); 98 private: 99 usb_port_status m_hw_port_status[2]; // the port status (maximum of two) 100 OHCI *m_ohci; // needed because of internal data 101 }; 102 103 #define OHCI_DEBUG 104 #ifdef OHCI_DEBUG 105 #define TRACE dprintf 106 #else 107 #define TRACE silent 108 void silent( const char * , ... ) {} 109 #endif 110 111 #endif // OHCI_H 112