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

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

?? fat32.c

?? 該原碼為在ateml的單片機上實現的mp3播放器.里面有電路圖和完整的源程序.
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*C**************************************************************************
* NAME:         fat32.c
*----------------------------------------------------------------------------
* Copyright (c) 2003 Atmel.
*----------------------------------------------------------------------------
* RELEASE:      snd1c-refd-nf-4_0_3      
* REVISION:     1.4     
*----------------------------------------------------------------------------
* 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 "fat32.h"                          /* fat32 file-system definition */


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


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

extern  pdata Byte    gl_buffer[];

extern char    pdata *lfn_name;                 /* long filename limited to MAX_FILENAME_LEN chars */

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

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

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

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


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

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

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

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


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

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

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

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

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

extern xdata Byte current_ext;

extern idata Uint16 fat_current_end_entry_position;
extern idata Uint16 fat_current_start_entry_position;
extern xdata Uint16 fat_nb_deleted_entries;
extern 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;

  /* read and check usefull MBR info */
  /* go to the first partition field */
  Hard_read_open(MBR_ADDRESS);
  Hard_load_sector();
  Hard_read_close();

  fat_ptr_fats = 0x01;
  if ((fat_buf_sector[0] == 0xEB) && (fat_buf_sector[2] == 0x90)) /* Jump instruction to boot code */
  {
    if ((fat_buf_sector[21] & 0xF0) == 0xF0)  /* Media byte */
    {
      if ((fat_buf_sector[510] == 0x55) && (fat_buf_sector[511] == 0xAA)) /* signature */
      {
        fat_ptr_fats = 0x00000000;            /* disk may not be partitionned : first sector */
      }                                       /* is PBR */
      else
      {
        return KO;  /* no signature -> low level error */
      }
    }
  }

  if (fat_ptr_fats)                     /* if first sector is not a PBR */
  {
    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();
      }
      Hard_read_byte();
      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;
    }
  }


  /* 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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲男人天堂av| 久久99精品国产91久久来源| 日韩av电影一区| 色综合久久久久久久久久久| 精品国产露脸精彩对白| 天天综合网 天天综合色| 92精品国产成人观看免费| 日韩精品一区二区三区中文不卡 | 日本成人在线不卡视频| 91尤物视频在线观看| 久久婷婷国产综合国色天香| 偷拍与自拍一区| 色综合视频在线观看| 国产欧美一区二区精品忘忧草| 亚洲一级二级三级| 91在线小视频| 国产精品久久久久桃色tv| 国产揄拍国内精品对白| 欧美一级一区二区| 亚洲成人1区2区| 欧美性色综合网| 亚洲免费伊人电影| 91色|porny| 亚洲三级在线观看| 92精品国产成人观看免费| 国产精品伦理在线| 成人的网站免费观看| 国产精品久久久久影院| 成人黄色国产精品网站大全在线免费观看| 日韩视频一区二区| 久88久久88久久久| www亚洲一区| 国产毛片精品国产一区二区三区| 精品国产乱码91久久久久久网站| 看片网站欧美日韩| 久久亚洲二区三区| 国产69精品久久久久毛片 | 欧美日韩精品欧美日韩精品一| 一区二区三区视频在线看| 欧洲日韩一区二区三区| 亚洲一级电影视频| 日韩一级黄色片| 国产剧情av麻豆香蕉精品| 国产网站一区二区| 97久久精品人人做人人爽50路| 亚洲男人都懂的| 欧美日本在线观看| 极品少妇一区二区| 国产精品三级久久久久三级| av在线播放不卡| 亚洲成人自拍偷拍| 日韩一级黄色大片| 风间由美中文字幕在线看视频国产欧美 | 国产精品一品二品| 中文字幕亚洲成人| 在线成人av网站| 国产乱一区二区| 亚洲人妖av一区二区| 欧美日韩大陆一区二区| 国产一区视频在线看| ...xxx性欧美| 欧美一区二区三区免费在线看| 国产精品一级片| 一区二区免费视频| 欧美电影免费观看高清完整版在线观看| 韩国午夜理伦三级不卡影院| 中文字幕中文字幕在线一区| 欧美人妇做爰xxxⅹ性高电影| 久久久噜噜噜久噜久久综合| 粉嫩av一区二区三区粉嫩| 亚洲欧美日韩中文播放| 6080日韩午夜伦伦午夜伦| 成人综合婷婷国产精品久久免费| 亚洲一区免费观看| 国产日韩欧美精品一区| 欧美日韩精品三区| 不卡在线视频中文字幕| 日日噜噜夜夜狠狠视频欧美人 | 精品久久99ma| 色综合 综合色| 精品一区二区三区免费毛片爱 | 国产精品久久久久久久午夜片| 色诱视频网站一区| 日本91福利区| 中文字幕欧美日本乱码一线二线| 欧美日韩一级二级三级| 国产久卡久卡久卡久卡视频精品| 亚洲图片欧美视频| 亚洲色图色小说| 久久在线观看免费| 9191国产精品| 欧美在线一区二区三区| 成人h版在线观看| 国产一区二区久久| 麻豆精品视频在线| 亚洲综合色噜噜狠狠| 亚洲欧美综合网| 国产三区在线成人av| 91精品国产综合久久久蜜臀粉嫩| 91视频一区二区三区| 国产99久久久国产精品免费看| 久久精品国产77777蜜臀| 亚洲h动漫在线| 亚洲综合在线五月| 国产精品嫩草影院com| 国产日本一区二区| 欧美变态口味重另类| 日韩欧美一区二区视频| 91精品在线一区二区| 欧美日韩免费不卡视频一区二区三区| 91小宝寻花一区二区三区| 国产91精品在线观看| 成人午夜激情片| 成人av在线资源网| eeuss国产一区二区三区| 国产成人免费av在线| 国产一区二区成人久久免费影院| 美腿丝袜一区二区三区| 精品一区二区在线观看| 国产主播一区二区| 国产福利一区二区三区在线视频| 国产精品18久久久久久久网站| 国产在线精品一区在线观看麻豆| 国产美女娇喘av呻吟久久| 国产精品亚洲综合一区在线观看| 国产一区二区免费在线| 成人自拍视频在线| 91在线高清观看| 欧美日韩亚洲综合在线 | 91精品国产欧美一区二区| 欧美一区二区视频在线观看2022| 日韩一级二级三级精品视频| 日韩欧美国产高清| 国产午夜一区二区三区| 国产精品的网站| 亚洲成av人片一区二区梦乃 | 国产精品综合久久| 成人福利视频网站| 欧美在线free| 欧美大片一区二区| 国产精品少妇自拍| 亚洲一级二级三级在线免费观看| 日本成人在线网站| 国产凹凸在线观看一区二区| 91视频国产观看| 欧美一区二区久久| 欧美激情综合五月色丁香| 亚洲精品国产成人久久av盗摄| 石原莉奈在线亚洲二区| 国产高清不卡一区二区| 一本一道久久a久久精品综合蜜臀| 欧美日韩视频在线一区二区| 久久综合一区二区| 一区二区三区欧美久久| 国内精品自线一区二区三区视频| 99久久99久久精品免费看蜜桃| 欧美裸体bbwbbwbbw| 国产精品热久久久久夜色精品三区 | 成人免费看黄yyy456| 欧美日韩国产综合视频在线观看| 久久天堂av综合合色蜜桃网| 一区二区在线观看av| 国产精品白丝av| 欧美日韩五月天| 国产精品国产三级国产三级人妇| 日韩电影在线一区二区| 99久久久久免费精品国产| 欧美电影免费观看高清完整版在 | 天堂成人国产精品一区| 成人晚上爱看视频| 日韩一区和二区| 亚洲一区二区精品3399| 国产精品一区久久久久| 777午夜精品视频在线播放| 亚洲视频在线一区观看| 国产成人免费视频网站高清观看视频 | 欧美一区二区精美| 亚洲一区二区三区中文字幕在线| 国产成人综合在线| 亚洲精品在线观看网站| 日韩高清在线一区| 欧美午夜精品理论片a级按摩| 中文字幕精品三区| 国产精品综合一区二区三区| 欧美xxxx在线观看| 日韩精品一二三| 欧美日韩国产一区二区三区地区| 亚洲精品国产成人久久av盗摄| 成人黄色在线看| 国产精品久久久久精k8 | 欧美国产禁国产网站cc| 久久成人精品无人区| 91麻豆精品国产91久久久| 亚洲成av人片一区二区| 日本精品一区二区三区高清 | 欧美精品一区二区不卡| 久久99国产精品成人| 日韩视频免费观看高清完整版在线观看 | 欧美zozo另类异族| 久久精品国产77777蜜臀|