xref: /haiku/src/add-ons/kernel/busses/usb/uhci.h (revision 39241fe22890fb958b6ba32d6ab9526da98be187)
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 public:
36 	UHCI( pci_info *info , Stack *stack );
37 
38 	//Override from BusManager
39 	status_t SubmitTransfer( Transfer &t );
40 
41 	// Global data for the module.
42 	static pci_module_info *pci_module;
43 private:
44 	//Utility functions
45 	void GlobalReset();
46 	status_t Reset();
47 
48 	uint32		m_reg_base;		//Base address of the registers
49 	pci_info 	*m_pcii;		//pci-info struct
50 	Stack 		*m_stack;		//Pointer to the stack
51 
52 	//Frame list memory
53 	area_id		m_framearea;
54 	addr_t 		*m_framelist[1024];	//The frame list struct
55 	addr_t		m_framelist_phy;	//The physical pointer to the frame list
56 
57 	// Virtual frame
58 	uhci_qh 	*m_qh_virtual[12];	 //
59 #define m_qh_interrupt_256 m_qh_virtual[0]
60 #define m_qh_interrupt_128 m_qh_virtual[1]
61 #define m_qh_interrupt_64  m_qh_virtual[2]
62 #define m_qh_interrupt_32  m_qh_virtual[3]
63 #define m_qh_interrupt_16  m_qh_virtual[4]
64 #define m_qh_interrupt_8   m_qh_virtual[5]
65 #define m_qh_interrupt_4   m_qh_virtual[6]
66 #define m_qh_interrupt_2   m_qh_virtual[7]
67 #define m_qh_interrupt_1   m_qh_virtual[8]
68 #define m_qh_control       m_qh_virtual[9]
69 #define m_qh_bulk          m_qh_virtual[10]
70 #define m_qh_terminate     m_qh_virtual[11]
71 
72 	//Root hub:
73 	UHCIRootHub *m_rh;				// the root hub
74 	uint8		m_rh_address;		// the address of the root hub
75 };
76 
77 class UHCIRootHub : public Hub
78 {
79 public:
80 	UHCIRootHub( UHCI *uhci , int8 devicenum );
81 	status_t SubmitTransfer( Transfer &t );
82 	void UpdatePortStatus();
83 private:
84 	usb_port_status m_hw_port_status[2]; // the port status (maximum of two)
85 	UHCI *m_uhci;					// needed because of internal data
86 };
87 
88 #define UHCI_DEBUG
89 #ifdef UHCI_DEBUG
90 #define TRACE dprintf
91 #else
92 #define TRACE silent
93 void silent( const char * , ... ) {}
94 #endif
95 
96 #endif
97