]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMass.h
1. Fixed tools_def.template to meet ICC build for IA32
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMassStorageDxe / UsbMass.h
1 /** @file
2
3 Copyright (c) 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 UsbMass.h
15
16 Abstract:
17
18 Defination for the USB mass storage class driver. The USB mass storage
19 class is specified in two layers: the bottom layer is the transportation
20 protocol. The top layer is the command set. The transportation layer
21 provides the transportation of the command, data and result. The command
22 set defines what the command, data and result. The Bulk-Only-Transport and
23 Control/Bulk/Interrupt transport are two transportation protocol. USB mass
24 storage class adopts various industrial standard as its command set.
25
26 Revision History
27
28
29 **/
30
31 #ifndef _EFI_USBMASS_H_
32 #define _EFI_USBMASS_H_
33
34 //
35 // The package level header files this module uses
36 //
37 #include <PiDxe.h>
38 //
39 // The protocols, PPI and GUID defintions for this module
40 //
41 #include <Protocol/BlockIo.h>
42 #include <Protocol/UsbIo.h>
43 //
44 // The Library classes this module consumes
45 //
46 #include <Library/DebugLib.h>
47 #include <Library/BaseMemoryLib.h>
48 #include <Library/UefiDriverEntryPoint.h>
49 #include <Library/UefiBootServicesTableLib.h>
50 #include <Library/UefiLib.h>
51 #include <Library/MemoryAllocationLib.h>
52
53 #define USB_IS_IN_ENDPOINT(EndPointAddr) (((EndPointAddr) & 0x80) == 0x80)
54 #define USB_IS_OUT_ENDPOINT(EndPointAddr) (((EndPointAddr) & 0x80) == 0)
55 #define USB_IS_BULK_ENDPOINT(Attribute) (((Attribute) & 0x03) == 0x02)
56 #define USB_IS_INTERRUPT_ENDPOINT(Attribute) (((Attribute) & 0x03) == 0x03)
57 #define USB_IS_ERROR(Result, Error) (((Result) & (Error)) != 0)
58
59 enum {
60 //
61 // Usb mass storage class code
62 //
63 USB_MASS_STORE_CLASS = 0x08,
64
65 //
66 // Usb mass storage subclass code, specify the command set used.
67 //
68 USB_MASS_STORE_RBC = 0x01, // Reduced Block Commands
69 USB_MASS_STORE_8020I = 0x02, // SFF-8020i, typically a CD/DVD device
70 USB_MASS_STORE_QIC = 0x03, // Typically a tape device
71 USB_MASS_STORE_UFI = 0x04, // Typically a floopy disk driver device
72 USB_MASS_STORE_8070I = 0x05, // SFF-8070i, typically a floppy disk driver device.
73 USB_MASS_STORE_SCSI = 0x06, // SCSI transparent command set
74
75 //
76 // Usb mass storage protocol code, specify the transport protocol
77 //
78 USB_MASS_STORE_CBI0 = 0x00, // CBI protocol with command completion interrupt
79 USB_MASS_STORE_CBI1 = 0x01, // CBI protocol without command completion interrupt
80 USB_MASS_STORE_BOT = 0x50, // Bulk-Only Transport
81
82 USB_MASS_STALL_1_MS = 1000,
83 USB_MASS_STALL_1_S = 1000 * USB_MASS_STALL_1_MS,
84
85 USB_MASS_CMD_SUCCESS = 0,
86 USB_MASS_CMD_FAIL,
87 USB_MASS_CMD_PERSISTENT
88 };
89
90 typedef
91 EFI_STATUS
92 (*USB_MASS_INIT_TRANSPORT) (
93 IN EFI_USB_IO_PROTOCOL *Usb,
94 IN EFI_HANDLE Controller,
95 OUT VOID **Context OPTIONAL
96 );
97
98 typedef
99 EFI_STATUS
100 (*USB_MASS_EXEC_COMMAND) (
101 IN VOID *Context,
102 IN VOID *Cmd,
103 IN UINT8 CmdLen,
104 IN EFI_USB_DATA_DIRECTION DataDir,
105 IN VOID *Data,
106 IN UINT32 DataLen,
107 IN UINT32 Timeout,
108 OUT UINT32 *CmdStatus
109 );
110
111 typedef
112 EFI_STATUS
113 (*USB_MASS_RESET) (
114 IN VOID *Context,
115 IN BOOLEAN ExtendedVerification
116 );
117
118 typedef
119 EFI_STATUS
120 (*USB_MASS_FINI) (
121 IN VOID *Context
122 );
123
124 //
125 // This structure contains information necessary to select the
126 // proper transport protocol. The mass storage class defines
127 // two transport protocols. One is the CBI, and the other is BOT.
128 // CBI is being obseleted. The design is made modular by this
129 // structure so that the CBI protocol can be easily removed when
130 // it is no longer necessary.
131 //
132 typedef struct {
133 UINT8 Protocol;
134 USB_MASS_INIT_TRANSPORT Init; // Initialize the mass storage transport protocol
135 USB_MASS_EXEC_COMMAND ExecCommand; // Transport command to the device then get result
136 USB_MASS_RESET Reset; // Reset the device
137 USB_MASS_FINI Fini; // Clean up the resources.
138 } USB_MASS_TRANSPORT;
139
140
141 EFI_STATUS
142 UsbClearEndpointStall (
143 IN EFI_USB_IO_PROTOCOL *UsbIo,
144 IN UINT8 EndpointAddress
145 );
146
147 extern UINTN mUsbMscInfo;
148 extern UINTN mUsbMscError;
149 #endif