/**
 * @file    scp-errors.h
 *
 * @brief   Error codes specific to the SCP module.
 *
 * Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * * Neither the name of NVIDIA CORPORATION nor the names of its
 * contributors may be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef SCP__SCP_ERRORS_H
#define SCP__SCP_ERRORS_H
#define FSP__SCP__SCP_ERRORS_H 1

/* Compiler headers */

/* Early FSP headers */
#include <misc/ct-assert.h>             // for HEADER_CHECK

/* Hardware headers */

/* Late FSP headers */
#include <base/module-id.h>             // for MODULE_ERROR

/* Module-specific FSP headers */

/*
 * Compile-time check for FSP header files
 *   Each FSP header file contains a signature unique to that file, and the
 *   FSP project.  The HEADER_CHECK macro (contained in misc/ct-assert.h) can
 *   check for this signature.  If it does not exist, then the build will
 *   abort.
 *
 *   This is a trap for projects which have their own include files of the
 *   same names, but different contents.  This trap ensures that only the
 *   files from the FSP project, are built into the FSP source code.
 */
HEADER_CHECK(FSP__BASE__MODULE_ID_H)


/**
 * @brief Error codes specific to the SCP module.
 *
 * @macro-title SCP error codes.
 *
 * @E_SCP_INSUFFICIENT_RESOURCES    The caller is operating in secure mode but
 *                                  access to secret-index zero is blocked.
 * @E_SCP_INVALID_ADDRESS           A passed buffer is misaligned, or two
 *                                  buffers overlap (when not permitted).
 * @E_SCP_INVALID_BASE              A passed buffer resides in an unsupported
 *                                  memory region.
 * @E_SCP_INVALID_DMA_SPECIFIER     The caller has requested an operation that
 *                                  requires a shortcut transfer but the
 *                                  shortcut-DMA path has not been configured.
 * @E_SCP_INVALID_FLAGS             The passed combination of flags is invalid.
 * @E_SCP_INVALID_INDEX             A passed index value falls outside of its
 *                                  supported range.
 * @E_SCP_INVALID_LOCK_STATE        SCP lockdown is misconfigured.
 * @E_SCP_INVALID_OBJECT            A passed compound argument is invalid.
 * @E_SCP_INVALID_OBJECT_BUFFER     A passed compound argument contains an
 *                                  invalid buffer element.
 * @E_SCP_INVALID_OPERATION         The caller has requested an unrecognized
 *                                  operation, or is attempting to perform a
 *                                  recognized operation incorrectly.
 * @E_SCP_INVALID_POINTER           A passed address is zero/NULL (when not
 *                                  permitted).
 * @E_SCP_INVALID_REQUEST           The caller has made a request that cannot be
 *                                  serviced by the driver.
 * @E_SCP_NOT_READY                 The SCP driver has not been initialized.
 * @E_SCP_OUT_OF_RANGE              A passed buffer is of invalid size.
 * @E_SCP_FEATURE_NOT_ENABLED       The requested operation requires the use of
 *                                  a feature that has not been enabled.
 * @E_SCP_GENERIC                   An unexpected error occurred.
 * @E_SCP_NOTHING_TO_DO             The caller has requested an operation that
 *                                  has no effect.
 */
#define E_SCP_INSUFFICIENT_RESOURCES    MODULE_ERROR(SCP,  0UL)
#define E_SCP_INVALID_ADDRESS           MODULE_ERROR(SCP,  1UL)
#define E_SCP_INVALID_BASE              MODULE_ERROR(SCP,  2UL)
#define E_SCP_INVALID_DMA_SPECIFIER     MODULE_ERROR(SCP,  3UL)
#define E_SCP_INVALID_FLAGS             MODULE_ERROR(SCP,  4UL)
#define E_SCP_INVALID_INDEX             MODULE_ERROR(SCP,  5UL)
#define E_SCP_INVALID_LOCK_STATE        MODULE_ERROR(SCP,  6UL)
#define E_SCP_INVALID_OBJECT            MODULE_ERROR(SCP,  7UL)
#define E_SCP_INVALID_OBJECT_BUFFER     MODULE_ERROR(SCP,  8UL)
#define E_SCP_INVALID_OPERATION         MODULE_ERROR(SCP,  9UL)
#define E_SCP_INVALID_POINTER           MODULE_ERROR(SCP, 10UL)
#define E_SCP_INVALID_REQUEST           MODULE_ERROR(SCP, 11UL)
#define E_SCP_NOT_READY                 MODULE_ERROR(SCP, 12UL)
#define E_SCP_OUT_OF_RANGE              MODULE_ERROR(SCP, 13UL)
#define E_SCP_FEATURE_NOT_ENABLED       MODULE_ERROR(SCP, 14UL)
#define E_SCP_GENERIC                   MODULE_ERROR(SCP, 15UL)
#define E_SCP_NOTHING_TO_DO             MODULE_ERROR(SCP, 16UL)

#endif /* SCP__SCP_ERRORS_H */
