/*===========================================================================
                    IMPORTANT NOTICE

            Not to be distributed in source format.

FILE:  bridle_sms.h

SERVICES:  Bridle'd SMS OEM interfaces. 

GENERAL DESCRIPTION:
   Contains inlined code that does swi into Supervisor mode and invokes
   appropriate routine.

        Copyright © 2004 QUALCOMM Incorporated.
               All Rights Reserved.
            QUALCOMM Proprietary/GTDR
===========================================================================*/

#ifndef __BRIDLE_SMS_H__
#define __BRIDLE_SMS_H__

#include "OEMSMS.h"
#include "OEMSMSStorage.h"
#include "AEEBridle.h"
#include "AEEkCB.h"

/* Subroutine Id to map different functions invoked in Supervisor mode. */
enum {
   BRIDLE_SMS_ID_OEMSMS_New,
   BRIDLE_SMS_ID_OEMSMS_AddRef,
   BRIDLE_SMS_ID_OEMSMS_Release,
   BRIDLE_SMS_ID_OEMSMS_GetNewMsgInfo,
   BRIDLE_SMS_ID_OEMSMS_GetMsgPayload,
   BRIDLE_SMS_ID_OEMSMS_GetMsgData,
   BRIDLE_SMS_ID_OEMSMS_OnMTMessage,
   BRIDLE_SMS_ID_OEMSMS_SendMessage,
   BRIDLE_SMS_ID_OEMSMS_SetClientStatus,
   BRIDLE_SMS_ID_OEMSMS_FreeMsg,
   BRIDLE_SMS_ID_OEMSMS_IsStorageInitialized,
   BRIDLE_SMS_ID_OEMSMS_GetStorageStatus,
   BRIDLE_SMS_ID_OEMSMS_StoreMsg,
   BRIDLE_SMS_ID_OEMSMS_ReadMsg,
   BRIDLE_SMS_ID_OEMSMS_RemoveMsg,
   BRIDLE_SMS_ID_OEMSMS_GetEnumMsgIDs,
   BRIDLE_SMS_ID_OEMSMSBCConfig_GetBCConfig,
   BRIDLE_SMS_ID_OEMSMSBCConfig_GetBCPref,
   BRIDLE_SMS_ID_OEMSMSBCConfig_SetBCPref,
   BRIDLE_SMS_ID_OEMSMSBCConfig_GetNumberOfServiceIDs,
   BRIDLE_SMS_ID_OEMSMSBCConfig_GetServiceOpts,
   BRIDLE_SMS_ID_OEMSMSBCConfig_SetServiceOpts,
   BRIDLE_SMS_ID_OEMSMSBCConfig_GetNumberOfServiceOpts,
   BRIDLE_SMS_ID_OEMSMSBCConfig_DeleteService,
   BRIDLE_SMS_ID_OEMSMSBCConfig_FillServiceIDs,
   BRIDLE_SMS_ID_OEMSMSBCConfig_FillServiceInfo,
   BRIDLE_SMS_ID_MAX
};

extern AEE_EXPORTS uint32 bridle_oemsms_swi;

extern OEMSMSMgr *hOEMSMS;

#define SMS_BRIDLE0_RET( r, f) \
         BRIDLE0_RET( r, f, \
                      bridle_oemsms_swi, BRIDLE_SMS_ID_##f )

#define SMS_BRIDLE1_VOID( f, t1, v1, n1 ) \
         BRIDLE1_VOID( f, t1, v1, n1, bridle_oemsms_swi, BRIDLE_SMS_ID_##f )

#define SMS_BRIDLE1_RET( r, f, t1, v1, n1 ) \
         BRIDLE1_RET( r, f, t1, v1, n1, \
                      bridle_oemsms_swi, BRIDLE_SMS_ID_##f )

#define SMS_BRIDLE2_VOID( f, t1, v1, n1, t2, v2, n2 ) \
         BRIDLE2_VOID( f, t1, v1, n1, t2, v2, n2, bridle_oemsms_swi, BRIDLE_SMS_ID_##f )
                                                                                       
#define SMS_BRIDLE2_RET( r, f, t1, v1, n1, t2, v2, n2 ) \
         BRIDLE2_RET( r, f, t1, v1, n1, t2, v2, n2, \
                      bridle_oemsms_swi, BRIDLE_SMS_ID_##f )

#define SMS_BRIDLE3_VOID( f, t1, v1, n1, t2, v2, n2, t3, v3, n3 ) \
         BRIDLE3_VOID( f, t1, v1, n1, t2, v2, n2, t3, v3, n3, \
                      bridle_oemsms_swi, BRIDLE_SMS_ID_##f )

#define SMS_BRIDLE3_RET( r, f, t1, v1, n1, t2, v2, n2, t3, v3, n3 ) \
         BRIDLE3_RET( r, f, t1, v1, n1, t2, v2, n2, t3, v3, n3, \
                      bridle_oemsms_swi, BRIDLE_SMS_ID_##f )

#define SMS_BRIDLE4_VOID( f, t1, v1, n1, t2, v2, n2, t3, v3, n3, t4, v4, n4 ) \
         BRIDLE4_VOID( f, t1, v1, n1, t2, v2, n2, t3, v3, n3, t4, v4, n4, \
                      bridle_oemsms_swi, BRIDLE_SMS_ID_##f )
                      
#define SMS_BRIDLE4_RET( r, f, t1, v1, n1, t2, v2, n2, t3, v3, n3, t4, v4, n4 ) \
         BRIDLE4_RET( r, f, t1, v1, n1, t2, v2, n2, t3, v3, n3, t4, v4, n4, \
                      bridle_oemsms_swi, BRIDLE_SMS_ID_##f )

#define SMS_BRIDLE5_VOID( f, t1, v1, n1, t2, v2, n2, t3, v3, n3, t4, v4, n4, t5, v5, n5 ) \
         BRIDLE5_VOID( f, t1, v1, n1, t2, v2, n2, t3, v3, n3, t4, v4, n4, t5, v5, n5, \
                      bridle_oemsms_swi, BRIDLE_SMS_ID_##f )
                    
#define SMS_BRIDLE6_VOID( f, t1, v1, n1, t2, v2, n2, t3, v3, n3, t4, v4, n4, t5, v5, n5, t6, v6, n6 ) \
         BRIDLE6_VOID( f, t1, v1, n1, t2, v2, n2, t3, v3, n3, t4, v4, n4, t5, v5, n5, t6, v6, n6, \
                      bridle_oemsms_swi, BRIDLE_SMS_ID_##f )

/* inlined functions packbridle_* and unpackbridle_* */
PACKBRIDLE1_RET( int, OEMSMS_New,
                 OEMSMSMgr **, 
                 bridle_oemsms_swi, BRIDLE_SMS_ID_OEMSMS_New )

SMS_BRIDLE1_RET( uint32, OEMSMS_AddRef,
                  OEMSMSMgr *, BRIDLE_CHECK_VALUE, hOEMSMS )

SMS_BRIDLE1_RET( uint32, OEMSMS_Release,
                  OEMSMSMgr *, BRIDLE_CHECK_VALUE, hOEMSMS )

SMS_BRIDLE3_RET( int, OEMSMS_GetNewMsgInfo,
                  OEMSMSMgr *, BRIDLE_CHECK_VALUE, hOEMSMS,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32),
                  int *, BRIDLE_CHECK_WRITEACCESS, sizeof(int))  

SMS_BRIDLE3_RET( int, OEMSMS_GetMsgPayload,
                  OEMSMSMgr *, BRIDLE_CHECK_VALUE, hOEMSMS,
                  uint32, BRIDLE_CHECK_NONE, 0,
                  OEMMsgPayload *, BRIDLE_CHECK_WRITEACCESS, sizeof(OEMMsgPayload) + ((OEMMsgPayload*)UNPACKBRIDLE_PARAM_3)->nBytes) 

SMS_BRIDLE3_RET( int, OEMSMS_GetMsgData,
                  OEMSMSMgr *, BRIDLE_CHECK_VALUE, hOEMSMS,
                  uint32, BRIDLE_CHECK_NONE, 0,
                  OEMMsgData *, BRIDLE_CHECK_WRITEACCESS, sizeof(OEMMsgData) + ((OEMMsgData*)UNPACKBRIDLE_PARAM_3)->nBytes)  

SMS_BRIDLE2_VOID( OEMSMS_OnMTMessage,
                  OEMSMSMgr *, BRIDLE_CHECK_VALUE, hOEMSMS,
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4 )

SMS_BRIDLE5_VOID( OEMSMS_SendMessage,
                  OEMSMSMgr *, BRIDLE_CHECK_VALUE, hOEMSMS,
                  OEMMsgData *, BRIDLE_CHECK_READACCESS, sizeof(OEMMsgData) + ((OEMMsgData*)UNPACKBRIDLE_PARAM_2)->nBytes,
                  OEMMsgPayload *, BRIDLE_CHECK_READACCESS, sizeof(OEMMsgPayload) + ((OEMMsgPayload*)UNPACKBRIDLE_PARAM_3)->nBytes,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32),
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4 )

SMS_BRIDLE3_VOID( OEMSMS_SetClientStatus,
                  OEMSMSMgr *, BRIDLE_CHECK_VALUE, hOEMSMS,
                  uint32, BRIDLE_CHECK_NONE, 0,
                  uint32, BRIDLE_CHECK_NONE, 0)

SMS_BRIDLE2_VOID( OEMSMS_FreeMsg,
                  OEMSMSMgr *, BRIDLE_CHECK_VALUE, hOEMSMS,
                  uint32, BRIDLE_CHECK_NONE, 0)

SMS_BRIDLE0_RET( boolean, OEMSMS_IsStorageInitialized)

SMS_BRIDLE5_VOID( OEMSMS_GetStorageStatus,
                  AEESMSStorageType, BRIDLE_CHECK_NONE, 0,
                  AEESMSTag, BRIDLE_CHECK_NONE, 0,
                  AEESMSStorageStatus *, BRIDLE_CHECK_WRITEACCESS, sizeof(AEESMSStorageStatus),
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32),
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4 )

SMS_BRIDLE6_VOID( OEMSMS_StoreMsg,
                  AEESMSStorageType, BRIDLE_CHECK_NONE, 0,
                  OEMMsgData *, BRIDLE_CHECK_READACCESS, sizeof(OEMMsgData) + ((OEMMsgData*)UNPACKBRIDLE_PARAM_2)->nBytes,
                  OEMMsgPayload *, BRIDLE_CHECK_READACCESS, sizeof(OEMMsgPayload) + ((OEMMsgPayload*)UNPACKBRIDLE_PARAM_3)->nBytes,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32),
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32),
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4 )

SMS_BRIDLE6_VOID( OEMSMS_ReadMsg,
                  AEESMSStorageType, BRIDLE_CHECK_NONE, 0,
                  uint32, BRIDLE_CHECK_NONE, 0,
                  OEMMsgData *, BRIDLE_CHECK_WRITEACCESS, sizeof(OEMMsgData) + ((OEMMsgData*)UNPACKBRIDLE_PARAM_3)->nBytes,
                  OEMMsgPayload *, BRIDLE_CHECK_WRITEACCESS, sizeof(OEMMsgPayload) + ((OEMMsgPayload*)UNPACKBRIDLE_PARAM_4)->nBytes,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32),
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4 )

SMS_BRIDLE5_VOID( OEMSMS_RemoveMsg,
                  AEESMSStorageType, BRIDLE_CHECK_NONE, 0,
                  AEESMSTag, BRIDLE_CHECK_NONE, 0,
                  uint32, BRIDLE_CHECK_NONE, 0,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32),
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4 )
                 
SMS_BRIDLE4_RET( int, OEMSMS_GetEnumMsgIDs,
                  AEESMSStorageType, BRIDLE_CHECK_NONE, 0,
                  AEESMSTag, BRIDLE_CHECK_NONE, 0,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, *((uint32*)UNPACKBRIDLE_PARAM_4),
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32) )

SMS_BRIDLE4_VOID( OEMSMSBCConfig_GetBCConfig,
                  AEESMSMode, BRIDLE_CHECK_NONE, 0,
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4,
                  AEESMSBCConfig *, BRIDLE_CHECK_WRITEACCESS, sizeof(AEESMSBCConfig),
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32))

SMS_BRIDLE4_VOID( OEMSMSBCConfig_GetBCPref,
                  AEESMSMode, BRIDLE_CHECK_NONE, 0,
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4,
                  AEESMSBCPref *, BRIDLE_CHECK_WRITEACCESS, sizeof(AEESMSBCPref),
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32))

SMS_BRIDLE4_VOID( OEMSMSBCConfig_SetBCPref,
                  AEESMSMode, BRIDLE_CHECK_NONE, 0,
                  AEESMSBCPref, BRIDLE_CHECK_NONE, 0,
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32))

