1. Import SnpNt32Dxe. That is a thunk driver could produce SNP protocol on NT32 platf...
[people/mcb30/edk2.git] / edk2 / Nt32Pkg / SnpNt32Dxe / SnpNt32.h
1 /** @file
2
3 Copyright (c) 2006 - 2007, 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   SnpNt32.h
15
16 Abstract:
17
18 -**/
19
20 #ifndef _SNP_NT32_H_
21 #define _SNP_NT32_H_
22 \r
23 #include <PiDxe.h>\r
24 \r
25 #include <Protocol/SimpleNetwork.h>\r
26 #include <Protocol/DevicePath.h>
27 #include <Protocol/WinNtThunk.h>\r
28
29 #include <Library/BaseLib.h>\r
30 #include <Library/DebugLib.h>\r
31 #include <Library/BaseMemoryLib.h>\r
32 #include <Library/UefiBootServicesTableLib.h>\r
33 #include <Library/UefiLib.h>\r
34 #include <Library/DevicePathLib.h>
35 #include <Library/NetLib.h>
36 #include <Library/MemoryAllocationLib.h>
37
38 typedef struct _SNPNT32_GLOBAL_DATA  SNPNT32_GLOBAL_DATA;
39 typedef struct _SNPNT32_INSTANCE_DATA SNPNT32_INSTANCE_DATA;
40
41 #define NETWORK_LIBRARY_NAME_U          L"SnpNt32Io.dll"
42
43 #define NETWORK_LIBRARY_INITIALIZE      "SnpInitialize"
44 #define NETWORK_LIBRARY_FINALIZE        "SnpFinalize"
45 #define NETWORK_LIBRARY_SET_RCV_FILTER  "SnpSetReceiveFilter"
46 #define NETWORK_LIBRARY_RECEIVE         "SnpReceive"
47 #define NETWORK_LIBRARY_TRANSMIT        "SnpTransmit"
48
49 #pragma pack(1)
50 typedef struct _NT_NET_INTERFACE_INFO {
51   UINT32          InterfaceIndex;
52   EFI_MAC_ADDRESS MacAddr;
53 } NT_NET_INTERFACE_INFO;
54 #pragma pack()
55
56 #define NET_ETHER_HEADER_SIZE     14
57
58 #define MAX_INTERFACE_INFO_NUMBER 16
59 #define MAX_FILE_NAME_LENGTH      280
60
61 //
62 //  Functions in Net Library
63 //
64 typedef
65 INT32
66 (*NT_NET_INITIALIZE) (
67   IN OUT  UINT32                *InterfaceCount,
68   IN OUT  NT_NET_INTERFACE_INFO * InterfaceInfoBuffer
69   );
70
71 typedef
72 INT32
73 (*NT_NET_FINALIZE) (
74   VOID
75   );
76
77 typedef
78 INT32
79 (*NT_NET_SET_RECEIVE_FILTER) (
80   IN  UINT32                        Index,
81   IN  UINT32                        EnableFilter,
82   IN  UINT32                        MCastFilterCnt,
83   IN  EFI_MAC_ADDRESS               * MCastFilter
84   );
85
86 typedef
87 INT32
88 (*NT_NET_RECEIVE) (
89   IN      UINT32                        Index,
90   IN OUT  UINT32                        *BufferSize,
91   OUT     VOID                          *Buffer
92   );
93
94 typedef
95 INT32
96 (*NT_NET_TRANSMIT) (
97   IN  UINT32                        Index,
98   IN  UINT32                        HeaderSize,
99   IN  UINT32                        BufferSize,
100   IN  VOID                          *Buffer,
101   IN  EFI_MAC_ADDRESS               * SrcAddr,
102   IN  EFI_MAC_ADDRESS               * DestAddr,
103   IN  UINT16                        *Protocol
104   );
105
106 typedef struct _NT_NET_UTILITY_TABLE {
107   NT_NET_INITIALIZE         Initialize;
108   NT_NET_FINALIZE           Finalize;
109   NT_NET_SET_RECEIVE_FILTER SetReceiveFilter;
110   NT_NET_RECEIVE            Receive;
111   NT_NET_TRANSMIT           Transmit;
112 } NT_NET_UTILITY_TABLE;
113
114 //
115 //  Private functions
116 //
117 typedef
118 EFI_STATUS
119 (*SNPNT32_INITIALIZE_GLOBAL_DATA) (
120   IN SNPNT32_GLOBAL_DATA * This
121   );
122
123 typedef
124 EFI_STATUS
125 (*SNPNT32_INITIALIZE_INSTANCE_DATA) (
126   IN SNPNT32_GLOBAL_DATA    * This,
127   IN SNPNT32_INSTANCE_DATA  * Instance
128   );
129
130 typedef
131 EFI_STATUS
132 (*SNPNT32_CLOSE_INSTANCE) (
133   IN SNPNT32_GLOBAL_DATA    * This,
134   IN SNPNT32_INSTANCE_DATA  * Instance
135   );
136
137 //
138 //  Global data for this driver
139 //
140 #define SNP_NT32_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('W', 'S', 'N', 'P')
141
142 typedef struct _SNPNT32_GLOBAL_DATA {
143   UINT32                            Signature;
144
145   //
146   //  List for all the fake SNP instance
147   //
148   NET_LIST_ENTRY                    InstanceList;
149
150   EFI_WIN_NT_THUNK_PROTOCOL         *WinNtThunk;
151   HMODULE                           NetworkLibraryHandle;
152
153   NT_NET_UTILITY_TABLE              NtNetUtilityTable;
154
155   NET_LOCK                          Lock;
156
157   //
158   //  Private functions
159   //
160   SNPNT32_INITIALIZE_GLOBAL_DATA    InitializeGlobalData;
161   SNPNT32_INITIALIZE_INSTANCE_DATA  InitializeInstanceData;
162   SNPNT32_CLOSE_INSTANCE            CloseInstance;
163 } SNPNT32_GLOBAL_DATA;
164
165 //
166 //  Instance data for each fake SNP instance
167 //
168 #define SNP_NT32_INSTANCE_SIGNATURE EFI_SIGNATURE_32 ('w', 'S', 'N', 'P')
169
170 typedef struct _SNPNT32_INSTANCE_DATA {
171   UINT32                      Signature;
172
173   //
174   //  List entry use for linking with other instance
175   //
176   NET_LIST_ENTRY              Entry;
177
178   SNPNT32_GLOBAL_DATA         *GlobalData;
179
180   EFI_HANDLE                  DeviceHandle;
181   EFI_DEVICE_PATH_PROTOCOL    *DevicePath;
182
183   EFI_SIMPLE_NETWORK_PROTOCOL Snp;
184   EFI_SIMPLE_NETWORK_MODE     Mode;
185
186   NT_NET_INTERFACE_INFO       InterfaceInfo;
187
188   //
189   //  Private functions
190   //
191 } SNPNT32_INSTANCE_DATA;
192
193 #define SNP_NT32_INSTANCE_DATA_FROM_SNP_THIS(a) \
194   CR ( \
195   a, \
196   SNPNT32_INSTANCE_DATA, \
197   Snp, \
198   SNP_NT32_INSTANCE_SIGNATURE \
199   )
200
201 extern EFI_DRIVER_BINDING_PROTOCOL  gSnpNt32DriverBinding;
202 extern EFI_COMPONENT_NAME_PROTOCOL   gSnpNt32DriverComponentName;
203
204 EFI_STATUS
205 EFIAPI
206 SnpNt32DriverBindingSupported (
207   IN EFI_DRIVER_BINDING_PROTOCOL  * This,
208   IN EFI_HANDLE                   ControllerHandle,
209   IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL
210   );
211
212 EFI_STATUS
213 EFIAPI
214 SnpNt32DriverBindingStart (
215   IN EFI_DRIVER_BINDING_PROTOCOL  * This,
216   IN EFI_HANDLE                   ControllerHandle,
217   IN EFI_DEVICE_PATH_PROTOCOL     * RemainingDevicePath OPTIONAL
218   );
219
220 EFI_STATUS
221 EFIAPI
222 SnpNt32DriverBindingStop (
223   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
224   IN  EFI_HANDLE                   ControllerHandle,
225   IN  UINTN                        NumberOfChildren,
226   IN  EFI_HANDLE                   *ChildHandleBuffer
227   );
228
229 EFI_STATUS
230 SnpNt32InitializeGlobalData (
231   IN SNPNT32_GLOBAL_DATA *This
232   );
233
234 EFI_STATUS
235 SnpNt32InitializeInstanceData (
236   IN SNPNT32_GLOBAL_DATA    *This,
237   IN SNPNT32_INSTANCE_DATA  *Instance
238   );
239
240 EFI_STATUS
241 SnpNt32CloseInstance (
242   IN SNPNT32_GLOBAL_DATA    *This,
243   IN SNPNT32_INSTANCE_DATA  *Instance
244   );
245
246 #endif