/* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** ************************************************************************ * @file M4OSA_Error.h * @ingroup OSAL * @brief Definition of common error types * @note This file contains macros to generate and analyze error codes. ************************************************************************ */ #ifndef M4OSA_ERROR_H #define M4OSA_ERROR_H #include "M4OSA_Types.h" /** M4OSA_ERR is a 32 bits unsigned integer. * To sort returned code, a specific naming convention must be followed: * - Severity (2 bits): It may br either 0b00 (no error), 0b01 (warning) or * 0b01 (fatal error) * - Core ID (14 bits): It is a unique ID for each core component * - ErrorID (16 bits): It is the specific error code * EACH CORE COMPONENT FUNCTION SHOULD RETURN AN M4OSA_ERR */ typedef M4OSA_UInt32 M4OSA_ERR; #define M4_OK 0 #define M4_WAR 1 #define M4_ERR 2 /* Macro to process M4OSA_ERR */ /** This macro tests if the provided M4OSA_ERR is a warning or not*/ #define M4OSA_ERR_IS_WARNING(error) ((((error)>>30) == M4_WAR) ? 1:0) /** This macro tests if the provided M4OSA_ERR is a fatal error or not*/ #define M4OSA_ERR_IS_ERROR(error) ((((error)>>30) == M4_ERR) ? 1:0) /** This macro returns an error code accroding to the 3 provided fields: * @arg severity: (IN) [M4OSA_UInt32] Severity to put in the error code * @arg coreID: (IN) [M4OSA_UInt32] CoreID to put in the error code * @arg errorID: (IN) [M4OSA_UInt32] ErrorID to put in the error code*/ #define M4OSA_ERR_CREATE(severity, coreID, errorID)\ (M4OSA_UInt32)((((M4OSA_UInt32)severity)<<30)+((((M4OSA_UInt32)coreID)&0x003FFF)<<16)+(((M4OSA_UInt32)errorID)&0x00FFFF)) /** This macro extracts the 3 fields from the error: * @arg error: (IN) [M4OSA_ERR] Error code * @arg severity: (OUT) [M4OSA_UInt32] Severity to put in the error code * @arg coreID: (OUT) [M4OSA_UInt32] CoreID to put in the error code * @arg errorID: (OUT) [M4OSA_UInt32] ErrorID to put in the error code*/ #define M4OSA_ERR_SPLIT(error, severity, coreID, errorID)\ { severity=(M4OSA_UInt32)((error)>>30);\ coreID=(M4OSA_UInt32)(((error)>>16)&0x003FFF);\ (M4OSA_UInt32)(errorID=(error)&0x00FFFF); } /* "fake" CoreID, is used to report an unknown CoreID. Used by the trace system when the core ID macro isn't defined. Defined here instead of CoreID.h to avoid introducing dependencies to common/inc. */ #define M4UNKNOWN_COREID 0x3FFF /* max possible CoreID */ #define M4_COMMON 0x00 /**