FreeCalypso > hg > freecalypso-sw
changeset 112:4179acab05f7
nuc-fw/bsp: niq32.c and sim.h replaced with new versions
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 20 Oct 2013 08:43:41 +0000 |
parents | 5b7403f6ae93 |
children | 3b2e941043d8 |
files | nuc-fw/bsp/niq32.c nuc-fw/bsp/sim.h |
diffstat | 2 files changed, 278 insertions(+), 245 deletions(-) [+] |
line wrap: on
line diff
--- a/nuc-fw/bsp/niq32.c Sun Oct 20 07:58:00 2013 +0000 +++ b/nuc-fw/bsp/niq32.c Sun Oct 20 08:43:41 2013 +0000 @@ -16,55 +16,96 @@ Author : proussel@ti.com Patrick Roussel. - Version number : 1.12 + Version number : 1.25 - Date and time : 02/19/01 14:01:50 + Date : 08/22/03 Previous delta : 12/19/00 14:24:51 - SCCS file : /db/gsm_asp/db_ht96/dsp_0/gsw/rel_0/mcu_l1/release_gprs/mod/emu_p/EMU_P_FRED_ADC/drivers1/common/SCCS/s.niq32.c - - Sccs Id (SID) : '@(#) niq32.c 1.12 02/19/01 14:01:50 ' *******************************************************************************/ -#include "l1_sw.cfg" +#include "l1sw.cfg" + +#include "chipset.cfg" +#include "board.cfg" +#include "rf.cfg" +#include "swconfig.cfg" -#if(!OP_L1_STANDALONE) - #include "chipset.cfg" +#if(OP_L1_STANDALONE == 0) #include "debug.cfg" - #include "board.cfg" - #include "rv_defined_swe.h" - #include "rtc_config.h" + #include "rv/rv_defined_swe.h" + #include "rtc/board/rtc_config.h" +#else + #include "l1_macro.h" + #include "l1_confg.h" +#endif + +#if(OP_L1_STANDALONE == 0) +#include "swconfig.cfg" +#ifdef BLUETOOTH_INCLUDED +#include "btemobile.cfg" +#ifdef BT_CLK_REQ_INT +#include "board/bth_drv.h" +#endif +#endif #endif -#include "sys_types.h" -#include "serialswitch.h" + +#if(L1_DYN_DSP_DWNLD == 1) + #include "l1_api_hisr.h" +#endif + +#if (OP_L1_STANDALONE == 0) + #include "main/sys_types.h" +#else + #include "sys_types.h" +#endif -#include "mem.h" -#include "inth.h" -#include "sim.h" -#include "abb_inth.h" // for External Interrupt +#if (CHIPSET == 12) + #include "sys_inth.h" +#else + #include "inth/inth.h" + #include "memif/mem.h" + #if (OP_L1_STANDALONE == 1) + #include "serialswitch_core.h" + #else + #include "uart/serialswitch.h" + #endif + #if (OP_L1_STANDALONE == 0) + #include "sim/sim.h" + #endif +#endif + +#include "abb/abb_core_inth.h" // for External Interrupt #define IQ_H -#include "iq.h" -#include "ulpd.h" +#include "inth/iq.h" +#include "ulpd/ulpd.h" +#if (BOARD == 34) + #include "csmi/csmi.h" +#endif #if (defined RVM_DAR_SWE) && (defined _GSM) extern void dar_watchdog_reset(void); #endif -#if ((BOARD == 8) || (BOARD == 9) || (BOARD == 40) || (BOARD == 41) || (BOARD == 43) || (BOARD == 45)) -#include "armio.h" -#include "uartfax.h" +#if ((BOARD == 8) || (BOARD == 9) || (BOARD == 40) || (BOARD == 41) || (BOARD == 42) || (BOARD == 43) || (BOARD == 45)) +#include "armio/armio.h" + #if (OP_L1_STANDALONE == 0) + #include "uart/uartfax.h" + #endif #endif /* External declaration */ extern void GAUGING_Handler(void); extern void TMT_Timer_Interrupt(void); +#if (OP_L1_STANDALONE == 1) + extern void TM_Timer1Handler(void); +#endif extern void kpd_key_handler(void); extern void TP_FrameIntHandler(void); -#if (!OP_L1_STANDALONE) +#if (OP_L1_STANDALONE == 0) #if (defined RVM_MPM_SWE) extern void MPM_InterruptHandler(void); #endif @@ -73,6 +114,10 @@ extern void ti_profiler_tdma_action(void); #endif + #if(RF_FAM==35) + extern void TSP_RxHandler(void); + #endif + extern void RTC_GaugingHandler(void); extern void RTC_ItTimerHandle(void); extern void RTC_ItAlarmHandle(void); @@ -88,19 +133,8 @@ unsigned IQ_FrameCount; /* Used to check if Frame IT TPU*/ unsigned IQ_GsmTimerCount; /* Used to check if GSM Timer IT */ -/* add this two variables for imported 188 functions, Jeffrey, 02/26/04 */ -typedef struct GPIO_HISR_INFO -{ - NU_HISR hisr; - char hisr_stack[1024]; -} T_GPIO_HISR_INFOS; -static T_GPIO_HISR_INFOS gpio_hisr_infos = {0}; -int g_interrupt = 0; - -extern void Hall_OC_IntHandler( void ) ; - - +#if (CHIPSET != 12) /*--------------------------------------------------------------*/ /* irqHandlers */ /*--------------------------------------------------------------*/ @@ -118,29 +152,27 @@ IQ_Dummy, /* AIRQ 3 */ IQ_FrameHandler, /* TPU Frame It AIRQ 4 */ IQ_Dummy, /* AIRQ 5 */ - #if (OP_L1_STANDALONE) - IQ_Dummy, - #else - SIM_IntHandler, /* AIRQ 6 */ - #endif +#if (OP_L1_STANDALONE == 0) + SIM_IntHandler, /* AIRQ 6 */ +#else + IQ_Dummy, /* AIRQ 6 */ +#endif #if ((CHIPSET == 2) || (CHIPSET == 3)) SER_uart_handler, /* AIRQ 7 */ - #elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) +#elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11)) SER_uart_modem_handler, /* AIRQ 7 */ #endif - #if (CHIPSET == 12) - IQ_KeypadHandler, /* AIRQ 8 */ - #else #if ((BOARD == 8) || (BOARD == 9) || (BOARD == 40) || (BOARD == 41)) +// CC test 0316 IQ_KeypadGPIOHandler, /* AIRQ 8 */ +// end #else IQ_KeypadHandler, /* AIRQ 8 */ #endif - #endif IQ_Rtc_Handler, /* AIRQ 9 RTC Timer*/ #if ((CHIPSET == 2) || (CHIPSET == 3)) IQ_RtcA_GsmTim_Handler, /* AIRQ 10 RTC ALARM OR ULPD GSM TIMER*/ - #elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) +#elif ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11)) IQ_RtcA_Handler, /* AIRQ 10 RTC ALARM */ #endif IQ_Gauging_Handler, /* AIRQ 11 ULPD GAUGING */ @@ -159,13 +191,21 @@ IQ_Dummy, /* External fast interrupt */ SER_uart_irda_handler, /* UART IrDA interrupt */ IQ_GsmTim_Handler, /* ULPD GSM timer */ + #if (BOARD == 34) + IQ_IcrHandler32, + #else IQ_Dummy, /* Not mapped interrupt */ + #endif IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy /* GEA interrupt */ #elif ((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11)) +#if (L1_DYN_DSP_DWNLD == 1) + IQ_ApiHandler, /* LEAD */ +#else IQ_Dummy, /* LEAD */ +#endif IQ_Dummy, /* SIM card-detect fast interrupt */ IQ_Dummy, /* External fast interrupt */ SER_uart_irda_handler, /* UART IrDA interrupt */ @@ -182,30 +222,12 @@ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy /* Reserved */ -#elif (CHIPSET == 12) - IQ_Dummy, /* IRQ15 - LEAD */ - IQ_Dummy, /* IRQ16 - GPIO */ - IQ_Dummy, /* IRQ17 - External fast interrupt */ - SER_uart_irda_handler, /* IRQ18 - UART IrDA interrupt */ - IQ_GsmTim_Handler, /* IRQ19 - ULPD GSM timer */ - IQ_Dummy, /* IRQ20 - GEA interrupt */ - IQ_Dummy, /* IRQ21 - External general Purpose interrupt IRQ1 */ - IQ_Dummy, /* IRQ22 - External general Purpose interrupt IRQ2 */ - IQ_Dummy, /* IRQ23 - USIM card insertion/extraction */ - IQ_Dummy, /* IRQ24 - USIM */ - IQ_Dummy, /* IRQ25 - LCD */ - IQ_Dummy, /* IRQ26 - USB */ - IQ_Dummy, /* IRQ27 - MMC/SD/Memory Stick */ - SER_uart_modem2_handler,/* IRQ28 - UART_MODEM2 */ - IQ_Dummy, /* IRQ29 - 2nd level interrupt handler */ - IQ_Dummy, /* IRQ30 - I2C or uWIRE */ - IQ_Dummy /* IRQ31 - NAND FLASH */ #else IQ_Dummy /* LEAD */ #endif }; -#if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) +#if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11)) /*--------------------------------------------------------------*/ /* fiqHandlers */ /*--------------------------------------------------------------*/ @@ -220,7 +242,11 @@ IQ_Dummy, /* Watchdog timer */ IQ_Dummy, /* timer 1 */ IQ_Dummy, /* timer 2 */ + #if ((OP_L1_STANDALONE == 0) && (RF_FAM == 35)) + TSP_RxHandler, /* 3 TSP */ + #else IQ_Dummy, /* AIRQ 3 */ + #endif IQ_Dummy, /* TPU Frame It AIRQ 4 */ IQ_Dummy, /* AIRQ 5 */ IQ_Dummy, /* AIRQ 6 */ @@ -233,17 +259,11 @@ IQ_Dummy, /* AIRQ 13 Spi Tx Rx interrupt */ IQ_Dummy, /* DMA interrupt */ IQ_Dummy, /* LEAD */ - #if (CHIPSET == 12) - IQ_Dummy, /* IRQ16 - GPIO */ - #else - #if (OP_L1_STANDALONE) - IQ_Dummy, - #else - /* glowing, 2004-06-08, replace SIM with Hall according to 188 */ - Hall_OC_IntHandler, /* glowing,2003-12-18, Hall open-close fast interrupt, it replace SIM_CD_IntHandler */ - //SIM_CD_IntHandler, /* SIM card-detect fast interrupt */ - #endif - #endif + #if (OP_L1_STANDALONE == 0) + SIM_CD_IntHandler, /* SIM card-detect fast interrupt */ + #else + IQ_Dummy, /* SIM card-detect fast interrupt */ + #endif IQ_Dummy, /* External fast interrupt */ IQ_Dummy, /* UART_IRDA interrupt */ #if (CHIPSET == 4) @@ -265,23 +285,10 @@ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy, /* Not mapped interrupt */ IQ_Dummy /* Reserved */ - #elif (CHIPSET == 12) - IQ_Dummy, /* IRQ19 - ULPD GSM timer */ - IQ_Dummy, /* IRQ20 - GEA interrupt */ - IQ_Dummy, /* IRQ21 - External general Purpose interrupt IRQ1 */ - IQ_Dummy, /* IRQ22 - External general Purpose interrupt IRQ2 */ - IQ_Dummy, /* IRQ23 - USIM card insertion/extraction */ - IQ_Dummy, /* IRQ24 - USIM */ - IQ_Dummy, /* IRQ25 - LCD */ - IQ_Dummy, /* IRQ26 - USB */ - IQ_Dummy, /* IRQ27 - MMC/SD/Memory Stick */ - IQ_Dummy, /* IRQ28 - UART_MODEM2 */ - IQ_Dummy, /* IRQ29 - 2nd level interrupt handler */ - IQ_Dummy, /* IRQ30 - I2C or uWIRE */ - IQ_Dummy /* IRQ31 - NAND FLASH */ #endif }; #endif +#endif /* (CHIPSET != 12)*/ /*--------------------------------------------------------------*/ /* IQ_Gauging_Handler */ @@ -293,7 +300,7 @@ void IQ_Gauging_Handler(void) { GAUGING_Handler(); -#if (!OP_L1_STANDALONE) +#if (OP_L1_STANDALONE == 0) RTC_GaugingHandler(); #endif } @@ -308,17 +315,28 @@ /*--------------------------------------------------------------*/ void IQ_External(void) { - // Mask external interrupt (12) - IQ_Mask(IQ_EXT); + #if (CHIPSET == 12) + // Mask external interrupt 12 + F_INTH_DISABLE_ONE_IT(C_INTH_ABB_IRQ_IT); + #else + // Mask external interrupt 12 + IQ_Mask(IQ_EXT); + #endif // The external IRQ is mapped on the ABB interrupt. // The associated HISR ABB_Hisr is activated on reception on the external IRQ. if(Activate_ABB_HISR()) { + #if (CHIPSET == 12) + F_INTH_ENABLE_ONE_IT(C_INTH_ABB_IRQ_IT); + #else + // Mask external interrupt 12 IQ_Unmask(IQ_EXT); + #endif } } +#if (CHIPSET != 12) /*--------------------------------------------------------------*/ /* IQ_Dummy */ /*--------------------------------------------------------------*/ @@ -330,6 +348,7 @@ { IQ_DummyCount++; } +#endif /*--------------------------------------------------------------*/ /* IQ_RTCHandler */ @@ -341,7 +360,7 @@ void IQ_Rtc_Handler(void) { -#if (!OP_L1_STANDALONE) +#if (OP_L1_STANDALONE == 0) RTC_ItTimerHandle(); #endif } @@ -357,7 +376,7 @@ #if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) void IQ_RtcA_Handler(void) { - #if (!OP_L1_STANDALONE) + #if (OP_L1_STANDALONE == 0) /* INTH_DISABLEONEIT(IQ_RTC_ALARM); *//* RTC ALARM IT */ if ( (* (SYS_WORD8 *) RTC_STATUS_REG) & RTC_ALARM ) RTC_ItAlarmHandle(); @@ -376,7 +395,7 @@ #else void IQ_RtcA_GsmTim_Handler(void) { - #if (!OP_L1_STANDALONE) + #if (OP_L1_STANDALONE == 0) if ( (* (SYS_UWORD16 *) ULDP_GSM_TIMER_IT_REG) & ULPD_IT_TIMER_GSM ) { // it is GSM Timer it..... @@ -392,6 +411,17 @@ } #endif +#if (BOARD == 34) +/* + * IQ_IcrHandler32 + * + */ + void IQ_IcrHandler32(void) + { + CSMI_InterruptHandler(); + } +#endif + /*--------------------------------------------------------------*/ /* IQ_TimerHandler */ /*--------------------------------------------------------------*/ @@ -420,7 +450,7 @@ IQ_FrameCount++; TMT_Timer_Interrupt(); TP_FrameIntHandler(); - #if (!OP_L1_STANDALONE) + #if (OP_L1_STANDALONE == 0) #if (TI_PROFILER == 1) // TDMA treatment for profiling buffer ti_profiler_tdma_action(); @@ -438,6 +468,9 @@ void IQ_TimerHandler1(void) { IQ_TimerCount1++; + #if (OP_L1_STANDALONE == 1) + TM_Timer1Handler(); + #endif } /*--------------------------------------------------------------*/ @@ -451,7 +484,23 @@ { IQ_TimerCount2++; } +#if(L1_DYN_DSP_DWNLD == 1) +/*-------------------------------------------------------*/ +/* IQ_ApiHandler() */ +/*-------------------------------------------------------*/ +/* Parameters : none */ +/* Return : none */ +/* Functionality : API int management */ +/*-------------------------------------------------------*/ +void IQ_ApiHandler(void) +{ + l1_api_handler(); +} /* IQ_ApiHandler() */ +#endif + + +#if (CHIPSET !=12) /*--------------------------------------------------------------*/ /* IQ_IRQ_isr */ /*--------------------------------------------------------------*/ @@ -474,11 +523,12 @@ /*--------------------------------------------------------------*/ void IQ_FIQ_isr(void) { - #if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) + #if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11)) fiqHandlers[((* (SYS_UWORD16 *) INTH_B_FIQ_REG) & INTH_SRC_NUM)](); /* ACK IT */ #endif * (SYS_UWORD16 *) INTH_CTRL_REG |= (1 << INTH_FIQ); /* valid next FIQ */ } +#endif /* chipset != 12 ) */ #if ((BOARD == 8) || (BOARD == 9) || (BOARD == 40) || (BOARD == 41)) @@ -489,109 +539,55 @@ /* Return : none */ /* Functionality : Handle keypad and GPIO interrupts */ /*--------------------------------------------------------------*/ +// CC test 0316 +//#include "rvm/rvm_use_id_list.h" +//#include "rvf/rvf_api.h" +//static char debug_buffer[50]; +// end + void IQ_KeypadGPIOHandler(void) { - #if (!OP_L1_STANDALONE) + + #if (OP_L1_STANDALONE == 0) /* * GPIO interrupt must be checked before the keypad interrupt. The GPIO * status bit is reset when the register is read. */ - g_interrupt = 80; - if (AI_CheckITSource (ARMIO_GPIO_INT)) { - #if 0 + if (AI_CheckITSource (ARMIO_GPIO_INT)) + +// CC test 0315 +{ + AI_MaskIT (ARMIO_MASKIT_GPIO); +//sprintf(debug_buffer, "GPIO_Interrupt"); +//rvf_send_trace(debug_buffer, 40, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVT_USE_ID); + AI_UnmaskIT(ARMIO_MASKIT_GPIO); //0x0002 +// end +/* #ifdef RVM_MPM_SWE - /* check if the SWE has been started */ - MPM_InterruptHandler (); + // check if the SWE has been started + MPM_InterruptHandler (); + #elif BT_CLK_REQ_INT + + BT_DRV_ClkReqInterruptHandler( ); #else UAF_DTRInterruptHandler (); #endif - #endif - /* Jeffrey, 02/26/04, add this line from 188 */ - gpio_handler(); - } +*/ +} + if (AI_CheckITSource (ARMIO_KEYPDAD_INT)) + { +// CC test 0316 +//sprintf(debug_buffer, "Key_Interrupt"); +//rvf_send_trace(debug_buffer, 40, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVT_USE_ID); +// end + kpd_key_handler (); + } - if (AI_CheckITSource (ARMIO_KEYPDAD_INT)) - kpd_key_handler (); #endif } -/** - * function: gpio_handler hall - */ -void gpio_handler(void) -{ - /* 2003/11/01 Robert.Chen for melody interrupt from GPIO1*/ - /* modify from */ - - /* - AI_MaskIT(2); - */ - - /* to */ - AI_MaskIT(2); - /* end Robert.Chen */ - - /* Activate HISR to process the key event */ - NU_Activate_HISR(&gpio_hisr_infos.hisr); - } - -/* 2003/11/01 Robert.Chen Melody HISR entry */ -void MI_Melody_Hisr(void) -{ - MaDevDrv_IntHandler(); - AI_UnmaskIT(0x02); -} - -/** - * function: kpd_initialize_keypad_hardware - */ -void Gpio_hisr_initialize(void) -{ - int i; - - /* 2003/11/01 Robert.Chen, modify for Melody HISR */ - /* modify from */ - #if 0 - /* HISR creation */ - NU_Create_HISR(&gpio_hisr_infos.hisr, - "GPIO_HISR", - gpio_hisr_entry, - 2, - gpio_hisr_infos.hisr_stack, - sizeof(gpio_hisr_infos.hisr_stack)); - - AI_UnmaskIT(0x02); - - i = HallOnOff(); - - if(i){ - AI_SelectIOForIT (2, 0);//ARMIO_FALLING_EDGE - } - else{ - - AI_SelectIOForIT (2, 1);//ARMIO_RISING_EDGE - } - #endif - /* to */ - NU_Create_HISR(&gpio_hisr_infos.hisr, - "GPIO_HISR", - MI_Melody_Hisr, - 2, - gpio_hisr_infos.hisr_stack, - sizeof(gpio_hisr_infos.hisr_stack)); - - AI_EnableBit(5); /* MCSI_TXD as GPIO9 */ - AI_ConfigBitAsInput(9); /* GPIO9 as input pin for YMU765 ~IRQ */ - AI_SelectIOForIT (9, 0); /* GPIO9 as input, falling edge triggered */ - AI_UnmaskIT(0x02); /* enable GPIO IRQ */ - - /* end modify, Robert.Chen */ -} -/* end of imported functins, Jeffrey, 02/26/04 */ -/* ---------------------------------------------*/ - -#elif ((BOARD == 43) || (BOARD == 45)) +#elif ((BOARD == 34) || (BOARD == 42) || (BOARD == 43) || (BOARD == 45)) /*--------------------------------------------------------------*/ /* IQ_KeypadHandler */ @@ -602,8 +598,12 @@ /*--------------------------------------------------------------*/ void IQ_KeypadHandler(void) { - #if (!OP_L1_STANDALONE) + #if (OP_L1_STANDALONE == 0) + #if (BOARD == 34) + IQ_Mask (IQ_ARMIO); + #else kpd_key_handler (); + #endif #endif }
--- a/nuc-fw/bsp/sim.h Sun Oct 20 07:58:00 2013 +0000 +++ b/nuc-fw/bsp/sim.h Sun Oct 20 08:43:41 2013 +0000 @@ -19,9 +19,12 @@ #include "../nucleus/nucleus.h" /* Flags activation section */ -/* #define SIM_RETRY by default : NOT ACTIVE */ -/* #define SIM_DEBUG_TRACE by default : NOT ACTIVE */ - +// #define SIM_RETRY /* by default : NOT ACTIVE */ +//#define SIM_DEBUG_TRACE /* by default : NOT ACTIVE */ +//#define SIM_UWORD16_MASK 0x00ff //when using SIM entity not maped to length on 16 bits +#define SIM_UWORD16_MASK 0xffff //when using SIM entity maped to length on 16 bits +//#define SIM_APDU_TEST +//#define SIM_SAT_REFRESH_TEST #define SIM_CMD (MEM_SIM + 0x00) #define SIM_STAT (MEM_SIM + 0x02) @@ -176,7 +179,7 @@ // so SIM drv is configured in 3V only with IOTA.and SYREN // When 1.8V Sim Card will be delivered and tested on IOTA and SYREN, then Sim driver will pass // to : #define SIM_TYPE SIM_TYPE_1_8_3V -#define SIM_TYPE SIM_TYPE_3V +#define SIM_TYPE SIM_TYPE_1_8_3V // MODIFY BY JENNIFER SIM_TYPE_3V #else #define SIM_TYPE SIM_TYPE_3_5V #endif @@ -268,9 +271,12 @@ // Buffer sizes -#define RSIMBUFSIZE 256 +#define RSIMBUFSIZE 270 #define RSIZESW1SW2 2 -#define XSIMBUFSIZE 256 +#define XSIMBUFSIZE 270 + + + // Structures typedef struct @@ -291,6 +297,14 @@ typedef struct { + SYS_UWORD8 Inverse; + SYS_UWORD8 AtrSize; + SYS_UWORD8 AtrData[MAX_ATR_SIZE]; +} SIM_CARD; + + +typedef struct +{ SIM_CONTROLLER *c; SYS_UWORD8 *xIn; // xmit input pointer SYS_UWORD8 *xOut; // xmit output pointer @@ -324,86 +338,106 @@ SYS_UWORD8 xbuf[XSIMBUFSIZE]; SYS_UWORD8 rSW12[RSIZESW1SW2]; //buffer to store SW1 and SW2 SYS_UWORD8 SWcount; //static counter - - void (*InsertFunc)(void); + void (*InsertFunc)(SIM_CARD *); void (*RemoveFunc)(void); + SYS_UWORD16 apdu_ans_length; } SIM_PORT; -typedef struct -{ - SYS_UWORD8 Inverse; - SYS_UWORD8 AtrSize; - SYS_UWORD8 AtrData[MAX_ATR_SIZE]; -} SIM_CARD; + + +void SIM_IntHandler(void); +#if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) + void SIM_CD_IntHandler(void); +#endif + + + /* * Prototypes */ -void SIM_IntHandler(void); -#if ((CHIPSET == 4) || (CHIPSET == 5) || (CHIPSET == 6) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 9) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12)) - void SIM_CD_IntHandler(void); -#endif +// obsolete function +void SIM_Init(void (Insert(SIM_CARD *cP)), void (Remove(void))); + +// initialization +void SIM_Initialize(void); +SYS_UWORD16 SIM_Register(void (Insert(SIM_CARD *cP)), void (Remove(void))); +SYS_UWORD16 SIM_Reset(SIM_CARD *cP); +SYS_UWORD16 SIM_Restart(SIM_CARD *cP); + +// file commands +SYS_UWORD16 SIM_Select(SYS_UWORD16 id, SYS_UWORD8 *dat, SYS_UWORD16 *size); +SYS_UWORD16 SIM_Status(SYS_UWORD8 *dat, SYS_UWORD16 *size); +SYS_UWORD16 SIM_ReadBinary(SYS_UWORD8 *dat, SYS_UWORD16 offset, SYS_UWORD16 len, SYS_UWORD16 *size); +SYS_UWORD16 SIM_UpdateBinary(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 offset, SYS_UWORD16 len, SYS_UWORD16 *size); +SYS_UWORD16 SIM_ReadRecord(SYS_UWORD8 *dat, SYS_UWORD8 mode, SYS_UWORD8 recNum, SYS_UWORD16 len, SYS_UWORD16 *size); +SYS_UWORD16 SIM_UpdateRecord(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 mode, SYS_UWORD8 recNum, SYS_UWORD16 len, SYS_UWORD16 *size); +SYS_UWORD16 SIM_Seek(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 mode, SYS_UWORD16 len, SYS_UWORD16 *size); +SYS_UWORD16 SIM_Increase(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 *size); + +// Authentication +SYS_UWORD16 SIM_VerifyCHV(SYS_UWORD8 *result, SYS_UWORD8 *chv, SYS_UWORD8 chvType, SYS_UWORD16 *size); +SYS_UWORD16 SIM_ChangeCHV(SYS_UWORD8 *result,SYS_UWORD8 *oldChv, SYS_UWORD8 *newChv, SYS_UWORD8 chvType, SYS_UWORD16 *size); +SYS_UWORD16 SIM_DisableCHV(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 *size); +SYS_UWORD16 SIM_EnableCHV(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 *size); +SYS_UWORD16 SIM_UnblockCHV(SYS_UWORD8 *result, SYS_UWORD8 *unblockChv, SYS_UWORD8 *newChv, SYS_UWORD8 chvType, SYS_UWORD16 *size); + +// managing +SYS_UWORD16 SIM_Invalidate(SYS_UWORD8 *rP, SYS_UWORD16 *size); +SYS_UWORD16 SIM_Rehabilitate(SYS_UWORD8 *rP, SYS_UWORD16 *size); +SYS_UWORD16 SIM_RunGSMAlgo(SYS_UWORD8 *result, SYS_UWORD8 *rand, SYS_UWORD16 *size); +SYS_UWORD16 SIM_GetResponse(SYS_UWORD8 *dat, SYS_UWORD16 len, SYS_UWORD16 *size); + +// STK +SYS_UWORD16 SIM_TerminalProfile(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 len, SYS_UWORD16 *rcvSize); +SYS_UWORD16 SIM_Fetch(SYS_UWORD8 *result, SYS_UWORD16 len, SYS_UWORD16 *rcvSize); +SYS_UWORD16 SIM_TerminalResponse(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 len, SYS_UWORD16 *rcvSize); +SYS_UWORD16 SIM_Envelope(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 len, SYS_UWORD16 *rcvSize); + +// power off +void SIM_PowerOff(void); + +// WIM +SYS_UWORD16 SIM_XchTPDU(SYS_UWORD8 *dat, SYS_UWORD16 trxLen, SYS_UWORD8 *result, + SYS_UWORD16 rcvLen, SYS_UWORD16 *rcvSize); + +void SIM_lock_cr17689(void); + + + +/* + * Internal Prototypes + */ void SIM_WriteBuffer(SIM_PORT *p, SYS_UWORD16 offset, SYS_UWORD16 n); -SYS_UWORD16 SIM_Command(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *rP, SYS_UWORD8 *lP); +SYS_UWORD16 SIM_Result(SIM_PORT *p, SYS_UWORD8 *rP, SYS_UWORD16 *lenP, SYS_UWORD8 offset); +SYS_UWORD16 SIM_Command(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *rP, SYS_UWORD16 *lP); +SYS_UWORD16 SIM_Command_Base(SIM_PORT *p, SYS_UWORD16 n, SYS_UWORD8 *dP, SYS_UWORD16 *lP); SYS_UWORD16 SIM_Dummy(void); void SIM_InitLog(void); -void SIM_Init(void (Insert(void)), void (Remove(void))); -void SIM_Initialize(void); -SYS_UWORD16 SIM_Register(void (Insert(void)), void (Remove(void))); -SYS_UWORD16 SIM_Reset(SIM_CARD *c); - -SYS_UWORD16 SIM_Select(SYS_UWORD16 id, SYS_UWORD8 *dat, SYS_UWORD8 *size); -SYS_UWORD16 SIM_Status(SYS_UWORD8 *dat, SYS_UWORD8 *size); -SYS_UWORD16 SIM_ReadBinary(SYS_UWORD8 *dat, SYS_UWORD16 offset, SYS_UWORD8 len, SYS_UWORD8 *size); -SYS_UWORD16 SIM_UpdateBinary(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD16 offset, SYS_UWORD8 len, SYS_UWORD8 *size); -SYS_UWORD16 SIM_ReadRecord(SYS_UWORD8 *dat, SYS_UWORD8 mode, SYS_UWORD8 recNum, SYS_UWORD8 len, SYS_UWORD8 *size); -SYS_UWORD16 SIM_UpdateRecord(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 mode, SYS_UWORD8 recNum, SYS_UWORD8 len, SYS_UWORD8 *size); -SYS_UWORD16 SIM_Seek(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 mode, SYS_UWORD8 len, SYS_UWORD8 *size); -SYS_UWORD16 SIM_Increase(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 *size); - -// Authentication -SYS_UWORD16 SIM_VerifyCHV(SYS_UWORD8 *result, SYS_UWORD8 *chv, SYS_UWORD8 chvType, SYS_UWORD8 *size); -SYS_UWORD16 SIM_ChangeCHV(SYS_UWORD8 *result,SYS_UWORD8 *oldChv, SYS_UWORD8 *newChv, SYS_UWORD8 chvType, SYS_UWORD8 *size); -SYS_UWORD16 SIM_DisableCHV(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 *size); -SYS_UWORD16 SIM_EnableCHV(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 *size); -SYS_UWORD16 SIM_UnblockCHV(SYS_UWORD8 *result, SYS_UWORD8 *unblockChv, SYS_UWORD8 *newChv, SYS_UWORD8 chvType, SYS_UWORD8 *size); - -SYS_UWORD16 SIM_Invalidate(SYS_UWORD8 *rP, SYS_UWORD8 *size); -SYS_UWORD16 SIM_Rehabilitate(SYS_UWORD8 *rP, SYS_UWORD8 *size); -SYS_UWORD16 SIM_RunGSMAlgo(SYS_UWORD8 *result, SYS_UWORD8 *rand, SYS_UWORD8 *size); -SYS_UWORD16 SIM_GetResponse(SYS_UWORD8 *dat, SYS_UWORD8 len, SYS_UWORD8 *size); - SYS_UWORD16 SIM_TxParityErrors(); - -SYS_UWORD16 SIM_TerminalProfile(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 len, SYS_UWORD8 *rcvSize); -SYS_UWORD16 SIM_Fetch(SYS_UWORD8 *result, SYS_UWORD8 len, SYS_UWORD8 *rcvSize); -SYS_UWORD16 SIM_TerminalResponse(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 len, SYS_UWORD8 *rcvSize); -SYS_UWORD16 SIM_Envelope(SYS_UWORD8 *result, SYS_UWORD8 *dat, SYS_UWORD8 len, SYS_UWORD8 *rcvSize); - - SYS_UWORD16 SIM_WaitReception(SIM_PORT *p); -void SIM_PowerOff(void); void SIM_Interpret_FileCharacteristics(SIM_PORT *p); SYS_UWORD16 SIM_PTSprocedure(SIM_CARD *cP, SIM_PORT *p); void SIM_WARMReset (SIM_PORT *p); void SIM_SleepMode_In(SYS_UWORD32 param); void SIM_SleepMode_Out(SIM_PORT *p); SYS_UWORD8 SIM_GetFileCharacteristics(SIM_PORT *p); -SYS_UWORD16 SIM_ATRdynamictreatement (SIM_PORT *p, SIM_CARD *c); +SYS_UWORD16 SIM_ATRdynamictreatement (SIM_PORT *p, SIM_CARD *cP); SYS_UWORD16 SIM_Waitforchars (SIM_PORT *p, SYS_UWORD16 max_wait); void SIM_Calcetu (SIM_PORT *p); SYS_UWORD8 SIM_Translate_atr_char (SYS_UWORD8 input, SIM_CARD *cP); -SYS_UWORD8 SIM_StartVolt (void); -SYS_UWORD8 SIM_SwitchVolt (void); +SYS_UWORD8 SIM_StartVolt (SYS_UWORD8 ResetFlag); +SYS_UWORD8 SIM_SwitchVolt (SYS_UWORD8 ResetFlag); SYS_UWORD16 SIM_ManualStart (SIM_PORT *p); -SYS_UWORD8 SIM_Memcpy(SYS_UWORD8 *Buff_target, SYS_UWORD8 Buff_source[], SYS_UWORD8 len); +SYS_UWORD8 SIM_Memcpy(SYS_UWORD8 *Buff_target, SYS_UWORD8 Buff_source[], SYS_UWORD16 len); SYS_BOOL SIM_SleepStatus(void); +SYS_UWORD16 SIM_Reset_Restart_Internal(SIM_CARD *cP, SYS_UWORD8 ResetFlag); /* * Global variables @@ -419,4 +453,3 @@ SI_GLOBAL NU_TIMER SIM_timer; SI_GLOBAL STATUS status_os_sim; SI_GLOBAL SYS_UWORD8 SIM_sleep_status; -