Changeset 530 for soft/giet_vm/giet_fat32/fat32.h
- Timestamp:
- Mar 27, 2015, 12:10:20 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_fat32/fat32.h
r503 r530 1 //////////////////////////////////////////////////////////////////////////// 1 //////////////////////////////////////////////////////////////////////////////// 2 2 // File : fat32.h 3 3 // Date : 01/09/2013 4 4 // Author : Marco Jankovic / Alain Greiner 5 5 // Copyright (c) UPMC-LIP6 6 //////////////////////////////////////////////////////////////////////////// 6 //////////////////////////////////////////////////////////////////////////////// 7 7 8 8 #ifndef _FAT32_H … … 12 12 #include "kernel_locks.h" 13 13 14 /*************** Partition Boot Sector Format ********************************** ********/14 /*************** Partition Boot Sector Format **********************************/ 15 15 // offset | length 16 16 #define BS_JMPBOOT 0 , 3 … … 56 56 #define FOURTH_PARTITION_BEGIN_LBA 502 , 4 57 57 #define FOURTH_PARTITION_SIZE 506 , 4 58 /******************************************************************************* ********/58 /*******************************************************************************/ 59 59 60 60 #define MBR_SIGNATURE_POSITION 510 , 2 61 61 #define MBR_SIGNATURE_VALUE 0xAA55 62 62 63 /************** FAT_FS_INFO SECTOR ******************************************** ********/63 /************** FAT_FS_INFO SECTOR ********************************************/ 64 64 #define FS_SIGNATURE_VALUE_1 0x52526141 65 65 #define FS_SIGNATURE_VALUE_2 0x72724161 … … 70 70 #define FS_FREE_CLUSTER 488 , 4 71 71 #define FS_FREE_CLUSTER_HINT 492 , 4 72 /******************************************************************************* ********/72 /*******************************************************************************/ 73 73 74 74 #define DIR_ENTRY_SIZE 32 75 75 76 /******* Directory Entry Structure (32 bytes) ********************************** ********/76 /******* Directory Entry Structure (32 bytes) **********************************/ 77 77 // offset | length 78 78 #define DIR_NAME 0 , 11 // dir_entry name … … 85 85 #define DIR_FST_CLUS_LO 26 , 2 // cluster index 16 LSB bit 86 86 #define DIR_FILE_SIZE 28 , 4 // file size (up to 4 giga bytes) 87 /******************************************************************************* ********/88 89 /******* LFN Directory Entry Structure (32 bytes) ***************************** ********/87 /*******************************************************************************/ 88 89 /******* LFN Directory Entry Structure (32 bytes) *****************************/ 90 90 // offset | length 91 91 #define LDIR_ORD 0 , 1 // Sequence number (from 0x01 to 0x0f) … … 97 97 #define LDIR_RSVD 26 , 2 // artifact of previous fat (must be 0) 98 98 #define LDIR_NAME_3 28 , 4 99 /******************************************************************************* ********/100 101 /*********************** DIR_ATTR values (attributes) ************************ ********/99 /*******************************************************************************/ 100 101 /*********************** DIR_ATTR values (attributes) ************************/ 102 102 #define ATTR_READ_ONLY 0x01 103 103 #define ATTR_HIDDEN 0x02 … … 107 107 #define ATTR_ARCHIVE 0x20 108 108 #define ATTR_LONG_NAME_MASK 0x0f // READ_ONLY|HIDDEN|SYSTEM|VOLUME_ID 109 /******************************************************************************* ********/110 111 /********************* DIR_ORD special values ********************************** ********/109 /*******************************************************************************/ 110 111 /********************* DIR_ORD special values **********************************/ 112 112 #define FREE_ENTRY 0xE5 // this entry is free in the directory 113 113 #define NO_MORE_ENTRY 0x00 // no more entry in the directory 114 /******************************************************************************* ********/115 116 /******************** CLuster Index Special Values ***************************** ********/114 /*******************************************************************************/ 115 116 /******************** CLuster Index Special Values *****************************/ 117 117 #define FREE_CLUSTER 0x00000000 118 118 #define RESERVED_CLUSTER 0x00000001 119 119 #define BAD_CLUSTER 0x0FFFFFF7 120 120 #define END_OF_CHAIN_CLUSTER 0x0ffffff8 121 /******************************************************************************* ********/121 /*******************************************************************************/ 122 122 123 123 #define FAT_INITIALISED 0xBABEF00D 124 124 125 /************ This struct defines a file descriptor **************************** ********/125 /************ This struct defines a file descriptor ****************************/ 126 126 typedef struct file_descriptor_s 127 127 { … … 132 132 char name[244]; // pathname 133 133 } file_desc_t; 134 /******************************************************************************* ********/135 136 /************ This struct describes a FAT32 disk ******************************* ***/134 /*******************************************************************************/ 135 136 /************ This struct describes a FAT32 disk *******************************/ 137 137 typedef struct fat32_fs_s 138 138 { 139 char fat_cache[512]; // FAT cache: 1 sector = 128 cluster indexes139 char fat_cache[512]; // FAT cache: 1 sector 140 140 spin_lock_t fat_lock; // lock protecting exclusive access 141 141 file_desc_t fd[GIET_OPEN_FILES_MAX]; // file descriptors array 142 unsigned int initialised; // contains0xBABEF00D when FAT initialised142 unsigned int initialised; // 0xBABEF00D when FAT initialised 143 143 unsigned int sector_size; // number of bytes (power of 2) 144 144 unsigned int sectors_per_cluster; // power of 2 (must be greater than 4) 145 unsigned int cluster_size; // sector_size * sector_per_cluster (bytes)146 unsigned int fat_sectors; // number of sectors occupied by oneFAT copy145 unsigned int cluster_size; // sector_size * sector_per_cluster 146 unsigned int fat_sectors; // number of sectors for 1 FAT copy 147 147 unsigned int fat_lba; // lba of first FAT sector 148 148 unsigned int data_lba; // lba of first data sector … … 152 152 unsigned int fs_info_lba; // lba of fs_info 153 153 } fat32_fs_t; 154 /***************************************************************************************/ 155 156 /*********************** Export Functions *********************************************/ 157 158 extern void _fat_print(); 159 160 // functions used for low level access to fat 161 // (move sectors between block device and system buffers) 162 163 extern int _fat_init( unsigned int mode ); // mode for IOC driver 164 165 extern int _fat_open( unsigned int mode, // mode for IOC driver 166 char* pathname, // file pathname from root 167 unsigned int create ); // create new file if non zero 168 169 extern int _fat_read( unsigned int mode, // mode for IOC driver 170 unsigned int fd_id, // file descriptor index 171 void* buffer, // destination buffer 172 unsigned int count, // number of sectors to read 173 unsigned int offset ); // offset sector in file 174 175 extern int _fat_write( unsigned int mode, // mode for IOC driver 176 unsigned int fd_id, // file descriptor index 177 void* buffer, // source buffer 178 unsigned int count, // number of sectors to write 179 unsigned int offset ); // offset sector in file 180 181 extern int _fat_fstat( unsigned int fd_id ); // file descriptor index 182 183 extern int _fat_close( unsigned int fd_id ); // file descriptor index 184 185 186 // functions used by user system calls 187 // (should move bytes between system buffers and user buffers) 188 189 extern int _fat_user_open( char* pathname, // file pathname from root 190 unsigned int flags ); // unused 154 /*******************************************************************************/ 155 156 /*********************** Extern Functions *************************************/ 157 158 extern int _fat_init( unsigned int use_irq ); // use IRQ if possible 159 160 extern int _fat_open( unsigned int use_irq, // use IRQ if possible 161 char* pathname, // file pathname from root 162 unsigned int create ); // create new file if non zero 163 164 extern int _fat_read( unsigned int use_irq, // use IRQ if possible 165 unsigned int fd_id, // file descriptor index 166 void* buffer, // destination buffer 167 unsigned int count, // number of sectors to read 168 unsigned int offset ); // offset sector in file 169 170 extern int _fat_write( unsigned int use_irq, // use IRQ if possible 171 unsigned int fd_id, // file descriptor index 172 void* buffer, // source buffer 173 unsigned int count, // number of sectors to write 174 unsigned int offset ); // offset sector in file 175 176 extern int _fat_fstat( unsigned int fd_id ); // file descriptor index 177 178 extern int _fat_close( unsigned int fd_id ); // file descriptor index 179 180 181 extern int _fat_user_open( char* pathname, // file pathname from root 182 unsigned int flags ); // unused 191 183 192 184 extern int _fat_user_read( unsigned int fd_id, // file descriptor index 193 185 void* buffer, // destination buffer 194 186 unsigned int count, // number of sectors to read 195 unsigned int offset ); // number ofsectors to skip in file187 unsigned int offset ); // sectors to skip in file 196 188 197 189 extern int _fat_user_write( unsigned int fd_id, // file descriptor index 198 190 void* buffer, // source buffer 199 191 unsigned int count, // number of sectors to write 200 unsigned int offset ); // number ofsectors to skip in file192 unsigned int offset ); // sectors to skip in file 201 193 202 194 extern int _fat_user_lseek( unsigned int fd_id, … … 204 196 unsigned int whence ); 205 197 206 /******************************************************************************* ********/198 /*******************************************************************************/ 207 199 208 200
Note: See TracChangeset
for help on using the changeset viewer.