fx_api.h

来自「Zoran V966 DVD 解码 Soc芯片的源程序」· C头文件 代码 · 共 963 行 · 第 1/3 页

H
963
字号
/**************************************************************************/ 
/*                                                                        */ 
/*            Copyright (c) 1996-2002 by Express Logic Inc.               */ 
/*                                                                        */ 
/*  This software is copyrighted by and is the sole property of Express   */ 
/*  Logic, Inc.  All rights, title, ownership, or other interests         */ 
/*  in the software remain the property of Express Logic, Inc.  This      */ 
/*  software may only be used in accordance with the corresponding        */ 
/*  license agreement.  Any unauthorized use, duplication, transmission,  */ 
/*  distribution, or disclosure of this software is expressly forbidden.  */ 
/*                                                                        */
/*  This Copyright notice may not be removed or modified without prior    */ 
/*  written consent of Express Logic, Inc.                                */ 
/*                                                                        */ 
/*  Express Logic, Inc. reserves the right to modify this software        */ 
/*  without notice.                                                       */ 
/*                                                                        */ 
/*  Express Logic, Inc.                     info@expresslogic.com         */
/*  11423 West Bernardo Court               http://www.expresslogic.com   */
/*  San Diego, CA  92127                                                  */
/*                                                                        */
/**************************************************************************/


/**************************************************************************/
/**************************************************************************/
/**                                                                       */ 
/** FileX Component                                                       */
/**                                                                       */
/**   Application Interface (API)                                         */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/


/**************************************************************************/ 
/*                                                                        */ 
/*  APPLICATION INTERFACE DEFINITION                       RELEASE        */ 
/*                                                                        */ 
/*    fx_api.h                                            PORTABLE C      */ 
/*                                                           3.0          */ 
/*  AUTHOR                                                                */ 
/*                                                                        */ 
/*    William E. Lamie, Express Logic, Inc.                               */ 
/*                                                                        */ 
/*  DESCRIPTION                                                           */ 
/*                                                                        */ 
/*    This file defines the basic Application Interface (API) to the      */ 
/*    high-performance FileX MS-DOS compatible embedded file system.      */ 
/*    All service prototypes and data structure definitions are defined   */ 
/*    in this file.                                                       */ 
/*                                                                        */ 
/*  RELEASE HISTORY                                                       */ 
/*                                                                        */ 
/*    DATE              NAME                      DESCRIPTION             */ 
/*                                                                        */ 
/*  01-01-1999     William E. Lamie         Initial Version 1.0           */ 
/*  03-01-2000     William E. Lamie         Modified comment(s), added    */ 
/*                                            FX_MAXIMUM_PATH constant,   */ 
/*                                            added current path string,  */ 
/*                                            added prototype for the     */ 
/*                                            fx_system_time_get call,    */ 
/*                                            and added prototypes for    */ 
/*                                            utilities used by drivers,  */ 
/*                                            resulting in version 1.0b.  */ 
/*  01-28-2001     William E. Lamie         Modified comment(s), added    */ 
/*                                            new constants, function     */ 
/*                                            prototypes, local path      */ 
/*                                            logic, smart FAT searching, */ 
/*                                            and support for logical     */ 
/*                                            sector caching, resulting   */ 
/*                                            in version 2.0.             */ 
/*  03-01-2002     Mohammad N. Minhaz       Modified comment(s),          */ 
/*                                            added FAT32 constants and   */ 
/*                                            structure fields, changed   */ 
/*                                            directory name size for     */ 
/*                                            long file name support,     */ 
/*                                            added write protect flag,   */ 
/*                                            and added support for       */ 
/*                                            notification of drive when  */ 
/*                                            clusters are freed,         */ 
/*                                            resulting in version 3.0.   */ 
/*                                                                        */
/**************************************************************************/ 

#ifndef  FX_API
#define  FX_API

#define _fx_utility_16_unsigned_read(source_ptr) \
    (((((UINT) *((source_ptr) + 1)) & 0xFF) << 8) | \
       ((UINT) *(source_ptr) & 0xFF))

#define _fx_utility_16_unsigned_write(dest_ptr, value) \
   {*((dest_ptr)) =       (UCHAR) ((value) & 0xFF);\
    *((dest_ptr) + 1) =   (UCHAR) (((value) >> 8) & 0xFF);}

#define  _fx_utility_32_unsigned_read(source_ptr) \
  			   (((((ULONG) *((source_ptr)+3)) & 0xFF) << 24) | \
             ((((ULONG) *((source_ptr)+2)) & 0xFF) << 16) | \
             ((((ULONG) *((source_ptr)+1)) & 0xFF) << 8)  | \
              (((ULONG) *(source_ptr)) & 0xFF))

