summaryrefslogtreecommitdiff
path: root/Platform/Intel/AdvancedFeaturePkg/Ipmi/IpmiInit/PeiIpmiInit.c
diff options
context:
space:
mode:
Diffstat (limited to 'Platform/Intel/AdvancedFeaturePkg/Ipmi/IpmiInit/PeiIpmiInit.c')
-rw-r--r--Platform/Intel/AdvancedFeaturePkg/Ipmi/IpmiInit/PeiIpmiInit.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/Platform/Intel/AdvancedFeaturePkg/Ipmi/IpmiInit/PeiIpmiInit.c b/Platform/Intel/AdvancedFeaturePkg/Ipmi/IpmiInit/PeiIpmiInit.c
new file mode 100644
index 0000000000..962aff6f4b
--- /dev/null
+++ b/Platform/Intel/AdvancedFeaturePkg/Ipmi/IpmiInit/PeiIpmiInit.c
@@ -0,0 +1,95 @@
+/** @file
+ IPMI stack initialization in PEI.
+
+Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/TimerLib.h>
+#include <Library/IpmiCommandLib.h>
+
+#define BMC_TIMEOUT_PEI 50 // [s] How long shall BIOS wait for BMC
+#define BMC_KCS_TIMEOUT 5 // [s] Single KSC request timeout
+
+EFI_STATUS
+GetDeviceId (
+ OUT BOOLEAN *UpdateMode
+ )
+/*++
+
+Routine Description:
+ Execute the Get Device ID command to determine whether or not the BMC is in Force Update
+ Mode. If it is, then report it to the error manager.
+
+Arguments:
+
+Returns:
+ Status
+
+--*/
+{
+ EFI_STATUS Status;
+ IPMI_GET_DEVICE_ID_RESPONSE BmcInfo;
+ UINT32 Retries;
+
+ //
+ // Set up a loop to retry for up to 30 seconds. Calculate retries not timeout
+ // so that in case KCS is not enabled and EfiIpmiSendCommand() returns
+ // immediately we will not wait all the 30 seconds.
+ //
+ Retries = BMC_TIMEOUT_PEI/ BMC_KCS_TIMEOUT + 1;
+ //
+ // Get the device ID information for the BMC.
+ //
+ do {
+ Status = IpmiGetDeviceId (&BmcInfo);
+ if (!EFI_ERROR(Status)) {
+ break;
+ }
+ DEBUG ((DEBUG_ERROR, "[IPMI] BMC does not respond (status: %r), %d retries left\n", Status, Retries));
+ if (Retries-- == 0) {
+ return Status;
+ }
+ } while (TRUE);
+
+ DEBUG((DEBUG_INFO, "[IPMI] BMC Device ID: 0x%02X, firmware version: %d.%02X\n", BmcInfo.DeviceId, BmcInfo.MajorFirmwareRev, BmcInfo.MinorFirmwareRev));
+ *UpdateMode = (BOOLEAN)BmcInfo.UpdateMode;
+ return Status;
+}
+
+/**
+ The entry point of the Ipmi PEIM.
+
+ @param FileHandle Handle of the file being invoked.
+ @param PeiServices Describes the list of possible PEI Services.
+
+ @retval EFI_SUCCESS Indicates that Ipmi initialization completed successfully.
+**/
+EFI_STATUS
+EFIAPI
+PeimIpmiInterfaceInit (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ BOOLEAN UpdateMode;
+ EFI_STATUS Status;
+
+ DEBUG((EFI_D_ERROR,"IPMI Peim:Get BMC Device Id\n"));
+
+ //
+ // Get the Device ID and check if the system is in Force Update mode.
+ //
+ Status = GetDeviceId (&UpdateMode);
+ return EFI_SUCCESS;
+}