亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? psgdrv.c

?? SIM卡的驅動程序,有利于開發一些與SIM相通的一些工具,或者手機軟件SIM驅動的開發
?? C
?? 第 1 頁 / 共 5 頁
字號:
  PSInc,
  PSTPrf,
  PSEnv,
  PSFtch,
  PSTRsp,
  PSBad
  } XXXX;



/*---------------------------- Special Globals: --------------------------*/
extern CHAR SIMBuffer[257]; 
extern UINT16 GetAPDULength(UINT8 paramP3);
extern void SIResetSupplyVoltageIndicator(void);
UINT8 CCPAR0;
UINT8 CCPAR1;
UINT8 CCPAR2;
UINT8 CCRBR;
UINT8 CCTBR;
UINT8 CCINT;

PS_COMMAND PSCommandBuffer;        /* Interface buffer for SIM Command */
PS_STATUS  PSStatusBuffer;         /* Interface buffer to return SIM status */
UINT8      *PSDataBuffer;          /* Pointer to buffer for data to be
                                      transferred to or from the SIM */
BOOLEAN    DMABufferHasData;
void       (*PSIntAction)(void);   /* Current SIM action for a successful
                                      byte transfer */
void       (*PSErrAction)(void);   /* Current SIM action for a erroneous
                                      byte transfer.  Note assumes that
                                      normally byte will be automatically
                                      repeated under HW control! */
UINT16  PSRemainingWorkTime;        /* Remaining polling periods before
                                      timeout waiting for SIM to respond */
UINT16  PSWorkWaitingTime;          /* Value of the work waiting time in
                                      polling periods */

BOOL PSRxDMAEnabled =FALSE;  /* To keep track if whem SIM receive DMA is active */

                                      
INT16  PSTransferRemainingRetries; /* Count of remaining errouneous byte
                                      transfers before driver should give up
                                      trying to talk to SIM */

// This is to keep track of the current PTS state
PS_PTS_STATE currentPTSState = PTS_NOT_STARTED;

// This flag is used to keep track of Enhanced Clocking Mode retry attempts
PS_ENH_RETRY_STATE enhancedModeRetryState = PS_ENH_RETRY_INITIALIZED;

// GUARD PERIOD value used for Tx
UINT32 PSGuardPeriod = PS_DEFAULT_GUARD_PERIOD;

UINT8 *SIMbuffPtr;
SIM_DMA_CONFIG_STRUCT *SIMConfigDataPtr;
SIM_DMA_CONFIG_STRUCT SIMConfigData;

#if SIM_DEBUG == SIM_DEBUG_MAX
BOOL HighSpeedClockEnabled_Dbg = FALSE;
BOOL DisableClockHigh_Dbg = FALSE;
PS_ACTION_DBG OldIntAction_Dbg = _NotAssignedYet;
PS_ACTION_DBG NewIntAction_Dbg = _NotAssignedYet;
PS_ACTION_DBG OldErrAction_Dbg = _NotAssignedYet;
PS_ACTION_DBG NewErrAction_Dbg = _NotAssignedYet;
PS_IH_DBG IntHandler_Dbg = _SimResetTimerAIH;
UINT8 DefectSIMScenario_Dbg = 0;
UINT8 PSStateScenario_Dbg = 0;
PS_STATE OldPSState_Dbg = PSNoMess;
UINT8 PSDeactivateSIM_Dbg = 0;
PS_COMPLETION_CODE PSCompletionCode_Dbg = PSNormalCompletion;
#elif SIM_DEBUG == SIM_DEBUG_MIN
UINT8 DefectSIMScenario_Dbg = 0;
PS_STATE OldPSState_Dbg = PSNoMess;
#endif

SIM_CLOCK_SPEED PSClockSpeed;       // Flag that indicates the clock speed of SIM.

/*----------------------- Local Function Prototypes: ---------------------*/

void DeadLoop( void );                     // PMIC access error, stop
static void PSStartSIMResetSequence(void);
static void PSNullCompleter(PS_COMPLETION_CODE CompletionCode);
static void PSCommandCompleter(PS_COMPLETION_CODE CompletionCode);
static void PSStartCommandCompleter(PS_COMPLETION_CODE CompletionCode);
static void PSStartResetCompleter(PS_COMPLETION_CODE CompletionCode);
static void PSResetLoCompleter(PS_COMPLETION_CODE CompletionCode);
static void PSResetHiCompleter(PS_COMPLETION_CODE CompletionCode);
static void PSPTSCompleter(PS_COMPLETION_CODE CompletionCode);
static void PSIdleCompleter(PS_COMPLETION_CODE CompletionCode);
//added by gary for phase 2
#if PS_CLOCK_START_DELAY>0
static void PSResetStartClockCompleter( PS_COMPLETION_CODE CompletionCode );
#endif
//end of added by gary for phase 2

#ifdef PSDisableClockHigh
static void PSStopClockHighCompleter(PS_COMPLETION_CODE CompletionCode);
#endif
#ifdef PSDisableClockLow
static void PSStopClockLowCompleter(PS_COMPLETION_CODE CompletionCode);
#endif

static void PSIdle(void);
void PSSendINS(void);
static void PSSendP1(void);
static void PSSendP2(void);
static void PSSendP3(void);
static void PSTXOneByte(void);
static void PSWaitProcByte(void);
static void PSRXOneByte(void);
static void PSRXData(void);
static void PSTXData(void);
static void PSWaitStatus(void);
static void PSWaitStatusByteByByte(void);
static void PSWaitSW2(void);
static void PSInitChar(void);
static void PST0Char(void);
static void PSTABCiChar(void);
static void PSTDiChar(void);
static void PSHistChar(void);
static void PSWaitTCK(void);
static void PSSendPTS0(void);
static void PSSendPTS1(void);
static void PSSendPCK(void);
static void PSSendPTSDone(void);
static void PSWaitPTSSAck(void);
static void PSWaitPTS0Ack(void);
static void PSWaitPTS1Ack(void);
static void PSWaitPCKAck(void);
static void PSParityErr(void);
static void EnableDMAWaitStatus(void); 
static void ClampVSIM(BOOL state);
static void PSSetSIMVoltage(UINT8 simvcc);
static void PSSetGuardPeriod( UINT32 period );

/*---------------------------- Local Statics: ----------------------------*/

/* The C166 locator renders the whole stack unusable, if this variable
   isn't defined as "far" */

static UINT16 PSInitRemainingRetries;  /* Count of remaining errouneous byte
                                          transfers before driver should give
                                          up waiting for an initial character
                                          on ATR */

//end of added by gary for phase 2

static const PS_STATE CompletionCodeToState[7] =
                   { PSSIM, PSSIM, PSSIM, PSNoSIM, PSDefectSIM, PSDefectSIM, PSDefectSIM };
              /* Look up table to map SIM completion codes to the SIM State */
static void (*PSCompleter)(PS_COMPLETION_CODE CompletionCode) = PSNullCompleter;
                                      /* Pointer to current completer routine */
#if SIM_DEBUG == SIM_DEBUG_NONE
static PS_COMPLETION_CODE PSCompletionCode;  /* Completion code of current SIM operation */
#else
PS_COMPLETION_CODE PSCompletionCode;  /* Completion code of current SIM operation */
#endif
INT16 PSDataCount;                /* Count of remaining Data Bytes to be
                                         transferred */
static UINT16 PSCardProtocols;        /* Bit map of Protocols supported by
                                         SIM */
static INT16 PSResetRemainingRetries; /* Count of remaining retries to
                                         Reset SIM */
static UINT8 PSTByteMask;             /* Bit map mask for Protocol types
                                         supported by SIM */
static UINT8 PSTByteFlags;            /* Flags for the protocol characters
                                         received from SIM during answer to
                                         reset.  Determines which characters
                                         will be transmitted */
static UINT8 PSNoHistChars;           /* Number of Historical Characters
                                         to expect during answer to reset */
static UINT8 PSCurrProtType;          /* Current Protocol Type that SIM
                                         claims to support during answer
                                         to reset */
static UINT8 PSTi;                    /* Counter for currently expected
                                         interface character during answer to
                                         reset */
static UINT8 PSCheckSum;              /* Current checksum of bytes received
                                         during answer to reset */
static UINT8 PSDirection;             /* Direction of data transfer of current
                                         SIM command */
static UINT8 *PSTBytePtr;             /* Pointer into PSIFChars array to where
                                         current IF char should be stored */
static UINT8 PSIFChars[6];            /* Array to store the Interface
                                         characters useful to the GSM
                                         application that have been received
                                         during the answer to reset */
static BOOLEAN PSFoundInitChar;       /* Flag to indicate SIM has started
                                         answering the reset */
static BOOLEAN PSEverFoundInitChar;   /* Flag to indicate the SIM started
                                         answering the reset in some reset
                                         attempt */
// Also used by psintrpt.c
BOOLEAN PSClockStopped;               /* Flag to indicate that the SIM driver
                                         has stopped the SIM clock */
static BOOLEAN PSSocketClosed;        /* Flag to determine if the SIM Socket
                                         os closed or not */
static PS_STATE PSState;              /* The current State of the SIM driver */

static UINT8 PSCommandRetryCount=0;            /* Retry Counter for incompleted SIM commanad
                                                  will be set to PS_COMMAND_RETRY_COUNT.
                                                  Must initialy be zero in order to pass FTA 27.17.1.5.1*/

static const UINT8 UniqueLookUp[128] =
   {
/*          X0      X2      X4      X6      X8      XA      XC     XE   */
/* 0X */  PSBad,  PSBad,  PSInv,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* 1X */ PSTPrf, PSFtch, PSTRsp,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* 2X */  PSVer,  PSBad,  PSChg,  PSDis,  PSEna,  PSBad, PSUnbl,  PSBad,
/* 3X */  PSBad,  PSInc,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* 4X */  PSBad,  PSBad,  PSReH,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* 5X */  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* 6X */  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* 7X */  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* 8X */  PSBad,  PSBad,  PSBad,  PSBad,  PSRun,  PSBad,  PSBad,  PSBad,
/* 9X */  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* AX */  PSBad, PSSeek,  PSSel,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* BX */ PSRBin, PSRRec,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* CX */ PSGRes,  PSEnv,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* DX */  PSBad,  PSBad,  PSBad, PSWBin,  PSBad,  PSBad, PSWRec,  PSBad,
/* EX */  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,  PSBad,
/* FX */  PSBad,  PSSta,  PSBad,  PSBad,  PSBad,  PSSlp,  PSBad,  PSBad
   };

static BOOLEAN PSBadSIMStatus;       /* Flag to indicate bad SIM status */

/*---------------------------- Local Functions: --------------------------*/


/*---------------------------- Utility Functions: --------------------------

The PS Driver Utility functions are static helper functions used by the
SIM driver code
*/

//***************************************************************************
//
// Name:    PSSetClockSpeed
// Desc:    Helper function to set up the SIM block clock speed based on the 
//        	parameter specified in pubparam.c
// Params:  None
// Returns: None
// Caveats:
//***************************************************************************
void  PSSetClockSpeed()
{
	switch (PSClockSpeed)
	{
		case SIM_CLOCK_3_9Mhz :
			*(UINT16 *)SIM_CTRL_HI_REG &= ~(SIM_CLK_DIV);
#if SIM_DEBUG == SIM_DEBUG_MAX
			HighSpeedClockEnabled_Dbg = TRUE;
#endif  
			break;

		case SIM_CLOCK_1_95Mhz :
		default:				// errror case, set to 1.95Mhz and let it run
			*(UINT16 *)SIM_CTRL_HI_REG |= SIM_CLK_DIV ;
#if SIM_DEBUG == SIM_DEBUG_MAX
			HighSpeedClockEnabled_Dbg = FALSE;
#endif  
			break;
	}
}


/*------------------------------------------------------------------------*/

/*
Name:    PSAcceptSIM
Desc:    Helper function to set up the SIM driver state following acceptance
         of a valid SIM.  Having accepted the SIM the SIM driver can accept
         and process SIM Commands.
Params:  None
Returns: Nothing
Caveats:
*/

static void PSAcceptSIM(void)
   {
   PSCompleter = PSIdleCompleter;
   PSState = PSSIM;
#if SIM_DEBUG == SIM_DEBUG_MAX
   PSStateScenario_Dbg = 1;
#endif
   }

/*------------------------------------------------------------------------*/

/*
Name:    PSDeactivateSIM
Desc:    Helper function to return the SIM driver to the idle state following
         removal of the SIM, detection of an invalid SIM, or simply as part
         of the power down deactivation sequence.
Params:  PS_STATE SIMState - The new SIM driver state.
Returns: Nothing
Caveats:
*/

static void PSDeactivateSIM(PS_STATE SIMState)
   {

   //PSChangeIdleToDeact();
   PSDoShutDown();
   PSIntAction = PSIdle;
   PSErrAction = PSIdle;
   PSCompleter = PSIdleCompleter;
//changed by gary for phase 2
#if PS_CLOCK_START_DELAY>0
   PSRemainingWorkTime = PS_CLOCK_START_DELAY;
   PSCompletionCode = PSBusy;
#else
   PSCompletionCode = PSNormalCompletion;
#endif
//end of changed by gary for phase 2
   PSState = SIMState;
#if SIM_DEBUG == SIM_DEBUG_MAX
   PSStateScenario_Dbg = 2;
#endif

#if SIM_DEBUG == SIM_DEBUG_MAX
   //PS Debug...
   OldIntAction_Dbg = NewIntAction_Dbg;
   NewIntAction_Dbg	= _PSIdle;
   OldErrAction_Dbg	= NewErrAction_Dbg;
   NewErrAction_Dbg	= _PSIdle;
   //End PS Debug
#endif
   }

/*------------------------------------------------------------------------*/

/*
Name:    PSDoPTSIfNecessary(void)
Desc:    Routine to check the results of the 'answer to reset', and determine
         if the Protocol Type Selection procedure needs to be performed.
         As a result of performing the analysis of the answer to reset, the
         SIM driver may reject the SIM.  Reasons for rejecting a SIM are
         specified in GSM rec. 11.10.
         The Routine also sets the value of PSWorkWaitingTime, which is used
         as a timeout value for SIM responses.
Params:  None
Returns:
Caveats: This code is specific to GSM SIMs!
*/