#define _fx_utility_32_unsigned_write(dest_ptr,value) \
   {*((UCHAR_PTR)(dest_ptr)) =       (UCHAR)  (((ULONG)(value)) & 0xFF);\
    *(((UCHAR_PTR)(dest_ptr)) + 1) =   (UCHAR) ((((ULONG)(value)) >> 8) & 0xFF);\
    *(((UCHAR_PTR)(dest_ptr)) + 2) =   (UCHAR) ((((ULONG)(value)) >> 16) & 0xFF);\
    *(((UCHAR_PTR)(dest_ptr)) + 3) =   (UCHAR) ((((ULONG)(value)) >> 24) & 0xFF);}


/* Determine if a C++ compiler is being used.  If so, ensure that standard
   C is used to process the API information.  */

#ifdef   __cplusplus

/* Yes, C++ compiler is present.  Use standard C.  */
extern   "C" {

#endif

// Remove checking
#define FX_DISABLE_ERROR_CHECKING

#ifdef FILEX_ENABLE_WRITE
//moved second fat map to SDRAM
#define FILEX_REMOVE_SECOND_FAT_MAP  

//remove default path string
#define FILEX_NO_DEFAULT_PATH_STRING

// TODO: Currently it dose not support time related features in filex functions
//#define FILEX_ENABLE_UTILITY_TIME
#endif

// Added by Ofir in order to avoid semaphores and timers
#define FX_NO_TIMER
#define FX_NO_LOCAL_PATH
#define FX_SINGLE_THREAD
#define TX_NO_LOCAL_PATH

#ifdef FILEX_ENABLE_WRITE
// The maximal length for LFN.
#define FX_MAX_LONG_NAME_LEN    54//64 simon.huang the length is decreased to save memory, make FX_MEDIA <= 512B
#endif

/* Include the FileX port-specific file.  */

#include "Playcore\FileSys\FileX\fx_port.h"
#include "Mediacards\include\register.h"

/* Define basic constants for FileX.  */

#define FX_MEDIA_ID           0x4D454449UL
#define FX_MEDIA_DIRECT_ID    0x4D454448UL
#define FX_MEDIA_CLOSED_ID    0x4D454443UL
#define FX_MEDIA_ABORTED_ID   0x4D454441UL
#define FX_DIRECT_SUCCESS   0x91
#define FX_MEDIA_INVALID    0x02
#define FX_BUFFER_ERROR     0x21
#define FX_FREE_CLUSTER         0x0000

#define FX_FILE_ID            0x46494C45UL
#define FX_FILE_CLOSED_ID     0x46494C43UL
#define FX_FILE_ABORTED_ID    0x46494C41UL

#define FX_MAXIMUM_PATH     256

#ifdef FILEX_READ_4_SECTORS
#define FX_MAX_SECTOR_CACHE 2
#else
#define FX_MAX_SECTOR_CACHE 1
#endif

#ifdef FILEX_ENABLE_WRITE
#define FX_SECTOR_SIZE      512
#endif


/* FileX API input parameters and general constants.  */

#define FX_FAIL             2          //XD_FAST_LOADING
#define FX_TRUE             1
#define FX_FALSE            0
#define FX_NULL             0
#define FX_OPEN_FOR_READ    0
#define FX_OPEN_FOR_WRITE   1
#ifdef FILEX_ENABLE_WRITE 
#define FX_OPEN_FOR_WRITE_BURST 0x80
#endif

#define FX_NO_PARTITION        0xFFFFFFFFUL

#define FX_FAT_ENTRY_START  2
#define FX_DIR_ENTRY_SIZE   32UL
#define FX_DIR_NAME_SIZE    8
#define FX_DIR_EXT_SIZE     3
#define FX_DIR_RESERVED     8
#define FX_DIR_ENTRY_FREE   0xE5
#define FX_DIR_ENTRY_DONE   0x00
#define FX_READ_ONLY        0x01
#define FX_HIDDEN           0x02
#define FX_SYSTEM           0x04
#define FX_VOLUME           0x08
#define FX_DIRECTORY        0x10
#define FX_ARCHIVE          0x20
#define FX_LONG_NAME        0x0f

#define FX_12_BIT_FAT_SIZE  4086
#define FX_16_BIT_FAT_SIZE  65525U

/* Define MS-DOS FAT entry values.  */

#define FX_RESERVED_1           0xFFF0
#define FX_LAST_CLUSTER_1       0xFFF8

#define FX_RESERVED_1_32        0x0FFFFFF0UL
#define FX_LAST_CLUSTER_1_32    0x0FFFFFF8UL

#ifdef FILEX_ENABLE_WRITE
#define FX_LAST_CLUSTER_2       0xFFFF
#define FX_LAST_CLUSTER_2_32    0x0FFFFFFFUL
#endif

/* Define time/date MS-DOS constants.  */

#define FX_YEAR_SHIFT       9
#define FX_MONTH_SHIFT      5
#define FX_HOUR_SHIFT       11
#define FX_MINUTE_SHIFT     5

#define FX_YEAR_MASK        0x7F
#define FX_MONTH_MASK       0x0F
#define FX_DAY_MASK         0x1F
#define FX_HOUR_MASK        0x1F
#define FX_MINUTE_MASK      0x3F
#define FX_SECOND_MASK      0x1F
#define FX_BASE_YEAR        1980
#define FX_INITIAL_DATE     0x2C61          /* 3-1-2002 */
#define FX_INITIAL_TIME     0x0000          /* 12:00 am */
#ifdef FILEX_ENABLE_WRITE
#define FX_MAXIMUM_YEAR     2107
#define FX_MAXIMUM_MONTH    12
#define FX_MAXIMUM_HOUR     23
#define FX_MAXIMUM_MINUTE   59
#define FX_MAXIMUM_SECOND   59
#endif

/* FileX API return values.  */

#define FX_SUCCESS          0x00
#define FX_FAT_READ_ERROR   0x03
#define FX_NOT_FOUND        0x04
#define FX_NOT_A_FILE       0x05
#define FX_ACCESS_ERROR     0x06
#define FX_NOT_OPEN         0x07
#define FX_FILE_CORRUPT     0x08
#define FX_END_OF_FILE      0x09
#define FX_INVALID_PATH     0x0D
#define FX_NOT_DIRECTORY    0x0E
#define FX_NO_MORE_ENTRIES  0x0F
#define FX_MEDIA_NOT_OPEN   0x11
#define FX_NOT_IMPLEMENTED  0x22
#define FX_WRITE_PROTECT	0x23
#define FX_SECTOR_INVALID   0x89
#define FX_IO_ERROR         0x90
//#define FX_DIRECT_SUCCESS    0xF1
#define FX_GENERAL_ERROR     0xF2
#define FX_READ_ONLY_ERROR   0xF3

#ifdef FILEX_ENABLE_WRITE 
#define FX_NO_MORE_SPACE     0x0A
#define FX_ALREADY_CREATED   0x0B
#define FX_INVALID_NAME      0x0C
#define FX_DIR_NOT_EMPTY     0x10
#endif


/* FileX driver interface constants.  */

#define FX_DRIVER_READ                0
#define FX_DRIVER_WRITE               1
#define FX_DRIVER_FLUSH               2
#define FX_DRIVER_ABORT               3
#define FX_DRIVER_INIT                4
#define FX_DRIVER_BOOT_READ           5
#define FX_DRIVER_RELEASE_SECTORS     6
#define FX_DRIVER_ERASE               7
#define FX_DRIVER_GET_MEDIA_GEOMETRY  8
#define FX_DRIVER_GET_DEVICE_GEOMETRY 9 // new - NOTICE!
#define FX_DRIVER_FORMAT_DEVICE       16
#define FX_DRIVER_FORMAT_PARTITION    10
#define FX_DRIVER_INIT_ON_FORMAT      11
#define FX_DRIVER_OPEN_BURST          12
#define FX_DRIVER_WRITE_BURST         13
#define FX_DRIVER_CLOSE_BURST         14
#define FX_DRIVER_CHECK_WP_STATUS     15

/* Define the control block definitions for all system objects.  */

/* Define media geometry structure. This structure contains fields describing
   the media both physically and logically. It is initialized by calling
   _fx_utility_get_media_geometry for the specified media. The structure
   is divided into groups of related parameters. Changing this structure
   requires good understanding of its functionality. */

// These are invalid values used to initialize the parameter groups of the
// structure.

#define FX_UNDEF_CYLINDERS           0
#define FX_UNDEF_START_END           0xFFFF
#define FX_UNDEF_CLUSTER_SIZE        0
#define FX_UNDEF_ROOT_ENTRIES        0
#define FX_UNDEF_SIZE_IN_SECTORS     0xFFFFFFFFUL
#define FX_UNDEF_SECTORS_PER_FAT     0
#define FX_UNDEF_HIDDEN_SECTORS      0xFFFFFFFFUL
#define FX_UNDEF_FAT_TYPE            0xFF
#define FX_UNDEF_PARTITION_ALIGNMENT 0
#define FX_UNDEF_MBR_SECTOR          0xFFFFFFFFUL

#define FX_BOOT_SECTOR_SIZE 512

#ifdef FILEX_ENABLE_WRITE

⌨️ 快捷键说明

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