📄 fsmf.c
字号:
/* ============================================================================ Project Name : jayaCard Module Name : proto/bios/fs/fsmf.c Version : $Id: fsmf.c,v 1.25 2004/04/23 20:29:15 dgil Exp $ Description: Manage the MF 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 040403 dgil wrote it from scratch ============================================================================*/#include "precomp.h"#ifdef JAYA_FILESYSTEM/* ============================================================================ import from fstools.c ========================================================================= */void __fs_load_DF_header(jword link);/* ============================================================================ __fs_new_session() eventually close the current session and go back to the MF note: eventually update lasterr if any problem to load MF header ========================================================================= */void __fs_new_session(jbool bResetAlsoDF,jbool bSelMF){ LOG2("FS","FS_NEW_SESSION - reset also DF = %d, select the MF = %d ",bResetAlsoDF,bSelMF); gGlobalSem--; if (bResetAlsoDF) { HAL_ERASE_XRAM((jbyte xdata*)¤t_DF,sizeof(current_DF)); current_DF_addr = NO_CURRENT_FILE; /* be sure to reset the authentication in APPLI mode */ if (tag_life == LIFE_APPLI) { LOG("FS","__fs_new_session() reset authentification process !"); BIOS_SET_SEQVAL(SEQVAL_NOPROCESS); } } HAL_ERASE_XRAM((jbyte xdata*)¤t_EF,sizeof(current_EF)); current_EF_addr = NO_CURRENT_FILE; current_recnum = NO_CURRENT_RECORD; if (bSelMF) { __fs_load_DF_header(ADDR_HEADER_MF); } gGlobalSem--;}/* ============================================================================ __fs_mount_MF() Fill current_DF with the MasterFile (MF) header Eventually Select the default DF Some error code in lasterr if any problem. Note/Security : even in case of critical failures, __fs_mount_MF() on a card with or without filesystem shall not HALT the tag because we must proceed until the ATR. ========================================================================= */void __fs_mount_MF(){ LOG("FS","__fs_mount_MF()"); /* bootstrap the file system ? */ gGlobalSem = JSEC_OK; gBiosSem = FS_ISBOOTSTRAPED(); gGlobalSem--; if (gBiosSem!=0xFF) { /* reset the session without selecting the MF */ FS_NEW_SESSION(jtrue,jfalse); if ((gBiosSem!=LOCK_UNSET) || (gGlobalSem!=JSEC_SEM)) { LOG2("ATTACK","__fs_mount_MF() gBiosSem(55)=%.2X gGlobalSem(58)=%.2X",gBiosSem,gGlobalSem); BIOS_SETERR(ERR_FAULT); } /* nothing to mount - wait for an explicit command */ LOG("FS","__fs_mount_MF() - nothing to mount / bootstrap not done"); return; } /* start a new session resetting everything (current_EF, current_DF, current_fileheader) then loading MF to the current_DF using the stream API and checking the final CRC secure: will reset also the gGlobalSem. */ FS_NEW_SESSION(jtrue,jtrue); gGlobalSem++; if (lasterr!=NOERR) { LOG1("FS","__fs_mount_MF() - MF not mounted 1 error code = %d",lasterr); return; } if ((gGlobalSem!=JSEC_OK) || (gBiosSem!=0xFF)) { LOG2("ATTACK","__fs_mount_MF() gBiosSem(FF)=%.2X gGlobalSem(55)=%.2X",gBiosSem,gGlobalSem); FS_NEW_SESSION(jtrue,jfalse); BIOS_SETERR(ERR_FAULT); return; } LOG("FS","__fs_mount_MF() - MF mounted"); /* select the default DF */ if (tag_life == LIFE_APPLI) { /* __x temp */ BIOS_APPLICATION_DESELECT(); /* IMPLEMENTME __x */ LOG("FS","__fs_mount_MF() - DefaultDF mounted __x XXX"); }}/* ========================================================================= That's all folks ! ========================================================================= */#endif/* JAYA_FILESYSTEM */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -