📄 initbios.c
字号:
/* ============================================================================ Project Name : jayaCard Module Name : proto/bios/init/initbios.c Version : $Id: initbios.c,v 1.21 2004/01/11 09:56:31 dgil Exp $ Description: BIOS initialization 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"/* ========================================================================= __bios_reset_context() Reset the context: - during BIOS initialisation - after an explicit request from the COS What to do ? - default cipher algo - deselect currentkey - set lasterr - reset seqval process if lasterr - ... __x XXX ========================================================================= */void __bios_reset_context(jbyte err){ /* reset cipher algo, current key, ... */ BIOS_SETCIPHERALGO(JAYACFG_CIPHER_ALGO_DEFAULT); BIOS_SETPADDING(JAYACFG_CIPHER_PAD_DEFAULT); BIOS_SETMACALGO(JAYACFG_CIPHER_MAC_DEFAULT); currentkey_type = KEY_TYPE_NOKEY; /* set error and reset SeqVal process only if it is a real error ! */ if (err != SUCCESS) { BIOS_SETERR(err); if (err != PENDING) { LOG1("BIOS","__bios_reset_context() err = %d / reset authentification process",err); BIOS_SET_SEQVAL(SEQVAL_NOPROCESS); } } /* cleanup the crypto context itself ... just in case its not already done */ BIOS_CRYPTO_CLEANUP();}/* ========================================================================= __bios_init() This function must initialize the BIOS : HAL initialisation appliData generation file system initialisation tcl initialisation crypto initialisation ========================================================================= */void __bios_init(void){ LOG("BIOS","__bios_init() ..."); /* Read chip configuration */ cfg_config_flag1 = HAL_EEPROM_READ_BYTE(ADDR_CONFIG_FLAG1); cfg_config_flag2 = HAL_EEPROM_READ_BYTE(ADDR_CONFIG_FLAG2); cfg_config_flag3 = HAL_EEPROM_READ_BYTE(ADDR_CONFIG_FLAG3); if ((cfg_config_flag1&CONFIG_FLAG1_CONFIG_FWI)==CONFIG_FLAG1_CONFIG_FWI) { cfg_fwi = HAL_EEPROM_READ_BYTE(ADDR_CONFIG_FWI); } else { cfg_fwi = JAYACFG_FWI; } if ((cfg_config_flag1&CONFIG_FLAG1_CONFIG_FSCI)==CONFIG_FLAG1_CONFIG_FSCI) { cfg_fsci = HAL_EEPROM_READ_BYTE(ADDR_CONFIG_FSCI); } else { cfg_fsci = JAYACFG_FSCI; } #ifdef JAYA_TCL_WTX if ((cfg_config_flag1&CONFIG_FLAG1_CONFIG_CHUNKEEP)==CONFIG_FLAG1_CONFIG_CHUNKEEP) { cfg_chunkeep = HAL_EEPROM_READ_BYTE(ADDR_CONFIG_CHUNKEEP); } else { cfg_chunkeep = JAYACFG_CHUNK_EEPROM_WRITE_BEFORE_WTX_REQUIRED; } #endif /* very first init because need CRC to communicate */ #ifdef TCL_TYPEAB #ifdef XPCORE_SIMU /* the simulator sets the type on the power on */ #else /* the component need to read the configuration from a cell in EEPROM */ tcl_type = ((cfg_config_flag1&CONFIG_FLAG1_TYPEA)==CONFIG_FLAG1_TYPEA)?TCL_TYPEA:TCL_TYPEB; #endif #endif /* HAL and low-level BIOS initialisation */ HAL_INIT(); BIOS_APPLIDATA(); BIOS_TCL_INIT(); /* default status for access */ gSeqVal = SEQVAL_NOPROCESS; /* no process pending */ gSeqKeyPin = 0x00; /* default key | default pin */ /* default security context */ BIOS_RESET_CONTEXT(SUCCESS);}/* ========================================================================= That's all folks ! ========================================================================= */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -