/** @file\r
\r
-Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions\r
\r
@param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
@param Ax PCI address of Undi device.\r
- \r
- @retval EFI_DEVICE_ERROR Fail to start 16 bit UNDI ROM. \r
- @retval Others Status of start 16 bit UNDI ROM. \r
+\r
+ @retval EFI_DEVICE_ERROR Fail to start 16 bit UNDI ROM.\r
+ @retval Others Status of start 16 bit UNDI ROM.\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkStartUndi (\r
Start the UNDI interface\r
\r
@param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
- \r
- @retval EFI_DEVICE_ERROR Fail to start 16 bit UNDI ROM. \r
- @retval Others Status of start 16 bit UNDI ROM. \r
+\r
+ @retval EFI_DEVICE_ERROR Fail to start 16 bit UNDI ROM.\r
+ @retval Others Status of start 16 bit UNDI ROM.\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkStopUndi (\r
Stop the UNDI interface\r
\r
@param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
- \r
- @retval EFI_DEVICE_ERROR Fail to stop 16 bit UNDI ROM. \r
- @retval Others Status of stop 16 bit UNDI ROM. \r
+\r
+ @retval EFI_DEVICE_ERROR Fail to stop 16 bit UNDI ROM.\r
+ @retval Others Status of stop 16 bit UNDI ROM.\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkCleanupUndi (\r
Get runtime information for Undi network interface\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
- \r
- @retval EFI_SUCCESS Sucess operation. \r
- @retval Others Fail to get runtime information for Undi network interface. \r
+\r
+ @retval EFI_SUCCESS Sucess operation.\r
+ @retval Others Fail to get runtime information for Undi network interface.\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkGetInformation (\r
Get NIC type\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
- \r
- @retval EFI_SUCCESS Sucess operation. \r
+\r
+ @retval EFI_SUCCESS Sucess operation.\r
@retval Others Fail to get NIC type.\r
**/\r
EFI_STATUS\r
Get NDIS information\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
- \r
- @retval EFI_SUCCESS Sucess operation. \r
+\r
+ @retval EFI_SUCCESS Sucess operation.\r
@retval Others Fail to get NDIS information.\r
**/\r
EFI_STATUS\r
\r
/**\r
Signal handlers for ExitBootServices event.\r
- \r
- Clean up any Real-mode UNDI residue from the system \r
- \r
+\r
+ Clean up any Real-mode UNDI residue from the system\r
+\r
@param Event ExitBootServices event\r
- @param Context \r
+ @param Context\r
**/\r
VOID\r
EFIAPI\r
Loads the undi driver.\r
\r
@param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
- \r
+\r
@retval EFI_SUCCESS - Successfully loads undi driver.\r
@retval EFI_NOT_FOUND - Doesn't find undi driver or undi driver load failure.\r
**/\r
Unload 16 bit UNDI Option ROM from memory\r
\r
@param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
- \r
- @return EFI_STATUS \r
+\r
+ @return EFI_STATUS\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkUnloadUndi (\r
\r
@param ImageHandle Handle that identifies the loaded image.\r
@param SystemTable System Table for this image.\r
- \r
- @return EFI_STATUS Return status from EfiLibInstallAllDriverProtocols. \r
+\r
+ @return EFI_STATUS Return status from EfiLibInstallAllDriverProtocols.\r
**/\r
EFI_STATUS\r
EFIAPI\r
@param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
@param Controller The handle of the controller to test.\r
@param RemainingDevicePath A pointer to the remaining portion of a device path.\r
- \r
+\r
@retval EFI_SUCCESS The driver supports given controller.\r
@retval EFI_UNSUPPORT The driver doesn't support given controller.\r
@retval Other Other errors prevent driver finishing to test\r
@param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
@param Controller The handle of the controller to test.\r
@param RemainingDevicePath A pointer to the remaining portion of a device path.\r
- \r
- @retval EFI_SUCCESS - The device was started. \r
+\r
+ @retval EFI_SUCCESS - The device was started.\r
@retval EFI_DEVICE_ERROR - The device could not be started due to a device error.\r
@retval EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources.\r
**/\r
&Supports\r
);\r
if (!EFI_ERROR (Status)) {\r
- Supports &= EFI_PCI_DEVICE_ENABLE;\r
+ Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
Status = PciIo->Attributes (\r
PciIo,\r
EfiPciIoAttributeOperationEnable,\r
// Create an event to be signalled when Legacy Boot occurs to clean up the IVT\r
//\r
Status = EfiCreateEventLegacyBootEx(\r
- TPL_NOTIFY, \r
- Undi16SimpleNetworkEvent, \r
- NULL, \r
+ TPL_NOTIFY,\r
+ Undi16SimpleNetworkEvent,\r
+ NULL,\r
&SimpleNetworkDevice->LegacyBootEvent\r
);\r
- \r
+\r
if (EFI_ERROR(Status)) {\r
DEBUG ((DEBUG_ERROR,"ERROR : Could not create event. Status = %r\n",Status));\r
goto Done;\r
if (SimpleNetworkDevice->LegacyBootEvent != NULL) {\r
gBS->CloseEvent (SimpleNetworkDevice->LegacyBootEvent);\r
}\r
- \r
+\r
if (SimpleNetworkDevice->EfiBootEvent != NULL) {\r
gBS->CloseEvent (SimpleNetworkDevice->EfiBootEvent);\r
}\r
}\r
\r
gBS->FreePool (SimpleNetworkDevice);\r
- \r
+\r
//\r
// Only restore the vector if it was cached.\r
//\r
&Supports\r
);\r
if (!EFI_ERROR (Status)) {\r
- Supports &= EFI_PCI_DEVICE_ENABLE;\r
+ Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
Status = PciIo->Attributes (\r
PciIo,\r
EfiPciIoAttributeOperationDisable,\r
if (Status != EFI_OUT_OF_RESOURCES) {\r
Status = EFI_DEVICE_ERROR;\r
}\r
- } \r
+ }\r
return Status;\r
}\r
\r
@param NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
@param ChildHandleBuffer An array of child handles to be freed. May be NULL if\r
NumberOfChildren is 0.\r
- \r
+\r
@retval EFI_SUCCESS - The device was stopped.\r
@retval EFI_DEVICE_ERROR - The device could not be stopped due to a device error.\r
**/\r
&Supports\r
);\r
if (!EFI_ERROR (Status)) {\r
- Supports &= EFI_PCI_DEVICE_ENABLE;\r
+ Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
Status = PciIo->Attributes (\r
PciIo,\r
EfiPciIoAttributeOperationDisable,\r
This->DriverBindingHandle,\r
Controller\r
);\r
- \r
+\r
if (EFI_ERROR (Status)) {\r
Status = EFI_DEVICE_ERROR;\r
}\r
if (SimpleNetworkDevice->LegacyBootEvent != NULL) {\r
gBS->CloseEvent (SimpleNetworkDevice->LegacyBootEvent);\r
}\r
- \r
+\r
if (SimpleNetworkDevice->EfiBootEvent != NULL) {\r
gBS->CloseEvent (SimpleNetworkDevice->EfiBootEvent);\r
}\r
Judge whether transmit FIFO is full.\r
\r
@param Fifo Point to trasmit FIFO structure.\r
- \r
+\r
@return BOOLEAN whether transmit FIFO is full.\r
**/\r
BOOLEAN\r
Judge whether transmit FIFO is empty.\r
\r
@param Fifo Point to trasmit FIFO structure.\r
- \r
+\r
@return BOOLEAN whether transmit FIFO is empty.\r
**/\r
BOOLEAN\r
\r
@param Fifo Point to trasmit FIFO structure.\r
@param Data The data point want to be added.\r
- \r
- @retval EFI_OUT_OF_RESOURCES FIFO is full \r
- @retval EFI_SUCCESS Success operation. \r
+\r
+ @retval EFI_OUT_OF_RESOURCES FIFO is full\r
+ @retval EFI_SUCCESS Success operation.\r
**/\r
EFI_STATUS\r
SimpleNetworkTransmitFifoAdd (\r
\r
@param Fifo Point to trasmit FIFO structure.\r
@param Data On return, point to the data point want to be got and removed.\r
- \r
- @retval EFI_OUT_OF_RESOURCES network transmit buffer is empty. \r
- @retval EFI_SUCCESS Success operation. \r
+\r
+ @retval EFI_OUT_OF_RESOURCES network transmit buffer is empty.\r
+ @retval EFI_SUCCESS Success operation.\r
**/\r
EFI_STATUS\r
SimpleNetworkTransmitFifoRemove (\r
Get recive filter setting according to EFI mask value.\r
\r
@param ReceiveFilterSetting filter setting EFI mask value.\r
- \r
+\r
@return UINT16 Undi filter setting value.\r
**/\r
UINT16\r
\r
/**\r
Get filter setting from multi cast buffer .\r
- \r
+\r
@param Mode Point to mode structure.\r
- @param McastBuffer The multi cast buffer \r
+ @param McastBuffer The multi cast buffer\r
@param HwAddressSize Size of filter value.\r
- \r
+\r
**/\r
VOID\r
Undi16GetMCastFilters (\r
Loads the undi driver.\r
\r
@param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
- \r
+\r
@retval EFI_SUCCESS - Successfully loads undi driver.\r
@retval EFI_NOT_FOUND - Doesn't find undi driver or undi driver load failure.\r
**/\r
PCI_EXPANSION_ROM_HEADER *PciExpansionRomHeader;\r
PCI_DATA_STRUCTURE *PciDataStructure;\r
PCI_TYPE00 Pci;\r
- \r
+\r
if (!mCachedInt1A) {\r
Status = CacheVectorAddress (0x1A);\r
if (!EFI_ERROR (Status)) {\r
- mCachedInt1A = TRUE; \r
+ mCachedInt1A = TRUE;\r
}\r
}\r
\r
\r
DEBUG ((DEBUG_INIT, "Option ROM found at %X\n", RomAddress));\r
\r
+ //\r
+ // If the pointer to the PCI Data Structure is invalid, no further images can be located.\r
+ // The PCI Data Structure must be DWORD aligned.\r
+ //\r
+ if (PciExpansionRomHeader->PcirOffset == 0 ||\r
+ (PciExpansionRomHeader->PcirOffset & 3) != 0 ||\r
+ RomAddress + PciExpansionRomHeader->PcirOffset + sizeof (PCI_DATA_STRUCTURE) > 0x100000) {\r
+ break;\r
+ }\r
+\r
PciDataStructure = (PCI_DATA_STRUCTURE *) (RomAddress + PciExpansionRomHeader->PcirOffset);\r
\r
if (PciDataStructure->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {\r
}\r
\r
DEBUG (\r
- (DEBUG_INIT, \r
+ (DEBUG_INIT,\r
"PCI device with matchinng VendorId and DeviceId (%d,%d)\n",\r
(UINTN) PciDataStructure->VendorId,\r
(UINTN) PciDataStructure->DeviceId)\r
if (!EFI_ERROR (Status)) {\r
return EFI_SUCCESS;\r
}\r
+\r
+ //\r
+ // Free resources allocated in LaunchBaseCode\r
+ //\r
+ Undi16SimpleNetworkUnloadUndi (SimpleNetworkDevice);\r
}\r
\r
return EFI_NOT_FOUND;\r
Unload 16 bit UNDI Option ROM from memory\r
\r
@param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
- \r
- @return EFI_STATUS \r
+\r
+ @return EFI_STATUS\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkUnloadUndi (\r
\r
@param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
@param Ax PCI address of Undi device.\r
- \r
- @retval EFI_DEVICE_ERROR Fail to start 16 bit UNDI ROM. \r
- @retval Others Status of start 16 bit UNDI ROM. \r
+\r
+ @retval EFI_DEVICE_ERROR Fail to start 16 bit UNDI ROM.\r
+ @retval Others Status of start 16 bit UNDI ROM.\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkStartUndi (\r
Stop the UNDI interface\r
\r
@param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
- \r
- @retval EFI_DEVICE_ERROR Fail to stop 16 bit UNDI ROM. \r
- @retval Others Status of stop 16 bit UNDI ROM. \r
+\r
+ @retval EFI_DEVICE_ERROR Fail to stop 16 bit UNDI ROM.\r
+ @retval Others Status of stop 16 bit UNDI ROM.\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkStopUndi (\r
Cleanup Unid network interface\r
\r
@param SimpleNetworkDevice A pointer to EFI_SIMPLE_NETWORK_DEV data structure.\r
- \r
- @retval EFI_DEVICE_ERROR Fail to cleanup 16 bit UNDI ROM. \r
- @retval Others Status of cleanup 16 bit UNDI ROM. \r
+\r
+ @retval EFI_DEVICE_ERROR Fail to cleanup 16 bit UNDI ROM.\r
+ @retval Others Status of cleanup 16 bit UNDI ROM.\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkCleanupUndi (\r
Get runtime information for Undi network interface\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
- \r
- @retval EFI_SUCCESS Sucess operation. \r
- @retval Others Fail to get runtime information for Undi network interface. \r
+\r
+ @retval EFI_SUCCESS Sucess operation.\r
+ @retval Others Fail to get runtime information for Undi network interface.\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkGetInformation (\r
Get NIC type\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
- \r
- @retval EFI_SUCCESS Sucess operation. \r
+\r
+ @retval EFI_SUCCESS Sucess operation.\r
@retval Others Fail to get NIC type.\r
**/\r
EFI_STATUS\r
Get NDIS information\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
- \r
- @retval EFI_SUCCESS Sucess operation. \r
+\r
+ @retval EFI_SUCCESS Sucess operation.\r
@retval Others Fail to get NDIS information.\r
**/\r
EFI_STATUS\r
@param Frame The frame buffer to process network interrupt.\r
@param ProtType The type network transmit protocol\r
@param PktType The type of package.\r
- \r
- @retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM's ISR, or status is invalid. \r
- @retval EFI_SUCCESS Success operation. \r
+\r
+ @retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM's ISR, or status is invalid.\r
+ @retval EFI_SUCCESS Success operation.\r
**/\r
EFI_STATUS\r
Undi16SimpleNetworkIsr (\r
\r
CopyMem (\r
Frame,\r
- (VOID *)(UINTN) ((SimpleNetworkDevice->Isr.FrameSegSel << 4) + SimpleNetworkDevice->Isr.FrameOffset),\r
+ (VOID *) (((UINTN) SimpleNetworkDevice->Isr.FrameSegSel << 4) + SimpleNetworkDevice->Isr.FrameOffset),\r
SimpleNetworkDevice->Isr.BufferLength\r
);\r
Frame = Frame + SimpleNetworkDevice->Isr.BufferLength;\r
Call 16 bit UNDI ROM to start the network interface\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
- \r
+\r
@retval EFI_DEVICE_ERROR Network interface has not be initialized.\r
@retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM call.\r
@retval EFI_SUCESS Success operation.\r
Call 16 bit UNDI ROM to stop the network interface\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
- \r
+\r
@retval EFI_DEVICE_ERROR Network interface has not be initialized.\r
@retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM call.\r
@retval EFI_SUCESS Success operation.\r
// Initialize()\r
//\r
/**\r
- Initialize network interface \r
+ Initialize network interface\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
@param ExtraRxBufferSize The size of extra request receive buffer.\r
@param ExtraTxBufferSize The size of extra request transmit buffer.\r
- \r
+\r
@retval EFI_DEVICE_ERROR Fail to execute 16 bit ROM call.\r
@retval EFI_SUCESS Success operation.\r
**/\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
@param ExtendedVerification Need extended verfication.\r
- \r
- @retval EFI_INVALID_PARAMETER Invalid This paramter.\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
@retval EFI_DEVICE_ERROR Network device has not been initialized.\r
@retval EFI_NOT_STARTED Network device has been stopped.\r
@retval EFI_DEVICE_ERROR Invalid status for network device\r
Shutdown network interface.\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
- \r
- @retval EFI_INVALID_PARAMETER Invalid This paramter.\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
@retval EFI_DEVICE_ERROR Network device has not been initialized.\r
@retval EFI_NOT_STARTED Network device has been stopped.\r
@retval EFI_DEVICE_ERROR Invalid status for network device\r
@param ResetMCastFilter Whether reset multi cast filter or not\r
@param MCastFilterCnt Count of mutli cast filter for different MAC address\r
@param MCastFilter Buffer for mustli cast filter for different MAC address.\r
- \r
- @retval EFI_INVALID_PARAMETER Invalid This paramter.\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
@retval EFI_DEVICE_ERROR Network device has not been initialized.\r
@retval EFI_NOT_STARTED Network device has been stopped.\r
@retval EFI_DEVICE_ERROR Invalid status for network device\r
&SimpleNetworkDevice->SimpleNetworkMode.MCastFilter[Index],\r
&MCastFilter[Index],\r
sizeof (EFI_MAC_ADDRESS)\r
- ); \r
+ );\r
}\r
}\r
//\r
Set new MAC address.\r
\r
@param This A pointer to EFI_SIMPLE_NETWORK_PROTOCOL structure.\r
- @param Reset Whether reset station MAC address to permenent address\r
+ @param Reset Whether reset station MAC address to permanent address\r
@param New A pointer to New address\r
- \r
- @retval EFI_INVALID_PARAMETER Invalid This paramter.\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
@retval EFI_DEVICE_ERROR Network device has not been initialized.\r
@retval EFI_NOT_STARTED Network device has been stopped.\r
@retval EFI_DEVICE_ERROR Invalid status for network device\r
\r
if (Reset) {\r
//\r
- // If we are reseting the Station Address to the permanent address, and the\r
+ // If we are resetting the Station Address to the permanent address, and the\r
// Station Address is not programmable, then just return EFI_SUCCESS.\r
//\r
if (!SimpleNetworkDevice->SimpleNetworkMode.MacAddressChangeable) {\r
@param IPv6 IPv6 or IPv4\r
@param IP A pointer to given Ip address.\r
@param MAC On return, translated MAC address.\r
- \r
- @retval EFI_INVALID_PARAMETER Invalid This paramter.\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid This parameter.\r
@retval EFI_INVALID_PARAMETER Invalid IP address.\r
@retval EFI_INVALID_PARAMETER Invalid return buffer for holding MAC address.\r
- @retval EFI_UNSUPPORTED Do not support IPv6 \r
+ @retval EFI_UNSUPPORTED Do not support IPv6\r
@retval EFI_DEVICE_ERROR Network device has not been initialized.\r
@retval EFI_NOT_STARTED Network device has been stopped.\r
@retval EFI_DEVICE_ERROR Invalid status for network device\r
// NvData()\r
//\r
/**\r
- Performs read and write operations on the NVRAM device attached to a \r
+ Performs read and write operations on the NVRAM device attached to a\r
network interface.\r
\r
@param This The protocol instance pointer.\r
// GetStatus()\r
//\r
/**\r
- Reads the current interrupt status and recycled transmit buffer status from \r
+ Reads the current interrupt status and recycled transmit buffer status from\r
a network interface.\r
\r
@param This The protocol instance pointer.\r
\r
@retval EFI_SUCCESS The packet was placed on the transmit queue.\r
@retval EFI_NOT_STARTED The network interface has not been started.\r
- @retval EFI_NOT_READY The network interface is too busy to accept this transmit request. \r
+ @retval EFI_NOT_READY The network interface is too busy to accept this transmit request.\r
@retval EFI_BUFFER_TOO_SMALL The BufferSize parameter is too small.\r
@retval EFI_INVALID_PARAMETER One or more of the parameters has an unsupported value.\r
@retval EFI_DEVICE_ERROR The command could not be sent to the network interface.\r
\r
/**\r
Receives a packet from a network interface.\r
- \r
+\r
@param This The protocol instance pointer.\r
@param HeaderSize The size, in bytes, of the media header received on the network\r
interface. If this parameter is NULL, then the media header size\r
\r
@param Event Event used with WaitForEvent() to wait for a packet to be received.\r
@param Context Event Context\r
- \r
+\r
**/\r
VOID\r
EFIAPI\r
Check whether packet is ready for receive.\r
\r
@param This The protocol instance pointer.\r
- \r
+\r
@retval EFI_SUCCESS Receive data is ready.\r
@retval EFI_NOT_STARTED The network interface has not been started.\r
@retval EFI_NOT_READY The network interface is too busy to accept this transmit\r
\r
/**\r
Signal handlers for ExitBootServices event.\r
- \r
- Clean up any Real-mode UNDI residue from the system \r
- \r
+\r
+ Clean up any Real-mode UNDI residue from the system\r
+\r
@param Event ExitBootServices event\r
- @param Context \r
+ @param Context\r
**/\r
VOID\r
EFIAPI\r
\r
@param NumPages The number pages want to be allocated.\r
@param Buffer On return, allocated buffer.\r
- \r
+\r
@return Status of allocating pages.\r
**/\r
EFI_STATUS\r