| Index: embios/trunk/target/ipodnano2g/target.h | 
| — | — | @@ -35,4 +35,7 @@ | 
| 36 | 36 | #define USB_NUM_ENDPOINTS 5 | 
| 37 | 37 |  | 
| 38 | 38 |  | 
|  | 39 | +#define NUM_VOLUMES 1 | 
|  | 40 | + | 
|  | 41 | + | 
| 39 | 42 | #endif | 
| Index: embios/trunk/fat.c | 
| — | — | @@ -208,12 +208,12 @@ | 
| 209 | 209 |  | 
| 210 | 210 | static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE]; | 
| 211 | 211 | static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE]; | 
| 212 |  | -static struct mutex cache_mutex SHAREDBSS_ATTR; | 
|  | 212 | +static struct mutex cache_mutex; | 
| 213 | 213 |  | 
| 214 | 214 | #if defined(HAVE_HOTSWAP) && !(CONFIG_STORAGE & STORAGE_MMC) /* A better condition ?? */ | 
| 215 | 215 | void fat_lock(void) | 
| 216 | 216 | { | 
| 217 |  | -    mutex_lock(&cache_mutex); | 
|  | 217 | +    mutex_lock(&cache_mutex, TIMEOUT_BLOCK); | 
| 218 | 218 | } | 
| 219 | 219 |  | 
| 220 | 220 | void fat_unlock(void) | 
| — | — | @@ -475,7 +475,7 @@ | 
| 476 | 476 | else | 
| 477 | 477 | {   /* volume is not accessible any more, e.g. MMC removed */ | 
| 478 | 478 | int i; | 
| 479 |  | -        mutex_lock(&cache_mutex); | 
|  | 479 | +        mutex_lock(&cache_mutex, TIMEOUT_BLOCK); | 
| 480 | 480 | for(i = 0;i < FAT_CACHE_SIZE;i++) | 
| 481 | 481 | { | 
| 482 | 482 | struct fat_cache_entry *fce = &fat_cache[i]; | 
| — | — | @@ -660,7 +660,7 @@ | 
| 661 | 661 | unsigned char *sectorbuf = &fat_cache_sectors[cache_index][0]; | 
| 662 | 662 | int rc; | 
| 663 | 663 |  | 
| 664 |  | -    mutex_lock(&cache_mutex); /* make changes atomic */ | 
|  | 664 | +    mutex_lock(&cache_mutex, TIMEOUT_BLOCK); /* make changes atomic */ | 
| 665 | 665 |  | 
| 666 | 666 | /* Delete the cache entry if it isn't the sector we want */ | 
| 667 | 667 | if(fce->inuse && (fce->secnum != secnum | 
| — | — | @@ -970,7 +970,7 @@ | 
| 971 | 971 | unsigned char *sec; | 
| 972 | 972 | DEBUGF("flush_fat()"); | 
| 973 | 973 |  | 
| 974 |  | -    mutex_lock(&cache_mutex); | 
|  | 974 | +    mutex_lock(&cache_mutex, TIMEOUT_BLOCK); | 
| 975 | 975 | for(i = 0;i < FAT_CACHE_SIZE;i++) | 
| 976 | 976 | { | 
| 977 | 977 | struct fat_cache_entry *fce = &fat_cache[i]; | 
| — | — | @@ -1013,81 +1013,11 @@ | 
| 1014 | 1014 | if (tenth) | 
| 1015 | 1015 | *tenth = (tm->tm_sec & 1) * 100; | 
| 1016 | 1016 | #else | 
| 1017 |  | -    /* non-RTC version returns an increment from the supplied time, or a | 
| 1018 |  | -     * fixed standard time/date if no time given as input */ | 
| 1019 | 1017 |  | 
| 1020 |  | -/* Macros to convert a 2-digit string to a decimal constant. | 
| 1021 |  | -   (YEAR), MONTH and DAY are set by the date command, which outputs | 
| 1022 |  | -   DAY as 00..31 and MONTH as 01..12. The leading zero would lead to | 
| 1023 |  | -   misinterpretation as an octal constant. */ | 
| 1024 |  | -#define S100(x) 1 ## x | 
| 1025 |  | -#define C2DIG2DEC(x) (S100(x)-100) | 
| 1026 |  | -/* The actual build date, as FAT date constant */ | 
| 1027 |  | -#define BUILD_DATE_FAT (((YEAR - 1980) << 9) \ | 
| 1028 |  | -                        | (C2DIG2DEC(MONTH) << 5) \ | 
| 1029 |  | -                        | C2DIG2DEC(DAY)) | 
|  | 1018 | +    if (date) *date = (1 << 5) | 1; | 
|  | 1019 | +    if (time) *time = 0; | 
|  | 1020 | +    if (tenth) *tenth = 0; | 
| 1030 | 1021 |  | 
| 1031 |  | -    bool date_forced = false; | 
| 1032 |  | -    bool next_day = false; | 
| 1033 |  | -    unsigned time2 = 0; /* double time, for CRTTIME with 1s precision */ | 
| 1034 |  | - | 
| 1035 |  | -    if (date && *date < BUILD_DATE_FAT) | 
| 1036 |  | -    { | 
| 1037 |  | -        *date = BUILD_DATE_FAT; | 
| 1038 |  | -        date_forced = true; | 
| 1039 |  | -    } | 
| 1040 |  | -     | 
| 1041 |  | -    if (time) | 
| 1042 |  | -    { | 
| 1043 |  | -        time2 = *time << 1; | 
| 1044 |  | -        if (time2 == 0 || date_forced) | 
| 1045 |  | -        { | 
| 1046 |  | -            time2 = (11 < 6) | 11; /* set to 00:11:11 */ | 
| 1047 |  | -        } | 
| 1048 |  | -        else | 
| 1049 |  | -        { | 
| 1050 |  | -            unsigned mins  = (time2 >> 6) & 0x3f; | 
| 1051 |  | -            unsigned hours = (time2 >> 12) & 0x1f; | 
| 1052 |  | -             | 
| 1053 |  | -            mins = 11 * ((mins/11) + 1); /* advance to next multiple of 11 */ | 
| 1054 |  | -            if (mins > 59) | 
| 1055 |  | -            { | 
| 1056 |  | -                mins = 11; /* 00 would be a bad marker */ | 
| 1057 |  | -                if (++hours > 23) | 
| 1058 |  | -                { | 
| 1059 |  | -                    hours = 0; | 
| 1060 |  | -                    next_day = true; | 
| 1061 |  | -                } | 
| 1062 |  | -            } | 
| 1063 |  | -            time2 = (hours << 12) | (mins << 6) | mins; /* secs = mins */ | 
| 1064 |  | -        } | 
| 1065 |  | -        *time = time2 >> 1; | 
| 1066 |  | -    } | 
| 1067 |  | -     | 
| 1068 |  | -    if (tenth) | 
| 1069 |  | -        *tenth = (time2 & 1) * 100; | 
| 1070 |  | - | 
| 1071 |  | -    if (date && next_day) | 
| 1072 |  | -    { | 
| 1073 |  | -        static const unsigned char daysinmonth[] = | 
| 1074 |  | -                              {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | 
| 1075 |  | -        unsigned day   = *date & 0x1f; | 
| 1076 |  | -        unsigned month = (*date >> 5) & 0x0f; | 
| 1077 |  | -        unsigned year  = (*date >> 9) & 0x7f; | 
| 1078 |  | - | 
| 1079 |  | -        /* simplification: ignore leap years */ | 
| 1080 |  | -        if (++day > daysinmonth[month-1]) | 
| 1081 |  | -        { | 
| 1082 |  | -            day = 1; | 
| 1083 |  | -            if (++month > 12) | 
| 1084 |  | -            { | 
| 1085 |  | -                month = 1; | 
| 1086 |  | -                year++; | 
| 1087 |  | -            } | 
| 1088 |  | -        } | 
| 1089 |  | -        *date = (year << 9) | (month << 5) | day; | 
| 1090 |  | -    } | 
| 1091 |  | - | 
| 1092 | 1022 | #endif /* CONFIG_RTC */ | 
| 1093 | 1023 | } | 
| 1094 | 1024 |  | 
| — | — | @@ -1104,7 +1034,7 @@ | 
| 1105 | 1035 | unsigned int sector = firstentry / DIR_ENTRIES_PER_SECTOR; | 
| 1106 | 1036 | unsigned char chksum = 0; | 
| 1107 | 1037 | unsigned int i, j=0; | 
| 1108 |  | -    unsigned int nameidx=0, namelen = utf8length(name); | 
|  | 1038 | +    unsigned int nameidx=0, namelen = strlen(name); | 
| 1109 | 1039 | int rc; | 
| 1110 | 1040 | unsigned short name_utf16[namelen + 1]; | 
| 1111 | 1041 |  | 
| — | — | @@ -1132,7 +1062,7 @@ | 
| 1133 | 1063 | /* we need to convert the name first    */ | 
| 1134 | 1064 | /* since it is written in reverse order */ | 
| 1135 | 1065 | for (i = 0; i <= namelen; i++) | 
| 1136 |  | -        name = utf8decode(name, &name_utf16[i]); | 
|  | 1066 | +        name_utf16[i] = *(name++); | 
| 1137 | 1067 |  | 
| 1138 | 1068 | for (i=0; i < numentries; i++) { | 
| 1139 | 1069 | /* new sector? */ | 
| — | — | @@ -2456,7 +2386,7 @@ | 
| 2457 | 2387 | break; | 
| 2458 | 2388 | /* utf8encode will return a pointer after the converted | 
| 2459 | 2389 | * string, subtract the pointer to the start to get the length of it */ | 
| 2460 |  | -                            segm_utf8len = utf8encode(ucs, longname_utf8segm) - longname_utf8segm; | 
|  | 2390 | +                            segm_utf8len = 1; | 
| 2461 | 2391 |  | 
| 2462 | 2392 | /* warn the trailing zero ! (FAT_FILENAME_BYTES includes it) */ | 
| 2463 | 2393 | if (longname_utf8len + segm_utf8len >= FAT_FILENAME_BYTES) { | 
| — | — | @@ -2465,6 +2395,8 @@ | 
| 2466 | 2396 | break; /* fallback later */ | 
| 2467 | 2397 | } | 
| 2468 | 2398 | else { | 
|  | 2399 | +                                if (ucs < 128) longname_utf8segm[0] = (unsigned char)ucs; | 
|  | 2400 | +                                else longname_utf8segm[0] = '?'; | 
| 2469 | 2401 | longname_utf8segm[segm_utf8len] = 0; | 
| 2470 | 2402 | strcat(entry->name + longname_utf8len, longname_utf8segm); | 
| 2471 | 2403 | longname_utf8len += segm_utf8len; | 
| — | — | @@ -2482,9 +2414,8 @@ | 
| 2483 | 2415 | are control characters. */ | 
| 2484 | 2416 | DEBUGF("SN-DOS: %s", shortname); | 
| 2485 | 2417 | unsigned char *utf8; | 
| 2486 |  | -                            utf8 = iso_decode(shortname, entry->name, -1, | 
| 2487 |  | -                                              strlen(shortname)); | 
| 2488 |  | -                            *utf8 = 0; | 
|  | 2418 | +                            memcpy(entry->name, shortname, strlen(shortname)); | 
|  | 2419 | +                            *(entry->name + strlen(shortname)) = 0; | 
| 2489 | 2420 | DEBUGF("SN: %s", entry->name); | 
| 2490 | 2421 | } else { | 
| 2491 | 2422 | DEBUGF("LN: %s", entry->name); |