* [PATCH v2 0/1] AsfFeaturePkg: Add Alert standard format support
@ 2022-09-05 12:15 CrystalLee [李怡萱]
2022-09-05 12:15 ` [PATCH v2 1/1] Features/Intel/OutOfBandManagement/AsfFeaturePkg: Add initial package CrystalLee [李怡萱]
0 siblings, 1 reply; 4+ messages in thread
From: CrystalLee [李怡萱] @ 2022-09-05 12:15 UTC (permalink / raw)
To: devel@edk2.groups.io
Cc: isaac.w.oram@intel.com, rangasai.v.chaganty@intel.com,
nathaniel.l.desimone@intel.com, gaoliming@byosoft.com.cn,
DavidHsieh [謝坤智],
CrystalLee [李怡萱]
Issac,
Thank you for your advice.
I change to edk2-platform repository and create AsfFeaturePkg branch in the forked edk2-platform repository
REF: https://github.com/CrystalLee-77/edk2-platforms/tree/AsfFeaturePkg
Patch V2 change lists:
1. Add the Asf feature in edk2-platforms/Features/Intel/OutOfBandManagement/AsfFeaturePkg
2. Remove AsfAcpitable library. Create PcdControlDataArrays for remote control in Asf Acpi table.
3. Add Readme.md
4. Improve the coding that your provided in the review comments.
• Asf.h has a whitespace alignment issue on line 78 -- removed
• AsfPei.inf – does it really support EBC? -- removed EBC support
• ## PRODUCES and ## CONSUMES are added in INF
• AsfDxe.c – add missing @param in AsfGetBootOption function
o Line 331 has a trailing ‘\’ -- removed
Regards,
Crystal
CrystalLee (1):
Features/Intel/OutOfBandManagement/AsfFeaturePkg: Add initial package
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c | 234 ++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c | 340 +++++++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c | 319 ++++++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c | 384 ++++++++++++++++++++
Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc | 1 +
Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc | 4 +
Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc | 2 +
Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf | 4 +
Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf | 4 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h | 66 ++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf | 51 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni | 15 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni | 13 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec | 47 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc | 40 ++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf | 51 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni | 15 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni | 13 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc | 52 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h | 104 ++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h | 145 ++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf | 8 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf | 8 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h | 57 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md | 63 ++++
25 files changed, 2040 insertions(+)
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h
create mode 100644 Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md
--
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/1] Features/Intel/OutOfBandManagement/AsfFeaturePkg: Add initial package
2022-09-05 12:15 [PATCH v2 0/1] AsfFeaturePkg: Add Alert standard format support CrystalLee [李怡萱]
@ 2022-09-05 12:15 ` CrystalLee [李怡萱]
2022-09-07 22:36 ` Isaac Oram
[not found] ` <1712B4FC5186ABBC.20240@groups.io>
0 siblings, 2 replies; 4+ messages in thread
From: CrystalLee [李怡萱] @ 2022-09-05 12:15 UTC (permalink / raw)
To: devel@edk2.groups.io
Cc: isaac.w.oram@intel.com, rangasai.v.chaganty@intel.com,
nathaniel.l.desimone@intel.com, gaoliming@byosoft.com.cn,
DavidHsieh [謝坤智],
CrystalLee [李怡萱]
Add a new feature package for Alert standard format support.
Alert Standard format specification(DSP0136)
REF:https://www.dmtf.org/sites/default/files/standards/documents/DSP0136.pdf
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: CrystalLee <CrystalLee@ami.com>
---
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c | 234 ++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c | 340 +++++++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c | 319 ++++++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c | 384 ++++++++++++++++++++
Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc | 1 +
Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc | 4 +
Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc | 2 +
Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf | 4 +
Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf | 4 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h | 66 ++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf | 51 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni | 15 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni | 13 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec | 47 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc | 40 ++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf | 51 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni | 15 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni | 13 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc | 52 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h | 104 ++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h | 145 ++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf | 8 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf | 8 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h | 57 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md | 63 ++++
25 files changed, 2040 insertions(+)
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c
new file mode 100644
index 0000000000..7d4a864e2c
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c
@@ -0,0 +1,234 @@
+/** @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>
+#include <Library/BaseMemoryLib.h>
+
+// ASF Table Definitions
+// Below array size define should follow mAsfAcpiTable 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 mAsfAcpiTable = {
+ {
+ 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;
+ UINT8 *ControlDataArrays;
+ UINTN ControlDataArraysSize;
+
+ 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);
+ }
+
+ ControlDataArrays = (UINT8 *)PcdGetPtr (PcdControlDataArrays);
+ ControlDataArraysSize = PcdGetSize (PcdControlDataArrays);
+
+ if (ControlDataArraysSize == (sizeof(EFI_ACPI_ASF_CONTROLDATA) * ASF_RCTL_DEVICES_ARRAY_LENGTH)) {
+ // Currently Asf 2.0 spec only support four type of control function, so We support 4 arrays of
+ // EFI_ACPI_ASF_CONTROLDATA that should be defined in the PcdControlDataArrays
+ CopyMem((VOID *)(UINTN)mAsfAcpiTable.AsfRctlAll.ControlDataArray, (VOID *)(UINTN)ControlDataArrays, ControlDataArraysSize);
+ }
+
+{
+ UINTN Index;
+
+ DEBUG ((DEBUG_ERROR, "crystal ControlDataArraysSize = %x\n", ControlDataArraysSize));
+ DEBUG ((DEBUG_ERROR, "ControlDataArrays = \n"));
+ for (Index = 0; Index < ControlDataArraysSize; Index++) {
+ if ((Index != 0) && (Index % 4) == 0) DEBUG ((DEBUG_ERROR, "\n"));
+ DEBUG ((DEBUG_ERROR, "%02x ", ControlDataArrays[Index]));
+ }
+ DEBUG ((DEBUG_ERROR, "\n"));
+}
+
+ AcpiTableProtocol->InstallAcpiTable (
+ AcpiTableProtocol,
+ &mAsfAcpiTable,
+ mAsfAcpiTable.Header.Length,
+ &TableHandle
+ );
+
+ return;
+}
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c
new file mode 100644
index 0000000000..7d680404ba
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c
@@ -0,0 +1,340 @@
+/** @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.
+
+ @param[in] AsfSlaveAddress Specify the Dash lan SmBus slave address.
+
+ @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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c
new file mode 100644
index 0000000000..64265c6d5c
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c
new file mode 100644
index 0000000000..8b44cd26e0
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc b/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc
index f0f1e0435f..ce0eac7a56 100644
--- a/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc
+++ b/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc
@@ -63,6 +63,7 @@
#
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable |TRUE
gSpcrFeaturePkgTokenSpaceGuid.PcdSpcrFeatureEnable |TRUE
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable |TRUE
#
# PowerManagement features
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc
index 804aab89bc..85a067d6a0 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc
+++ b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc
@@ -47,6 +47,10 @@
!include SpcrFeaturePkg/Include/SpcrFeature.dsc
!endif
+!if gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable == TRUE
+ !include AsfFeaturePkg/Include/AsfFeature.dsc
+!endif
+
#
# PowerManagement features
#
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc
index 0af5a8bfbc..ebf8d1f9b8 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc
+++ b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc
@@ -35,6 +35,7 @@
#
IpmiFeaturePkg/IpmiFeaturePkg.dec
SpcrFeaturePkg/SpcrFeaturePkg.dec
+ AsfFeaturePkg/AsfFeaturePkg.dec
#
# PowerManagement features
@@ -73,6 +74,7 @@
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable |FALSE
gSpcrFeaturePkgTokenSpaceGuid.PcdSpcrFeatureEnable |FALSE
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable |FALSE
gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable |FALSE
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf b/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf
index 349bdcc491..acfbb0e209 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf
+++ b/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf
@@ -48,6 +48,10 @@
!include SpcrFeaturePkg/Include/PostMemory.fdf
!endif
+!if gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable == TRUE
+ !include AsfFeaturePkg/Include/PostMemory.fdf
+!endif
+
#
# PowerManagement features
#
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf b/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf
index b991a5aabf..90b03e6108 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf
+++ b/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf
@@ -48,6 +48,10 @@
!include SpcrFeaturePkg/Include/PreMemory.fdf
!endif
+!if gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable == TRUE
+ !include AsfFeaturePkg/Include/PreMemory.fdf
+!endif
+
#
# PowerManagement features
#
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h
new file mode 100644
index 0000000000..9cde358b93
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h
@@ -0,0 +1,66 @@
+/** @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 <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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf
new file mode 100644
index 0000000000..44517cfd27
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf
@@ -0,0 +1,51 @@
+## @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
+ AsfAcpiTable.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AsfFeaturePkg/AsfFeaturePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ UefiRuntimeServicesTableLib
+ DebugLib
+ BaseMemoryLib
+ PrintLib
+ UefiLib
+
+[Protocols]
+ gEfiRscHandlerProtocolGuid ## CONSUMES
+ gAsfProtocolGuid ## PRODUCES
+ gEfiAcpiTableProtocolGuid ## CONSUMES
+ gEfiSmbusHcProtocolGuid ## CONSUMES
+
+[Pcd]
+ gAsfFeaturePkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfMessageErrorLevel
+ gAsfFeaturePkgTokenSpaceGuid.PcdControlDataArrays
+
+[Depex]
+ TRUE
+
+[UserExtensions.TianoCore."ExtraFiles"]
+ AsfDxeExtra.uni
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni
new file mode 100644
index 0000000000..02ff1f7293
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni
new file mode 100644
index 0000000000..dbc747257c
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec
new file mode 100644
index 0000000000..d5df0cb62f
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.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 = AsfFeaturePkg
+ PACKAGE_GUID = 025BE9BD-50B3-4139-9A70-4336E277339A
+ PACKAGE_VERSION = 1.0
+
+[Includes]
+ Include
+
+[Guids]
+ gAsfFeaturePkgTokenSpaceGuid = { 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]
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable|FALSE|BOOLEAN|0x00000001
+
+[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
+ ## Specifies the Dash lan SmBus slave address.
+ # @Prompt Slave address of Dash lan
+ gAsfFeaturePkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan|0x0|UINT8|0x90000001
+
+ ## 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
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfMessageErrorLevel|0x7|UINT32|0x90000002
+
+ ## Specifies the four arrays of control datas in the ASF_RCTL Acpi table.
+ # @Prompt the four arrays of control datas that used in ASF_RCTL.
+ gAsfFeaturePkgTokenSpaceGuid.PcdControlDataArrays|{0x00, 0x88, 0x00, 0x03, 0x01, 0x88, 0x00, 0x02, 0x02, 0x88, 0x00, 0x01, 0x03, 0x88, 0x00, 0x04}|VOID*|0x90000003
+
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc
new file mode 100644
index 0000000000..006f3892ba
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc
@@ -0,0 +1,40 @@
+## @file
+# Asf Package
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ PLATFORM_NAME = AsfFeaturePkg
+ PLATFORM_GUID = 79D22E13-3F30-470A-AF9D-B80CB4324379
+ PLATFORM_VERSION = 0.1
+ DSC_SPECIFICATION = 0x00010005
+ OUTPUT_DIRECTORY = Build/$(PLATFORM_NAME)
+ SUPPORTED_ARCHITECTURES = IA32|X64
+ BUILD_TARGETS = DEBUG|RELEASE|NOOPT
+ SKUID_IDENTIFIER = DEFAULT
+ PEI_ARCH = IA32
+ DXE_ARCH = X64
+
+[Packages]
+ MinPlatformPkg/MinPlatformPkg.dec
+
+#
+# MinPlatform common include for required feature PCD
+# These PCD must be set before the core include files, CoreCommonLib,
+# CorePeiLib, and CoreDxeLib.
+#
+!include MinPlatformPkg/Include/Dsc/MinPlatformFeaturesPcd.dsc.inc
+
+#
+# Include common libraries
+#
+!include MinPlatformPkg/Include/Dsc/CoreCommonLib.dsc
+!include MinPlatformPkg/Include/Dsc/CorePeiLib.dsc
+!include MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
+
+#
+# This package always builds the feature.
+#
+!include Include/AsfFeature.dsc
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf
new file mode 100644
index 0000000000..a0239f1990
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf
@@ -0,0 +1,51 @@
+## @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
+#
+
+[Sources]
+ AsfPei.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AsfFeaturePkg/AsfFeaturePkg.dec
+
+[LibraryClasses]
+ PeimEntryPoint
+ PeiServicesLib
+ DebugLib
+
+[Ppis]
+ gEfiPeiRscHandlerPpiGuid ## CONSUMES
+ gEfiPeiMemoryDiscoveredPpiGuid ## CONSUMES
+ gEfiPeiSmbus2PpiGuid ## CONSUMES
+
+[Pcd]
+ gAsfFeaturePkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfMessageErrorLevel
+
+[Depex]
+ gEfiPeiSmbus2PpiGuid
+
+[UserExtensions.TianoCore."ExtraFiles"]
+ AsfPeiExtra.uni
+
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni
new file mode 100644
index 0000000000..646712917e
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni
new file mode 100644
index 0000000000..72819f4986
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc
new file mode 100644
index 0000000000..d76ab30008
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc
@@ -0,0 +1,52 @@
+## @file
+# Asf Package
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+!ifndef $(PEI_ARCH)
+ !error "PEI_ARCH must be specified to build this feature!"
+!endif
+!ifndef $(DXE_ARCH)
+ !error "DXE_ARCH must be specified to build this feature!"
+!endif
+
+
+################################################################################
+#
+# Component section - list of all components that need built for this feature.
+#
+# Note: The EDK II DSC file is not used to specify how compiled binary images get placed
+# into firmware volume images. This section is just a list of modules to compile from
+# source into UEFI-compliant binaries.
+# It is the FDF file that contains information on combining binary files into firmware
+# volume images, whose concept is beyond UEFI and is described in PI specification.
+# There may also be modules listed in this section that are not required in the FDF file,
+# When a module listed here is excluded from FDF file, then UEFI-compliant binary will be
+# generated for it, but the binary will not be put into any firmware volume.
+#
+################################################################################
+#
+# Feature PEI Components
+#
+
+# @todo: Change below line to [Components.$(PEI_ARCH)] after https://bugzilla.tianocore.org/show_bug.cgi?id=2308
+# is completed.
+[Components.IA32]
+ AsfFeaturePkg/AsfPei/AsfPei.inf
+
+#
+# Feature DXE Components
+#
+
+# @todo: Change below line to [Components.$(DXE_ARCH)] after https://bugzilla.tianocore.org/show_bug.cgi?id=2308
+# is completed.
+[Components.X64]
+ AsfFeaturePkg/AsfDxe/AsfDxe.inf
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h
new file mode 100644
index 0000000000..6e79f4993f
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h
new file mode 100644
index 0000000000..f660fe0b72
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf
new file mode 100644
index 0000000000..1038e77b5d
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf
@@ -0,0 +1,8 @@
+## @file
+# FDF file for post-memory modules that enable Intelligent Platform Management Interface.
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+INF AsfFeaturePkg/AsfDxe/AsfDxe.inf
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf
new file mode 100644
index 0000000000..a723544855
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf
@@ -0,0 +1,8 @@
+## @file
+# FDF file for pre-memory modules that enable Intelligent Platform Management Interface.
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+INF AsfFeaturePkg/AsfPei/AsfPei.inf
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h
new file mode 100644
index 0000000000..d3af0fba73
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md
new file mode 100644
index 0000000000..f18b1bfb07
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md
@@ -0,0 +1,63 @@
+# Overview
+* **Feature Name:** Alert Standard Format (ASF)
+* **PI Phase(s) Supported:** PEI, DXE
+* **SMM Required?** No
+
+More Information:
+* [ASF Specification v2.0](https://www.dmtf.org/sites/default/files/standards/documents/DSP0136.pdf)
+
+## Purpose
+The ASF feature provides firmware functionality that implements behavior described in the ASF specification.
+Alerting technologies provide advance warning and system failure indication from managed clients to remote management consoles. Once a system alert provides its warning or error report, the next step in remote system manageability is to allow corrective action to be taken — these actions include the ability to remotely reset or power-on or -off the client system.
+
+# High-Level Theory of Operation
+Bases on the system reported status code, the driver will send warning or system failure indication from managed clients to remote management consoles.
+
+## Firmware Volumes
+* AsfPei: PreMemory
+* AsfDxe: PostMemory
+
+## Modules
+* AsfPei
+* AsfDxe
+
+## AsfPei
+Asf initialize and send standard progress messages to NIC.
+
+## AsfDxe
+Install Asf Acpi table and register RSC handle to send progress/error event logs to NIC.
+Produce Asf Dxe protocol.
+
+## <Library Name>
+N/A now.
+
+## Key Functions
+AsfPushEvent: This function is provided in protocol, call this function to send messages to NIC.
+
+## Configuration
+For PcdControlDataArrays structure information, please check Asf2.0 spec chapter 4.1.2.5 ASF_CONTROLDATA.
+
+## Data Flows
+AsfPushEvent() -> through SmBus -> NIC -> Remote management consoles
+
+## Control Flows
+N/A now.
+
+## Build Flows
+There is not special build flow.
+
+## Test Point Results
+There are not test points implemented.
+
+## Functional Exit Criteria
+Check Asf Acpi table
+Check the event log in remote management consoles
+
+## Feature Enabling Checklist
+PcdAsfFeatureEnable to enable this feature.
+
+## Performance Impact
+There is no performance impact.
+
+## Common Optimizations
+N/A now.
--
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.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] Features/Intel/OutOfBandManagement/AsfFeaturePkg: Add initial package
2022-09-05 12:15 ` [PATCH v2 1/1] Features/Intel/OutOfBandManagement/AsfFeaturePkg: Add initial package CrystalLee [李怡萱]
@ 2022-09-07 22:36 ` Isaac Oram
[not found] ` <1712B4FC5186ABBC.20240@groups.io>
1 sibling, 0 replies; 4+ messages in thread
From: Isaac Oram @ 2022-09-07 22:36 UTC (permalink / raw)
To: CrystalLee [李怡萱], devel@edk2.groups.io
Cc: Chaganty, Rangasai V, Desimone, Nathaniel L, Gao, Liming,
DavidHsieh [謝坤智]
Reviewed-by: Isaac Oram <isaac.w.oram@intel.com>
Looks good, thank you.
-----Original Message-----
From: CrystalLee [李怡萱] <CrystalLee@ami.com>
Sent: Monday, September 5, 2022 5:15 AM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; DavidHsieh [謝坤智] <DavidHsieh@ami.com>; CrystalLee [李怡萱] <CrystalLee@ami.com>
Subject: [PATCH v2 1/1] Features/Intel/OutOfBandManagement/AsfFeaturePkg: Add initial package
Add a new feature package for Alert standard format support.
Alert Standard format specification(DSP0136)
REF:https://www.dmtf.org/sites/default/files/standards/documents/DSP0136.pdf
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: CrystalLee <CrystalLee@ami.com>
---
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c | 234 ++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c | 340 +++++++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c | 319 ++++++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c | 384 ++++++++++++++++++++
Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc | 1 +
Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc | 4 +
Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc | 2 +
Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf | 4 +
Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf | 4 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h | 66 ++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf | 51 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni | 15 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni | 13 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec | 47 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc | 40 ++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf | 51 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni | 15 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni | 13 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc | 52 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h | 104 ++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h | 145 ++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf | 8 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf | 8 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h | 57 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md | 63 ++++
25 files changed, 2040 insertions(+)
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c
new file mode 100644
index 0000000000..7d4a864e2c
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c
@@ -0,0 +1,234 @@
+/** @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>
+#include <Library/BaseMemoryLib.h>
+
+// ASF Table Definitions
+// Below array size define should follow mAsfAcpiTable 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 mAsfAcpiTable = {
+ {
+ 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;
+ UINT8 *ControlDataArrays;
+ UINTN ControlDataArraysSize;
+
+ 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);
+ }
+
+ ControlDataArrays = (UINT8 *)PcdGetPtr (PcdControlDataArrays);
+ ControlDataArraysSize = PcdGetSize (PcdControlDataArrays);
+
+ if (ControlDataArraysSize == (sizeof(EFI_ACPI_ASF_CONTROLDATA) * ASF_RCTL_DEVICES_ARRAY_LENGTH)) {
+ // Currently Asf 2.0 spec only support four type of control function, so We support 4 arrays of
+ // EFI_ACPI_ASF_CONTROLDATA that should be defined in the PcdControlDataArrays
+ CopyMem((VOID *)(UINTN)mAsfAcpiTable.AsfRctlAll.ControlDataArray, (VOID *)(UINTN)ControlDataArrays, ControlDataArraysSize);
+ }
+
+{
+ UINTN Index;
+
+ DEBUG ((DEBUG_ERROR, "crystal ControlDataArraysSize = %x\n", ControlDataArraysSize));
+ DEBUG ((DEBUG_ERROR, "ControlDataArrays = \n"));
+ for (Index = 0; Index < ControlDataArraysSize; Index++) {
+ if ((Index != 0) && (Index % 4) == 0) DEBUG ((DEBUG_ERROR, "\n"));
+ DEBUG ((DEBUG_ERROR, "%02x ", ControlDataArrays[Index]));
+ }
+ DEBUG ((DEBUG_ERROR, "\n"));
+}
+
+ AcpiTableProtocol->InstallAcpiTable (
+ AcpiTableProtocol,
+ &mAsfAcpiTable,
+ mAsfAcpiTable.Header.Length,
+ &TableHandle
+ );
+
+ return;
+}
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c
new file mode 100644
index 0000000000..7d680404ba
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c
@@ -0,0 +1,340 @@
+/** @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.
+
+ @param[in] AsfSlaveAddress Specify the Dash lan SmBus slave address.
+
+ @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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c
new file mode 100644
index 0000000000..64265c6d5c
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c
new file mode 100644
index 0000000000..8b44cd26e0
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc b/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc
index f0f1e0435f..ce0eac7a56 100644
--- a/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc
+++ b/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc
@@ -63,6 +63,7 @@
#
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable |TRUE
gSpcrFeaturePkgTokenSpaceGuid.PcdSpcrFeatureEnable |TRUE
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable |TRUE
#
# PowerManagement features
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc
index 804aab89bc..85a067d6a0 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc
+++ b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc
@@ -47,6 +47,10 @@
!include SpcrFeaturePkg/Include/SpcrFeature.dsc
!endif
+!if gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable == TRUE
+ !include AsfFeaturePkg/Include/AsfFeature.dsc
+!endif
+
#
# PowerManagement features
#
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc
index 0af5a8bfbc..ebf8d1f9b8 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc
+++ b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc
@@ -35,6 +35,7 @@
#
IpmiFeaturePkg/IpmiFeaturePkg.dec
SpcrFeaturePkg/SpcrFeaturePkg.dec
+ AsfFeaturePkg/AsfFeaturePkg.dec
#
# PowerManagement features
@@ -73,6 +74,7 @@
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable |FALSE
gSpcrFeaturePkgTokenSpaceGuid.PcdSpcrFeatureEnable |FALSE
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable |FALSE
gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable |FALSE
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf b/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf
index 349bdcc491..acfbb0e209 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf
+++ b/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf
@@ -48,6 +48,10 @@
!include SpcrFeaturePkg/Include/PostMemory.fdf
!endif
+!if gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable == TRUE
+ !include AsfFeaturePkg/Include/PostMemory.fdf
+!endif
+
#
# PowerManagement features
#
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf b/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf
index b991a5aabf..90b03e6108 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf
+++ b/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf
@@ -48,6 +48,10 @@
!include SpcrFeaturePkg/Include/PreMemory.fdf
!endif
+!if gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable == TRUE
+ !include AsfFeaturePkg/Include/PreMemory.fdf
+!endif
+
#
# PowerManagement features
#
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h
new file mode 100644
index 0000000000..9cde358b93
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h
@@ -0,0 +1,66 @@
+/** @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 <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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf
new file mode 100644
index 0000000000..44517cfd27
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf
@@ -0,0 +1,51 @@
+## @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
+ AsfAcpiTable.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AsfFeaturePkg/AsfFeaturePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ UefiRuntimeServicesTableLib
+ DebugLib
+ BaseMemoryLib
+ PrintLib
+ UefiLib
+
+[Protocols]
+ gEfiRscHandlerProtocolGuid ## CONSUMES
+ gAsfProtocolGuid ## PRODUCES
+ gEfiAcpiTableProtocolGuid ## CONSUMES
+ gEfiSmbusHcProtocolGuid ## CONSUMES
+
+[Pcd]
+ gAsfFeaturePkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfMessageErrorLevel
+ gAsfFeaturePkgTokenSpaceGuid.PcdControlDataArrays
+
+[Depex]
+ TRUE
+
+[UserExtensions.TianoCore."ExtraFiles"]
+ AsfDxeExtra.uni
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni
new file mode 100644
index 0000000000..02ff1f7293
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni
new file mode 100644
index 0000000000..dbc747257c
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec
new file mode 100644
index 0000000000..d5df0cb62f
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.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 = AsfFeaturePkg
+ PACKAGE_GUID = 025BE9BD-50B3-4139-9A70-4336E277339A
+ PACKAGE_VERSION = 1.0
+
+[Includes]
+ Include
+
+[Guids]
+ gAsfFeaturePkgTokenSpaceGuid = { 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]
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable|FALSE|BOOLEAN|0x00000001
+
+[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
+ ## Specifies the Dash lan SmBus slave address.
+ # @Prompt Slave address of Dash lan
+ gAsfFeaturePkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan|0x0|UINT8|0x90000001
+
+ ## 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
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfMessageErrorLevel|0x7|UINT32|0x90000002
+
+ ## Specifies the four arrays of control datas in the ASF_RCTL Acpi table.
+ # @Prompt the four arrays of control datas that used in ASF_RCTL.
+ gAsfFeaturePkgTokenSpaceGuid.PcdControlDataArrays|{0x00, 0x88, 0x00, 0x03, 0x01, 0x88, 0x00, 0x02, 0x02, 0x88, 0x00, 0x01, 0x03, 0x88, 0x00, 0x04}|VOID*|0x90000003
+
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc
new file mode 100644
index 0000000000..006f3892ba
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc
@@ -0,0 +1,40 @@
+## @file
+# Asf Package
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ PLATFORM_NAME = AsfFeaturePkg
+ PLATFORM_GUID = 79D22E13-3F30-470A-AF9D-B80CB4324379
+ PLATFORM_VERSION = 0.1
+ DSC_SPECIFICATION = 0x00010005
+ OUTPUT_DIRECTORY = Build/$(PLATFORM_NAME)
+ SUPPORTED_ARCHITECTURES = IA32|X64
+ BUILD_TARGETS = DEBUG|RELEASE|NOOPT
+ SKUID_IDENTIFIER = DEFAULT
+ PEI_ARCH = IA32
+ DXE_ARCH = X64
+
+[Packages]
+ MinPlatformPkg/MinPlatformPkg.dec
+
+#
+# MinPlatform common include for required feature PCD
+# These PCD must be set before the core include files, CoreCommonLib,
+# CorePeiLib, and CoreDxeLib.
+#
+!include MinPlatformPkg/Include/Dsc/MinPlatformFeaturesPcd.dsc.inc
+
+#
+# Include common libraries
+#
+!include MinPlatformPkg/Include/Dsc/CoreCommonLib.dsc
+!include MinPlatformPkg/Include/Dsc/CorePeiLib.dsc
+!include MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
+
+#
+# This package always builds the feature.
+#
+!include Include/AsfFeature.dsc
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf
new file mode 100644
index 0000000000..a0239f1990
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf
@@ -0,0 +1,51 @@
+## @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
+#
+
+[Sources]
+ AsfPei.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AsfFeaturePkg/AsfFeaturePkg.dec
+
+[LibraryClasses]
+ PeimEntryPoint
+ PeiServicesLib
+ DebugLib
+
+[Ppis]
+ gEfiPeiRscHandlerPpiGuid ## CONSUMES
+ gEfiPeiMemoryDiscoveredPpiGuid ## CONSUMES
+ gEfiPeiSmbus2PpiGuid ## CONSUMES
+
+[Pcd]
+ gAsfFeaturePkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfMessageErrorLevel
+
+[Depex]
+ gEfiPeiSmbus2PpiGuid
+
+[UserExtensions.TianoCore."ExtraFiles"]
+ AsfPeiExtra.uni
+
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni
new file mode 100644
index 0000000000..646712917e
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni
new file mode 100644
index 0000000000..72819f4986
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc
new file mode 100644
index 0000000000..d76ab30008
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc
@@ -0,0 +1,52 @@
+## @file
+# Asf Package
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+!ifndef $(PEI_ARCH)
+ !error "PEI_ARCH must be specified to build this feature!"
+!endif
+!ifndef $(DXE_ARCH)
+ !error "DXE_ARCH must be specified to build this feature!"
+!endif
+
+
+################################################################################
+#
+# Component section - list of all components that need built for this feature.
+#
+# Note: The EDK II DSC file is not used to specify how compiled binary images get placed
+# into firmware volume images. This section is just a list of modules to compile from
+# source into UEFI-compliant binaries.
+# It is the FDF file that contains information on combining binary files into firmware
+# volume images, whose concept is beyond UEFI and is described in PI specification.
+# There may also be modules listed in this section that are not required in the FDF file,
+# When a module listed here is excluded from FDF file, then UEFI-compliant binary will be
+# generated for it, but the binary will not be put into any firmware volume.
+#
+################################################################################
+#
+# Feature PEI Components
+#
+
+# @todo: Change below line to [Components.$(PEI_ARCH)] after https://bugzilla.tianocore.org/show_bug.cgi?id=2308
+# is completed.
+[Components.IA32]
+ AsfFeaturePkg/AsfPei/AsfPei.inf
+
+#
+# Feature DXE Components
+#
+
+# @todo: Change below line to [Components.$(DXE_ARCH)] after https://bugzilla.tianocore.org/show_bug.cgi?id=2308
+# is completed.
+[Components.X64]
+ AsfFeaturePkg/AsfDxe/AsfDxe.inf
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h
new file mode 100644
index 0000000000..6e79f4993f
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h
new file mode 100644
index 0000000000..f660fe0b72
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf
new file mode 100644
index 0000000000..1038e77b5d
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf
@@ -0,0 +1,8 @@
+## @file
+# FDF file for post-memory modules that enable Intelligent Platform Management Interface.
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+INF AsfFeaturePkg/AsfDxe/AsfDxe.inf
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf
new file mode 100644
index 0000000000..a723544855
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf
@@ -0,0 +1,8 @@
+## @file
+# FDF file for pre-memory modules that enable Intelligent Platform Management Interface.
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+INF AsfFeaturePkg/AsfPei/AsfPei.inf
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h
new file mode 100644
index 0000000000..d3af0fba73
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md
new file mode 100644
index 0000000000..f18b1bfb07
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md
@@ -0,0 +1,63 @@
+# Overview
+* **Feature Name:** Alert Standard Format (ASF)
+* **PI Phase(s) Supported:** PEI, DXE
+* **SMM Required?** No
+
+More Information:
+* [ASF Specification v2.0](https://www.dmtf.org/sites/default/files/standards/documents/DSP0136.pdf)
+
+## Purpose
+The ASF feature provides firmware functionality that implements behavior described in the ASF specification.
+Alerting technologies provide advance warning and system failure indication from managed clients to remote management consoles. Once a system alert provides its warning or error report, the next step in remote system manageability is to allow corrective action to be taken — these actions include the ability to remotely reset or power-on or -off the client system.
+
+# High-Level Theory of Operation
+Bases on the system reported status code, the driver will send warning or system failure indication from managed clients to remote management consoles.
+
+## Firmware Volumes
+* AsfPei: PreMemory
+* AsfDxe: PostMemory
+
+## Modules
+* AsfPei
+* AsfDxe
+
+## AsfPei
+Asf initialize and send standard progress messages to NIC.
+
+## AsfDxe
+Install Asf Acpi table and register RSC handle to send progress/error event logs to NIC.
+Produce Asf Dxe protocol.
+
+## <Library Name>
+N/A now.
+
+## Key Functions
+AsfPushEvent: This function is provided in protocol, call this function to send messages to NIC.
+
+## Configuration
+For PcdControlDataArrays structure information, please check Asf2.0 spec chapter 4.1.2.5 ASF_CONTROLDATA.
+
+## Data Flows
+AsfPushEvent() -> through SmBus -> NIC -> Remote management consoles
+
+## Control Flows
+N/A now.
+
+## Build Flows
+There is not special build flow.
+
+## Test Point Results
+There are not test points implemented.
+
+## Functional Exit Criteria
+Check Asf Acpi table
+Check the event log in remote management consoles
+
+## Feature Enabling Checklist
+PcdAsfFeatureEnable to enable this feature.
+
+## Performance Impact
+There is no performance impact.
+
+## Common Optimizations
+N/A now.
--
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.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/1] Features/Intel/OutOfBandManagement/AsfFeaturePkg: Add initial package
[not found] ` <1712B4FC5186ABBC.20240@groups.io>
@ 2022-09-07 22:40 ` Isaac Oram
0 siblings, 0 replies; 4+ messages in thread
From: Isaac Oram @ 2022-09-07 22:40 UTC (permalink / raw)
To: devel@edk2.groups.io, Oram, Isaac W,
CrystalLee [李怡萱]
Cc: Chaganty, Rangasai V, Desimone, Nathaniel L, Gao, Liming,
DavidHsieh [謝坤智]
Pushed as a81614e456..341d41ac40
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Isaac Oram
Sent: Wednesday, September 7, 2022 3:37 PM
To: CrystalLee [李怡萱] <CrystalLee@ami.com>; devel@edk2.groups.io
Cc: Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; DavidHsieh [謝坤智] <DavidHsieh@ami.com>
Subject: Re: [edk2-devel] [PATCH v2 1/1] Features/Intel/OutOfBandManagement/AsfFeaturePkg: Add initial package
Reviewed-by: Isaac Oram <isaac.w.oram@intel.com>
Looks good, thank you.
-----Original Message-----
From: CrystalLee [李怡萱] <CrystalLee@ami.com>
Sent: Monday, September 5, 2022 5:15 AM
To: devel@edk2.groups.io
Cc: Oram, Isaac W <isaac.w.oram@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; DavidHsieh [謝坤智] <DavidHsieh@ami.com>; CrystalLee [李怡萱] <CrystalLee@ami.com>
Subject: [PATCH v2 1/1] Features/Intel/OutOfBandManagement/AsfFeaturePkg: Add initial package
Add a new feature package for Alert standard format support.
Alert Standard format specification(DSP0136)
REF:https://www.dmtf.org/sites/default/files/standards/documents/DSP0136.pdf
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: CrystalLee <CrystalLee@ami.com>
---
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c | 234 ++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c | 340 +++++++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c | 319 ++++++++++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c | 384 ++++++++++++++++++++
Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc | 1 +
Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc | 4 +
Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc | 2 +
Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf | 4 +
Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf | 4 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h | 66 ++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf | 51 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni | 15 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni | 13 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec | 47 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc | 40 ++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf | 51 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni | 15 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni | 13 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc | 52 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h | 104 ++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h | 145 ++++++++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf | 8 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf | 8 +
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h | 57 +++
Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md | 63 ++++
25 files changed, 2040 insertions(+)
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c
new file mode 100644
index 0000000000..7d4a864e2c
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfAcpiTable.c
@@ -0,0 +1,234 @@
+/** @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>
+#include <Library/BaseMemoryLib.h>
+
+// ASF Table Definitions
+// Below array size define should follow mAsfAcpiTable 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 mAsfAcpiTable = {
+ {
+ 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;
+ UINT8 *ControlDataArrays;
+ UINTN ControlDataArraysSize;
+
+ 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);
+ }
+
+ ControlDataArrays = (UINT8 *)PcdGetPtr (PcdControlDataArrays);
+ ControlDataArraysSize = PcdGetSize (PcdControlDataArrays);
+
+ if (ControlDataArraysSize == (sizeof(EFI_ACPI_ASF_CONTROLDATA) * ASF_RCTL_DEVICES_ARRAY_LENGTH)) {
+ // Currently Asf 2.0 spec only support four type of control function, so We support 4 arrays of
+ // EFI_ACPI_ASF_CONTROLDATA that should be defined in the PcdControlDataArrays
+ CopyMem((VOID *)(UINTN)mAsfAcpiTable.AsfRctlAll.ControlDataArray, (VOID *)(UINTN)ControlDataArrays, ControlDataArraysSize);
+ }
+
+{
+ UINTN Index;
+
+ DEBUG ((DEBUG_ERROR, "crystal ControlDataArraysSize = %x\n", ControlDataArraysSize));
+ DEBUG ((DEBUG_ERROR, "ControlDataArrays = \n"));
+ for (Index = 0; Index < ControlDataArraysSize; Index++) {
+ if ((Index != 0) && (Index % 4) == 0) DEBUG ((DEBUG_ERROR, "\n"));
+ DEBUG ((DEBUG_ERROR, "%02x ", ControlDataArrays[Index]));
+ }
+ DEBUG ((DEBUG_ERROR, "\n"));
+}
+
+ AcpiTableProtocol->InstallAcpiTable (
+ AcpiTableProtocol,
+ &mAsfAcpiTable,
+ mAsfAcpiTable.Header.Length,
+ &TableHandle
+ );
+
+ return;
+}
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c
new file mode 100644
index 0000000000..7d680404ba
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.c
@@ -0,0 +1,340 @@
+/** @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.
+
+ @param[in] AsfSlaveAddress Specify the Dash lan SmBus slave address.
+
+ @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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeEvent.c
new file mode 100644
index 0000000000..64265c6d5c
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.c
new file mode 100644
index 0000000000..8b44cd26e0
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc b/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc
index f0f1e0435f..ce0eac7a56 100644
--- a/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc
+++ b/Features/Intel/AdvancedFeaturePkg/AdvancedFeaturePkg.dsc
@@ -63,6 +63,7 @@
#
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable |TRUE
gSpcrFeaturePkgTokenSpaceGuid.PcdSpcrFeatureEnable |TRUE
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable |TRUE
#
# PowerManagement features
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc
index 804aab89bc..85a067d6a0 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc
+++ b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeatures.dsc
@@ -47,6 +47,10 @@
!include SpcrFeaturePkg/Include/SpcrFeature.dsc
!endif
+!if gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable == TRUE
+ !include AsfFeaturePkg/Include/AsfFeature.dsc
+!endif
+
#
# PowerManagement features
#
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc
index 0af5a8bfbc..ebf8d1f9b8 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc
+++ b/Features/Intel/AdvancedFeaturePkg/Include/AdvancedFeaturesPcd.dsc
@@ -35,6 +35,7 @@
#
IpmiFeaturePkg/IpmiFeaturePkg.dec
SpcrFeaturePkg/SpcrFeaturePkg.dec
+ AsfFeaturePkg/AsfFeaturePkg.dec
#
# PowerManagement features
@@ -73,6 +74,7 @@
gIpmiFeaturePkgTokenSpaceGuid.PcdIpmiFeatureEnable |FALSE
gSpcrFeaturePkgTokenSpaceGuid.PcdSpcrFeatureEnable |FALSE
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable |FALSE
gS3FeaturePkgTokenSpaceGuid.PcdS3FeatureEnable |FALSE
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf b/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf
index 349bdcc491..acfbb0e209 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf
+++ b/Features/Intel/AdvancedFeaturePkg/Include/PostMemory.fdf
@@ -48,6 +48,10 @@
!include SpcrFeaturePkg/Include/PostMemory.fdf
!endif
+!if gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable == TRUE
+ !include AsfFeaturePkg/Include/PostMemory.fdf
+!endif
+
#
# PowerManagement features
#
diff --git a/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf b/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf
index b991a5aabf..90b03e6108 100644
--- a/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf
+++ b/Features/Intel/AdvancedFeaturePkg/Include/PreMemory.fdf
@@ -48,6 +48,10 @@
!include SpcrFeaturePkg/Include/PreMemory.fdf
!endif
+!if gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable == TRUE
+ !include AsfFeaturePkg/Include/PreMemory.fdf
+!endif
+
#
# PowerManagement features
#
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h
new file mode 100644
index 0000000000..9cde358b93
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.h
@@ -0,0 +1,66 @@
+/** @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 <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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf
new file mode 100644
index 0000000000..44517cfd27
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.inf
@@ -0,0 +1,51 @@
+## @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
+ AsfAcpiTable.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AsfFeaturePkg/AsfFeaturePkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ UefiRuntimeServicesTableLib
+ DebugLib
+ BaseMemoryLib
+ PrintLib
+ UefiLib
+
+[Protocols]
+ gEfiRscHandlerProtocolGuid ## CONSUMES
+ gAsfProtocolGuid ## PRODUCES
+ gEfiAcpiTableProtocolGuid ## CONSUMES
+ gEfiSmbusHcProtocolGuid ## CONSUMES
+
+[Pcd]
+ gAsfFeaturePkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfMessageErrorLevel
+ gAsfFeaturePkgTokenSpaceGuid.PcdControlDataArrays
+
+[Depex]
+ TRUE
+
+[UserExtensions.TianoCore."ExtraFiles"]
+ AsfDxeExtra.uni
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxe.uni
new file mode 100644
index 0000000000..02ff1f7293
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfDxe/AsfDxeExtra.uni
new file mode 100644
index 0000000000..dbc747257c
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dec
new file mode 100644
index 0000000000..d5df0cb62f
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.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 = AsfFeaturePkg
+ PACKAGE_GUID = 025BE9BD-50B3-4139-9A70-4336E277339A
+ PACKAGE_VERSION = 1.0
+
+[Includes]
+ Include
+
+[Guids]
+ gAsfFeaturePkgTokenSpaceGuid = { 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]
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfFeatureEnable|FALSE|BOOLEAN|0x00000001
+
+[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
+ ## Specifies the Dash lan SmBus slave address.
+ # @Prompt Slave address of Dash lan
+ gAsfFeaturePkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan|0x0|UINT8|0x90000001
+
+ ## 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
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfMessageErrorLevel|0x7|UINT32|0x90000002
+
+ ## Specifies the four arrays of control datas in the ASF_RCTL Acpi table.
+ # @Prompt the four arrays of control datas that used in ASF_RCTL.
+ gAsfFeaturePkgTokenSpaceGuid.PcdControlDataArrays|{0x00, 0x88, 0x00, 0x03, 0x01, 0x88, 0x00, 0x02, 0x02, 0x88, 0x00, 0x01, 0x03, 0x88, 0x00, 0x04}|VOID*|0x90000003
+
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc
new file mode 100644
index 0000000000..006f3892ba
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfFeaturePkg.dsc
@@ -0,0 +1,40 @@
+## @file
+# Asf Package
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ PLATFORM_NAME = AsfFeaturePkg
+ PLATFORM_GUID = 79D22E13-3F30-470A-AF9D-B80CB4324379
+ PLATFORM_VERSION = 0.1
+ DSC_SPECIFICATION = 0x00010005
+ OUTPUT_DIRECTORY = Build/$(PLATFORM_NAME)
+ SUPPORTED_ARCHITECTURES = IA32|X64
+ BUILD_TARGETS = DEBUG|RELEASE|NOOPT
+ SKUID_IDENTIFIER = DEFAULT
+ PEI_ARCH = IA32
+ DXE_ARCH = X64
+
+[Packages]
+ MinPlatformPkg/MinPlatformPkg.dec
+
+#
+# MinPlatform common include for required feature PCD
+# These PCD must be set before the core include files, CoreCommonLib,
+# CorePeiLib, and CoreDxeLib.
+#
+!include MinPlatformPkg/Include/Dsc/MinPlatformFeaturesPcd.dsc.inc
+
+#
+# Include common libraries
+#
+!include MinPlatformPkg/Include/Dsc/CoreCommonLib.dsc
+!include MinPlatformPkg/Include/Dsc/CorePeiLib.dsc
+!include MinPlatformPkg/Include/Dsc/CoreDxeLib.dsc
+
+#
+# This package always builds the feature.
+#
+!include Include/AsfFeature.dsc
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf
new file mode 100644
index 0000000000..a0239f1990
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.inf
@@ -0,0 +1,51 @@
+## @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
+#
+
+[Sources]
+ AsfPei.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AsfFeaturePkg/AsfFeaturePkg.dec
+
+[LibraryClasses]
+ PeimEntryPoint
+ PeiServicesLib
+ DebugLib
+
+[Ppis]
+ gEfiPeiRscHandlerPpiGuid ## CONSUMES
+ gEfiPeiMemoryDiscoveredPpiGuid ## CONSUMES
+ gEfiPeiSmbus2PpiGuid ## CONSUMES
+
+[Pcd]
+ gAsfFeaturePkgTokenSpaceGuid.PcdSmbusSlaveAddressForDashLan
+ gAsfFeaturePkgTokenSpaceGuid.PcdAsfMessageErrorLevel
+
+[Depex]
+ gEfiPeiSmbus2PpiGuid
+
+[UserExtensions.TianoCore."ExtraFiles"]
+ AsfPeiExtra.uni
+
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPei.uni
new file mode 100644
index 0000000000..646712917e
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/AsfPei/AsfPeiExtra.uni
new file mode 100644
index 0000000000..72819f4986
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc
new file mode 100644
index 0000000000..d76ab30008
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfFeature.dsc
@@ -0,0 +1,52 @@
+## @file
+# Asf Package
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+!ifndef $(PEI_ARCH)
+ !error "PEI_ARCH must be specified to build this feature!"
+!endif
+!ifndef $(DXE_ARCH)
+ !error "DXE_ARCH must be specified to build this feature!"
+!endif
+
+
+################################################################################
+#
+# Component section - list of all components that need built for this feature.
+#
+# Note: The EDK II DSC file is not used to specify how compiled binary images get placed
+# into firmware volume images. This section is just a list of modules to compile from
+# source into UEFI-compliant binaries.
+# It is the FDF file that contains information on combining binary files into firmware
+# volume images, whose concept is beyond UEFI and is described in PI specification.
+# There may also be modules listed in this section that are not required in the FDF file,
+# When a module listed here is excluded from FDF file, then UEFI-compliant binary will be
+# generated for it, but the binary will not be put into any firmware volume.
+#
+################################################################################
+#
+# Feature PEI Components
+#
+
+# @todo: Change below line to [Components.$(PEI_ARCH)] after https://bugzilla.tianocore.org/show_bug.cgi?id=2308
+# is completed.
+[Components.IA32]
+ AsfFeaturePkg/AsfPei/AsfPei.inf
+
+#
+# Feature DXE Components
+#
+
+# @todo: Change below line to [Components.$(DXE_ARCH)] after https://bugzilla.tianocore.org/show_bug.cgi?id=2308
+# is completed.
+[Components.X64]
+ AsfFeaturePkg/AsfDxe/AsfDxe.inf
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/AsfMessages.h
new file mode 100644
index 0000000000..6e79f4993f
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/IndustryStandard/Asf.h
new file mode 100644
index 0000000000..f660fe0b72
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf
new file mode 100644
index 0000000000..1038e77b5d
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PostMemory.fdf
@@ -0,0 +1,8 @@
+## @file
+# FDF file for post-memory modules that enable Intelligent Platform Management Interface.
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+INF AsfFeaturePkg/AsfDxe/AsfDxe.inf
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf
new file mode 100644
index 0000000000..a723544855
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/PreMemory.fdf
@@ -0,0 +1,8 @@
+## @file
+# FDF file for pre-memory modules that enable Intelligent Platform Management Interface.
+#
+# Copyright (c) 1985 - 2022, AMI. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+INF AsfFeaturePkg/AsfPei/AsfPei.inf
diff --git a/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Include/Protocol/AsfProtocol.h
new file mode 100644
index 0000000000..d3af0fba73
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/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/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md
new file mode 100644
index 0000000000..f18b1bfb07
--- /dev/null
+++ b/Features/Intel/OutOfBandManagement/AsfFeaturePkg/Readme.md
@@ -0,0 +1,63 @@
+# Overview
+* **Feature Name:** Alert Standard Format (ASF)
+* **PI Phase(s) Supported:** PEI, DXE
+* **SMM Required?** No
+
+More Information:
+* [ASF Specification v2.0](https://www.dmtf.org/sites/default/files/standards/documents/DSP0136.pdf)
+
+## Purpose
+The ASF feature provides firmware functionality that implements behavior described in the ASF specification.
+Alerting technologies provide advance warning and system failure indication from managed clients to remote management consoles. Once a system alert provides its warning or error report, the next step in remote system manageability is to allow corrective action to be taken — these actions include the ability to remotely reset or power-on or -off the client system.
+
+# High-Level Theory of Operation
+Bases on the system reported status code, the driver will send warning or system failure indication from managed clients to remote management consoles.
+
+## Firmware Volumes
+* AsfPei: PreMemory
+* AsfDxe: PostMemory
+
+## Modules
+* AsfPei
+* AsfDxe
+
+## AsfPei
+Asf initialize and send standard progress messages to NIC.
+
+## AsfDxe
+Install Asf Acpi table and register RSC handle to send progress/error event logs to NIC.
+Produce Asf Dxe protocol.
+
+## <Library Name>
+N/A now.
+
+## Key Functions
+AsfPushEvent: This function is provided in protocol, call this function to send messages to NIC.
+
+## Configuration
+For PcdControlDataArrays structure information, please check Asf2.0 spec chapter 4.1.2.5 ASF_CONTROLDATA.
+
+## Data Flows
+AsfPushEvent() -> through SmBus -> NIC -> Remote management consoles
+
+## Control Flows
+N/A now.
+
+## Build Flows
+There is not special build flow.
+
+## Test Point Results
+There are not test points implemented.
+
+## Functional Exit Criteria
+Check Asf Acpi table
+Check the event log in remote management consoles
+
+## Feature Enabling Checklist
+PcdAsfFeatureEnable to enable this feature.
+
+## Performance Impact
+There is no performance impact.
+
+## Common Optimizations
+N/A now.
--
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.
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-07 22:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-05 12:15 [PATCH v2 0/1] AsfFeaturePkg: Add Alert standard format support CrystalLee [李怡萱]
2022-09-05 12:15 ` [PATCH v2 1/1] Features/Intel/OutOfBandManagement/AsfFeaturePkg: Add initial package CrystalLee [李怡萱]
2022-09-07 22:36 ` Isaac Oram
[not found] ` <1712B4FC5186ABBC.20240@groups.io>
2022-09-07 22:40 ` [edk2-devel] " Isaac Oram
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox