qnx学习笔记-QNX系统下载graphic镜-卡在Load QNX image from SDMMC...卡住不动
...
/* copy a file from to a memory location */
static int
fat_copy_file(unsigned cluster, unsigned size, unsigned char *buf)
{
#if 1
int result, txf;
unsigned prev_c, next_c, curr_c;
int sz = (int)size;
int cbytes = fs_info.cluster_size*SECTOR_SIZE;
int actual_len = 0;
if(sdmmc_debug > 1)
{
ser_putstr((char *)"fat_copy_file: cs 0x");
ser_puthex(fs_info.cluster_size);
ser_putstr((char *)" size 0x");
ser_puthex(sz);
ser_putstr((char *)"type 0x");
ser_puthex(fs_info.fat_type );
ser_putstr((char *)"\n");
}
#if 1
cache_valid = 1;
#endif
g_fat_sector = -1;
/*
*Note that this impl assume the following:
* 1) The max DMA transfer size is bigger than the max consolidate transfer size
* Otherwise, we need to break down into smaller transfer.
* 2) we always do at least one whole cluster transfer. This might overwrite the client buffer, but
* since this is purely used for IPL, we don't care about that now.
*/
curr_c = cluster;
while(sz>0){
txf = cbytes;
prev_c = curr_c;
while(sz>txf){
//try consolidate contigus entry;
next_c = fat_get_fat_entry(curr_c);
if(next_c == (curr_c+1) && txf > 20*SECTOR_SIZE){
txf +=cbytes;
curr_c = next_c;
}else{
curr_c = next_c;
break;
}
}
if(sdmmc_debug > 4)
{
ser_putstr((char *)"blkcnt 0x");
ser_puthex(txf/SECTOR_SIZE);
ser_putstr((char *)" p 0x");
ser_puthex(prev_c);
ser_putstr((char *)" n 0x");
ser_puthex(curr_c);
ser_putstr((char *)"\n");
}
//read the contig cluster out
result= read_fsector(cluster2fsector(prev_c), buf, txf/SECTOR_SIZE) ;
if (result != SDMMC_OK)
return result;
sz -= txf;
buf += txf;
actual_len += txf;
}
#else
int sz = (int)size;
while(!end_of_file(cluster) && (sz > 0)) {
int txf = MIN(sz, fs_info.cluster_size * SECTOR_SIZE);
if (SDMMC_OK != read_cluster(cluster, buf, txf)) {
ser_putstr(" Error - read_clust(): clust buf txf = ");
ser_puthex((unsigned int)clust); ser_putstr(" ");
ser_puthex((unsigned int)buf); ser_putstr(" ");
ser_puthex((unsigned int)txf); ser_putstr("\n");
return SDMMC_ERROR;
}
ser_putstr((char *)"cluster %x");
ser_puthex(cluster);
ser_putstr((char *)"\n");
sz -= txf;
buf += txf;
cluster = fat_get_fat_entry(cluster);
}
#endif
if(sdmmc_debug > 0)
{
ser_putstr("Actual read fs size = 0x");
ser_puthex(actual_len);
ser_putstr("\n");
}
return SDMMC_OK;
}