usbtrans.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2008 Free Software Foundation, Inc.
  4. *
  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.
  9. *
  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.
  14. *
  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/>.
  17. */
  18. #ifndef GRUB_USBTRANS_H
  19. #define GRUB_USBTRANS_H 1
  20. typedef enum
  21. {
  22. GRUB_USB_TRANSFER_TYPE_IN,
  23. GRUB_USB_TRANSFER_TYPE_OUT,
  24. GRUB_USB_TRANSFER_TYPE_SETUP
  25. } grub_transfer_type_t;
  26. typedef enum
  27. {
  28. GRUB_USB_TRANSACTION_TYPE_CONTROL,
  29. GRUB_USB_TRANSACTION_TYPE_BULK
  30. } grub_transaction_type_t;
  31. struct grub_usb_transaction
  32. {
  33. int size;
  34. int toggle;
  35. grub_transfer_type_t pid;
  36. char *data;
  37. };
  38. typedef struct grub_usb_transaction *grub_usb_transaction_t;
  39. struct grub_usb_transfer
  40. {
  41. int devaddr;
  42. int endpoint;
  43. int size;
  44. int transcnt;
  45. int max;
  46. grub_transaction_type_t type;
  47. struct grub_usb_device *dev;
  48. struct grub_usb_transaction *transactions;
  49. };
  50. typedef struct grub_usb_transfer *grub_usb_transfer_t;
  51. #define GRUB_USB_REQTYPE_IN (1 << 7)
  52. #define GRUB_USB_REQTYPE_OUT (0 << 7)
  53. #define GRUB_USB_REQTYPE_STANDARD (0 << 5)
  54. #define GRUB_USB_REQTYPE_CLASS (1 << 5)
  55. #define GRUB_USB_REQTYPE_VENDOR (2 << 5)
  56. #define GRUB_USB_REQTYPE_TARGET_DEV (0 << 0)
  57. #define GRUB_USB_REQTYPE_TARGET_INTERF (1 << 0)
  58. #define GRUB_USB_REQTYPE_TARGET_ENDP (2 << 0)
  59. #define GRUB_USB_REQTYPE_TARGET_OTHER (3 << 0)
  60. #define GRUB_USB_REQ_GET_STATUS 0x00
  61. #define GRUB_USB_REQ_CLEAR_FEATURE 0x01
  62. #define GRUB_USB_REQ_SET_FEATURE 0x03
  63. #define GRUB_USB_REQ_SET_ADDRESS 0x05
  64. #define GRUB_USB_REQ_GET_DESCRIPTOR 0x06
  65. #define GRUB_USB_REQ_SET_DESCRIPTOR 0x07
  66. #define GRUB_USB_REQ_GET_CONFIGURATION 0x08
  67. #define GRUB_USB_REQ_SET_CONFIGURATION 0x09
  68. #define GRUB_USB_REQ_GET_INTERFACE 0x0A
  69. #define GRUB_USB_REQ_SET_INTERFACE 0x0B
  70. #define GRUB_USB_REQ_SYNC_FRAME 0x0C
  71. #define GRUB_USB_REQ_HUB_GET_PORT_STATUS 0x00
  72. #define GRUB_USB_FEATURE_ENDP_HALT 0x01
  73. #define GRUB_USB_FEATURE_DEV_REMOTE_WU 0x02
  74. #define GRUB_USB_FEATURE_TEST_MODE 0x04
  75. #define GRUB_USB_HUB_STATUS_CONNECTED (1 << 0)
  76. #define GRUB_USB_HUB_STATUS_LOWSPEED (1 << 9)
  77. #define GRUB_USB_HUB_STATUS_HIGHSPEED (1 << 10)
  78. struct grub_usb_packet_setup
  79. {
  80. grub_uint8_t reqtype;
  81. grub_uint8_t request;
  82. grub_uint16_t value;
  83. grub_uint16_t index;
  84. grub_uint16_t length;
  85. } __attribute__((packed));
  86. #endif /* GRUB_USBTRANS_H */