Hi,

I would like to propose to add Alert standard format support which is based
on ASF2.0 specification(DSP0136).
REF:https://www.dmtf.org/sites/default/files/standards/documents/DSP0136.pdf

Could you suggest which package is suitable for this feature?
Since I'm not sure which package to include this feature, I create a temporarily
Asfpkg to include my patch.
Asf branch in forked edk2 reop
REF:https://github.com/CrystalLee-77/edk2/tree/AlertStandardFormatSupport

Currently, the drivers focus on below features
1. ASF Smbus alert-relate messages (progress logs or error logs)
2. Publish ASF ACPI table for remote control and other information

Drivers description:
Asf Pei driver: send Bios present and memory initial related messages.
Asf Dxe driver:
1. Get boot options from device(DSP0136, ch5.2 boot option messages)
2. Install Asf Acpi table.
3. Register callback function through RscHandler Protocol, the function will
send standard messages base on the reported status code.
4. Register callback function on ready to boot event, this function will send
set system state(S0) message to device.
5. Install Asf protocol, the protocol include the boot options information in
step 1 so other drivers can get the information.


Alert Standard format specification(DSP0136)
REF:https://www.dmtf.org/sites/default/files/standards/documents/DSP0136.pdf

Send standard alert message base on the status code reported by drivers.
Report Asf configuration and capabilities in Asf ACPI table

Signed-off-by: Crystal Lee <crystal...@ami.com>
---
 AsfPkg/Asf/AsfDxe/AsfDxe.c                         | 338 +++++++++++++++++
 AsfPkg/Asf/AsfDxe/AsfDxeEvent.c                    | 319 ++++++++++++++++
 AsfPkg/Asf/AsfPei/AsfPei.c                         | 384 ++++++++++++++++++++
 AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.c   | 210 +++++++++++
 AsfPkg/Asf/AsfDxe/AsfDxe.h                         |  67 ++++
 AsfPkg/Asf/AsfDxe/AsfDxe.inf                       |  52 +++
 AsfPkg/Asf/AsfDxe/AsfDxe.uni                       |  15 +
 AsfPkg/Asf/AsfDxe/AsfDxeExtra.uni                  |  13 +
 AsfPkg/Asf/AsfPei/AsfPei.inf                       |  57 +++
 AsfPkg/Asf/AsfPei/AsfPei.uni                       |  15 +
 AsfPkg/Asf/AsfPei/AsfPeiExtra.uni                  |  13 +
 AsfPkg/AsfPkg.dec                                  |  47 +++
 AsfPkg/AsfPkg.dsc                                  |  59 +++
 AsfPkg/Include/AsfMessages.h                       | 104 ++++++
 AsfPkg/Include/IndustryStandard/Asf.h              | 145 ++++++++
 AsfPkg/Include/Library/AsfAcpiTableLib.h           |  26 ++
 AsfPkg/Include/Protocol/AsfProtocol.h              |  57 +++
 AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.inf |  30 ++
 AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.uni |  15 +
 19 files changed, 1966 insertions(+)

diff --git a/AsfPkg/Asf/AsfDxe/AsfDxe.c b/AsfPkg/Asf/AsfDxe/AsfDxe.c
new file mode 100644
index 000000000000..1919dec6d095
--- /dev/null
+++ b/AsfPkg/Asf/AsfDxe/AsfDxe.c
@@ -0,0 +1,338 @@
+/** @file

+  Asf Dxe driver which is used for sending event record log to NIC or receiving

+  boot option command from NIC and provide in Asf Dxe protocol.

+

+  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#include <AsfDxe.h>

+

+ASF_BOOT_OPTION           gAsfBootOption = { 0, 0, 0, 0, 0, 0, 0 };

+ASF_PROTOCOL              gAsfProtocol   = { AsfPushEvent, NULL };

+EFI_SMBUS_DEVICE_ADDRESS  mFixedTargetAddress;

+EFI_SMBUS_HC_PROTOCOL     *mSmBus = NULL;

+

+/**

+  Send message through SmBus to lan card.

+

+  @param[in] Command      Command of System Firmware Events.

+  @param[in] Length       Length of the data in bytes.

+  @param[in] AsfEvent     Message data.

+

+  @retval EFI_SUCCESS     Push Event successfully.

+  @retval Others          Push Event error.

+**/

+EFI_STATUS

+EFIAPI

+AsfPushEvent  (

+  IN  UINT8  Command,

+  IN  UINTN  Length,

+  IN  UINT8  *AsfEvent

+  )

+{

+  EFI_STATUS  Status;

+

+  if (mSmBus == NULL) {

+    return EFI_UNSUPPORTED;

+  }

+

+  Status = mSmBus->Execute (

+                     mSmBus,

+                     mFixedTargetAddress,

+                     Command,

+                     EfiSmbusWriteBlock,

+                     TRUE,

+                     &Length,

+                     AsfEvent

+                     );

+  if (EFI_ERROR (Status)) {

+    DEBUG ((DEBUG_ERROR, "AsfPushEvent Status = %r\n", Status));

+  }

+

+  return Status;

+}

+

+/**

+  This function pushes the System Firmware State Events.

+

+  @param[in] SystemState    System Firmware State.

+

+**/

+VOID

+EFIAPI

+AsfPushSystemState  (

+  IN  UINT8  SystemState

+  )

+{

+  mAsfSystemState.EventSensorType = SystemState;

+  AsfPushEvent (

+    mAsfSystemState.Command,

+    mAsfSystemState.ByteCount,

+    (UINT8 *)&(mAsfSystemState.SubCommand)

+    );

+  return;

+}

+

+/**

+  This function processes the System Firmware Progress/Error Events.

+

+  @param[in] MessageErrorLevel   Progress or error or system management 
message Type.

+  @param[in] MessageType         Specific ASF message type.

+

+**/

+VOID

+EFIAPI

+AsfPushSystemErrorProgressEvent  (

+  IN UINT32            MessageErrorLevel,

+  IN ASF_MESSAGE_TYPE  MessageType

+  )

+{

+  UINTN  i;

+

+  if ((MessageErrorLevel & PcdGet32 (PcdAsfMessageErrorLevel)) ||

+      ((gAsfBootOption.BootOptionBit & ASF_BOP_BIT_FORCE_PROGRESS_EVENT)))

+  {

+    for ( i = 0; i < mAsfMessagesSize; i++ ) {

+      if ( mAsfMessages[i].Type == MessageType ) {

+        AsfPushEvent (

+          mAsfMessages[i].Message.Command,

+          mAsfMessages[i].Message.ByteCount,

+          (UINT8 *)&(mAsfMessages[i].Message.SubCommand)

+          );

+        break;

+      }

+    }

+  }

+

+  return;

+}

+

+/**

+  Send relate progress or error message to lan card

+

+  @param[in]  CodeType         Indicates the type of status code being 
reported.

+  @param[in]  Value            Describes the current status of a hardware or 
software entity.

+                               This included information about the class and 
subclass that is used to

+                               classify the entity as well as an operation.

+  @param[in]  Instance         The enumeration of a hardware or software 
entity within

+                               the system. Valid instance numbers start with 1.

+  @param[in]  CallerId         This optional parameter may be used to identify 
the caller.

+                               This parameter allows the status code driver to 
apply different rules to

+                               different callers.

+  @param[in]  Data             This optional parameter may be used to pass 
additional data.

+

+  @retval EFI_SUCCESS          Reported all the progress and error codes for 
Asf successfully.

+**/

+EFI_STATUS

+EFIAPI

+AsfRscHandlerCallback (

+  IN EFI_STATUS_CODE_TYPE   CodeType,

+  IN EFI_STATUS_CODE_VALUE  Value,

+  IN UINT32                 Instance,

+  IN EFI_GUID               *CallerId,

+  IN EFI_STATUS_CODE_DATA   *Data

+  )

+{

+  UINTN  Index;

+

+  if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) {

+    for (Index = 0; Index < mMsgProgressMapSize; Index++) {

+      if (mMsgProgressMap[Index].StatusCode == Value) {

+        AsfPushSystemErrorProgressEvent (MESSAGE_ERROR_LEVEL_PROGRESS, 
mMsgProgressMap[Index].MessageType);

+        break;

+      }

+    }

+  }

+

+  if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {

+    for ( Index = 0; Index < mMsgErrorMapSize; Index++ ) {

+      if ( mMsgErrorMap[Index].StatusCode == Value ) {

+        AsfPushSystemErrorProgressEvent (MESSAGE_ERROR_LEVEL_ERROR, 
mMsgErrorMap[Index].MessageType);

+        break;

+      }

+    }

+  }

+

+  return EFI_SUCCESS;

+}

+

+/**

+  This function issues the ASF Get/Clear Boot Option command.

+

+  @retval EFI_SUCCESS Reported all the progress and error codes for Asf 
successfully.

+  @retval Others      Smbus Execute function return error.

+**/

+EFI_STATUS

+EFIAPI

+AsfGetBootOption (

+  IN  EFI_SMBUS_DEVICE_ADDRESS  AsfSlaveAddress

+  )

+{

+  EFI_STATUS       Status;

+  UINTN            Length = sizeof (ASF_BOOT_OPTION);

+  ASF_BOOT_OPTION  BootOption;

+

+  // Initialize get boot option Buffer.

+  SetMem (&BootOption, sizeof (ASF_BOOT_OPTION), 0);

+

+  // Execute ASFMSG_CMD_CONFIG command.

+  Status = mSmBus->Execute (

+                     mSmBus,

+                     AsfSlaveAddress,

+                     ASFMSG_CMD_CONFIG,

+                     EfiSmbusReadBlock,

+                     TRUE,

+                     &Length,

+                     &BootOption

+                     );

+  if ( EFI_ERROR (Status)) {

+    return Status;

+  }

+

+  if ( BootOption.SubCommand == ASFMSG_SUBCMD_RET_BOOT_OPTION ) {

+    // copy Return Boot Option to global ASF Boot Option buffer.

+    CopyMem (&gAsfBootOption, &BootOption, sizeof (ASF_BOOT_OPTION));

+    gAsfProtocol.BootOption = &gAsfBootOption;

+    // Execute Clear Boot Option command.

+    BootOption.SubCommand = ASFMSG_SUBCMD_CLR_BOOT_OPTION;

+    BootOption.Version    = 0x10;

+    Length                = 2;

+    mSmBus->Execute (

+              mSmBus,

+              AsfSlaveAddress,

+              ASFMSG_CMD_CONFIG,

+              EfiSmbusWriteBlock,

+              TRUE,

+              &Length,

+              &BootOption

+              );

+  }

+

+  return Status;

+}

+

+/**

+  This Event Callback processes the requests at EFI Ready to Boot Event 
triggered.

+

+  @param[in]  Event      A pointer to the Event that triggered the callback.

+  @param[in]  Context    A pointer to private data registered with the 
callback function.

+**/

+VOID

+EFIAPI

+AsfReadyToBootEvent (

+  IN  EFI_EVENT  Event,

+  IN  VOID       *Context

+  )

+{

+  // Push System State S0 - "Working".

+  AsfPushSystemState (ASFMSG_SYSTEM_STATE_S0);

+

+  gBS->CloseEvent (Event);

+  return;

+}

+

+/**

+    Register callback if Acpi protocol is not ready, else install ASF acpi 
table directly.

+

+**/

+VOID

+EFIAPI

+InstallAsfAcpiTable (

+  VOID

+  )

+{

+  EFI_STATUS               Status;

+  EFI_EVENT                Event;

+  VOID                     *Registration;

+  EFI_ACPI_TABLE_PROTOCOL  *AcpiTableProtocol;

+

+  Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID 
**)&AcpiTableProtocol);

+  if (!EFI_ERROR (Status)) {

+    InstallAsfAcpiTableEvent (NULL, NULL);

+  } else {

+    Status = gBS->CreateEvent (

+                    EVT_NOTIFY_SIGNAL,

+                    TPL_CALLBACK,

+                    InstallAsfAcpiTableEvent,

+                    NULL,

+                    &Event

+                    );

+

+    if (!EFI_ERROR (Status)) {

+      Status = gBS->RegisterProtocolNotify (

+                      &gEfiAcpiTableProtocolGuid,

+                      Event,

+                      &Registration

+                      );

+

+      if (EFI_ERROR (Status)) {

+        gBS->CloseEvent (Event);

+      }

+    }

+  }

+

+  return;

+}

+

+/**

+  This is the standard EFI driver entry point for DXE phase of ASF.

+

+  @param[in] ImageHandle   Image handle of the loaded driver

+  @param[in] SystemTable   Pointer to the System Table

+

+  @retval EFI_SUCCESS      This driver initial correctly

+  @retval Others           This driver initial fail

+**/

+EFI_STATUS

+EFIAPI

+AsfDxeEntry (

+  IN EFI_HANDLE        ImageHandle,

+  IN EFI_SYSTEM_TABLE  *SystemTable

+  )

+{

+  EFI_STATUS                Status;

+  EFI_RSC_HANDLER_PROTOCOL  *RscHandler;

+  EFI_EVENT                 AsfEfiReadyToBootEvent;

+

+  Status = gBS->LocateProtocol (&gEfiSmbusHcProtocolGuid, NULL, (VOID 
**)&mSmBus);

+  if ( EFI_ERROR (Status)) {

+    return Status;

+  }

+

+  mFixedTargetAddress.SmbusDeviceAddress = PcdGet8 
(PcdSmbusSlaveAddressForDashLan) >> 1;

+  if (mFixedTargetAddress.SmbusDeviceAddress == 0) {

+    return EFI_UNSUPPORTED;

+  }

+

+  Status = AsfGetBootOption (mFixedTargetAddress);

+  if ( EFI_ERROR (Status)) {

+    return Status;

+  }

+

+  InstallAsfAcpiTable ();

+

+  // Send mother board initialization message.

+  AsfPushSystemErrorProgressEvent (MESSAGE_ERROR_LEVEL_PROGRESS, 
MsgMotherBoardInit);

+

+  Status = gBS->LocateProtocol (&gEfiRscHandlerProtocolGuid, NULL, (VOID 
**)&RscHandler);

+  if (!EFI_ERROR (Status)) {

+    RscHandler->Register (AsfRscHandlerCallback, TPL_CALLBACK);

+  }

+

+  EfiCreateEventReadyToBootEx (

+    TPL_CALLBACK,

+    AsfReadyToBootEvent,

+    NULL,

+    &AsfEfiReadyToBootEvent

+    );

+

+  gBS->InstallProtocolInterface (

+         &ImageHandle, \

+         &gAsfProtocolGuid,

+         EFI_NATIVE_INTERFACE,

+         &gAsfProtocol

+         );

+

+  return EFI_SUCCESS;

+}

diff --git a/AsfPkg/Asf/AsfDxe/AsfDxeEvent.c b/AsfPkg/Asf/AsfDxe/AsfDxeEvent.c
new file mode 100644
index 000000000000..64265c6d5c3c
--- /dev/null
+++ b/AsfPkg/Asf/AsfDxe/AsfDxeEvent.c
@@ -0,0 +1,319 @@
+/** @file

+  Asf messages define

+

+  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#include <AsfDxe.h>

+

+MESSAGE_DATA_HUB_MAP  mMsgProgressMap[] = {

+  { MsgHddInit,           EFI_PERIPHERAL_FIXED_MEDIA | EFI_P_PC_ENABLE         
    },

+  { MsgApInit,            EFI_COMPUTING_UNIT_HOST_PROCESSOR | 
EFI_CU_HP_PC_AP_INIT },

+  { MsgUserInitSetup,     EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP    
    },

+  { MsgUsbResourceConfig, EFI_IO_BUS_USB | EFI_P_PC_ENABLE                     
    },

+  { MsgPciResourceConfig, EFI_IO_BUS_PCI | EFI_IOB_PCI_BUS_ENUM                
    },

+  { MsgVideoInit,         EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_ENABLE       
    },

+  { MsgKbcInit,           EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_ENABLE            
    },

+  { MsgKbcTest,           EFI_PERIPHERAL_KEYBOARD | 
EFI_P_KEYBOARD_PC_SELF_TEST    }

+};

+

+MESSAGE_DATA_HUB_MAP  mMsgErrorMap[] = {

+  { MsgNoVideo,    EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_NOT_DETECTED },

+  { MsgKbdFailure, EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED      },

+  { MsgHddFailure, EFI_PERIPHERAL_FIXED_MEDIA | EFI_P_EC_NOT_DETECTED   }

+};

+

+ASF_MESSAGE  mAsfMessages[] = {

+  {

+    MsgHddInit,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_DISK,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_HARD_DISK_INITIALIZATION

+    }

+  },

+  {

+    MsgApInit,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_PROCESSOR,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_AP_INITIALIZATION

+    }

+  },

+  {

+    MsgUserInitSetup,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_BIOS,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_SETUP_INITIALIZATION

+    }

+  },

+  {

+    MsgUsbResourceConfig,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_BIOS,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_USB_RESOURCE_CONFIG

+    }

+  },

+  {

+    MsgPciResourceConfig,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_BIOS,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_PCI_RESOURCE_CONFIG

+    }

+  },

+  {

+    MsgVideoInit,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_ADD_IN_CARD,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_VIDEO_INITIALIZATION

+    }

+  },

+  {

+    MsgKbcInit,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_SYSTEM_BOARD,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_KEYBOARD_INITIALIZATION

+    }

+  },

+  {

+    MsgKbcTest,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_SYSTEM_BOARD,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_KEYBOARD_TEST

+    }

+  },

+  {

+    MsgMotherBoardInit,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_MONITOR,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_SYSTEM_BOARD,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_BOARD_INITIALIZATION

+    }

+  },

+  {

+    MsgNoVideo,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_NO_BOOTABLE_MEDIA,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_ADD_IN_CARD,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_NO_VIDEO

+    }

+  },

+  {

+    MsgKbdFailure,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_ERROR,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_SYSTEM_BOARD,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_KEYBOARD_FAILURE

+    }

+  },

+  {

+    MsgHddFailure,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_ERROR,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_RECOVERABLE,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_DISK,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_HARD_DISK_FAILURE

+    }

+  },

+  {

+    MsgChassisIntrusion,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0b, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_CHASSIS_INTRUSION,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_CHASSIS_INTRUSION,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_MONITOR,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_SYSTEM_BOARD,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED

+    }

+  },

+  {

+    MsgNoBootMedia,

+    {

+      ASFMSG_COMMAND_MESSAGING,

+      0x0d, // ByteCount

+      ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+      ASFMSG_VERSION_NUMBER_10,

+      ASFMSG_EVENT_SENSOR_TYPE_BOOT_ERROR,

+      ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+      ASFMSG_EVENT_OFFSET_SYS_FW_ERROR,

+      ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+      ASFMSG_EVENT_SEVERITY_NON_RECOVERABLE,

+      ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+      ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+      ASFMSG_ENTITY_UNSPECIFIED,

+      ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+      ASFMSG_EVENT_DATA1,

+      ASFMSG_EVENT_DATA_UNSPECIFIED

+    }

+  }

+};

+

+UINTN  mMsgProgressMapSize = sizeof (mMsgProgressMap) / sizeof 
(MESSAGE_DATA_HUB_MAP);

+UINTN  mMsgErrorMapSize    = sizeof (mMsgErrorMap) / sizeof 
(MESSAGE_DATA_HUB_MAP);

+UINTN  mAsfMessagesSize    = sizeof (mAsfMessages) / sizeof (ASF_MESSAGE);

+

+ASF_MSG_NORETRANSMIT  mAsfSystemState =

+{

+  ASFMSG_COMMAND_SYSTEM_STATE,

+  0x3,    // ByteCount

+  ASFMSG_SUBCOMMAND_SET_SYSTEM_STATE,

+  ASFMSG_VERSION_NUMBER_10,

+  ASFMSG_SYSTEM_STATE_S0

+};

diff --git a/AsfPkg/Asf/AsfPei/AsfPei.c b/AsfPkg/Asf/AsfPei/AsfPei.c
new file mode 100644
index 000000000000..8b44cd26e0fe
--- /dev/null
+++ b/AsfPkg/Asf/AsfPei/AsfPei.c
@@ -0,0 +1,384 @@
+/** @file

+  Asf Pei Initialization Driver.

+

+  Follow Asf spec to send progress or error message to Smbus device

+

+  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#include <AsfMessages.h>

+#include <Base.h>

+#include <Ppi/ReportStatusCodeHandler.h>

+#include <Ppi/MemoryDiscovered.h>

+#include <Ppi/Smbus2.h>

+#include <Library/DebugLib.h>

+#include <Library/PeiServicesLib.h>

+#include <Pi/PiStatusCode.h>

+

+/**

+  This Event Notify processes the ASF request at Memory Initial Completed.

+

+  @param[in] PeiServices          General purpose services available to every 
PEIM.

+  @param[in] NotifyDescriptor     The notification structure this PEIM 
registered on install.

+  @param[in] Ppi                  The memory discovered PPI.  Not used.

+

+  @retval EFI_SUCCESS             Succeeds.

+  @retval EFI_UNSUPPORTED         Push Event error.

+

+**/

