/** @file Gbe Library. All function in this library is available for PEI, DXE, and SMM, But do not support UEFI RUNTIME environment call. Copyright (c) 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /** Check whether GbE region is valid Check SPI region directly since GbE might be disabled in SW. @retval TRUE Gbe Region is valid @retval FALSE Gbe Region is invalid **/ BOOLEAN IsGbeRegionValid ( VOID ) { return SpiIsGbeRegionValid (); } /** Check whether GBE controller is enabled in the platform. @retval TRUE GbE is enabled @retval FALSE GbE is disabled **/ BOOLEAN IsGbePresent ( VOID ) { // // Check PCH Support // if (!PchIsGbeSupported ()) { return FALSE; } // // Check PMC strap/fuse // if (!PmcIsGbeSupported ()) { return FALSE; } // // Check GbE NVM // if (IsGbeRegionValid () == FALSE) { return FALSE; } return TRUE; } /** Verifies Gigabit Ethernet PCI Class Code @param [in] GbePciCfgBase GbE PCI Config Space Address @retval TRUE GbE Class Code match @retval FALSE GbE Class Code does not match **/ BOOLEAN STATIC GbeCheckClassCode ( UINT64 GbePciCfgBase ) { UINT8 BaseCode; UINT8 SubClassCode; SubClassCode = PciSegmentRead8 (GbePciCfgBase + PCI_CLASSCODE_OFFSET + 1); BaseCode = PciSegmentRead8 (GbePciCfgBase + PCI_CLASSCODE_OFFSET + 2); if ((BaseCode != PCI_CLASS_NETWORK) || (SubClassCode != PCI_CLASS_NETWORK_ETHERNET)) { DEBUG ((DEBUG_ERROR, "GbeCheckClassCode : BaseCode(0x%x) or ClassCode(0x%x) is not supported\n", BaseCode, SubClassCode)); ASSERT (FALSE); return FALSE; } return TRUE; } /** Checks if Gbe is Enabled or Disabled @retval BOOLEAN TRUE if device is enabled, FALSE otherwise. **/ BOOLEAN IsGbeEnabled ( VOID ) { UINT64 GbePciBase; GbePciBase = GbePciCfgBase (); if (PciSegmentRead32 (GbePciBase) != 0xFFFFFFFF) { return GbeCheckClassCode (GbePciBase); } return FALSE; }