示例#1
0
文件: init.c 项目: adel71/moboot
void target_init(void)
{
	uint32_t base_addr;
	uint8_t slot;
	dprintf(INFO, "target_init()\n");

	/* Initialize PMIC driver */
	pmic.read  = pa1_ssbi2_read_bytes;
	pmic.write = pa1_ssbi2_write_bytes;

	pm8921_init(&pmic);

	/* Keypad init */
	keys_init();
	keypad_init();

	/* fbcon */
	display_init();

	/* Trying Slot 1 first */
	slot = 1;
	base_addr = mmc_sdc_base[slot-1];
	if(mmc_boot_main(slot, base_addr))
	{
		/* Trying Slot 3 next */
		slot = 3;
		base_addr = mmc_sdc_base[slot-1];
		if(mmc_boot_main(slot, base_addr))
		{
			dprintf(CRITICAL, "mmc init failed!");
			ASSERT(0);
		}
	}
}
示例#2
0
static void target_keystatus()
{
	keys_init();

	if(target_volume_down())
		keys_post_event(KEY_VOLUMEDOWN, 1);
}
示例#3
0
文件: main.c 项目: nibelungen/HCAN
int main(void)
{
	wdt_enable(WDTO_2S);
	canix_init();

	// Haus-Elektrik Service Handler installieren
	canix_reg_frame_callback(hauselektrik_callback, -1, 
			HCAN_PROTO_SFP, HCAN_SRV_HES);

	canix_reg_rtc_callback(timer_handler);
	canix_reg_idle_callback(idle_handler);

	lcd_init(LCD_DISP_ON);
	lcd_clrscr();

	/*
	 * HINT: Grad Celsius = \337
	 *       (octal fuer 206 bzw. 0xdf)
	 */

	lcdctrl_init();
	keys_init();
	lcdstatemachine_init();

	canix_mainloop();
	return 0;
}
示例#4
0
文件: init.c 项目: bpadalino/lk
void target_init(void)
{
	struct ptentry *ptn;
	unsigned offset;

	dprintf(INFO, "target_init()\n");

	keys_init();
	keypad_init();

	ptable_init(&flash_ptable);
	smem_ptable_init();

	offset = smem_get_apps_flash_start();
	if (offset == 0xffffffff)
		offset = BOARD_FLASH_OFFSET;

	for (ptn = &board_part_list[0]; ptn->name[0]; ptn++) {
		ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
			   ptn->length, ptn->flags);
	}

	ptable_dump(&flash_ptable);

	flash_init(&flash_ptable);
}
示例#5
0
void target_init(void)
{
	unsigned base_addr;
	unsigned char slot;
	dprintf(INFO, "target_init()\n");

	/* Keypad init */
	keys_init();
	keypad_init();

	/* Trying Slot 1 first */
	slot = 1;
	base_addr = mmc_sdc_base[slot-1];
	if(mmc_boot_main(slot, base_addr))
	{
		/* Trying Slot 3 next */
		slot = 3;
		base_addr = mmc_sdc_base[slot-1];
		if(mmc_boot_main(slot, base_addr))
		{
			dprintf(CRITICAL, "mmc init failed!");
			ASSERT(0);
		}
	}
}
示例#6
0
void target_init(void)
{
	unsigned offset;
	struct flash_info *flash_info;
	int i;

	dprintf(INFO, "target_init()\n");

	keys_init();
	keypad_init();

	ptable_init(&flash_ptable);
	smem_ptable_init();

	flash_init();
	flash_info = flash_get_info();
	ASSERT(flash_info);

	offset = smem_get_apps_flash_start();
	if (offset == 0xffffffff)
		offset = BOARD_FLASH_OFFSET;

	for (i = 0; i < num_parts; i++) {
		struct ptentry *ptn = &board_part_list[i];
		unsigned len = ptn->length;

		if ((len == 0) && (i == num_parts - 1))
			len = flash_info->num_blocks - offset - ptn->start;
		ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
			   len, ptn->flags);
	}

	ptable_dump(&flash_ptable);
	flash_set_ptable(&flash_ptable);
}
示例#7
0
void target_init(void)
{
	target_shutdown_for_rtc_alarm();
	dprintf(INFO, "target_init()\n");

	setup_fpga();

	/* Setting Debug LEDs ON */
	debug_led_write(0xFF);
#if (!ENABLE_NANDWRITE)
	keys_init();
	keypad_init();
#endif

	/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
	display_init();
	dprintf(SPEW, "Diplay initialized\n");
	display_image_on_screen();
#endif

	if (mmc_boot_main(MMC_SLOT, MSM_SDC1_BASE)) {
		dprintf(CRITICAL, "mmc init failed!");
		ASSERT(0);
	}
}
示例#8
0
void api_platform_init(void) {
	// from target_init
	// Initialize PMIC driver
	spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);

	keys_init();
	keys_add_source(&event_source);
	event_source.keymap[0].enable_longpress = true;
}
示例#9
0
void target_init(void)
{
	unsigned base_addr;
	unsigned char slot;
	unsigned platform_id = board_platform_id();

	dprintf(INFO, "target_init()\n");

	/* Initialize PMIC driver */
	pmic.read = (pm8921_read_func) & pa1_ssbi2_read_bytes;
	pmic.write = (pm8921_write_func) & pa1_ssbi2_write_bytes;

	pm8921_init(&pmic);

	/* Keypad init */
	keys_init();

	if(platform_id == MSM8960)
	{
		msm8960_keypad_init();
	}
	else if(platform_id == MSM8930)
	{
		msm8930_keypad_init();
	}
	else if( (platform_id == APQ8064) ||
		 (platform_id == MPQ8064))
	{
		apq8064_keypad_init();
	}

	/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
	display_init();
	dprintf(SPEW, "Diplay initialized\n");
#endif

	if ((platform_id == MSM8960) || (platform_id == MSM8660A)
        || (platform_id == MSM8260A) || (platform_id == APQ8060A))
		/* Enable Hardware CE */
		platform_ce_type = CRYPTO_ENGINE_TYPE_HW;

	/* Trying Slot 1 first */
	slot = 1;
	base_addr = mmc_sdc_base[slot - 1];
	if (mmc_boot_main(slot, base_addr)) {
		/* Trying Slot 3 next */
		slot = 3;
		base_addr = mmc_sdc_base[slot - 1];
		if (mmc_boot_main(slot, base_addr)) {
			dprintf(CRITICAL, "mmc init failed!");
			ASSERT(0);
		}
	}
}
示例#10
0
文件: board.c 项目: AmesianX/WinQEMU
int misc_init_r(void)
{
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
	set_board_info();
#endif
#ifdef CONFIG_LCD_MENU
	keys_init();
	check_boot_mode();
#endif
#ifdef CONFIG_CMD_BMP
	if (panel_info.logo_on)
		draw_logo();
#endif
	return 0;
}
示例#11
0
int  main()
{
    /* variables */
    char  key;  		/* an input key */

    int   buffer_ptr = 0;	/* the buffer pointer */

    keys_init();  /* initialize keys handler */

    /* infinite loop processing input */
    while(TRUE)  {

        /* wait for a key to be ready */
	while (!key_available());


	/* have keypad input - get the key */
	key = key_lookup();
	/* and store the key */
	key_buffer[buffer_ptr++] = key;

	/* make sure buffer pointer stays in range */
	if (buffer_ptr >= BUFFER_SIZE)
	    buffer_ptr -= BUFFER_SIZE;


	/* check if there is still a key available (shouldn't be) */
	if (key_available())  {

	    /* if there is a key available now, it's an error */
	    /* put ? in the buffer and update the buffer pointer */
	    key_buffer[buffer_ptr++] = '?';
	    /* make sure pointer stays in range */
	    if (buffer_ptr >= BUFFER_SIZE)
	        buffer_ptr -= BUFFER_SIZE;
        }
    }


    /* done with main (never should get here), return 0 */
    return  0;

}
示例#12
0
void target_init(void)
{

    dprintf(INFO, "target_init()\n");

    setup_fpga();

    /* Setting Debug LEDs ON */
    debug_led_write(0xFF);
#if (!ENABLE_NANDWRITE)
	keys_init();
	keypad_init();
#endif
    if(mmc_boot_main(MMC_SLOT,MSM_SDC1_BASE))
    {
        dprintf(CRITICAL, "mmc init failed!");
        ASSERT(0);
    }
}
示例#13
0
void target_init(void)
{
	unsigned offset;
	struct flash_info *flash_info;
	int i;

	dprintf(INFO, "target_init()\n");

#if (!ENABLE_NANDWRITE)
	keys_init();
	keypad_init();
#endif

	if (target_is_emmc_boot())
		return;

	ptable_init(&flash_ptable);
	smem_ptable_init();

	flash_init();
	flash_info = flash_get_info();
	ASSERT(flash_info);

	offset = smem_get_apps_flash_start();
	if (offset == 0xffffffff)
	        while(1);

	for (i = 0; i < num_parts; i++) {
		struct ptentry *ptn = &board_part_list[i];
		unsigned len = ptn->length;

		if ((len == 0) && (i == num_parts - 1))
			len = flash_info->num_blocks - offset - ptn->start;
		ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
			   len, ptn->flags);
	}

	ptable_dump(&flash_ptable);
	flash_set_ptable(&flash_ptable);
}
示例#14
0
int board_late_init(void)
{
#ifdef DELTA_CHECK_KEYBD
	uchar kbd_data[KEYBD_DATALEN];
	char keybd_env[2 * KEYBD_DATALEN + 1];
	char *str;
	int i;
#endif /* DELTA_CHECK_KEYBD */

	setenv("stdout", "serial");
	setenv("stderr", "serial");

#ifdef DELTA_CHECK_KEYBD
	keys_init();

	memset(kbd_data, '\0', KEYBD_DATALEN);

	/* check for pressed keys and setup keybd_env */
	get_pressed_keys(kbd_data);

	for (i = 0; i < KEYBD_DATALEN; ++i) {
		sprintf (keybd_env + i + i, "%02X", kbd_data[i]);
	}
	setenv ("keybd", keybd_env);

	str = strdup ((char *)key_match (kbd_data));	/* decode keys */

# ifdef CONFIG_PREBOOT	/* automatically configure "preboot" command on key match */
	setenv ("preboot", str);	/* set or delete definition */
# endif /* CONFIG_PREBOOT */
	if (str != NULL) {
		free (str);
	}
#endif /* DELTA_CHECK_KEYBD */

	init_DA9030();
	return 0;
}
示例#15
0
void target_init(void)
{
	unsigned offset;
	struct flash_info *flash_info;
	unsigned total_num_of_blocks;
	bool  start_addr_changed = false;
	unsigned next_ptr_start_adr = 0;
	int i;

	dprintf(INFO, "target_init()\n");

#if (!ENABLE_NANDWRITE)
	keys_init();
	keypad_init();
#endif

	if (target_is_emmc_boot())
		return;

	ptable_init(&flash_ptable);
	smem_ptable_init();

	flash_init();
	flash_info = flash_get_info();
	ASSERT(flash_info);

	offset = smem_get_apps_flash_start();
	if (offset == 0xffffffff)
	        while(1);

	total_num_of_blocks = (flash_info->block_size)/NUM_PAGES_PER_BLOCK;

	for (i = 0; i < num_parts; i++) {
		struct ptentry *ptn = &board_part_list[i];
		unsigned len = ptn->length;

		if(len == VARIABLE_LENGTH)
		{
		        start_addr_changed = true;
			unsigned length_for_prt = 0;
			unsigned j;
			for (j = i+1; j < num_parts; j++)
			{
			        struct ptentry *temp_ptn = &board_part_list[j];
			        ASSERT(temp_ptn->length != VARIABLE_LENGTH);
			        length_for_prt += temp_ptn->length;
			}
		        len = (total_num_of_blocks - 1) - (offset + ptn->start + length_for_prt);
			ASSERT(len >= 0);
		        next_ptr_start_adr = ptn->start + len;
		}
		if((ptn->start == DIFF_START_ADDR) && (start_addr_changed))
		{
		        ASSERT(next_ptr_start_adr);
			ptn->start = next_ptr_start_adr;
			next_ptr_start_adr = ptn->start + ptn->length;
		}
		ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
			   len, ptn->flags);
	}

	ptable_dump(&flash_ptable);
	flash_set_ptable(&flash_ptable);
}
示例#16
0
void target_init(void)
{
	unsigned offset;
	struct flash_info *flash_info;
	unsigned total_num_of_blocks;
	unsigned next_ptr_start_adr = 0;
	unsigned blocks_per_1MB = 8; /* Default value of 2k page size on 256MB flash drive*/
	int i;

	dprintf(INFO, "target_init()\n");

#if (!ENABLE_NANDWRITE)
	keys_init();
	keypad_init();
#endif

	if (target_is_emmc_boot())
		return;

	ptable_init(&flash_ptable);
	smem_ptable_init();

	flash_init();
	flash_info = flash_get_info();
	ASSERT(flash_info);

	offset = smem_get_apps_flash_start();
	if (offset == 0xffffffff)
	        while(1);

	total_num_of_blocks = flash_info->num_blocks;
	blocks_per_1MB = (1 << 20) / (flash_info->block_size);

	for (i = 0; i < num_parts; i++) {
		struct ptentry *ptn = &board_part_list[i];
		unsigned len = ((ptn->length) * blocks_per_1MB);

		if(ptn->start != 0)
		        ASSERT(ptn->start == DIFF_START_ADDR);

		ptn->start = next_ptr_start_adr;

		if(ptn->length == VARIABLE_LENGTH)
		{
			unsigned length_for_prt = 0;
			unsigned j;
			for (j = i+1; j < num_parts; j++)
			{
			        struct ptentry *temp_ptn = &board_part_list[j];
			        ASSERT(temp_ptn->length != VARIABLE_LENGTH);
			        length_for_prt += ((temp_ptn->length) * blocks_per_1MB);
			}
		        len = (total_num_of_blocks - 1) - (offset + ptn->start + length_for_prt);
			ASSERT(len >= 0);
		}
		next_ptr_start_adr = ptn->start + len;
		ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
			   len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE);
	}

	smem_add_modem_partitions(&flash_ptable);

	ptable_dump(&flash_ptable);
	flash_set_ptable(&flash_ptable);
}
示例#17
0
int main(void) {
	FRESULT res;
	WORD br;

	sei(); // Globally enable interrupts

	hibernate_init();
	DAC_init();
	keys_init();

	if (pf_mount(&fs)) { sound_osch(); }
	else { sound_gut(); }

	while(1) {
		cli(); // disable interrupts to avoid race condition with sleep function
		if (FLAG_CHECK(NEW_SOUND)) {
			hibernate_timer_stop();
			FLAG_CLEAR(NEW_SOUND);
			sei();
			switch (special_mode) {
				case 1:
				if (new_sound_id == old_sound_id - 1) {
					special_mode = 2;
					goto sound_ende;
				} else if (new_sound_id == old_sound_id + 1) {
					special_mode = 4;
					goto sound_ende;
				} else if (new_sound_id == old_sound_id) {
					credits_counter = CREDITS_COUNTER_MAX - 5;
					special_mode = 0;
					goto sound_ende;
				} else special_mode = 0;
				break;
				case 2:
				special_mode = 3;
				break;
				case 4:
				special_mode = 5;
				break;
				default:
				special_mode = 0;
			}
			if (new_sound_id == 36) {
				special_mode = 1;
				goto sound_ende;
			}
			old_sound_id = new_sound_id;
			char* filename;
			if (++credits_counter > CREDITS_COUNTER_MAX) {
				credits_counter = 0;
				filename = "image.hex";
			} else {
				if (new_sound_id == 255) goto sound_ende;
				filename = filenames(bank, new_sound_id);
			}
			uint8_t tries = 3;
			while (pf_open(filename) && pf_open("error1.wav")) {
				if ((tries--) == 0) goto sound_ende;
				_delay_ms(10);
				pf_mount(&fs);
			}
			if (parse_wav_header()) {
				if (pf_open("error2.wav") || parse_wav_header()) goto sound_ende;
			}
			do {
				#define read_length 16384
				if (wavinfo.data_length > read_length) {
					res = pf_read(0, read_length, &br);
					wavinfo.data_length -= read_length;
				} else {
					res = pf_read(0, wavinfo.data_length, &br);
					break;
				}
			} while (res==0 && br==read_length && wavinfo.data_length>0 && !FLAG_CHECK(NEW_SOUND));
			stop_audio();
			sound_ende:
			hibernate_timer_init();
		} else {
			sleep_enable();
			sei();
			sleep_cpu();
			sleep_disable();
		}
		hibernate_check();
	}
}
示例#18
0
void target_init(void)
{

	ASSERT(NAND_MTD_PARTITION_NUM == num_parts);

		
	unsigned	offset;	
	unsigned	total_num_of_blocks;
	unsigned	blocks_per_megabytes;
	unsigned	next_ptr_start_adr = 0;
	int		 	ret, i;

	struct 		flash_info *flash_info;
	bool  		start_addr_changed = false;
	
	unsigned int				nMTDReserved_Num=0;			// total number of MTD Reserved Area
	TNFTL_MTDBadBlkInfo			MTDBadBlkInfo[num_parts];

	/////////////////////////////////////////////////////////////////////////////////////////////	
	unsigned int  		nROAreaSize, nPartitionSize = 0;
	unsigned int		nBlockSize, nBlockSize_MB;
	unsigned int		nDevPBpV, nDevBBpZ, nDevBBpV, nRervRate;
	unsigned int		j, nUserDataArea = 0;
	struct ptable 		sPartition_List;
			

	memset( MTDBadBlkInfo, 0, sizeof(TNFTL_MTDBadBlkInfo) * num_parts );
	dprintf(ALWAYS, "target_init()\n");
	
#if _EMMC_BOOT_TCC	
	PARTITION PartitionArr[50]; 	 
	unsigned int nPartitionCnt = 0; 
#endif		

#ifdef TRIFLASH_INCLUDE
		ioctl_diskinfo_t	disk_info;
#endif	


#if (!ENABLE_NANDWRITE)
#ifdef BOARD_TCC930X_STB_DEMO

#else
	keys_init();
	keypad_init();
#endif
#endif

	if (target_is_emmc_boot())
	{
#if _EMMC_BOOT_TCC	
		dprintf(INFO, "target_init() emmc_boot\n");
 
		ptable_init(&flash_ptable);

		//SDMMC init  //MCC
		DISK_Ioctl(DISK_DEVICE_TRIFLASH, DEV_INITIALIZE, NULL );

		//get flash info?   //MCC
		DISK_Ioctl(DISK_DEVICE_TRIFLASH, DEV_GET_DISKINFO, (void *)&disk_info);

		dprintf(INFO, "disk info: head: %d cylinder: %d sector : %d  sector size: %d Total_sectors: %d \n",disk_info.head,disk_info.cylinder,disk_info.sector,disk_info.sector_size,disk_info.Total_sectors);

		//ptabel init			//MCC
//		offset = flash_info->offset;	
		offset = 0;     //fixme

//		total_num_of_blocks = flash_info->num_blocks;
		total_num_of_blocks=10000000;    // fixme
																					 
		memset(&PartitionArr, 0, sizeof(PARTITION) * 50);												 
		nPartitionCnt = GetLocalPartition(0, PartitionArr); 											 
																								   
		for(i=0; i<nPartitionCnt; i++)																	 
			PrintPartitionInfo(&PartitionArr[i], i);		


		/* convert partition size to block unit */  //512byte ?
		blocks_per_megabytes = 1024*1024 / (disk_info.sector_size);		
		ASSERT(blocks_per_megabytes);
		
		for (i = 0; i < num_parts; i++) {
			struct ptentry *ptn = &board_part_list[i];
			if (ptn->length != VARIABLE_LENGTH)
				ptn->length *= blocks_per_megabytes;
		}
		
		for (i = 0; i < num_parts; i++) {
			struct ptentry *ptn = &board_part_list[i];
			unsigned len = ptn->length;
	
			if (ptn->start != DIFF_START_ADDR)
			{			
				if(i==2)
				{
					ptn->start = PartitionArr[1].start;
				}
				else
				{
					ptn->start *= blocks_per_megabytes;
				}
			}	
			
			if (len == VARIABLE_LENGTH) {
				start_addr_changed = true;
				unsigned length_for_prt = ptn->start;
				unsigned j;
				for (j = i+1; j < num_parts; j++)
				{
						struct ptentry *temp_ptn = &board_part_list[j];
						ASSERT(temp_ptn->length != VARIABLE_LENGTH);
						length_for_prt += temp_ptn->length;
				}
				len = total_num_of_blocks - length_for_prt;
				ASSERT(len >= 0);
				next_ptr_start_adr = ptn->start + len;
			}
			if((ptn->start == DIFF_START_ADDR) && (start_addr_changed)) {
				ASSERT(next_ptr_start_adr);
				ptn->start = next_ptr_start_adr;
				next_ptr_start_adr = ptn->start + ptn->length;
			}
			ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
				   len, ptn->flags);
		}
		ptable_dump(&flash_ptable);
		flash_set_ptable(&flash_ptable);		
#endif
		return;
	}

	if (flash_get_ptable() == NULL) {

		ptable_init(&flash_ptable);
		
		flash_set_partnum( num_parts );
		flash_init();
		flash_info = flash_get_info();
		ASSERT(flash_info);

		if ( (flash_info->num_blocks) && (!flash_check_table()) ) 
		{
			

			memcpy( sPartition_List.parts, board_part_list, sizeof( struct ptentry ) * num_parts );

			nBlockSize		=	flash_info->page_size << flash_info->ShiftPpB;			// Set Block Size ( Byte Size ) 
			nROAreaSize		=	flash_info->num_blocks * nBlockSize;					// Set Total ROArea Size ( Byte Size )
			nBlockSize_MB	=	nBlockSize / ( 1 << 20 );								
			
			if( nBlockSize_MB > 1 )					// If Block is over the 1MB. Block must aligned. 
			{										// ex) Block Size 2MB, If Partition Size is 3MB. Partition Block Number must be 2. not 1.
			
				if( nBlockSize_MB == 2 )			// If Block Size 2MB.
				{
					for( i = 0; i < num_parts; i++ )
					{
						if( sPartition_List.parts[i].length & 0x01 )
							sPartition_List.parts[i].length++;
					}
				}
				else if ( nBlockSize_MB == 4 )		// If Block Size 4MB 
				{
					unsigned int nDiff_Val;
						
					for( i = 0; i < num_parts; i++ )
					{
						nDiff_Val = sPartition_List.parts[i].length & 0x03;
						if( nDiff_Val )
							sPartition_List.parts[i].length += ( 4 - nDiff_Val );
					}
				}
				
			}
				
			flash_get_DevPBpV( &nDevPBpV, &nDevBBpZ, &nMTDReserved_Num );

			nMTDReserved_Num 	= 	( nMTDReserved_Num << 20 ) / nBlockSize;

			nDevBBpV			=	( nDevPBpV / 1024 ) * nDevBBpZ;
			nRervRate			=	( nMTDReserved_Num * 100 ) / nDevPBpV;
			nDevBBpV			=	( nDevBBpV * nRervRate ) / 100;
			nRervRate			= 	( 100 / nRervRate );

			nMTDReserved_Num	=	nRervRate + nDevBBpV;								// Setup ROArea Reserved Block 

			if( nMTDReserved_Num & 0x01 )
				nMTDReserved_Num++;

			if( flash_info->ExtInterrupt == TRUE )
				nMTDReserved_Num = nMTDReserved_Num << 1;

			for( i = 0; i < num_parts; i++ )
			{
				if( sPartition_List.parts[i].length != VARIABLE_LENGTH )
				{
					sPartition_List.parts[i].length  = sPartition_List.parts[i].length << 20; 	// Convert Length Unit. MByte -> Byte	
					nPartitionSize					+= sPartition_List.parts[i].length;
				}
				else
				{
					nUserDataArea	=	i;
				}
			}
		
			sPartition_List.parts[nUserDataArea].length	= nROAreaSize - nPartitionSize;			// Calculate UserDataArea Size ( include Rerv Block )
			sPartition_List.parts[nUserDataArea].length	-= (nMTDReserved_Num * nBlockSize ); 	// UserDataArea Size. Reverved Block Removed

			i = 1;
			sPartition_List.parts[0].length		/= nBlockSize;									// Partition 0 Length ( Block Unit )
			MTDBadBlkInfo[0].PartBlkNum			 =	sPartition_List.parts[0].length;			// Set Block Number Each Partition
			
			do
			{
				sPartition_List.parts[i].length /= nBlockSize;									// Partition i Length ( Block Unit )
				sPartition_List.parts[i].start	 = sPartition_List.parts[i-1].start + sPartition_List.parts[i-1].length;

				MTDBadBlkInfo[i].PartBlkNum		 = sPartition_List.parts[i].length;				// Set Block Number Each Partition

				++i;
				
			} while( i < num_parts );

			flash_set_rervnum( nMTDReserved_Num );				// Set Reserved Block Number
			flash_set_badblkinfo( MTDBadBlkInfo );				// Set Bad Block Table Info. About Block Number Each Partition
			

			for( i = 0; i < num_parts; i++ )
			{
				ptable_add(&flash_ptable, sPartition_List.parts[i].name, flash_info->offset + sPartition_List.parts[i].start,
						   				  sPartition_List.parts[i].length, sPartition_List.parts[i].flags);
			}

			ND_TRACE("\n-------------- [ Partition Table ] --------------\n");		          
			for( i = 0; i < num_parts; i++ )
			{
			ND_TRACE(" [Part %2d.%9s] [Start:%4d] [Length:%4d]\n", i, sPartition_List.parts[i].name ,sPartition_List.parts[i].start + flash_info->offset, sPartition_List.parts[i].length );	
			}
			ND_TRACE("-------------------------------------------------\n");
			
			dprintf(INFO, "[NAND        ] [Maker:0x%02x ][Device:0x%02x][Page_size:%d]\n",
				flash_info->vendor, flash_info->device, flash_info->page_size);
			dprintf(INFO, "               [Spare_Size:%d][Block_Size:%d][MTD_Block:%d][Rerv_Block:%d]\n",
				flash_info->spare_size, flash_info->block_size, flash_info->num_blocks - (U32)nMTDReserved_Num, (U32)nMTDReserved_Num);
		
			//ptable_dump(&flash_ptable);
			flash_set_ptable(&flash_ptable);

			ret = flash_set_badblktable();

			if( ret != SUCCESS )
			{
				dprintf(INFO, " !!! Fail Create Bad Block Table. [func:%s] [line:%d] !!! \n", __func__, __LINE__ );
				ASSERT(-1);
			}
			
			flash_set_tablestatus(TRUE);
			
		}
	}

}
示例#19
0
文件: init.c 项目: Ever-Never/lk
void target_init(void)
{
	struct flash_info *flash_info;
	unsigned start_block;
	unsigned blocks_per_plen = 1; //blocks per partition length
	unsigned nand_num_blocks;

	keys_init();
	keypad_init();

	uint16_t keys[] = {KEY_VOLUMEUP, KEY_VOLUMEDOWN, KEY_SOFT1, KEY_SEND, KEY_CLEAR, KEY_BACK, KEY_HOME};
	for(unsigned i=0; i< sizeof(keys)/sizeof(uint16_t); i++)
	if (keys_get_state(keys[i]) != 0)
	{
		display_init();
		display_lk_version();
		//dprintf(ALWAYS,"key %d pressed\n", i);
		break;
	}
	dprintf(INFO, "htcleo_init\n");

	if(get_boot_reason()==2) // booting for offmode charging, start recovery so kernel will charge phone
	{
		boot_into_recovery = 1;
		//dprintf(INFO, "reboot needed... \n");
		//reboot(0);
	}
	dprintf(ALWAYS, "load address %x\n", load_address);

	dprintf(INFO, "flash init\n");
	flash_init();
	flash_info = flash_get_info();
	ASSERT(flash_info);
	ASSERT(flash_info->num_blocks);
	nand_num_blocks = flash_info->num_blocks;

	ptable_init(&flash_ptable);

	if( strcmp(board_part_list[0].name,"PTABLE-BLK")==0 ) blocks_per_plen =1 ;
	else if( strcmp(board_part_list[0].name,"PTABLE-MB")==0 ) blocks_per_plen = (1024*1024)/flash_info->block_size;
	else panic("Invalid partition table\n");

	start_block = HTCLEO_FLASH_OFFSET;
	for (unsigned i = 1; i < num_parts; i++)
	{
		struct ptentry *ptn = &board_part_list[i];
		if( IS_PART_EMPTY(ptn) ) break;
		int len = ((ptn->length) * blocks_per_plen);

		if( ptn->start == 0 ) ptn->start = start_block;
		else if( ptn->start < start_block) panic("Partition %s start %x < %x\n", ptn->name, ptn->start, start_block);

		if(ptn->length == 0)
		{
			unsigned length_for_prt = 0;
			if( i<num_parts && !IS_PART_EMPTY((&board_part_list[i+1])) && board_part_list[i+1].start!=0)
			{
				length_for_prt =  board_part_list[i+1].start - ptn->start;
			}
			else
			{
				for (unsigned j = i+1; j < num_parts; j++)
				{
						struct ptentry *temp_ptn = &board_part_list[j];
						if( IS_PART_EMPTY(temp_ptn) ) break;
						if( temp_ptn->length==0 ) panic("partition %s and %s have variable length\n", ptn->name, temp_ptn->name);
						length_for_prt += ((temp_ptn->length) * blocks_per_plen);
				}
			}
			len = (nand_num_blocks - 1 - 186 - 4) - (ptn->start + length_for_prt);
			ASSERT(len >= 0);
		}

		start_block = ptn->start + len;
		ptable_add(&flash_ptable, ptn->name, ptn->start, len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE);
	}

	htcleo_ptable_dump(&flash_ptable);
	flash_set_ptable(&flash_ptable);
}
示例#20
0
void target_init(void)
{
	unsigned offset;
	struct flash_info *flash_info;
	unsigned total_num_of_blocks;
	unsigned next_ptr_start_adr = 0;
	unsigned blocks_per_1MB = 8; /* Default value of 2k page size on 256MB flash drive*/
	unsigned base_addr;
	unsigned char slot;
	int i;

	dprintf(INFO, "target_init()\n");

#if (!ENABLE_NANDWRITE)
	keys_init();
	keypad_init();
#endif

	if (target_is_emmc_boot())
	{
		/* Trying Slot 2 first */
		slot = 2;
		base_addr = mmc_sdc_base[slot-1];
		if(mmc_boot_main(slot, base_addr))
		{
			/* Trying Slot 4 next */
			slot = 4;
			base_addr = mmc_sdc_base[slot-1];
			if(mmc_boot_main(slot, base_addr))
			{
				dprintf(CRITICAL, "mmc init failed!");
				ASSERT(0);
			}
		}
		return;
	}

	ptable_init(&flash_ptable);
	smem_ptable_init();

	flash_init();
	flash_info = flash_get_info();
	ASSERT(flash_info);
	enable_interleave_mode(target_is_interleaved_mode());

	offset = smem_get_apps_flash_start();
	if (offset == 0xffffffff)
	        while(1);

	total_num_of_blocks = flash_info->num_blocks;
	blocks_per_1MB = (1 << 20) / (flash_info->block_size);

	for (i = 0; i < num_parts; i++) {
		struct ptentry *ptn = &board_part_list[i];
		unsigned len = ((ptn->length) * blocks_per_1MB);

		if(ptn->start != 0)
		        ASSERT(ptn->start == DIFF_START_ADDR);

		ptn->start = next_ptr_start_adr;

		if(ptn->length == VARIABLE_LENGTH)
		{
			unsigned length_for_prt = 0;
			unsigned j;
			for (j = i+1; j < num_parts; j++)
			{
			        struct ptentry *temp_ptn = &board_part_list[j];
			        ASSERT(temp_ptn->length != VARIABLE_LENGTH);
			        length_for_prt += ((temp_ptn->length) * blocks_per_1MB);
			}
		        len = (total_num_of_blocks - 1) - (offset + ptn->start + length_for_prt);
			ASSERT(len >= 0);
		}
		next_ptr_start_adr = ptn->start + len;
		if(target_is_interleaved_mode()) {
		        ptable_add(&flash_ptable, ptn->name, offset + (ptn->start / 2),
				   (len / 2), ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE);
		}
		else {
		        ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
				   len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE);
		}
	}

	smem_add_modem_partitions(&flash_ptable);

	ptable_dump(&flash_ptable);
	flash_set_ptable(&flash_ptable);
}
示例#21
0
文件: main.c 项目: bgbock/rdmp
  int main (void)
  {
  init_hw();
  LCD_init();
  keys_init();
  number_pointer = 0;
  number[number_pointer] = 0;
  main_substate = 0;
  //main_state = STATE_IDLE;
  main_state = STATE_INIT;
  //main_substate = 2;
  while (1)
  	{
//  	dly_ms(NORMAL_CYCLE_MS);
  	if (main_state==STATE_INIT)
  		{
  		f_gsm_ok = 0;
  		if (main_substate==0)
  			{
  	  		update_lcd("Init...");
  			uart_sendstr("AT\r\nAT\r\n");
  			main_state=STATE_INIT_W;
  			}
  		if (main_substate==1)
  			{
  	  		if (number_pointer>0)
  	  			update_lcd(number);
  	  		else
  	  			update_lcd("PIN?");
			if (keys_handling(&key))
				{
				if (key<10)
					{
					number[number_pointer++] = key + '0';
					number[number_pointer]=0;
					}
				if (key==KEY_YES)
					{
					f_gsm_ok = 0;
					main_state=STATE_WFCALL;
					uart_sendstr("AT+CPIN=");
					uart_sendstr(number);
					uart_sendstr("\r\n");
					main_state=STATE_INIT_W;
					update_lcd("PIN...");
					number_pointer = 0;
					number[number_pointer] = 0;
					}
				if (key==KEY_NO)
					{
					number_pointer = 0;
					number[number_pointer] = 0;
					}
				}
  			}
  		if (main_substate==2)
  			{
  			update_lcd("PIN OK");
  			uart_sendstr("AT+CLVL=100\r\n");
  			main_state=STATE_INIT_W;
  			}
  		if (main_substate==3)
  			{
  			update_lcd("S1 OK");
  			uart_sendstr("AT+CALM=0\r\n");
  			main_state=STATE_INIT_W;
  			}
  		if (main_substate==4)
  			{
  			update_lcd("S2 OK");
  			uart_sendstr("AT+IPR=38400\r\n");
  			main_state=STATE_INIT_W;
  			}
  		if (main_substate==5)
  			{
  			update_lcd("Network...");
  			if (f_gsm_cr)
  				main_state = STATE_IDLE;
  			}
  		}

  	if (main_state==STATE_INIT_W)
  		{
  		if (f_gsm_ok==1)
  			{
  			f_gsm_ok = 0;
  			main_state=STATE_INIT;
  			main_substate++;
  			}
  		}

  	if (main_state==STATE_IDLE)
  		{
  		if (f_gsm_ring)
  			{
  			f_gsm_ring=0;
  			main_state=STATE_WFINCALL;
  			}
  		if (number_pointer>0)
  			update_lcd(number);
  		else
  			update_lcd("Ready");
  		if (keys_handling(&key))
  			{
  			if (key<10)
  				{
  				number[number_pointer++] = key + '0';
  				number[number_pointer]=0;
  				}
  			if (key==KEY_YES)
  				{
  				f_gsm_ok = 0;
  				main_state=STATE_WFCALL;
  				uart_sendstr("ATD");
  				uart_sendstr(number);
  				uart_sendstr(";\r\n");
  				}
  			if (key==KEY_NO)
  				{
  				number_pointer = 0;
  				number[number_pointer] = 0;
  				}
  			}
  		}

  	if (main_state==STATE_WFCALL)
  		{
  		update_lcd("Wait");
		if (f_gsm_ok==1)
  			{
  			f_gsm_ok = 0;
  			main_state=STATE_CALLING;
  			}
  		}

  	if (main_state==STATE_CALLING)
  		{
  		update_lcd("Calling");
  		if (f_gsm_nc)
  			{
  			f_gsm_nc = 0;
  			main_state=STATE_IDLE;
  			}
  		if (keys_handling(&key))
  			{
  			if (key==KEY_YES)
  				{
  				}
  			if (key==KEY_NO)
  				{
  				f_gsm_ok = 0;
  				uart_sendstr("ATH\r\n");
  				main_state=STATE_WFECALL;
  				}
  			}
  		}
  	if (main_state==STATE_WFECALL)
  		{
  		update_lcd("Ending");
  		if (f_gsm_ok==1)
  			{
  			f_gsm_ok = 0;
  			main_state=STATE_IDLE;
  			}
  		}

  	if (main_state==STATE_WFINCALL)
  		{
  		update_lcd("RING");
  		if (f_gsm_nc)
  			{
  			f_gsm_nc = 0;
                          f_gsm_ring = 0;
  			main_state=STATE_IDLE;
  			}
  		if (keys_handling(&key))
  			{
  			if (key==KEY_YES)
  				{
  				f_gsm_ok = 0;
  				uart_sendstr("ATA\r\n");
  				main_state=STATE_WFAINCALL;
  				}
  			if (key==KEY_NO)
  				{
  				f_gsm_ok = 0;
  				uart_sendstr("ATH\r\n");
  				main_state=STATE_WFEINCALL;
  				}
  			}
  		}

  	if (main_state==STATE_WFEINCALL)
  		{
  		update_lcd("Ending");
  		if (f_gsm_ok==1)
  			{
  			f_gsm_ok = 0;
  			main_state=STATE_IDLE;
  			}
  		}

  	if (main_state==STATE_WFAINCALL)
  		{
  		update_lcd("Wait");
  		if (f_gsm_ok==1)
  			{
  			f_gsm_ok = 0;
  			main_state=STATE_INCALL;
  			}
  		}

  	if (main_state==STATE_INCALL)
  		{
  		update_lcd("Incall");
  		if (f_gsm_nc)
  			{
  			f_gsm_nc = 0;
  			main_state=STATE_IDLE;
  			}
  		if (keys_handling(&key))
  			{
  			if (key==KEY_NO)
  				{
  				f_gsm_ok = 0;
                                  f_gsm_ring = 0;
  				uart_sendstr("ATH\r\n");
  				main_state=STATE_WFEINCALL;
  				}
  			}
  		}
  	}
  }
示例#22
0
文件: init.c 项目: MiCode/mi2_lk
void target_init(void)
{
	unsigned base_addr;
	unsigned char slot;
	unsigned platform_id = board_platform_id();

	dprintf(INFO, "target_init()\n");

	pu_reason = target_check_power_on_reason();
	reboot_mode = check_reboot_mode();

	/* Initialize PMIC driver */
	pmic.read = (pm8921_read_func) & pa1_ssbi2_read_bytes;
	pmic.write = (pm8921_write_func) & pa1_ssbi2_write_bytes;

	pm8921_init(&pmic);

	target_shutdown_for_battinfo();
	target_shutdown_for_pwrkey();

	/* Keypad init */
	keys_init();

	if((platform_id == MSM8960)   ||
	   (platform_id == MSM8960AB) ||
	   (platform_id == APQ8060AB) ||
	   (platform_id == MSM8260AB) ||
	   (platform_id == MSM8660AB))
	{
		msm8960_keypad_init();
	}
	else if((platform_id == MSM8230)   ||
			(platform_id == MSM8630)   ||
			(platform_id == MSM8930)   ||
			(platform_id == MSM8230AA) ||
			(platform_id == MSM8630AA) ||
			(platform_id == MSM8930AA))
	{
		msm8930_keypad_init();
	}
	else if((platform_id == APQ8064) ||
		    (platform_id == MPQ8064) ||
		    (platform_id == APQ8064AB))
	{
		apq8064_keypad_init();
	}

	/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
	if (board_target_id() == LINUX_MACHTYPE_8960_CDP || (board_target_id() == LINUX_MACHTYPE_8960_MITWOA))
		panel_backlight_on_mitwoa(0);
	display_init();
	dprintf(INFO, "Diplay initialized\n");
	mdelay(34);
	if (board_target_id() == LINUX_MACHTYPE_8064_MITWO || (board_target_id() == LINUX_MACHTYPE_8064_MTP))
		panel_backlight_on_mitwo(1);
	else
		panel_backlight_on_mitwoa(1);
#endif

	if ((platform_id == MSM8960) || (platform_id == MSM8960AB) ||
		(platform_id == APQ8060AB) || (platform_id == MSM8260AB) ||
		(platform_id == MSM8660AB) || (platform_id == MSM8660A) ||
		(platform_id == MSM8260A) || (platform_id == APQ8060A))
		/* Enable Hardware CE */
		platform_ce_type = CRYPTO_ENGINE_TYPE_HW;

	/* Trying Slot 1 first */
	slot = 1;
	base_addr = mmc_sdc_base[slot - 1];
	if (mmc_boot_main(slot, base_addr)) {
		/* Trying Slot 3 next */
		slot = 3;
		base_addr = mmc_sdc_base[slot - 1];
		if (mmc_boot_main(slot, base_addr)) {
			dprintf(CRITICAL, "mmc init failed!");
			ASSERT(0);
		}
	}
}
示例#23
0
void target_init(void)
{
#if defined(NAND_BOOT_INCLUDE)
	ASSERT(NAND_MTD_PARTITION_NUM == num_parts);
		
	unsigned	offset;	
	unsigned	total_num_of_blocks;
	unsigned	blocks_per_megabytes;
	unsigned	next_ptr_start_adr = 0;
	int		 	ret, i;

	struct 		flash_info *flash_info;
	bool  		start_addr_changed = false;
	
	unsigned long long			nMTDReserved_Num=0;			// total number of MTD Reserved Area
	TNFTL_MTDBadBlkInfo			MTDBadBlkInfo[num_parts];

	/////////////////////////////////////////////////////////////////////////////////////////////	
	unsigned long long	nROAreaSize, nPartitionSize = 0;
	unsigned long int	nBlockSize, nBlockSize_MB;
	unsigned int		nDevPBpV, nDevBBpZ, nDevBBpV, nRervRate;
	unsigned int		j, nUserDataArea = 0;
	struct ptable 		sPartition_List;
			

	memset( MTDBadBlkInfo, 0, sizeof(TNFTL_MTDBadBlkInfo) * num_parts );

	edi_init();
#endif
	dprintf(ALWAYS, "target_init()\n");

	keys_init();
	keypad_init();

#if defined(BOOTSD_INCLUDE)

	if (target_is_emmc_boot())
	{
		emmc_boot_main();
		return ;

	}
#endif

#if defined(NAND_BOOT_INCLUDE)
#if defined(TNFTL_V8_INCLUDE)
	if (check_fwdn_mode()) {
		fwdn_start();
		return;
	}

	flash_boot_main();

#else
	if ( ( flash_get_ptable() == NULL ) ) {

		ptable_init(&flash_ptable);
		
		flash_set_partnum( num_parts );
		flash_init();
		flash_info = flash_get_info();
		ASSERT(flash_info);

		if ( (flash_info->num_blocks) && (!flash_check_table()) ) 
		{

			memcpy( sPartition_List.parts, board_part_list, sizeof( struct ptentry ) * num_parts );

			flash_get_DevPBpV( &nDevPBpV, &nDevBBpZ, &nMTDReserved_Num );

			nROAreaSize		= (unsigned long long)( nMTDReserved_Num << 20 );		
			nBlockSize		= flash_info->page_size << flash_info->ShiftPpB;			// Set Block Size ( Byte Size ) 
			//nROAreaSize		=	flash_info->num_blocks * nBlockSize;					// Set Total ROArea Size ( Byte Size )
			nBlockSize_MB	=	nBlockSize / ( 1 << 20 );								
			if( nBlockSize_MB > 1 )					// If Block is over the 1MB. Block must aligned. 
			{										// ex) Block Size 2MB, If Partition Size is 3MB. Partition Block Number must be 2. not 1.
			
				if( nBlockSize_MB == 2 )			// If Block Size 2MB.
				{
					for( i = 0; i < num_parts; i++ )
					{
						if( sPartition_List.parts[i].length & 0x01 )
							sPartition_List.parts[i].length++;
					}
				}
				else if ( nBlockSize_MB == 4 )		// If Block Size 4MB 
				{
					unsigned int nDiff_Val;
						
					for( i = 0; i < num_parts; i++ )
					{
						nDiff_Val = sPartition_List.parts[i].length & 0x03;
						if( nDiff_Val )
							sPartition_List.parts[i].length += ( 4 - nDiff_Val );
					}
				}
				
			}			

			nMTDReserved_Num 	= 	( nMTDReserved_Num << 20 ) / nBlockSize;

			nDevBBpV			=	( nDevPBpV / 1024 ) * nDevBBpZ;
			nRervRate			=	( nMTDReserved_Num * 100 ) / nDevPBpV;
			nDevBBpV			=	( nDevBBpV * nRervRate ) / 100;

			if( nRervRate != 0 )
				nRervRate			= 	( 100 / nRervRate );

			nMTDReserved_Num	=	nRervRate + nDevBBpV;								// Setup ROArea Reserved Block 

			if(nMTDReserved_Num == 0) 
				nMTDReserved_Num = 2;
			else if ( nMTDReserved_Num & 0x01 )
				nMTDReserved_Num++;

			if( flash_info->ExtInterrupt == TRUE )
				nMTDReserved_Num = nMTDReserved_Num << 1;

			for( i = 0; i < num_parts; i++ )
			{
				if( sPartition_List.parts[i].length != VARIABLE_LENGTH )
				{
					sPartition_List.parts[i].length  = (unsigned long long)(sPartition_List.parts[i].length << 20); 	// Convert Length Unit. MByte -> Byte	
					nPartitionSize					+= sPartition_List.parts[i].length;

					//ND_TRACE("sPartition_List.parts[%d].length:%lld [nPartitionSize:%d]\n", i, sPartition_List.parts[i].length, nPartitionSize);
				}
				else
				{
					nUserDataArea	=	i;
				}
			}

			if( nUserDataArea != 0 )
			{
				sPartition_List.parts[nUserDataArea].length	= nROAreaSize - nPartitionSize;			// Calculate UserDataArea Size ( include Rerv Block )
				//ND_TRACE("sPartition_List.parts[5].length:%lld [nPartitionSize:%d]\n", i, sPartition_List.parts[5].length, nPartitionSize);
				//sPartition_List.parts[nUserDataArea].length	-= (nMTDReserved_Num * nBlockSize ); 	// UserDataArea Size. Reverved Block Removed
			}	

			i = 1;
			sPartition_List.parts[0].length		/= nBlockSize;									// Partition 0 Length ( Block Unit )
			MTDBadBlkInfo[0].PartBlkNum			 =	sPartition_List.parts[0].length;			// Set Block Number Each Partition
			
			do
			{
				sPartition_List.parts[i].length /= nBlockSize;									// Partition i Length ( Block Unit )
				sPartition_List.parts[i].start	 = sPartition_List.parts[i-1].start + sPartition_List.parts[i-1].length;

				MTDBadBlkInfo[i].PartBlkNum		 = sPartition_List.parts[i].length;				// Set Block Number Each Partition

				++i;
				
			} while( i < num_parts );

			flash_set_rervnum( nMTDReserved_Num );				// Set Reserved Block Number
			flash_set_badblkinfo( MTDBadBlkInfo );				// Set Bad Block Table Info. About Block Number Each Partition
			

			for( i = 0; i < num_parts; i++ )
			{
				ptable_add(&flash_ptable, sPartition_List.parts[i].name, flash_info->offset + sPartition_List.parts[i].start,
						   				  sPartition_List.parts[i].length, sPartition_List.parts[i].flags);
			}

			ND_TRACE("\n-------------- [ Partition Table ] --------------\n");		          
			for( i = 0; i < num_parts; i++ )
			{
			ND_TRACE(" [Part %2d.%9s] [Start:%4d] [Length:%4d]\n", i, sPartition_List.parts[i].name ,sPartition_List.parts[i].start + flash_info->offset, sPartition_List.parts[i].length );	
			}
			ND_TRACE("-------------------------------------------------\n");
			
			dprintf(INFO, "[NAND        ] [Maker:0x%02x ][Device:0x%02x][Page_size:%d]\n",
				flash_info->vendor, flash_info->device, flash_info->page_size);
			dprintf(INFO, "               [Spare_Size:%d][Block_Size:%d][MTD_TotalBlock:%d]\n",
				flash_info->spare_size, flash_info->block_size, flash_info->num_blocks);
			//dprintf(INFO, "               [Spare_Size:%d][Block_Size:%d][MTD_Block:%d][Rerv_Block:%d]\n",
			//	flash_info->spare_size, flash_info->block_size, flash_info->num_blocks - (U32)nMTDReserved_Num, (U32)nMTDReserved_Num);
		
			//ptable_dump(&flash_ptable);
			flash_set_ptable(&flash_ptable);

			ret = flash_set_badblktable();

			if( ret != SUCCESS )
			{
				dprintf(INFO, " !!! Fail Create Bad Block Table. [func:%s] [line:%d] !!! \n", __func__, __LINE__ );
				ASSERT(-1);
			}
			
			flash_set_tablestatus(TRUE);
			
		}
	}
#endif
#endif
}
示例#24
0
/* Called by Geany to initialize the plugin.
 * Note: data is the same as geany_data. */