+EFI_STATUS

+EFIAPI

+MsgMemoryInitCompleted (

+  IN EFI_PEI_SERVICES           **PeiServices,

+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,

+  IN VOID                       *Ppi

+  );

+

+STATIC EFI_PEI_NOTIFY_DESCRIPTOR  mMemoryDiscoveredNotifyDes = {

+  EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | 
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,

+  &gEfiPeiMemoryDiscoveredPpiGuid,

+  MsgMemoryInitCompleted

+};

+

+ASF_MSG_NORETRANSMIT  mAsfSystemStateWorking = \

+{

+  ASFMSG_COMMAND_SYSTEM_STATE,

+  0x3,    // ByteCount

+  ASFMSG_SUBCOMMAND_SET_SYSTEM_STATE,

+  ASFMSG_VERSION_NUMBER_10,

+  ASFMSG_SYSTEM_STATE_S0

+};

+

+ASF_MSG_NORETRANSMIT  mMsgStopTimer =

+{

+  ASFMSG_COMMAND_MANAGEMENT_CONTROL,

+  0x2,    // ByteCount

+  ASFMSG_SUBCOMMAND_STOP_WATCH_DOG,

+  ASFMSG_VERSION_NUMBER_10

+};

+

+// 3.1.5.3 System Firmware Progress Events

+ASF_MSG_NORETRANSMIT  mMsgBiosPresent =

+{

+  ASFMSG_COMMAND_MESSAGING,

+  0xd,    // ByteCount

+  ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+  ASFMSG_VERSION_NUMBER_10,

+  ASFMSG_EVENT_SENSOR_TYPE_ENTITY_PRESENCE,

+  ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+  ASFMSG_EVENT_OFFSET_ENTITY_PRESENT,

+  ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+  ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+  ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+  ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+  ASFMSG_ENTITY_BIOS,

+  ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+  ASFMSG_EVENT_DATA1,

+  ASFMSG_EVENT_DATA_UNSPECIFIED

+};

+

+// Starting memory initialization and test.

+ASF_MSG_NORETRANSMIT  mMsgMemoryInit =

+{

+  ASFMSG_COMMAND_MESSAGING,

+  0xd,    // ByteCount

+  ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+  ASFMSG_VERSION_NUMBER_10,

+  ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+  ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+  ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+  ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+  ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+  ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+  ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+  ASFMSG_ENTITY_MEMORY_DEVICE,

+  ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+  ASFMSG_EVENT_DATA1,

+  ASFMSG_EVENT_DATA_MEMORY_INITIALIZATION

+};

+

+// Memory initialized and tested.

+ASF_MSG_NORETRANSMIT  mMsgMemoryInitialized =

+{

+  ASFMSG_COMMAND_MESSAGING,

+  0xd,    // ByteCount

+  ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+  ASFMSG_VERSION_NUMBER_10,

+  ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+  ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+  ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_EXIT,

+  ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+  ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+  ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+  ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+  ASFMSG_ENTITY_MEMORY_DEVICE,

+  ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+  ASFMSG_EVENT_DATA1,

+  ASFMSG_EVENT_DATA_MEMORY_INITIALIZATION

+};

+

+ASF_MSG_NORETRANSMIT  mAsfmsgCacheInit =

+{

+  ASFMSG_COMMAND_MESSAGING,

+  0xd,    // ByteCount

+  ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+  ASFMSG_VERSION_NUMBER_10,

+  ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+  ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+  ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY,

+  ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+  ASFMSG_EVENT_SEVERITY_MONITOR,

+  ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+  ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+  ASFMSG_ENTITY_PROCESSOR,

+  ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+  ASFMSG_EVENT_DATA1,

+  ASFMSG_EVENT_DATA_CACHE_INITIALIZATION

+};

+

+ASF_MSG_NORETRANSMIT  mAsfmsgMemoryMissing =

+{

+  ASFMSG_COMMAND_MESSAGING,

+  0xd,    // ByteCount

+  ASFMSG_SUBCOMMAND_NO_RETRANSMIT,

+  ASFMSG_VERSION_NUMBER_10,

+  ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS,

+  ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC,

+  ASFMSG_EVENT_OFFSET_SYS_FW_ERROR,

+  ASFMSG_EVENT_SOURCE_TYPE_ASF10,

+  ASFMSG_EVENT_SEVERITY_NON_CRITICAL,

+  ASFMSG_SENSOR_DEVICE_UNSPECIFIED,

+  ASFMSG_SENSOR_NUMBER_UNSPECIFIED,

+  ASFMSG_ENTITY_MEMORY_DEVICE,

+  ASFMSG_ENTITY_INSTANCE_UNSPECIFIED,

+  ASFMSG_EVENT_DATA1,

+  ASFMSG_EVENT_DATA_NO_MEMORY

+};

+

+/**

+  This function pushes the PEI System Firmware Progress Events.

+

+  @param[in] SmBus               Pointer to the SmBus PPI.

+  @param[in] FixedTargetAddress  Device address

+  @param[in] MessageErrorLevel   Progress or error or system management 
message Type.

+  @param[in] MessageBuffer       Pointer to the Event Data Buffer.

+

+**/

+VOID

+EFIAPI

+AsfPushProgressMessage (

+  IN EFI_PEI_SMBUS2_PPI        *SmBus,

+  IN EFI_SMBUS_DEVICE_ADDRESS  FixedTargetAddress,

+  IN UINT32                    MessageErrorLevel,

+  IN UINT8                     *MessageBuffer

+  )

+{

+  EFI_STATUS  Status;

+  UINTN       Length;

+

+  if (MessageErrorLevel & PcdGet32 (PcdAsfMessageErrorLevel)) {

+    Length = ((ASF_MSG_NORETRANSMIT *)MessageBuffer)->ByteCount;

+    Status = SmBus->Execute (

+                      SmBus,

+                      FixedTargetAddress,

+                      ((ASF_MSG_NORETRANSMIT *)MessageBuffer)->Command,

+                      EfiSmbusWriteBlock,

+                      TRUE,

+                      &Length,

+                      (UINT8 *)(MessageBuffer+2)

+                      );

+    if (EFI_ERROR (Status)) {

+      DEBUG ((DEBUG_ERROR, "Push alert message fail, status = %r\n", Status));

+    }

+  }

+

+  return;

+}

+

