• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

簡易NC通信端末の製作


Commit MetaInfo

Revisão4d90248a84c2db68af0b77ded25c837ce312d8de (tree)
Hora2012-06-04 18:56:37
AutorKAZ.Imamura (Office) <kaz@tekk...>
CommiterKAZ.Imamura (Office)

Mensagem de Log

Merge branch 'master' of git.pf.sourceforge.jp:/gitroot/t/te/tekken_boss/H8_first_build

Conflicts:
tool/fat_test.c

Mudança Sumário

Diff

--- a/tool/fat_test.c
+++ b/tool/fat_test.c
@@ -7,7 +7,13 @@
77 #include <stdlib.h>
88 #include <error.h>
99
10+<<<<<<< HEAD
1011 #define MAX_FILE_IN_DIR 128
12+=======
13+void read_BPB( int fd );
14+void read_DIR( int fd );
15+unsigned long Cluster2Sector( unsigned long cluster );
16+>>>>>>> 5d25b5c54834a18f08f4fba3c3a1bb32974c16f2
1117
1218 typedef struct {
1319 char Name[13];
@@ -45,6 +51,7 @@ struct BPB_information {
4551 // Only for FAT32
4652 unsigned long FATSz32; // Offset 36 Size 2 FAT size for FAT32
4753 unsigned long RootClus; // Offset 44 Size 4
54+<<<<<<< HEAD
4855 };
4956 struct BPB_information BPB_info;
5057
@@ -60,6 +67,18 @@ enum {
6067 };
6168
6269 DIR_ENTRY dir_entry;
70+=======
71+};
72+struct BPB_information BPB_info;
73+
74+
75+struct DIR_Entry {
76+ char Name[13];
77+ unsigned long FirstCluster;
78+ unsigned char Attributes;
79+};
80+struct DIR_Entry dir_info[128];
81+>>>>>>> 5d25b5c54834a18f08f4fba3c3a1bb32974c16f2
6382
6483 unsigned char buf[512];
6584
@@ -70,11 +89,15 @@ unsigned long TotalSect;
7089 unsigned long DataSectors;
7190 unsigned long CountofClusters;
7291
92+<<<<<<< HEAD
7393 unsigned long CurrentWindowSector;
94+=======
95+>>>>>>> 5d25b5c54834a18f08f4fba3c3a1bb32974c16f2
7496 unsigned long CurrentDirCluster;
7597 unsigned int TotalFileNum;
7698 unsigned char IsFAT32;
7799
100+<<<<<<< HEAD
78101 void read_DIR( int fd ) {
79102 unsigned long SearchSector, SearchCluster;
80103 int i,a;
@@ -86,6 +109,19 @@ void read_DIR( int fd ) {
86109 else if ( res == DIR_ENTRY_READY ) TotalFileNum++;
87110
88111 next_dir_entry(fd, &dir_entry);
112+=======
113+main (int argc, char *argv[] ) {
114+ int fd, i;
115+
116+ // Global initialize
117+ CurrentDirCluster = 0;
118+ TotalFileNum = 0;
119+ IsFAT32 = 0;
120+
121+ if( argc == 1 ) {
122+ printf("No file is specified.\r\n");
123+ return;
124+>>>>>>> 5d25b5c54834a18f08f4fba3c3a1bb32974c16f2
89125 }
90126 }
91127
@@ -236,6 +272,7 @@ int GetNextCluster(int fd, unsigned long *p_cluster ) {
236272 return;
237273 }
238274
275+<<<<<<< HEAD
239276 if(IsFAT32) {
240277 EntryVal = *(unsigned long*) &buf[FATEntOffset] & 0x0FFFFFFF;
241278 } else {
@@ -258,6 +295,10 @@ int GetNextCluster(int fd, unsigned long *p_cluster ) {
258295 printf("[GetNextCluster] it should be reserved cluster.\r\n");
259296 return -1;
260297 }
298+=======
299+ read_BPB(fd);
300+ read_DIR(fd);
301+>>>>>>> 5d25b5c54834a18f08f4fba3c3a1bb32974c16f2
261302 }
262303
263304
@@ -369,6 +410,7 @@ void read_BPB(int fd) {
369410 IsFAT32 = 1;
370411 }
371412 }
413+<<<<<<< HEAD
372414
373415 // ------------------------------------------------------
374416 // Main function
@@ -396,4 +438,97 @@ main (int argc, char *argv[] ) {
396438
397439 init_dir_entry(fd, (P_DIR_ENTRY) &dir_entry, 0L ); // Set to root
398440 read_DIR(fd);
441+=======
442+
443+
444+void read_DIR( int fd ) {
445+ unsigned long SearchSector;
446+ int i;
447+
448+
449+ if( CurrentDirCluster == 0 ) { // Root directory ?
450+ if(IsFAT32) {
451+ SearchSector = FirstDataSector;
452+ } else {
453+ SearchSector = BPB_info.ResvdSecCnt + (BPB_info.NumFATs * FATSectors);
454+ }
455+ } else {
456+ SearchSector = Cluster2Sector( CurrentDirCluster );
457+ }
458+ printf("[read_DIR] Seek to 0x%08X.\r\n", SearchSector);
459+ if( lseek(fd, (off_t) (SearchSector * BPB_info.BytsPerSec), SEEK_SET) < 0 ) {
460+ printf("[read_DIR] Seek failed.\r\n");
461+ perror("[read_DIR]");
462+ return;
463+ }
464+ if( read(fd, buf, sizeof(buf)) == 0 ) {
465+ printf("[read_DIR] Read failed.\r\n");
466+ return;
467+ }
468+
469+ i=0;
470+ for(i=0;i<sizeof(buf)/32;i++) { // 1 entry = 32 bytes
471+ if(buf[i*32+ 0] == 0x00) {
472+ // end of entries
473+ break;
474+ } else if (buf[i*32+ 0] == 0xE5) {
475+ // empty entry
476+ continue;
477+ } else if ( (buf[i*32+ 11] & 0x0F) == 0x0F) {
478+ // Long file name entry
479+ continue;
480+ } else {
481+ TotalFileNum++;
482+
483+ dir_info[i].FirstCluster = buf[i*32+ 20] * 0x10000
484+ + buf[i*32+ 21] * 0x1000000
485+ + buf[i*32+ 26]
486+ + buf[i*32+ 27] * 0x100;
487+ dir_info[i].Attributes = buf[i*32+ 11];
488+
489+ dir_info[i].Name[ 0] = buf[i*32+ 0];
490+ dir_info[i].Name[ 1] = buf[i*32+ 1];
491+ dir_info[i].Name[ 2] = buf[i*32+ 2];
492+ dir_info[i].Name[ 3] = buf[i*32+ 3];
493+ dir_info[i].Name[ 4] = buf[i*32+ 4];
494+ dir_info[i].Name[ 5] = buf[i*32+ 5];
495+ dir_info[i].Name[ 6] = buf[i*32+ 6];
496+ dir_info[i].Name[ 7] = buf[i*32+ 7];
497+
498+ if(dir_info[i].Attributes & 0x10) {
499+ dir_info[i].Name[ 8] = buf[i*32+ 8];
500+ dir_info[i].Name[ 9] = buf[i*32+ 9];
501+ dir_info[i].Name[10] = buf[i*32+ 10];
502+ dir_info[i].Name[11] = ' ';
503+ dir_info[i].Name[12] = 0x00;
504+ printf(" [%12s] 0x%08X\r\n", dir_info[i].Name, dir_info[i].FirstCluster );
505+ } else {
506+ dir_info[i].Name[ 8] = '.';
507+ dir_info[i].Name[ 9] = buf[i*32+ 8];
508+ dir_info[i].Name[10] = buf[i*32+ 9];
509+ dir_info[i].Name[11] = buf[i*32+ 10];
510+ dir_info[i].Name[12] = 0x00;
511+ printf(" %12s 0x%08X\r\n", dir_info[i].Name, dir_info[i].FirstCluster );
512+ }
513+ }
514+
515+
516+ }
517+
518+ // Contents dump
519+ for(i=0; i<sizeof(buf)/16; i++) {
520+ printf("%06X | %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X \r\n",
521+ i*0x10,
522+ buf[i*16+ 0], buf[i*16+ 1], buf[i*16+ 2], buf[i*16+ 3],
523+ buf[i*16+ 4], buf[i*16+ 5], buf[i*16+ 6], buf[i*16+ 7],
524+ buf[i*16+ 8], buf[i*16+ 9], buf[i*16+10], buf[i*16+11],
525+ buf[i*16+12], buf[i*16+13], buf[i*16+14], buf[i*16+15] );
526+ }
527+
528+
529+}
530+
531+unsigned long Cluster2Sector( unsigned long cluster ) {
532+ return ( FirstDataSector + (cluster - 2) * BPB_info.SecPerClus );
533+>>>>>>> 5d25b5c54834a18f08f4fba3c3a1bb32974c16f2
399534 }