void plugin_init(GeanyData *data)
{
	GtkWidget* vbox;
	int i;

	plugin_module_make_resident(geany_plugin);

	keys_init();
	
	pixbufs_init();

	/* main box */
	hbox = gtk_hbox_new(FALSE, 7);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);

	/* add target page */
	tpage_init();
	
	/* init brekpoints */
	breaks_init(editor_open_position);
	
	/* init markers */
	markers_init();

	/* init debug */
	debug_init();

	/* load config */
	config_init();

	/* init paned */
	dpaned_init();
	tpage_pack_widgets(config_get_tabbed());

	vbox = btnpanel_create(on_paned_mode_changed);

	gtk_box_pack_start(GTK_BOX(hbox), dpaned_get_paned(), TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);

	gtk_widget_show_all(hbox);
	
	gtk_notebook_append_page(
		GTK_NOTEBOOK(geany->main_widgets->message_window_notebook),
		hbox,
		gtk_label_new(_("Debug")));

	if (geany_data->app->project)
	{
		config_update_project_keyfile();
	}
	config_set_debug_store(
		config_get_save_to_project() && geany_data->app->project ? DEBUG_STORE_PROJECT : DEBUG_STORE_PLUGIN
	);

	/* set calltips for all currently opened documents */
	foreach_document(i)
	{
		scintilla_send_message(document_index(i)->editor->sci, SCI_SETMOUSEDWELLTIME, 500, 0);
		scintilla_send_message(document_index(i)->editor->sci, SCI_CALLTIPUSESTYLE, 20, (long)NULL);
	}
}
示例#25
0
void target_init(void)
{
	unsigned offset;
	struct flash_info *flash_info;
	struct ptentry *board_part_list;
	unsigned total_num_of_blocks;
	unsigned next_ptr_start_adr = 0;
	unsigned blocks_per_1MB = 8; /* Default value of 2k page size on 256MB flash drive*/
	int i;

	dprintf(INFO, "target_init()\n");

#if (!ENABLE_NANDWRITE)
	keys_init();
	keypad_init();
#endif

	/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
	display_init();
	dprintf(SPEW, "Diplay initialized\n");
	display_image_on_screen();
#endif

	if (target_is_emmc_boot())
	{
		/* Must wait for modem-up before we can intialize MMC.
		 */
		while (readl(MSM_SHARED_BASE + 0x14) != 1);

		if(mmc_boot_main(MMC_SLOT, MSM_SDC3_BASE))
		{
			dprintf(CRITICAL, "mmc init failed!");
			ASSERT(0);
		}
		return;
	}

	ptable_init(&flash_ptable);
	smem_ptable_init();

	flash_init();
	flash_info = flash_get_info();
	ASSERT(flash_info);

	offset = smem_get_apps_flash_start();
	if (offset == 0xffffffff)
			while(1);

	total_num_of_blocks = flash_info->num_blocks;
	blocks_per_1MB = (1 << 20) / (flash_info->block_size);

	if (flash_ecc_bch_enabled())
		board_part_list = board_part_list_bchecc;
	else
		board_part_list = board_part_list_default;

	for (i = 0; i < num_parts; i++) {
		struct ptentry *ptn = &board_part_list[i];
		unsigned len = ((ptn->length) * blocks_per_1MB);

		if(ptn->start != 0)
				ASSERT(ptn->start == DIFF_START_ADDR);

		ptn->start = next_ptr_start_adr;

		if(ptn->length == VARIABLE_LENGTH)
		{
			unsigned length_for_prt = 0;
			unsigned j;
			for (j = i+1; j < num_parts; j++)
			{
					struct ptentry *temp_ptn = &board_part_list[j];
					ASSERT(temp_ptn->length != VARIABLE_LENGTH);
					length_for_prt += ((temp_ptn->length) * blocks_per_1MB);
			}
				len = (total_num_of_blocks - 1) - (offset + ptn->start + length_for_prt);
			ASSERT(len >= 0);
		}
		next_ptr_start_adr = ptn->start + len;
		ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
			   len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE);
	}

	smem_add_modem_partitions(&flash_ptable);

	ptable_dump(&flash_ptable);
	flash_set_ptable(&flash_ptable);
}
示例#26
0
文件: init.c 项目: M1cha/lktris
void target_init(void)
{
	unsigned base_addr;
	unsigned char slot;
	unsigned platform_id = board_platform_id();

	dprintf(INFO, "target_init()\n");

	/* Initialize PMIC driver */
	pmic.read = (pm8921_read_func) & pa1_ssbi2_read_bytes;
	pmic.write = (pm8921_write_func) & pa1_ssbi2_write_bytes;

	pm8921_init(&pmic);

	/* Keypad init */
	keys_init();

	switch(platform_id) {
	case MSM8960:
	case MSM8960AB:
	case APQ8060AB:
	case MSM8260AB:
	case MSM8660AB:
		msm8960_keypad_init();
		break;
	case MSM8130:
	case MSM8230:
	case MSM8630:
	case MSM8930:
	case MSM8130AA:
	case MSM8230AA:
	case MSM8630AA:
	case MSM8930AA:
	case MSM8930AB:
	case MSM8630AB:
	case MSM8230AB:
	case MSM8130AB:
	case APQ8030AB:
	case APQ8030:
	case APQ8030AA:
		msm8930_keypad_init();
		break;
	case APQ8064:
	case MPQ8064:
	case APQ8064AA:
	case APQ8064AB:
		apq8064_keypad_init();
		break;
	default:
		dprintf(CRITICAL,"Keyboard is not supported for platform: %d\n",platform_id);
	};

	if ((platform_id == MSM8960) || (platform_id == MSM8960AB) ||
		(platform_id == APQ8060AB) || (platform_id == MSM8260AB) ||
		(platform_id == MSM8660AB) || (platform_id == MSM8660A) ||
		(platform_id == MSM8260A) || (platform_id == APQ8060A) ||
		(platform_id == APQ8064) || (platform_id == APQ8064AA) ||
		(platform_id == APQ8064AB))
		/* Enable Hardware CE */
		platform_ce_type = CRYPTO_ENGINE_TYPE_HW;

	/* Trying Slot 1 first */
	slot = 1;
	base_addr = mmc_sdc_base[slot - 1];
	if (mmc_boot_main(slot, base_addr)) {
		/* Trying Slot 3 next */
		slot = 3;
		base_addr = mmc_sdc_base[slot - 1];
		if (mmc_boot_main(slot, base_addr)) {
			dprintf(CRITICAL, "mmc init failed!");
			ASSERT(0);
		}
	}
}