summaryrefslogtreecommitdiff
path: root/Core/EM/CSM/thunk/BlockIo/CsmBlockIo.h
blob: 59ce30b73aecdfb49b01affa51ce4fd2a11406b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**           5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093      **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************

//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/CSM/Generic/Thunk/INT13/CsmBlockIo.h 10    12/23/11 2:12p Olegi $
//
// $Revision: 10 $
//
// $Date: 12/23/11 2:12p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/CSM/Generic/Thunk/INT13/CsmBlockIo.h $
// 
// 10    12/23/11 2:12p Olegi
// [TAG]  		EIP78921
// [Category]  	Improvement
// [Description]  	CsmBlockIo should create device handle in BBS table
// [Files]  		CsmBlockIo.c
// CsmBlockIo.h
// 
// 9     6/27/11 4:50p Olegi
// 
// 8     1/12/10 11:50a Olegi
// Copyright message updated.
// 
// 7     9/23/09 11:18a Olegi
// 
// 6     8/07/09 2:46p Rameshr
// SD boot support Added.
// 
// 5     10/03/07 4:42p Yakovlevs
// Removed Component Name Protocol and its Strings in NO DEBUG mode to
// save some space. 
// 
// 4     4/27/07 5:14p Olegi
// CSM.CHM file preparation.
// 
// 3     3/13/06 2:38p Felixp
// 
// 2     3/04/05 1:45p Mandal
// 
// 1     2/15/05 11:00a Olegi
// Initial VSS check-in.
// 
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:            CsmBlockIo.h
//
// Description:     CSM BlockIO driver header file.
//
//<AMI_FHDR_END>
//**********************************************************************

#ifndef _CsmBlockIo_
#define _CsmBlockIo_

#ifdef __cplusplus
extern "C" {
#endif

#include <Efi.h>
#include <Token.h>
#include <Dxe.h>
#include <PCI.h>
#include <AmiDxeLib.h>
#include <Protocol\PciIo.h>
#include <Protocol\DevicePath.h>
#include <Protocol\LegacyBios.h>
#include <Protocol\LegacyBiosExt.h>
#include <protocol\DriverBinding.h>
#include <Protocol\ComponentName.h>
#include <protocol\BlockIo.h>

#include "CsmEdd.h"


// Global Variables
#if EFI_DEBUG
extern EFI_COMPONENT_NAME_PROTOCOL gBiosBlockIoComponentName;
#endif


// Define the I2O class code

#define PCI_BASE_CLASS_INTELLIGENT      0x0e
#define PCI_SUB_CLASS_INTELLIGENT       0x00

// SD class/subclass defined in PCI.H in 4.6.3.7
#ifndef PCI_CL_SYSTEM_PERIPHERALS
#define PCI_CL_SYSTEM_PERIPHERALS		0x08
#endif
#ifndef PCI_CL_SYSTEM_PERIPHERALS_SCL_SD
#define PCI_CL_SYSTEM_PERIPHERALS_SCL_SD	0x05
#endif


// Number of pages needed for our buffer under 1MB

#define BLOCK_IO_BUFFER_PAGE_SIZE (((sizeof (EDD_DEVICE_ADDRESS_PACKET) + sizeof (CSM_LEGACY_DRIVE) + MAX_EDD11_XFER) / EFI_PAGE_SIZE) + 1)


// PROTOTYPES

// Driver Binding Protocol functions

EFI_STATUS
CsmBlockIoSupported (
  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
  IN EFI_HANDLE                   Controller,
  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
  );

EFI_STATUS
CsmBlockIoStart (
  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
  IN EFI_HANDLE                   Controller,
  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
  );

EFI_STATUS
CsmBlockIoStop (
  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
  IN  EFI_HANDLE                   Controller,
  IN  UINTN                        NumberOfChildren,
  IN  EFI_HANDLE                   *ChildHandleBuffer
  );
  
// Block I/O functions

EFI_STATUS 
CsmBlockIoFlushBlocks (
    IN  EFI_BLOCK_IO_PROTOCOL           *This
    );

EFI_STATUS 
CsmBlockIoReset (
    IN  EFI_BLOCK_IO_PROTOCOL           *This,
    IN  BOOLEAN                ExtendedVerification
    );

// These prototypes aren't actually used -- they are the generic for the specific
// functions below
EFI_STATUS
CsmBlockIoReadBlocks (
    IN  EFI_BLOCK_IO_PROTOCOL          *This,
    IN  UINT32                MediaId,
    IN  EFI_LBA               LBA,
    IN  UINTN                 BufferSize,
    OUT VOID                  *Buffer
    );

EFI_STATUS
CsmBlockIoWriteBlocks (
    IN  EFI_BLOCK_IO_PROTOCOL           *This,
    IN  UINT32                 MediaId,
    IN  EFI_LBA                LBA,
    IN  UINTN                  BufferSize,
    OUT VOID                   *Buffer
    );

// Specific read/write function prototypes
EFI_STATUS
Edd30CsmReadBlocks (
    IN  EFI_BLOCK_IO_PROTOCOL          *This, 
    IN  UINT32                MediaId, 
    IN  EFI_LBA               LBA, 
    IN  UINTN                 BufferSize, 
    OUT VOID                  *Buffer
    );

EFI_STATUS
Edd30CsmWriteBlocks (
    IN  EFI_BLOCK_IO_PROTOCOL          *This,
    IN  UINT32                MediaId,
    IN  EFI_LBA               LBA,
    IN  UINTN                 BufferSize,
    OUT VOID                  *Buffer
    );

EFI_STATUS
Edd11CsmReadBlocks (
    IN  EFI_BLOCK_IO_PROTOCOL          *This,
    IN  UINT32                MediaId,
    IN  EFI_LBA               LBA,
    IN  UINTN                 BufferSize,
    OUT VOID                  *Buffer
    );

EFI_STATUS
Edd11CsmWriteBlocks (
    IN  EFI_BLOCK_IO_PROTOCOL          *This,
    IN  UINT32                MediaId,
    IN  EFI_LBA               LBA,
    IN  UINTN                 BufferSize,
    OUT VOID                  *Buffer
    );

EFI_STATUS
LegacyCsmReadBlocks (
    IN  EFI_BLOCK_IO_PROTOCOL          *This,
    IN  UINT32                MediaId,
    IN  EFI_LBA               LBA,
    IN  UINTN                 BufferSize,
    OUT VOID                  *Buffer
    );

EFI_STATUS
LegacyCsmWriteBlocks (
    IN  EFI_BLOCK_IO_PROTOCOL          *This,
    IN  UINT32                MediaId,
    IN  EFI_LBA               LBA,
    IN  UINTN                 BufferSize,
    OUT VOID                  *Buffer
    );

// Local support function prototypes
BOOLEAN
InitBlockIo (
    IN  CSM_BLOCK_IO_DEV        *Dev
    );

// Local function prototypes
VOID
BuildDevicePath (
    IN  EFI_DEVICE_PATH_PROTOCOL  *BaseDevicePath,
    IN  CSM_LEGACY_DRIVE          *Drive,
    IN  EFI_DEVICE_PATH_PROTOCOL  **DevPath
    );

EFI_DEVICE_PATH_PROTOCOL *
AppendDevicePathNode (
    IN EFI_DEVICE_PATH_PROTOCOL  *DevPath,
    IN EFI_DEVICE_PATH_PROTOCOL  *Node
    );

UINTN AlignAddress (
    UINTN                       Address
    );

VOID ZeroMemory (
    VOID                        *Buffer,
    UINTN                       Size
);

/****** DO NOT WRITE BELOW THIS LINE *******/
#ifdef __cplusplus
}
#endif

#endif

//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2010, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**           5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093      **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************