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