www.pudn.com > UDiskFileSystem.rar > MX_FFS_LAYER1.h
/*************************************************************************/ /* */ /* Copyright (c) 1993-2001 Macronix, Inc. */ /* */ /* PROPRIETARY RIGHTS of Macronix are involved in the */ /* subject matter of this material. All manufacturing, reproduction, */ /* use, and sales rights pertaining to this subject matter are governed */ /* by the license agreement. The recipient of this software implicitly */ /* accepts the terms of the license. */ /* */ /*************************************************************************/ /*************************************************************************/ /* FILE NAME */ /* MX_FFS_LAYER1.h */ /* DESCRIPTION */ /* This file definition only internal used in Data Synchronize by USB */ /* AUTHOR */ /* MXIC ISG , Inc. System Application Department */ /* */ /* */ /* HISTORY */ /* 2005/12/07 Released version 1.0 */ /*************************************************************************/ #ifndef MX_FFS_LAYER1_H #define MX_FFS_LAYER1_H #include "stdio.h" #include#include #include #include "mx_types.h" typedef struct { u_16 BytesPerSector; // Record BSP n Bytes per one Sector u_8 SectorsPerCluster; // Record BSP n Sectors per one Cluster u_32 BytesPerCluster; // Record BSP n Bytes per one Cluster u_16 ReservedSector; // Record BSP Reserve n Sector, then can get FAT Table Cluster Address u_16 RootEntries; // for FAT16, Record Root Entry numbers u_32 Sectors; // Record Total Sectors number u_32 SectorsPerFAT; // Record FAT Table Sectors, then can get FAT2 Table Cluster Address u_16 RootDir1stCluster; // Record Root Entry Cluster s_8 FileSystm[5]; // Record ˇ§FAT16ˇ¨ or ˇ§FAT32ˇ¨ }bBootSector; typedef struct // unit Sector = UFI's LBA { u_32 FAT1_Address; // FAT1 Link Table Address u_32 FAT2_Address; // FAT2 Link Table Address u_32 BootDIR_Address; // Boot Dir Address u_32 DiskTotalCluster; // Disk Total Cluster number u_32 DikFreeCluster; // Disk Free Cluster number u_8 DiskFreeSize; //? }bPartitionInformation; #define MemoryPerSector 1 // Memory Size / Sector Size #define SystemPass 0 #define SystemError 1 // File System Function void UFI_ReadFile(HANDLE SourceFile, u_32 LBA_START, u_16 LBA_Length, u_8 *Buffer); void UFI_WriteFile(HANDLE SourceFile, u_32 LBA_START, u_16 LBA_Length, u_8 *Buffer); u_8 CheckFileSystem(u_8 *Buffer, u_8 *TypeCode, s_8 *FileSystem); u_8 ClusterToLogicBlockAddrFun(u_32 BootDIR_Address, u_16 RootDir1stCluster, u_8 SectorsPerCluster, u_32 ClusterAddress, u_32 * LBA); u_8 Sector_CopyFunction(u_32 SectorAddr1, u_32 SectorAddr2, u_16 BytesPerSector, u_32 SectorLength); /* --- File System - FAT16 Function --- */ // FAT16 Read Function u_8 FAT16_BootSector_InitFun(u_8 *Buffer, bBootSector *BootSector, bPartitionInformation *PartitionInfor); u_32 FAT16_DiskFreeSize(u_32 TableAddr, u_32 TableSize, u_16 SectorSize); u_8 FAT16_GetFDBInformation(u_32 DirAddree, s_8 *FileName, s_8 *Extension, u_8 *Buffer, u_8 SectorsPerCluster, u_32 BytesPerCluster); u_8 FAT16_GetFile_FristFATLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 FileFstCluster, u_32 *FATLinkTable, u_16 LinkClusterCnt, u_16 *ReturnCounter); u_8 FAT16_GetFile_FATLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 FileFstCluster, u_32 *FATLinkTable, u_16 LinkClusterCnt, u_16 *ReturnCounter); // FAT16 Write Function u_8 FAT16_FAT_Format(u_32 FAT_Address, u_16 BytesPerSector, u_32 SectorsPerFAT, u_16 RootDir1stCluster); u_8 FAT16_SearchFATFreeLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 TotalCluster, u_16 RootDir1stCluster, u_32 ClusterNumber, u_32 *FATLinkTable, u_16 LinkClusterCnt, u_16 *ReturnCounter); u_8 FAT16_DelFile_FATLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 FileFstCluster, u_16 LinkClusterCnt, u_16 *ReturnCounter); u_8 FAT16_CreatFile_FATLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 *FATLinkTable, u_16 LinkClusterCnt, u_16 *ReturnCounter); /* --- File System - FAT32 Function --- */ // FAT32 Read Function u_8 FAT32_BootSector_InitFun(u_8 *Buffer, bBootSector *BootSector, bPartitionInformation *PartitionInfor); u_32 FAT32_DiskFreeSize(u_32 TableAddr, u_32 TableSize, u_16 SectorSize); u_8 FAT32_GetFDBInformation(u_32 DirAddree, s_8 *FileName, s_8 *Extension, u_8 *Buffer, u_8 SectorsPerCluster, u_32 BytesPerCluster); u_8 FAT32_GetFile_FristFATLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 FileFstCluster, u_32 *FATLinkTable, u_16 LinkClusterCnt, u_16 *ReturnCounter); u_8 FAT32_GetFile_FATLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 FileFstCluster, u_32 *FATLinkTable, u_16 LinkClusterCnt, u_16 *ReturnCounter); u_8 FAT16_Modify_FATLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 ClusterNumber, u_32 ClusterNumber_Data); // FAT32 Write Function u_8 FAT32_FAT_Format(u_32 FAT_Address, u_16 BytesPerSector, u_32 SectorsPerFAT, u_16 RootDir1stCluster); u_8 FAT32_SearchFATFreeLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 TotalCluster, u_16 RootDir1stCluster, u_32 ClusterNumber, u_32 *FATLinkTable, u_16 LinkClusterCnt, u_16 *ReturnCounter); u_8 FAT32_DelFile_FATLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 FileFstCluster, u_16 LinkClusterCnt, u_16 *ReturnCounter); u_8 FAT32_CreatFile_FATLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 *FATLinkTable, u_16 LinkClusterCnt, u_16 *ReturnCounter); u_8 FAT32_Modify_FATLinkTable(u_32 FAT_Address, u_16 BytesPerSector, u_32 ClusterNumber, u_32 ClusterNumber_Data); #endif /* MX_FFS_LAYER1_H */