亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? flashwriternor.c

?? 手機中寫FLASH的代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
// Notes:
//   Callable from C. Registers r0-r3 are *not* preserved.
//
///////////////////////////////////////////////////////////////////////////////
void AMD_Soft_Reset_Flash(ULONG addr)
{  
	// Reset Flash to be in Read Array Mode 
	*((vHwdptr) addr) =  AMD_DEVICE_RESET;
	// return to caller
}

///////////////////////////////////////////////////////////////////////////////
//
// AMD Flash Erase Block
//
// Description:
//   This routine erases the AMD Page specified by the input parameter 
//   address. This routine is common for both the AM29LV017B device and
//   the AM29DL800B device.
//
// Arguments:
//   address - address in chip select to be erased
//
// Assumptions:
//   The AM29LV017B device won't become confused when the addresses required
//   by the AM29DL800B are used.
//
///////////////////////////////////////////////////////////////////////////////
void AMD_Flash_Erase_Block(ULONG blockaddress)
{
	volatile USHORT *address_cs;
	ULONG tmp_ptr;
			
	tmp_ptr  = (ULONG) blockaddress;
	address_cs = (USHORT *) (tmp_ptr & AMD_ADDRESS_CS_MASK);		
	*(address_cs + AMD_CMD0_ADDR) = AMD_ERASE_BLK_CMD0;
	*(address_cs + AMD_CMD1_ADDR) = AMD_ERASE_BLK_CMD1;
	*(address_cs + AMD_CMD2_ADDR) = AMD_ERASE_BLK_CMD2;
	*(address_cs + AMD_CMD0_ADDR) = AMD_ERASE_BLK_CMD3;
	*(address_cs + AMD_CMD1_ADDR) = AMD_ERASE_BLK_CMD4;
	*((vHwdptr) blockaddress) = AMD_ERASE_BLK_CMD5;		
	while (*((vHwdptr)blockaddress) != AMD_ERASE_DONE);
}
 
///////////////////////////////////////////////////////////////////////////////
//
// AMD Flash Erase All
//
// Description:
//   This routine erases the entire AMD Chip.
//   This routine is common for both the AM29LV017B device and
//   the AM29DL800B device.
//
// Arguments:
//   address - chip select address  to be erased
//
// Assumptions:
//   The AM29LV017B device won't become confused when the addresses required
//   by the AM29DL800B are used.
//
///////////////////////////////////////////////////////////////////////////////
void AMD_Flash_Erase_All(ULONG address)
{
	volatile USHORT *psAddress;
	volatile USHORT *address_cs;
	ULONG tmp_ptr;
	USHORT tmp;
	
	psAddress = (USHORT *)address;
	tmp_ptr  = (ULONG) address;
	address_cs = (USHORT *) (tmp_ptr & AMD_ADDRESS_CS_MASK);	
	*(address_cs + AMD_CMD0_ADDR) = AMD_ERASE_CMD0;
	*(address_cs + AMD_CMD1_ADDR) = AMD_ERASE_CMD1;
	*(address_cs + AMD_CMD2_ADDR) = AMD_ERASE_CMD2;										
	*(address_cs + AMD_CMD0_ADDR) = AMD_ERASE_CMD3;
	*(address_cs + AMD_CMD1_ADDR) = AMD_ERASE_CMD4;
	*(address_cs + AMD_CMD2_ADDR) = AMD_ERASE_CMD5;
										
	while (1)
	{
		tmp = *psAddress; 
		if(tmp & BIT7) 
		{
			break;
		}  else
		{
			if(tmp & BIT5)             // Exceeded Time Limit
			{
				tmp = *psAddress; 
				if(tmp & BIT7) 
				{
					break; 
				}  else
				{
					AMD_Soft_Reset_Flash((ULONG) psAddress);
				}	
			}
		}
	}
}

///////////////////////////////////////////////////////////////////////////////
//
// AMD Flash Write
//
// Description:
//   This routine writes data to flash memory starting at the specified 
//   parameter address.
//
// Arguments:
//   plAddress - address to be erased
//   ulData    - data to be written
///////////////////////////////////////////////////////////////////////////////
int AMD_Flash_Write( ULONG *plAddress, USHORT ulData )
{
	volatile USHORT *psAddress;
	volatile USHORT *address_cs;
	USHORT tmp;
	ULONG tmp_ptr;

	// Lower WORD.
	psAddress = (USHORT *)plAddress;
	tmp_ptr  = (ULONG) plAddress;
	address_cs = (USHORT *) (tmp_ptr & AMD_ADDRESS_CS_MASK);

    *((vHwdptr)address_cs + AMD_CMD0_ADDR) = AMD_PROG_CMD0;
    *((vHwdptr)address_cs + AMD_CMD1_ADDR) = AMD_PROG_CMD1;
    *((vHwdptr)address_cs + AMD_CMD2_ADDR) = AMD_PROG_CMD2;
	
	*psAddress = ulData;

	// Wait for ready.
	while (1)
	{
		tmp = *psAddress; 
		if( (tmp & BIT7)  == (ulData & BIT7)) 
		{
			break;
		}
		else
		{
			if(tmp & BIT5)             // Exceeded Time Limit
			{
				tmp = *psAddress; 
				if( (tmp & BIT7)  == (ulData & BIT7)) 
				{
					break; 
				}
				else
				{
				  	AMD_Soft_Reset_Flash((ULONG) psAddress);
			      	return 1;
				}	
			}
		}
	}
    // Return Read Mode 
	AMD_Soft_Reset_Flash((ULONG) psAddress);
	// Verify the data.
	if (*psAddress != ulData)
	{
     	return 1;
	}
	return 0;
}

///////////////////////////////////////////////////////////////////////////////
//
// AMD Flash Optimized Write
//
// Description:
//   This routine writes an array of data to flash memory starting beginning 
//   at the specified parameter address.
//
// Arguments:
//   plAddress - address to begin writing
//   ulData[]  - data array to be written
//   length    - length of data array 
//
// Return:
//   int - 0 Success
//		 - 1 Fail 
//
///////////////////////////////////////////////////////////////////////////////
int AMD_Flash_Optimized_Write(ULONG *plAddress, USHORT ulData[], ULONG ullength )
{
	volatile USHORT *psAddress;			//
	volatile USHORT *address_cs;		//
	volatile USHORT *psBlockAddress;
	volatile USHORT *psPollingAddress;	//
	USHORT           usPollingData;     //
	USHORT           tmp;               //
	ULONG tmp_ptr;
	USHORT i;					

    // Adjust the timings for Writes
	tmp_ptr  = (ULONG) plAddress;
	psAddress = (USHORT *)plAddress;
	address_cs = (USHORT *) (tmp_ptr & AMD_ADDRESS_CS_MASK);           
	// Block Address WORD.
	psBlockAddress = (USHORT *)(tmp_ptr &= 0xFFFF0000);                // 64KB Sectors
	// Write the Write Buffer Load command
    *((vHwdptr)address_cs + AMD_CMD0_ADDR) = AMD_WRT_BUF_LOAD_CMD0;    
    *((vHwdptr)address_cs + AMD_CMD1_ADDR) = AMD_WRT_BUF_LOAD_CMD1;    
    *((vHwdptr)address_cs + AMD_CMD2_ADDR) = AMD_WRT_BUF_LOAD_CMD2;    	
	// Write Length 
	*psBlockAddress = (USHORT) (ullength-1);
	// Write Data 
	for(i=0; i<ullength; i++)
	{
		*psAddress = ulData[i];
        usPollingData    = ulData[i];                                  // store polling data
		psPollingAddress = psAddress;                                  // store polling address
		psAddress++;
	}
    // Program Buffer to Flash Confirm Write 
	*psBlockAddress = AMD_WRT_BUF_CONF_CMD0;                         

	psAddress = psPollingAddress;    // set polling address to last loaded location 
	                                 // (minimizes edits to "borrowed" polling routine)s	
	// Wait for ready.
	while (1)
	{
		tmp = *psAddress; 
		if((tmp & BIT7)  == (usPollingData & BIT7)) 
		{
			break;
		}  else
		{
			if(tmp & BIT5)             // Exceeded Time Limit
			{
				tmp = *psAddress; 
				if( (tmp & BIT7)  == (usPollingData & BIT7)) 
				{
					break; 
				}  else
				{
				  	AMD_Soft_Reset_Flash((ULONG) psAddress);
			      	return 1;
				}	
			}
			if(tmp & BIT1)             // Write Buffer Loaded Incorrectly
			{
				tmp = *psAddress; 
				if( (tmp & BIT7)  == (usPollingData & BIT7)) 
				{
					break; 
				}  else
				{
				  	AMD_Write_Buf_Abort_Reset_Flash ((ULONG) psAddress);
			      	return 1;
				}	
			}
		}
	}	
	// Put chip back into read array mode.
	AMD_Soft_Reset_Flash((ULONG) psBlockAddress);
	// Verify Written Data 
	psAddress = (USHORT *)plAddress;
	for(i=0; i<ullength; i++)
	{
	 	if(*psAddress != ulData[i])
        {
			return 1;
        }
		psAddress++;
	}		
	return 0;
}

///////////////////////////////////////////////////////////////////////////////
//
// AMD Write Buf Abort Reset Flash  
//
// Description:
//   Resets the flash device when in a write buffer abort state.
//
// C Syntax:
//   void AMD_Soft_Reset_Flash(ULONG addr);
//
// Arguments:
//   r0: Any valid address in a flash memory sector.
//
// Notes:
//   Callable from C. Registers r0-r3 are *not* preserved.
//
///////////////////////////////////////////////////////////////////////////////
void AMD_Write_Buf_Abort_Reset_Flash( ULONG plAddress )
{  
	volatile USHORT *address_cs;
	ULONG tmp_ptr;

	// Lower WORD.
	tmp_ptr  = (ULONG) plAddress;
	address_cs = (USHORT *) (tmp_ptr & AMD_ADDRESS_CS_MASK);           
	// Reset Flash to be in Read Array Mode 
    *((vHwdptr)address_cs + AMD_CMD0_ADDR) = AMD_WRT_BUF_ABORT_RESET_CMD0;
    *((vHwdptr)address_cs + AMD_CMD1_ADDR) = AMD_WRT_BUF_ABORT_RESET_CMD1;
    *((vHwdptr)address_cs + AMD_CMD2_ADDR) = AMD_WRT_BUF_ABORT_RESET_CMD2;
	// return to caller
	return;
}

///////////////////////////////////////////////////////////////////////////////
//
// Enable Flash Write Protection
//
// Description:
//				Wiggles the EMIFS WP# signal high to write to Flash devices
//				Control for older EVM's and TEB's also included
///////////////////////////////////////////////////////////////////////////////
void Enable_Flash_WP(void)
{
	ULONG nMIFConfReg;
	ULONG volatile  *pMIFConfReg = (ULONG volatile *) MIF_CONFIG_REG;
	// Enable write protection in the Memory Interface, bit 0 low.
	nMIFConfReg = *pMIFConfReg;
	nMIFConfReg &= 0xFFFFFFFE;
	*pMIFConfReg = nMIFConfReg; 			
	return;
}

