usbtrans.h revision 2
2521N/A/*
2521N/A * GRUB -- GRand Unified Bootloader
2521N/A * Copyright (C) 2008 Free Software Foundation, Inc.
2521N/A *
2521N/A * GRUB is free software: you can redistribute it and/or modify
2521N/A * it under the terms of the GNU General Public License as published by
2521N/A * the Free Software Foundation, either version 3 of the License, or
2521N/A * (at your option) any later version.
2521N/A *
2521N/A * GRUB is distributed in the hope that it will be useful,
2521N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2521N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2521N/A * GNU General Public License for more details.
2521N/A *
2521N/A * You should have received a copy of the GNU General Public License
2521N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2521N/A */
2521N/A
2521N/A#ifndef GRUB_USBTRANS_H
2521N/A#define GRUB_USBTRANS_H 1
2521N/A
2521N/Atypedef enum
5403N/A {
2521N/A GRUB_USB_TRANSFER_TYPE_IN,
3998N/A GRUB_USB_TRANSFER_TYPE_OUT,
2521N/A GRUB_USB_TRANSFER_TYPE_SETUP
3998N/A } grub_transfer_type_t;
3998N/A
2521N/Atypedef enum
5403N/A {
5403N/A GRUB_USB_TRANSACTION_TYPE_CONTROL,
5403N/A GRUB_USB_TRANSACTION_TYPE_BULK
2521N/A } grub_transaction_type_t;
2521N/A
2521N/Astruct grub_usb_transaction
5403N/A{
2521N/A int size;
3533N/A int toggle;
2521N/A grub_transfer_type_t pid;
3998N/A grub_uint32_t data;
3998N/A grub_size_t preceding;
3998N/A};
5403N/Atypedef struct grub_usb_transaction *grub_usb_transaction_t;
3998N/A
5403N/Astruct grub_usb_transfer
5403N/A{
3998N/A int devaddr;
3998N/A
3998N/A int endpoint;
5403N/A
3998N/A int size;
3998N/A
3998N/A int transcnt;
3998N/A
3998N/A int max;
3998N/A
3998N/A grub_transaction_type_t type;
5403N/A
3998N/A grub_transfer_type_t dir;
5403N/A
3998N/A struct grub_usb_device *dev;
5403N/A
5403N/A struct grub_usb_transaction *transactions;
5403N/A
3998N/A int last_trans;
3998N/A /* Index of last processed transaction in OHCI/UHCI driver. */
3998N/A
3998N/A void *controller_data;
3998N/A
3998N/A /* Used when finishing transfer to copy data back. */
4194N/A struct grub_pci_dma_chunk *data_chunk;
3998N/A void *data;
3998N/A};
3998N/Atypedef struct grub_usb_transfer *grub_usb_transfer_t;
3998N/A
3998N/A
3998N/A
5860N/Aenum
5860N/A {
4194N/A GRUB_USB_REQTYPE_TARGET_DEV = (0 << 0),
3998N/A GRUB_USB_REQTYPE_TARGET_INTERF = (1 << 0),
3998N/A GRUB_USB_REQTYPE_TARGET_ENDP = (2 << 0),
3998N/A GRUB_USB_REQTYPE_TARGET_OTHER = (3 << 0),
3998N/A GRUB_USB_REQTYPE_STANDARD = (0 << 5),
3998N/A GRUB_USB_REQTYPE_CLASS = (1 << 5),
5860N/A GRUB_USB_REQTYPE_VENDOR = (2 << 5),
5860N/A GRUB_USB_REQTYPE_OUT = (0 << 7),
4194N/A GRUB_USB_REQTYPE_IN = (1 << 7),
3998N/A GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT = GRUB_USB_REQTYPE_TARGET_INTERF
3998N/A | GRUB_USB_REQTYPE_CLASS | GRUB_USB_REQTYPE_OUT,
3998N/A GRUB_USB_REQTYPE_VENDOR_OUT = GRUB_USB_REQTYPE_VENDOR | GRUB_USB_REQTYPE_OUT,
5860N/A GRUB_USB_REQTYPE_CLASS_INTERFACE_IN = GRUB_USB_REQTYPE_TARGET_INTERF
3998N/A | GRUB_USB_REQTYPE_CLASS | GRUB_USB_REQTYPE_IN,
3998N/A GRUB_USB_REQTYPE_VENDOR_IN = GRUB_USB_REQTYPE_VENDOR | GRUB_USB_REQTYPE_IN
5860N/A };
5860N/A
4194N/Aenum
3998N/A {
3998N/A GRUB_USB_REQ_GET_STATUS = 0x00,
3998N/A GRUB_USB_REQ_CLEAR_FEATURE = 0x01,
5860N/A GRUB_USB_REQ_SET_FEATURE = 0x03,
3998N/A GRUB_USB_REQ_SET_ADDRESS = 0x05,
3998N/A GRUB_USB_REQ_GET_DESCRIPTOR = 0x06,
5860N/A GRUB_USB_REQ_SET_DESCRIPTOR = 0x07,
5860N/A GRUB_USB_REQ_GET_CONFIGURATION = 0x08,
4194N/A GRUB_USB_REQ_SET_CONFIGURATION = 0x09,
3998N/A GRUB_USB_REQ_GET_INTERFACE = 0x0A,
3998N/A GRUB_USB_REQ_SET_INTERFACE = 0x0B,
3998N/A GRUB_USB_REQ_SYNC_FRAME = 0x0C
5860N/A };
2521N/A
3998N/A#define GRUB_USB_FEATURE_ENDP_HALT 0x00
5860N/A#define GRUB_USB_FEATURE_DEV_REMOTE_WU 0x01
5860N/A#define GRUB_USB_FEATURE_TEST_MODE 0x02
4194N/A
3998N/Aenum
3998N/A {
3998N/A GRUB_USB_HUB_FEATURE_PORT_RESET = 0x04,
5860N/A GRUB_USB_HUB_FEATURE_PORT_POWER = 0x08,
3998N/A GRUB_USB_HUB_FEATURE_C_PORT_CONNECTED = 0x10,
3998N/A GRUB_USB_HUB_FEATURE_C_PORT_ENABLED = 0x11,
5860N/A GRUB_USB_HUB_FEATURE_C_PORT_SUSPEND = 0x12,
5860N/A GRUB_USB_HUB_FEATURE_C_PORT_OVERCURRENT = 0x13,
4194N/A GRUB_USB_HUB_FEATURE_C_PORT_RESET = 0x14
3998N/A };
5403N/A
3998N/Aenum
5860N/A {
3998N/A GRUB_USB_HUB_STATUS_PORT_CONNECTED = (1 << 0),
3998N/A GRUB_USB_HUB_STATUS_PORT_ENABLED = (1 << 1),
5860N/A GRUB_USB_HUB_STATUS_PORT_SUSPEND = (1 << 2),
5860N/A GRUB_USB_HUB_STATUS_PORT_OVERCURRENT = (1 << 3),
4194N/A GRUB_USB_HUB_STATUS_PORT_POWERED = (1 << 8),
3998N/A GRUB_USB_HUB_STATUS_PORT_LOWSPEED = (1 << 9),
3998N/A GRUB_USB_HUB_STATUS_PORT_HIGHSPEED = (1 << 10),
3998N/A GRUB_USB_HUB_STATUS_C_PORT_CONNECTED = (1 << 16),
5860N/A GRUB_USB_HUB_STATUS_C_PORT_ENABLED = (1 << 17),
3998N/A GRUB_USB_HUB_STATUS_C_PORT_SUSPEND = (1 << 18),
3998N/A GRUB_USB_HUB_STATUS_C_PORT_OVERCURRENT = (1 << 19),
5860N/A GRUB_USB_HUB_STATUS_C_PORT_RESET = (1 << 20)
5860N/A };
4194N/A
3998N/Astruct grub_usb_packet_setup
3998N/A{
3998N/A grub_uint8_t reqtype;
5860N/A grub_uint8_t request;
3998N/A grub_uint16_t value;
3998N/A grub_uint16_t index;
5860N/A grub_uint16_t length;
5860N/A} __attribute__((packed));
4194N/A
3998N/A
3998N/A#endif /* GRUB_USBTRANS_H */
3998N/A