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