// Copyright (c) 2018 Qualcomm Technologies, Inc.  All Rights
// Reserved.  Qualcomm Technologies Proprietary and Confidential.

/** @cond */
struct IRTICReport_reportHeader
{
  uint64 reportVersion;     /**<Version of the EL2 report.*/
  uint64 mpCatalogVersion;  /**<Version of MP catalogue used for kernel protection.*/
  uint64 numIncidents;      /**<Number of Incidents Observed by EL2. */
  uint8 protectionEnabled;  /**<Kernel Assets protected by EL2. */
  uint8 pad1;               /**<Padding */
  uint8 pad2;               /**<Padding */
  uint8 pad3;               /**<Padding */
  uint32 pad4;              /**<Padding */
};

/** @cond */
struct IRTICReport_El2ActorReportIDL
{
  uint32 mpgen_interface_ver;       /** MPGen interface version */
  uint32 num_incidents;             /** Number of Incidentes Observed by EL2. */
  uint64 timestamp;                 /** Timestamp of report */
  uint8 protection_enabled;         /** Flag indicating if protection is enabled in EL2 */
  uint8 report_type;                /** Type of report: info or incident */
  uint8 asset_category;             /** Category of affected asset: ro, wo etc */
  uint8 response;                   /** Type of response: allow or restrict */
  uint32 actor_count;               /** Number of actors that contributed to the violation */
  uint64 spare;                     /** Spare field for future use */
};

/** @cond */
struct IRTICReport_El2ActorDataIDL
{
  uint64 state;                    /** State of actor process: runnable, stopped etc */
  uint32 pid;                      /** PID of actor process */
  uint32 padding;                  /** Padding */
};

/** @cond */
interface IRTICReport {
/** @endcond */

  /**
   * @addtogroup IRTICReport
   * @{
   */

  /** @cond */
  /**
   * Specifies the type of the response.
   */
  const uint32 RESPONSE_ALLOW     = 0;
  const uint32 RESPONSE_RESTRICT  = 1;

  /**
   * Specifies the type of the report.
   */
  const uint32 REPORT_INFO      = 0;
  const uint32 REPORT_INCIDENT  = 1;

  /**
   * Specifies the type of counter.
   */
  const uint32 PF_COUNTER            = 0;        /*Total number of Page Faults that occured*/
  const uint32 PF_COUNTER_ASSET      = 1;        /*Total number of Page Faults that occured on a non-asset, can be deprecated once we consolidate all assets into a separate 4k region.*/
  const uint32 PF_COUNTER_NON_ASSET  = 2;        /*Total number of Page Faults that occured on a RO asset*/
  const uint32 PF_COUNTER_RO         = 3;        /*Total number of Page Faults that occured on a RO asset*/
  const uint32 PF_COUNTER_WN         = 4;        /*Total number of Page Faults that occured on a WO Known asset*/
  const uint32 PF_COUNTER_WU         = 5;        /*Total number of Page Faults that occured on a WO Unknown asset*/
  const uint32 PF_COUNTER_AW         = 6;        /*Total number of Page Faults that occured on a AW asset*/
  const uint32 PF_COUNTER_ENFORCE    = 7;        /*Total number of Page Faults that got denied due to enforcing mode*/
  const uint32 PF_COUNTER_WRITER     = 8;        /*Total number of Page Faults that got denied due to bad writer*/
  const uint32 PF_COUNTER_ISV_INVALID = 9;       /*Total number of Page Faults that doesn't have syndrome information*/
  const uint32 PF_COUNTER_END        = 10;       /*End Marker*/

  /**
   * Specifies the Category of the asset.
   */
  const uint32 ASSET_RO_DATA                 = 0;
  const uint32 ASSET_RO_TEXT                 = 1;
  const uint32 ASSET_WRITE_ONCE_VALUE_KNOWN  = 2;
  const uint32 ASSET_WRITE_ONCE_VALUE_UNKNOW = 3;
  const uint32 ASSET_BLACK_LISTED            = 4;
  const uint32 ASSET_PAGE_TABLE              = 5;

  /**
   * Specifies the length of name of an EL2 Actor.
   */
  const uint32 ACTOR_NAME_LEN = 16;
  /** @endcond */

  /**
    Retrieves contents of Report Header generated by EL2.

    @param[out] reportheader         Output Report Header Structure.

    @return
    Object_OK on success.
  */
  method getReportHeader(out IRTICReport_reportHeader reportheader);

  /**
    Retrieves contents of Report generated by EL2.

    @param[out] actor_report        Instance of Actor Report generated by EL2.
    @param[out] asset_name          Asset name affected by EL2 violation.
    @param[out] actor_data          Array of Actor Data generated by EL2.
    @param[out] actor_names         Array of Actor names generated by EL2.

    @return
    Object_OK on success.
  */
  method getReport(out IRTICReport_El2ActorReportIDL actor_report,
                   out buffer asset_name,
                   out IRTICReport_El2ActorDataIDL[] actor_data,
                   out buffer actor_names);

  /**
    Retrieve Page Fault Counters from the report.

    @param[out] PFCounters         Array of Page Fault Counters indexed by PF_COUNTER_*.

    @return
    Object_OK on success.
  */
  method getReportPFCounters(out uint32[] PFCounters);

  /**
    Retrieves SHA256 hash of the MP Catalog.

    @param[out] MPHash         SHA256 hash of MP Data.

    @return
    Object_OK on success.
  */
  method getMPHash(out uint8[] MPHash);
  /* @} */ /* end_addtogroup IRTICReport */
};
