📄 tcltypea.c
字号:
/* ============================================================================ Project Name : jayaCard Module Name : proto/bios/tcl/tcltypea.c Version : $Id: tcltypea.c,v 1.26 2004/01/11 09:56:31 dgil Exp $ Description: Type A support for the T=CL library The Original Code is jayaCard code. The Initial Developer of the Original Code is Gilles Dumortier. Portions created by the Initial Developer are Copyright (C) 2002-2004 the Initial Developer. All Rights Reserved. Contributor(s): This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see http://www.gnu.org/licenses/gpl.html History Rev Description 012603 dgil wrote it from scratch ============================================================================*/#include "precomp.h"#ifdef JAYACFG_CONTACTLESS_TYPEA/* ============================================================================ ROM table (see tclrom.c) ========================================================================= */extern jword code fsd[16];/* ============================================================================ __bios_tcl_activationA() Type A requests the help of the HAL to anticollision and select the chip ========================================================================= */void __bios_tcl_activationA(){ LOG("TCL","__bios_tcl_activationA() ..."); /* on some platform */ HAL_BOOST(); /* wait for a valid message (RATS or HALT expected) */wait: do { LOG("TCL","wait for RATS or HALT ..."); tcl_cnt = HAL_TCL_RECEIVE(gInBuffer.b,sizeof(gInBuffer),jtrue); } while (tcl_cnt==0); /* HALT command ? */ if (gInBuffer.b[0]==0x50) { /* note: ignore second byte */ LOG("TCL","HALT"); /* halt state is true -> next time, accept wakeupA */ tcl_halt_state = jtrue; return; /* chip will reset */ } /* RATS command ? */ if (gInBuffer.b[0]!=0xE0) { /* ignore other bytes and wait for command ! */ LOG1("TCL","Unknown command 0x%.2X",gInBuffer.b[0]); goto wait; } tcl_fsd = MIN(fsd[gInBuffer.b[1]>>4],fsd[JAYACFG_FSCI]); if (tcl_fsd == 0) { LOG1("TCL","Unknown fsd size ! index=%.2X",gInBuffer.b[1]); goto wait; } cos_cid = gInBuffer.b[1]&0x0F; LOG2("TCL","RATS cid=%d fsd=%d\n",cos_cid,tcl_fsd); /* second step of the cos_initialization can occur here __r check the timing required between RATS and ATS answer */ cos_init2(); /* send ATS */ BIOS_ATS(); /* wait for a valid message (PPS or regular Block expected) */ do { LOG("TCL","wait for PPS or x-BLOCK ..."); tcl_cnt = HAL_TCL_RECEIVE(gInBuffer.b,sizeof(gInBuffer),jtrue); } while (tcl_cnt<1); /* a message */ if (gInBuffer.b[0] == (0xD0 | cos_cid)) { /* default baudrate is 106 Kbauds */ jbyte br = 0x00; LOG("TCL","PPS"); /* done in __bios_tcl_init(): tcl_getmsg = jtrue; */ /* RFU decoding ! */ if ((gInBuffer.b[1]&0xEF)!=0x01) return; /* chip will reset */ if ((gInBuffer.b[1]&0x10)==0x10) { /* higher data rates negociation */ br = gInBuffer.b[2]; } /* answer to PPS */ HAL_TCL_INITSEND(gInBuffer.b[0]); /* send PPS */ HAL_TCL_SENDGO(jtrue); /* wait because next step will be a baudrate change ! */ /* change baudrate just after answering the frame */ HAL_TCL_SETBAUDRATE(br&0x03); } else { /* jump to data link layer directly with this message */ /* be sure to have tcl registers ready */ tcl_pcb = gInBuffer.b[0]; tcl_apdu++; tcl_cnt--; /* __x FIXME buffer overflow if tcl_cnt <- 0 !!! */ if ((tcl_pcb&TCL_MASK_CID)!=0) { tcl_cid = gInBuffer.b[1]; tcl_apdu++; tcl_cnt--; if ((tcl_pcb&TCL_MASK_NAD)!=0) { tcl_nad = gInBuffer.b[2]; tcl_apdu++; tcl_cnt--; } } else { if ((tcl_pcb&TCL_MASK_NAD)!=0) { tcl_nad = gInBuffer.b[1]; tcl_apdu++; tcl_cnt--; } } tcl_getmsg = jfalse; } tcl_state = TCL_FSM_START; BIOS_TCL_FSM();}/* ========================================================================= That's all folks ! ========================================================================= */#endif/* JAYACFG_CONTACTLESS_TYPEA */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -