Пример #1
0
void rk28_kld_loader_init( void )
{      
        struct rktag_header  *tg;
        __u32   tag = KRTAG_IDTAG;

        tg = *param_addr;
        if( (unsigned long)tg < 0x62000000 
        	&& (unsigned long)tg > 0x60002000 
                && tg->tag == tag  &&  tg->size == RKTAG_IDSIZE ) {
                RkPrintf("found valid tag\n");
                /* 20091224,HSL@RK,FOR multi copy at loader */
                memcpy(rkh_begin , tg , 0x2000 );
                tg->tag = 0;
        } else {
                RkPrintf("no valid tag found\n");
                tag = RKTAG_IDTAG;
        }
        tg = (struct rktag_header  *)rkh_begin;
        kernel_reset = NULL;
        
        if( tg->tag != tag || tg->size != RKTAG_IDSIZE ) {
                struct kld_tag  ltg;
                rkh_current = rkh_begin;
                memset(rkh_begin,0,(char*)rkh_end-(char*)rkh_begin);
                ltg.hdr.tag = RKTAG_IDTAG;
                ltg.hdr.size = RKTAG_IDSIZE;
                kld_set_tag( &ltg.hdr );
        } else {
                rkh_current = kld_get_current();
                tg = kld_find_tag( KRTAG_RESET_FLAG );
                if( tg )
                        kernel_reset = (struct krtag_reset_flag  *)(tg+1);
                //RkPrintf("4:found valid tag , kernel reset=0x%p\n" , kernel_reset );
        }
        if( kernel_reset ) {
                if( (kernel_reset->boot_type & kernel_reset->xboot_type)
                        || (kernel_reset->reset_type & kernel_reset->xreset_type) ) {
                        //RkPrintf("5:invalid kernel reset,bt=0x%x,^bt=0x%x,rt=0x%x,^rt=0x%x\n" , 
                        //kernel_reset->boot_type , kernel_reset->xboot_type ,
                        //kernel_reset->reset_type , kernel_reset->xreset_type);
                        kernel_reset = NULL;
                }
        }
}
Пример #2
0
void dump_gpio(gpio_conf* gpio)
{
    RkPrintf("group: %d\n", gpio->group);
    RkPrintf("index: %d\n", gpio->index);
    RkPrintf("valid: %d\n", gpio->valid);
    RkPrintf("io_read: %08X\n", gpio->io_read);
    RkPrintf("io_write: %08X\n", gpio->io_write);
    RkPrintf("io_dir_conf: %08X\n", gpio->io_dir_conf);
    RkPrintf("io_debounce: %08X\n", gpio->io_debounce);
}
Пример #3
0
/*  
 * 20100202,HSL@RK,change to string format.
*/
void loader_tag_set_version( __u32 date , __u16 maj_v , __u16 min_v )
{
        #if 0
        struct kld_tag  tg;
        tg.hdr.tag = RKTAG_VERSION;
        tg.hdr.size = sizeof( struct rktag_header ) + sizeof(struct rktag_version);
        tg.u.lver.date = date;                   /* 20091114 */
        tg.u.lver.main_version = maj_v;             /*2.6.27: 0206 */
        tg.u.lver.min_version = min_v;          /* 0027  */
        kld_set_tag( &tg.hdr );
        #else
        char    ver[128];
        int       len;
        struct kld_tag  tg;
        tg.hdr.tag = RKTAG_VERSION;
        // loader version X.XX YYYYMMDD
        len = sprintf(ver,"loader version %x.%x %x\n" , maj_v,min_v,date )+1;
        RkPrintf("%s",ver );
        tg.hdr.size = sizeof( struct rktag_header ) + ALIGN4(len);
        memcpy(&tg.u.lver , ver , len );
        kld_set_tag( &tg.hdr );
        #endif
}
Пример #4
0
static void SecureNSModeInit(void)
{
	uint32 updataFlag = 0;

	SecureBootEn = 1;
	SecureBootCheckOK = 0;
	RSK_KEY = (uint16 *)&RSA_KEY_DATA;
#if 0
{
	int i;
	char *p = RSK_KEY;
	printf("RSA_KEY_DATA============================================\n");
	for(i=0;i<32;i++)
	printf("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",*p++,*p++,*p++,*p++,*p++,*p++,*p++,*p++,*p++,*p++,*p++,*p++,*p++,*p++,*p++,*p++);
	printf("RSA_KEY_DATA============================================\n");
}
#endif
	if((RSK_KEY[0] != 0X400))
	{
		SecureBootEn = 0;
		RkPrintf("unsigned!\n");
	}

	SecureBootLock = 0;

	if(StorageSysDataLoad(1, &gDrmKeyInfo) == FTL_OK)
	{
		updataFlag = 0;
		SecureBootLock = gDrmKeyInfo.secureBootLock;
		if(SecureBootLock != 1) {
			SecureBootLock = 0;
		}

		if(gDrmKeyInfo.drmtag != 0x4B4D5244)
		{
			gDrmKeyInfo.drmtag = 0x4B4D5244;
			gDrmKeyInfo.drmLen = 504;
			gDrmKeyInfo.keyBoxEnable = 0;
			gDrmKeyInfo.drmKeyLen = 0;
			gDrmKeyInfo.publicKeyLen = 0;
			gDrmKeyInfo.secureBootLock = 0;
			gDrmKeyInfo.secureBootLockKey = 0;
			updataFlag = 1;
		}

		if(RSK_KEY[0] == 0X400)
		{
#ifdef SECURE_BOOT_SET_LOCK_ALWAY
			if(gDrmKeyInfo.secureBootLock == 0)
			{
				gDrmKeyInfo.secureBootLock = 1;
				gDrmKeyInfo.secureBootLockKey = 0;
				updataFlag = 1;
			}
#endif
			if(gDrmKeyInfo.publicKeyLen == 0)
			{//没有公钥,是第一次才开启keyBoxEnable,
				gDrmKeyInfo.publicKeyLen = 0x100;
				ftl_memcpy(gDrmKeyInfo.publicKey, RSK_KEY, 0x104);
				updataFlag = 1;
				gDrmKeyInfo.drmKeyLen = 0;
				gDrmKeyInfo.keyBoxEnable = 1;
				gDrmKeyInfo.secureBootLockKey = 0;
				memset( gDrmKeyInfo.drmKey, 0, 0x80);
#ifdef SECURE_BOOT_LOCK
				gDrmKeyInfo.secureBootLock = 1;
#endif
			}
			else if(memcmp(gDrmKeyInfo.publicKey, RSK_KEY, 0x100) != 0)
			{   //如果已经存在公钥,并且公钥被替换了,那么关闭
				if(memcmp(gDrmKeyInfo.publicKey + 4, RSK_KEY, 0x100) == 0)
				{
					ftl_memcpy(gDrmKeyInfo.publicKey, RSK_KEY, 0x104);
					updataFlag = 1;
				}
				else
				{
					gDrmKeyInfo.keyBoxEnable = 0; //暂时不启用这个功能
					SecureBootEn = 0;
					RkPrintf("E:pKey!\n");
				}
			}
		}

		if(updataFlag)
		{
			updataFlag = 0;
			if(FTL_ERROR == StorageSysDataStore(1, &gDrmKeyInfo))
			{
				;// TODO:SysDataStore异常处理
			}
		}
	}

	if(StorageSysDataLoad(0, &gBootConfig) == FTL_OK)
	{
		updataFlag = 0;
		if(gBootConfig.bootTag != 0x44535953)
		{
			gBootConfig.bootTag = 0x44535953;
			gBootConfig.bootLen = 504;
			gBootConfig.bootMedia = 0;// TODO: boot 选择
			gBootConfig.BootPart = 0;
			gBootConfig.secureBootEn = 0;//SecureBootEn; 默认disable
			updataFlag = 1;
		}
		else
		{
#ifndef SECURE_BOOT_ENABLE_ALWAY
			if(gBootConfig.secureBootEn == 0)
				SecureBootEn = 0;
#endif
		}

		if(updataFlag)
		{
			updataFlag = 0;
			if(FTL_ERROR == StorageSysDataStore(0, &gBootConfig))
			{
				;// TODO:SysDataStore异常处理
			}
		}
	}
	else
	{
		RkPrintf("no sys part.\n");
		SecureBootEn = 0;
	}
}
Пример #5
0
static void rk28_kld_dead( void )
{
        RkPrintf("dead for jtag......\n" );
        while( loader_stop == 0 );
}