42540307e586c134bf36ccbb67764f4c6c45841b
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / DiskIo / Dxe / DiskIo.h
1 /** @file
2 DiskIo driver that layers it's self on every Block IO protocol in the system.
3 DiskIo converts a block oriented device to a byte oriented device.
4
5 Copyright (c) 2006 - 2007, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include <Uefi.h>
17 #include <Protocol/BlockIo.h>
18 #include <Protocol/ComponentName.h>
19 #include <Protocol/DriverBinding.h>
20 #include <Protocol/DiskIo.h>
21 #include <Library/DebugLib.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/UefiLib.h>
24 #include <Library/BaseLib.h>
25 #include <Library/BaseMemoryLib.h>
26 #include <Library/MemoryAllocationLib.h>
27 #include <Library/UefiBootServicesTableLib.h>
28
29
30 #define DISK_IO_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('d', 's', 'k', 'I')
31
32 #define DATA_BUFFER_BLOCK_NUM (64)
33
34 typedef struct {
35 UINTN Signature;
36 EFI_DISK_IO_PROTOCOL DiskIo;
37 EFI_BLOCK_IO_PROTOCOL *BlockIo;
38 } DISK_IO_PRIVATE_DATA;
39
40 #define DISK_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE)
41
42 //
43 // Global Variables
44 //
45 extern EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding;
46 extern EFI_COMPONENT_NAME_PROTOCOL gDiskIoComponentName;
47
48 //
49 // Prototypes
50 // Driver model protocol interface
51 //
52 EFI_STATUS
53 EFIAPI
54 DiskIoDriverBindingSupported (
55 IN EFI_DRIVER_BINDING_PROTOCOL *This,
56 IN EFI_HANDLE ControllerHandle,
57 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
58 );
59
60 EFI_STATUS
61 EFIAPI
62 DiskIoDriverBindingStart (
63 IN EFI_DRIVER_BINDING_PROTOCOL *This,
64 IN EFI_HANDLE ControllerHandle,
65 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
66 );
67
68 EFI_STATUS
69 EFIAPI
70 DiskIoDriverBindingStop (
71 IN EFI_DRIVER_BINDING_PROTOCOL *This,
72 IN EFI_HANDLE ControllerHandle,
73 IN UINTN NumberOfChildren,
74 IN EFI_HANDLE *ChildHandleBuffer
75 );
76
77 //
78 // Disk I/O Protocol Interface
79 //
80 EFI_STATUS
81 EFIAPI
82 DiskIoReadDisk (
83 IN EFI_DISK_IO_PROTOCOL *This,
84 IN UINT32 MediaId,
85 IN UINT64 Offset,
86 IN UINTN BufferSize,
87 OUT VOID *Buffer
88 );
89
90 EFI_STATUS
91 EFIAPI
92 DiskIoWriteDisk (
93 IN EFI_DISK_IO_PROTOCOL *This,
94 IN UINT32 MediaId,
95 IN UINT64 Offset,
96 IN UINTN BufferSize,
97 IN VOID *Buffer
98 );
99
100 //
101 // EFI Component Name Functions
102 //
103 EFI_STATUS
104 EFIAPI
105 DiskIoComponentNameGetDriverName (
106 IN EFI_COMPONENT_NAME_PROTOCOL *This,
107 IN CHAR8 *Language,
108 OUT CHAR16 **DriverName
109 );
110
111 EFI_STATUS
112 EFIAPI
113 DiskIoComponentNameGetControllerName (
114 IN EFI_COMPONENT_NAME_PROTOCOL *This,
115 IN EFI_HANDLE ControllerHandle,
116 IN EFI_HANDLE ChildHandle OPTIONAL,
117 IN CHAR8 *Language,
118 OUT CHAR16 **ControllerName
119 );
120