• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**@file
2 
3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 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 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_COMPONENT_NAME2_PROTOCOL        gWinNtBlockIoComponentName2;
100 extern EFI_DRIVER_CONFIGURATION_PROTOCOL   gWinNtBlockIoDriverConfiguration;
101 extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL     gWinNtBlockIoDriverDiagnostics;
102 extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL    gWinNtBlockIoDriverDiagnostics2;
103 
104 //
105 // EFI Driver Binding Functions
106 //
107 EFI_STATUS
108 EFIAPI
109 WinNtBlockIoDriverBindingSupported (
110   IN EFI_DRIVER_BINDING_PROTOCOL    *This,
111   IN  EFI_HANDLE                    Handle,
112   IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath
113   )
114 /*++
115 
116 Routine Description:
117 
118   TODO: Add function description
119 
120 Arguments:
121 
122   This                - TODO: add argument description
123   Handle              - TODO: add argument description
124   RemainingDevicePath - TODO: add argument description
125 
126 Returns:
127 
128   TODO: add return values
129 
130 --*/
131 ;
132 
133 EFI_STATUS
134 EFIAPI
135 WinNtBlockIoDriverBindingStart (
136   IN EFI_DRIVER_BINDING_PROTOCOL    *This,
137   IN  EFI_HANDLE                    Handle,
138   IN  EFI_DEVICE_PATH_PROTOCOL      *RemainingDevicePath
139   )
140 /*++
141 
142 Routine Description:
143 
144   TODO: Add function description
145 
146 Arguments:
147 
148   This                - TODO: add argument description
149   Handle              - TODO: add argument description
150   RemainingDevicePath - TODO: add argument description
151 
152 Returns:
153 
154   TODO: add return values
155 
156 --*/
157 ;
158 
159 EFI_STATUS
160 EFIAPI
161 WinNtBlockIoDriverBindingStop (
162   IN  EFI_DRIVER_BINDING_PROTOCOL   *This,
163   IN  EFI_HANDLE                    Handle,
164   IN  UINTN                         NumberOfChildren,
165   IN  EFI_HANDLE                    *ChildHandleBuffer
166   )
167 /*++
168 
169 Routine Description:
170 
171   TODO: Add function description
172 
173 Arguments:
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 
180 Returns:
181 
182   TODO: add return values
183 
184 --*/
185 ;
186 
187 //
188 // Block IO protocol member functions
189 //
190 EFI_STATUS
191 EFIAPI
192 WinNtBlockIoReadBlocks (
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 
201 Routine Description:
202 
203   TODO: Add function description
204 
205 Arguments:
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 
213 Returns:
214 
215   TODO: add return values
216 
217 --*/
218 ;
219 
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 EFI_STATUS
251 EFIAPI
252 WinNtBlockIoFlushBlocks (
253   IN EFI_BLOCK_IO_PROTOCOL  *This
254   )
255 /*++
256 
257 Routine Description:
258 
259   TODO: Add function description
260 
261 Arguments:
262 
263   This  - TODO: add argument description
264 
265 Returns:
266 
267   TODO: add return values
268 
269 --*/
270 ;
271 
272 EFI_STATUS
273 EFIAPI
274 WinNtBlockIoResetBlock (
275   IN EFI_BLOCK_IO_PROTOCOL  *This,
276   IN BOOLEAN                ExtendedVerification
277   )
278 /*++
279 
280 Routine Description:
281 
282   TODO: Add function description
283 
284 Arguments:
285 
286   This                  - TODO: add argument description
287   ExtendedVerification  - TODO: add argument description
288 
289 Returns:
290 
291   TODO: add return values
292 
293 --*/
294 ;
295 
296 //
297 // Private Worker functions
298 //
299 EFI_STATUS
300 WinNtBlockIoCreateMapping (
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 
312 Routine Description:
313 
314   TODO: Add function description
315 
316 Arguments:
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 
327 Returns:
328 
329   TODO: add return values
330 
331 --*/
332 ;
333 
334 EFI_STATUS
335 WinNtBlockIoReadWriteCommon (
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 
345 Routine Description:
346 
347   TODO: Add function description
348 
349 Arguments:
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 
358 Returns:
359 
360   TODO: add return values
361 
362 --*/
363 ;
364 
365 EFI_STATUS
366 WinNtBlockIoError (
367   IN WIN_NT_BLOCK_IO_PRIVATE      *Private
368   )
369 /*++
370 
371 Routine Description:
372 
373   TODO: Add function description
374 
375 Arguments:
376 
377   Private - TODO: add argument description
378 
379 Returns:
380 
381   TODO: add return values
382 
383 --*/
384 ;
385 
386 EFI_STATUS
387 WinNtBlockIoOpenDevice (
388   WIN_NT_BLOCK_IO_PRIVATE         *Private
389   )
390 /*++
391 
392 Routine Description:
393 
394   TODO: Add function description
395 
396 Arguments:
397 
398   Private - TODO: add argument description
399 
400 Returns:
401 
402   TODO: add return values
403 
404 --*/
405 ;
406 
407 CHAR16                                    *
408 GetNextElementPastTerminator (
409   IN  CHAR16  *EnvironmentVariable,
410   IN  CHAR16  Terminator
411   )
412 /*++
413 
414 Routine Description:
415 
416   TODO: Add function description
417 
418 Arguments:
419 
420   EnvironmentVariable - TODO: add argument description
421   Terminator          - TODO: add argument description
422 
423 Returns:
424 
425   TODO: add return values
426 
427 --*/
428 ;
429 
430 
431 
432 EFI_STATUS
433 SetFilePointer64 (
434   IN  WIN_NT_BLOCK_IO_PRIVATE    *Private,
435   IN  INT64                      DistanceToMove,
436   OUT UINT64                     *NewFilePointer,
437   IN  DWORD                      MoveMethod
438   )
439 /*++
440 
441 Routine Description:
442 
443   TODO: Add function description
444 
445 Arguments:
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 
452 Returns:
453 
454   TODO: add return values
455 
456 --*/
457 ;
458 
459 UINTN
460 Atoi (
461   CHAR16  *String
462   )
463 /*++
464 
465 Routine Description:
466 
467   TODO: Add function description
468 
469 Arguments:
470 
471   String  - TODO: add argument description
472 
473 Returns:
474 
475   TODO: add return values
476 
477 --*/
478 ;
479 
480 #endif
481