connectivitylayer/isce/isirouter_dll/inc/isihelpers.h
changeset 9 8486d82aef45
parent 0 63b37f68c1ce
equal deleted inserted replaced
8:6295dc2169f3 9:8486d82aef45
    22 //  INCLUDES
    22 //  INCLUDES
    23 #include <pn_const.h>                   // For PN_HEADER_SIZE
    23 #include <pn_const.h>                   // For PN_HEADER_SIZE
    24 #include <commisi.h>                    // For SIZE_COMMON_MESSAGE_COMM_ISA_ENTITY_NOT_REACHABLE_RESP
    24 #include <commisi.h>                    // For SIZE_COMMON_MESSAGE_COMM_ISA_ENTITY_NOT_REACHABLE_RESP
    25 #include <phonetisi.h>                  // For ISI_HEADER_SIZE
    25 #include <phonetisi.h>                  // For ISI_HEADER_SIZE
    26 
    26 
       
    27 
       
    28 #ifndef PN_DEV_OWN
       
    29 #define PN_DEV_OWN 0 // PN_DEV_HOST
       
    30 #endif // PN_DEV_OWN
       
    31 
       
    32 #ifndef PN_OBJ_ROUTING_REQ
       
    33 #define PN_OBJ_ROUTING_REQ 0x00
       
    34 #endif // PN_OBJ_ROUTING_REQ
       
    35 
       
    36 #ifndef PN_MEDIA_ROUTING_REQ
       
    37 #define PN_MEDIA_ROUTING_REQ 0x00
       
    38 #endif // PN_MEDIA_ROUTING_REQ
       
    39 
       
    40 #ifndef PN_OBJ_ROUTER
       
    41 #define PN_OBJ_ROUTER PN_OBJ_ROUTING_REQ
       
    42 #endif // PN_OBJ_ROUTER
       
    43 
       
    44 
       
    45 #ifndef PN_DEV_MODEM
       
    46 #define PN_DEV_MODEM        0x60
       
    47 #endif // PN_DEV_MODEM
       
    48 
       
    49 #ifndef PN_MEDIA_MODEM_HOST_IF
       
    50 #define PN_MEDIA_MODEM_HOST_IF  0x26 // Media to/from PN_DEV_MODEM
       
    51 #endif // PN_MEDIA_MODEM_HOST_IF
       
    52 
       
    53 #ifndef PN_DEV_PC
       
    54 #define PN_DEV_PC       0x10
       
    55 #endif // PN_MEDIA_TEST
       
    56 
       
    57 // not real only for testing
       
    58 #ifndef PN_DEV_DUMMYIST
       
    59 // SET equla to PN_DEV_TEST 0x3c
       
    60 #define PN_DEV_DUMMYIST     0x3c 
       
    61 #endif // PN_DEV_DUMMYIST
       
    62 
       
    63 #ifndef PN_MEDIA_TEST
       
    64 #define PN_MEDIA_TEST       0xBB
       
    65 #endif // PN_MEDIA_TEST
       
    66 // not real
       
    67 
       
    68 // <- end 
       
    69 
    27 // MACROS
    70 // MACROS
    28 
    71 
    29 #if defined ( __WINS__ )
    72 #if defined ( __WINS__ )
    30 #define MESSAGELENGTH_LSB 5
    73 #define MESSAGELENGTH_LSB 5
    31 #define MESSAGELENGTH_MSB 4
    74 #define MESSAGELENGTH_MSB 4
    32 #else
    75 #else // __WINS__
       
    76 #ifndef ISI_LENGTH_BIG_ENDIAN
    33 #define MESSAGELENGTH_LSB 4
    77 #define MESSAGELENGTH_LSB 4
    34 #define MESSAGELENGTH_MSB 5
    78 #define MESSAGELENGTH_MSB 5
    35 #endif
    79 #else  //ISI_LENGTH_BIG_ENDIAN
       
    80 #define MESSAGELENGTH_LSB 5
       
    81 #define MESSAGELENGTH_MSB 4
       
    82 #endif // ISI_LENGTH_BIG_ENDIAN
       
    83 #endif // __WINS__
    36 
    84 
    37 #define IS_DEV_HOST( dev )            ( ( dev & 0xF0 ) == 0 )
    85 #define IS_DEV_HOST( dev )            ( ( dev & 0xF0 ) == 0 )
    38 #define GET_RECEIVER_DEV( msg )       ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] & 0xFC )
    86 #define GET_RECEIVER_DEV( msg )       ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] & 0xFC )
    39 #define GET_SENDER_DEV( msg )         ( msg[ ISI_HEADER_OFFSET_SENDERDEVICE ] & 0xFC )
    87 #define GET_SENDER_DEV( msg )         ( msg[ ISI_HEADER_OFFSET_SENDERDEVICE ] & 0xFC )
    40 //OK (WINS?)
    88 //OK (WINS?)
    55                                       msg[ ISI_HEADER_OFFSET_SENDEROBJECT ] = ( TUint8 )( ( o ) & 0x00FF )
   103                                       msg[ ISI_HEADER_OFFSET_SENDEROBJECT ] = ( TUint8 )( ( o ) & 0x00FF )
    56 
   104 
    57 #define SET_LENGTH( msg,len )         msg[ MESSAGELENGTH_MSB ] = ( TUint8 )( ( len ) >> 8 );msg[ MESSAGELENGTH_LSB ] = ( TUint8 )( len );
   105 #define SET_LENGTH( msg,len )         msg[ MESSAGELENGTH_MSB ] = ( TUint8 )( ( len ) >> 8 );msg[ MESSAGELENGTH_LSB ] = ( TUint8 )( len );
    58 #define GET_LENGTH( msg )             ( ( ( TUint16 )( ( msg[ MESSAGELENGTH_MSB ] ) << 8 ) ) | msg[ MESSAGELENGTH_LSB ] )
   106 #define GET_LENGTH( msg )             ( ( ( TUint16 )( ( msg[ MESSAGELENGTH_MSB ] ) << 8 ) ) | msg[ MESSAGELENGTH_LSB ] )
    59 
   107 
       
   108 
       
   109 /* PUTB8 macro writes byte value to given address.
       
   110  * This macro is used mainly by other PUTBXX macros.
       
   111  */
       
   112 #define PUTB8(p,v) \
       
   113     {(*(TUint8 *)(p)) = ((TUint8)(v));}
       
   114 
       
   115 
       
   116 /* PUTB16 macro writes 16-bit value in Big Endian format
       
   117  * to given address. 16-bit value is written as two separate
       
   118  * bytes, and so this macro can write 16-bit value to whatever
       
   119  * address, regardless of the processor alignment restrictions
       
   120  */
       
   121 #define PUTB16(p,v) \
       
   122     {PUTB8((p),(TUint16)(v)>>8); PUTB8((TUint8*)(p)+1,v);}
       
   123 
       
   124 
       
   125 /* PUTB32 macro writes 32-bit value in Big Endian format
       
   126  * to given address. 32-bit value is written as four separate
       
   127  * bytes, and so this macro can write 32-bit value to whatever
       
   128  * address, regardless of the processor alignment restrictions
       
   129  */
       
   130 #define PUTB32(p,v) \
       
   131     {PUTB16((p),(TUint32)(v)>>16); PUTB16((TUint8*)(p)+2,(TUint32)(v));}
       
   132 
       
   133 
       
   134 /**
       
   135  *    Big Endian to local endian type
       
   136  */
       
   137  /* GETB8 macro returns byte value from given address.
       
   138  * This macro is used mainly by other GETBXX macros.
       
   139  */
       
   140 #define GETB8(p) \
       
   141     (*(TUint8 *)(p))
       
   142 
       
   143 
       
   144 /* GETB16 macro reads 16-bit value in Big Endian format
       
   145  * from given address. 16-bit value is read as two separate
       
   146  * bytes, and so this macro can read 16-bit value from whatever
       
   147  * address, regardless of the processor alignment restrictions
       
   148  */
       
   149 #define GETB16(p) \
       
   150     (((TUint16) GETB8(p)<<8) | (TUint16) GETB8((TUint8 *)(p)+1))
       
   151 
       
   152 
       
   153 /* GETB32 macro reads 32-bit value in Big Endian format
       
   154  * from given address. 32-bit value is read as four separate
       
   155  * bytes, and so this macro can read 32-bit value from whatever
       
   156  * address, regardless of the processor alignment restrictions
       
   157  */
       
   158 #define GETB32(p) \
       
   159     (((TUint32) GETB16(p)<<16) | (TUint32) GETB16((TUint8 *)(p)+2))
       
   160 
       
   161 
    60 // FUNCTION PROTOTYPES
   162 // FUNCTION PROTOTYPES
    61 
   163 
    62 // FORWARD DECLARATIONS
   164 // FORWARD DECLARATIONS
    63 
   165 
    64 #endif // ISI_HELPERS_H
   166 #endif // ISI_HELPERS_H