2009-11-21 Samuel Thibault <samuel.thibault@ens-lyon.org>
[grub2.git] / include / grub / usbtrans.h
blob7e4a9d7ee706dfc8bb9a3f947592f946fc48b15c
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2008 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_USBTRANS_H
20 #define GRUB_USBTRANS_H 1
22 typedef enum
24 GRUB_USB_TRANSFER_TYPE_IN,
25 GRUB_USB_TRANSFER_TYPE_OUT,
26 GRUB_USB_TRANSFER_TYPE_SETUP
27 } grub_transfer_type_t;
29 typedef enum
31 GRUB_USB_TRANSACTION_TYPE_CONTROL,
32 GRUB_USB_TRANSACTION_TYPE_BULK
33 } grub_transaction_type_t;
35 struct grub_usb_transaction
37 int size;
38 int toggle;
39 grub_transfer_type_t pid;
40 char *data;
42 typedef struct grub_usb_transaction *grub_usb_transaction_t;
44 struct grub_usb_transfer
46 int devaddr;
48 int endpoint;
50 int size;
52 int transcnt;
54 int max;
56 grub_transaction_type_t type;
58 struct grub_usb_device *dev;
60 struct grub_usb_transaction *transactions;
62 typedef struct grub_usb_transfer *grub_usb_transfer_t;
65 #define GRUB_USB_REQTYPE_IN (1 << 7)
66 #define GRUB_USB_REQTYPE_OUT (0 << 7)
67 #define GRUB_USB_REQTYPE_STANDARD (0 << 5)
68 #define GRUB_USB_REQTYPE_CLASS (1 << 5)
69 #define GRUB_USB_REQTYPE_VENDOR (2 << 5)
70 #define GRUB_USB_REQTYPE_TARGET_DEV (0 << 0)
71 #define GRUB_USB_REQTYPE_TARGET_INTERF (1 << 0)
72 #define GRUB_USB_REQTYPE_TARGET_ENDP (2 << 0)
73 #define GRUB_USB_REQTYPE_TARGET_OTHER (3 << 0)
75 #define GRUB_USB_REQ_GET_STATUS 0x00
76 #define GRUB_USB_REQ_CLEAR_FEATURE 0x01
77 #define GRUB_USB_REQ_SET_FEATURE 0x03
78 #define GRUB_USB_REQ_SET_ADDRESS 0x05
79 #define GRUB_USB_REQ_GET_DESCRIPTOR 0x06
80 #define GRUB_USB_REQ_SET_DESCRIPTOR 0x07
81 #define GRUB_USB_REQ_GET_CONFIGURATION 0x08
82 #define GRUB_USB_REQ_SET_CONFIGURATION 0x09
83 #define GRUB_USB_REQ_GET_INTERFACE 0x0A
84 #define GRUB_USB_REQ_SET_INTERFACE 0x0B
85 #define GRUB_USB_REQ_SYNC_FRAME 0x0C
87 #define GRUB_USB_REQ_HUB_GET_PORT_STATUS 0x00
89 #define GRUB_USB_FEATURE_ENDP_HALT 0x01
90 #define GRUB_USB_FEATURE_DEV_REMOTE_WU 0x02
91 #define GRUB_USB_FEATURE_TEST_MODE 0x04
93 #define GRUB_USB_HUB_STATUS_CONNECTED (1 << 0)
94 #define GRUB_USB_HUB_STATUS_LOWSPEED (1 << 9)
95 #define GRUB_USB_HUB_STATUS_HIGHSPEED (1 << 10)
97 struct grub_usb_packet_setup
99 grub_uint8_t reqtype;
100 grub_uint8_t request;
101 grub_uint16_t value;
102 grub_uint16_t index;
103 grub_uint16_t length;
104 } __attribute__((packed));
107 #endif /* GRUB_USBTRANS_H */