Sorting source tree a bit
[tpg/acess2.git] / KernelLand / Modules / Filesystems / FAT / fs_fat.h
diff --git a/KernelLand/Modules/Filesystems/FAT/fs_fat.h b/KernelLand/Modules/Filesystems/FAT/fs_fat.h
new file mode 100644 (file)
index 0000000..6896945
--- /dev/null
@@ -0,0 +1,171 @@
+/*\r
+ * Acess2\r
+ * FAT12/16/32 Driver\r
+ * vfs/fs/fs_fat.h\r
+ */\r
+#ifndef _FS_FAT_H_\r
+#define _FS_FAT_H_\r
+\r
+// === On Disk Structures ===\r
+/**\r
+ * \struct fat_bootsect_s\r
+ * \brief Bootsector format\r
+ */\r
+struct fat_bootsect_s\r
+{\r
+       Uint8   jmp[3]; //!< Jump Instruction\r
+       char    oemname[8];     //!< OEM Name. Typically MSDOS1.1\r
+       Uint16  bps;    //!< Bytes per Sector. Assumed to be 512\r
+       Uint8   spc;            //!< Sectors per Cluster\r
+       Uint16  resvSectCount;  //!< Number of reserved sectors at beginning of volume\r
+       // +0x10\r
+       Uint8   fatCount;       //!< Number of copies of the FAT\r
+       Uint16  files_in_root;  //!< Count of files in the root directory\r
+       Uint16  totalSect16;    //!< Total sector count (FAT12/16)\r
+       Uint8   mediaDesc;      //!< Media Desctiptor\r
+       Uint16  fatSz16;        //!< FAT Size (FAT12/16)\r
+       // +0x18\r
+       Uint16  spt;    //!< Sectors per track. Ignored (Acess uses LBA)\r
+       Uint16  heads;  //!< Heads. Ignored (Acess uses LBA)\r
+       Uint32  hiddenCount;    //!< ???\r
+       Uint32  totalSect32;    //!< Total sector count (FAT32)\r
+       union {\r
+               struct {\r
+                       Uint8   drvNum; //!< Drive Number. BIOS Drive ID (E.g. 0x80)\r
+                       Uint8   resv;   //!< Reserved byte\r
+                       Uint8   bootSig;        //!< Boot Signature. ???\r
+                       Uint32  volId;  //!< Volume ID\r
+                       char    label[11];      //!< Disk Label\r
+                       char    fsType[8];      //!< FS Type. ???\r
+               } __attribute__((packed)) fat16;        //!< FAT16 Specific information\r
+               struct {\r
+                       Uint32  fatSz32;        //!< 32-Bit FAT Size\r
+                       Uint16  extFlags;       //!< Extended flags\r
+                       Uint16  fsVer;  //!< Filesystem Version\r
+                       Uint32  rootClust;      //!< Root Cluster ID\r
+                       Uint16  fsInfo; //!< FS Info. ???\r
+                       Uint16  backupBS;       //!< Backup Bootsector Sector Offset\r
+                       char    resv[12];       //!< Reserved Data\r
+                       Uint8   drvNum; //!< Drive Number\r
+                       char    resv2;  //!< Reserved Data\r
+                       Uint8   bootSig;        //!< Boot Signature. ???\r
+                       Uint32  volId;  //!< Volume ID\r
+                       char    label[11];      //!< Disk Label\r
+                       char    fsType[8];      //!< Filesystem Type. ???\r
+               } __attribute__((packed)) fat32;        //!< FAT32 Specific Information\r
+       }__attribute__((packed)) spec;  //!< Non Shared Data\r
+       char pad[512-90];       //!< Bootsector Data (Code/Boot Signature 0xAA55)\r
+} __attribute__((packed));\r
+\r
+/**\r
+ \struct fat_filetable_s\r
+ \brief Format of a 8.3 file entry on disk\r
+*/\r
+struct fat_filetable_s {\r
+       char    name[11];       //!< 8.3 Name\r
+       Uint8   attrib; //!< File Attributes.\r
+       Uint8   ntres;  //!< Reserved for NT - Set to 0\r
+       Uint8   ctimems;        //!< 10ths of a second ranging from 0-199 (2 seconds)\r
+       Uint16  ctime;  //!< Creation Time\r
+       Uint16  cdate;  //!< Creation Date\r
+       Uint16  adate;  //!< Accessed Date. No Time feild though\r
+       Uint16  clusterHi;      //!< High Cluster. 0 for FAT12 and FAT16\r
+       Uint16  mtime;  //!< Last Modified Time\r
+       Uint16  mdate;  //!< Last Modified Date\r
+       Uint16  cluster;        //!< Low Word of First cluster\r
+       Uint32  size;   //!< Size of file\r
+} __attribute__((packed));\r
+\r
+/**\r
+ * \struct fat_longfilename_s\r
+ * \brief Format of a long file name entry on disk\r
+ */\r
+struct fat_longfilename_s {\r
+       Uint8   id;     //!< ID of entry. Bit 6 is set for last entry\r
+       Uint16  name1[5];       //!< 5 characters of name\r
+       Uint8   attrib; //!< Attributes. Must be ATTR_LFN\r
+       Uint8   type;   //!< Type. ???\r
+       Uint8   checksum;       //!< Checksum\r
+       Uint16  name2[6];       //!< 6 characters of name\r
+       Uint16  firstCluster;   //!< Used for non LFN compatability. Set to 0\r
+       Uint16  name3[2];       //!< Last 2 characters of name\r
+} __attribute__((packed));\r
+\r
+/**\r
+ * \name File Attributes\r
+ * \brief Flag values for ::fat_filetable_s.attrib\r
+ * \{\r
+ */\r
+#define ATTR_READONLY  0x01    //!< Read-only file\r
+#define ATTR_HIDDEN            0x02    //!< Hidden File\r
+#define ATTR_SYSTEM            0x04    //!< System File\r
+#define ATTR_VOLUMEID  0x08    //!< Volume ID (Deprecated)\r
+#define ATTR_DIRECTORY 0x10    //!< Directory\r
+/**\r
+ * \brief File needs archiving\r
+ * \note User set flag, no significance to the FS driver\r
+ */\r
+#define ATTR_ARCHIVE   0x20\r
+/**\r
+ * \brief Meta Attribute \r
+ * \r
+ * If ::fat_filetable_s.attrib equals ATTR_LFN the file is a LFN entry\r
+ */\r
+#define        ATTR_LFN                (ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUMEID)\r
+/**\r
+ * \}\r
+ */\r
+\r
+/**\r
+ * \brief Internal IDs for FAT types\r
+ */\r
+enum eFatType\r
+{\r
+       FAT12,  //!< FAT12 Volume\r
+       FAT16,  //!< FAT16 Volume\r
+       FAT32,  //!< FAT32 Volume\r
+};\r
+\r
+/**\r
+ * \name End of Cluster marks\r
+ * \brief FAT values that indicate the end of a cluster chain in\r
+ *        different versions.\r
+ * \{\r
+ */\r
+#define        EOC_FAT12       0x0FFF  //!< FAT-12 Mark\r
+#define        EOC_FAT16       0xFFFF  //!< FAT-16 Mark\r
+#define        EOC_FAT32       0x00FFFFFF      //!< FAT-32 Mark\r
+/**\r
+ * \}\r
+ */\r
+\r
+typedef struct fat_bootsect_s fat_bootsect;\r
+typedef struct fat_filetable_s fat_filetable;\r
+typedef struct fat_longfilename_s fat_longfilename;\r
+\r
+// === Memory Structures ===\r
+/**\r
+ * \struct drv_fat_volinfo_s\r
+ * \brief Representation of a volume in memory\r
+ */\r
+struct drv_fat_volinfo_s\r
+{\r
+        int    fileHandle;     //!< File Handle\r
+        int    type;   //!< FAT Type. See eFatType\r
+       char    name[12];       //!< Volume Name (With NULL Terminator)\r
+       tMutex  lFAT;   //!< Lock to prevent double-writing to the FAT\r
+       Uint32  firstDataSect;  //!< First data sector\r
+       Uint32  rootOffset;     //!< Root Offset (clusters)\r
+       Uint32  ClusterCount;   //!< Total Cluster Count\r
+       fat_bootsect    bootsect;       //!< Boot Sector\r
+       tVFS_Node       rootNode;       //!< Root Node\r
+        int    BytesPerCluster;\r
+        int    inodeHandle;    //!< Inode Cache Handle\r
+       #if CACHE_FAT\r
+       Uint32  *FATCache;      //!< FAT Cache\r
+       #endif\r
+};\r
+\r
+typedef struct drv_fat_volinfo_s tFAT_VolInfo;\r
+\r
+#endif\r

UCC git Repository :: git.ucc.asn.au