SMS_BRIDLE4_VOID( OEMSMSBCConfig_GetNumberOfServiceIDs,
                  AEESMSMode, BRIDLE_CHECK_NONE, 0,
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32),
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32))

SMS_BRIDLE5_VOID( OEMSMSBCConfig_GetServiceOpts,
                  AEESMSMode, BRIDLE_CHECK_NONE, 0,
                  AEESMSBCSrvID *, BRIDLE_CHECK_READACCESS, sizeof(AEESMSBCSrvID),
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4,
                  OEMSMSBCSrvInfo *, BRIDLE_CHECK_WRITEACCESS, sizeof(OEMSMSBCSrvInfo),
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32))

SMS_BRIDLE4_VOID( OEMSMSBCConfig_SetServiceOpts,
                  AEESMSMode, BRIDLE_CHECK_NONE, 0,
                  OEMSMSBCSrvInfo *, BRIDLE_CHECK_READACCESS, sizeof(OEMSMSBCSrvInfo),
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32))

SMS_BRIDLE4_VOID( OEMSMSBCConfig_GetNumberOfServiceOpts,
                  AEESMSMode, BRIDLE_CHECK_NONE, 0,
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32),
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32))

SMS_BRIDLE4_VOID( OEMSMSBCConfig_DeleteService,
                  AEESMSMode, BRIDLE_CHECK_NONE, 0,
                  AEESMSBCSrvID *, BRIDLE_CHECK_READACCESS, sizeof(AEESMSBCSrvID),
                  AEECallback *, BRIDLE_CHECK_AEEKCB, 4,
                  uint32 *, BRIDLE_CHECK_WRITEACCESS, sizeof(uint32))

