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

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

?? fat.c

?? ATMEL 89c51sndc mp3外接硬盤源碼
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*C**************************************************************************
* NAME:         fat.c
*----------------------------------------------------------------------------
* Copyright (c) 2002 Atmel.
*----------------------------------------------------------------------------
* RELEASE:      snd1c-demo-hdd-0_2_0      
* REVISION:     1.1     
*----------------------------------------------------------------------------
* PURPOSE:
* FAT32 file-system basics functions
* 
* NOTES:
* Supports only the first partition
* Supports only 512 bytes sector size
* Supports only file fragmentation < MAX_FILE_FRAGMENT_NUMBER
* Supports only one file openned at a time
*
* Global Variables:
*   - gl_buffer: array of bytes in pdata space
*****************************************************************************/

/*_____ I N C L U D E S ____________________________________________________*/

#include "config.h"                         /* system configuration */
#include "..\mem\hard.h"                    /* low level function definition */
#include "file.h"                           /* file function definition */
#include "fat.h"                            /* fat file-system definition */


/*_____ M A C R O S ________________________________________________________*/


/*_____ D E F I N I T I O N ________________________________________________*/

extern  pdata Byte    gl_buffer[];

char    pdata *lfn_name = &(gl_buffer[32]); /* long filename limited to MAX_FILENAME_LEN chars */

xdata Byte fat_buf_sector[MAX_DIRECTORY_FILE]; /* 512 bytes buffer */

/* disk management */
static  data  Uint32  fat_ptr_fats;         /* address of the first byte of FAT */
static  data  Uint32  fat_ptr_data;         /* address of the first byte of data */
static  data  Byte    fat_cluster_size;     /* cluster size (sector count) */
static  data  Byte    fat_cluster_mask;     /* mask for end of cluster test */

static  bdata bit     dir_is_root;          /* TRUE: point the root directory  */
static  bdata bit     fat_is_fat16;         /* TRUE: FAT16 - FALSE: FAT12 */
static  bdata bit     fat_is_fat32;         /* TRUE: FAT32 - FALSE: FAT12/FAT16 */
static  bdata bit     fat_open_mode;        /* READ or WRITE */
static  bdata bit     fat_2_is_present;     /* TRUE: 2 FATs - FALSE: 1 FAT */
static  bdata bit     flag_end_disk_file;

static  xdata Uint32  fat_count_of_clusters;/* number of cluster - 2 */
static  xdata Union32 fat_file_size;
static  xdata Uint32  fat_fat_size;         /* FAT size in sector count */


/* directory management */
static  xdata fat_st_clust_chain dclusters[MAX_DIR_FRAGMENT_NUMBER];
                                            /* cluster chain for the current directory */
static  idata Uint16  fat_dclust_byte_count;/* byte counter in directory sector */

static  idata Uint16  fat_dchain_index;     /* the number of the fragment of the dir, in fact
                                               the index of the table in the cluster chain */
static  idata Byte    fat_dchain_nb_clust;  /* the offset of the cluster from the first cluster
                                               of the dir fragment */
static  xdata Byte    fat_last_dclust_index;/* index of the last cluster in directory chain */

static  idata Uint16  fat_dir_list_index;   /* index of current entry in dir list */
static  idata Uint16  fat_dir_list_last;    /* index of last entry in dir list */
static  xdata Uint32  fat_dir_start_sect;   /* start sector of dir list */
static  idata Uint32  fat_dir_current_sect; /* sector of selected entry in dir list */
static  xdata Uint32  fat_dir_current_offs; /* entry offset from fat_dir_current_sect */

static  xdata fat_st_cache   fat_cache;     /* The cache structure, see the .h for more info */
static  xdata char  ext[3];                 /* file extension (limited to 3 characters) */


/* file management */
static  xdata fat_st_clust_chain fclusters[MAX_FILE_FRAGMENT_NUMBER];
                                            /* cluster chain for the current file */
static  idata  Byte    fat_last_clust_index; /* index of the last cluster in file chain */

static  data  Uint16   fat_fclust_byte_count;/* byte counter in file cluster */

static  idata  Byte    fat_fchain_index;     /* the number of the fragment of the file, in fact
                                               the index of the table in the cluster chain */
              
static  idata  Uint16  fat_fchain_nb_clust;  /* the offset of the cluster from the first cluster
                                               of the file fragment */

static xdata  Uint32  fat_current_file_size;
static xdata  Uint32  fat_rootclus_fat32;                  /* root cluster address */
static bdata bit fat_last_dir_cluster_full;
static bdata bit fat_no_entries_free;
static xdata Uint16 fat_total_clusters;
static xdata Uint32 last_free_cluster;

/* Mode repeat A/B variables */
static xdata  Byte    fat_fchain_index_save;         
static xdata  Byte    fat_fchain_nb_clust_save;
static xdata  Uint16  fat_fclust_byte_count_save;

xdata Byte current_ext;

idata Uint16 fat_current_end_entry_position;
idata Uint16 fat_current_start_entry_position;
xdata Uint16 fat_nb_deleted_entries;
xdata Uint16 fat_nb_total_entries;


/*_____ D E C L A R A T I O N ______________________________________________*/

static  void    fat_get_dir_entry (fat_st_dir_entry xdata *);
static  void    fat_get_dir_file_list (Byte);
static  bit     fat_get_clusters (fat_st_clust_chain xdata *, Byte);
static  bit     fat_get_free_clusters (bit);
static  bit     fat_dseek (Int16);
static  Byte    fat_dgetc (void);


