1 /* SPDX-License-Identifier: BSD-3-Clause 2 * 3 * Copyright(c) 2022 Intel Corporation. All rights reserved. 4 */ 5 /*! \file system_error.h */ 6 7 #ifndef _ADSP_SYSTEM_ERROR_H_ 8 #define _ADSP_SYSTEM_ERROR_H_ 9 10 #include "adsp_error_code.h" 11 12 namespace intel_adsp 13 { 14 /*! 15 * \brief Scoped enumeration of common error code values which can be reported 16 * to ADSP System 17 */ 18 struct ErrorCode { 19 /*! \brief type of the error code value */ 20 typedef int Type; 21 22 /*! \brief list of named error codes */ 23 enum Enum { 24 NO_ERROR = ADSP_NO_ERROR, 25 INVALID_PARAMETERS = ADSP_INVALID_PARAMETERS, 26 BUSY = ADSP_BUSY_RESOURCE, 27 FATAL_FAILURE = ADSP_FATAL_FAILURE, 28 29 }; 30 /*! \brief Indicates the minimal value in the enumeration list */ 31 static Enum const MinValue = NO_ERROR; 32 /*! \brief Indicates the maximal value in the enumeration list */ 33 static Enum const MaxValue = FATAL_FAILURE; 34 35 /*! \brief Initializes a new ErrorCode instance given a value of error code */ ErrorCodeErrorCode36 explicit ErrorCode(Type value) 37 : value_(value) { } 38 39 /*! \brief Returns the current value of the ErrorCode */ operatorErrorCode40 Type operator()() const 41 { 42 return value_; 43 } 44 45 /*! \brief Converts the ErrorCode instance into its code value */ TypeErrorCode46 operator Type(void) const 47 { 48 return value_; 49 } 50 51 /*! \brief Evaluates the ErrorCode value against a given value */ 52 bool operator == (Type a) 53 { 54 return value_ == a; 55 } 56 57 /*! 58 * \brief Gets a const reference on the error code value 59 */ ValueErrorCode60 const Type & Value() const 61 { 62 return value_; 63 } 64 65 protected: 66 /*! 67 * \brief Gets a reference on the error code value 68 */ ValueErrorCode69 Type & Value() 70 { 71 return value_; 72 } 73 74 private: 75 Type value_; 76 }; 77 } 78 79 #endif /*_ADSP_SYSTEM_ERROR_H_ */ 80