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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? fat_sys.c

?? fat16文件系統(tǒng)源碼。需要的請下
?? C
?? 第 1 頁 / 共 3 頁
字號:
//****************************************************************
// FileName:    fat_dir.c                                        
// Description: file system control                               
// Version:     1.0                                               
// Histrory:                                                      
//            1.0   chanjl  2003.11.10    create the module    
//****************************************************************

#include "DataType.h"
#include "FTC32t.h"
#include "Define.h"
#include "ftc32t_m.h"
#include "register.h"
#include "global_variable.h"

#include "fat.h" 
#include "fat_h.h"   
#include <string.h>
void fat_count_sector(void)
{
	if(fat_buf_count == fat_sector_size)
	{
		fat_buf_count=0;
	    phy_read_sector(); 
	}
}

/*F**************************************************************************
* NAME: fat_get_clusters
*----------------------------------------------------------------------------
* PARAMS:
*   chain:   allocation list address
*   nb_frag: maximum number of fragment 
*
* return:
*   - OK: allocation done
*   - KO: allocation done but truncated: file too much fragmented
*----------------------------------------------------------------------------
* PURPOSE:
*   Prepare a list of the file clusters:
*     chain[n].cluster contains the starting cluster number of a fragment
*     chain[n].number contains the number of contiguous clusters in fragment
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   File cluster list is limited by the nb_frag parameter.
*   If memory is too much fragmented, file may not be fully played.
*   Last list item always has single cluster
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
#if COMPILE_FAT_16 == TRUE
byte fat16_get_clusters (fat_st_clust_chain xdata *chain, Byte nb_frag)
{
	Byte   index; 
	/* index in chain */
	Uint16 new_cluster;
	Uint16 old_cluster;
	nb_frag = nb_frag - 1;                    /* set limit (index start at 0) */

  	/* build the first entry of the allocation list */
  	chain[0].number = 1;
  	chain[0].cluster.l = fat_cache.current.start_cluster.l - 2; /* 2 = 1st cluster */
  	old_cluster = fat_cache.current.start_cluster.l;
  	index = 0;

   	fat_buf_count = (old_cluster % (fat_sector_size >> 1)) << 1;
	phy_read_open(fat_ptr_fats + (old_cluster / (fat_sector_size >> 1)));
	/* read first entry */
	phy_read_sector();

	((Byte*)&new_cluster)[1] = gl_buffer[fat_buf_count];
	((Byte*)&new_cluster)[0] = gl_buffer[fat_buf_count + 1];

	while (new_cluster != LAST_CLUSTER16)   /* loop until last cluster found */
	{
  		if ((new_cluster == (old_cluster + 1)) && (chain[index].number != MAX_CL_PER_FRAG))
  		{ /* contiguous cluster up to 255 */
	        chain[index].number++;
			fat_buf_count = fat_buf_count + 2;
			fat_count_sector();
  		}
  		else
  		{ /* compute fragmentation */
	        index++;
	        chain[index].number = 1;
	        chain[index].cluster.w[1] = new_cluster - 2;  /* 2 = 1st cluster */

	        fat_buf_count=(new_cluster % (fat_sector_size >> 1)) << 1;
			phy_read_close();  
		    phy_read_open(fat_ptr_fats + (new_cluster / (fat_sector_size >> 1)));
		    phy_read_sector();      
  		}

  		old_cluster = new_cluster;

  		if (index == nb_frag)
  		{ /* end of chain reached */
   		 	/* last fragment always contains a single cluster */
    		chain[nb_frag].number = 0;          /* end of chain marker */
    		fat_last_clust_index = nb_frag;
    		return  KO;                         /* file too much fragmented */
  		}
  		else
  		{
    		/* read new entry */
      		((Byte *)&new_cluster)[1]= gl_buffer[0+fat_buf_count];
	  		((Byte *)&new_cluster)[0]= gl_buffer[1+fat_buf_count];
  		}
	}	

	fat_last_clust_index = index;
//	fat_get_clusters_end(chain,index);
	return OK;
}
#endif //COMPILE_FAT_16

#if COMPILE_FAT_12 == TRUE

byte fat12_get_clusters (fat_st_clust_chain xdata *chain, Byte nb_frag)
{
	byte   fat12_parity;
	Byte   index; 
	/* index in chain */
//	Byte   sector_count;
	Uint16 i; 
	Uint16 new_cluster;
	Uint16 old_cluster;
//	Uint16 count;
	Uint16 fat12_cluster;
	nb_frag = nb_frag - 1;                    /* set limit (index start at 0) */

  	/* build the first entry of the allocation list */
  	chain[0].number = 1;
  	chain[0].cluster.l = fat_cache.current.start_cluster.l - 2; /* 2 = 1st cluster */
  	old_cluster = fat_cache.current.start_cluster.l;
  	index = 0;

 	/* compute offset in sector */
	phy_read_open(fat_ptr_fats);
	phy_read_sector();

	fat_buf_count = 0; 

	fat12_parity = 0;
	i = old_cluster + 1;
	do
	{
  		if (fat12_parity == 0)
  		{
    		((Byte *)&fat12_cluster)[1]= gl_buffer[fat_buf_count++];

			fat_count_sector();

	        ((Byte *)&fat12_cluster)[0]= gl_buffer[fat_buf_count++];
			fat_count_sector();

	        new_cluster = (fat12_cluster & 0x00FF);
	        new_cluster += (fat12_cluster & 0x0F00);
	        fat12_parity = 1;
  		}
      	else
      	{
	        ((Byte *)&fat12_cluster)[1]= gl_buffer[fat_buf_count++];
			fat_count_sector();
	        new_cluster = (fat12_cluster & 0xF000) >> 12;
	        new_cluster += (fat12_cluster & 0x00FF) << 4;
	        fat12_parity = 0;
      	}
      	i--;
    }
    while (i != 0);

	while (new_cluster != LAST_CLUSTER12)   /* loop until last cluster found */
	{
		if ((new_cluster == (old_cluster + 1)) && (chain[index].number != MAX_CL_PER_FRAG))
		{ /* contiguous cluster up to 255 */
			chain[index].number++;
            //if(count>=pageSize)			
		}
		else
		{
			/* add fragmentation */
			index++;
			chain[index].number = 1;
			chain[index].cluster.w[1] = new_cluster - 2;  /* 2 = 1st cluster */
	        for (i = new_cluster - old_cluster - 1; i != 0; i--)
	        {  /* dummy FAT read */
	          	if (fat12_parity == 0)
	          	{
	            	((Byte *)&fat12_cluster)[1]= gl_buffer[fat_buf_count++];
					fat_count_sector();

	            	((Byte *)&fat12_cluster)[0]= gl_buffer[fat_buf_count++];
					fat_count_sector();
		            fat12_parity = 1;
	          	}
	          	else
	          	{
		            ((Byte *)&fat12_cluster)[1]= gl_buffer[fat_buf_count++];
					fat_count_sector();
		            fat12_parity = 0;
	          	}
	       	}
		}

		old_cluster=new_cluster;

		if(index==nb_frag)
		{/* end of chain reached */
            /* last fragment always contains a single cluster */
			chain[nb_frag].number = 0;          /* end of chain marker */
			fat_last_clust_index = nb_frag;
			return KO;                          /* file too much fragmented */
		}
        else
		{
			/* read new entry */
            if(fat12_parity == 0)
            {
    			((Byte *)&fat12_cluster)[1]= gl_buffer[fat_buf_count++];
				fat_count_sector();

    			((Byte *)&fat12_cluster)[0]= gl_buffer[fat_buf_count++];
				fat_count_sector();

                new_cluster = (fat12_cluster & 0x00FF);
                new_cluster += (fat12_cluster & 0x0F00);
                fat12_parity = 1;
            }
            else
            {
                ((Byte *)&fat12_cluster)[1] = gl_buffer[fat_buf_count++];
				fat_count_sector();

                new_cluster = (fat12_cluster & 0xF000) >> 12;
                new_cluster += (fat12_cluster & 0x00FF) << 4;
                fat12_parity = 0;
            }
		}
 	}//while
	fat_last_clust_index = index;
//	fat_get_clusters_end(chain,index);
	return OK;
}

#endif //COMPILE_FAT_12


#if COMPILE_FAT_32 == TRUE
byte fat32_get_clusters (fat_st_clust_chain xdata *chain, Byte nb_frag)
{
	Byte   index; 
	/* index in chain */
	Union32 new_cluster;
	Union32 old_cluster;
	nb_frag = nb_frag - 1;                    /* set limit (index start at 0) */

  	/* build the first entry of the allocation list */
  	chain[0].number = 1;
  	chain[0].cluster.l = fat_cache.current.start_cluster.l - 2; /* 2 = 1st cluster */
  	old_cluster.l = fat_cache.current.start_cluster.l;
  	index = 0;

	fat_buf_count = (old_cluster.l % (fat_sector_size >> 2)) << 2;

	phy_read_open(fat_ptr_fats + (old_cluster.l / (fat_sector_size >> 2)));
	/* read first entry */
	phy_read_sector(); 

	new_cluster.b[3] = gl_buffer[0+fat_buf_count];
	new_cluster.b[2] = gl_buffer[1+fat_buf_count];
	new_cluster.b[1] = gl_buffer[2+fat_buf_count];
	new_cluster.b[0] = gl_buffer[3+fat_buf_count];

	while(new_cluster.l != LAST_CLUSTER32) /* loop until last cluster found */
	{
		if ((new_cluster.l == (old_cluster.l + 1)) && (chain[index].number != MAX_CL_PER_FRAG))
		{/* contiguous cluster up to 255 */
			chain[index].number++;
			fat_buf_count=fat_buf_count+4;
			fat_count_sector();
		}
		else
		{/* compute fragmentation */
			index++;
			chain[index].number = 1;
	        chain[index].cluster.l = new_cluster.l - 2;  /* 2 = 1st cluster */
	
	        fat_buf_count=(new_cluster.l % (fat_sector_size >> 2))<<2;
			phy_read_close();  
		    phy_read_open(fat_ptr_fats + (new_cluster.l / (fat_sector_size >> 2)));
		    phy_read_sector();	
		}
		old_cluster.l = new_cluster.l;

	    if (index == nb_frag)
	    { /* end of chain reached */
	       /* last fragment always contains a single cluster */
	       chain[nb_frag].number = 0;          /* end of chain marker */
	       fat_last_clust_index = nb_frag;
	       return  KO;                         /* file too much fragmented */
	    }
	    else
	    {
	        /* read new entry */
			new_cluster.b[3] = gl_buffer[0+fat_buf_count];
			new_cluster.b[2] = gl_buffer[1+fat_buf_count];
			new_cluster.b[1] = gl_buffer[2+fat_buf_count];
			new_cluster.b[0] = gl_buffer[3+fat_buf_count];
	    }
	}
	fat_last_clust_index = index;	
	//fat_get_clusters_end(chain,index);
	return OK;
}
#endif //COMPILE_FAT_32

byte fat_get_clusters (fat_st_clust_chain xdata *chain, Byte nb_frag)
{
	
	if(fat_type_id == FAT_IS_16)
	{
#if COMPILE_FAT_16 == TRUE
		if(fat16_get_clusters (chain,  nb_frag) == KO)
			return KO;	
#endif
	}
	else if(fat_type_id == FAT_IS_12)
	{
#if COMPILE_FAT_12 == TRUE	
	if(fat12_get_clusters (chain,  nb_frag) == KO)
			return KO;	
#endif
	}
	else if(fat_type_id == FAT_IS_32)
	{
#if COMPILE_FAT_32 == TRUE
		if(fat32_get_clusters (chain,  nb_frag) == KO)
			return KO;
#endif
	}

  	phy_read_close();
  	/* end of file: last fragment must always contain a single cluster */
  	if (chain[fat_last_clust_index].number == 1)
  	{ /* last cluster is the current one */
 //   	fat_last_clust_index = index;
    	chain[fat_last_clust_index].number = 0; /* end of chain marker */
  	}
  	else
  	{ 	
    	chain[fat_last_clust_index ].number--;
		fat_last_clust_index++;  // = index + 1;
    	chain[fat_last_clust_index].cluster.l = chain[fat_last_clust_index - 1].cluster.l + chain[fat_last_clust_index - 1].number;
    	chain[fat_last_clust_index].number = 0; /* end of chain marker */
  	}

  	return OK;
}

