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

📄 fsal.h

📁 最新MTK手机软件源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*******************************************************************************
 *
 * Filename:
 * ---------
 *   fsal.h
 *
 * Project:
 * --------
 *   MAUI
 *
 * Description:
 * ------------
 *   File System Abstraction Layer, with buffered read/write.
 *
 * Author:
 * -------
 * -------
 *
 *==============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 *
 * removed!
 * removed!
 *
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *==============================================================================
 *******************************************************************************/

/**
 * \file fsal.h
 * \author Murphy Chen
 * \version $Revision:   1.26  $
 * \date $Modtime:   May 16 2005 23:18:18  $
 *
 * FSAL stands for File System Abstraction Layer.
 * This layer provides the following functionalities:
 * - Isolate the underlying file systems.
 * - Provide buffered read/write operations.
 * - Provide bits/bytes accessing functions.
 */

#ifndef __FSAL_BUFFER_H__
#define __FSAL_BUFFER_H__


#ifndef MMI_ON_WIN32
   /// For target and MoDIS
   #define FSAL_VERBOSE 0
   #include "kal_release.h"
   #include "fat_fs.h"
   #include "med_status.h"
   /// access MOD_MED module ID for kal_prompt_trace
   #include "stack_config.h"
   /// for kal_prompt_trace
   #include "kal_trace.h"
   #define FSAL_PLATFORM_KAL 1
   #define FSAL_PLATFORM_WIN32 0
   #define FSAL_PLATFORM_MEMORY 0
#else
   /// For Win32 standalone application, unit test and PC Simulator
   #include <stdio.h>
   #include <assert.h>
   #include <string.h>
   #ifndef ASSERT
      #define ASSERT(x) assert(x)
   #endif
   #define FSAL_VERBOSE 0
   #define kal_mem_cpy(a,b,c) memcpy(a,b,c)
   #include "kal_non_specific_general_types.h"
   #define MED_STAT_FSAL_START 0
   #define FSAL_PLATFORM_KAL 0
   #define FSAL_PLATFORM_WIN32 1
   #define FSAL_PLATFORM_MEMORY 0
#endif

typedef enum {
   FSAL_OK = MED_STAT_FSAL_START,
   FSAL_OPEN_ERROR,
   FSAL_READ_ERROR,
   FSAL_WRITE_ERROR,
   FSAL_SEEK_ERROR,
   FSAL_CLOSE_ERROR,
   FSAL_INVALID_ARGUMENT,
   /// The field of the structure is invalid. Possibly caused by memory corruption.
   FSAL_MEMORY_CORRUPTION,
   FSAL_FATAL_ERROR,
   FSAL_DEVICE_BUSY
} FSAL_Status;



typedef enum {
   /// Open for reading.
   FSAL_READ = 0,
   /// Open for reading and writing.
   /// The file is created if it is not existed, otherwise it is truncated.
   FSAL_WRITE,
   /// Open for reading and appending.
   /// The file is created if it is not existed.
   FSAL_APPEND,
   /// Open a ROM file for reading.
   /// FSAL_Direct_SetRamFileSize shall be called before calling FSAL_Open.
   FSAL_ROMFILE,
   ///
   FSAL_NONBLOCKING = 0x80
} FSAL_FileMode;

/**
 * The memory space of the FSAL structure is prepared by the caller.
 * Accesses to each file requires a separate instance of each FSAL structure.
 * The content of the structuer will be initialized via the FSAL_Open
 * function call.
 * And the pointer to the structure need to be passed as the first argument
 * to each FSAL function invocations.
 */
typedef struct {
   /* file system abstration layer*/
#if FSAL_PLATFORM_KAL
   FS_HANDLE hFile;
   /// error code from file system
   kal_int32 iFSErrorCode;
#elif FSAL_PLATFORM_MEMORY
   kal_uint32 uMaxRamFileSize;
#elif FSAL_PLATFORM_WIN32
   FILE *hFile;
#endif
   /// For ROM file. Point to the start memory address of the file.
   kal_uint8 *pbFile;
   kal_uint32 uRamFileSize;
   kal_uint32 uRamFileOffset;
   kal_uint32 uFileSize;
   kal_uint32 uFileOffset;
   kal_bool bBuffering;
   kal_uint8 *pbBuf;
   kal_uint32 uBufSize;
   kal_uint32 uCachedBlock;
   kal_bool bDirty; /* whether the cache has been written to */
} STFSAL;

/* ------ Private Macros ------ */

#define FSAL_CHECK_ARG(exp) \
   if (!(exp)) \
      return FSAL_INVALID_ARGUMENT

#define FSAL_ASSERT(exp) \
   if (!(exp)) \
      return FSAL_FATAL_ERROR

#define FSAL_ASSERT_NO_RET_VAL(exp) \
   if (!(exp)) \
      return

/* ------ public functions ------ */

/**
 * Open the file.
 *
 * @param pstFSAL pointer to FSAL structure prepared by caller.
 * FSAL will initialize the structure.
 * @param szFile pointer to a string contained the file name when opened in FSAL_READ,
 * FSAL_WRITE, or FSAL_APPEND mode; pointer to the start memory address of the file
 * when opened in FSAL_ROMFILE mode.
 * @param eMode file operation mode.
 *
 * @return If the function succeeds, the return value is FSAL_OK.
 * Otherwise, an error code is returned.
 */
FSAL_Status FSAL_Open(STFSAL *pstFSAL, void *szFile, FSAL_FileMode eMode);

/**
 * Open the file which has been opened via file I/O API with its file handle.
 * Please do not call FSAL_Close for this handle.
 *
 * @param pstFSAL pointer to FSAL structure prepared by caller.
 * FSAL will initialize the structure.
 * @param pFileHandle file handle of the underlying file I/O API.
 *
 * @return If the function succeeds, the return value is FSAL_OK.
 * Otherwise, an error code is returned.
 */
FSAL_Status FSAL_Open_WithHandle(STFSAL *pstFSAL, void *pFileHandle);

/**
 * Open an existing file. When using this interface, you need to consider
 * about the issues of multiple access to the same file.
 * Please do not call FSAL_Close for this handle.
 *
 * @param pstFSAL pointer to FSAL structure prepared by caller.
 * FSAL will initialize the structure.
 * @param pstFSAL_Existing pointer to an existing FSAL structure,
 * FSAL will access file opened via the file handle in that structure.
 *
 * @return If the function succeeds, the return value is FSAL_OK.
 * Otherwise, an error code is returned.
 */
FSAL_Status FSAL_Open_Attach(STFSAL *pstFSAL, STFSAL *pstFSAL_Existing);

/**
 * Client prepares its own buffer and call this function
 * to set buffer for FSAL cache.
 *
 * @param pstFSAL pointer to FSAL structure.
 * @param uBufferSize size of the buffer in unit of byte.
 * @param pbBuf memory location of the buffer
 *
 * @return None.
 */
void FSAL_SetBuffer(STFSAL *pstFSAL, kal_uint32 uBufferSize, kal_uint8 *pbBuf);

/**
 * Flush FSAL cache and close the file.
 *
 * @param pstFSAL pointer to FSAL structure.
 *

⌨️ 快捷键说明

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