]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/MnpDxe/MnpDriver.h
fb140127ad2e5b18d64e1dc4b3ac7690a4452b5b
[mirror_edk2.git] / MdeModulePkg / Universal / Network / MnpDxe / MnpDriver.h
1 /** @file
2 Declaration of strctures and functions for MnpDxe driver.
3
4 Copyright (c) 2005 - 2007, Intel Corporation.<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _MNP_DRIVER_H_
16 #define _MNP_DRIVER_H_
17 #include <Uefi.h>
18
19 #include <Protocol/ManagedNetwork.h>
20 #include <Protocol/SimpleNetwork.h>
21 #include <Protocol/ServiceBinding.h>
22
23 #include <Library/DebugLib.h>
24 #include <Library/UefiDriverEntryPoint.h>
25 #include <Library/UefiBootServicesTableLib.h>
26 #include <Library/UefiLib.h>
27 #include <Library/NetLib.h>
28 #include <Library/BaseLib.h>
29 #include <Library/MemoryAllocationLib.h>
30 #include <Library/BaseMemoryLib.h>
31
32 //
33 // Required Global Variables
34 //
35 extern EFI_DRIVER_BINDING_PROTOCOL gMnpDriverBinding;
36 extern EFI_COMPONENT_NAME_PROTOCOL gMnpComponentName;
37 extern EFI_COMPONENT_NAME2_PROTOCOL gMnpComponentName2;
38
39 #define MNP_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('M', 'n', 'p', 'S')
40
41 typedef struct _MNP_SERVICE_DATA {
42 UINT32 Signature;
43
44 EFI_HANDLE ControllerHandle;
45
46 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
47 EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
48
49 UINT32 Mtu;
50
51 LIST_ENTRY ChildrenList;
52 UINTN ChildrenNumber;
53 UINTN ConfiguredChildrenNumber;
54
55 LIST_ENTRY GroupAddressList;
56 UINT32 GroupAddressCount;
57
58 EFI_EVENT TxTimeoutEvent;
59
60 NET_BUF_QUEUE FreeNbufQue;
61 INTN NbufCnt;
62
63 EFI_EVENT PollTimer;
64 BOOLEAN EnableSystemPoll;
65
66 EFI_EVENT TimeoutCheckTimer;
67
68 UINT32 UnicastCount;
69 UINT32 BroadcastCount;
70 UINT32 MulticastCount;
71 UINT32 PromiscuousCount;
72
73 //
74 // The size of the data buffer in the MNP_PACKET_BUFFER used to
75 // store a packet.
76 //
77 UINT32 BufferLength;
78 UINT32 PaddingSize;
79 NET_BUF *RxNbufCache;
80 UINT8 *TxBuf;
81 } MNP_SERVICE_DATA;
82
83 #define MNP_SERVICE_DATA_FROM_THIS(a) \
84 CR ( \
85 (a), \
86 MNP_SERVICE_DATA, \
87 ServiceBinding, \
88 MNP_SERVICE_DATA_SIGNATURE \
89 )
90
91 /**
92 Test to see if this driver supports ControllerHandle. This service
93 is called by the EFI boot service ConnectController(). In
94 order to make drivers as small as possible, there are a few calling
95 restrictions for this service. ConnectController() must
96 follow these calling restrictions. If any other agent wishes to call
97 Supported() it must also follow these calling restrictions.
98
99 @param[in] This Protocol instance pointer.
100 @param[in] ControllerHandle Handle of device to test
101 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
102 device to start.
103
104 @retval EFI_SUCCESS This driver supports this device
105 @retval EFI_ALREADY_STARTED This driver is already running on this device
106 @retval other This driver does not support this device
107
108 **/
109 EFI_STATUS
110 EFIAPI
111 MnpDriverBindingSupported (
112 IN EFI_DRIVER_BINDING_PROTOCOL *This,
113 IN EFI_HANDLE ControllerHandle,
114 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
115 );
116
117 /**
118 Start this driver on ControllerHandle. This service is called by the
119 EFI boot service ConnectController(). In order to make
120 drivers as small as possible, there are a few calling restrictions for
121 this service. ConnectController() must follow these
122 calling restrictions. If any other agent wishes to call Start() it
123 must also follow these calling restrictions.
124
125 @param[in] This Protocol instance pointer.
126 @param[in] ControllerHandle Handle of device to bind driver to.
127 @param[in] RemainingDevicePath Optional parameter use to pick a specific child
128 device to start.
129
130 @retval EFI_SUCCESS This driver is added to ControllerHandle
131 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
132 @retval other This driver does not support this device
133
134 **/
135 EFI_STATUS
136 EFIAPI
137 MnpDriverBindingStart (
138 IN EFI_DRIVER_BINDING_PROTOCOL *This,
139 IN EFI_HANDLE ControllerHandle,
140 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
141 );
142
143
144 /**
145 Stop this driver on ControllerHandle. This service is called by the
146 EFI boot service DisconnectController(). In order to
147 make drivers as small as possible, there are a few calling
148 restrictions for this service. DisconnectController()
149 must follow these calling restrictions. If any other agent wishes
150 to call Stop() it must also follow these calling restrictions.
151
152 @param[in] This Protocol instance pointer.
153 @param[in] ControllerHandle Handle of device to stop driver on
154 @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
155 children is zero stop the entire bus driver.
156 @param[in] ChildHandleBuffer List of Child Handles to Stop.
157
158 @retval EFI_SUCCESS This driver is removed ControllerHandle
159 @retval other This driver was not removed from this device
160
161 **/
162 EFI_STATUS
163 EFIAPI
164 MnpDriverBindingStop (
165 IN EFI_DRIVER_BINDING_PROTOCOL *This,
166 IN EFI_HANDLE ControllerHandle,
167 IN UINTN NumberOfChildren,
168 IN EFI_HANDLE *ChildHandleBuffer
169 );
170
171 /**
172 Creates a child handle and installs a protocol.
173
174 The CreateChild() function installs a protocol on ChildHandle.
175 If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
176 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
177
178 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
179 @param ChildHandle Pointer to the handle of the child to create. If it is NULL,
180 then a new handle is created. If it is a pointer to an existing UEFI handle,
181 then the protocol is added to the existing UEFI handle.
182
183 @retval EFI_SUCCES The protocol was added to ChildHandle.
184 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
185 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
186 the child
187 @retval other The child handle was not created
188
189 **/
190 EFI_STATUS
191 EFIAPI
192 MnpServiceBindingCreateChild (
193 IN EFI_SERVICE_BINDING_PROTOCOL *This,
194 IN OUT EFI_HANDLE *ChildHandle
195 );
196
197 /**
198 Destroys a child handle with a protocol installed on it.
199
200 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
201 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
202 last protocol on ChildHandle, then ChildHandle is destroyed.
203
204 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
205 @param ChildHandle Handle of the child to destroy
206
207 @retval EFI_SUCCES The protocol was removed from ChildHandle.
208 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
209 @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
210 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
211 because its services are being used.
212 @retval other The child handle was not destroyed
213
214 **/
215 EFI_STATUS
216 EFIAPI
217 MnpServiceBindingDestroyChild (
218 IN EFI_SERVICE_BINDING_PROTOCOL *This,
219 IN EFI_HANDLE ChildHandle
220 );
221
222 #endif