SMS_BRIDLE2_VOID( OEMSMSBCConfig_FillServiceIDs,
                  AEESMSBCSrvID *, BRIDLE_CHECK_WRITEACCESS, (uint32)UNPACKBRIDLE_PARAM_2,
                  uint32, BRIDLE_CHECK_NONE, 0)
                  
SMS_BRIDLE2_VOID( OEMSMSBCConfig_FillServiceInfo,
                  OEMSMSBCSrvInfo *, BRIDLE_CHECK_WRITEACCESS, (uint32)UNPACKBRIDLE_PARAM_2,
                  uint32, BRIDLE_CHECK_NONE, 0)

#ifndef _BRIDLE_SMS_IMPL

#define OEMSMS_New                     packbridle_OEMSMS_New
#define OEMSMS_AddRef                  packbridle_OEMSMS_AddRef
#define OEMSMS_Release                 packbridle_OEMSMS_Release
#define OEMSMS_GetNewMsgInfo           packbridle_OEMSMS_GetNewMsgInfo
#define OEMSMS_GetMsgPayload           packbridle_OEMSMS_GetMsgPayload
#define OEMSMS_GetMsgData              packbridle_OEMSMS_GetMsgData
#define OEMSMS_OnMTMessage             packbridle_OEMSMS_OnMTMessage
#define OEMSMS_SendMessage             packbridle_OEMSMS_SendMessage
#define OEMSMS_SetClientStatus         packbridle_OEMSMS_SetClientStatus
#define OEMSMS_FreeMsg                 packbridle_OEMSMS_FreeMsg
#define OEMSMS_IsStorageInitialized    packbridle_OEMSMS_IsStorageInitialized
#define OEMSMS_GetStorageStatus        packbridle_OEMSMS_GetStorageStatus
#define OEMSMS_StoreMsg                packbridle_OEMSMS_StoreMsg
#define OEMSMS_ReadMsg                 packbridle_OEMSMS_ReadMsg
#define OEMSMS_RemoveMsg               packbridle_OEMSMS_RemoveMsg
#define OEMSMS_GetEnumMsgIDs           packbridle_OEMSMS_GetEnumMsgIDs
#define OEMSMSBCConfig_GetBCConfig              packbridle_OEMSMSBCConfig_GetBCConfig
#define OEMSMSBCConfig_GetBCPref                packbridle_OEMSMSBCConfig_GetBCPref
#define OEMSMSBCConfig_SetBCPref                packbridle_OEMSMSBCConfig_SetBCPref
#define OEMSMSBCConfig_GetNumberOfServiceIDs    packbridle_OEMSMSBCConfig_GetNumberOfServiceIDs
#define OEMSMSBCConfig_GetServiceOpts           packbridle_OEMSMSBCConfig_GetServiceOpts
#define OEMSMSBCConfig_SetServiceOpts           packbridle_OEMSMSBCConfig_SetServiceOpts
#define OEMSMSBCConfig_GetNumberOfServiceOpts   packbridle_OEMSMSBCConfig_GetNumberOfServiceOpts
#define OEMSMSBCConfig_DeleteService            packbridle_OEMSMSBCConfig_DeleteService
#define OEMSMSBCConfig_FillServiceIDs           packbridle_OEMSMSBCConfig_FillServiceIDs
#define OEMSMSBCConfig_FillServiceInfo          packbridle_OEMSMSBCConfig_FillServiceInfo
#endif /* !_BRIDLE_SMS_IMPL */

#endif // __BRIDLE_SMS_H__