+/**

+  This callback registered by Report Status Code Ppi for Memory Missing PET.

+

+  @param[in] PeiServices        General purpose services available to every 
PEIM.

+  @param[in] Type               Indicates the type of status code being 
reported.

+  @param[in] Value              Describes the current status of a hardware or 
software entity.

+                                This included information about the class and 
subclass that is

+                                used to classify the entity as well as an 
operation.

+  @param[in] Instance           The enumeration of a hardware or software 
entity within the system.

+                                Valid instance numbers start with 1.

+  @param[in] CallerId           This optional parameter may be used to 
identify the caller.

+                                This parameter allows the status code driver 
to apply different

+                                rules to different callers.

+  @param[in] Data               This optional parameter may be used to pass 
additional data.

+

+  @retval EFI_SUCCESS           Always return EFI_SUCCESS

+

+**/

+EFI_STATUS

+EFIAPI

+AsfPeiStatusCodeCallBack (

+  IN  EFI_PEI_SERVICES       **PeiServices,

+  IN  EFI_STATUS_CODE_TYPE   Type,

+  IN  EFI_STATUS_CODE_VALUE  Value,

+  IN  UINT32                 Instance,

+  IN  EFI_GUID               *CallerId,

+  IN  EFI_STATUS_CODE_DATA   *Data

+  )

+{

+  EFI_STATUS                Status;

+  EFI_PEI_SMBUS2_PPI        *SmBus;

+  EFI_SMBUS_DEVICE_ADDRESS  FixedTargetAddress;

+

+  FixedTargetAddress.SmbusDeviceAddress = PcdGet8 
(PcdSmbusSlaveAddressForDashLan) >> 1;

+  if (FixedTargetAddress.SmbusDeviceAddress == 0) {

+    return EFI_SUCCESS;

+  }

+

+  Status = PeiServicesLocatePpi (

+             &gEfiPeiSmbus2PpiGuid,

+             0,

+             NULL,

+             (VOID **)&SmBus

+             );

+  if ( EFI_ERROR (Status)) {

+    return EFI_SUCCESS;

+  }

+

+  if ((Type & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) {

+    if ((Value == (EFI_SOFTWARE_PEI_CORE | 
EFI_SW_PEI_CORE_EC_MEMORY_NOT_INSTALLED)) ||

+        (Value == (EFI_COMPUTING_UNIT_MEMORY | 
EFI_CU_MEMORY_EC_NONE_DETECTED)))

+    {

+      // Error message - Memory Missing.

+      AsfPushProgressMessage (SmBus, FixedTargetAddress, 
MESSAGE_ERROR_LEVEL_ERROR, (UINT8 *)&mAsfmsgMemoryMissing);

+    }

+  }

+

+  if (((Type & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) &&

+      (Value == (EFI_COMPUTING_UNIT_HOST_PROCESSOR | EFI_CU_HP_PC_CACHE_INIT)))

+  {

+    // Progress message - Cache initialization.

+    AsfPushProgressMessage (SmBus, FixedTargetAddress, 
MESSAGE_ERROR_LEVEL_PROGRESS, (UINT8 *)&mAsfmsgCacheInit);

+  }

+

+  return EFI_SUCCESS;

+}

+

+/**

+  This send memory initialized message after memory discovered.

+

+  @param[in] PeiServices          General purpose services available to every 
PEIM.

+  @param[in] NotifyDescriptor     The notification structure this PEIM 
registered on install.

+  @param[in] Ppi                  The memory discovered PPI.

+

+  @retval EFI_SUCCESS             Always return EFI_SUCCESS

+

+**/

+EFI_STATUS

+EFIAPI

+MsgMemoryInitCompleted (

+  IN EFI_PEI_SERVICES           **PeiServices,

+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,

+  IN VOID                       *Ppi

+  )

+{

+  EFI_STATUS                Status;

+  EFI_PEI_SMBUS2_PPI        *SmBus;

+  EFI_BOOT_MODE             BootMode;

+  EFI_SMBUS_DEVICE_ADDRESS  FixedTargetAddress;

+

+  FixedTargetAddress.SmbusDeviceAddress = PcdGet8 
(PcdSmbusSlaveAddressForDashLan) >> 1;

+  if (FixedTargetAddress.SmbusDeviceAddress == 0) {

+    return EFI_SUCCESS;

+  }

+

+  Status = PeiServicesLocatePpi (

+             &gEfiPeiSmbus2PpiGuid,

+             0,

+             NULL,

+             (VOID **)&SmBus

+             );

+  if ( EFI_ERROR (Status)) {

+    return EFI_SUCCESS;

+  }

+

+  // Progress message - Completed memory initialization and test.

+  AsfPushProgressMessage (SmBus, FixedTargetAddress, 
MESSAGE_ERROR_LEVEL_PROGRESS, (UINT8 *)&mMsgMemoryInitialized);

+

+  // Get Boot Path.

+  Status = PeiServicesGetBootMode (&BootMode);

+  if (!EFI_ERROR (Status) && (BootMode == BOOT_ON_S3_RESUME)) {

+    // Push System State Working if S3 resuming.

+    AsfPushProgressMessage (

+      SmBus,

+      FixedTargetAddress,

+      MESSAGE_ERROR_LEVEL_SYSTEM_MANAGEMENT,

+      (UINT8 *)&mAsfSystemStateWorking

+      );

+  }

+

+  return EFI_SUCCESS;

+}

+

+/**

+  Asf PEI module entry point

+

+  @param[in]  FileHandle           FileHandle  Handle of the file being 
invoked.

+  @param[in]  PeiServices          Describes the list of possible PEI Services.

+

+  @retval     EFI_SUCCESS          The PEIM initialized successfully.

+

+**/

+EFI_STATUS

+EFIAPI

+AsfPeiEntry (

+  IN       EFI_PEI_FILE_HANDLE  FileHandle,

+  IN CONST EFI_PEI_SERVICES     **PeiServices

+  )

+{

+  EFI_STATUS                Status;

+  EFI_PEI_SMBUS2_PPI        *SmBus;

+  EFI_PEI_RSC_HANDLER_PPI   *RscHndrPpi;

+  EFI_SMBUS_DEVICE_ADDRESS  FixedTargetAddress;

+

+  FixedTargetAddress.SmbusDeviceAddress = PcdGet8 
(PcdSmbusSlaveAddressForDashLan) >> 1;

+  if (FixedTargetAddress.SmbusDeviceAddress == 0) {

+    return EFI_UNSUPPORTED;

+  }

+

+  Status = PeiServicesLocatePpi (

+             &gEfiPeiSmbus2PpiGuid,

+             0,

+             NULL,

+             (VOID **)&SmBus

+             );

+  if (EFI_ERROR (Status)) {

+    return Status;

+  }

+

+  //

+  // If the managed client's firmware supports a system boot-failure watchdog 
timer,

+  // the firmware issues the Stop Watchdog Timer command to stop the timer 
that is

+  // automatically started by the alert-sending device at power-on reset.

+  //

+  AsfPushProgressMessage (SmBus, FixedTargetAddress, 
MESSAGE_ERROR_LEVEL_SYSTEM_MANAGEMENT, (UINT8 *)&mMsgStopTimer);

+

+  // Progress message - BIOS Present.

+  AsfPushProgressMessage (SmBus, FixedTargetAddress, 
MESSAGE_ERROR_LEVEL_PROGRESS, (UINT8 *)&mMsgBiosPresent);

+

+  // Progress message - Started memory initialization and test.

+  AsfPushProgressMessage (SmBus, FixedTargetAddress, 
MESSAGE_ERROR_LEVEL_PROGRESS, (UINT8 *)&mMsgMemoryInit);

+

+  PeiServicesNotifyPpi (&mMemoryDiscoveredNotifyDes);

+

+  Status = PeiServicesLocatePpi (

+             &gEfiPeiRscHandlerPpiGuid,

+             0,

+             NULL,

+             (VOID **)&RscHndrPpi

+             );

+  if (!EFI_ERROR (Status)) {

+    RscHndrPpi->Register 
((EFI_PEI_RSC_HANDLER_CALLBACK)AsfPeiStatusCodeCallBack);

+  }

+

+  return EFI_SUCCESS;

+}

diff --git a/AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.c 
b/AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.c
new file mode 100644
index 000000000000..7476dbf52752
--- /dev/null
+++ b/AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.c
@@ -0,0 +1,210 @@
+/** @file

+  Asf Acpi table

+

+  Install Asf Acpi table

+

+  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#include <Library/UefiBootServicesTableLib.h>

+#include <Library/DebugLib.h>

+#include <Protocol/AcpiSystemDescriptionTable.h>

+#include <IndustryStandard/AlertStandardFormatTable.h>

+#include <IndustryStandard/Acpi.h>

+#include <Protocol/AcpiTable.h>

+

+// ASF Table Definitions

+// Below array size define should follow AsfAcpiTable setting

+#define ASF_RCTL_DEVICES_ARRAY_LENGTH  4

+#define ASF_ADDR_DEVICE_ARRAY_LENGTH   11

+

+#pragma pack(push,1)

+

+//

+// Alert Remote Control System Actions.

+//

+typedef struct {

+  EFI_ACPI_ASF_RCTL           AsfRctl;

+  EFI_ACPI_ASF_CONTROLDATA    ControlDataArray[ASF_RCTL_DEVICES_ARRAY_LENGTH];

+} ACPI_ASF_RCTL_ALL;

+

+//

+// SmBus Devices with fixed addresses.

+//

+typedef struct {

+  EFI_ACPI_ASF_ADDR    AsfAddr;

+  UINT8                FixedSmBusAddresses[ASF_ADDR_DEVICE_ARRAY_LENGTH];

+} ACPI_ASF_ADDR_ALL;

+

+//

+// ACPI 1.0 Structure for ASF Descriptor Table.

+//

+typedef struct {

+  EFI_ACPI_SDT_HEADER    Header;

+  EFI_ACPI_ASF_INFO      AsfInfo;

+  ACPI_ASF_RCTL_ALL      AsfRctlAll;

+  EFI_ACPI_ASF_RMCP      AsfRmcp;

+  ACPI_ASF_ADDR_ALL      AsfAddrAll;

+} ASF_DESCRIPTION_TABLE;

+

+#pragma pack(pop)

+

+#define EFI_ACPI_1_0_ASF_DESCRIPTION_TABLE_REVISION  0x20

+

+ASF_DESCRIPTION_TABLE  AsfAcpiTable = {

+  {

+    EFI_ACPI_ASF_DESCRIPTION_TABLE_SIGNATURE,

+    sizeof (ASF_DESCRIPTION_TABLE),

+    EFI_ACPI_1_0_ASF_DESCRIPTION_TABLE_REVISION,

+    0,                                              //  Checksum

+

+    // OEM identification

+    { 'O',  'E',  'M',  '_', 'I', 'D' },

+

+    // OEM table identification

+    { 'D',  '8',  '6',  '5', 'G', 'C', 'H', ' '},   // OEM table identification

+

+    1,                                              // OEM revision number

+    ((((('M' << 8) + 'S') << 8) + 'F') << 8) + 'T', // ASL compiler vendor ID

+    1000000                                         // ASL compiler revision 
number

+  },

+  {

+    //

+    // EFI_ACPI_ASF_INFO

+    //

+    {

+      0x00,                      // Type "ASF_INFO"

+      0x00,                      // Reserved

+      sizeof (EFI_ACPI_ASF_INFO) // Length

+    },

+    0x05,               // Min Watchdog Reset Value

+    0xFF,               // Min ASF Sensor poll Wait Time

+    0x0001,             // System ID

+    0x57010000,         // IANA Manufacture ID for Intel

+    0x00,               // Feature Flag

+    {

+      0x00,             // Reserved

+      0x00,

+      0x00

+    } // Reserved

+  },

+  {

+    //

+    // ACPI_ASF_RCTL_ALL

+    //

+    {

+      //

+      // EFI_ACPI_ASF_RCTL

+      //

+      {

+        0x02,                      // Type "ASF_RCTL"

+        0x00,                      // Reserved

+        sizeof (ACPI_ASF_RCTL_ALL) // Length

+      },

+      0x04,             // Number of Controls

+      0x04,             // Array Element Length

+      0x0000            // Reserved

+    },

+    {

+      //

+      // EFI_ACPI_ASF_CONTROLDATA

+      //

+      { 0x00, 0x88, 0x00, 0x03 }, // Control 0 --> Reset system

+      { 0x01, 0x88, 0x00, 0x02 }, // Control 1 --> Power Off system

+      { 0x02, 0x88, 0x00, 0x01 }, // Control 2 --> Power On system

+      { 0x03, 0x88, 0x00, 0x04 }  // Control 3 --> Power Cycle Reset (off then 
on)

+    }

+  },

+  {

+    //

+    // EFI_ACPI_ASF_RMCP

+    //

+    {

+      0x03,                      // Type "ASF_RMCP"

+      0x00,                      // Reserved

+      sizeof (EFI_ACPI_ASF_RMCP) // Length

+    },

+    {

+      // Remote Control Capabilities supported Bit Masks

+      0x00,                       // System Firmware Capabilities Bit Mask 
byte 1

+      0x00,                       // System Firmware Capabilities Bit Mask 
byte 2

+      0x00,                       // System Firmware Capabilities Bit Mask 
byte 3

+      0x00,                       // System Firmware Capabilities Bit Mask 
byte 4

+      0x00,                       // Special Commands Bit Mask byte 1

+      0x00,                       // Special Commands Bit Mask byte 2

+      0xF0                        // System Capabilities Bit Mask (Supports 
Reset,

+                                  // Power-Up, Power-Down, Power-Cycle Reset 
for

+                                  // compat and secure port.

+    },

+    0x00,                       // Boot Option Complete Code

+    0x57010000,                 // IANA ID for Intel Manufacturer

+    0x00,                       // Special Command

+    { 0x00, 0x00 },             // Special Command Parameter

+    { 0x00, 0x00 },             // Boot Options

+    { 0x00, 0x00 }              // OEM Parameters

+  },

+  {

+    //

+    // ACPI_ASF_ADDR_ALL

+    //

+    {

+      //

+      // EFI_ACPI_ASF_ADDR

+      //

+      {

+        0x84,                      // Type "ASF_ADDR", last record

+        0x00,                      // Reserved

+        sizeof (ACPI_ASF_ADDR_ALL) // Length

+      },

+      0x00,                        // SEEPROM Address

+      ASF_ADDR_DEVICE_ARRAY_LENGTH // Number Of Devices

+    },

+    //

+    // Fixed SMBus Address

+    //

+    {

+      0x5C, 0x68, 0x88, 0xC2, 0xD2,

+      0xDC, 0xA0, 0xA2, 0xA4, 0xA6,

+      0xC8

+    }

+  }

+};

+

+/**

+  This function install the ASF acpi Table.

+

+  @param[in]  Event     A pointer to the Event that triggered the callback.

+  @param[in]  Context   A pointer to private data registered with the callback 
function.

+**/

+VOID

+EFIAPI

+InstallAsfAcpiTableEvent  (

+  IN EFI_EVENT  Event,

+  IN VOID       *Context

+  )

+{

+  EFI_STATUS               Status;

+  UINTN                    TableHandle = 0;

+  EFI_ACPI_TABLE_PROTOCOL  *AcpiTableProtocol;

+

+  Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID 
**)&AcpiTableProtocol);

+

+  if ( EFI_ERROR (Status)) {

+    DEBUG ((DEBUG_ERROR, "Locate Acpi protocol %r Error\n", Status));

+    return;

+  }

+

+  if (Event != NULL) {

+    gBS->CloseEvent (Event);

+  }

+

+  AcpiTableProtocol->InstallAcpiTable (

+                       AcpiTableProtocol,

+                       &AsfAcpiTable,

+                       AsfAcpiTable.Header.Length,

+                       &TableHandle

+                       );

+

+  return;

+}

diff --git a/AsfPkg/Asf/AsfDxe/AsfDxe.h b/AsfPkg/Asf/AsfDxe/AsfDxe.h
new file mode 100644
index 000000000000..7f59fc27d86d
--- /dev/null
+++ b/AsfPkg/Asf/AsfDxe/AsfDxe.h
@@ -0,0 +1,67 @@
+/** @file

+  Asf Dxe driver which is used for sending event record log to NIC or receiving

+  boot option command from NIC and provide in Asf Dxe protocol.

+

+  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#ifndef __ASF_DXE_H__

+#define __ASF_DXE_H__

+

+#include <Pi/PiStatusCode.h>

+#include <Protocol/AsfProtocol.h>

+#include <IndustryStandard/SmBus.h>

+#include <Protocol/SmbusHc.h>

+#include <Protocol/ReportStatusCodeHandler.h>

+#include <Library/BaseLib.h>

+#include <Library/UefiLib.h>

+#include <Library/DebugLib.h>

+#include <Library/UefiBootServicesTableLib.h>

+#include <Library/UefiRuntimeServicesTableLib.h>

+#include <Library/BaseMemoryLib.h>

+#include <Library/PrintLib.h>

+#include <Protocol/AcpiTable.h>

+#include <Library/AsfAcpiTableLib.h>

+#include <AsfMessages.h>

+

+extern MESSAGE_DATA_HUB_MAP     mMsgProgressMap[];

+extern MESSAGE_DATA_HUB_MAP     mMsgErrorMap[];

+extern ASF_MESSAGE              mAsfMessages[];

+extern UINTN                    mMsgProgressMapSize;

+extern UINTN                    mMsgErrorMapSize;

+extern UINTN                    mAsfMessagesSize;

+extern ASF_MSG_NORETRANSMIT     mAsfSystemState;

+

+/**

+  This function pushes the DXE System Firmware Events.

+

+  @param[in] Command      Command of System Firmware Events.

+  @param[in] Length       Length of the data in bytes.

+  @param[in] AsfEvent     System Firmware Events Command.

+

+  @retval EFI_SUCCESS     Push Event successfully.

+  @retval EFI_UNSUPPORTED Push Event error.

+**/

+EFI_STATUS

+EFIAPI

+AsfPushEvent  (

+  IN  UINT8  Command,

+  IN  UINTN  Length,

+  IN  UINT8  *AsfEvent

+  );

+

+/**

+  This function install the ASF acpi Table.

+

+  @param[in]  Event     A pointer to the Event that triggered the callback.

+  @param[in]  Context   A pointer to private data registered with the callback 
function.

+**/

+VOID

+EFIAPI

+InstallAsfAcpiTableEvent  (

+  IN EFI_EVENT  Event,

+  IN VOID       *Context

+  );

+

+#endif //__ASF_DXE_H__

diff --git a/AsfPkg/Asf/AsfDxe/AsfDxe.inf b/AsfPkg/Asf/AsfDxe/AsfDxe.inf
new file mode 100644
index 000000000000..247fc6ca9da6
--- /dev/null
+++ b/AsfPkg/Asf/AsfDxe/AsfDxe.inf
@@ -0,0 +1,52 @@
+## @file

+#  Asf Dxe driver which is used for sending event record log to NIC or 
receiving

+#  boot option command from NIC and provide in Asf Dxe protocol.

+#

+#  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+#  SPDX-License-Identifier: BSD-2-Clause-Patent

+##

+

+[Defines]

+  INF_VERSION           = 0x00010005

+  BASE_NAME             = AsfDxe

+  MODULE_UNI_FILE       = AsfDxe.uni

+  FILE_GUID             = ED7AD1A2-1427-41EC-A71E-32EC9A1549E8

+  MODULE_TYPE           = DXE_DRIVER

+  VERSION_STRING        = 1.0

+  ENTRY_POINT           = AsfDxeEntry

+

+[Sources]

+  AsfDxe.c

+  AsfDxe.h

+  AsfDxeEvent.c

+

+[Packages]

+  MdePkg/MdePkg.dec

+  AsfPkg/AsfPkg.dec

+

+[LibraryClasses]

+  UefiDriverEntryPoint

+  UefiRuntimeServicesTableLib

+  DebugLib

+  BaseMemoryLib

+  PrintLib

+  AsfAcpiTableLib

+  UefiLib

+

+[Protocols]

+  gEfiRscHandlerProtocolGuid

+  gAsfProtocolGuid                # Produce

+  gEfiAcpiTableProtocolGuid

+  gEfiSmbusHcProtocolGuid

+

+[Guids]

+

+[FixedPcd]

+  gAsfPkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan

+  gAsfPkgTokenSpaceGuid.PcdAsfMessageErrorLevel

+

+[Depex]

+  TRUE

+

+[UserExtensions.TianoCore."ExtraFiles"]

+  AsfDxeExtra.uni

diff --git a/AsfPkg/Asf/AsfDxe/AsfDxe.uni b/AsfPkg/Asf/AsfDxe/AsfDxe.uni
new file mode 100644
index 000000000000..02ff1f72931d
--- /dev/null
+++ b/AsfPkg/Asf/AsfDxe/AsfDxe.uni
@@ -0,0 +1,15 @@
+// /** @file

+// Asf DXE Module

+//

+// Follow Asf spec to send progress or error message to Smbus device

+//

+// Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+// SPDX-License-Identifier: BSD-2-Clause-Patent

+//

+// **/

+

+

+#string STR_MODULE_ABSTRACT             #language en-US "Asf DXE Module"

+

+#string STR_MODULE_DESCRIPTION          #language en-US "Follow Asf spec to 
send progress or error message to Smbus device."

+

diff --git a/AsfPkg/Asf/AsfDxe/AsfDxeExtra.uni 
b/AsfPkg/Asf/AsfDxe/AsfDxeExtra.uni
new file mode 100644
index 000000000000..dbc747257c85
--- /dev/null
+++ b/AsfPkg/Asf/AsfDxe/AsfDxeExtra.uni
@@ -0,0 +1,13 @@
+// /** @file

+// Asf Dxe Module

+//

+// Follow Asf spec to send progress or error message to Smbus device

+//

+// Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+// SPDX-License-Identifier: BSD-2-Clause-Patent

+//

+// **/

+

+#string STR_PROPERTIES_MODULE_NAME

+#language en-US

+"Asf DXE"

diff --git a/AsfPkg/Asf/AsfPei/AsfPei.inf b/AsfPkg/Asf/AsfPei/AsfPei.inf
new file mode 100644
index 000000000000..0569a86e0925
--- /dev/null
+++ b/AsfPkg/Asf/AsfPei/AsfPei.inf
@@ -0,0 +1,57 @@
+## @file

+#  Asf PEIM

+#

+#  Follow Asf spec to send progress or error message to Smbus device

+#

+#  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+#  SPDX-License-Identifier: BSD-2-Clause-Patent

+##

+

+[Defines]

+  INF_VERSION                    = 0x00010005

+  BASE_NAME                      = AsfPei

+  MODULE_UNI_FILE                = AsfPei.uni

+  FILE_GUID                      = D2603B09-B8A2-4837-AA1E-EAE8E4DF78E7

+  MODULE_TYPE                    = PEIM

+  VERSION_STRING                 = 1.0

+  ENTRY_POINT                    = AsfPeiEntry

+

+#

+# The following information is for reference only and not required by the 
build tools.

+#

+#  VALID_ARCHITECTURES           = IA32 X64 EBC

+#

+

+[Sources]

+  AsfPei.c

+

+[Packages]

+  MdePkg/MdePkg.dec

+  AsfPkg/AsfPkg.dec

+

+[LibraryClasses]

+  PeimEntryPoint

+  PeiServicesLib

+  DebugLib

+

+[Guids]

+

+[Ppis]

+  gEfiPeiRscHandlerPpiGuid

+  gEfiPeiMemoryDiscoveredPpiGuid

+  gEfiPeiSmbus2PpiGuid

+

+[FeaturePcd]

+

+[Pcd]

+

+[FixedPcd]

+  gAsfPkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan

+  gAsfPkgTokenSpaceGuid.PcdAsfMessageErrorLevel

+

+[Depex]

+  gEfiPeiSmbus2PpiGuid

+

+[UserExtensions.TianoCore."ExtraFiles"]

+  AsfPeiExtra.uni

+

diff --git a/AsfPkg/Asf/AsfPei/AsfPei.uni b/AsfPkg/Asf/AsfPei/AsfPei.uni
new file mode 100644
index 000000000000..646712917e12
--- /dev/null
+++ b/AsfPkg/Asf/AsfPei/AsfPei.uni
@@ -0,0 +1,15 @@
+// /** @file

+// Asf PEI Module

+//

+// Follow Asf spec to send progress or error message to Smbus device

+//

+// Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+// SPDX-License-Identifier: BSD-2-Clause-Patent

+//

+// **/

+

+

+#string STR_MODULE_ABSTRACT             #language en-US "Asf PEI Module"

+

+#string STR_MODULE_DESCRIPTION          #language en-US "Follow Asf spec to 
send progress or error message to Smbus device."

+

diff --git a/AsfPkg/Asf/AsfPei/AsfPeiExtra.uni 
b/AsfPkg/Asf/AsfPei/AsfPeiExtra.uni
new file mode 100644
index 000000000000..72819f49862c
--- /dev/null
+++ b/AsfPkg/Asf/AsfPei/AsfPeiExtra.uni
@@ -0,0 +1,13 @@
+// /** @file

+// Asf PEI Module

+//

+// Follow Asf spec to send progress or error message to Smbus device

+//

+// Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+// SPDX-License-Identifier: BSD-2-Clause-Patent

+//

+// **/

+

+#string STR_PROPERTIES_MODULE_NAME

+#language en-US

+"Asf PEI"

diff --git a/AsfPkg/AsfPkg.dec b/AsfPkg/AsfPkg.dec
new file mode 100644
index 000000000000..b7bca0ac2231
--- /dev/null
+++ b/AsfPkg/AsfPkg.dec
@@ -0,0 +1,47 @@
+## @file

+# This package defines Asf specific interfaces and library classes.

+#

+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+# SPDX-License-Identifier: BSD-2-Clause-Patent

+##

+

+[Defines]

+  DEC_SPECIFICATION                   = 0x00010005

+  PACKAGE_NAME                        = AsfPkg

+  PACKAGE_GUID                        = 025BE9BD-50B3-4139-9A70-4336E277339A

+  PACKAGE_VERSION                     = 1.0

+

+[Includes]

+  Include

+

+[LibraryClasses]

+  ##  @libraryclass  Install Asf Acpi table

+  ##

+  AsfAcpiTableLib|AsfPkg\Library\AsfAcpiTableLib\AsfAcpiTableLib.inf

+

+[Guids]

+  gAsfPkgTokenSpaceGuid    = { 0xa12d9aa4, 0xe69b, 0x425c, { 0x96, 0xc5, 0x41, 
0x8d, 0xb1, 0xd0, 0xb9, 0x4f }}

+

+[Ppis]

+

+[Protocols]

+  ## Asf protocol GUID

+  # Include/Protocol/AmiAsfProtocol.h

+  gAsfProtocolGuid                  =  { 0xdec89827, 0x8a7e, 0x45e0, { 0xbc, 
0xb5, 0xd5, 0x3b, 0x46, 0x14, 0xad, 0xb8 } }

+

+[PcdsFeatureFlag]

+

+[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]

+  ## Specify the Dash lan SmBus slave address.

+  # @Prompt Slave address of Dash lan

+  gAsfPkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan|0x0|UINT8|0x00000001

+

+  ## This flag is used to control which message would be send.

+  #  If enabled, Asf driver will send message to device.<BR><BR>

+  #   BIT0  - Progress message is enabled.<BR>

+  #   BIT1  - Error message is enabled.<BR>

+  #   BIT2  - System menagement message is enabled.<BR>

+  #   Other - reserved

+  # @Prompt Message level

+  gAsfPkgTokenSpaceGuid.PcdAsfMessageErrorLevel|0x7|UINT32|0x00000002

+

diff --git a/AsfPkg/AsfPkg.dsc b/AsfPkg/AsfPkg.dsc
new file mode 100644
index 000000000000..acbede1ca02d
--- /dev/null
+++ b/AsfPkg/AsfPkg.dsc
@@ -0,0 +1,59 @@
+## @file

+# Asf Package

+#

+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+# SPDX-License-Identifier: BSD-2-Clause-Patent

+##

+

+[Defines]

+  PLATFORM_NAME             = AsfPkg

+  PLATFORM_GUID             = 79D22E13-3F30-470A-AF9D-B80CB4324379

+  PLATFORM_VERSION          = 0.10

+  DSC_SPECIFICATION         = 0x00010005

+  OUTPUT_DIRECTORY          = Build/AsfPkg

+  SUPPORTED_ARCHITECTURES   = IA32|X64

+  BUILD_TARGETS             = DEBUG|RELEASE|NOOPT

+

+

+[LibraryClasses]

+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf

+  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

+  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf

+  SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf

+  
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf

+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf

+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf

+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf

+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf

+  
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf

+  
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf

+  
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf

+  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf

+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf

+  
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf

+  
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf

+  
RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf

+

+

+[LibraryClasses.common.SEC]

+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf

+  
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf

+  
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf

+

+[LibraryClasses.common.PEIM]

+  
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf

+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf

+

+[LibraryClasses.IA32.PEIM, LibraryClasses.X64.PEIM]

+  
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf

+

+[LibraryClasses.common.DXE_DRIVER]

+  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf

+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf

+  AsfAcpiTableLib|AsfPkg\Library\AsfAcpiTableLib\AsfAcpiTableLib.inf

+

+[Components]

+

+[Components.IA32, Components.X64]

+  AsfPkg/Asf/AsfPei/AsfPei.inf

+  AsfPkg/Asf/AsfDxe/AsfDxe.inf

diff --git a/AsfPkg/Include/AsfMessages.h b/AsfPkg/Include/AsfMessages.h
new file mode 100644
index 000000000000..6e79f4993f33
--- /dev/null
+++ b/AsfPkg/Include/AsfMessages.h
@@ -0,0 +1,104 @@
+/** @file

+  Asf message format define.

+

+  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+  @par Revision Reference:

+  Format defined in Asf 2.0 Specification.

+**/

+

+#ifndef __ASF_MESSAGES_H__

+#define __ASF_MESSAGES_H__

+

+#include <Base.h>

+#include <IndustryStandard/Asf.h>

+

+#define MESSAGE_ERROR_LEVEL_PROGRESS           BIT0

+#define MESSAGE_ERROR_LEVEL_ERROR              BIT1

+#define MESSAGE_ERROR_LEVEL_SYSTEM_MANAGEMENT  BIT2

+

+#pragma pack(push,1)

+

+/**

+  This message causes the alert-sending device to transmit a single,

+  un-retransmitted PET frame. If the alert-sending device is either temporarily

+  unable to handle the message or unable to send the requested PET frame

+  because the device's transport media is down, the device must NACK the 
message

+  according to SMBUS_2.0 definitions; otherwise, the device sends the

+  single-frame transmission.

+**/

+typedef struct {

+  UINT8    Command;         ///< Message Command.

+  UINT8    ByteCount;       ///< Length of the data in bytes.

+  UINT8    SubCommand;      ///< SubCommand No Retransmit.

+  UINT8    Version;         ///< Version Number.

+  UINT8    EventSensorType; ///< Event Sensor Type.

+  UINT8    EventType;       ///< Event Type.

+  UINT8    EventOffset;     ///< Event Offset.

+  UINT8    EventSourceType; ///< Describes the originator of the event.

+  UINT8    EventSeverity;   ///< The severity of the event

+  UINT8    SensorDevice;    ///< The Sensor Device that caused the event

+  UINT8    SensorNumber;    ///< Identify a given instance of a sensor 
relative to the Sensor Device.

+  UINT8    Entity;          ///< Indicates the platform device or subsystem 
associated with the event.

+  UINT8    EntityInstance;  ///< Identifies which unique device is associated 
with the event.

+  UINT8    EventData1;

+  UINT8    EventData2;

+  UINT8    EventData3;

+  UINT8    EventData4;

+  UINT8    EventData5;

+} ASF_MSG_NORETRANSMIT;

+

+/**

+  This is the ASF START WatchDog Timer Data structure.

+

+**/

+typedef struct {

+  UINT8    Command;

+  UINT8    ByteCount;

+  UINT8    SubCommand;

+  UINT8    Version;

+} ASF_STOP_WATCHDOG;

+

+/**

+  This is the ASF Message Type structure.

+

+**/

+typedef enum {

+  MsgHddInit,

+  MsgApInit,

+  MsgUserInitSetup,

+  MsgUsbResourceConfig,

+  MsgPciResourceConfig,

+  MsgVideoInit,

+  MsgKbcInit,

+  MsgKbcTest,

+  MsgMotherBoardInit,

+  MsgNoVideo,

+  MsgKbdFailure,

+  MsgHddFailure,

+  MsgChassisIntrusion,

+  MsgNoBootMedia

+} ASF_MESSAGE_TYPE;

+

+/**

+  This is the Message Data Hub Map Structure.

+

+**/

+typedef struct {

+  ASF_MESSAGE_TYPE         MessageType;

+  EFI_STATUS_CODE_VALUE    StatusCode;

+} MESSAGE_DATA_HUB_MAP;

+

+/**

+  This is the ASF System Firmware Event Structure.

+

+**/

+typedef struct {

+  ASF_MESSAGE_TYPE        Type;

+  ASF_MSG_NORETRANSMIT    Message;

+} ASF_MESSAGE;

+

+#pragma pack(pop)

+

+#endif //__ASF_MESSAGES_H__

diff --git a/AsfPkg/Include/IndustryStandard/Asf.h 
b/AsfPkg/Include/IndustryStandard/Asf.h
new file mode 100644
index 000000000000..69b6a0230d4f
--- /dev/null
+++ b/AsfPkg/Include/IndustryStandard/Asf.h
@@ -0,0 +1,145 @@
+/** @file

+  Asf message commands byte define.

+

+  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+  @par Revision Reference:

+  Data defined in Asf 2.0 Specification.

+**/

+

+#ifndef __ASF_H__

+#define __ASF_H__

+

+#include <Base.h>

+

+//

+// Boot option messages

+//

+#define ASFMSG_CMD_CONFIG              0x3   // ASF Configuration

+#define ASFMSG_SUBCMD_CLR_BOOT_OPTION  0x15  // Clear Boot Options

+#define ASFMSG_SUBCMD_RET_BOOT_OPTION  0x16  // Return Boot Options

+#define ASFMSG_SUBCMD_NO_BOOT_OPTION   0x17  // No Boot Options

+

+//

+// System states

+//

+#define ASFMSG_SYSTEM_STATE_S0  0             // S0/G0 "Working"

+#define ASFMSG_SYSTEM_STATE_S1  1             // S1

+#define ASFMSG_SYSTEM_STATE_S2  2             // S2

+#define ASFMSG_SYSTEM_STATE_S3  3             // S3

+#define ASFMSG_SYSTEM_STATE_S4  4             // S4

+#define ASFMSG_SYSTEM_STATE_S5  5             // S5/G2 "Soft-off"

+

+//

+// Asf version

+//

+#define ASFMSG_VERSION_NUMBER_10      0x10

+

+//

+// System firmware capabilities Bit

+//

+#define ASF_BOP_BIT_FORCE_PROGRESS_EVENT        BIT12

+

+//

+// Asf message command

+//

+#define ASFMSG_COMMAND_SYSTEM_STATE               0x1

+#define ASFMSG_COMMAND_MANAGEMENT_CONTROL         0x2

+#define ASFMSG_COMMAND_MESSAGING                  0x4

+

+//

+// Asf message subcommand

+//

+#define ASFMSG_SUBCOMMAND_STOP_WATCH_DOG          0x14

+#define ASFMSG_SUBCOMMAND_NO_RETRANSMIT           0x16

+#define ASFMSG_SUBCOMMAND_SET_SYSTEM_STATE        0x18

+

+//

+// Asf message event sensor type

+//

+#define ASFMSG_EVENT_SENSOR_TYPE_CHASSIS_INTRUSION  0x5

+#define ASFMSG_EVENT_SENSOR_TYPE_FW_ERROR_PROGRESS  0xF

+#define ASFMSG_EVENT_SENSOR_TYPE_BOOT_ERROR         0x1E

+#define ASFMSG_EVENT_SENSOR_TYPE_ENTITY_PRESENCE    0x25

+

+//

+// Asf message event type

+//

+#define ASFMSG_EVENT_TYPE_SENSOR_SPECIFIC           0x6F

+

+//

+// Asf message event offset

+//

+#define ASFMSG_EVENT_OFFSET_ENTITY_PRESENT          0x0

+

+#define ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_ENTRY   0x2

+#define ASFMSG_EVENT_OFFSET_SYS_FW_PROGRESS_EXIT    0x82

+#define ASFMSG_EVENT_OFFSET_SYS_FW_ERROR   0x0

+

+#define ASFMSG_EVENT_OFFSET_NO_BOOTABLE_MEDIA       0x0

+#define ASFMSG_EVENT_OFFSET_CHASSIS_INTRUSION       0x0

+

+//

+// Asf message event source type

+//

+#define ASFMSG_EVENT_SOURCE_TYPE_ASF10              0x68

+

+//

+// Asf message event severity

+//

+#define ASFMSG_EVENT_SEVERITY_MONITOR               0x1

+#define ASFMSG_EVENT_SEVERITY_NON_CRITICAL          0x8

+#define ASFMSG_EVENT_SEVERITY_CRITICAL              0x10

+#define ASFMSG_EVENT_SEVERITY_NON_RECOVERABLE       0x20

+

+//

+// Asf message sensor device

+//

+#define ASFMSG_SENSOR_DEVICE_UNSPECIFIED            0xFF

+

+//

+// Asf message sensor number

+//

+#define ASFMSG_SENSOR_NUMBER_UNSPECIFIED            0xFF

+

+//

+// Asf message Entity

+//

+

+#define ASFMSG_ENTITY_UNSPECIFIED                   0x0

+#define ASFMSG_ENTITY_PROCESSOR                     0x3

+#define ASFMSG_ENTITY_DISK                          0x4

+#define ASFMSG_ENTITY_SYSTEM_BOARD                  0x7

+#define ASFMSG_ENTITY_ADD_IN_CARD                   0xB

+#define ASFMSG_ENTITY_BIOS                          0x22

+#define ASFMSG_ENTITY_MEMORY_DEVICE                 0x20

+

+//

+// Asf message entity instance

+//

+#define ASFMSG_ENTITY_INSTANCE_UNSPECIFIED          0x0

+

+//

+// Asf message event data

+//

+#define ASFMSG_EVENT_DATA1                          0x40

+#define ASFMSG_EVENT_DATA_UNSPECIFIED               0x0

+#define ASFMSG_EVENT_DATA_MEMORY_INITIALIZATION     0x1

+#define ASFMSG_EVENT_DATA_HARD_DISK_INITIALIZATION  0x2

+#define ASFMSG_EVENT_DATA_AP_INITIALIZATION         0x3

+#define ASFMSG_EVENT_DATA_SETUP_INITIALIZATION      0x5

+#define ASFMSG_EVENT_DATA_USB_RESOURCE_CONFIG       0x6

+#define ASFMSG_EVENT_DATA_PCI_RESOURCE_CONFIG       0x7

+#define ASFMSG_EVENT_DATA_VIDEO_INITIALIZATION      0x9

+#define ASFMSG_EVENT_DATA_CACHE_INITIALIZATION      0xA

+#define ASFMSG_EVENT_DATA_KEYBOARD_INITIALIZATION   0xC

+#define ASFMSG_EVENT_DATA_BOARD_INITIALIZATION      0x14

+#define ASFMSG_EVENT_DATA_KEYBOARD_TEST             0x17

+

+#define ASFMSG_EVENT_DATA_NO_MEMORY                 0x1

+#define ASFMSG_EVENT_DATA_HARD_DISK_FAILURE         0x3

+#define ASFMSG_EVENT_DATA_KEYBOARD_FAILURE          0x7

+#define ASFMSG_EVENT_DATA_NO_VIDEO                  0xA

+

+#endif //__ASF_H__

diff --git a/AsfPkg/Include/Library/AsfAcpiTableLib.h 
b/AsfPkg/Include/Library/AsfAcpiTableLib.h
new file mode 100644
index 000000000000..4b1d687825ff
--- /dev/null
+++ b/AsfPkg/Include/Library/AsfAcpiTableLib.h
@@ -0,0 +1,26 @@
+/** @file

+  Provides services to create Asf Acpi table.

+

+  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#ifndef __ASF_ACPI_TABLE_LIB_H__

+#define __ASF_ACPI_TABLE_LIB_H__

+

+#include <Uefi.h>

+

+/**

+  This function install the ASF acpi Table.

+

+  @param[in]  Event     A pointer to the Event that triggered the callback.

+  @param[in]  Context   A pointer to private data registered with the callback 
function.

+**/

+VOID

+EFIAPI

+InstallAsfAcpiTableEvent  (

+  IN EFI_EVENT  Event,

+  IN VOID       *Context

+  );

+

+#endif

diff --git a/AsfPkg/Include/Protocol/AsfProtocol.h 
b/AsfPkg/Include/Protocol/AsfProtocol.h
new file mode 100644
index 000000000000..d3af0fba73bd
--- /dev/null
+++ b/AsfPkg/Include/Protocol/AsfProtocol.h
@@ -0,0 +1,57 @@
+/** @file

+  Asf protocol define.

+

+  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#ifndef __ASF_PROTOCOL_H__

+#define __ASF_PROTOCOL_H__

+

+#include <IndustryStandard/SmBus.h>

+

+#define ASF_PROTOCOL_GUID \

+  { \

+    0xdec89827, 0x8a7e, 0x45e0, { 0xbc, 0xb5, 0xd5, 0x3b, 0x46, 0x14, 0xad, 
0xb8 } \

+  }

+

+#pragma pack(push, 1)

+

+/**

+  This is the ASF Boot Option data structure.

+

+**/

+typedef struct {

+  UINT8     SubCommand;

+  UINT8     Version;

+  UINT32    IanaId;

+  UINT8     SpecialCommand;

+  UINT16    SpecCmdParameter;

+  UINT16    BootOptionBit;

+  UINT16    OemParameter;

+} ASF_BOOT_OPTION;

+

+/**

+  This is the ASF PUSH EVENT Structure.

+

+**/

+typedef EFI_STATUS (EFIAPI *ASF_PUSH_EVENT)(

+                                            IN UINT8 Command,

+                                            IN UINTN Length,

+                                            IN UINT8 *ASFEvent

+                                            );

+

+/**

+  This is the AMI ASF Protocol Structure.

+

+**/

+typedef struct {

+  ASF_PUSH_EVENT     PushEvent;

+  ASF_BOOT_OPTION    *BootOption;

+} ASF_PROTOCOL;

+

+#pragma pack(pop)

+

+extern EFI_GUID  gAsfProtocolGuid;

+

+#endif //__ASF_PROTOCOL_H__

diff --git a/AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.inf 
b/AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.inf
new file mode 100644
index 000000000000..ca90d02f005b
--- /dev/null
+++ b/AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.inf
@@ -0,0 +1,30 @@
+## @file

+#  Asf Acpi table Library instance that create Asf Acpi table

+#

+#  Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+#  SPDX-License-Identifier: BSD-2-Clause-Patent

+##

+

+[Defines]

+  INF_VERSION                    = 0x00010005

+  BASE_NAME                      = AsfAcpiTableLib

+  MODULE_UNI_FILE                = AsfAcpiTableLib.uni

+  FILE_GUID                      = 9A0EC995-0F1A-444C-BA02-8C3F0482AE8C

+  MODULE_TYPE                    = DXE_DRIVER

+  VERSION_STRING                 = 1.0

+  LIBRARY_CLASS                  = AsfAcpiTableLib | DXE_DRIVER 
DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER

+

+[Sources]

+  AsfAcpiTableLib.c

+

+[Packages]

+  MdePkg/MdePkg.dec

+  MdeModulePkg/MdeModulePkg.dec

+

+[Protocols]

+  gEfiAcpiTableProtocolGuid                     ## CONSUMES

+

+[LibraryClasses]

+  BaseLib

+  DebugLib

+

diff --git a/AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.uni 
b/AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.uni
new file mode 100644
index 000000000000..681458140452
--- /dev/null
+++ b/AsfPkg/Library/AsfAcpiTableLib/AsfAcpiTableLib.uni
@@ -0,0 +1,15 @@
+// /** @file

+// Asf Acpi table

+//

+// Install Asf Acpi table

+//

+// Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>

+// SPDX-License-Identifier: BSD-2-Clause-Patent

+//

+// **/

+

+

+#string STR_MODULE_ABSTRACT             #language en-US "Asf Acpi table"

+

+#string STR_MODULE_DESCRIPTION          #language en-US "Install Asf Acpi 
table."

+

--
2.36.0.windows.1
-The information contained in this message may be confidential and proprietary 
to American Megatrends (AMI). This communication is intended to be read only by 
the individual or entity to whom it is addressed or by their designee. If the 
reader of this message is not the intended recipient, you are on notice that 
any distribution of this message, in any form, is strictly prohibited. Please 
promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and 
then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#92210): https://edk2.groups.io/g/devel/message/92210
Mute This Topic: https://groups.io/mt/92898446/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to