📄 taglife.c
字号:
/* ============================================================================ Project Name : jayaCard Module Name : proto/bios/init/taglife.c Version : $Id: taglife.c,v 1.7 2004/04/23 20:29:15 dgil Exp $ Description: BIOS tag life cycle management 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 050303 dgil wrote it from cos ============================================================================*/#include "precomp.h"/* ============================================================================ __bios_init_taglife() Given the current lock states, update the life variable Note/Security : even in case of critical failures, __bios_init_taglife() shall not HALT the tag because we must proceed until the ATR. ========================================================================= */#define SHOULDBE_INIT 0x01#define SHOULDBE_PERSO 0x02#define SHOULDBE_APPLI 0x04void __bios_init_taglife(void){ LOCAL(jbyte,locks); LOCAL(jbyte,byLock); LOG("TAGLIFE","__bios_init_taglife()"); locks = 0; tag_life = LIFE_BLOCKED; /* read lock INIT */ gGlobalSem = JSEC_OK; byLock = HAL_LOCK(LOCK_INIT); gGlobalSem++; /* Lock INIT unset -> tag_life should be INIT */ if ((byLock==LOCK_UNSET) && (gGlobalSem==JSEC_SEM)) { LOG("TAGLIFE","__bios_init_taglife() LOCK INIT = UNSET; SHOULDBE_INIT = SET"); locks |= SHOULDBE_INIT; } /* read lock PERSO */ gGlobalSem = JSEC_OK; byLock = HAL_LOCK(LOCK_PERSO); gGlobalSem++; /* Lock PERSO unset -> tag_life should be PERSO */ if ((byLock==LOCK_UNSET) && (gGlobalSem==JSEC_SEM)) { LOG("TAGLIFE","__bios_init_taglife() LOCK PERSO = UNSET; SHOUDLBE_PERSO = SET"); locks |= SHOULDBE_PERSO; } /* read lock LOCKED */ gGlobalSem = JSEC_OK; byLock = HAL_LOCK(LOCK_BLOCKED); gGlobalSem++; /* Lock BLOCKED unset -> tag_life should be APPLI */ if ((byLock==LOCK_UNSET) && (gGlobalSem==JSEC_SEM)) { LOG("TAGLIFE","__bios_init_taglife() LOCK BLOCKED = UNSET; SHOUDLBE_APPLI = SET"); locks |= SHOULDBE_APPLI; } /* check coherency for INIT life */ if (((locks&SHOULDBE_INIT)==SHOULDBE_INIT) && ((locks&(SHOULDBE_PERSO|SHOULDBE_APPLI))==(SHOULDBE_PERSO|SHOULDBE_APPLI))) { /* all the locks are unset => INIT need to be done ! */ LOG("TAGLIFE","__bios_init_taglife() try LIFE_INIT"); tag_life = LIFE_INIT; } /* check coherency for PERSO life */ if (((locks&SHOULDBE_PERSO)==SHOULDBE_PERSO) && ((locks&(SHOULDBE_INIT|SHOULDBE_APPLI))==(SHOULDBE_APPLI))) { /* INIT lock set (INIT has been done) + PERSO/APPLI clear => PERSO need to be done ! */ LOG("TAGLIFE","__bios_init_taglife() try LIFE_PERSO"); tag_life = LIFE_PERSO; } /* check coherency for APPLI life */ if (((locks&SHOULDBE_APPLI)==SHOULDBE_APPLI) && ((locks&(SHOULDBE_INIT|SHOULDBE_PERSO))==(0x00))) { /* LOCKED lock clear (card not blocked) + INIT/PERSO lock set (PERSO/APPLI has been done) => APPLI mode */ LOG("TAGLIFE","__bios_init_taglife() try LIFE_APPLI"); tag_life = LIFE_APPLI; } LOG1("BIOS","__bios_init_taglife() ... tag_life=0x%.2X",tag_life); if (tag_life!=LIFE_BLOCKED) return; LOG("BIOS","__bios_init_taglife() ... TAG BLOCKED!\n(if it is not the intended behaviour, delete or change the 'eeprom.bin' file)"); /* rem: HAL_HALT(); continue because some commands are still supported with a blocked card */}/* ========================================================================= That's all folks ! ========================================================================= */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -