1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2004, Niels S. Reedijk 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 #ifndef UHCI_H 23 #define UHCI_H 24 25 #include "usb_p.h" 26 #include "uhci_hardware.h" 27 28 struct pci_info; 29 struct pci_module_info; 30 class UHCIRootHub; 31 32 class UHCI : public BusManager 33 { 34 friend class UHCIRootHub; 35 friend int32 uhci_interrupt_handler( void *data ); 36 public: 37 UHCI( pci_info *info , Stack *stack ); 38 39 //Override from BusManager 40 status_t Start(); 41 status_t SubmitTransfer( Transfer *t ); 42 43 // Global data for the module. 44 static pci_module_info *pci_module; 45 private: 46 //Utility functions 47 void GlobalReset(); 48 status_t Reset(); 49 int32 Interrupt(); 50 51 //Functions for the actual functioning of transfers 52 status_t InsertControl( Transfer *t ); 53 54 uint32 m_reg_base; //Base address of the registers 55 pci_info *m_pcii; //pci-info struct 56 Stack *m_stack; //Pointer to the stack 57 58 //Frame list memory 59 area_id m_framearea; 60 addr_t m_framelist[1024]; //The frame list struct 61 addr_t m_framelist_phy; //The physical pointer to the frame list 62 63 // Virtual frame 64 uhci_qh *m_qh_virtual[12]; // 65 #define m_qh_interrupt_256 m_qh_virtual[0] 66 #define m_qh_interrupt_128 m_qh_virtual[1] 67 #define m_qh_interrupt_64 m_qh_virtual[2] 68 #define m_qh_interrupt_32 m_qh_virtual[3] 69 #define m_qh_interrupt_16 m_qh_virtual[4] 70 #define m_qh_interrupt_8 m_qh_virtual[5] 71 #define m_qh_interrupt_4 m_qh_virtual[6] 72 #define m_qh_interrupt_2 m_qh_virtual[7] 73 #define m_qh_interrupt_1 m_qh_virtual[8] 74 #define m_qh_control m_qh_virtual[9] 75 #define m_qh_bulk m_qh_virtual[10] 76 #define m_qh_terminate m_qh_virtual[11] 77 78 //Maintain a list of transfers 79 Vector<Transfer *> m_transfers; 80 81 //Root hub: 82 UHCIRootHub *m_rh; // the root hub 83 uint8 m_rh_address; // the address of the root hub 84 }; 85 86 class UHCIRootHub : public Hub 87 { 88 public: 89 UHCIRootHub( UHCI *uhci , int8 devicenum ); 90 status_t SubmitTransfer( Transfer *t ); 91 void UpdatePortStatus(); 92 private: 93 usb_port_status m_hw_port_status[2]; // the port status (maximum of two) 94 UHCI *m_uhci; // needed because of internal data 95 }; 96 97 struct hostcontroller_priv 98 { 99 uhci_qh *topqh; 100 uhci_td *firsttd; 101 uhci_td *lasttd; 102 }; 103 104 #define UHCI_DEBUG 105 #ifdef UHCI_DEBUG 106 #define TRACE dprintf 107 #else 108 #define TRACE silent 109 void silent( const char * , ... ) {} 110 #endif 111 112 #endif 113