/** @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
};
