⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sci_atom.c

📁 IBM source for pallas/vulcan/vesta
💻 C
📖 第 1 页 / 共 3 页
字号:
            {                /* data must be flushed to OPB wall before reading */                _OS_OUTB(sci_cb[sci_id].scctl1,                    (_OS_INB(sci_cb[sci_id].scctl1) | FLUSH));                /* wait for flush to complete - 1 OPB clock cycle */                while(((_OS_INB(sci_cb[sci_id].scctl1) & 0x02) == 0x02) &&                      (_check_bits(sci_id, SCCTL3, POLDET) ==                       _check_bits(sci_id, SCSTAT, DET)));            }            /* read 1 word from the Rx FIFO */            *(ULONG *)p_buffer = _OS_INL(sci_cb[sci_id].scbuffs);            /* determine the number of valid bytes in the word */            validb = ((_OS_INB(sci_cb[sci_id].scstat) & VALIDB) >> 6);            if(validb == 0)            {                validb = 4;            }            p_buffer += validb;            if(sci_cb[sci_id].bytes_expected != -1)            {                if((sci_cb[sci_id].bytes_expected - validb) >= 0)                {                    sci_cb[sci_id].bytes_expected -= validb;                }                else                {                    sci_cb[sci_id].bytes_expected = 0;                }                if(sci_cb[sci_id].bytes_expected < 16)                {                    /* set RX threshold for not empty */                    _clear_bits(sci_id, SCBMR, RFFT);                    //outbyte(sci_cb[sci_id].scbmr,inbyte(sci_cb[sci_id].scbmr)&~RFFT);                }            }        }    }    else    {        /* byte FIFO access */        while((_check_bits(sci_id, SCSTAT, RPEND) == 1) &&              (_check_bits(sci_id, SCCTL3, POLDET) ==               _check_bits(sci_id, SCSTAT, DET)))        {            *p_buffer = _OS_INB(sci_cb[sci_id].scbuffs);            p_buffer ++;            if(sci_cb[sci_id].bytes_expected != -1)            {                if(sci_cb[sci_id].bytes_expected > 0)                {                    sci_cb[sci_id].bytes_expected --;                }                if(sci_cb[sci_id].bytes_expected < 16)                {                    /* set RX threshold for not empty */                    _clear_bits(sci_id, SCBMR, RFFT);                    //outbyte(sci_cb[sci_id].scbmr,inbyte(sci_cb[sci_id].scbmr)&~RFFT);                }            }        }    }    *p_buffer_addr = p_buffer;}/******************************************************************************* Function:    sci_atom_set_para_T**** Purpose:     Set the current Smart Card parameters of T.**** Parameters:  sci_id: zero-based number to identify smart card controller**              p_sci_parameters: input pointer to Smart Card parameters*****************************************************************************/void sci_atom_set_para_T(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters){    sci_cb[sci_id].sci_parameters.T = p_sci_parameters->T;    if(p_sci_parameters->T == 0)    {        _clear_bits(sci_id, SCCTL1, PRTCL);        /* byte wide FIFO */        _clear_bits(sci_id, SCCTL1, FIFO0);        /* Rx FIFO threshold not empty */        _clear_bits(sci_id, SCBMR, RFFT);    }    else    {        _set_bits(sci_id, SCCTL1, PRTCL);        /* word wide FIFO */        _set_bits(sci_id, SCCTL1, FIFO0);        /* Rx FIFO threshold >= half full */        _set_bits(sci_id, SCBMR, RFFT);    }}/******************************************************************************* Function:    sci_atom_set_para_f**** Purpose:     Set the current Smart Card parameters of frequency.**** Parameters:  sci_id: zero-based number to identify smart card controller**              p_sci_parameters: input pointer to Smart Card parameters*****************************************************************************/void sci_atom_set_para_f(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters){    ULONG divisor, frequency;    /* set scclk to nearest possible frequency */    divisor = 0;    do    {        divisor++;        frequency = __STB_SYS_CLK / (2 * divisor);    }    while(frequency > p_sci_parameters->f);    /* ensure this bit is not set before updating */    while(_check_bits(sci_id, SCETU0, CNT0BUSY) == 1);    sci_cb[sci_id].sci_parameters.f = frequency;    _OS_OUTB(sci_cb[sci_id].scclk_cnt0, divisor);}/******************************************************************************* Function:    sci_atom_set_para_ETU**** Purpose:     Set the current Smart Card parameters of ETU.**** Parameters:  sci_id: zero-based number to identify smart card controller**              p_sci_parameters: input pointer to Smart Card parameters*****************************************************************************/void sci_atom_set_para_ETU(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters){    sci_cb[sci_id].sci_parameters.ETU = p_sci_parameters->ETU;    _OS_OUTW(sci_cb[sci_id].scetu, p_sci_parameters->ETU);}/******************************************************************************* Function:    sci_atom_set_para_WWT**** Purpose:     Set the current Smart Card parameters of WWT.**** Parameters:  sci_id: zero-based number to identify smart card controller**              p_sci_parameters: input pointer to Smart Card parameters*****************************************************************************/void sci_atom_set_para_WWT(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters){    sci_cb[sci_id].sci_parameters.WWT = p_sci_parameters->WWT;    if(p_sci_parameters->T==0)    {        _OS_OUTL(sci_cb[sci_id].scbwt, p_sci_parameters->WWT);    }}/******************************************************************************* Function:    sci_atom_set_para_CWT**** Purpose:     Set the current Smart Card parameters of CWT.**** Parameters:  sci_id: zero-based number to identify smart card controller**              p_sci_parameters: input pointer to Smart Card parameters*****************************************************************************/void sci_atom_set_para_CWT(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters){    sci_cb[sci_id].sci_parameters.CWT = p_sci_parameters->CWT;    _OS_OUTW(sci_cb[sci_id].sccwt, p_sci_parameters->CWT);}/******************************************************************************* Function:    sci_atom_set_para_BWT**** Purpose:     Set the current Smart Card parameters of BWT.**** Parameters:  sci_id: zero-based number to identify smart card controller**              p_sci_parameters: input pointer to Smart Card parameters*****************************************************************************/void sci_atom_set_para_BWT(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters){    sci_cb[sci_id].sci_parameters.BWT = p_sci_parameters->BWT;    if(p_sci_parameters->T==1)    {        _OS_OUTL(sci_cb[sci_id].scbwt, p_sci_parameters->BWT);    }}/******************************************************************************* Function:    sci_atom_set_para_EGT**** Purpose:     Set the current Smart Card parameters of EGT.**** Parameters:  sci_id: zero-based number to identify smart card controller**              p_sci_parameters: input pointer to Smart Card parameters*****************************************************************************/void sci_atom_set_para_EGT(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters){    sci_cb[sci_id].sci_parameters.EGT = p_sci_parameters->EGT;    _OS_OUTB(sci_cb[sci_id].scegt, p_sci_parameters->EGT);}/******************************************************************************* Function:    sci_atom_set_para_check**** Purpose:     Set the current Smart Card parameters of check.**** Parameters:  sci_id: zero-based number to identify smart card controller**              p_sci_parameters: input pointer to Smart Card parameters*****************************************************************************/void sci_atom_set_para_check(ULONG sci_id, SCI_PARAMETERS *p_sci_parameters){    sci_cb[sci_id].sci_parameters.check = p_sci_parameters->check;    if(p_sci_parameters->check == 1)    {        _clear_bits(sci_id, SCCTL1, ERRDET);    }    else    {        _set_bits(sci_id, SCCTL1, ERRDET);    }}/****************************************************************************** Name:        sci_atom_emv_check**** Purpose:     check if this chip support EMV mode**** Returns      0: if NO EMV mode supported**              1: if EMV mode support****************************************************************************/INT sci_atom_emv_check(void){    INT rc = 0;#if defined (__DRV_FOR_PALLAS__)    /* STB04xxx pass-1 has no EMV support */    if(MF_SPR(SPR_PVR) != PPC_PALLAS_PBA)    {        rc = 1;    }#elif defined (__DRV_FOR_VULCAN__)    rc = 1;#elif defined (__DRV_FOR_VESTA__)#endif    return(rc);}/******************************************************************************* Function:    sci_atom_set_mode_emv2000**** Purpose:     Set the current Smart Card mode of emv2000.**** Parameters:  sci_id: zero-based number to identify smart card controller**              p_sci_modes: input pointer to Smart Card modes*****************************************************************************/void sci_atom_set_mode_emv2000(ULONG sci_id, SCI_MODES *p_sci_modes){    sci_cb[sci_id].sci_modes.emv2000 = p_sci_modes->emv2000;        if(p_sci_modes->emv2000 == 1)    {        _set_bits(sci_id, SCCTL3, SCIEMV);    }    else    {        _clear_bits(sci_id, SCCTL3, SCIEMV);    }}/****************************************************************************** Name:        _set_bits**** Purpose:     set bits in a register**** Parameters:  sci_id: zero-based number to identify smart card controller**              reg:    register offset from base address**              bits:   bit mask****************************************************************************/static void _set_bits (ULONG sci_id, ULONG reg, UCHAR bits){    ULONG *reg_address;    reg_address = (ULONG *)(sci_cb[sci_id].sci_base_address + reg);    _OS_OUTB(reg_address, _OS_INB(reg_address) | bits);}/****************************************************************************** Name:        _clear_bits**** Purpose:     clear bits in a register**** Parameters:  sci_id: zero-based number to identify smart card controller**              reg:    register offset from base address**              bits:   bit mask****************************************************************************/static void _clear_bits (ULONG sci_id, ULONG reg, UCHAR bits){    ULONG *reg_address;    reg_address = (ULONG *)(sci_cb[sci_id].sci_base_address + reg);    _OS_OUTB(reg_address, _OS_INB(reg_address) & ~bits);}/****************************************************************************** Name:        _check_bits**** Purpose:     check bits in a register**** Parameters:  sci_id: zero-based number to identify smart card controller**              reg:    register offset from base address**              bits:   bit mask**** Returns      0: if any bits in the bit mask are cleared**              1: if all bits in the bit mask are set****************************************************************************/static INT _check_bits (ULONG sci_id, ULONG reg, UCHAR bits){    ULONG *reg_address;    INT rc = 0;    reg_address = (ULONG *)(sci_cb[sci_id].sci_base_address + reg);    if((_OS_INB(reg_address) & bits) == bits)	{        rc = 1;	}    return(rc);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -