Home | History | Annotate | Download | only in inc
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 /**
     17  ************************************************************************
     18  * @file         M4OSA_OptionID.h
     19  * @ingroup      OSAL
     20  * @brief        Option ID macros
     21  * @note         This file defines macros to generate and analyze option ID.
     22  *               Option ID is used by M4YYY_ZZsetOption() and
     23  *               M4YYY_ZZgetOption() functions.
     24  ************************************************************************
     25 */
     26 
     27 #ifndef M4OSA_OPTIONID_H
     28 #define M4OSA_OPTIONID_H
     29 
     30 
     31 #include "M4OSA_Types.h"
     32 
     33 /** M4OSA_OptionID is a 32 bits unsigned integer.
     34 - Right access (2 bits): Some options may have read only, write only or read
     35   and write access
     36 - Core ID (14 bits): It is a unique ID for each core component
     37 - SubOption ID (16 bits): To select which option in a specific core component
     38 */
     39 typedef M4OSA_UInt32 M4OSA_OptionID;
     40 typedef void*        M4OSA_DataOption;
     41 
     42 #define M4_READ      0x01
     43 #define M4_WRITE     0x02
     44 #define M4_READWRITE 0x03
     45 
     46 /* Macro to process M4OSA_OptionID */
     47 
     48 /** This macro creates an optionID given read/write access,
     49     coreID and SubOptionID*/
     50 #define M4OSA_OPTION_ID_CREATE(right, coreID, errorID)\
     51    (M4OSA_Int32)((((((M4OSA_UInt32)right)&0x03)<<30))+((((M4OSA_UInt32)coreID)&0x003FFF)<<16)+(((M4OSA_UInt32)errorID)&0x00FFFF))
     52 
     53 /** This macro splits an optionID into read/write access,
     54     coreID and SubOptionID*/
     55 #define M4OSA_OPTION_ID_SPLIT(optionID, right, coreID, errorID)\
     56    { right=(M4OSA_UInt8)((optionID)>>30);\
     57      coreID=(M4OSA_UInt16)(((optionID)>>16)&0x00003FFF);\
     58      errorID=(M4OSA_UInt32)((optionID)&0x0000FFFF); }
     59 
     60 /** This macro returns 1 if the optionID is writable, 0 otherwise*/
     61 #define M4OSA_OPTION_ID_IS_WRITABLE(optionID) ((((optionID)>>30)&M4_WRITE)!=0)
     62 
     63 /** This macro returns 1 if the optionID is readable, 0 otherwise*/
     64 #define M4OSA_OPTION_ID_IS_READABLE(optionID) ((((optionID)>>30)&M4_READ)!=0)
     65 
     66 /** This macro returns 1 if the optionID has its core ID equal to 'coreID', 0 otherwise*/
     67 #define M4OSA_OPTION_ID_IS_COREID(optionID, coreID)\
     68    (((((optionID)>>16)&0x003FFF) == (coreID)) ? M4OSA_TRUE:M4OSA_FALSE)
     69 
     70 
     71 #endif   /*M4OSA_OPTIONID_H*/
     72 
     73