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

📄 ats.c

📁 开发源代码的CPU卡的COS源程序。
💻 C
字号:
/* ============================================================================   Project Name : jayaCard   Module Name  : proto/bios/init/ats.c   Version : $Id: ats.c,v 1.15 2004/01/11 09:56:31 dgil Exp $	Description: ATS    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 - today we have an entry point !   ============================================================================*/#include "precomp.h"/* =========================================================================	__bios_ats()	algo:		if opcode ATS 			execute it		else			if ATS in EEPROM				send it			else				build the default one calling cos_historical_bytes()			endif		endif   ========================================================================= */void __bios_ats(void){	LOCAL(jbyte,i);    LOCAL(jbyte,bitratecap);	// opcode for ATS ?	if (BIOS_CALL_OPCODE(OPCODE_ATS)==JSEC_OK) return;	// valid ATS in EEPROM ?	HAL_EEPROM_READ(&u.bBlock[JAYA_BCRYPTO_INPUT0+0],ADDR_EEPROM_ATS,EEPROM_SIZEOF_ATS);	if ((u.bBlock[JAYA_BCRYPTO_INPUT0+0]!=0) && (u.bBlock[JAYA_BCRYPTO_INPUT0+0]<=(EEPROM_SIZEOF_ATS-3))) {		HAL_CRC_INIT();		for (i=1;i<=u.bBlock[JAYA_BCRYPTO_INPUT0+0];i++) { HAL_CRC_COMPUTE(u.bBlock[JAYA_BCRYPTO_INPUT0+i]); }		if ( (HAL_CRC_LO()==u.bBlock[JAYA_BCRYPTO_INPUT0+EEPROM_SIZEOF_ATS-2]) && (HAL_CRC_HI()==u.bBlock[JAYA_BCRYPTO_INPUT0+EEPROM_SIZEOF_ATS-1]) ) {			goto send_hist;		}	}    if ((cfg_config_flag1&CONFIG_FLAG1_CONFIG_BITRATECAP)==CONFIG_FLAG1_CONFIG_BITRATECAP) {        bitratecap = HAL_EEPROM_READ_BYTE(ADDR_CONFIG_BITRATECAP);    } else {        bitratecap = 0x80 | (JAYACFG_BITRATECAP&0x07) | ((JAYACFG_BITRATECAP&0x07)<<4);    }	// send our ATS with the user historical bytes	u.bBlock[JAYA_BCRYPTO_INPUT0+0] = cos_historical_bytes(&u.bBlock[JAYA_BCRYPTO_INPUT0+1]);	HAL_TCL_INITSEND(u.bBlock[JAYA_BCRYPTO_INPUT0+0]+5);	// send other mandatory part	HAL_TCL_SEND(0x70+(cfg_fsci&0x0F));	/* T0 = TC(1) TB(1) TA(1) FSCI_TYPEA */    HAL_TCL_SEND(bitratecap);           /* TA = bit rate capabilities */	HAL_TCL_SEND(((cfg_fwi&0x0F) << 4)+JAYACFG_SFGI_TYPEA);		/* TB = FWI and SFGI */	HAL_TCL_SEND(0x03);		/* TC = support NAD, support CID */	// then send historical bytessend_hist:	for (i=1;i<=u.bBlock[JAYA_BCRYPTO_INPUT0+0];i++) { HAL_TCL_SEND(u.bBlock[JAYA_BCRYPTO_INPUT0+i]); }	HAL_TCL_SENDGO(jfalse);}/* =========================================================================	That's all folks !   ========================================================================= */

⌨️ 快捷键说明

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