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

📄 flsystem.h

📁 电子盘DEMO板程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************/
/*                                                                            */
/*  Copyright (C), 1995-2006, msystems Ltd. All rights reserved.              */
/*                                                                            */
/*  Redistribution and use in source and binary forms, with or without        */
/*  modification, are permitted provided that the following conditions are    */
/*  met:                                                                      */
/*  1. Redistributions of source code must retain the above copyright notice, */
/*     this list of conditions and the following disclaimer.                  */
/*  2. Redistributions in binary form must reproduce the above copyright      */
/*     notice, this list of conditions and the following disclaimer in the    */
/*     documentation and/or other materials provided with the distribution.   */
/*  3. Neither the name of msystems nor the names of its contributors may be  */
/*     used to endorse or promote products derived from this software without */
/*     specific prior written permission.                                     */
/*                                                                            */
/*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       */
/*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
/*  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR             */
/*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      */
/*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,     */
/*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED  */
/*  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR    */
/*  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
/*  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      */
/*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        */
/*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
/*                                                                            */
/******************************************************************************/
/*
 * $Log:   V:/PVCSDB/DiskOnChip/archives/DocDriver/TrueFFS BD/systems/vc60/flsystem.h-arc  $
 * 
 *    Rev 1.5   Sep 11 2006 13:46:00   yaniv.iarovici
 * Legal header added
 * 
 *    Rev 1.4   Sep 03 2006 14:45:58   Yaniv.Iarovici
 * Removed un-used defines.
 * 
 *    Rev 1.3   Aug 22 2006 13:27:34   Yaniv.Iarovici
 * Define DOCH_32K_SLIDING_WINDOW by DEFAULT
 * 
 *    Rev 1.2   Aug 16 2006 09:37:50   Yaniv.Iarovici
 * Fix FL_DOC_ADDRESS to 0xD0000
 * 
 *    Rev 1.1   Aug 16 2006 08:49:40   Yaniv.Iarovici
 * Added customization as follows: (To enable DRQ > 1)
 * 	#define DOCHBLK_WRITE(address, buf, sectors) 	(flWriteEvenNumberOfBytes((DOCHFlash),(FLWord)DOCH_DATA_PORT_AREA,(buf),((FLWord)(512*sectors))),0)
 * 	#define DOCHBLK_READ(address, buf, sectors)	(flReadEvenNumberOfBytes((DOCHFlash),(FLWord)DOCH_DATA_PORT_AREA,(buf),((FLWord)(512*sectors))),0)
 * 
 * 
 *    Rev 1.0   Aug 08 2006 15:41:16   Polina.Marimont
 * Initial revision.
 */

#ifndef FLSYSTEM_H
#define FLSYSTEM_H

#include "flcustom.h" /* Application compilation flags */
#include "flsystyp.h" /* Basic system types            */

#include <memory.h> 
#include <windows.h> 
#include <winbase.h> 
#include <string.h>
#include <stdlib.h>
#include <stdio.h>


/* CPU target
 *
 * Use compiler switches or insert a #pragma here to select the CPU type
 * you are targeting.
 *
 */
struct __DMA_Params_S;



/* DiskOnChip window base address
 *
 * Defines the possible location of the DiskOnChip device. You should specify
 * the lowest and highest addresses for the search.
 *
 * The use of those definition, should be done in your own FLCUSTOM.C file.
 * Those definitions are for your convenient and are not used by TrueFFS itself.
 *
 * Note: The range in this example is for M-Systems x86 EVB's.
 */

#define FL_DOC_ADDRESS  0xD0000L



/* NULL constant
 *
 * Some compilers require a different definition for the NULL pointer.
 */

#ifndef NULL
#define NULL ((void *)0)
#endif

/*
 * First IOCTL function number
 *
 * When using TrueFFS' IOCTL functions you have to define the code of the first 
 * TrueFFS IOCTL function (after that the functions get consecutive increasing numbers).
 * This number should be out of the range of the standard IOCTL codes used by your 
 * operating system.
 *
 */

#define FL_IOCTL_START  0

/* Naming convention for functions that uses non-default convention. 
 *
 * In case the calling application uses a different convention then the one 
 * used to compile TrueFFS you can use the NAMING_CONVENTION definition. 
 * The NAMING_CONVENTION definition is added as a qualifier to all TrueFFS 
 * exported API. A good example is a c++ application that uses TrueFFS, 
 * which was compiled using standard C.If this is not the case simply leave 
 * the NAMING_CONVENTION defined as empty macro.
 */

#define NAMING_CONVENTION cdecl 

