0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef ISI_HELPERS_H
|
|
21 |
#define ISI_HELPERS_H
|
|
22 |
// INCLUDES
|
|
23 |
#include <pn_const.h> // For PN_HEADER_SIZE
|
|
24 |
#include <commisi.h> // For SIZE_COMMON_MESSAGE_COMM_ISA_ENTITY_NOT_REACHABLE_RESP
|
|
25 |
#include <phonetisi.h> // For ISI_HEADER_SIZE
|
|
26 |
|
9
|
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 |
|
0
|
70 |
// MACROS
|
|
71 |
|
|
72 |
#if defined ( __WINS__ )
|
|
73 |
#define MESSAGELENGTH_LSB 5
|
|
74 |
#define MESSAGELENGTH_MSB 4
|
9
|
75 |
#else // __WINS__
|
|
76 |
#ifndef ISI_LENGTH_BIG_ENDIAN
|
0
|
77 |
#define MESSAGELENGTH_LSB 4
|
|
78 |
#define MESSAGELENGTH_MSB 5
|
9
|
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__
|
0
|
84 |
|
|
85 |
#define IS_DEV_HOST( dev ) ( ( dev & 0xF0 ) == 0 )
|
|
86 |
#define GET_RECEIVER_DEV( msg ) ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] & 0xFC )
|
|
87 |
#define GET_SENDER_DEV( msg ) ( msg[ ISI_HEADER_OFFSET_SENDERDEVICE ] & 0xFC )
|
|
88 |
//OK (WINS?)
|
|
89 |
#define GET_RECEIVER_OBJ( msg ) ( IS_DEV_HOST( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] ) ? \
|
|
90 |
( ( TUint16 )msg[ ISI_HEADER_OFFSET_RECEIVEROBJECT ] + ( ( msg [ ISI_HEADER_OFFSET_RECEIVERDEVICE ] & 0x0F ) << 8 ) ) : \
|
|
91 |
( ( TUint16 )msg[ ISI_HEADER_OFFSET_RECEIVEROBJECT ] + ( ( msg [ ISI_HEADER_OFFSET_RECEIVERDEVICE ] & 0x03 ) << 8 ) ) )
|
|
92 |
//OK (WINS?)
|
|
93 |
#define GET_SENDER_OBJ( msg ) ( IS_DEV_HOST( msg[ ISI_HEADER_OFFSET_SENDERDEVICE ] ) ? \
|
|
94 |
( ( TUint16 )msg[ ISI_HEADER_OFFSET_SENDEROBJECT ] + ( ( msg[ ISI_HEADER_OFFSET_SENDERDEVICE ] & 0x0F ) << 8 ) ) : \
|
|
95 |
( ( TUint16 )msg[ ISI_HEADER_OFFSET_SENDEROBJECT ] + ( ( msg[ ISI_HEADER_OFFSET_SENDERDEVICE ] & 0x03 ) << 8 ) ) )
|
|
96 |
#define SET_RECEIVER_DEV( msg, dev ) ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE] = ( ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] & 0x03 ) | ( ( dev ) & 0xFC ) ) )
|
|
97 |
#define SET_SENDER_DEV( msg, dev ) ( msg[ ISI_HEADER_OFFSET_SENDERDEVICE] = ( ( msg[ ISI_HEADER_OFFSET_SENDERDEVICE ] & 0x03 ) | ( ( dev ) & 0xFC ) ) )
|
|
98 |
#define SET_RECEIVER_OBJ( msg, o ) msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] = ( IS_DEV_HOST( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] ) ) ? \
|
|
99 |
GET_RECEIVER_DEV( msg ) | ( ( ( o ) >> 8 ) & 0x0F ) : GET_RECEIVER_DEV( msg ) | ( ( ( o ) >> 8 ) & 0x03 ), \
|
|
100 |
msg[ ISI_HEADER_OFFSET_RECEIVEROBJECT ] = ( TUint8 )( ( o ) & 0x00FF )
|
|
101 |
#define SET_SENDER_OBJ( msg, o ) msg[ ISI_HEADER_OFFSET_SENDERDEVICE ] = ( IS_DEV_HOST( msg[ ISI_HEADER_OFFSET_SENDERDEVICE ] ) ) ? \
|
|
102 |
GET_SENDER_DEV( msg ) | ( ( ( o ) >> 8 ) & 0x0F ) : GET_SENDER_DEV( msg ) | ( ( ( o ) >> 8 ) & 0x03 ), \
|
|
103 |
msg[ ISI_HEADER_OFFSET_SENDEROBJECT ] = ( TUint8 )( ( o ) & 0x00FF )
|
|
104 |
|
|
105 |
#define SET_LENGTH( msg,len ) msg[ MESSAGELENGTH_MSB ] = ( TUint8 )( ( len ) >> 8 );msg[ MESSAGELENGTH_LSB ] = ( TUint8 )( len );
|
|
106 |
#define GET_LENGTH( msg ) ( ( ( TUint16 )( ( msg[ MESSAGELENGTH_MSB ] ) << 8 ) ) | msg[ MESSAGELENGTH_LSB ] )
|
|
107 |
|
9
|
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 |
|
0
|
162 |
// FUNCTION PROTOTYPES
|
|
163 |
|
|
164 |
// FORWARD DECLARATIONS
|
|
165 |
|
|
166 |
#endif // ISI_HELPERS_H
|
|
167 |
// End of File
|