/*F**************************************************************************
* NAME: fat_set_clusters
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   - OK: allocation done
*   - KO: allocation cannot be done : no free cluster
*----------------------------------------------------------------------------
* PURPOSE:
*   Prepare a list of the free clusters:
*     chain[n].cluster contains the starting cluster number of a fragment
*     chain[n].number contains the number of contiguous clusters in fragment
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   Free cluster list is limited by the nb_frag parameter.
*   If memory is too much fragmented, created file may be limited in size.
*   Last list item always has single cluster
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/

#if COMPILE_FAT_16 == TRUE
byte fat16_set_clusters (fat_st_clust_chain xdata *chain, Byte nb_frag)
{
	Byte     cluster_free;//,flag;

	Byte    index;
//	Uint16  count;
//  word    sector_count; // 2004.2.25 modify
//	Uint16  cluster,cluster2start;
	Uint16  max_cluster;
	Union16 tmp_cluster;
	Uint16 cluster,cluster2start;
//	Uint16 tmp_cluster;
	

	Uint16 nb_cluster;
	Uint16 max,min;
   	max_cluster = fat_count_of_clusters;
    //max_cluster = fat_max_cluster_number;//2004.3.13 modify

  	index = 0;
  	nb_cluster = 0;
  	cluster_free = FALSE;

    phy_read_open(fat_ptr_fats);
	phy_read_sector();

	cluster = 0;
	cluster2start = 0;//2;

	max = fat_sector_size>>1;
	min = 0;
	fat_buf_count = fat_sector_size>>2;
	do
	{
		while((max - min) > 1)
		{
		   	tmp_cluster.b[1] = gl_buffer[(fat_buf_count<<1)];   
		   	tmp_cluster.b[0] = gl_buffer[(fat_buf_count<<1)+1];
	  
		   	if(tmp_cluster.w == 0x0000)
		   	{
		       	max = fat_buf_count;
		   	   	fat_buf_count = ((fat_buf_count - min) >> 1) + min ;			   
		   	}
		   	else
		   	{
		       	min = fat_buf_count;
		   	   	fat_buf_count = ((max - fat_buf_count) >> 1) + fat_buf_count;		  
		   	}			   
		}
        if(max == 1)
        {
		    tmp_cluster.b[1] = gl_buffer[0];   
		    tmp_cluster.b[0] = gl_buffer[1];
			if(tmp_cluster.w == 0x0000)
			{
				max = max - 1;
			}
	    }
  		 	 	 
	 	if(max == (fat_sector_size>>1))
		{
			phy_read_sector();
            max = fat_sector_size>>1;
			min = 0;
		    fat_buf_count = fat_sector_size>>2;
			cluster += max;
            //cluster2start += n;
		}
		else
		{
		    fat_buf_count = max*2;
			cluster += (fat_buf_count >> 1);
			//cluster2start += count / 2;
			cluster_free = TRUE;
			break;
		}
	}while(cluster < max_cluster);

 	cluster2start = cluster;
 	cluster -= 2;

	if (!cluster_free)
	{
  		return KO;                            /* no free cluster found */
	}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美国产精品一区二区三区| 亚洲嫩草精品久久| 91麻豆国产香蕉久久精品| 性做久久久久久免费观看| 国产欧美一区二区精品久导航| 在线观看91精品国产入口| 国产在线观看一区二区| 亚洲一区二区三区四区在线观看 | 韩国精品主播一区二区在线观看 | 欧美女孩性生活视频| 丁香六月久久综合狠狠色| 男男gaygay亚洲| 亚洲国产精品影院| ...xxx性欧美| 中文字幕 久热精品 视频在线 | 精品无码三级在线观看视频| 亚洲一级二级三级在线免费观看| 国产精品人妖ts系列视频| 精品国产伦理网| 在线播放中文一区| 一本久久a久久精品亚洲| 成人黄动漫网站免费app| 国产又粗又猛又爽又黄91精品| 香蕉成人伊视频在线观看| 亚洲精品中文字幕乱码三区| 中文字幕国产精品一区二区| 久久久久久亚洲综合影院红桃| 欧美一级xxx| 777a∨成人精品桃花网| 欧美亚洲国产一区二区三区| 色哟哟一区二区三区| 97精品视频在线观看自产线路二| 国产成人免费视| 国产成人精品影视| 国产精品 日产精品 欧美精品| 国产一区在线精品| 国产一区福利在线| 国产一区二区三区国产| 黑人巨大精品欧美黑白配亚洲| 老司机精品视频一区二区三区| 日本欧美肥老太交大片| 麻豆精品在线看| 麻豆一区二区三区| 国产一区二区三区不卡在线观看| 国产伦精品一区二区三区视频青涩| 黄色日韩三级电影| 国产精品影音先锋| 懂色av一区二区三区免费看| 国产成人综合亚洲网站| 成人综合婷婷国产精品久久| 成人一级黄色片| 99久久99久久综合| 在线视频综合导航| 在线不卡免费av| 久久人人超碰精品| 国产精品久久久一本精品 | 久久成人18免费观看| 韩国精品久久久| 成人av免费网站| 欧美午夜精品理论片a级按摩| 欧美久久一区二区| 欧美r级在线观看| 国产精品色眯眯| 一区二区久久久| 美女一区二区三区在线观看| 激情文学综合丁香| 91美女蜜桃在线| 正在播放一区二区| 国产亚洲欧美在线| 亚洲一区二区欧美激情| 激情小说欧美图片| 色狠狠桃花综合| 日韩亚洲欧美一区| 国产精品美女久久久久久久| 亚洲国产日韩精品| 国产尤物一区二区| 在线看国产一区二区| 日韩一卡二卡三卡| 国产精品国模大尺度视频| 午夜一区二区三区视频| 国产精品一色哟哟哟| 精品1区2区3区| 国产喷白浆一区二区三区| 亚洲国产一区在线观看| 国内精品嫩模私拍在线| 91麻豆国产福利在线观看| 日韩一区二区免费电影| 亚洲人午夜精品天堂一二香蕉| 日本午夜一区二区| 99久久久久免费精品国产| 日韩一卡二卡三卡四卡| 亚洲激情自拍视频| 国产成人无遮挡在线视频| 欧美精品一二三区| 自拍偷拍欧美精品| 国产一区二区在线观看免费| 欧美午夜片在线看| 国产精品嫩草99a| 久久国内精品视频| 欧美日韩dvd在线观看| 国产精品久久久久久久久免费樱桃 | 国产麻豆欧美日韩一区| 欧美吞精做爰啪啪高潮| 欧美韩日一区二区三区四区| 日本色综合中文字幕| 91网址在线看| 中文字幕第一区| 精品无人码麻豆乱码1区2区| 欧美揉bbbbb揉bbbbb| 国产精品丝袜一区| 精油按摩中文字幕久久| 欧美三级三级三级爽爽爽| 国产精品久久久久久妇女6080| 另类人妖一区二区av| 欧美日韩一区二区三区高清| 亚洲丝袜另类动漫二区| 成人性生交大片免费看中文网站| 精品奇米国产一区二区三区| 亚洲3atv精品一区二区三区| 日本久久精品电影| 亚洲欧美一区二区视频| 成人黄色小视频在线观看| 国产午夜精品久久久久久久| 秋霞午夜鲁丝一区二区老狼| 欧美日韩一二区| 亚洲一区二区免费视频| 色av成人天堂桃色av| 亚洲欧美视频在线观看| 成人成人成人在线视频| 国产欧美日韩在线视频| 国产麻豆精品95视频| 2020国产精品| 激情综合网天天干| 精品成人一区二区三区四区| 免费成人在线网站| 日韩一区二区不卡| 久久电影网站中文字幕| 欧美电视剧免费全集观看| 青青草国产成人av片免费| 日韩欧美亚洲一区二区| 老司机免费视频一区二区| 精品久久久三级丝袜| 韩国一区二区视频| 国产欧美精品一区| 成人午夜激情影院| |精品福利一区二区三区| 色综合久久中文字幕综合网| 1024国产精品| 91福利国产精品| 午夜视频在线观看一区二区三区| 91精品啪在线观看国产60岁| 免费成人在线影院| 国产亚洲欧美一区在线观看| 成人高清视频在线观看| 亚洲乱码国产乱码精品精可以看 | 国产午夜一区二区三区| 成人黄页毛片网站| 亚洲综合男人的天堂| 91精品国产综合久久久久久 | av激情亚洲男人天堂| 亚洲激情第一区| 69堂亚洲精品首页| 国模娜娜一区二区三区| 国产精品网友自拍| 精品视频一区二区不卡| 狠狠v欧美v日韩v亚洲ⅴ| 中文字幕在线一区二区三区| 欧美在线短视频| 久久精品免费观看| 自拍偷拍国产精品| 日韩亚洲欧美中文三级| jlzzjlzz欧美大全| 首页亚洲欧美制服丝腿| 国产欧美在线观看一区| 欧美性大战久久久| 国产一区二区在线视频| 亚洲一区二区三区四区五区黄| 精品美女被调教视频大全网站| av资源网一区| 喷白浆一区二区| 亚洲麻豆国产自偷在线| 日韩三级视频在线看| 91麻豆精东视频| 国产一区视频导航| 亚洲chinese男男1069| 国产欧美精品在线观看| 在线电影欧美成精品| 成a人片亚洲日本久久| 日本成人在线看| 亚洲免费色视频| 久久午夜羞羞影院免费观看| 91国产精品成人| 国产精品一区二区91| 日韩福利电影在线观看| 国产精品久久久久久久久免费樱桃 | 精品久久久久99| 91国内精品野花午夜精品| 国产成a人亚洲精| 日本一不卡视频| 亚洲午夜日本在线观看|