/*F**************************************************************************
* NAME: fat_install
*----------------------------------------------------------------------------
* PARAMS:
*
* return:
*   - OK: intallation succeeded
*   - KO: - partition 1 not active
*         - FAT type is not FAT16
*         - sector size is not 512 bytes
*         - MBR or PBR signatures are not correct
*         - low level read open failure
*----------------------------------------------------------------------------
* PURPOSE:
*   Install the fat system, read mbr, bootrecords...
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   if MBR not found, try to mount unpartitionned FAT
*   sector size is fixed to 512 bytes to simplify low level drivers
*   fat_ptr_fats = partition offset + nb_reserved_sector
*----------------------------------------------------------------------------
* REQUIREMENTS:
*****************************************************************************/
bit fat_install (void)
{          
Byte i;
Uint32 tot_sect;
Uint32 fat_nb_sector;
Uint16 bpb_rsvd_sec_cnt;
Byte bpb_num_fat;
Uint16 bpb_root_ent_count;

  Hard_read_open(MBR_ADDRESS);
  Hard_load_sector();
  Hard_read_close();

  /* read and check usefull MBR info */
  /* go to the first partition field */
  if (Hard_read_open(MBR_ADDRESS) == OK) 
  {
    for (i = 446/2; i != 0; i--)
    {
      Hard_read_byte();                     /* go to first partition entry */
      Hard_read_byte();
    }
    /* check first partition state */
    if (Hard_read_byte() != PARTITION_ACTIVE)
    {
      Hard_read_close();                    /* close physical read */
      fat_ptr_fats = 0x00000000;            /* disk may not be partitionned */
    }
    else
    {
      Hard_read_byte();                     /* dummy reads */
      Hard_read_byte();
      Hard_read_byte();
      Hard_read_byte();
      Hard_read_byte();
      Hard_read_byte();
      Hard_read_byte();
      /* read partition offset (in sectors) at offset 8 */
      ((Byte*)&fat_ptr_fats)[3] = Hard_read_byte();
      ((Byte*)&fat_ptr_fats)[2] = Hard_read_byte();
      ((Byte*)&fat_ptr_fats)[1] = Hard_read_byte();
      ((Byte*)&fat_ptr_fats)[0] = Hard_read_byte();
      /* go to the MBR signature field */
      for (i = 52; i != 0; i--)
      {
        Hard_read_byte();                   /* dummy reads */
      }
      /* check MBR signature */
      if ((Hard_read_byte() != LOW(BR_SIGNATURE)) &&
          (Hard_read_byte() != HIGH(BR_SIGNATURE)))
      {
        fat_ptr_fats = 0x00000000;          /* disk may not be partitionned */
      }
      Hard_read_close();                    /* close physical read */
    }
  }
  else
  { /* low level error */
    return KO;
  }

  Hard_read_open(MBR_ADDRESS);
  Hard_load_sector();
  Hard_read_close();

  /* read and check usefull PBR info */
  if (Hard_read_open(fat_ptr_fats) == OK) 
  {
    /* go to sector size field */
    for (i = 11; i != 0; i--)
    {
      Hard_read_byte();                     /* dummy reads */
    }
    /* read sector size (in bytes) */
    if ((Hard_read_byte() != LOW(SECTOR_SIZE)) ||
        (Hard_read_byte() != HIGH(SECTOR_SIZE)))
    {
      Hard_read_close();                    /* close physical read */
      return KO;
    }
    /* read cluster size (in sector) */
    fat_cluster_size = Hard_read_byte();
    fat_cluster_mask = HIGH((Uint16)fat_cluster_size * SECTOR_SIZE) - 1;
    /* reserved sector number */
    ((Byte*)&bpb_rsvd_sec_cnt)[1] = Hard_read_byte();
    ((Byte*)&bpb_rsvd_sec_cnt)[0] = Hard_read_byte();
    /* number of FATs */
    bpb_num_fat = Hard_read_byte();
    if (bpb_num_fat == 2)
      fat_2_is_present = TRUE;
    else
      fat_2_is_present = FALSE;    
    
    /* read number of dir entries*/
    ((Byte*)&bpb_root_ent_count)[3] = Hard_read_byte();
    ((Byte*)&bpb_root_ent_count)[2] = Hard_read_byte();

    /* read number of sector in partition (<32Mb) */
    ((Byte*)&fat_nb_sector)[3] = Hard_read_byte();
    ((Byte*)&fat_nb_sector)[2] = Hard_read_byte();
    ((Byte*)&fat_nb_sector)[1] = 0x00;
    ((Byte*)&fat_nb_sector)[0] = 0x00;
    Hard_read_byte();
    Hard_read_byte();                               /* FAT size for FAT12/16 */
    Hard_read_byte();
    
    Hard_read_byte();
    Hard_read_byte();
    Hard_read_byte();
    Hard_read_byte();
    Hard_read_byte();
    Hard_read_byte();
    Hard_read_byte();
    Hard_read_byte();

    /* read number of sector in partition (>32Mb) */
    ((Byte*)&fat_nb_sector)[3] += Hard_read_byte();
    ((Byte*)&fat_nb_sector)[2] += Hard_read_byte();
    ((Byte*)&fat_nb_sector)[1] += Hard_read_byte();
    ((Byte*)&fat_nb_sector)[0] += Hard_read_byte();

    fat_is_fat16 = FALSE;
    fat_is_fat32 = FALSE;

    fat_ptr_data = (bpb_root_ent_count * DIR_SIZE) / SECTOR_SIZE;

    /* Here start the structure for FAT32 */
    /* Offset 36 : 32 bits size of fat */
    ((Byte*)&fat_fat_size)[3] = Hard_read_byte();
    ((Byte*)&fat_fat_size)[2] = Hard_read_byte();
    ((Byte*)&fat_fat_size)[1] = Hard_read_byte();
    ((Byte*)&fat_fat_size)[0] = Hard_read_byte();

    tot_sect = fat_nb_sector - (Uint32)(((Uint32)(bpb_rsvd_sec_cnt) + (Uint32)((bpb_num_fat * (Uint32)(fat_fat_size))) + fat_ptr_data));
    fat_count_of_clusters = tot_sect / fat_cluster_size;
       
    /* Offset 40 : ExtFlags */
    Hard_read_byte();
    Hard_read_byte();
    /* Offset 42 : FS Version */
    Hard_read_byte();
    Hard_read_byte();
    /* Offset 44 : Root Cluster */
    ((Byte*)&fat_rootclus_fat32)[3] = Hard_read_byte();
    ((Byte*)&fat_rootclus_fat32)[2] = Hard_read_byte();
    ((Byte*)&fat_rootclus_fat32)[1] = Hard_read_byte();
    ((Byte*)&fat_rootclus_fat32)[0] = Hard_read_byte();

    fat_ptr_fats += bpb_rsvd_sec_cnt;
    fat_ptr_data = fat_ptr_fats + (bpb_num_fat * fat_fat_size);

    /* Offset 48 : FS Info */
    /* Offset 50 : Backup Boot Sector */
    /* Offset 52 : Reserved */
    /* Offset 64 - 89 : Data */
    /* Offset 90 : 510 : Free */
    for (i = 231; i != 0; i--)
    {
      Hard_read_byte();
      Hard_read_byte();
    }
    /* check partition signature */
    if ((Hard_read_byte() != LOW(BR_SIGNATURE)) &&
        (Hard_read_byte() != HIGH(BR_SIGNATURE)))
    {
      Hard_read_close();                    /* close physical read */
      return KO;
    }
    Hard_read_close();                      /* close physical read */
    return OK;
  }
  else
  { /* low level error */
    return KO;
  }
}

#define UPLOAD      0
#define DOWNLOAD    1
#define FETCH_NEXT  0
#define FETCH_PREV  1

/*F**************************************************************************
* NAME: fat_calc_cluster
*----------------------------------------------------------------------------
* PARAMS:
*   
*
* return:
*----------------------------------------------------------------------------
* PURPOSE:
*   Calculate fat_dir_current_sect and update directory variable from the
*   value of fat_dir_current_offs.
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*   
*----------------------------------------------------------------------------
* REQUIREMENTS:
*   
*****************************************************************************/
void fat_calc_cluster(void)
{
Uint32   i;
  fat_dchain_index = 0;
  fat_dchain_nb_clust = 0;
  for (i = (fat_dir_current_offs / SECTOR_SIZE / fat_cluster_size) + 1; i != 0; i--)
  {
    if (dclusters[fat_dchain_index].number == fat_dchain_nb_clust)
    { /* new fragment */
      fat_dchain_index++;
      fat_dchain_nb_clust = 1;
    }
    else
    { /* no new fragment */
      fat_dchain_nb_clust++;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品乱码av一区二区| 日韩欧美国产三级电影视频| 99久久精品免费看| 欧美在线看片a免费观看| 日韩一区和二区| 国产精品女人毛片| 亚洲成a人片综合在线| 国产老妇另类xxxxx| 色综合天天综合色综合av| 日韩欧美中文一区二区| 综合色天天鬼久久鬼色| 久久精品免费观看| 欧美影视一区在线| 国产精品美女久久久久久久久久久 | 久久久精品日韩欧美| 中文字幕日韩欧美一区二区三区| 亚洲国产精品综合小说图片区| 久久草av在线| 在线视频你懂得一区| 国产无一区二区| 日本色综合中文字幕| 99久精品国产| 久久婷婷成人综合色| 午夜精品国产更新| 99久久国产免费看| 久久新电视剧免费观看| 中文字幕二三区不卡| 一区二区视频在线| 久国产精品韩国三级视频| 欧美午夜精品久久久久久孕妇 | 日韩精品一区二区三区四区 | 亚洲永久免费av| 国产成人av在线影院| 日韩欧美国产一区二区三区| 亚洲一区二区三区四区在线观看| 国产高清亚洲一区| 日韩欧美亚洲一区二区| 亚洲高清久久久| 色综合久久久久网| 国产精品久线在线观看| 国产成人av自拍| 久久免费看少妇高潮| 精品在线你懂的| 日韩精品自拍偷拍| 蜜桃视频在线观看一区二区| 欧美乱熟臀69xxxxxx| 一二三四社区欧美黄| 日本电影亚洲天堂一区| 亚洲精品视频在线观看网站| 99国产欧美久久久精品| **欧美大码日韩| 91一区二区在线观看| 亚洲乱码日产精品bd| 日本乱人伦一区| 亚洲一区二区精品久久av| 欧美系列亚洲系列| 五月天网站亚洲| 日韩一区和二区| 国产一区在线视频| 中国av一区二区三区| 成人激情电影免费在线观看| 国产精品女主播av| 色综合视频在线观看| 亚洲精品乱码久久久久久黑人| 色综合久久六月婷婷中文字幕| 亚洲综合一区二区| 欧美日韩久久不卡| 毛片不卡一区二区| 国产视频在线观看一区二区三区 | 日韩电影在线观看电影| 欧美精品1区2区| 九九精品一区二区| 国产精品久久久久久久久免费相片| 99久久精品国产麻豆演员表| 亚洲亚洲精品在线观看| 日韩一区二区视频在线观看| 国产精品资源网站| 亚洲精品免费一二三区| 日韩一区二区三区观看| 经典三级在线一区| 亚洲欧洲一区二区三区| 欧美日韩在线播放| 韩国精品在线观看| 成人免费在线视频| 91电影在线观看| 亚洲国产精品一区二区www| 日韩欧美一区在线| 91视频免费看| 久久电影网电视剧免费观看| 综合在线观看色| 日韩午夜激情视频| 91亚洲精品久久久蜜桃网站 | 欧美zozozo| 92国产精品观看| 秋霞电影一区二区| 中文字幕一区二区不卡| 中文字幕在线免费不卡| 5858s免费视频成人| 国产suv精品一区二区三区| 五月天丁香久久| 中文字幕在线一区二区三区| 日韩欧美激情在线| 欧美综合在线视频| 成人午夜激情视频| 久久精品国产久精国产爱| 亚洲精品国产第一综合99久久| 精品国产三级a在线观看| 色婷婷精品久久二区二区蜜臀av| 精品一区二区三区香蕉蜜桃| 亚洲国产美国国产综合一区二区| 欧美韩国日本综合| 精品国产1区二区| 欧美情侣在线播放| 色av成人天堂桃色av| 粉嫩绯色av一区二区在线观看| 蜜臀av亚洲一区中文字幕| 亚洲综合色自拍一区| 国产精品热久久久久夜色精品三区| 91精品国产免费| 欧美午夜一区二区三区| 波多野结衣亚洲| 国产寡妇亲子伦一区二区| 久久国产婷婷国产香蕉| 热久久免费视频| 日韩不卡免费视频| 99精品视频一区| 国产精品99久久久久久久女警| 老司机午夜精品99久久| 亚洲成av人在线观看| 亚洲另类在线视频| 亚洲人成在线观看一区二区| 中文字幕一区二区三区在线播放| 国产丝袜在线精品| 久久免费的精品国产v∧| 精品播放一区二区| 欧美成人一区二区三区| 91精品国产品国语在线不卡| 欧美人体做爰大胆视频| 欧美无砖专区一中文字| 欧美午夜电影一区| 欧美美女一区二区在线观看| 欧美日韩一级片在线观看| 欧美日韩中文字幕一区二区| 91福利国产成人精品照片| 欧洲精品一区二区| 欧美男男青年gay1069videost| 欧美日免费三级在线| 欧美日韩性生活| 欧美日韩国产免费一区二区| 91麻豆精品国产无毒不卡在线观看| 欧美疯狂性受xxxxx喷水图片| 欧美疯狂性受xxxxx喷水图片| 91精品国产入口| 久久久久久久久久久99999| 国产人成亚洲第一网站在线播放 | 91精品国产91热久久久做人人| 欧美日韩午夜影院| 日韩一区二区在线观看视频| 久久蜜桃av一区精品变态类天堂 | 99免费精品在线观看| heyzo一本久久综合| 91黄色免费观看| 91精品国产aⅴ一区二区| 久久亚洲精品国产精品紫薇| 中文字幕成人在线观看| 中文字幕亚洲不卡| 日韩制服丝袜先锋影音| 久久99久久99| jvid福利写真一区二区三区| 欧美日韩电影一区| 久久免费午夜影院| 洋洋成人永久网站入口| 奇米一区二区三区av| 国产精品白丝jk白祙喷水网站 | 亚洲成av人片一区二区三区| 免费观看在线综合色| 波多野结衣在线一区| 欧美日韩精品免费| 国产三级三级三级精品8ⅰ区| 一区二区三区加勒比av| 精品一二三四在线| 日本精品一级二级| www激情久久| 一区二区在线观看视频| 精品影视av免费| 在线日韩av片| 久久免费的精品国产v∧| 一区二区三区在线看| 久久av老司机精品网站导航| 色综合久久中文字幕综合网| 精品国产成人系列| 亚洲一线二线三线久久久| 国产精品亚洲视频| 欧美日韩夫妻久久| 国产精品国产三级国产普通话三级| 日韩成人一区二区| 91官网在线免费观看| 国产精品天天摸av网| 麻豆91在线观看| 欧美日韩小视频|