static void PSDoPTSIfNecessary(void)
   {
   /* Set up WorkWaitingTime */
   if (PSIFChars[5]==0) 
      PSIFChars[5] = PS_DEFAULT_WI;
   PSWorkWaitingTime = MSECS(PSIFChars[5]*PS_WORK_WAIT_FACTOR);


   if (((PSIFChars[1]&0x1F)!=0&&(PSIFChars[1]&0x1F)!=5)||PSIFChars[4]!=50)
      /* The card required non-standard programming voltages */
      {
      PSStartSIMResetSequence();   
      //      PSDeactivateSIM(PSDefectSIM);
      }
   else if (PSIFChars[2]!=0&&PSIFChars[2]!=255) /* TC1 not valid */
      {
      PSStartSIMResetSequence();   
      // PSDeactivateSIM(PSDefectSIM);
      }
   else if ((PSCardProtocols&1)==0) /* The card does not support T=0 */
      {
      PSStartSIMResetSequence();   
      //PSDeactivateSIM(PSDefectSIM);
      }
   else if ((PSCardProtocols>1|| /* The card supports protocols other than T=0 */
//            Need to also check if TA1 != 0x01
//            PSIFChars[0]!=0x11||
            ((PSIFChars[0]!=0x11)&&(PSIFChars[0]!=0x01))||
            PSIFChars[2]==255) && (currentPTSState != PTS_DEFAULT_RETRY_STARTED))
      {                         /* Must perform protocol type selection */
      // This makes the ME initiate PPS procedure using default values
      // after two failed PPS attempts.
      // Originally, this variable is for three consecutive wrong ATRs
      PSResetRemainingRetries = PS_RESET_ALLOWED_RETRIES;
      PSChangeIdletoTX();
      PSSend(0xFF);
      PSCompletionCode = PSBusy;
      PSCompleter = PSPTSCompleter;
      PSIntAction = PSSendPTS0;
   
 //   Move to the next PTS state
      if (PSIFChars[0] == 0x94)
         (UINT8)currentPTSState++;  

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品一区二区蜜臀亚洲| 久久精品亚洲精品国产欧美kt∨| 中文字幕在线观看不卡视频| 成人午夜伦理影院| 欧美国产精品v| 成人黄色软件下载| 一区二区三区.www| 欧美一区二区三区在线电影| 久久不见久久见免费视频1| 26uuu色噜噜精品一区二区| 国产成a人亚洲| 亚洲免费av在线| 69精品人人人人| 激情综合网最新| 亚洲青青青在线视频| 欧美三区在线观看| 国产原创一区二区| 国产精品二三区| 制服丝袜亚洲网站| 成人免费毛片嘿嘿连载视频| 一二三区精品视频| 日韩视频一区二区在线观看| 国产成都精品91一区二区三| 亚洲自拍另类综合| 久久综合九色综合欧美98| 99精品久久久久久| 蜜桃久久久久久| 中文字幕在线一区| 7777精品伊人久久久大香线蕉的| 国产精品1区2区3区| 夜夜嗨av一区二区三区中文字幕| 91精品国产综合久久香蕉麻豆| 国产精品一区在线| 偷拍日韩校园综合在线| 国产日韩精品一区二区三区| 欧美性做爰猛烈叫床潮| 国产成人在线视频网址| 亚洲国产成人高清精品| 国产精品你懂的| 日韩亚洲国产中文字幕欧美| 色哟哟在线观看一区二区三区| 久久99久久99精品免视看婷婷| 国产精品成人网| 精品乱码亚洲一区二区不卡| 在线亚洲+欧美+日本专区| 国产成人免费9x9x人网站视频| 亚洲成a人片综合在线| 国产精品每日更新在线播放网址| 欧美一区二区精美| 欧美三级欧美一级| 91影院在线观看| 国产成人精品免费| 久久精品国产秦先生| 亚洲成人一区二区在线观看| 中文字幕一区日韩精品欧美| 久久午夜老司机| 欧美一区在线视频| 欧美亚洲一区二区在线观看| 波多野结衣精品在线| 国产真实精品久久二三区| 亚洲不卡在线观看| 亚洲国产视频网站| 亚洲日本乱码在线观看| 亚洲国产精品激情在线观看| 久久综合狠狠综合| 日韩精品一区二区在线| 日韩亚洲欧美中文三级| 在线观看91精品国产麻豆| 欧美中文字幕一区二区三区| 91免费视频网址| 99视频在线精品| 99久久精品国产导航| 99视频精品全部免费在线| 成人免费看的视频| 成人v精品蜜桃久久一区| 国产成人免费在线视频| 国产精品一二二区| 国产成人免费在线观看不卡| 高清免费成人av| 国产不卡视频在线播放| 国产成人精品aa毛片| 国产.精品.日韩.另类.中文.在线.播放| 激情深爱一区二区| 国产精品羞羞答答xxdd| 成人激情免费电影网址| 99免费精品视频| 色乱码一区二区三区88| 欧美性色黄大片手机版| 欧美精品1区2区| 精品嫩草影院久久| 中文幕一区二区三区久久蜜桃| 国产精品白丝在线| 亚洲综合在线视频| 日韩激情一区二区| 久久国产生活片100| 国产精品一区2区| 99久久精品免费精品国产| 日本精品裸体写真集在线观看| 欧美日韩亚洲综合在线 | 日韩精品在线一区| 自拍偷自拍亚洲精品播放| 国产精品久久久久久福利一牛影视| 亚洲欧美综合网| 亚洲成人精品一区二区| 精品无人码麻豆乱码1区2区| 成人午夜看片网址| 欧美日韩在线播放| 久久嫩草精品久久久久| 亚洲欧美日本在线| 奇米亚洲午夜久久精品| 国产91丝袜在线播放九色| 色综合久久中文字幕综合网 | 日本女人一区二区三区| 国产一区二区日韩精品| 91麻豆自制传媒国产之光| 在线不卡一区二区| 国产精品美女久久久久久久久| 亚洲超碰97人人做人人爱| 国产高清精品在线| 欧美性色aⅴ视频一区日韩精品| www欧美成人18+| 亚洲一区二区三区小说| 国产成人午夜精品5599 | 欧美一区二区三区四区久久| 国产日韩欧美a| 日日嗨av一区二区三区四区| 国产成人精品一区二| 91精品婷婷国产综合久久| 欧美经典一区二区| 日产国产欧美视频一区精品| 91一区在线观看| 亚洲精品一线二线三线无人区| 亚洲精品伦理在线| 国产大陆a不卡| 日韩你懂的在线播放| 一区二区日韩av| 不卡的av在线| 精品成人a区在线观看| 亚洲va欧美va人人爽| 91色视频在线| 中文字幕av一区二区三区免费看| 久久国产麻豆精品| 欧美人与禽zozo性伦| 亚洲欧美日本韩国| 成人性生交大片免费看中文网站 | 久久亚洲捆绑美女| 青青草国产精品97视觉盛宴| 欧美中文字幕一区二区三区 | 亚洲一区日韩精品中文字幕| 国产精品羞羞答答xxdd| 337p日本欧洲亚洲大胆精品| 天天做天天摸天天爽国产一区| 97aⅴ精品视频一二三区| 久久久久9999亚洲精品| 久久aⅴ国产欧美74aaa| 欧美伦理视频网站| 亚洲高清视频的网址| 91久久精品一区二区三| 亚洲麻豆国产自偷在线| 99r国产精品| 国产精品你懂的在线| 成人午夜精品在线| 中文字幕不卡在线播放| 国产成人精品网址| 久久精品夜色噜噜亚洲a∨| 国产一级精品在线| 久久综合丝袜日本网| 国产酒店精品激情| 久久综合成人精品亚洲另类欧美| 狠狠色狠狠色综合| 久久精品欧美日韩精品| 国产精品1024| 中文字幕乱码亚洲精品一区| 成人av免费在线观看| 国产精品动漫网站| 91女厕偷拍女厕偷拍高清| 亚洲欧美国产毛片在线| 在线观看不卡一区| 丝袜诱惑制服诱惑色一区在线观看| 久久人人超碰精品| 精品一区二区三区视频| 国产午夜精品美女毛片视频| aa级大片欧美| 亚洲小说春色综合另类电影| 91精品国产综合久久小美女| 久久精品国产网站| 久久精品人人做人人综合| 成人精品小蝌蚪| 一区二区三区日本| 欧美一级在线观看| 国产精品小仙女| 亚洲毛片av在线| 日韩午夜激情av| 国产v综合v亚洲欧| 亚洲色图制服诱惑| 91精品国产色综合久久不卡蜜臀| 国产一区视频导航| 亚洲另类在线制服丝袜| 欧美一区二区福利视频| 成人听书哪个软件好|