📄 mtdsa.h
字号:
/* pointer to that memory (the size parameter tells how much memory */
/* should be mapped). */
/* */
/* 'addToFarPointer' adds an increment to a pointer and returns a new */
/* pointer. The increment may be as large as your window size. The code */
/* below assumes that the increment is larger than 64 KB and so */
/* performs huge pointer arithmetic. */
/* */
/* 'freePointer' frees an allocated pointer. This is useful in */
/* architectures using virtual memory. */
/* */
/* The example bellow is relevant for DOS OS */
/************************************************************************/
#if FAR_LEVEL > 0
#define physicalToPointer(physical,size,driveNo) \
MK_FP((int) ((physical) >> 4),(int) (physical) & 0xF)
#define pointerToPhysical(ptr) \
(((unsigned long) FP_SEG(ptr) << 4) + FP_OFF(ptr))
#define freePointer(ptr,size) 1
#define addToFarPointer(base,increment) \
MK_FP(FP_SEG(base) + \
((unsigned short) ((FP_OFF(base) + (unsigned long)(increment)) >> 16) << 12), \
FP_OFF(base) + (int) (increment))
#else
#define physicalToPointer(physical,size,driveNo) ((void *) (physical))
#define pointerToPhysical(ptr) ((unsigned long)(ptr))
#define addToFarPointer(base,increment) ((void *) ((unsigned char *) (base) + (increment)))
#define freePointer(ptr,size) 1
#endif
/************************************************************************/
/* Debug mode */
/* */
/* Uncomment the following lines if you want debug messages to be */
/* printed out. Messages will be printed at initialization key points, */
/* and when low-level errors occur. */
/* You may choose to use 'printf' or provide your own routine. */
/************************************************************************/
#ifdef BDK_DEBUG
#include <stdio.h>
#define DEBUG_PRINT(p) printf p
#define DFORMAT_PRINT(p) printf p
#else
#define DEBUG_PRINT(str)
#define DFORMAT_PRINT(str)
#endif
/************************************************************************/
/* Default calling convention */
/* */
/* C compilers usually use the C calling convention to routines (cdecl),*/
/* but often can also use the pascal calling convention, which is */
/* somewhat more economical in code size. Some compilers also have */
/* specialized calling conventions which may be suitable. Use compiler */
/* switches or insert a #pragma here to select your favorite calling */
/* convention. */
/************************************************************************/
#if (CURRENT_OS == CUR_OS_DOS)
#pragma option -p /* Default pascal calling convention */
#endif /* CURRENT_OS == CUR_OS_DOS */
/************************************************************************/
/* NULL constant */
/* */
/* Some compilers require a different definition for the NULL pointer */
/************************************************************************/
#if (CURRENT_OS == CUR_OS_DOS)
#include <_null.h>
#else
#ifndef NULL
#define NULL ((void FAR0*)0)
#endif /* NULL */
#endif /* CURRENT_OS == CUR_OS_DOS */
/************************************************************************/
/* 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. */
/************************************************************************/
#if (CURRENT_OS == CUR_OS_DOS)
#pragma option -K- /* default char is signed */
#endif /* CURRENT_OS == CUR_OS_DOS */
/************************************************************************/
/* CPU target */
/* */
/* Use compiler switches or insert a #pragma here to select the CPU */
/* type you are targeting. */
/* */
/* If the target is an Intel 80386 or above, also uncomment the */
/* CPU_i386 definition. */
/************************************************************************/
#if (CURRENT_OS == CUR_OS_DOS)
#pragma option -3 /* Select 80386 CPU */
#endif /* CURRENT_OS == CUR_OS_DOS */
/***********************************************************************/
/* End of Customization Area */
/***********************************************************************/
/* Replacement for various TrueFFS definitions */
#define SECTOR_SIZE_BITS 9 /* defines the log2 of a sector size (512) */
#define MTDS 2 /* Maximum number of registred MTDS */
/***********************************************************************/
/* Check for missing defines dependencies Do not customized */
/***********************************************************************/
/* 1) Update routines require the functionalities of the read routine. */
/* 2) Removal of the binary read or write routines does not remove the */
/* flash read and write routines. In order to save on the TEXT code */
/***********************************************************************/
#ifdef UPDATE_BDK_IMAGE
#ifndef ACCESS_BDK_IMAGE
#define ACCESS_BDK_IMAGE
#endif /* !ACCESS_BDK_IMAGE */
#endif /* UPDATE_BDK_IMAGE */
/***********************************************************************/
/* Custom the MTD definitions to meet the above definitions */
/***********************************************************************/
/* 1) EDC_MODE -> ~ NO_EDC_MODE */
/* 2) BDK_VERIFY_WRITE -> VERIFY_WRITE */
/* 3) USE_FUNC_FOR_ACCESS -> ~ FL_NO_USE_FUNC */
/* 4) UPDATE_BDK_IMAGE -> ~ FL_READ_ONLY */
/* 5) ~DOCPLUS_FAMILY -> ~ PROTECT_BDK_IMAGE */
/* 6) PROTECT_BDK_IMAGE -> HW_PROTECTION */
/* 7) DOS -> CUR_OS */
/* 8) FL_BIG_ENDIAN -> ~ USE_STD_FUNC */
/* 9) MTD_NO_READ_BBT_CODE -> ~ MTD_READ_BBT + ~ MTD_RECONSTRUCT_BBT */
/***********************************************************************/
#ifdef EDC_MODE
#ifdef NO_EDC_MODE
#undef NO_EDC_MODE
#endif /* NO_EDC_MODE */
#else /* EDC_MODE */
#define NO_EDC_MODE
#endif /* EDC_MODE */
#ifdef BDK_VERIFY_WRITE
#define VERIFY_WRITE
#endif /* BDK_VERIFY_WRITE */
#ifdef USE_FUNC_FOR_ACCESS
#undef FL_NO_USE_FUNC
#endif /* USE_FUNC_FOR_ACCESS */
#ifndef UPDATE_BDK_IMAGE
#define FL_READ_ONLY
#endif /* UPDATE_BDK_IMAGE */
#if (defined(PROTECT_BDK_IMAGE) && !defined(HW_PROTECTION))
#define HW_PROTECTION
#endif /* PRTOECTION_BDK_IMAGE */
#if (defined(FL_BIG_ENDIAN) && defined(USE_STD_FUNC))
#undef USE_STD_FUNC
#endif /* FL_BIG_ENDIAN */
#ifdef MTD_NO_READ_BBT_CODE
#undef MTD_READ_BBT
#undef MTD_RECONSTRUCT_BBT
#endif /* MTD_NO_READ_BBT_CODE */
/*********************************/
/* Include specific OS resources */
/*********************************/
#if (CURRENT_OS == CUR_OS_WINCE)
#include <windows.h>
#include "pkfuncs.h"
#include <memory.h>
#include <stdio.h>
#endif /*CUR_OS_WINCE*/
#if (CURRENT_OS == CUR_OS_VX_WORKS)
/* OS-specific includes */
#include <vxWorks.h>
#include <tickLib.h>
#include <sysLib.h>
#ifdef USE_STD_FUNC
#include "memLib.h"
#endif /* USE_STD_FUNC */
#define VXW_DELAY /* uncomment for VxWorks delay */
#endif /* CURRENT_OS == CUR_OS_VX_WORKS */
#if (CURRENT_OS == CUR_OS_PSOS)
/* OS-specific includes */
#include <psos.h>
#include <bspfuncs.h>
#include "sys_conf.h"
#ifdef USE_STD_FUNC
#include "memLib.h"
#endif /* USE_STD_FUNC */
#define PSS_DELAY /* uncomment for pSOS delay */
#endif /* CURRENT_OS == CUR_PSOS */
#if (CURRENT_OS == CUR_OS_DOS)
/* OS-specific includes */
#include <dos.h>
#ifdef USE_STD_FUNC
#include "mem.h"
#endif /* USE_STD_FUNC */
#define DOS_DELAY /* uncomment for DOS delay */
#endif /* CURRENT_OS == CUR_OS_DOS */
/*******************************************/
/* Declare memcpy, memset, memcmp routines */
/*******************************************/
#ifdef USE_STD_FUNC
#if FAR_LEVEL > 0
#define tffscpy _fmemcpy
#define tffscmp _fmemcmp
#define tffsset _fmemset
#else
#define tffscpy memcpy
#define tffscmp memcmp
#define tffsset memset
#endif /* FAR_LEVEL */
#endif /* USE_STD_FUNC */
/* define IO memory access macros - must be defined in flsystem.h */
#ifndef FLWRITE_IO_BYTE
#define FLWRITE_IO_BYTE(val,address) *((volatile byte FAR0*)(address))=(byte)(val)
#endif
#ifndef FLWRITE_IO_WORD
#define FLWRITE_IO_WORD(val,address) *((volatile word FAR0*)(address))=(word)(val)
#endif
#ifndef FLWRITE_IO_DWORD
#define FLWRITE_IO_DWORD(val,address) *((volatile dword FAR0*)(address))=(dword)(val)
#endif
#ifndef FLCPY_FROM_IO
#define FLCPY_FROM_IO(dest,src,count) flcpy(dest,(void FAR0*)(src),count)
#endif
#ifndef TFFSCPY_FROM_IO
#define TFFSCPY_FROM_IO(dest,src,count) tffscpy(dest,(void FAR0*)(src),count)
#endif
#ifndef FLREAD_IO_BYTE
#define FLREAD_IO_BYTE(address) (*((volatile byte FAR0*)(address)))
#endif
#ifndef FLREAD_IO_WORD
#define FLREAD_IO_WORD(address) (*((volatile word FAR0*)(address)))
#endif
#ifndef FLREAD_IO_DWORD
#define FLREAD_IO_DWORD(address) (*((volatile dword FAR0*)(address)))
#endif
#ifndef FLCPY_TO_IO
#define FLCPY_TO_IO(dest,src,count) flcpy((void FAR0*)(dest),src,count)
#endif
#ifndef FLSET_IO
#define FLSET_IO(dest,val,count) flset((void FAR0*)(dest),val,count)
#endif
#ifndef TFFSCPY_TO_IO
#define TFFSCPY_TO_IO(dest,src,count) tffscpy((void FAR0*)(dest),src,count)
#endif
#ifndef TFFSSET_IO
#define TFFSSET_IO(dest,val,count) tffsset((void FAR0*)(dest),val,count)
#endif
#endif /* MTD_STANDALONE */
#endif /* MTD_SA_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -