1 /* 2 * Copyright (c) 2008 Travis Geiselbrecht 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8 #pragma once 9 10 #include <sys/types.h> 11 #include <lk/compiler.h> 12 13 /* GLOBAL STATUS VALUES */ 14 #define STD_COMMAND 0x00 15 #define SETUP_COMMAND_PHASE 0x40 16 #define FUNCTION_ERROR 0x7F /* Used when we are stalling the function EP0 */ 17 #define HUB_ERROR 0xFF /* Used when we are stalling the HUB EP0 */ 18 19 /* Request Types */ 20 #define DIR_OUT (0 << 7) 21 #define DIR_IN (1 << 7) 22 #define DIR_MASK (1 << 7) 23 #define TYPE_STANDARD (0 << 5) 24 #define TYPE_CLASS (1 << 5) 25 #define TYPE_VENDOR (2 << 5) 26 #define TYPE_MASK (3 << 5) 27 #define RECIP_DEVICE (0 << 0) 28 #define RECIP_INTERFACE (1 << 0) 29 #define RECIP_ENDPOINT (2 << 0) 30 #define RECIP_OTHER (3 << 0) 31 #define RECIP_MASK (0x1f << 0) 32 33 /* 1.0 Request Values */ 34 #define GET_STATUS 0x00 35 #define CLEAR_FEATURE 0x01 36 #define SET_FEATURE 0x03 37 #define SET_ADDRESS 0x05 38 #define GET_DESCRIPTOR 0x06 39 #define SET_DESCRIPTOR 0x07 40 #define GET_CONFIGURATION 0x08 41 #define SET_CONFIGURATION 0x09 42 #define GET_INTERFACE 0x0A 43 #define SET_INTERFACE 0x0B 44 #define SYNCH_FRAME 0x0C 45 46 /* Mass storage requests */ 47 #define MASS_STORAGE_GET_MAX_LUN 0xfe 48 #define MASS_STORAGE_RESET 0xff 49 50 /* DFU requests */ 51 #define DFU_DETACH 0x00 52 #define DFU_DNLOAD 0x01 53 #define DFU_UPLOAD 0x02 54 #define DFU_GETSTATUS 0x03 55 #define DFU_CLRSTATUS 0x04 56 #define DFU_GETSTATE 0x05 57 #define DFU_ABORT 0x06 58 59 /* HID Request Values */ 60 #define GET_REPORT 0x01 61 #define GET_IDLE 0x02 62 #define GET_PROTOCOL 0x03 63 #define SET_REPORT 0x09 64 #define SET_IDLE 0x0A 65 #define SET_PROTOCOL 0x0B 66 67 /* Descriptor Types */ 68 #define DEVICE 0x01 69 #define CONFIGURATION 0x02 70 #define STRING 0x03 71 #define INTERFACE 0x04 72 #define ENDPOINT 0x05 73 #define DEVICE_QUALIFIER 0x06 74 #define OTHER_SPEED_CONFIGURATION 0x07 75 #define INTERFACE_POWER 0x08 76 #define HID 0x21 77 #define HIDREPORT 0x22 78 #define HIDPHYSICAL 0x23 79 80 /* general USB defines */ 81 struct usb_setup { 82 uint8_t request_type; 83 uint8_t request; 84 uint16_t value; 85 uint16_t index; 86 uint16_t length; 87 } __PACKED; 88