12UINT32 gRateLimitingCredit;
13UINT32 gRateLimitingPollTimer;
14BOOLEAN gRateLimitingEnable;
20 NETWORK_COMMON_DRIVER_VERSION,
55 MacAddrNode.Header.
Length[0] = (UINT8)
sizeof (MacAddrNode);
56 MacAddrNode.Header.
Length[1] = 0;
64 BaseLength = (UINT16)((
UINTN)(EndNode) - (
UINTN)(BaseDev));
68 if (EFI_ERROR (Status)) {
73 CopyMem (DevicePath, (CHAR8 *)BaseDev, BaseLength);
74 DevicePath += BaseLength;
75 CopyMem (DevicePath, (CHAR8 *)&MacAddrNode,
sizeof (MacAddrNode));
76 DevicePath +=
sizeof (MacAddrNode);
106 Status =
gBS->OpenProtocol (
108 &gEdkIIUsbEthProtocolGuid,
110 This->DriverBindingHandle,
112 EFI_OPEN_PROTOCOL_BY_DRIVER
114 if (EFI_ERROR (Status)) {
120 &gEdkIIUsbEthProtocolGuid,
121 This->DriverBindingHandle,
155 UINT8 *TmpPxePointer;
157 Status =
gBS->OpenProtocol (
159 &gEdkIIUsbEthProtocolGuid,
161 This->DriverBindingHandle,
163 EFI_OPEN_PROTOCOL_BY_DRIVER
165 if (EFI_ERROR (Status)) {
169 Status =
gBS->OpenProtocol (
171 &gEfiDevicePathProtocolGuid,
172 (VOID **)&UsbEthPath,
173 This->DriverBindingHandle,
175 EFI_OPEN_PROTOCOL_BY_DRIVER
178 if (EFI_ERROR (Status)) {
181 &gEdkIIUsbEthProtocolGuid,
182 This->DriverBindingHandle,
190 Status = UsbEth->UsbEthMacAddress (UsbEth, &MacAddress);
192 Status = UsbEth->UsbEthMaxBulkSize (UsbEth, &BulkDataSize);
194 if (EFI_ERROR (Status)) {
197 &gEfiDevicePathProtocolGuid,
198 This->DriverBindingHandle,
203 &gEdkIIUsbEthProtocolGuid,
204 This->DriverBindingHandle,
214 &gEfiDevicePathProtocolGuid,
215 This->DriverBindingHandle,
220 &gEdkIIUsbEthProtocolGuid,
221 This->DriverBindingHandle,
224 return EFI_OUT_OF_RESOURCES;
229 TmpPxePointer =
NULL;
231 if (!TmpPxePointer) {
232 if (NicDevice !=
NULL) {
238 &gEfiDevicePathProtocolGuid,
239 This->DriverBindingHandle,
244 &gEdkIIUsbEthProtocolGuid,
245 This->DriverBindingHandle,
249 return EFI_OUT_OF_RESOURCES;
252 if (((
UINTN)TmpPxePointer & 0x0F) != 0) {
259 if (NicDevice !=
NULL) {
265 &gEfiDevicePathProtocolGuid,
266 This->DriverBindingHandle,
271 &gEdkIIUsbEthProtocolGuid,
272 This->DriverBindingHandle,
275 return EFI_OUT_OF_RESOURCES;
282 NicDevice->NiiProtocol.
Id = (UINT64)(
UINTN)(gPxe);
287 NicDevice->NicInfo.Signature = NIC_DATA_SIGNATURE;
289 NicDevice->NicInfo.UsbEth = UsbEth;
290 NicDevice->NicInfo.MaxSegmentSize = (UINT16)BulkDataSize;
291 NicDevice->NicInfo.CableDetect = 0;
292 NicDevice->ReceiveBuffer =
ALIGN_POINTER ((VOID *)NicDevice, 4096);
294 CopyMem ((CHAR8 *)&(NicDevice->NicInfo.MacAddr), (CHAR8 *)&MacAddress, sizeof (MacAddress));
296 NicDevice->NicInfo.TxBufferCount = 0;
298 if (NicDevice->NiiProtocol.
IfNum < MAX_LAN_INTERFACE) {
299 gLanDeviceList[NicDevice->NiiProtocol.
IfNum] = NicDevice;
303 &gEfiDevicePathProtocolGuid,
304 This->DriverBindingHandle,
309 &gEdkIIUsbEthProtocolGuid,
310 This->DriverBindingHandle,
314 if (TmpPxePointer !=
NULL) {
318 if (NicDevice !=
NULL) {
322 return EFI_DEVICE_ERROR;
331 if (EFI_ERROR (Status)) {
333 if (TmpPxePointer !=
NULL) {
338 NicDevice->Signature = UNDI_DEV_SIGNATURE;
339 NicDevice->NiiProtocol.
Revision = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION;
340 NicDevice->NiiProtocol.
Type = EfiNetworkInterfaceUndi;
342 NicDevice->NiiProtocol.
MinorVer = PXE_ROMID_MINORVER;
347 NicDevice->NiiProtocol.
StringId[0] =
'U';
348 NicDevice->NiiProtocol.
StringId[1] =
'N';
349 NicDevice->NiiProtocol.
StringId[2] =
'D';
350 NicDevice->NiiProtocol.
StringId[3] =
'I';
351 NicDevice->DeviceHandle =
NULL;
353 NicDevice->NicInfo.RateLimitingEnable = gRateLimitingEnable;
354 NicDevice->NicInfo.RateLimitingCreditCount = 0;
355 NicDevice->NicInfo.RateLimitingCredit = gRateLimitingCredit;
356 NicDevice->NicInfo.RateLimitingPollTimer = gRateLimitingPollTimer;
357 NicDevice->NicInfo.RateLimiter =
NULL;
361 Status = UsbEth->UsbEthInterrupt (UsbEth,
TRUE, NETWORK_COMMON_POLLING_INTERVAL, &NicDevice->NicInfo.Request);
364 Status =
gBS->InstallMultipleProtocolInterfaces (
365 &NicDevice->DeviceHandle,
366 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
367 &NicDevice->NiiProtocol,
368 &gEfiDevicePathProtocolGuid,
373 if (EFI_ERROR (Status)) {
374 if (NicDevice->NiiProtocol.
IfNum < MAX_LAN_INTERFACE) {
375 gLanDeviceList[NicDevice->NiiProtocol.
IfNum] =
NULL;
380 &gEfiDevicePathProtocolGuid,
381 This->DriverBindingHandle,
386 &gEdkIIUsbEthProtocolGuid,
387 This->DriverBindingHandle,
391 if (TmpPxePointer !=
NULL) {
395 if (NicDevice->DevPath !=
NULL) {
399 if (NicDevice !=
NULL) {
403 return EFI_DEVICE_ERROR;
406 Status =
gBS->OpenProtocol (
408 &gEdkIIUsbEthProtocolGuid,
410 This->DriverBindingHandle,
411 NicDevice->DeviceHandle,
412 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
441 BOOLEAN AllChildrenStopped;
447 if (NumberOfChildren == 0) {
448 Status =
gBS->OpenProtocol (
450 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
451 (VOID **)&NiiProtocol,
452 This->DriverBindingHandle,
454 EFI_OPEN_PROTOCOL_GET_PROTOCOL
457 if (EFI_ERROR (Status)) {
460 &gEfiDevicePathProtocolGuid,
461 This->DriverBindingHandle,
466 &gEdkIIUsbEthProtocolGuid,
467 This->DriverBindingHandle,
473 NicDevice = UNDI_DEV_FROM_THIS (NiiProtocol);
474 Status =
gBS->UninstallMultipleProtocolInterfaces (
476 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
477 &NicDevice->NiiProtocol,
478 &gEfiDevicePathProtocolGuid,
482 if (EFI_ERROR (Status)) {
491 &gEfiDevicePathProtocolGuid,
492 This->DriverBindingHandle,
497 &gEdkIIUsbEthProtocolGuid,
498 This->DriverBindingHandle,
504 AllChildrenStopped =
TRUE;
506 for (Index = 0; Index < NumberOfChildren; Index++) {
507 Status =
gBS->OpenProtocol (
508 ChildHandleBuffer[Index],
509 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
510 (VOID **)&NiiProtocol,
511 This->DriverBindingHandle,
513 EFI_OPEN_PROTOCOL_GET_PROTOCOL
515 if (EFI_ERROR (Status)) {
516 AllChildrenStopped =
FALSE;
520 NicDevice = UNDI_DEV_FROM_THIS (NiiProtocol);
524 &gEdkIIUsbEthProtocolGuid,
525 This->DriverBindingHandle,
526 ChildHandleBuffer[Index]
529 Status =
gBS->UninstallMultipleProtocolInterfaces (
530 ChildHandleBuffer[Index],
531 &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
532 &NicDevice->NiiProtocol,
533 &gEfiDevicePathProtocolGuid,
537 if (EFI_ERROR (Status)) {
538 Status =
gBS->OpenProtocol (
540 &gEdkIIUsbEthProtocolGuid,
542 This->DriverBindingHandle,
543 ChildHandleBuffer[Index],
544 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
552 if (!AllChildrenStopped) {
553 return EFI_DEVICE_ERROR;
581 gNetworkCommonDriverBinding.
ImageHandle = ImageHandle;
582 gRateLimitingEnable =
PcdGetBool (PcdEnableUsbNetworkRateLimiting);
583 gRateLimitingCredit =
PcdGet32 (PcdUsbNetworkRateLimitingCredit);
584 gRateLimitingPollTimer =
PcdGet32 (PcdUsbNetworkRateLimitingFactor);
586 Status =
gBS->InstallMultipleProtocolInterfaces (
588 &gEfiDriverBindingProtocolGuid,
589 &gNetworkCommonDriverBinding,
590 &gEfiComponentName2ProtocolGuid,
591 &gNetworkCommonComponentName2,
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define MESSAGING_DEVICE_PATH
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI NetworkCommonDriverStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI NetworkCommonSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI NetworkCommonDriverStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS CreateMacDevicePath(IN OUT EFI_DEVICE_PATH_PROTOCOL **Dev, IN EFI_DEVICE_PATH_PROTOCOL *BaseDev, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI NetworkCommonEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID PxeStructInit(OUT PXE_SW_UNDI *PxeSw)
VOID UpdateNicNum(IN NIC_DATA *Nic, IN OUT PXE_SW_UNDI *PxeSw)
#define ALIGN_POINTER(Pointer, Alignment)
#define ASSERT_EFI_ERROR(StatusParameter)
#define PcdGet32(TokenName)
#define PcdGetBool(TokenName)
#define PXE_ROMID_MAJORVER
EFI_HANDLE DriverBindingHandle
UINT8 MajorVer
Major version number.
UINT32 ImageSize
The size of unrelocated network interface image.
UINT64 Revision
The revision of the EFI_NETWORK_INTERFACE_IDENTIFIER protocol.
UINT8 MinorVer
Minor version number.
BOOLEAN Ipv6Supported
TRUE if the network interface supports IPv6; otherwise FALSE.
EFI_MAC_ADDRESS MacAddress
PXE_UINT8 IFcnt
physical connector count lower byte.
PXE_UINT8 IFcntExt
physical connector count upper byte.