📄 sci_osi.c
字号:
/*-----------------------------------------------------------------------------+| This source code has been made available to you by IBM on an AS-IS| basis. Anyone receiving this source is licensed under IBM| copyrights to use it in any way he or she deems fit, including| copying it, modifying it, compiling it, and redistributing it either| with or without modifications. No license under IBM patents or| patent applications is to be implied by the copyright license.|| Any user of this software should understand that IBM cannot provide| technical support for this software and will not be responsible for| any consequences resulting from the use of this software.|| Any person who transfers this source code or any derivative work| must include the IBM copyright notice, this paragraph, and the| preceding two paragraphs in the transferred software.|| COPYRIGHT I B M CORPORATION 2001| LICENSED MATERIAL - PROGRAM PROPERTY OF I B M+-----------------------------------------------------------------------------*//*-----------------------------------------------------------------------------+| Author: Mike Lepore, Zongwei Liu| Component: sci| File: sci_osi.c| Purpose: The OS-independency functions of Smart Card Interface| Changes:|| Date: Author Comment:| ---------- ---------------- -----------------------------------------------| 03/22/2001 MAL Initial check-in.| 03/26/2001 Zongwei Liu Port to Linux| 09/26/2001 Zongwei Liu Port to pallas| 10/10/2001 Zongwei Liu Port to OS-Adaption layer| 12/13/2001 MAL, Zongwei Liu Move init, uninit, reset, read, write and irq| handler to the OS-dependent layer.| Merge sci_osi.c and sci_osi_local.c.| 12/13/2001 MAL, Zongwei Liu Added EMV2000 support and made several changes| to improve PIO efficiency.| 04/25/2003 Detrick, Mark Changed sci_osi_set_modes to print a message| instead of returning an error when DMA mode| (which is not supported) is requested.+----------------------------------------------------------------------------*/#include "os/os-types.h"#include "os/os-sync.h"#include "hw/hardware.h"#include "sci_osi.h"#include "sci_atom.h"#include "os/drv_debug.h"extern SCI_CONTROL_BLOCK sci_cb[SCI_NUMBER_OF_CONTROLLERS];extern ULONG sci_driver_init;extern SCI_DRV_MODES sci_drv_modes;/* Local function calls for set parameters */SCI_ERROR sci_osi_set_para_T (ULONG sci_id, SCI_PARAMETERS *p_sci_parameters);SCI_ERROR sci_osi_set_para_f (ULONG sci_id, SCI_PARAMETERS *p_sci_parameters);SCI_ERROR sci_osi_set_para_ETU (ULONG sci_id, SCI_PARAMETERS *p_sci_parameters);SCI_ERROR sci_osi_set_para_WWT (ULONG sci_id, SCI_PARAMETERS *p_sci_parameters);SCI_ERROR sci_osi_set_para_CWT (ULONG sci_id, SCI_PARAMETERS *p_sci_parameters);SCI_ERROR sci_osi_set_para_BWT (ULONG sci_id, SCI_PARAMETERS *p_sci_parameters);SCI_ERROR sci_osi_set_para_EGT (ULONG sci_id, SCI_PARAMETERS *p_sci_parameters);SCI_ERROR sci_osi_set_para_CLK_p (ULONG sci_id, SCI_PARAMETERS *p_sci_parameters);SCI_ERROR sci_osi_set_para_check (ULONG sci_id, SCI_PARAMETERS *p_sci_parameters);SCI_ERROR sci_osi_set_para_class (ULONG sci_id, SCI_PARAMETERS *p_sci_parameters);/******************************************************************************* Function: sci_osi_clock_stop**** Purpose: Stop the SCI/Smart Card clock at a given polarity.**** Parameters: sci_id: zero-based number to identify smart card controller**** Returns: SCI_ERROR_OK: if successful** SCI_ERROR_DRIVER_NOT_INITIALIZED: if no successful call to** sci_init() has been made** SCI_ERROR_PARAMETER_OUT_OF_RANGE: if sci_id is invalid** SCI_ERROR_CARD_NOT_ACTIVATED: if card is not activated** SCI_ERROR_CLOCK_STOP_DISABLED: if clock stop is disabled*****************************************************************************/SCI_ERROR sci_osi_clock_stop(ULONG sci_id){ SCI_ERROR rc = SCI_ERROR_OK; PDEBUG("card[%d] enter\n", (UINT) sci_id); if(sci_driver_init == 1) { if(sci_id < SCI_NUMBER_OF_CONTROLLERS) { if(sci_osi_is_card_activated(sci_id) == 1) { /* check for clock stop enabled */ if(sci_cb[sci_id].sci_parameters.clock_stop_polarity != SCI_CLOCK_STOP_DISABLED) { sci_atom_clock_stop(sci_id); } else { rc = SCI_ERROR_CLOCK_STOP_DISABLED; } } else { rc = SCI_ERROR_CARD_NOT_ACTIVATED; } } else { rc = SCI_ERROR_PARAMETER_OUT_OF_RANGE; } } else { rc = SCI_ERROR_DRIVER_NOT_INITIALIZED; } if(rc != SCI_ERROR_OK) { PDEBUG("card[%d] error=%d\n", (UINT) sci_id, rc); } PDEBUG("card[%d] exit\n", (UINT) sci_id); return(rc);}/******************************************************************************* Function: sci_osi_clock_start**** Purpose: Start the SCI/Smart Card clock.**** Parameters: sci_id: zero-based number to identify smart card controller**** Returns: SCI_ERROR_OK: if successful** SCI_ERROR_DRIVER_NOT_INITIALIZED: if no successful call to** sci_init() has been made** SCI_ERROR_PARAMETER_OUT_OF_RANGE: if sci_id is invalid** SCI_ERROR_CARD_NOT_ACTIVATED: if card is not activated*****************************************************************************/SCI_ERROR sci_osi_clock_start(unsigned long sci_id){ SCI_ERROR rc = SCI_ERROR_OK; PDEBUG("card[%d] enter\n", (UINT) sci_id); if(sci_driver_init == 1) { if(sci_id < SCI_NUMBER_OF_CONTROLLERS) { if(sci_osi_is_card_activated(sci_id) == 1) { /* start the clock */ sci_atom_clock_start(sci_id); } else { rc = SCI_ERROR_CARD_NOT_ACTIVATED; } } else { rc = SCI_ERROR_PARAMETER_OUT_OF_RANGE; } } else { rc = SCI_ERROR_DRIVER_NOT_INITIALIZED; } if(rc != SCI_ERROR_OK) { PDEBUG("card[%d] error=%d\n", (UINT) sci_id, rc); } PDEBUG("card[%d] exit\n", (UINT) sci_id); return(rc);}/****************************************************************************** Name: sci_osi_is_card_activated**** Purpose: This determines if the SCI/Smart Card is activated.**** Parameters: sci_id: zero-based number to identify smart card controller**** Returns: 0: card is not present** 1: card is present** SCI_ERROR_DRIVER_NOT_INITIALIZED: if no successful call to** sci_init() has been made****************************************************************************/SCI_ERROR sci_osi_is_card_activated (ULONG sci_id){ SCI_ERROR rc = 0; PDEBUG("card[%d] enter\n", (UINT) sci_id); if(sci_driver_init == 1) { /* check both the driver state and the h/w state (VCC) */ if((sci_cb[sci_id].state == SCI_STATE_RX) || (sci_cb[sci_id].state == SCI_STATE_TX)) { /* driver is in activated state, now check h/w */ if((rc = sci_atom_is_HW_activated(sci_id)) == 0) { /* h/w is not activated for some reason- */ /* deactivate to get driver and h/w "in sync" */ rc = SCI_ERROR_CARD_NOT_ACTIVATED; } } } else { rc = SCI_ERROR_DRIVER_NOT_INITIALIZED; } PDEBUG("card[%d] exit:returns %d\n", (UINT) sci_id, rc); return(rc);}/****************************************************************************** Name: sci_osi_is_card_present**** Purpose: Determine if a card is present in the reader.**** Parameters: sci_id: zero-based number to identify smart card controller**** Returns: 0: card is not present** 1: card is present** SCI_ERROR_DRIVER_NOT_INITIALIZED: if no successful call to** sci_init() has been made****************************************************************************/SCI_ERROR sci_osi_is_card_present(ULONG sci_id){ SCI_ERROR rc; PDEBUG("card[%d] enter\n", (UINT) sci_id); if(sci_driver_init == 1) { rc = sci_atom_is_card_present(sci_id); } else { rc = SCI_ERROR_DRIVER_NOT_INITIALIZED; } PDEBUG("card[%d] exit:returns %d\n", (UINT) sci_id, rc); return(rc);}/******************************************************************************* Function: sci_osi_set_modes**** Purpose: Set the current Smart Card driver modes.**** Parameters: sci_id: zero-based number to identify smart card controller** p_sci_modes: input pointer to Smart Card modes**** Returns: SCI_ERROR_OK: if successful** SCI_ERROR_DRIVER_NOT_INITIALIZED: if no successful call to** sci_init() has been made** SCI_ERROR_PARAMETER_OUT_OF_RANGE: if sci_id is invalid or** p_sci_modes is zero.*****************************************************************************/SCI_ERROR sci_osi_set_modes(ULONG sci_id, SCI_MODES *p_sci_modes){ SCI_ERROR rc = SCI_ERROR_OK; PDEBUG("card[%d] enter\n", (UINT) sci_id); if(sci_driver_init == 1) { if((p_sci_modes != 0) && (sci_id < SCI_NUMBER_OF_CONTROLLERS)) { if((p_sci_modes->emv2000 == 0) || (p_sci_modes->emv2000 == 1)) { if((p_sci_modes->emv2000 == 1) && (sci_drv_modes.emv_supported == 0)) { sci_cb[sci_id].sci_modes.emv2000 = 0; rc = SCI_ERROR_PARAMETER_OUT_OF_RANGE; } else { sci_cb[sci_id].sci_modes.emv2000 = p_sci_modes->emv2000; } } else { rc = SCI_ERROR_PARAMETER_OUT_OF_RANGE; } if((p_sci_modes->dma == 0) || (p_sci_modes->dma == 1)) { /*sci_cb[sci_id].sci_modes.dma = p_sci_modes->dma;*/ /* not yet supported */ if(p_sci_modes->dma == 1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -