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

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

?? fat_sys.c

?? fat16文件系統源碼。需要的請下
?? 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一区二区三区免费野_久草精品视频
国产99久久久久久免费看农村| 亚洲午夜在线观看视频在线| 欧美日韩亚洲综合一区| av高清不卡在线| 99久久综合国产精品| 国产成人精品在线看| 国产精品影视网| 国产69精品久久久久毛片| 国产一区不卡视频| 成人av网址在线| 成人精品免费看| 成人蜜臀av电影| 日本久久一区二区三区| 欧美精品在线观看一区二区| 777奇米成人网| 精品国产凹凸成av人导航| 日本一区二区三区四区| 中文字幕一区二区三区av| 亚洲视频中文字幕| 午夜婷婷国产麻豆精品| 蜜臀精品一区二区三区在线观看 | 国产精品一二三四| 国产成人av电影| 欧美亚洲一区三区| 欧美电影免费提供在线观看| 久久婷婷色综合| 中文字幕五月欧美| 视频在线观看91| 国产91在线看| 欧美精品三级日韩久久| 久久久久亚洲蜜桃| 亚洲精品中文字幕在线观看| 青草av.久久免费一区| 成人免费av资源| 欧美一区二区三区免费| 日本一区二区三区视频视频| 午夜精品国产更新| 不卡视频免费播放| 日韩免费一区二区三区在线播放| 国产欧美日韩精品在线| 日韩电影在线一区二区三区| 成年人网站91| 久久综合给合久久狠狠狠97色69| 亚洲婷婷综合久久一本伊一区| 午夜精品久久久久| 成人听书哪个软件好| 欧美一二三区在线| 亚洲免费看黄网站| 国产一区二区三区免费观看| 欧美日韩久久一区| 亚洲精品免费一二三区| 国产精品18久久久久| 欧美一级黄色片| 亚洲午夜免费福利视频| eeuss鲁一区二区三区| 欧美一区二区久久久| 亚洲一区二区精品视频| av在线一区二区三区| 国产日韩三级在线| 久久69国产一区二区蜜臀| 欧美二区乱c少妇| 亚洲视频精选在线| 91在线视频播放| 中文字幕电影一区| 国产精品亚洲午夜一区二区三区 | 日本91福利区| 欧美中文字幕一区二区三区亚洲| 椎名由奈av一区二区三区| 风间由美一区二区三区在线观看 | 欧洲亚洲国产日韩| 亚洲蜜桃精久久久久久久| 丁香婷婷综合五月| 国产精品毛片a∨一区二区三区| 国产伦精品一区二区三区免费 | 久久精品国产在热久久| 欧美一区二区在线观看| 欧美aaa在线| 精品国产一二三区| 粉嫩蜜臀av国产精品网站| 欧美不卡在线视频| 国产伦精一区二区三区| 国产精品久久久久影院色老大| a美女胸又www黄视频久久| 国产精品每日更新| 色综合久久中文综合久久97| 亚洲男人电影天堂| 欧美放荡的少妇| 国内精品久久久久影院色| 精品黑人一区二区三区久久| 国产成人综合网站| 亚洲人精品午夜| 欧美日韩在线播| 国产在线不卡一区| 日韩一区日韩二区| 欧美福利视频导航| 国产高清不卡一区| 亚洲一级在线观看| 欧美成人一区二区三区| 岛国av在线一区| 亚洲一区二区欧美激情| 欧美一区二区免费| 97se狠狠狠综合亚洲狠狠| 亚洲不卡在线观看| 国产校园另类小说区| 一本久久精品一区二区| 久久精品国产99国产精品| 亚洲天堂2014| 精品免费99久久| 在线看国产一区| 激情欧美日韩一区二区| 亚洲精品你懂的| 精品国产乱码久久久久久浪潮 | 国产一区二区主播在线| 亚洲人一二三区| 久久夜色精品国产欧美乱极品| 成人av网站大全| 加勒比av一区二区| 首页亚洲欧美制服丝腿| 国产精品日日摸夜夜摸av| 欧美狂野另类xxxxoooo| 国产不卡高清在线观看视频| 奇米一区二区三区| 亚洲综合久久久久| 国产精品妹子av| 久久精品欧美日韩精品| 4438成人网| 欧美图片一区二区三区| 99精品久久只有精品| 激情综合色播五月| 日韩国产精品久久| 亚洲国产日韩一区二区| 亚洲欧美另类在线| 国产精品萝li| 国产日韩精品一区二区浪潮av| 91麻豆精品国产综合久久久久久| 91搞黄在线观看| 99视频精品在线| youjizz国产精品| 成人福利在线看| 国产成人精品一区二区三区四区| 视频一区二区国产| 亚洲综合成人在线| 亚洲久草在线视频| 亚洲精品福利视频网站| 亚洲精品美国一| 亚洲男女毛片无遮挡| 亚洲精品免费在线观看| 一区二区日韩电影| 一区二区三区丝袜| 亚洲国产欧美在线人成| 亚洲国产一区二区a毛片| 一区二区三区四区蜜桃| 亚洲午夜久久久久| 丝瓜av网站精品一区二区| 五月天亚洲婷婷| 美腿丝袜亚洲一区| 国内精品视频666| 国产suv精品一区二区6| 成人性生交大合| 91视频免费看| 在线观看免费成人| 91精品国产91久久久久久最新毛片| 欧美精品乱码久久久久久| 欧美精品日韩精品| 久久老女人爱爱| 日本一区二区三区高清不卡| 国产精品天美传媒沈樵| 亚洲另类色综合网站| 五月天婷婷综合| 国产久卡久卡久卡久卡视频精品| 大美女一区二区三区| 色国产综合视频| 制服丝袜亚洲精品中文字幕| 精品国产欧美一区二区| 国产精品久久久久久久久快鸭| 一区二区三区成人在线视频| 日本视频在线一区| 成人精品免费网站| 欧美日韩不卡一区| 久久―日本道色综合久久| 国产精品不卡视频| 美女mm1313爽爽久久久蜜臀| 国模大尺度一区二区三区| av成人免费在线观看| 制服丝袜亚洲播放| 国产精品视频线看| 日韩经典一区二区| 成人av动漫在线| 日韩欧美二区三区| 中文字幕一区在线观看视频| 亚洲电影一区二区三区| 国产精品小仙女| 91精品国产入口| 自拍偷拍亚洲综合| 国产一区二区三区蝌蚪| 欧美日韩一卡二卡三卡| 国产亲近乱来精品视频| 另类欧美日韩国产在线| 色爱区综合激月婷婷| 国产亚洲一区字幕|