blob: 7a7817c59f31265e32cbab164f6acb448e4b9762 [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301/**@file
2
3Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4This program and the accompanying materials
5are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution. The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13
14 WinNtBlockIo.h
15
16Abstract:
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
55typedef enum {
56 EfiWinNtVirtualDisks,
57 EfiWinNtPhysicalDisks,
58 EifWinNtMaxTypeDisks
59} WIN_NT_RAW_DISK_DEVICE_TYPE;
60
61#define WIN_NT_BLOCK_IO_PRIVATE_SIGNATURE SIGNATURE_32 ('N', 'T', 'b', 'k')
62typedef 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//
97extern EFI_DRIVER_BINDING_PROTOCOL gWinNtBlockIoDriverBinding;
98extern EFI_COMPONENT_NAME_PROTOCOL gWinNtBlockIoComponentName;
99extern EFI_COMPONENT_NAME2_PROTOCOL gWinNtBlockIoComponentName2;
100extern EFI_DRIVER_CONFIGURATION_PROTOCOL gWinNtBlockIoDriverConfiguration;
101extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gWinNtBlockIoDriverDiagnostics;
102extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gWinNtBlockIoDriverDiagnostics2;
103
104//
105// EFI Driver Binding Functions
106//
107EFI_STATUS
108EFIAPI
109WinNtBlockIoDriverBindingSupported (
110 IN EFI_DRIVER_BINDING_PROTOCOL *This,
111 IN EFI_HANDLE Handle,
112 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
113 )
114/*++
115
116Routine Description:
117
118 TODO: Add function description
119
120Arguments:
121
122 This - TODO: add argument description
123 Handle - TODO: add argument description
124 RemainingDevicePath - TODO: add argument description
125
126Returns:
127
128 TODO: add return values
129
130--*/
131;
132
133EFI_STATUS
134EFIAPI
135WinNtBlockIoDriverBindingStart (
136 IN EFI_DRIVER_BINDING_PROTOCOL *This,
137 IN EFI_HANDLE Handle,
138 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
139 )
140/*++
141
142Routine Description:
143
144 TODO: Add function description
145
146Arguments:
147
148 This - TODO: add argument description
149 Handle - TODO: add argument description
150 RemainingDevicePath - TODO: add argument description
151
152Returns:
153
154 TODO: add return values
155
156--*/
157;
158
159EFI_STATUS
160EFIAPI
161WinNtBlockIoDriverBindingStop (
162 IN EFI_DRIVER_BINDING_PROTOCOL *This,
163 IN EFI_HANDLE Handle,
164 IN UINTN NumberOfChildren,
165 IN EFI_HANDLE *ChildHandleBuffer
166 )
167/*++
168
169Routine Description:
170
171 TODO: Add function description
172
173Arguments:
174
175 This - TODO: add argument description
176 Handle - TODO: add argument description
177 NumberOfChildren - TODO: add argument description
178 ChildHandleBuffer - TODO: add argument description
179
180Returns:
181
182 TODO: add return values
183
184--*/
185;
186
187//
188// Block IO protocol member functions
189//
190EFI_STATUS
191EFIAPI
192WinNtBlockIoReadBlocks (
193 IN EFI_BLOCK_IO_PROTOCOL *This,
194 IN UINT32 MediaId,
195 IN EFI_LBA Lba,
196 IN UINTN BufferSize,
197 OUT VOID *Buffer
198 )
199/*++
200
201Routine Description:
202
203 TODO: Add function description
204
205Arguments:
206
207 This - TODO: add argument description
208 MediaId - TODO: add argument description
209 Lba - TODO: add argument description
210 BufferSize - TODO: add argument description
211 Buffer - TODO: add argument description
212
213Returns:
214
215 TODO: add return values
216
217--*/
218;
219
220EFI_STATUS
221EFIAPI
222WinNtBlockIoWriteBlocks (
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
231Routine Description:
232
233 TODO: Add function description
234
235Arguments:
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
243Returns:
244
245 TODO: add return values
246
247--*/
248;
249
250EFI_STATUS
251EFIAPI
252WinNtBlockIoFlushBlocks (
253 IN EFI_BLOCK_IO_PROTOCOL *This
254 )
255/*++
256
257Routine Description:
258
259 TODO: Add function description
260
261Arguments:
262
263 This - TODO: add argument description
264
265Returns:
266
267 TODO: add return values
268
269--*/
270;
271
272EFI_STATUS
273EFIAPI
274WinNtBlockIoResetBlock (
275 IN EFI_BLOCK_IO_PROTOCOL *This,
276 IN BOOLEAN ExtendedVerification
277 )
278/*++
279
280Routine Description:
281
282 TODO: Add function description
283
284Arguments:
285
286 This - TODO: add argument description
287 ExtendedVerification - TODO: add argument description
288
289Returns:
290
291 TODO: add return values
292
293--*/
294;
295
296//
297// Private Worker functions
298//
299EFI_STATUS
300WinNtBlockIoCreateMapping (
301 IN EFI_WIN_NT_IO_PROTOCOL *WinNtIo,
302 IN EFI_HANDLE EfiDeviceHandle,
303 IN CHAR16 *Filename,
304 IN BOOLEAN ReadOnly,
305 IN BOOLEAN RemovableMedia,
306 IN UINTN NumberOfBlocks,
307 IN UINTN BlockSize,
308 IN WIN_NT_RAW_DISK_DEVICE_TYPE DeviceType
309 )
310/*++
311
312Routine Description:
313
314 TODO: Add function description
315
316Arguments:
317
318 WinNtIo - TODO: add argument description
319 EfiDeviceHandle - TODO: add argument description
320 Filename - TODO: add argument description
321 ReadOnly - TODO: add argument description
322 RemovableMedia - TODO: add argument description
323 NumberOfBlocks - TODO: add argument description
324 BlockSize - TODO: add argument description
325 DeviceType - TODO: add argument description
326
327Returns:
328
329 TODO: add return values
330
331--*/
332;
333
334EFI_STATUS
335WinNtBlockIoReadWriteCommon (
336 IN WIN_NT_BLOCK_IO_PRIVATE *Private,
337 IN UINT32 MediaId,
338 IN EFI_LBA Lba,
339 IN UINTN BufferSize,
340 IN VOID *Buffer,
341 IN CHAR8 *CallerName
342 )
343/*++
344
345Routine Description:
346
347 TODO: Add function description
348
349Arguments:
350
351 Private - TODO: add argument description
352 MediaId - TODO: add argument description
353 Lba - TODO: add argument description
354 BufferSize - TODO: add argument description
355 Buffer - TODO: add argument description
356 CallerName - TODO: add argument description
357
358Returns:
359
360 TODO: add return values
361
362--*/
363;
364
365EFI_STATUS
366WinNtBlockIoError (
367 IN WIN_NT_BLOCK_IO_PRIVATE *Private
368 )
369/*++
370
371Routine Description:
372
373 TODO: Add function description
374
375Arguments:
376
377 Private - TODO: add argument description
378
379Returns:
380
381 TODO: add return values
382
383--*/
384;
385
386EFI_STATUS
387WinNtBlockIoOpenDevice (
388 WIN_NT_BLOCK_IO_PRIVATE *Private
389 )
390/*++
391
392Routine Description:
393
394 TODO: Add function description
395
396Arguments:
397
398 Private - TODO: add argument description
399
400Returns:
401
402 TODO: add return values
403
404--*/
405;
406
407CHAR16 *
408GetNextElementPastTerminator (
409 IN CHAR16 *EnvironmentVariable,
410 IN CHAR16 Terminator
411 )
412/*++
413
414Routine Description:
415
416 TODO: Add function description
417
418Arguments:
419
420 EnvironmentVariable - TODO: add argument description
421 Terminator - TODO: add argument description
422
423Returns:
424
425 TODO: add return values
426
427--*/
428;
429
430
431
432EFI_STATUS
433SetFilePointer64 (
434 IN WIN_NT_BLOCK_IO_PRIVATE *Private,
435 IN INT64 DistanceToMove,
436 OUT UINT64 *NewFilePointer,
437 IN DWORD MoveMethod
438 )
439/*++
440
441Routine Description:
442
443 TODO: Add function description
444
445Arguments:
446
447 Private - TODO: add argument description
448 DistanceToMove - TODO: add argument description
449 NewFilePointer - TODO: add argument description
450 MoveMethod - TODO: add argument description
451
452Returns:
453
454 TODO: add return values
455
456--*/
457;
458
459UINTN
460Atoi (
461 CHAR16 *String
462 )
463/*++
464
465Routine Description:
466
467 TODO: Add function description
468
469Arguments:
470
471 String - TODO: add argument description
472
473Returns:
474
475 TODO: add return values
476
477--*/
478;
479
480#endif