Ejemplo n.º 1
0
void trustzone_pre_init(void)
{
    sec_malloc_buf_reset();
    tz_dapc_sec_init();

#if CFG_ATF_LOG_SUPPORT    
#if !CFG_TEE_SUPPORT
    {
        atf_arg_t_ptr teearg = (atf_arg_t_ptr)trustzone_get_atf_boot_param_addr();
        atf_log_buf_start = (u32)mblock_reserve(&bootarg.mblock_info,
            (u64)ATF_LOG_BUFFER_SIZE, (u64)TEE_MEM_ALIGNMENT, 
            0x100000000, RANKMAX);    
        if(!atf_log_buf_start){
            printf("%s Fail to allocate atf log buffer: 0x%x, 0x%x\n", MOD, 
                ATF_LOG_BUFFER_SIZE, TEE_MEM_ALIGNMENT);
            teearg->atf_log_buf_size = 0;
        }
    }
#endif
#endif
}
Ejemplo n.º 2
0
void sec_lib_init (void)
{

#ifdef MTK_SECURITY_SW_SUPPORT
    part_t *part;
    U32 err;
    CUSTOM_SEC_CFG cust_cfg;
    BOOL bAC = g_ROM_INFO.m_SEC_CTRL.m_seccfg_ac_en;
    g_sec_cfg_exists = 0;
    U8* seccfg_buf = NULL;

    /* ---------------------- */
    /* check status           */
    /* ---------------------- */

    /* check customer configuration data structure */
    COMPILE_ASSERT(CUSTOM_SEC_CFG_SIZE == sizeof(CUSTOM_SEC_CFG));


    /* ---------------------- */
    /* initialize variables   */
    /* ---------------------- */
    sec_malloc_buf_reset();
    
    /* initialize customer configuration buffer */
    memset (&cust_cfg, 0x0, sizeof(cust_cfg));

    /* initialize customer configuration for security library */
    cust_cfg.sec_usb_dl = SEC_USBDL_CFG;
    cust_cfg.sec_boot = SEC_BOOT_CFG;
    /* fixme, hard coded temporarily, should parse secro header to get secro count, it's not necessarily 11 */
    cust_cfg.secro_len = 11 * AND_SECROIMG_SIZE_WITH_PADDING; 
    cust_cfg.secro_ac_enable = g_ROM_INFO.m_SEC_CTRL.m_secro_ac_en;
    cust_cfg.secro_ac_offset = sizeof(AND_AC_HEADER_T);
    cust_cfg.secro_ac_len = sizeof(AND_AC_ANDRO_T) + sizeof(AND_AC_SV5_T);
    memcpy (cust_cfg.img_auth_rsa_n, IMG_CUSTOM_RSA_N, sizeof(cust_cfg.img_auth_rsa_n));    
    memcpy (cust_cfg.img_auth_rsa_e, IMG_CUSTOM_RSA_E, sizeof(cust_cfg.img_auth_rsa_e));   
    memcpy (cust_cfg.crypto_seed, CUSTOM_CRYPTO_SEED, sizeof(cust_cfg.crypto_seed));        

    /* ---------------------- */
    /* check data structure   */
    /* ---------------------- */
    
    sec_rom_info_init();
    sec_key_init();
    sec_ctrl_init();   
    sec_flashtool_cfg_init();
    
    /* ---------------------- */
    /* find sec cfg part info */
    /* ---------------------- */
    SMSG ("[%s] AES Legacy : %d\n", MOD,g_ROM_INFO.m_SEC_CTRL.m_sec_aes_legacy);
    SMSG ("[%s] SECCFG AC : %d\n", MOD,bAC);

    err = seclib_img_auth_init(&cust_cfg, TRUE);	    
    if (SEC_OK != err)
    {
	SMSG ("[%s] Basic config not available...\n", MOD);
	ASSERT(0);
    }

    part = part_get("seccfg");
    if (part)
    {
	sec_cfg_info.addr = part->start_sect * 512;
	sec_cfg_info.len = part->nr_sects * 512;
	sec_cfg_info.part_id = part->part_id;
	seccfg_buf = sec_cfg_load();
	if (seccfg_buf)
	{
	    #if !CFG_FPGA_PLATFORM
	    /* starting to initialze security library */
	    if(SEC_OK == (err = seclib_img_auth_load_sig(seccfg_buf, SEC_CFG_READ_SIZE, TRUE, bAC)))
	    {
		g_sec_cfg_exists = 1;
	    }
	    else
	    {
		SMSG("[%s] init fail '0x%x'\n",MOD,err);
	    }

	    seclib_set_img_hdr_ver();
	    #endif 
	}
    }
    else
    {
        SMSG ("[%s] seccfg part not found\n", MOD);
    }

    if (NULL != part)
    {
        put_part(part);
    }

#else
    /* ROM_INFO must be linked even though MTK_SECURITY_SW_SUPPORT=0. 
     * Therefore, we refer to ROM_INFO to make sure it's linked.
     */
    g_ROM_INFO.m_SEC_CTRL.reserve[0] = 0;
#endif
}