Add WinNtBlockIoDxe module into Nt32Pkg.
[mirror_edk2.git] / Nt32Pkg / WinNtBlockIoDxe / WinNtBlockIo.h
1 /*++
2
3 Copyright (c) 2006, 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 WinNtBlockIo.h
15
16 Abstract:
17
18 Produce block IO abstractions for real devices on your PC using Win32 APIs.
19 The configuration of what devices to mount or emulate comes from NT
20 environment variables. The variables must be visible to the Microsoft*
21 Developer Studio for them to work.
22
23 * Other names and brands may be claimed as the property of others.
24
25 --*/
26
27 #ifndef _WIN_NT_BLOCK_IO_H_
28 #define _WIN_NT_BLOCK_IO_H_
29
30 #include <Uefi.h>
31 #include <WinNtDxe.h>
32 #include <Protocol/WinNtThunk.h>
33 #include <Protocol/WinNtIo.h>
34 #include <Protocol/BlockIo.h>
35 #include <Protocol/ComponentName.h>
36 #include <Protocol/DriverBinding.h>
37 //
38 // The Library classes this module consumes
39 //
40 #include <Library/DebugLib.h>
41 #include <Library/BaseLib.h>
42 #include <Library/UefiDriverEntryPoint.h>
43 #include <Library/UefiLib.h>
44 #include <Library/BaseMemoryLib.h>
45 #include <Library/UefiBootServicesTableLib.h>
46 #include <Library/MemoryAllocationLib.h>
47
48 #define FILENAME_BUFFER_SIZE 80
49
50 //
51 // Language supported for driverconfiguration protocol
52 //
53 #define LANGUAGESUPPORTED "eng"
54
55 typedef enum {
56 EfiWinNtVirtualDisks,
57 EfiWinNtPhysicalDisks,
58 EifWinNtMaxTypeDisks
59 } WIN_NT_RAW_DISK_DEVICE_TYPE;
60
61 #define WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'b', 'k')
62 typedef struct {
63 UINTN Signature;
64
65 EFI_LOCK Lock;
66
67 CHAR16 Filename[FILENAME_BUFFER_SIZE];
68 UINTN ReadMode;
69 UINTN ShareMode;
70 UINTN OpenMode;
71
72 HANDLE NtHandle;
73 WIN_NT_RAW_DISK_DEVICE_TYPE DeviceType;
74
75 UINT64 LastBlock;
76 UINTN BlockSize;
77 UINT64 NumberOfBlocks;
78
79 EFI_HANDLE EfiHandle;
80 EFI_BLOCK_IO_PROTOCOL BlockIo;
81 EFI_BLOCK_IO_MEDIA Media;
82
83 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
84
85 EFI_WIN_NT_THUNK_PROTOCOL *WinNtThunk;
86
87 } WIN_NT_BLOCK_IO_PRIVATE;
88
89 #define WIN_NT_BLOCK_IO_PRIVATE_DATA_FROM_THIS(a) \
90 CR(a, WIN_NT_BLOCK_IO_PRIVATE, BlockIo, WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE)
91
92 #define LIST_BUFFER_SIZE 512
93
94 //
95 // Block I/O Global Variables
96 //
97 extern EFI_DRIVER_BINDING_PROTOCOL gWinNtBlockIoDriverBinding;
98 extern EFI_COMPONENT_NAME_PROTOCOL gWinNtBlockIoComponentName;
99 extern EFI_DRIVER_CONFIGURATION_PROTOCOL gWinNtBlockIoDriverConfiguration;
100 extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gWinNtBlockIoDriverDiagnostics;
101
102 //
103 // EFI Driver Binding Functions
104 //
105 EFI_STATUS
106 EFIAPI
107 WinNtBlockIoDriverBindingSupported (
108 IN EFI_DRIVER_BINDING_PROTOCOL *This,
109 IN EFI_HANDLE Handle,
110 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
111 )
112 /*++
113
114 Routine Description:
115
116 TODO: Add function description
117
118 Arguments:
119
120 This - TODO: add argument description
121 Handle - TODO: add argument description
122 RemainingDevicePath - TODO: add argument description
123
124 Returns:
125
126 TODO: add return values
127
128 --*/
129 ;
130
131 EFI_STATUS
132 EFIAPI
133 WinNtBlockIoDriverBindingStart (
134 IN EFI_DRIVER_BINDING_PROTOCOL *This,
135 IN EFI_HANDLE Handle,
136 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
137 )
138 /*++
139
140 Routine Description:
141
142 TODO: Add function description
143
144 Arguments:
145
146 This - TODO: add argument description
147 Handle - TODO: add argument description
148 RemainingDevicePath - TODO: add argument description
149
150 Returns:
151
152 TODO: add return values
153
154 --*/
155 ;
156
157 EFI_STATUS
158 EFIAPI
159 WinNtBlockIoDriverBindingStop (
160 IN EFI_DRIVER_BINDING_PROTOCOL *This,
161 IN EFI_HANDLE Handle,
162 IN UINTN NumberOfChildren,
163 IN EFI_HANDLE *ChildHandleBuffer
164 )
165 /*++
166
167 Routine Description:
168
169 TODO: Add function description
170
171 Arguments:
172
173 This - TODO: add argument description
174 Handle - TODO: add argument description
175 NumberOfChildren - TODO: add argument description
176 ChildHandleBuffer - TODO: add argument description
177
178 Returns:
179
180 TODO: add return values
181
182 --*/
183 ;
184
185 //
186 // Block IO protocol member functions
187 //
188 STATIC
189 EFI_STATUS
190 EFIAPI
191 WinNtBlockIoReadBlocks (
192 IN EFI_BLOCK_IO_PROTOCOL *This,
193 IN UINT32 MediaId,
194 IN EFI_LBA Lba,
195 IN UINTN BufferSize,
196 OUT VOID *Buffer
197 )
198 /*++
199
200 Routine Description:
201
202 TODO: Add function description
203
204 Arguments:
205
206 This - TODO: add argument description
207 MediaId - TODO: add argument description
208 Lba - TODO: add argument description
209 BufferSize - TODO: add argument description
210 Buffer - TODO: add argument description
211
212 Returns:
213
214 TODO: add return values
215
216 --*/
217 ;
218
219 STATIC
220 EFI_STATUS
221 EFIAPI
222 WinNtBlockIoWriteBlocks (
223 IN EFI_BLOCK_IO_PROTOCOL *This,
224 IN UINT32 MediaId,
225 IN EFI_LBA Lba,
226 IN UINTN BufferSize,
227 IN VOID *Buffer
228 )
229 /*++
230
231 Routine Description:
232
233 TODO: Add function description
234
235 Arguments:
236
237 This - TODO: add argument description
238 MediaId - TODO: add argument description
239 Lba - TODO: add argument description
240 BufferSize - TODO: add argument description
241 Buffer - TODO: add argument description
242
243 Returns:
244
245 TODO: add return values
246
247 --*/
248 ;
249
250 STATIC
251 EFI_STATUS
252 EFIAPI
253 WinNtBlockIoFlushBlocks (
254 IN EFI_BLOCK_IO_PROTOCOL *This
255 )
256 /*++
257
258 Routine Description:
259
260 TODO: Add function description
261
262 Arguments:
263
264 This - TODO: add argument description
265
266 Returns:
267
268 TODO: add return values
269
270 --*/
271 ;
272
273 STATIC
274 EFI_STATUS
275 EFIAPI
276 WinNtBlockIoResetBlock (
277 IN EFI_BLOCK_IO_PROTOCOL *This,
278 IN BOOLEAN ExtendedVerification
279 )
280 /*++
281
282 Routine Description:
283
284 TODO: Add function description
285
286 Arguments:
287
288 This - TODO: add argument description
289 ExtendedVerification - TODO: add argument description
290
291 Returns:
292
293 TODO: add return values
294
295 --*/
296 ;
297
298 //
299 // Private Worker functions
300 //
301 STATIC
302 EFI_STATUS
303 WinNtBlockIoCreateMapping (
304 IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo,
305 IN EFI_HANDLE EfiDeviceHandle,
306 IN CHAR16 *Filename,
307 IN BOOLEAN ReadOnly,
308 IN BOOLEAN RemovableMedia,
309 IN UINTN NumberOfBlocks,
310 IN UINTN BlockSize,
311 IN WIN_NT_RAW_DISK_DEVICE_TYPE DeviceType
312 )
313 /*++
314
315 Routine Description:
316
317 TODO: Add function description
318
319 Arguments:
320
321 WinNtIo - TODO: add argument description
322 EfiDeviceHandle - TODO: add argument description
323 Filename - TODO: add argument description
324 ReadOnly - TODO: add argument description
325 RemovableMedia - TODO: add argument description
326 NumberOfBlocks - TODO: add argument description
327 BlockSize - TODO: add argument description
328 DeviceType - TODO: add argument description
329
330 Returns:
331
332 TODO: add return values
333
334 --*/
335 ;
336
337 STATIC
338 EFI_STATUS
339 WinNtBlockIoReadWriteCommon (
340 IN WIN_NT_BLOCK_IO_PRIVATE *Private,
341 IN UINT32 MediaId,
342 IN EFI_LBA Lba,
343 IN UINTN BufferSize,
344 IN VOID *Buffer,
345 IN CHAR8 *CallerName
346 )
347 /*++
348
349 Routine Description:
350
351 TODO: Add function description
352
353 Arguments:
354
355 Private - TODO: add argument description
356 MediaId - TODO: add argument description
357 Lba - TODO: add argument description
358 BufferSize - TODO: add argument description
359 Buffer - TODO: add argument description
360 CallerName - TODO: add argument description
361
362 Returns:
363
364 TODO: add return values
365
366 --*/
367 ;
368
369 STATIC
370 EFI_STATUS
371 WinNtBlockIoError (
372 IN WIN_NT_BLOCK_IO_PRIVATE *Private
373 )
374 /*++
375
376 Routine Description:
377
378 TODO: Add function description
379
380 Arguments:
381
382 Private - TODO: add argument description
383
384 Returns:
385
386 TODO: add return values
387
388 --*/
389 ;
390
391 STATIC
392 EFI_STATUS
393 WinNtBlockIoOpenDevice (
394 WIN_NT_BLOCK_IO_PRIVATE *Private
395 )
396 /*++
397
398 Routine Description:
399
400 TODO: Add function description
401
402 Arguments:
403
404 Private - TODO: add argument description
405
406 Returns:
407
408 TODO: add return values
409
410 --*/
411 ;
412
413 STATIC
414 CHAR16 *
415 GetNextElementPastTerminator (
416 IN CHAR16 *EnvironmentVariable,
417 IN CHAR16 Terminator
418 )
419 /*++
420
421 Routine Description:
422
423 TODO: Add function description
424
425 Arguments:
426
427 EnvironmentVariable - TODO: add argument description
428 Terminator - TODO: add argument description
429
430 Returns:
431
432 TODO: add return values
433
434 --*/
435 ;
436
437
438
439 EFI_STATUS
440 SetFilePointer64 (
441 IN WIN_NT_BLOCK_IO_PRIVATE *Private,
442 IN INT64 DistanceToMove,
443 OUT UINT64 *NewFilePointer,
444 IN DWORD MoveMethod
445 )
446 /*++
447
448 Routine Description:
449
450 TODO: Add function description
451
452 Arguments:
453
454 Private - TODO: add argument description
455 DistanceToMove - TODO: add argument description
456 NewFilePointer - TODO: add argument description
457 MoveMethod - TODO: add argument description
458
459 Returns:
460
461 TODO: add return values
462
463 --*/
464 ;
465
466 UINTN
467 Atoi (
468 CHAR16 *String
469 )
470 /*++
471
472 Routine Description:
473
474 TODO: Add function description
475
476 Arguments:
477
478 String - TODO: add argument description
479
480 Returns:
481
482 TODO: add return values
483
484 --*/
485 ;
486
487 #endif