///////////////////////////////////////////////////////////////////////////////
//
// Disable Flash Write Protection
//
///////////////////////////////////////////////////////////////////////////////
void Disable_Flash_WP(void)
{
	ULONG nMIFConfReg;
	ULONG volatile  *pMIFConfReg = (ULONG volatile *) MIF_CONFIG_REG;	
	// Disable write protection in FPGA, bit 2 high.
	#if (TICFG_PROC_VER!=HELENDC_V1)		// HelenDC
		#ifdef TICFG_EVM_PRESENT	
			unsigned char volatile  *pDIPSwitchReg = (unsigned char volatile *) FPGA_DIP_SWITCH_REG;
			unsigned char nDIPSwitchReg;
			nDIPSwitchReg = *pDIPSwitchReg;
			nDIPSwitchReg |= 0x04;
			*pDIPSwitchReg = nDIPSwitchReg;
		#endif 
	#endif
	// Disable write protection in TC, bit 0 high.
	nMIFConfReg = *pMIFConfReg;
	nMIFConfReg |= 0x00000001;
	*pMIFConfReg = nMIFConfReg; 				
	return;
}

///////////////////////////////////////////////////////////////////////////////
//
// DownloadToNORFlash
//
// Description:
//   Copies RAM Memory region to Flash region
//
// Arguments:
//   ULONG *startWriteAddress   - Base address of the data to be copied
//   USHORT *startReadAddress   - Base address of the destination address 
//   ULONG  size	            - Number of bytes to copy
//
// Return:
//   Flash Programming Status 
//
// Assumptions:
//   Flash addresses are always on a halfword boundary, and the byte count
//   is always even.
//
///////////////////////////////////////////////////////////////////////////////
void  DownloadToNORFlash(ULONG startWriteAddress,	//R0 Intel Strata Address 
					 ULONG startReadAddress,	//R1 SDRAM Address 
					 ULONG size,				//R2
					 ULONG statusAddress,     	//R3 status address 
   				 	 enum NORFlashType flash_id)
{   
	ULONG  flash_addr;
	long  SizeInBytes;
	ULONG  sdram_src;
	USHORT flash_data;
	USHORT opt_array[16];   //For buffered writes to specific devices 
	ULONG  i;
	
	SizeInBytes = size;
	flash_addr = startWriteAddress;
	sdram_src = startReadAddress;	
	//Print what flash type was found
		
	// Disable flash write protection
	Disable_Flash_WP();
	// Erase the flash where the image will sit	
	EraseNORFlash(flash_addr, SizeInBytes, flash_id);	                   
	//Write to the Flash in this loop		
	printf("Writing the Flash\n");
	while (SizeInBytes > 0)
  	{
    	if((User_Flash_Optimized_Write == 
    		(int (*)(ULONG *, USHORT[], ULONG)) Flash_Do_Nothing) 
			|| (SizeInBytes < 32) || (flash_addr%32))
		{
			flash_data = *((USHORT *) sdram_src);      
			(*User_Flash_Write)((ULONG *) flash_addr, flash_data);      		
			SizeInBytes   -= 2;
			flash_addr += 2;
			sdram_src  += 2;
		}
		else
		{
			for(i = 0; i<16; i++)	 // <- *** INTEL Specific 
			{
				opt_array[i] = *((USHORT *) sdram_src);		  
				sdram_src += 2;
			}										
			(*User_Flash_Optimized_Write)((ULONG *)flash_addr, opt_array, i);
			SizeInBytes -= (i*2);
			flash_addr += (i*2);		
		}
		if ((flash_addr & 0xFFFC0000) == flash_addr)
		{
			printf("Flashed 0x%08X bytes of 0x%08X total bytes\n", (flash_addr - startWriteAddress), size);
		}		 		 		
  	}
  	// Enable flash write protection
  	Enable_Flash_WP();
  	
}

