Skip to content

Commit

Permalink
ManageabilityPkg: Add TransportLib instance for IPMI Serial
Browse files Browse the repository at this point in the history
This adds ManageabilityTransportSerialLib instance following the
manageability transport framework to support IPMI Serial protocol.

Signed-off-by: John Chung <[email protected]>
  • Loading branch information
gtossk2 committed Nov 7, 2024
1 parent ea33b27 commit 17064b9
Show file tree
Hide file tree
Showing 13 changed files with 1,245 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,21 @@ typedef struct {
UINT32 BmcSlaveAddress;
} MANAGEABILITY_TRANSPORT_SSIF_HARDWARE_INFO;

///
/// Manageability Serial protocol interface hardware information.
///
typedef struct {
UINT8 IpmiRequestAddress;
UINT8 IpmiResponseAddress;
UINT8 IpmiRequestLunNumer;
UINT8 IpmiResponseLunNumer;
} MANAGEABILITY_TRANSPORT_SERIAL_HARDWARE_INFO;

typedef union {
VOID *Pointer;
MANAGEABILITY_TRANSPORT_KCS_HARDWARE_INFO *Kcs;
MANAGEABILITY_TRANSPORT_SSIF_HARDWARE_INFO *Ssif;
MANAGEABILITY_TRANSPORT_SERIAL_HARDWARE_INFO *Serial;
} MANAGEABILITY_TRANSPORT_HARDWARE_INFORMATION;

///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ MANAGEABILITY_SPECIFICATION_NAME ManageabilitySpecNameTable[] = {
{ &gManageabilityTransportKcsGuid, L"KCS" },
{ &gManageabilityTransportSmbusI2cGuid, L"SMBUS I2C"},
{ &gManageabilityTransportPciVdmGuid, L"PCI VDM" },
{ &gManageabilityTransportSerialGuid, L"SERIAL" },
{ &gManageabilityTransportMctpGuid, L"MCTP" },
{ &gManageabilityProtocolIpmiGuid, L"IPMI" },
{ &gManageabilityProtocolMctpGuid, L"MCTP" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
gManageabilityTransportKcsGuid
gManageabilityTransportSmbusI2cGuid
gManageabilityTransportPciVdmGuid
gManageabilityTransportSerialGuid
gManageabilityTransportMctpGuid
gManageabilityProtocolIpmiGuid
gManageabilityProtocolMctpGuid
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/** @file
Manageability transport Serial internal used definitions.
Copyright (c) 2024, ARM Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MANAGEABILITY_TRANSPORT_SERIAL_LIB_H_
#define MANAGEABILITY_TRANSPORT_SERIAL_LIB_H_

#include <IndustryStandard/IpmiNetFnApp.h>
#include <Library/ManageabilityTransportIpmiLib.h>
#include <Library/ManageabilityTransportLib.h>

#define MANAGEABILITY_TRANSPORT_SERIAL_SIGNATURE SIGNATURE_32 ('M', 'T', 'S', 'E')

///
/// Manageability transport Serial internal data structure.
///
typedef struct {
UINTN Signature;
MANAGEABILITY_TRANSPORT_TOKEN Token;
} MANAGEABILITY_TRANSPORT_SERIAL;

///
/// IPMI Serial data structure.
///
typedef struct {
UINT8 ResponseAddress;
UINT8 NetFn;
UINT8 CheckSum;
UINT8 RequestAddress;
UINT8 RequestSequence;
UINT8 Command;
} IPMI_SERIAL_HEADER;

#define MANAGEABILITY_TRANSPORT_SERIAL_FROM_LINK(a) CR (a, MANAGEABILITY_TRANSPORT_SERIAL, Token, MANAGEABILITY_TRANSPORT_SERIAL_SIGNATURE)

///
/// IPMI Serial Escaped Character Definition
///
#define BM_START 0xA0
#define BM_STOP 0xA5
#define BM_HANDSHAKE 0xA6
#define BM_ESCAPE 0xAA

///
/// IPMI Serial State Machine
///
#define MSG_IDLE 0
#define MSG_IN_PROGRESS 1

///
/// IPMI Serial
///
#define IPMI_MAX_LUN 0x3
#define IPMI_MAX_NETFUNCTION 0x3F
#define IPMI_SERIAL_CHECKSUM1_COUNT 2
#define IPMI_SERIAL_CHECKSUM2_COUNT 3
#define IPMI_SERIAL_MAXIMUM_PACKET_SIZE_IN_BYTES 256
#define IPMI_SERIAL_MIN_REQ 7

///
/// IPMI Serial Configure
///
#define IPMI_SERIAL_RS_ADDRESS FixedPcdGet8 (PcdIpmiSerialResponseAddress)
#define IPMI_SERIAL_RQ_ADDRESS FixedPcdGet8 (PcdIpmiSerialRequestAddress)
#define IPMI_SERIAL_RS_LUN_NUMBER FixedPcdGet8 (PcdIpmiSerialResponseLunNumber)
#define IPMI_SERIAL_RQ_LUN_NUMBER FixedPcdGet8 (PcdIpmiSerialRequestLunNumber)
#define IPMI_SERIAL_RETRY_COUNT FixedPcdGet8 (PcdIpmiSerialRetryCount)
#define IPMI_SERIAL_REQUEST_RETRY_INTERVAL FixedPcdGet32 (PcdIpmiSerialRequestRetryInterval)
#define IPMI_SERIAL_RESPONSE_RETRY_INTERVAL FixedPcdGet32 (PcdIpmiSerialResponseRetryInterval)

/**
This service communicates with BMC using Serial protocol.
@param[in] TransmitHeader Serial packet header.
@param[in] TransmitHeaderSize Serial packet header size in byte.
@param[in] TransmitTrailer Serial packet trailer.
@param[in] TransmitTrailerSize Serial packet trailer size in byte.
@param[in] RequestData Command Request Data.
@param[in] RequestDataSize Size of Command Request Data.
@param[out] ResponseData Command Response Data. The completion
code is the first byte of response
data.
@param[in, out] ResponseDataSize Size of Command Response Data.
@param[out] AdditionalStatus Additional status of this transaction.
@retval EFI_SUCCESS The command byte stream was
successfully submit to the device and a
response was successfully received.
@retval EFI_NOT_FOUND The command was not successfully sent
to the device or a response was not
successfully received from the device.
@retval EFI_NOT_READY Ipmi Device is not ready for Ipmi
command access.
@retval EFI_DEVICE_ERROR Ipmi Device hardware error.
@retval EFI_TIMEOUT The command time out.
@retval EFI_UNSUPPORTED The command was not successfully sent to
the device.
@retval EFI_OUT_OF_RESOURCES The resource allocation is out of
resource or data size error.
**/

EFI_STATUS
EFIAPI
SerialTransportSendCommand (
IN MANAGEABILITY_TRANSPORT_HEADER TransmitHeader OPTIONAL,
IN UINT16 TransmitHeaderSize,
IN MANAGEABILITY_TRANSPORT_TRAILER TransmitTrailer OPTIONAL,
IN UINT16 TransmitTrailerSize,
IN UINT8 *RequestData OPTIONAL,
IN UINT32 RequestDataSize,
OUT UINT8 *ResponseData OPTIONAL,
IN OUT UINT32 *ResponseDataSize OPTIONAL,
OUT MANAGEABILITY_TRANSPORT_ADDITIONAL_STATUS *AdditionalStatus
);

#endif
Loading

0 comments on commit 17064b9

Please sign in to comment.