3 Copyright (c) 2006, 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
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.
18 Initialization functions for EFI UNDI32 driver
29 PXE_SW_UNDI
*pxe
= 0; // 3.0 entry point
30 PXE_SW_UNDI
*pxe_31
= 0; // 3.1 entry
31 UNDI32_DEV
*UNDI32DeviceList
[MAX_NIC_INTERFACES
];
33 NII_TABLE
*UnidiDataPointer
=NULL
;
35 // external Global Variables
37 extern UNDI_CALL_TABLE api_table
[];
40 // function prototypes
49 InitializeUNDIDriver (
50 IN EFI_HANDLE ImageHandle
,
51 IN EFI_SYSTEM_TABLE
*SystemTable
70 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
71 IN EFI_HANDLE Controller
,
72 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
78 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
79 IN EFI_HANDLE Controller
,
80 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
86 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
87 IN EFI_HANDLE Controller
,
88 IN UINTN NumberOfChildren
,
89 IN EFI_HANDLE
*ChildHandleBuffer
94 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevPtr
,
95 IN EFI_DEVICE_PATH_PROTOCOL
*BaseDevPtr
,
96 IN NIC_DATA_INSTANCE
*AdapterInfo
99 // end function prototypes
111 When address mapping changes to virtual this should make the appropriate
116 (Standard Event handler)
123 // TODO: Context - add argument and description to function comment
128 if (pxe_31
!= NULL
) {
129 Pxe31Pointer
= (VOID
*) pxe_31
;
132 EFI_OPTIONAL_POINTER
,
133 (void **) &Pxe31Pointer
137 // UNDI32DeviceList is an array of pointers
139 for (Index
= 0; Index
< pxe_31
->IFcnt
; Index
++) {
140 UNDI32DeviceList
[Index
]->NIIProtocol_31
.ID
= (UINT64
) (UINTN
) Pxe31Pointer
;
142 EFI_OPTIONAL_POINTER
,
143 (void **) &(UNDI32DeviceList
[Index
])
148 EFI_OPTIONAL_POINTER
,
149 (void **) &(pxe_31
->EntryPoint
)
151 pxe_31
= Pxe31Pointer
;
154 for (Index
= 0; Index
<= PXE_OPCODE_LAST_VALID
; Index
++) {
156 EFI_OPTIONAL_POINTER
,
157 (void **) &api_table
[Index
].api_ptr
172 When EFI is shuting down the boot services, we need to install a
173 configuration table for UNDI to work at runtime!
177 (Standard Event handler)
184 // TODO: Context - add argument and description to function comment
186 InstallConfigTable ();
189 // UNDI Class Driver Global Variables
191 EFI_DRIVER_BINDING_PROTOCOL gUndiDriverBinding
= {
202 InitializeUNDIDriver (
203 IN EFI_HANDLE ImageHandle
,
204 IN EFI_SYSTEM_TABLE
*SystemTable
210 Register Driver Binding protocol for this driver.
214 ImageHandle - Image Handle
216 SystemTable - Pointer to system table
220 EFI_SUCCESS - Driver loaded.
222 other - Driver not loaded.
229 Status
= gBS
->CreateEvent (
230 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
,
242 UndiDriverSupported (
243 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
244 IN EFI_HANDLE Controller
,
245 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
251 Test to see if this driver supports ControllerHandle. Any ControllerHandle
252 than contains a DevicePath, PciIo protocol, Class code of 2, Vendor ID of 0x8086,
253 and DeviceId of (D100_DEVICE_ID || D102_DEVICE_ID || ICH3_DEVICE_ID_1 ||
254 ICH3_DEVICE_ID_2 || ICH3_DEVICE_ID_3 || ICH3_DEVICE_ID_4 || ICH3_DEVICE_ID_5 ||
255 ICH3_DEVICE_ID_6 || ICH3_DEVICE_ID_7 || ICH3_DEVICE_ID_8) can be supported.
259 This - Protocol instance pointer.
261 Controller - Handle of device to test.
263 RemainingDevicePath - Not used.
267 EFI_SUCCESS - This driver supports this device.
269 other - This driver does not support this device.
274 EFI_PCI_IO_PROTOCOL
*PciIo
;
277 Status
= gBS
->OpenProtocol (
279 &gEfiDevicePathProtocolGuid
,
281 This
->DriverBindingHandle
,
283 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
285 if (EFI_ERROR (Status
)) {
289 Status
= gBS
->OpenProtocol (
291 &gEfiPciIoProtocolGuid
,
293 This
->DriverBindingHandle
,
295 EFI_OPEN_PROTOCOL_BY_DRIVER
297 if (EFI_ERROR (Status
)) {
301 Status
= PciIo
->Pci
.Read (
305 sizeof (PCI_CONFIG_HEADER
),
309 if (!EFI_ERROR (Status
)) {
310 Status
= EFI_UNSUPPORTED
;
312 if (Pci
.Hdr
.ClassCode
[2] == 0x02 && Pci
.Hdr
.VendorId
== PCI_VENDOR_ID_INTEL
) {
313 switch (Pci
.Hdr
.DeviceId
) {
316 case ICH3_DEVICE_ID_1
:
317 case ICH3_DEVICE_ID_2
:
318 case ICH3_DEVICE_ID_3
:
319 case ICH3_DEVICE_ID_4
:
320 case ICH3_DEVICE_ID_5
:
321 case ICH3_DEVICE_ID_6
:
322 case ICH3_DEVICE_ID_7
:
323 case ICH3_DEVICE_ID_8
:
340 Status
= EFI_SUCCESS
;
347 &gEfiPciIoProtocolGuid
,
348 This
->DriverBindingHandle
,
358 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
359 IN EFI_HANDLE Controller
,
360 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
366 Start this driver on Controller by opening PciIo and DevicePath protocol.
367 Initialize PXE structures, create a copy of the Controller Device Path with the
368 NIC's MAC address appended to it, install the NetworkInterfaceIdentifier protocol
369 on the newly created Device Path.
373 This - Protocol instance pointer.
375 Controller - Handle of device to work with.
377 RemainingDevicePath - Not used, always produce all possible children.
381 EFI_SUCCESS - This driver is added to Controller.
383 other - This driver does not support this device.
388 EFI_DEVICE_PATH_PROTOCOL
*UndiDevicePath
;
389 PCI_CONFIG_HEADER
*CfgHdr
;
390 UNDI32_DEV
*UNDI32Device
;
392 UINT8
*TmpPxePointer
;
393 EFI_PCI_IO_PROTOCOL
*PciIoFncs
;
396 Status
= gBS
->OpenProtocol (
398 &gEfiPciIoProtocolGuid
,
399 (VOID
**) &PciIoFncs
,
400 This
->DriverBindingHandle
,
402 EFI_OPEN_PROTOCOL_BY_DRIVER
405 if (EFI_ERROR (Status
)) {
409 Status
= gBS
->OpenProtocol (
411 &gEfiDevicePathProtocolGuid
,
412 (VOID
**) &UndiDevicePath
,
413 This
->DriverBindingHandle
,
415 EFI_OPEN_PROTOCOL_BY_DRIVER
418 if (EFI_ERROR (Status
)) {
421 &gEfiPciIoProtocolGuid
,
422 This
->DriverBindingHandle
,
429 Status
= gBS
->AllocatePool (
430 EfiRuntimeServicesData
,
432 (VOID
**) &UNDI32Device
435 if (EFI_ERROR (Status
)) {
439 ZeroMem ((CHAR8
*) UNDI32Device
, sizeof (UNDI32_DEV
));
442 // allocate and initialize both (old and new) the !pxe structures here,
443 // there should only be one copy of each of these structure for any number
444 // of NICs this undi supports. Also, these structures need to be on a
445 // paragraph boundary as per the spec. so, while allocating space for these,
446 // make sure that there is space for 2 !pxe structures (old and new) and a
447 // 32 bytes padding for alignment adjustment (in case)
449 TmpPxePointer
= NULL
;
450 if (pxe_31
== NULL
) {
451 Status
= gBS
->AllocatePool (
452 EfiRuntimeServicesData
,
453 (sizeof (PXE_SW_UNDI
) + sizeof (PXE_SW_UNDI
) + 32),
454 (VOID
**) &TmpPxePointer
457 if (EFI_ERROR (Status
)) {
458 goto UndiErrorDeleteDevice
;
463 sizeof (PXE_SW_UNDI
) + sizeof (PXE_SW_UNDI
) + 32
466 // check for paragraph alignment here, assuming that the pointer is
467 // already 8 byte aligned.
469 if (((UINTN
) TmpPxePointer
& 0x0F) != 0) {
470 pxe_31
= (PXE_SW_UNDI
*) ((UINTN
) (TmpPxePointer
+ 8));
472 pxe_31
= (PXE_SW_UNDI
*) TmpPxePointer
;
475 // assuming that the sizeof pxe_31 is a 16 byte multiple
477 pxe
= (PXE_SW_UNDI
*) ((CHAR8
*) (pxe_31
) + sizeof (PXE_SW_UNDI
));
479 PxeStructInit (pxe
, 0x30);
480 PxeStructInit (pxe_31
, 0x31);
483 UNDI32Device
->NIIProtocol
.ID
= (UINT64
) (UINTN
) (pxe
);
484 UNDI32Device
->NIIProtocol_31
.ID
= (UINT64
) (UINTN
) (pxe_31
);
486 Status
= PciIoFncs
->Attributes (
488 EfiPciIoAttributeOperationEnable
,
489 EFI_PCI_DEVICE_ENABLE
| EFI_PCI_IO_ATTRIBUTE_MEMORY
| EFI_PCI_IO_ATTRIBUTE_IO
| EFI_PCI_IO_ATTRIBUTE_BUS_MASTER
,
493 // Read all the registers from device's PCI Configuration space
495 Status
= PciIoFncs
->Pci
.Read (
500 &UNDI32Device
->NicInfo
.Config
503 CfgHdr
= (PCI_CONFIG_HEADER
*) &(UNDI32Device
->NicInfo
.Config
[0]);
506 // make sure that this device is a PCI bus master
509 NewCommand
= (UINT16
) (CfgHdr
->Command
| PCI_COMMAND_MASTER
| PCI_COMMAND_IO
);
510 if (CfgHdr
->Command
!= NewCommand
) {
511 PciIoFncs
->Pci
.Write (
518 CfgHdr
->Command
= NewCommand
;
522 // make sure that the latency timer is at least 32
524 if (CfgHdr
->LatencyTimer
< 32) {
525 CfgHdr
->LatencyTimer
= 32;
526 PciIoFncs
->Pci
.Write (
531 &CfgHdr
->LatencyTimer
535 // the IfNum index for the current interface will be the total number
536 // of interfaces initialized so far
538 UNDI32Device
->NIIProtocol
.IfNum
= pxe
->IFcnt
;
539 UNDI32Device
->NIIProtocol_31
.IfNum
= pxe_31
->IFcnt
;
541 PxeUpdate (&UNDI32Device
->NicInfo
, pxe
);
542 PxeUpdate (&UNDI32Device
->NicInfo
, pxe_31
);
544 UNDI32Device
->NicInfo
.Io_Function
= PciIoFncs
;
545 UNDI32DeviceList
[UNDI32Device
->NIIProtocol
.IfNum
] = UNDI32Device
;
546 UNDI32Device
->Undi32BaseDevPath
= UndiDevicePath
;
548 Status
= AppendMac2DevPath (
549 &UNDI32Device
->Undi32DevPath
,
550 UNDI32Device
->Undi32BaseDevPath
,
551 &UNDI32Device
->NicInfo
555 goto UndiErrorDeletePxe
;
558 UNDI32Device
->Signature
= UNDI_DEV_SIGNATURE
;
560 UNDI32Device
->NIIProtocol
.Revision
= EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION
;
561 UNDI32Device
->NIIProtocol
.Type
= EfiNetworkInterfaceUndi
;
562 UNDI32Device
->NIIProtocol
.MajorVer
= PXE_ROMID_MAJORVER
;
563 UNDI32Device
->NIIProtocol
.MinorVer
= PXE_ROMID_MINORVER
;
564 UNDI32Device
->NIIProtocol
.ImageSize
= 0;
565 UNDI32Device
->NIIProtocol
.ImageAddr
= 0;
566 UNDI32Device
->NIIProtocol
.Ipv6Supported
= FALSE
;
568 UNDI32Device
->NIIProtocol
.StringId
[0] = 'U';
569 UNDI32Device
->NIIProtocol
.StringId
[1] = 'N';
570 UNDI32Device
->NIIProtocol
.StringId
[2] = 'D';
571 UNDI32Device
->NIIProtocol
.StringId
[3] = 'I';
573 UNDI32Device
->NIIProtocol_31
.Revision
= EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31
;
574 UNDI32Device
->NIIProtocol_31
.Type
= EfiNetworkInterfaceUndi
;
575 UNDI32Device
->NIIProtocol_31
.MajorVer
= PXE_ROMID_MAJORVER
;
576 UNDI32Device
->NIIProtocol_31
.MinorVer
= PXE_ROMID_MINORVER_31
;
577 UNDI32Device
->NIIProtocol_31
.ImageSize
= 0;
578 UNDI32Device
->NIIProtocol_31
.ImageAddr
= 0;
579 UNDI32Device
->NIIProtocol_31
.Ipv6Supported
= FALSE
;
581 UNDI32Device
->NIIProtocol_31
.StringId
[0] = 'U';
582 UNDI32Device
->NIIProtocol_31
.StringId
[1] = 'N';
583 UNDI32Device
->NIIProtocol_31
.StringId
[2] = 'D';
584 UNDI32Device
->NIIProtocol_31
.StringId
[3] = 'I';
586 UNDI32Device
->DeviceHandle
= NULL
;
589 // install both the 3.0 and 3.1 NII protocols.
591 Status
= gBS
->InstallMultipleProtocolInterfaces (
592 &UNDI32Device
->DeviceHandle
,
593 &gEfiNetworkInterfaceIdentifierProtocolGuid_31
,
594 &UNDI32Device
->NIIProtocol_31
,
595 &gEfiNetworkInterfaceIdentifierProtocolGuid
,
596 &UNDI32Device
->NIIProtocol
,
597 &gEfiDevicePathProtocolGuid
,
598 UNDI32Device
->Undi32DevPath
,
602 if (EFI_ERROR (Status
)) {
603 goto UndiErrorDeleteDevicePath
;
607 // if the table exists, free it and alloc again, or alloc it directly
609 if (UnidiDataPointer
!= NULL
) {
610 Status
= gBS
->FreePool(UnidiDataPointer
);
612 if (EFI_ERROR (Status
)) {
613 goto UndiErrorDeleteDevicePath
;
616 Len
= (pxe_31
->IFcnt
* sizeof (NII_ENTRY
)) + sizeof (UnidiDataPointer
);
617 Status
= gBS
->AllocatePool (EfiRuntimeServicesData
, Len
, (VOID
**) &UnidiDataPointer
);
619 if (EFI_ERROR (Status
)) {
620 goto UndiErrorAllocDataPointer
;
624 // Open For Child Device
626 Status
= gBS
->OpenProtocol (
628 &gEfiPciIoProtocolGuid
,
629 (VOID
**) &PciIoFncs
,
630 This
->DriverBindingHandle
,
631 UNDI32Device
->DeviceHandle
,
632 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
636 UndiErrorAllocDataPointer
:
637 gBS
->UninstallMultipleProtocolInterfaces (
638 &UNDI32Device
->DeviceHandle
,
639 &gEfiNetworkInterfaceIdentifierProtocolGuid_31
,
640 &UNDI32Device
->NIIProtocol_31
,
641 &gEfiNetworkInterfaceIdentifierProtocolGuid
,
642 &UNDI32Device
->NIIProtocol
,
643 &gEfiDevicePathProtocolGuid
,
644 UNDI32Device
->Undi32DevPath
,
648 UndiErrorDeleteDevicePath
:
649 UNDI32DeviceList
[UNDI32Device
->NIIProtocol
.IfNum
] = NULL
;
650 gBS
->FreePool (UNDI32Device
->Undi32DevPath
);
653 PxeUpdate (NULL
, pxe
);
654 PxeUpdate (NULL
, pxe_31
);
655 if (TmpPxePointer
!= NULL
) {
656 gBS
->FreePool (TmpPxePointer
);
660 UndiErrorDeleteDevice
:
661 gBS
->FreePool (UNDI32Device
);
666 &gEfiDevicePathProtocolGuid
,
667 This
->DriverBindingHandle
,
673 &gEfiPciIoProtocolGuid
,
674 This
->DriverBindingHandle
,
684 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
685 IN EFI_HANDLE Controller
,
686 IN UINTN NumberOfChildren
,
687 IN EFI_HANDLE
*ChildHandleBuffer
692 Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and
693 closing the DevicePath and PciIo protocols on Controller.
696 This - Protocol instance pointer.
697 Controller - Handle of device to stop driver on.
698 NumberOfChildren - How many children need to be stopped.
699 ChildHandleBuffer - Not used.
702 EFI_SUCCESS - This driver is removed Controller.
703 other - This driver was not removed from this device.
706 // TODO: EFI_DEVICE_ERROR - add return value to function comment
709 BOOLEAN AllChildrenStopped
;
711 UNDI32_DEV
*UNDI32Device
;
712 EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL
*NIIProtocol
;
713 EFI_PCI_IO_PROTOCOL
*PciIo
;
716 // Complete all outstanding transactions to Controller.
717 // Don't allow any new transaction to Controller to be started.
719 if (NumberOfChildren
== 0) {
722 // Close the bus driver
724 Status
= gBS
->CloseProtocol (
726 &gEfiDevicePathProtocolGuid
,
727 This
->DriverBindingHandle
,
731 Status
= gBS
->CloseProtocol (
733 &gEfiPciIoProtocolGuid
,
734 This
->DriverBindingHandle
,
741 AllChildrenStopped
= TRUE
;
743 for (Index
= 0; Index
< NumberOfChildren
; Index
++) {
745 Status
= gBS
->OpenProtocol (
746 ChildHandleBuffer
[Index
],
747 &gEfiNetworkInterfaceIdentifierProtocolGuid
,
748 (VOID
**) &NIIProtocol
,
749 This
->DriverBindingHandle
,
751 EFI_OPEN_PROTOCOL_GET_PROTOCOL
753 if (!EFI_ERROR (Status
)) {
755 UNDI32Device
= UNDI_DEV_FROM_THIS (NIIProtocol
);
757 Status
= gBS
->CloseProtocol (
759 &gEfiPciIoProtocolGuid
,
760 This
->DriverBindingHandle
,
761 ChildHandleBuffer
[Index
]
764 Status
= gBS
->UninstallMultipleProtocolInterfaces (
765 ChildHandleBuffer
[Index
],
766 &gEfiDevicePathProtocolGuid
,
767 UNDI32Device
->Undi32DevPath
,
768 &gEfiNetworkInterfaceIdentifierProtocolGuid_31
,
769 &UNDI32Device
->NIIProtocol_31
,
770 &gEfiNetworkInterfaceIdentifierProtocolGuid
,
771 &UNDI32Device
->NIIProtocol
,
775 if (EFI_ERROR (Status
)) {
778 &gEfiPciIoProtocolGuid
,
780 This
->DriverBindingHandle
,
781 ChildHandleBuffer
[Index
],
782 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
785 gBS
->FreePool (UNDI32Device
->Undi32DevPath
);
786 gBS
->FreePool (UNDI32Device
);
790 if (EFI_ERROR (Status
)) {
791 AllChildrenStopped
= FALSE
;
795 if (!AllChildrenStopped
) {
796 return EFI_DEVICE_ERROR
;
806 IN UINTN MicroSeconds
812 Use the EFI boot services to produce a pause. This is also the routine which
813 gets replaced during RunTime by the O/S in the NIC_DATA_INSTANCE so it can
818 UnqId - Runtime O/S routine might use this, this temp routine does not use it
820 MicroSeconds - Determines the length of pause.
828 gBS
->Stall ((UINT32
) MicroSeconds
);
843 Use the PCI IO abstraction to issue memory or I/O reads and writes. This is also the routine which
844 gets replaced during RunTime by the O/S in the NIC_DATA_INSTANCE so it can do it's own I/O abstractions.
848 UnqId - Runtime O/S routine may use this field, this temp routine does not.
850 ReadWrite - Determine if it is an I/O or Memory Read/Write Operation.
852 Len - Determines the width of the data operation.
854 Port - What port to Read/Write from.
856 BuffAddr - Address to read to or write from.
864 EFI_PCI_IO_PROTOCOL_WIDTH Width
;
865 NIC_DATA_INSTANCE
*AdapterInfo
;
868 AdapterInfo
= (NIC_DATA_INSTANCE
*) (UINTN
) UnqId
;
885 AdapterInfo
->Io_Function
->Io
.Read (
886 AdapterInfo
->Io_Function
,
891 (VOID
*) (UINTN
) (BuffAddr
)
896 AdapterInfo
->Io_Function
->Io
.Write (
897 AdapterInfo
->Io_Function
,
902 (VOID
*) (UINTN
) (BuffAddr
)
907 AdapterInfo
->Io_Function
->Mem
.Read (
908 AdapterInfo
->Io_Function
,
913 (VOID
*) (UINTN
) (BuffAddr
)
918 AdapterInfo
->Io_Function
->Mem
.Write (
919 AdapterInfo
->Io_Function
,
924 (VOID
*) (UINTN
) (BuffAddr
)
934 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevPtr
,
935 IN EFI_DEVICE_PATH_PROTOCOL
*BaseDevPtr
,
936 IN NIC_DATA_INSTANCE
*AdapterInfo
942 Using the NIC data structure information, read the EEPROM to get the MAC address and then allocate space
943 for a new devicepath (**DevPtr) which will contain the original device path the NIC was found on (*BaseDevPtr)
944 and an added MAC node.
948 DevPtr - Pointer which will point to the newly created device path with the MAC node attached.
950 BaseDevPtr - Pointer to the device path which the UNDI device driver is latching on to.
952 AdapterInfo - Pointer to the NIC data structure information which the UNDI driver is layering on..
956 EFI_SUCCESS - A MAC address was successfully appended to the Base Device Path.
958 other - Not enough resources available to create new Device Path node.
962 EFI_MAC_ADDRESS MACAddress
;
963 PCI_CONFIG_HEADER
*CfgHdr
;
968 MAC_ADDR_DEVICE_PATH MacAddrNode
;
969 EFI_DEVICE_PATH_PROTOCOL
*EndNode
;
976 // set the environment ready (similar to UNDI_Start call) so that we can
977 // execute the other UNDI_ calls to get the mac address
978 // we are using undi 3.1 style
980 AdapterInfo
->Delay
= TmpDelay
;
981 AdapterInfo
->Virt2Phys
= (VOID
*) 0;
982 AdapterInfo
->Block
= (VOID
*) 0;
983 AdapterInfo
->Map_Mem
= (VOID
*) 0;
984 AdapterInfo
->UnMap_Mem
= (VOID
*) 0;
985 AdapterInfo
->Sync_Mem
= (VOID
*) 0;
986 AdapterInfo
->Mem_Io
= TmpMemIo
;
988 // these tmp call-backs follow 3.1 undi style
989 // i.e. they have the unique_id parameter.
991 AdapterInfo
->VersionFlag
= 0x31;
992 AdapterInfo
->Unique_ID
= (UINT64
) (UINTN
) AdapterInfo
;
997 CfgHdr
= (PCI_CONFIG_HEADER
*) &(AdapterInfo
->Config
[0]);
998 AdapterInfo
->ioaddr
= 0;
999 AdapterInfo
->RevID
= CfgHdr
->RevID
;
1001 AddrLen
= E100bGetEepromAddrLen (AdapterInfo
);
1003 for (Index
= 0, Index2
= 0; Index
< 3; Index
++) {
1004 Val
= E100bReadEeprom (AdapterInfo
, Index
, AddrLen
);
1005 MACAddress
.Addr
[Index2
++] = (UINT8
) Val
;
1006 MACAddress
.Addr
[Index2
++] = (UINT8
) (Val
>> 8);
1009 SetMem (MACAddress
.Addr
+ Index2
, sizeof (EFI_MAC_ADDRESS
) - Index2
, 0);
1010 //for (; Index2 < sizeof (EFI_MAC_ADDRESS); Index2++) {
1011 // MACAddress.Addr[Index2] = 0;
1016 AdapterInfo
->Delay
= (VOID
*) 0;
1017 AdapterInfo
->Mem_Io
= (VOID
*) 0;
1020 // fill the mac address node first
1022 ZeroMem ((CHAR8
*) &MacAddrNode
, sizeof MacAddrNode
);
1024 (CHAR8
*) &MacAddrNode
.MacAddress
,
1025 (CHAR8
*) &MACAddress
,
1026 sizeof (EFI_MAC_ADDRESS
)
1029 MacAddrNode
.Header
.Type
= MESSAGING_DEVICE_PATH
;
1030 MacAddrNode
.Header
.SubType
= MSG_MAC_ADDR_DP
;
1031 MacAddrNode
.Header
.Length
[0] = sizeof (MacAddrNode
);
1032 MacAddrNode
.Header
.Length
[1] = 0;
1035 // find the size of the base dev path.
1037 EndNode
= BaseDevPtr
;
1039 while (!IsDevicePathEnd (EndNode
)) {
1040 EndNode
= NextDevicePathNode (EndNode
);
1043 BasePathLen
= (UINT16
) ((UINTN
) (EndNode
) - (UINTN
) (BaseDevPtr
));
1046 // create space for full dev path
1048 TotalPathLen
= (UINT16
) (BasePathLen
+ sizeof (MacAddrNode
) + sizeof (EFI_DEVICE_PATH_PROTOCOL
));
1050 Status
= gBS
->AllocatePool (
1051 EfiRuntimeServicesData
,
1053 (VOID
**) &DevicePtr
1056 if (Status
!= EFI_SUCCESS
) {
1060 // copy the base path, mac addr and end_dev_path nodes
1062 *DevPtr
= (EFI_DEVICE_PATH_PROTOCOL
*) DevicePtr
;
1063 CopyMem (DevicePtr
, (CHAR8
*) BaseDevPtr
, BasePathLen
);
1064 DevicePtr
+= BasePathLen
;
1065 CopyMem (DevicePtr
, (CHAR8
*) &MacAddrNode
, sizeof (MacAddrNode
));
1066 DevicePtr
+= sizeof (MacAddrNode
);
1067 CopyMem (DevicePtr
, (CHAR8
*) EndNode
, sizeof (EFI_DEVICE_PATH_PROTOCOL
));
1073 InstallConfigTable (
1078 Routine Description:
1080 Install a GUID/Pointer pair into the system's configuration table.
1088 EFI_SUCCESS - Install a GUID/Pointer pair into the system's configuration table.
1090 other - Did not successfully install the GUID/Pointer pair into the configuration table.
1093 // TODO: VOID - add argument and description to function comment
1096 EFI_CONFIGURATION_TABLE
*CfgPtr
;
1099 NII_TABLE
*UndiData
;
1101 if (pxe_31
== NULL
) {
1105 if(UnidiDataPointer
== NULL
) {
1109 UndiData
= (NII_TABLE
*)UnidiDataPointer
;
1111 UndiData
->NumEntries
= pxe_31
->IFcnt
;
1112 UndiData
->NextLink
= NULL
;
1114 for (Index
= 0; Index
< pxe_31
->IFcnt
; Index
++) {
1115 UndiData
->NiiEntry
[Index
].InterfacePointer
= &UNDI32DeviceList
[Index
]->NIIProtocol_31
;
1116 UndiData
->NiiEntry
[Index
].DevicePathPointer
= UNDI32DeviceList
[Index
]->Undi32DevPath
;
1120 // see if there is an entry in the config table already
1122 CfgPtr
= gST
->ConfigurationTable
;
1124 for (Index
= 0; Index
< gST
->NumberOfTableEntries
; Index
++) {
1125 Status
= CompareGuid (
1126 &CfgPtr
->VendorGuid
,
1127 &gEfiNetworkInterfaceIdentifierProtocolGuid_31
1129 if (Status
!= EFI_SUCCESS
) {
1136 if (Index
< gST
->NumberOfTableEntries
) {
1137 TmpData
= (NII_TABLE
*) CfgPtr
->VendorTable
;
1140 // go to the last link
1142 while (TmpData
->NextLink
!= NULL
) {
1143 TmpData
= TmpData
->NextLink
;
1146 TmpData
->NextLink
= UndiData
;
1151 UndiData
= (NII_TABLE
*) CfgPtr
->VendorTable
;
1155 // create an entry in the configuration table for our GUID
1157 Status
= gBS
->InstallConfigurationTable (
1158 &gEfiNetworkInterfaceIdentifierProtocolGuid_31
,