/////////////////////////////////////////////////////////////////////////////////////////////////
//
//Main
//
//	Purpose:
//	Generates some messaging about the tool, Detects Flash devices, Detects OMAP device, 
/////////////////////////////////////////////////////////////////////////////////////////////////
ULONG main(void)
{  
	ULONG  flash_base_addr = (gp_vars->WriteAddress & 0xFFC00000); // Round to 4MB Boundaries 
	enum NORFlashType nor_flash_id;
	
	//point REad Address at whereever the image section is mapped into
	gp_vars->ReadAddress = (ULONG) &image;
	
	printinfo(gp_vars->Size, gp_vars->ReadAddress, gp_vars->WriteAddress);		

	//Try to ID as a NOR Flash first, then a NAND if a NOR can't be found at our address
	nor_flash_id = IdentifyNORFlash(flash_base_addr);		
	if(nor_flash_id == FLASH_NOT_FOUND)		//Try to find a NAND Flash
	{
		printf("No Flash devices have been found\n");
	} else 		//Found a NOR device
	{
		printNORflashtype(nor_flash_id);	
		DownloadToNORFlash(gp_vars->WriteAddress, 
							gp_vars->ReadAddress, 
							gp_vars->Size, 
							(ULONG) gp_vars, 
							nor_flash_id);
		printf("Flash writing completed!\n");  	
	}	
	return 0;  
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本一区二区三区电影| 国产**成人网毛片九色| 欧美日韩一二区| 亚洲第一成人在线| 日韩欧美在线一区二区三区| 蜜桃av一区二区在线观看| 2023国产精品视频| 91色乱码一区二区三区| 亚洲一区二区三区四区五区黄| 欧美四级电影在线观看| 日本一道高清亚洲日美韩| 精品久久久久99| 成人18视频在线播放| 一区二区三区四区乱视频| 欧美浪妇xxxx高跟鞋交| 国产麻豆日韩欧美久久| 亚洲欧美二区三区| 日韩精品中文字幕在线不卡尤物 | 色激情天天射综合网| 亚洲制服丝袜在线| 日韩精品一区二区在线| www.爱久久.com| 婷婷一区二区三区| 国产视频一区二区在线| 欧美日韩一二区| 国产不卡免费视频| 丝袜亚洲精品中文字幕一区| 免费精品视频最新在线| 狠狠色狠狠色综合| 自拍偷拍国产亚洲| 欧美电影一区二区三区| a在线播放不卡| 日日摸夜夜添夜夜添精品视频 | 午夜欧美大尺度福利影院在线看| 精品女同一区二区| 在线看一区二区| 国产一区二区三区综合| 亚洲午夜视频在线观看| 国产午夜精品理论片a级大结局| 欧美视频在线观看一区| 成人综合婷婷国产精品久久| 免费观看日韩电影| 亚洲美女在线一区| 国产亚洲欧美日韩在线一区| 欧美日韩国产综合草草| 99久久婷婷国产| 国产资源在线一区| 视频一区在线播放| 亚洲精选视频免费看| 欧美经典一区二区| 精品少妇一区二区三区在线视频| 中文字幕欧美激情一区| 欧美在线啊v一区| 国产最新精品免费| 天堂午夜影视日韩欧美一区二区| 国产精品视频麻豆| 久久理论电影网| 日韩欧美电影一区| 88在线观看91蜜桃国自产| 色综合天天性综合| heyzo一本久久综合| 国产九色sp调教91| 精品一区二区免费在线观看| 日韩电影在线免费看| 亚洲国产精品一区二区久久 | 日本美女视频一区二区| 一区二区欧美在线观看| 亚洲欧美自拍偷拍| 亚洲人成小说网站色在线| 国产欧美综合在线| 久久青草欧美一区二区三区| 久久久九九九九| 国产日韩三级在线| 精品在线一区二区| 一区二区三区在线视频观看| 国产精品国产三级国产专播品爱网| 久久精品夜色噜噜亚洲aⅴ| 精品国产乱码久久久久久夜甘婷婷| 欧美一区二区精美| 欧美丰满一区二区免费视频| 最新欧美精品一区二区三区| 国产精品毛片无遮挡高清| 中文字幕一区二区视频| 亚洲欧美国产毛片在线| 亚洲一区二区在线免费看| 性欧美大战久久久久久久久| 蜜桃在线一区二区三区| 国产精品一区久久久久| 成人午夜精品一区二区三区| 99精品在线免费| 欧日韩精品视频| 欧美一区日本一区韩国一区| 精品嫩草影院久久| 国产精品黄色在线观看| 亚洲美女免费在线| 亚洲成人动漫在线观看| 麻豆成人av在线| 国产成a人亚洲| 91精品福利在线| 日韩午夜激情av| 欧美激情一区三区| 一区二区三区在线影院| 日韩av电影天堂| 风间由美一区二区三区在线观看 | 5566中文字幕一区二区电影| 日韩精品中午字幕| 国产精品乱人伦| 一区二区三区欧美日| 国产黄色精品网站| eeuss鲁片一区二区三区 | 亚洲a一区二区| 激情综合五月婷婷| 日本久久电影网| 日韩欧美一区二区免费| 国产精品嫩草影院com| 亚洲a一区二区| 成熟亚洲日本毛茸茸凸凹| 欧美日韩一区 二区 三区 久久精品| 欧美一卡二卡三卡四卡| 中文字幕精品三区| 三级在线观看一区二区| 成人app下载| 日韩欧美国产午夜精品| 亚洲综合色成人| 91精品一区二区三区久久久久久| 国产精品视频一区二区三区不卡| 亚洲观看高清完整版在线观看| 国精品**一区二区三区在线蜜桃| 一本色道久久综合亚洲精品按摩| 精品免费一区二区三区| 亚洲一区免费观看| 成人h动漫精品一区二| 日本韩国一区二区| 中文字幕一区二区三区视频| 亚洲成a人v欧美综合天堂下载| 麻豆一区二区99久久久久| 91毛片在线观看| 久久男人中文字幕资源站| 视频一区视频二区中文字幕| 91原创在线视频| 久久蜜桃av一区精品变态类天堂| 午夜不卡av在线| 欧美最新大片在线看| 国产精品免费视频一区| 国产一区999| 日韩欧美在线影院| 日韩va亚洲va欧美va久久| 日本丶国产丶欧美色综合| 亚洲国产高清在线观看视频| 久久不见久久见免费视频1| 欧美浪妇xxxx高跟鞋交| 亚洲高清视频中文字幕| 欧美中文字幕一区二区三区亚洲 | 欧美日韩一区二区在线观看视频| 国产日韩欧美精品一区| 国产制服丝袜一区| 精品日韩在线一区| 麻豆成人av在线| 欧美成人精品3d动漫h| 日本精品视频一区二区| 国产精品全国免费观看高清| 国产一区二区三区久久久 | 欧美mv和日韩mv国产网站| 日韩影院免费视频| 4438x成人网最大色成网站| 亚洲成人你懂的| 欧美日韩一级片网站| 亚洲成av人片在www色猫咪| 日本韩国欧美在线| 亚洲va韩国va欧美va精品 | 精品日韩欧美在线| 久久精品国产99| 久久免费看少妇高潮| 国产精品77777竹菊影视小说| 精品日本一线二线三线不卡| 国产曰批免费观看久久久| 久久久国产午夜精品| 99精品桃花视频在线观看| 一区二区三区在线播放| 色狠狠av一区二区三区| 洋洋成人永久网站入口| 538prom精品视频线放| 精品夜夜嗨av一区二区三区| 久久久午夜精品| 99久久精品情趣| 天天色图综合网| 精品成人免费观看| 欧美成人欧美edvon| 亚洲国产精品av| 色综合天天综合网天天看片| 亚洲一区二区三区四区在线观看 | 欧美视频日韩视频在线观看| 亚洲电影你懂得| 日韩欧美国产综合一区| 国产盗摄精品一区二区三区在线| 亚洲欧洲精品一区二区三区不卡| 欧美在线观看禁18| 精一区二区三区| 亚洲日韩欧美一区二区在线| 在线播放欧美女士性生活|