net: tcp_client_socket connection state routines
[quarnos.git] / resources / uhci.h
blob1b169a45e4162f7aa35a19491c5328ee4bfee4eb
1 /* Quarn OS
3 * UHCI driver
5 * Copyright (C) 2009 Pawel Dziepak
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef _UHCI_H_
24 #define _UHCI_H_
26 #include "device.h"
27 #include "arch/low/general.h"
28 #include "pci.h"
30 namespace resources {
31 class uhci : public device /*usb_hc*/ {
32 public:
33 enum {
34 hc_stop = 0,
35 hc_run = 1,
36 hc_reset = 2,
37 hc_greset = 4,
38 hc_egsm = 8,
39 hc_fgr = 0x10,
40 hc_swdgb = 0x20,
41 hc_cf = 0x40,
42 hc_maxp = 0x80
45 enum uhci_registers {
46 uhci_command,
47 uhci_status = 2,
48 uhci_flbaseadd = 8,
49 uhci_portsc1 = 0x10
52 /* TD, QH, frame */
54 struct transfer_descriptor {
55 u32 link_ptr;
56 volatile u32 control;
57 u32 token;
58 u32 buffer;
61 struct queue_head {
62 u32 head_ptr;
63 volatile u32 element_ptr;
66 typedef u32 frame_pointer;
68 /* Transfers */
70 struct usb_setup_data {
71 u8 bmRequestType;
72 u8 bRequest;
73 u16 wValue;
74 u16 wIndex;
75 u16 wLength;
78 enum usb_pid {
79 pid_setup = 0x2d,
80 pid_in = 0x69,
81 pid_out = 0xe1
84 /* Got info */
85 struct device_descriptor {
86 u8 bLength;
87 u8 bDescriptorType;
88 u16 bcdUSB;
89 u8 bDeviceClass;
90 u8 bDeviceSubClass;
91 u8 bDeviceProtocol;
92 u8 bMaxPacketSize0;
93 u16 idVendor;
94 u16 idProduct;
95 u16 bcdDevice;
96 u8 iManufacturer;
97 u8 iProduct;
98 u8 iSerialNumber;
99 u8 bNumConfigurations;
100 } __attribute__((packed));
102 struct configuration_descriptor {
103 u8 bLength;
104 u8 bDescriptorType;
105 u16 wTotalLength;
106 u8 bNumInterfaces;
107 u8 bConfigurationValue;
108 u8 iConfiguration;
109 u8 bmAttrubutes;
110 u8 bMaxPower;
111 } __attribute__((packed));
113 struct interface_descriptor {
114 u8 bLength;
115 u8 bDescriptorType;
116 u8 bInterfaceNumber;
117 u8 bAlternateSetting;
118 u8 bNumEndpoints;
119 u8 bInterfaceClass;
120 u8 bInterfaceSubClass;
121 u8 bInterfaceProtocol;
122 u8 iInterface;
123 } __attribute__((packed));
125 void irq();
127 transfer_descriptor *td;
128 frame_pointer *fp;
129 int last_fp;
130 queue_head *qh;
132 protected:
133 pci_did pciid;
135 void init_structures();
136 int get_free_address();
137 void *control_transfer(usb_pid pid, void *val, int length, int rlength, u8 address);
138 void init();
139 void device_connected(int port);
141 public:
142 uhci() : td(0), fp(0), last_fp(0) {}
144 //virtual void init_port(int i) = 0;
146 //virtual array<char> control_transfer(usb_pid, array<char>, int, int) = 0;
148 bool init_device(p<did>);
150 static bool check_device(p<did>);
151 static void register_type();
155 #endif