/* Little-endian/big-endian
 *
 * If your machine uses the big-endian (Motorola) format, uncomment the
 * following line.
 *
 * This compilation flag makes sure that FAT and translation layer structures
 * will be written in little-endian (Intel) format for integers. It also 
 * affects the way DiskOnChip 16 bits registers are analyzed.
 */

/* #define FL_BIG_ENDIAN */

/* #define FL_NO_PACKED_STRUCTS_SUPPORTED */

/* H/W Byte swap 
 *
 * DiskOnChip devices support the H/W byte swap feature in order to support
 * situations where the device data lines were not properly connected 
 * (sometimes happen due to big/little endian design mistakes). 
 *
 * The compilation flag will automatically swap every 16 bit access to and
 * from the DiskOnChip device.
 */

/* #define FL_SWAP_BYTES */



/* Memory routines for RAM buffers
 *
 * The library routines memcpy, memset, and memcmp are standard for ANSI-C
 * compilers. However, there may be variations in which a #include defines
 * them, and variations such as the Borland's _fmemcpy, _fmemset, and _fmemcmp
 * routines also exist. To overcome such nuances, the TrueFFS code uses memory
 * handling macros called tffscpy, tffsset, and tffscmp, with prototypes 
 * identical to the standard memcpy, memset, memcmp. Provide the correct 
 * #include directive, and incorporate C macros that define the tffsxxx 
 * routines to the names of your library routines (or user-supplied routines
 * to manually code these routines).
 */

#define tffscpy memcpy
#define tffscmp memcmp
#define tffsset memset



/* Pointer arithmetic
 *
 * The following macros define machine and compiler-dependent macros for
 * handling pointers to physical window addresses. The definitions below are
 * for x86 using Windows XP on an M-Systems EVB.
 *
 * 'physicalToPointer' translates a physical flat address to a pointer.
 * Note that if your processor uses virtual memory, the code should
 * map the physical address to virtual memory, and return a pointer to that
 * memory (the size parameter tells how much memory should be mapped).
 *
 */

/* The include file and pragma bellows are used for opening a memory window to
 * the DiskOnChip device in Windows 2000 and up.
 */
#include "MapMemAPI.h"
#pragma comment(lib, "MapMemory.lib")
#define physicalToPointer(physical,size,drive) (GetPointerFromPhysAddress(physical))


/* The rest of the arithmetics are trivial addition and subtractions. */
#define addToFarPointer(base,increment)			\
	((void *) (((unsigned char *)(base)) + (increment)))
#define subFromFarPointer(base,increment)		\
       addToFarPointer(base,(-(long)(increment)))
#define distanceBetweenFarPointers(ptr1, ptr2)		\
	(((unsigned long)(ptr1)) - ((unsigned long)(ptr2)))
#define pointerToPhysical(ptr)  ((unsigned long)(ptr)) 
#define freePointer(ptr,size)



/*
 * Signed/unsigned char
 *
 * It is assumed that 'char' is signed. If this is not your compiler
 * default, use compiler switches, or insert a #pragma here to define this.
 *
 */



/* Mutex type
 *
 * If you intend to access the TrueFFS API in a multi-tasking environment,
 * you may need to implement some resource management and mutual-exclusion
 * of TrueFFS with mutex & semaphore services that are available to you. In
 * this case, define here the Mutex type you will use, and provide your own
 * implementation of the Mutex functions in flcustom.c
 *
 * By default, a Mutex is defined as a simple counter, and the Mutex
 * functions in flcustom.c implement locking and unlocking by incrementing
 * and decrementing the counter. This will work well on all single-tasking
 * environments, as well as on many multi-tasking environments.
 */

typedef int FLMutex;



/* Memory allocation
 *
 * Some modules in TrueFFS initialization routines need to allocate
 * memory to handle the Flash media. The required size depends on the media
 * being handled.
 *
 * You may choose to use the standard 'malloc' and 'free' to handle such
 * memory allocations, provide your own equivalent routines, or you may
 * choose not to define any memory allocation routine. In this case, the
 * memory will be allocated statically at compile-time on the assumption of
 * the largest media configuration you need to support. This is the simplest
 * choice, but may cause your RAM requirements to be larger than you
 * actually need.
 *
 * If you define routines other than malloc & free, they should have the
 * same parameters and return types as malloc & free. You should either code
 * these routines in flcustom.c or include them when you link your application.
 *
 * In case you do not have dynamic allocation resources, then you can use the 
 * TrueFFS implementation. You will need to set the FL_TRUEFFS_HEAP_SIZE 
 * definition in FLCUSTOM.H and add FLMALLOC.C to your application or driver.
 */

#if FL_TRUEFFS_HEAP_SIZE > 0

⌨️ 快捷键说明

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