Changeset 569 for soft/giet_vm/giet_fat32
- Timestamp:
- May 18, 2015, 7:07:43 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_fat32/fat32.c
r551 r569 5 5 // Copyright (c) UPMC-LIP6 6 6 ////////////////////////////////////////////////////////////////////////////////// 7 // The fat .h and fat_common.c files define a library of access functions7 // The fat32.h and fat32.c files define a library of access functions 8 8 // to a FAT32 disk on a block device. It is intended to be used 9 9 // by the GIET_VM nano-kernel for both the boot code and the kernel code. … … 14 14 // 2. the "cluster" variable is actually a cluster index. A cluster contains 15 15 // typically 8 sectors (4K bytes) and the cluster index is a 32 bits word. 16 // 3. This FAT32 library uses a FAT cache whose storage capacity is one 17 // sector (512 bytes = 128 cluster indexes in FAT) 16 // 3. This FAT32 library uses a FAT cache whose storage capacity is one sector. 18 17 ////////////////////////////////////////////////////////////////////////////////// 19 18 … … 38 37 extern unsigned int _ptabs_vaddr[GIET_NB_VSPACE_MAX][X_SIZE][Y_SIZE]; 39 38 40 ////////////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////////////// 41 40 // This function computes the memory buffer physical address, and calls 42 // the proper IOC driver depending on the subtype (BDV / HBA / SDC / RDK).41 // the proper IOC driver depending on the subtype (BDV / HBA / SDC / SPI / RDK). 43 42 // The use_irq argument allows to activate the descheduling mode, if it 44 43 // supported by the IOC driver subtype 45 ////////////////////////////////////////////////////////////////////////////// 44 ///////////////////////////////////////////////////////////////////////////////// 46 45 // Return 0 in case of success, return -1 in case of error 47 ////////////////////////////////////////////////////////////////////////////// 46 ///////////////////////////////////////////////////////////////////////////////// 48 47 static 49 48 int _fat_ioc_access( unsigned int use_irq, … … 66 65 } 67 66 68 #if (GIET_DEBUG_FAT > 1)67 #if GIET_DEBUG_FAT 69 68 unsigned int procid = _get_procid(); 70 69 unsigned int x = procid >> (Y_WIDTH + P_WIDTH); 71 70 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 72 71 unsigned int p = procid & ((1<<P_WIDTH)-1); 72 if ( _get_proctime() > GIET_DEBUG_FAT ) 73 73 _printf("\n[DEBUG FAT] P[%d,%d,%d] enters _fat_ioc_access() at cycle %d\n" 74 74 " to_mem = %d / vaddr = %x / paddr = %l / sectors = %d / lba = %x\n", … … 86 86 #elif ( USE_IOC_HBA ) 87 87 return( _hba_access( use_irq , to_mem , lba , buf_paddr , count ) ); 88 #elif ( USE_IOC_SDC ) 89 return( _sdc_access( use_irq , to_mem , lba , buf_paddr , count ) ); 88 90 #elif ( USE_IOC_SPI ) 89 return( _s dc_access( use_irq , to_mem , lba , buf_paddr , count ) );91 return( _spi_access( use_irq , to_mem , lba , buf_paddr , count ) ); 90 92 #elif ( USE_IOC_RDK ) 91 93 return( _rdk_access( use_irq , to_mem , lba , buf_paddr , count ) ); … … 101 103 // This function displays the content of the FAT cache 102 104 ////////////////////////////////////////////////////////////////////////////////// 103 #if (GIET_DEBUG_FAT > 1)105 #if GIET_DEBUG_FAT 104 106 static 105 107 void _display_fat_cache() … … 307 309 _fat.fat_cache, 308 310 1 ); 309 #if (GIET_DEBUG_FAT > 1)311 #if GIET_DEBUG_FAT 310 312 unsigned int procid = _get_procid(); 311 313 unsigned int x = procid >> (Y_WIDTH + P_WIDTH); 312 314 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 313 315 unsigned int p = procid & ((1<<P_WIDTH)-1); 316 if ( _get_proctime() > GIET_DEBUG_FAT ) 314 317 _printf("\n[DEBUG FAT] P[%d,%d,%d] in _get_next_cluster() : next = %x\n", 315 318 x , y , p , next ); 319 if ( (_get_proctime() > GIET_DEBUG_FAT) && (GIET_DEBUG_FAT & 0x1) ) 316 320 _display_fat_cache(); 317 321 #endif … … 725 729 726 730 #if GIET_DEBUG_FAT 731 if ( _get_proctime() > GIET_DEBUG_FAT ) 727 732 _printf("\n[DEBUG FAT] _update_fs_info()\n"); 728 733 #endif … … 773 778 774 779 #if GIET_DEBUG_FAT 780 if ( _get_proctime() > GIET_DEBUG_FAT ) 775 781 _printf("\n[DEBUG FAT] _update_fat() : cluster = %x / value = %x\n", 776 782 cluster, value ); … … 839 845 840 846 #if GIET_DEBUG_FAT 847 if ( _get_proctime() > GIET_DEBUG_FAT ) 841 848 _printf("\n[DEBUG FAT] _fat_allocate() for fd = %d\n", fd_id ); 842 849 #endif … … 855 862 856 863 #if GIET_DEBUG_FAT 864 if ( _get_proctime() > GIET_DEBUG_FAT ) 857 865 _printf("\n[DEBUG FAT] cluster to update = %x / free cluster = %x / count = %d\n", 858 866 last_cluster_file , free_cluster , cluster_to_allocate ); … … 926 934 unsigned int* lba_dir_entry ) // lba of dir_entry 927 935 { 928 char dir_entry[32]; // buffer to store a full directory_entry929 char name_entry[14]; // buffer to store a 13 characters (partial) name936 char dir_entry[32]; // buffer to store a full directory_entry 937 char name_entry[14]; // buffer to store a 13 characters (partial) name 930 938 931 939 char sfn_string[12] = {[0 ... 10] = ' ', '\0'}; // buffer Short File Name 932 940 unsigned int is_sfn = is_short(file_name, sfn_string); // file_name is short 933 941 unsigned int offset = 0; // byte offset in block 934 unsigned int block_id = _fat.sectors_per_cluster; 942 unsigned int block_id = _fat.sectors_per_cluster; // sector index 935 943 unsigned int lba = cluster_to_lba(cluster); // lba of cluster 936 944 unsigned int attr = 0; // dir entry attribute … … 945 953 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 946 954 unsigned int p = procid & ((1<<P_WIDTH)-1); 947 955 if ( _get_proctime() > GIET_DEBUG_FAT ) 948 956 _printf("\n[DEBUG FAT] _scan_directory() : P[%d,%d,%d] enters for %s\n", 949 957 x, y, p, file_name ); … … 968 976 _fat.cache_lba = lba; 969 977 970 #if ( GIET_DEBUG_FAT > 1 ) 978 #if GIET_DEBUG_FAT 979 if ( (_get_proctime() > GIET_DEBUG_FAT) && (GIET_DEBUG_FAT & 0x1) ) 971 980 _display_fat_cache(); 972 981 #endif … … 1095 1104 1096 1105 #if GIET_DEBUG_FAT 1106 if ( _get_proctime() > GIET_DEBUG_FAT ) 1097 1107 _printf("\n[DEBUG FAT] _scan_directory() : P[%d,%d,%d] found %s" 1098 1108 " : cluster = %x\n", x, y, p, file_name, searched_cluster ); … … 1137 1147 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 1138 1148 unsigned int p = procid & ((1<<P_WIDTH)-1); 1149 if ( _get_proctime() > GIET_DEBUG_FAT ) 1139 1150 _printf("\n[DEBUG FAT] P[%d,%d,%d] enters _fat_init\n",x,y,p); 1140 1151 #endif … … 1160 1171 1161 1172 #if GIET_DEBUG_FAT > 1 1173 if ( _get_proctime() > GIET_DEBUG_FAT ) 1162 1174 _printf("\n[DEBUG FAT] _fat_init() : Boot Sector Loaded\n"); 1175 if ( (_get_proctime() > GIET_DEBUG_FAT) && (GIET_DEBUG_FAT & 0x1) ) 1163 1176 _display_fat_cache(); 1164 1177 #endif … … 1205 1218 1206 1219 #if GIET_DEBUG_FAT 1220 if ( _get_proctime() > GIET_DEBUG_FAT ) 1207 1221 _printf("\n[DEBUG FAT] _fat_init() : FS_INFO Sector = %x\n", _fat.fs_info_lba ); 1208 1222 #endif … … 1224 1238 1225 1239 #if GIET_DEBUG_FAT 1240 if ( _get_proctime() > GIET_DEBUG_FAT ) 1226 1241 _fat_print(); 1227 1242 _printf("\n[DEBUG FAT] P[%d,%d,%d] exit _fat_init()\n", x,y,p ); … … 1260 1275 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 1261 1276 unsigned int p = procid & ((1<<P_WIDTH)-1); 1277 if ( _get_proctime() > GIET_DEBUG_FAT ) 1262 1278 _printf("\n[DEBUG FAT] _fat_open() : P[%d,%d,%d] enters for path %s\n", 1263 1279 x, y, p, pathname ); … … 1281 1297 1282 1298 #if GIET_DEBUG_FAT 1299 if ( _get_proctime() > GIET_DEBUG_FAT ) 1283 1300 _printf("\n[DEBUG FAT] _fat_open() : P[%d,%d,%d] takes the FAT lock\n", 1284 1301 x, y, p ); … … 1298 1315 1299 1316 #if GIET_DEBUG_FAT 1317 if ( _get_proctime() > GIET_DEBUG_FAT ) 1300 1318 _printf("\n[DEBUG FAT] _fat_open() : P[%d,%d,%d] search file/dir %s\n", 1301 1319 x, y, p, name ); … … 1306 1324 { 1307 1325 last_name = 1; 1308 dir_cluster = cluster; 1326 dir_cluster = cluster; // this is the lowest directory 1309 1327 } 1310 1328 … … 1325 1343 1326 1344 #if GIET_DEBUG_FAT 1345 if ( _get_proctime() > GIET_DEBUG_FAT ) 1327 1346 _printf("\n[DEBUG FAT] P[%d,%d,%d] in _fat_open() : cluster for %s = %x\n", 1328 1347 x, y, p, pathname, cluster ); … … 1351 1370 1352 1371 #if GIET_DEBUG_FAT 1372 if ( _get_proctime() > GIET_DEBUG_FAT ) 1353 1373 _printf("\n[DEBUG FAT] _fat_open() : P[%d,%d,%d] exit : fd = %d for file %s\n", 1354 1374 x, y, p, fd_id, pathname ); … … 1443 1463 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 1444 1464 unsigned int p = procid & ((1<<P_WIDTH)-1); 1465 if ( _get_proctime() > GIET_DEBUG_FAT ) 1445 1466 _printf("\n[DEBUG FAT] _fat_read() : P[%d,%d,%d] enters for file %s\n" 1446 1467 " - buffer vbase = %x\n" … … 1478 1499 1479 1500 #if GIET_DEBUG_FAT 1501 if ( _get_proctime() > GIET_DEBUG_FAT ) 1480 1502 _printf("\n[DEBUG FAT] _fat_read() : P[%d,%d,%d] makes an IOC read\n" 1481 1503 " cluster = %x / buffer = %x / lba = %x / sectors = %d\n", … … 1552 1574 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH)-1); 1553 1575 unsigned int p = procid & ((1<<P_WIDTH)-1); 1554 1576 if ( _get_proctime() > GIET_DEBUG_FAT ) 1555 1577 _printf("\n[DEBUG FAT] _fat_write() : P[%d,%d,%d] enters for file %s\n" 1556 1578 " - buffer vbase = %x\n" … … 1597 1619 1598 1620 #if GIET_DEBUG_FAT 1621 if ( _get_proctime() > GIET_DEBUG_FAT ) 1599 1622 _printf("\n[DEBUG FAT] _fat_write() : P[%d,%d,%d] get cluster %x\n", 1600 1623 x, y, p, cluster ); … … 1626 1649 1627 1650 #if GIET_DEBUG_FAT 1651 if ( _get_proctime() > GIET_DEBUG_FAT ) 1628 1652 _printf("\n[DEBUG FAT] _fat_write() : P[%d,%d,%d] makes an IOC write" 1629 1653 " cluster = %x / buffer = %x / lba = %x / sectors = %d\n",
Note: See TracChangeset
for help on using the changeset viewer.