⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xfile.c

📁 本程序为ST公司开发的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
/************************************************** * * xfile.c * * CVS ID:   $Id: xfile.c,v 1.138 2007/09/21 05:34:28 hara Exp $ * Author:   Ondrej Trubac [OT] - STM * Date:     $Date: 2007/09/21 05:34:28 $ * Revision: $Revision: 1.138 $ * * Description: * * *************************************************** * * COPYRIGHT (C) ST Microelectronics  2005 *            All Rights Reserved * *************************************************** * * STM CVS Log: * * $Log: xfile.c,v $ * Revision 1.138  2007/09/21 05:34:28  hara * Initial implementation for WMDRM feature into A+. * * Revision 1.137  2007/08/29 07:20:09  belardi * Changed absolute value to #define * * Revision 1.136  2007/08/28 13:08:05  trubac * Limit for 32K items in X_array * * Revision 1.135  2007/08/15 09:26:11  trubac * Bug fixed in XAR_TestExtension to support 5-byte extensions * * Revision 1.134  2007/08/06 07:42:29  belardi * Removed compiler warning * * Revision 1.133  2007/08/02 13:35:16  sedmik * added  XAR_PlayableFilesInDir for  checking playable files in specified directory * * Revision 1.132  2007/08/01 18:14:00  trubac * XAR_TestFileExtension changed: * - host_update_method of module_config controlling special file selection * * Revision 1.131  2007/08/01 10:28:12  trubac * Optimization of XAR_VolumeNodeForItem * * Revision 1.130  2007/07/19 11:09:19  trubac * Update file name configurable * * Revision 1.129  2007/03/15 11:45:02  trubac * directory names shrinking fixed * * Revision 1.128  2007/02/27 09:28:12  belardi * Changed variable type to remove compiler warning (uint to char) * * Revision 1.127  2007/02/26 14:36:15  trubac * lower case casting when file extension recognized in XAR_FileType * * Revision 1.126  2007/02/21 09:32:58  trubac * XAR_AddVolume was using uint16 vname instead of int * * Revision 1.125  2007/02/08 15:56:28  trubac * Optimization of song indexing * * Revision 1.124  2007/02/02 16:16:40  belardi * Changed cast in call to witeSDRAM32 to get rid of compiler warnings * * Revision 1.123  2007/01/29 14:32:00  chlapik * support for USB devices with any block size (not only 512B) * * Revision 1.122  2007/01/24 16:47:41  trubac * Filesystem supports 15000 files * String reverse page offset is in nodetype.b[1] * Bug fixed in deleting volumes - volume node could not have index>255 * * Revision 1.121  2007/01/18 15:01:31  trubac * Preparation for 15000 files * * Revision 1.120  2006/12/21 10:06:07  trubac * Handling of fragmented files improved * * Revision 1.119  2006/12/13 14:24:01  belardi * Moved functions outside of HAVE_EXTERNAL_MEMORY (were put there by mistake) * * Revision 1.118  2006/12/12 19:17:35  trubac * New functions for dir numbering, should be tested * * Revision 1.116  2006/11/28 15:59:14  trubac * host_file_index protected by X_safe_list * * Revision 1.115  2006/11/28 14:53:52  sedmik * increased  X_exfilter size to [40bytes] * * Revision 1.114  2006/11/28 13:49:44  belardi * Changed host update filename * * Revision 1.113  2006/11/28 10:16:57  belardi * Added ".m4a" extension to filters * * Revision 1.112  2006/11/28 09:40:06  trubac * comparison of file extensions is not changing to lower case * * Revision 1.111  2006/11/27 19:46:54  belardi * Host Update protocol addition * - added new return value used by XAR_TestFileExtension * * Revision 1.110  2006/11/25 08:14:09  belardi * Ununsed function removal to free code space * * Revision 1.109  2006/11/20 13:23:59  sedmik * fix in XAR_init file (used dirs numbering style variable) * * Revision 1.108  2006/11/16 13:15:03  trubac * SpecialFileNameList for firmware update file * * Revision 1.107  2006/11/15 15:01:52  trubac * PreviousSong selects only playable files * * Revision 1.106  2006/11/14 16:50:45  belardi * removed unreachable statements to reduce compiler warnings * * Revision 1.105  2006/11/10 15:10:50  belardi * Changes to compile for APM: STM code uses xfile.address field for quick song numbering. * APM does not need it, so it is removed to avoid some functions from possibly using it unitinialized * * Revision 1.104  2006/11/07 13:42:47  belardi * Removed unused variable to get rid of compiler warning * * Revision 1.103  2006/11/02 17:01:07  trubac * only pls and m3u playlists supported * * Revision 1.102  2006/11/01 13:55:02  trubac * Finding song nr. functions changed to be faster and to allow playlists * * Revision 1.100  2006/10/25 15:21:31  trubac * GetFileLBA fixed that caused problem w/o ext.memory * * Revision 1.99  2006/10/23 14:33:38  trubac * XAR_CreateSongIndexes called after new mount process * * Revision 1.98  2006/10/23 13:22:36  belardi * Fixed compilation error for HAVE_EXTERNA_XARRAY=0 * * Revision 1.97  2006/10/20 15:30:45  trubac * XAR_CreateSongIndexes added for faster index calculation * * Revision 1.96  2006/10/18 09:54:47  trubac * bug fix for no external X_array * * Revision 1.95  2006/10/17 14:20:42  chlapik * - XAR_ReallocateTOC used also for APM instead of clearing of whole X_array * * Revision 1.94  2006/10/17 10:01:35  trubac * TOC info at top of X_array * * Revision 1.93  2006/10/05 14:39:11  belardi * -Re-inserted CVS log in header * - avoid calling Song renumbering function when processing CD with Flash image (because the function assumes to work only with songs, not with data, so loops). Temporary fix. * * Revision 1.92  2006/10/5 7:30:56  trubac * Implementing TOC info at the end of string pool, slight RB changes adaptations * * Revision 1.91  2006/09/27 19:51:22  belardi * Removed (global) unused variables * * Revision 1.90  2006/09/26 11:44:47  belardi * Reintroduced line commented out in 1.88 for playlist tests * * Revision 1.89  2006/09/26 09:32:47  belardi * Added include to remove compiler warning * * Revision 1.88  2006/09/25 13:15:53  zaccaria * unused debug playlist code eliminated in XAR_NextSong function * * Revision 1.87  2006/09/22 13:59:14  belardi * Support for MPEG Layer I and II * - add .mp2 extension in X_exfilter * - updated XAR_FileType() * * Revision 1.86  2006/09/20 16:10:32  belardi * Conditional compilation for unused variable when HAVE_EXTERNAL_XARRAY=0 * * Revision 1.85  2006/09/15 19:51:13  belardi * Merged the m8_cav2_cm80506_cs3563. * - renamed X_LAST_ITEM * - removed unused functions (already commented out) * - removed APM-specific navigation functions * * ***************************************************/#include "configuration.h"#include "xfile.h"#include "gendef.h"#include "toc.h"#include "ISOtypes.h"#include "UDF_types.h"#include "capture.h"#include "id3tag.h"#include "filesys.h"#include <string.h>#include <stdio.h>#include "mconfig.h"#ifdef PLAYLIST_DEBUG#include "playlist.h"#endif#include "debug.h"#if (HAVE_WMDRM == 1) #include "WMDRM_Receiver.h"#endifextern semaphore_t sem_xfile;#if (1 == HAVE_EXTERNAL_XARRAY)uint32 XFILE_NODES_NUM;#elset_X_memory X_memory;#endift_XNode *X_array;uint16 X_dir_stop; // for faster next song searchinguint16 X_last_dir; /* [RB] extension MUST BE lower case */#if ((0 != HAVE_HOST_UPDATE) || (0 != HAVE_HOST_UPDATE_NEW))#define SpecialFileNameList ((char*)module_config.data.update_filename)#elsechar SpecialFileNameList[] = "\0";#endif//uint8 X_pool[6*1024];//uint16 X_last_item = 0;//uint16 X_pool_top = 0;//volatile uint16 X_curr_dir=0;//uint16 X_dir_stop,X_dir_first;uint16 *X_safe_list[X_SAFE_LIST_LENGTH];#if (HAVE_WMA == 1)#define PLACE_WMA_EXT '.','w','m','a',#else#define PLACE_WMA_EXT#endif#if (HAVE_AAC == 1)#define PLACE_AAC_EXT '.','a','a','c','.','m','4','a',#else#define PLACE_AAC_EXT#endif#if (HAVE_PLAYLIST == 1)#if (HAVE_WMDRM == 1)#define PLACE_PLST_EXT '.','p','l','s','.','m','3','u','.','p','l','a',#else#define PLACE_PLST_EXT '.','p','l','s','.','m','3','u',#endif#else#define PLACE_PLST_EXT#endif#if (LAYER2 == 1)#define PLACE_MP2_EXT '.','m','p','2',#else#define PLACE_MP2_EXT#endifuint8 X_exfilter[40]= { 'm','p','3',	PLACE_WMA_EXT	PLACE_AAC_EXT	PLACE_PLST_EXT	PLACE_MP2_EXT	0,0};	void memcpy16(void *dest, void *sour, int32 bytes);uint8 * filesys_get_name(t_XItem item){  UInt str;  uint8 *ptr;  if (item >= X_NEXTFREE_ITEM)    return NULL;  switch (XAR_NodeType(item))  {  case XTYPE_VOLUME:    str = X_array[item].data.xvolume.name;    break;  case XTYPE_DIRECTORY:    str = X_array[item].data.xdir.name;    break;  case XTYPE_DATA_FILE:    str = X_array[item].data.xfile.name;    break;  default:    return NULL;  }#if(HAVE_EXTERNAL_XARRAY==1)    str += (X_array[item].nodetype.b[1]<<16);      if (str == 0xffffff)#else  if (str == 0xffff)#endif    return NULL;  ptr = ((uint8 *)&X_array[XFILE_NODES_NUM]) - str - 1;#if HAVE_EXTERNAL_XARRAY  str = *(uint16*)ptr;#else  str = *ptr ;#endif  ptr -= str;  return ptr;}int filesys_name_length(t_XItem item){  UInt str;  switch (XAR_NodeType(item))  {  case XTYPE_VOLUME:    str = X_array[item].data.xvolume.name;    break;  case XTYPE_DIRECTORY:    str = X_array[item].data.xdir.name;    break;  case XTYPE_DATA_FILE:    str = X_array[item].data.xfile.name;    break;  default:    return 0;  }#if(HAVE_EXTERNAL_XARRAY==1)    str += (X_array[item].nodetype.b[1]<<16);      if (str == 0xffffff)#else  if (str == 0xffff)#endif      return 0;  #if HAVE_EXTERNAL_XARRAY    return *(uint16*)(((uint8 *)&X_array[XFILE_NODES_NUM]) - str - 1);#else    return *(((uint8*)&X_array[XFILE_NODES_NUM]) - str - 1);#endif}int filesys_update_name_length(t_XItem i,uint16 newlen){  UInt str;  switch (XAR_NodeType(i))  {  case XTYPE_VOLUME:    str = X_array[i].data.xvolume.name;    break;  case XTYPE_DIRECTORY:    str = X_array[i].data.xdir.name;    break;  case XTYPE_DATA_FILE:    str = X_array[i].data.xfile.name;    break;  default:    return 0;  }#if(HAVE_EXTERNAL_XARRAY==1)    str += (X_array[i].nodetype.b[1]<<16);      if (str == 0xffffff)#else  if (str == 0xffff)#endif  return 0;  #if HAVE_EXTERNAL_XARRAY    *(uint16*)(((uint8 *)&X_array[XFILE_NODES_NUM]) - str - 1) = newlen;#else    *(((uint8*)&X_array[XFILE_NODES_NUM]) - str - 1) = newlen;#endif    return 1;}t_XNodeType XAR_XNodeType(t_XItem node){  return (t_XNodeType) (0xFC & X_array[node].nodetype.i);}void XAR_ChangeXNodeType(t_XItem node, t_XNodeType type) /* BB060929a */{  X_array[node].nodetype.i &= ~0xFC;  X_array[node].nodetype.i |= (0xFC & type);}t_duid XAR_VolNodeDevType(t_XItem voli){  ASSERT((XAR_NodeType(voli) == XTYPE_VOLUME), "Not a volume node");  return (t_duid) ((X_array[voli].nodetype.i & 0x1C) >> 2);}#if 0 // [RB] unusedGRESULT XAR_SetVolNodeDevType(t_XItem voli,t_duid dev){	ASSERT((XAR_NodeType(voli)==XTYPE_VOLUME),"Not a volume node");	X_array[voli].type |= XAR_VolNodeDevPattern(dev);	return S_OK;}#endifint16 XAR_AddDirItem(DIR_ITEM *item, uint32 type){  uint8 *pt;  uint32 namelen;  if(X_NEXTFREE_ITEM > X_MAX_INDEX)     return E_FAIL;           // too many items in X_array, not addressable       if (type == XTYPE_DIRECTORY)  // directory  {#if HAVE_EXTERNAL_XARRAY    pt = ((uint8 *)&X_array[XFILE_NODES_NUM]) - X_POOL_TOP - 2;    if ((pt - (item->dir.NameLength) - 1) < (uint8 *)&X_array[X_NEXTFREE_ITEM + 1])      return E_INSUFFICIENT_MEMORY;#else    pt = ((uint8 *)&X_array[XFILE_NODES_NUM]) - X_POOL_TOP - 1;    if ((pt - (item->dir.NameLength)) < (uint8 *)&X_array[X_NEXTFREE_ITEM + 1])      return E_INSUFFICIENT_MEMORY;#endif    X_array[X_NEXTFREE_ITEM].nodetype.i = XTYPE_DIRECTORY;#if HAVE_EXTERNAL_XARRAY    writeSDRAM32((int16 *)&X_array[X_NEXTFREE_ITEM].data.xdir.lba, item->dir.DirRecordLba);#else    X_array[X_NEXTFREE_ITEM].data.xdir.lba_lsp = 0xffff & item->dir.DirRecordLba;    X_array[X_NEXTFREE_ITEM].data.xdir.lba_msp = (0xff0000 & item->dir.DirRecordLba) >> 16;#endif    X_array[X_NEXTFREE_ITEM].data.xdir.address = item->dir.ParentOffset;    X_array[X_NEXTFREE_ITEM].data.xdir.child = 0;    X_array[X_NEXTFREE_ITEM].data.xdir.parent = 0;    X_array[X_NEXTFREE_ITEM].data.xdir.first_file = 0;#if HAVE_EXTERNAL_XARRAY        X_array[X_NEXTFREE_ITEM].data.xdir.name = (X_POOL_TOP + 1)&0xffff;    X_array[X_NEXTFREE_ITEM].nodetype.i = X_array[X_NEXTFREE_ITEM].nodetype.b[0] | \                (((X_POOL_TOP + 1)&0xff0000)>>8);#else    X_array[X_NEXTFREE_ITEM].data.xdir.name = X_POOL_TOP;#endif    //       X_pool[X_pool_top]= item->dir.NameLength;    namelen = item->dir.NameLength;    namelen += (1 & item->dir.NameLength);#if HAVE_EXTERNAL_XARRAY    *(uint16 *) pt = item->dir.NameLength;    memcpy16(pt - item->dir.NameLength, item->dir.Name, namelen);    //X_POOL_TOP += namelen + 2;    writeSDRAM32((int16*)&X_POOL_TOP,X_POOL_TOP+namelen+2);    //X_pool_top += 1&item->dir.NameLength;#else    *pt = item->dir.NameLength;    memcpy(pt - (item->dir.NameLength), item->dir.Name, item->dir.NameLength);    X_POOL_TOP += item->dir.NameLength + 1;#endif  }  else      // file  {#if HAVE_EXTERNAL_XARRAY    pt = ((uint8 *)&X_array[XFILE_NODES_NUM]) - X_POOL_TOP - 2;#else    pt = ((uint8 *)&X_array[XFILE_NODES_NUM]) - X_POOL_TOP - 1;#endif    if (type == XTYPE_DATA_FILE)    {      if ((pt - (item->file.NameLength) - 1) < (uint8 *)&X_array[X_NEXTFREE_ITEM + 1])        return E_INSUFFICIENT_MEMORY;    }    else    {      if (pt < (uint8 *)&X_array[X_NEXTFREE_ITEM + 1])        return E_INSUFFICIENT_MEMORY;    }    X_array[X_NEXTFREE_ITEM].nodetype.i = type;#if HAVE_EXTERNAL_XARRAY    writeSDRAM32((int16 *)&X_array[X_NEXTFREE_ITEM].data.xfile.lba, item->file.ExtentLba);    writeSDRAM32((int16 *)&X_array[X_NEXTFREE_ITEM].data.xfile.size, item->file.FileSize);#else    X_array[X_NEXTFREE_ITEM].data.xfile.lba_lsp = 0xffff & item->file.ExtentLba;    X_array[X_NEXTFREE_ITEM].data.xfile.lba_msp = (0xff0000 & item->file.ExtentLba) >> 16;    X_array[X_NEXTFREE_ITEM].data.xfile.size = item->file.FileSize;#endif#ifndef APM_PICKUP    X_array[X_NEXTFREE_ITEM].data.xfile.address =    /*(item->file.DirRecordLba<<11)+ */ item->file.DirRecordOffset; //O.T. reduced length of address (16bits)#endif    X_array[X_NEXTFREE_ITEM].data.xfile.next_extent = 0;                                                  //M.Ch.    if (type == XTYPE_DATA_FILE)    {#if HAVE_EXTERNAL_XARRAY      //X_array[X_NEXTFREE_ITEM].data.xfile.name = X_POOL_TOP + 1;      X_array[X_NEXTFREE_ITEM].data.xfile.name = (X_POOL_TOP + 1)&0xffff;      X_array[X_NEXTFREE_ITEM].nodetype.i = X_array[X_NEXTFREE_ITEM].nodetype.b[0] + \                (((X_POOL_TOP + 1)&0xff0000)>>8);      namelen = item->file.NameLength;      namelen += (1 & item->file.NameLength);      *(uint16 *) pt = item->file.NameLength;      memcpy16(pt - item->file.NameLength, item->file.Name, namelen);      //X_POOL_TOP += (namelen + 2);      writeSDRAM32((int16*)&X_POOL_TOP,X_POOL_TOP+namelen+2);      //X_pool_top += 1&item->file.NameLength;   // justify to even value

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -