1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2003, 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 /************************************************************ 26 * The Registers * 27 ************************************************************/ 28 29 30 // R/W -- Read/Write 31 // R/WC -- Read/Write Clear 32 // ** -- Only writable with words! 33 34 35 // Registers 36 #define UHCI_USBCMD 0x0 // USB Command - word - R/W 37 #define UHCI_USBSTS 0x2 // USB Status - word - R/WC 38 #define UHCI_USBINTR 0x4 // USB Interrupt Enable - word - R/W 39 #define UHCI_FRNUM 0x6 // Frame number - word - R/W** 40 #define UHCI_FRBASEADD 0x08 // Frame List BAse Address - dword - R/W 41 #define UHCI_SOFMOD 0xC // Start of Frame Modify - byte - R/W 42 #define UHCI_PORTSC1 0x10 // Port 1 Status/Control - word - R/WC** 43 #define UHCI_PORTSC2 0x12 // Port 2 Status/Control - word - R/WC** 44 45 // USBCMD 46 #define UHCI_USBCMD_RS 0x1 // Run/Stop 47 #define UHCI_USBCMD_HCRESET 0x2 // Host Controller Reset 48 #define UHCI_USBCMD_GRESET 0x4 // Global Reset 49 #define UHCI_USBCMD_EGSM 0x8 // Enter Global Suspensd mode 50 #define UHCI_USBCMD_FGR 0x10 // Force Global resume 51 #define UHCI_USBCMD_SWDBG 0x20 // Software Debug 52 #define UHCI_USBCMD_CF 0x40 // Configure Flag 53 54 //USBSTS 55 #define UHCI_USBSTS_USBINT 0x1 // USB interrupt 56 #define UHCI_USBSTS_ERRINT 0x2 // USB error interrupt 57 #define UHCI_USBSTS_RESDET 0x4 // Resume Detect 58 #define UHCI_USBSTS_HOSTERR 0x8 // Host System Error 59 #define UHCI_USBSTS_HCPRERR 0x10// Host Controller Process error 60 #define UHCI_USBSTS_HCHALT 0x20 // HCHalted 61 62 //USBINTR 63 #define UHCI_USBINTR_CRC 0x1 // Timeout/ CRC interrupt enable 64 #define UHCI_USBINTR_RESUME 0x2 // Resume interrupt enable 65 #define UHCI_USBINTR_IOC 0x4 // Interrupt on complete enable 66 #define UHCI_USBINTR_SHORT 0x8 // Short packet interrupt enable 67 68 //PORTSC 69 #define UHCI_PORTSC_CURSTAT 0x1 // Current connect status 70 #define UHCI_PORTSC_STATCHA 0x2 // Current connect status change 71 #define UHCI_PORTSC_ENABLED 0x4 // Port enabled/disabled 72 73 /************************************************************ 74 * Hardware structs * 75 ************************************************************/ 76 77 //Represents a Transfer Descriptor (TD) 78 79 struct uhci_td 80 { 81 void * link; // Link to the next TD/QH 82 uint32 status; // Status field 83 uint32 token; // Contains the packet header (where it needs to be sent) 84 void * buffer; // A pointer to the buffer with the actual packet 85 }; 86 87 //Represents a Queue Head (QH) 88 89 struct uhci_qh 90 { 91 void * link; //Link to the next TD/QH 92 void * element; //Link to the first element pointer in the queue 93 }; 94 95 /************************************************************ 96 * Roothub Emulation * 97 ************************************************************/ 98 #define RH_GET_DESCRIPTOR 6 99 #define RH_SET_ADDRESS 5 100 #define RH_SET_CONFIG 9 101 102 //Descriptors (in usb_request_data->Value) 103 #define RH_DEVICE_DESCRIPTOR ( 1 << 8 ) 104 #define RH_CONFIG_DESCRIPTOR ( 2 << 8 ) 105 106 #endif 107