OAPL_MESSAGE
============

The host OS can use OPAL_GET_MSG to retrive messages queued by OPAL. The
messages are defined by enum opal_msg_type. The host is notified of there
being messages to be consumed by the OPAL_EVENT_MSG_PENDING bit being set.

An opal_msg is:
struct opal_msg {
	__be32 msg_type;
	__be32 reserved;
	__be64 params[8];
};

The data structure is ALWAYS at least this size (4+4+8*8 = 72 bytes). Some
messages define fewer than eight parameters. For messages that do not
define all eight parameters, the value in the undefined parameters is
undefined, although can safely be memcpy()d or otherwise moved.

In the device tree, there's an opal-msg-size property of the OPAL node that
says the size of a struct opal-msg. In the future, OPAL may support larger
messages. See OPAL_GET_MESSAGE documentation for details.

  ibm,opal {
            opal-msg-size = <0x48>;
  }


OPAL_MSG_ASYNC_COMP
-------------------

params[0] = token
params[1] = rc

Additional parameters are function-specific.

OPAL_MSG_MEM_ERR
----------------

OPAL_MSG_EPOW
-------------

OPAL_MSG_SHUTDOWN
-----------------

Used by OPAL to inform the host OS it must imitate a graceful shutdown. Uses
the first parameter to indicate weather the system is going down for shutdown
or a reboot.

params[0] = 0x01 reboot, 0x00 shutdown

OPAL_MSG_HMI_EVT
----------------

Used by OPAL to sends the OPAL HMI Event to the host OS that reports a
summary of HMI error and whether it was successfully recovered or not.

HMI is a Hypervisor Maintenance Interrupt usually reports error related
to processor recovery/checkstop, NX checkstop and Timer facility. Hypervisor
then takes this opportunity to analyze and recover from some of these errors.
Hypervisor takes assistance from OPAL layer to handle and recover from
HMI. After handling HMI, OPAL layer sends the summary of error report and
status of recovery action using HMI event structure shown below.

The HMI event structure uses version numbering to allow future enhancement
to accommodate additional members. The version start from V1 onward.
Version 0 is invalid version and unsupported.

The current version of HMI event structure V2 and is backward compatible
to V1 version.

Notes:
- When adding new structure to the union in future, the version number
  must be bumped.
- All future versions must be backward compatible to all its older versions.
- Size of this structure should not exceed that of struct opal_msg.

struct OpalHMIEvent {
        uint8_t         version;        /* 0x00 */
        uint8_t         severity;       /* 0x01 */
        uint8_t         type;           /* 0x02 */
        uint8_t         disposition;    /* 0x03 */
        uint8_t         reserved_1[4];  /* 0x04 */

	__be64		hmer;
	/* TFMR register. Valid only for TFAC and TFMR_PARITY error type. */
	__be64		tfmr;

	/* version 2 and later */
	union {
		/*
		 * checkstop info (Core/NX).
		 * Valid for OpalHMI_ERROR_MALFUNC_ALERT.
		 */
		struct {
			uint8_t	xstop_type;	/* enum OpalHMI_XstopType */
			uint8_t reserved_1[3];
			__be32 xstop_reason;
			union {
				__be32 pir;	  /* for CHECKSTOP_TYPE_CORE */
				__be32 chip_id; /* for CHECKSTOP_TYPE_NX */
			} u;
		} xstop_error;
	} u;
};


OPAL_MSG_DPO
------------

Used for delayed power off, where OPAL can inform a host OS that it intends to
perform a shutdown in the future.

The host OS can use the separate API OPAL_GET_DPO_STATUS to query OPAL for the
number of seconds before a forced shutdown will occur.

OPAL_MSG_PRD
------------

This message is a OPAL-to-HBRT notification, and contains a
struct opal_prd_msg:

	enum opal_prd_msg_type {
		OPAL_PRD_MSG_TYPE_INIT = 0,	/* HBRT --> OPAL */
		OPAL_PRD_MSG_TYPE_FINI,		/* HBRT --> OPAL */
		OPAL_PRD_MSG_TYPE_ATTN,		/* HBRT <-- OPAL */
		OPAL_PRD_MSG_TYPE_ATTN_ACK,	/* HBRT --> OPAL */
		OPAL_PRD_MSG_TYPE_OCC_ERROR,	/* HBRT <-- OPAL */
		OPAL_PRD_MSG_TYPE_OCC_RESET,	/* HBRT <-- OPAL */
	};

	struct opal_prd_msg {
		uint8_t		type;
		uint8_t		pad[3];
		__be32		token;
		union {
			struct {
				__be64	version;
				__be64	ipoll;
			} init;
			struct {
				__be64	proc;
				__be64	ipoll_status;
				__be64	ipoll_mask;
			} attn;
			struct {
				__be64	proc;
				__be64	ipoll_ack;
			} attn_ack;
			struct {
				__be64	chip;
			} occ_error;
			struct {
				__be64	chip;
			} occ_reset;
		};
	};

Responses from the kernel use the same message format, but are passed
through the opal_prd_msg call.
