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

interface IQRKS {


    const uint64 OPT_FAST_REPORT                          = 0x00000001;   // Return cached report of last attestation run.
    const uint64 OPT_INTEGRITY_REPORT                     = 0x00000002;   // Run fresh attestation and return report generated from that.
    const uint64 OPT_CURRENT_KP_INCIDENT_REPORT           = 0x00000004;   // Return extended report for all sections.
    const uint64 OPT_HISTORY_KP_INCIDENT_REPORT           = 0x00000008;   // Return extended report for all sections including history incidents.
    const uint64 OPT_INTEGRITY_ONLY                       = 0x00000010;   // Return overall integrity status instead of full report.
    //--------------------------------------------------------
    //  error codes
    //--------------------------------------------------------
    error ERROR_NO_MEM;
    error ERROR_NO_LICENSE_FILE;
    error ERROR_INVALID_LICENSE;
    error ERROR_BUFFER_TOO_SMALL;
    error ERROR_CBOR_FAILURE;
    error ERROR_NO_MPDATA;
    error ERROR_KP_NOT_ENABLED;
    error ERROR_NO_PFM;
    error ERROR_INVALID_OPTION;
    error ERROR_INVALID_INPUT;
    error ERROR_INVALID_INVOKE;
    error ERROR_HASH;
    error ERROR_GENERAL;
    error ERROR_SERVICE_ISSUE;
    error ERROR_UPDATE_HISTORY;
    error ERROR_SAVE_HISTORY;
    error ERROR_FETCH_HISTORY;

    /**
     * Primary QRKS interface function.
     *
     * @param[in] buffer license -  License for RTIC report FID to be passed by clients. QWES can skip license buffer.
     * @param[in] uint64 flags - QRKS report flags. This will specify if client wants cached report or latest report,
     * full report or just integrity status.
     * @param[out] buffer - QRKS report data
     * @return DH_SUCCESS (0) or DH specific error code
     */
    method GetReport(in buffer license, in uint64 flags, out buffer data);

    /**
     * QRKS interface to test if MP Data is Provisioned or not.
     *
     *@param[out] bool status -  status whether MP Data is provisioned or not in DevCFG.
     *set status true if provisioned in devcfg else false.
     */
    method MPProvisionStatus(out uint32 status);

    /**
     * The function gets QRKS MP(Measurement Parameter) Data from TA.
     *
     * @param[out] text_protection_enbled whether need to enable KP protection on text or not.
     * @param[out] pt_alignment which Page table alignment is to be used.
     * @param[out] mpdatabuf An output buffer populated with mpdata
     *
     * @return
     * Object_OK indicates success
     * Object_ERROR indicates failure
    */
    method getMPData(out uint32 text_protection_enbled, out uint32 pt_alignment, out buffer mpdatabuf);

    /**
     * The function does license check for KP feature TA.
     *
     * @return
     * Object_OK indicates success
     * Object_ERROR indicates failure
    */
    method CheckLicenseKP();
    /**
     * The function makes a call to TZ to get kp report.
     * Processes and updates report to RPMB.
     *
     * @return error or success
    */
    method UpdateHistory();

    /**
     * The function set/get QRKS MP(Measurement Parameter) Data from HLOS to TA and send back to
     * Hyperviosr Kernel protect module to enable memory protection on it.
     *
     * @param[in]  hlos_mp_data buffer which will contain MP data information filled by HLOS kernel module.
     * @param[out] text_protection_enbled whether need to enable KP protection on text or not.
     * @param[out] pt_alignment which Page table alignment is to be used.
     * @param[out] mp_data buffer which will be filled by TA based on the devcfg option set and in buffer.
     * @param[out] out_data_source notifies source of the MP data sent back to hypervisor. HLOS or Devcfg
     *
     * @return
     * Object_OK indicates success
     * In case of failure either of the below errors will be returned:
     * IQRKS_ERROR_INVALID_OPTION
     * IQRKS_ERROR_INVALID_INPUT
     * IQRKS_ERROR_NO_MPDATA
     * IQRKS_ERROR_NOMEM
     * 
    */
    method SetGetMPData(in buffer hlos_mp_data, out uint32 text_protection_enbled, out uint32 pt_alignment, out buffer mp_data, out uint32 out_data_source);

    /**
     * The function sets QRKS MP(Measurement Parameter) Asset info in TA.
     *
     * @param[in] asset_id indicates asset for which information needs to be updated.
     *
     * @return
     * Object_OK indicates success
     * IQRKS_ERROR_INVALID_INPUT will be returned in case of failure.
    */
    method SetAssetInfo(in uint32 asset_id);
};

