📄 tcl.h
字号:
#ifndef TCL__H/* ============================================================================ Project Name : jayaCard Module Name : proto/bios/tcl/tcl.h Version : $Id: tcl.h,v 1.22 2004/01/11 09:56:31 dgil Exp $ Description: This is the T=CL API 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 072102 dgil wrote it from scratch ============================================================================*/#define TCL__H/* ========================================================================= Chip UUID ========================================================================= */GLOBAL_XDATA_ARRAY(jbyte,chipUUID,8);/* ========================================================================= FSM State Machine ========================================================================= */#define TCL_FSM_START 0x00#define TCL_FSM_RECEIVE 0x01#define TCL_FSM_SEND_WTX 0x02#define TCL_FSM_RETRANSMIT 0x03#define TCL_FSM_SEND_IBLOCK 0x04#define TCL_FSM_APPLICATION 0x05#define TCL_FSM_RECEIVE_IBLOCK 0x06#define TCL_FSM_RECEIVE_WTX 0x07#define TCL_FSM_SEND_DESELECT 0x08#define TCL_FSM_SEND_ACK 0x09#define TCL_FSM_RECEIVE_NAK 0x0A#define TCL_FSM_RECEIVE_ACK 0x0B#define TCL_FSM_HALT 0x55void __bios_tcl_fsm(void);#define BIOS_TCL_FSM() __bios_tcl_fsm()/* ========================================================================= TCL mask for decoding information about the block ========================================================================= */#define TCL_MASK_POWER_LEVEL 0x00 /* Power Level bit 0000 0000 */#define TCL_MASK_BLOCK_NUMBER 0x01 /* block number bit 0000 0001 */#define TCL_MASK_NAD 0x04 /* NAD following bit 0000 0100 */#define TCL_MASK_CID 0x08 /* CID following bit 0000 1000 */#define TCL_MASK_CHAINING 0x10 /* Chaining bit 0001 0000 */#define TCL_MASK_WTXM 0x3F /* WTX Multipier 0011 1111 */#define TCL_MASK_IBLOCK 0xE2 /* I-BLOCK mask 1110 0010 */#define TCL_MASK_RBLOCK 0xF6 /* R-BLOCK mask 1111 0110 */#define TCL_MASK_SBLOCK 0xF7 /* S-BLOCK mask 1111 0111 *//* ========================================================================= TCL Block type coding ========================================================================= */#define TCL_TYPE_IBLOCK 0x02 /* I-BLOCK 000x xx1x */#define TCL_TYPE_RBLOCK_ACK 0xA2 /* R-BLOCK-ACK 1010 x01x */#define TCL_TYPE_RBLOCK_NAK 0xB2 /* R-BLOCK-NAK 1011 x01x */#define TCL_TYPE_SBLOCK_DESELECT 0xC2 /* S-BLOCK:deselect 1100 x010 */#define TCL_TYPE_SBLOCK_WTX 0xF2 /* S-BLOCK:wtx 1111 x010 *//* ========================================================================= TCL in process information ========================================================================= */#define TCL_INPROC_NONE 0x00#define TCL_INPROC_CHAINING_PCD 0x10#define TCL_INPROC_CHAINING_PICC 0x11#define TCL_INPROC_CHAINED_PICC 0x12#define TCL_INPROC_WTX 0x20#define TCL_INPROC_ERROR 0x30GLOBAL_IDATA(jbyte,tcl_inproc);/* ========================================================================= TCL library initialisation ========================================================================= */void __bios_tcl_init(void);#define BIOS_TCL_INIT() __bios_tcl_init()/* ========================================================================= anticollisionA/B ========================================================================= */#ifdef JAYACFG_CONTACTLESS_TYPEAvoid __bios_tcl_activationA(void);#define BIOS_TCL_ACTIVATIONA() __bios_tcl_activationA()#else#define BIOS_TCL_ACTIVATIONA()#endif#ifdef JAYACFG_CONTACTLESS_TYPEBvoid __bios_tcl_anticollisionB(void);#define BIOS_TCL_ANTICOL_AND_SELECTB() __bios_tcl_anticollisionB()#else#define BIOS_TCL_ANTICOL_AND_SELECTB()#endif/* ========================================================================= FSM TypeB Anticollision State Machine ========================================================================= */#ifdef JAYACFG_CONTACTLESS_TYPEB#define TCL_FSMB_REQB 0x00#define TCL_FSMB_ACTIVE 0x01#define TCL_FSMB_HALT 0x02#define TCL_FSMB_ANSWERATTRIB 0x03#define TCL_FSMB_ATTRIB 0x04#define TCL_FSMB_ATQB 0x05#define TCL_FSMB_SLOTMARKER 0x06#define TCL_FSMB_AFI 0x07GLOBAL_IDATA(jbyte,tcl_nslot);GLOBAL_IDATA(jbyte,tcl_rslot);#endif/* ========================================================================= TypeB Family coding ========================================================================= */#define TCL_TYPEB_FAMILY_PROPRIETARY 0x0#define TCL_TYPEB_FAMILY_TRANSPORT 0x1#define TCL_TYPEB_FAMILY_FINANCIAL 0x2#define TCL_TYPEB_FAMILY_IDENTIFICATION 0x3#define TCL_TYPEB_FAMILY_TELECOM 0x4#define TCL_TYPEB_FAMILY_MEDICAL 0x5#define TCL_TYPEB_FAMILY_MULTIMEDIA 0x6#define TCL_TYPEB_FAMILY_GAMING 0x7#define TCL_TYPEB_FAMILY_DATASTORAGE 0x8/* ========================================================================= TypeB Block type coding ========================================================================= */#ifdef JAYACFG_CONTACTLESS_TYPEB#define TYPEB_REQB 0x05#define TYPEB_ATQB 0x50#define TYPEB_SLOT_MARKER 0x05#define TYPEB_ATTRIB 0x1D#define TYPEB_HALT 0x50#define TYPEB_ANSWER_HALT 0x00#endif/* ============================================================================ WTX Management special case need attention under Keil-C compiler / 8051 core / Metrowerks reenter the TCL finite state machine without reentrant nor recursive problems ... requires to use a function callback ========================================================================= */#ifdef JAYA_TCL_WTXtypedef void (*FN_WTX)(void);GLOBAL_XDATA(FN_WTX,pfn_wtx);void __bios_tcl_wtx(void);#define BIOS_TCL_WTX() __bios_tcl_wtx()#else#define BIOS_TCL_WTX()#endif/* ========================================================================= TCL required variables ========================================================================= */#ifdef JAYA_TCL_WTXGLOBAL_IDATA(jbyte,tcl_wtxm); /* current WTX multiplier value */#else#define tcl_wtxm JAYACFG_WTXM#endifGLOBAL_IDATA(jword,tcl_apdu); /* apdu pointer in the input buffer */GLOBAL_IDATA(jbyte,tcl_state); /* FSM current state */GLOBAL_IDATA(jbyte,tcl_cnt); /* numner of received bytes */GLOBAL_BIT(tcl_getmsg); /* get message in the input buffer */GLOBAL_BIT(tcl_has_nad); /* block header has NAD field */GLOBAL_BIT(tcl_has_cid); /* block header has CID field */#ifdef JAYACFG_CONTACTLESS_TYPEB#ifdef JAYACFG_HLINF_FOR_TYPEBGLOBAL_BIT(tcl_hl_info);#endif#endif#ifdef JAYACFG_CONTACTLESS_TYPEAGLOBAL_BIT(tcl_halt_state); /* halt encountered */#endifGLOBAL_IDATA(jbyte,tcl_ofs); /* offset inside the output buffer */GLOBAL_BIT(tcl_block); /* block number : 0 or 1 */GLOBAL_IDATA(jbyte,tcl_cid); /* CID field of current block header */GLOBAL_IDATA(jbyte,tcl_nad); /* NAD field of current block header */GLOBAL_IDATA(jbyte,tcl_pcb); /* PCB field of current block header */GLOBAL_IDATA(jword,tcl_fsd); /* current FSD */GLOBAL_IDATA(jbyte,sav_pcb); /* backup of tcl_pcb for retransmist of the current block */GLOBAL_IDATA(jword,sav_apdu); /* backup of tcl_apdu for retransmist of the current block *//* ========================================================================= */#endif/* defined TCL__H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -