cacheLib.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:10k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* cacheLib.h - cache library header file */
  2. /* Copyright 1984-1998 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 03e,22oct01,dee  merge from T2.1.0 coldfire release
  7. 03d,10sep00,hk   extended CACHE_TYPE for SH7729.
  8. 03c,01mar00,frf  Add SH4 support for T2
  9. 03b,23apr97,hk   added SH support.
  10. 03c,05nov98.jpd  removed cacheArchLibInit definition for ARM.
  11. 03b,28nov96,cdp  added ARM support.
  12. 03a,26may94,yao  added PPC support.
  13. 02p,19mar95,dvs  removed #ifdef TRON - tron no longer supported.
  14. 02o,08jun94,tpr  added branch cache used by MC68060 cpu.
  15. 02n,02dec93,pme  Added Am29K family support.
  16. 02m,09jun93,hdn  added support for I80X86
  17. 02l,19oct92,jcf  reordered xxLibInit params.  made CACHE_TYPE v5.0 compatible.
  18. 02k,29sep92,jwt  merged cacheLibInit(), cacheReset(), and cacheModeSet().
  19. 02j,22sep92,rrr  added support for c++
  20. 02i,20aug92,wmd  added #include for i960.
  21. 02h,13aug92,rdc  removed instances of cacheLib functions and CACHE_FUNCS
  22.    structures and conditional compilation of corresponding
  23.  IMPORTS.
  24. 02g,30jul92,dnw  added cacheLib functions and CACHE_FUNCS structures.
  25. 02f,15jul92,jwt  added more CACHE_MODEs.
  26. 02e,09jul92,jwt  added virtual-to-physical and physical-to-virtual stuff.
  27. 02d,07jul92,ajm  added support for mips
  28. 02c,06jul92,jwt  cleaned up cacheDrvXxx() macros by stressing pointers.
  29. 02b,04jul92,jcf  cleaned up.
  30. 02a,03jul92,jwt  cache library header for 5.1; moved '040 stuff to arch/mc68k.
  31. 01k,16jun92,jwt  made safe for assembly language files.
  32. 01j,26may92,rrr  the tree shuffle
  33.                   -changed includes to have absolute path from h/
  34. 01i,20jan92,shl  added cache68kLib.h.
  35. 01h,09jan92,jwt  created cacheSPARCLib.h;
  36.                  cleaned up ANSI compiler warning messages.
  37. 01g,04oct91,rrr  passed through the ansification filter
  38.                   -fixed #else and #endif
  39.                   -changed copyright notice
  40. 01f,27aug91,shl  added scope type for MC68040 caches.
  41. 01e,19jul91,gae  renamed architecture specific include file to be xx<arch>.h.
  42. 01d,23jan91,jwt  added SPARC cache commands.
  43. 01c,01mar91,hdn  added TRON related stuff.
  44. 01b,05oct90,shl  added copyright notice; made #endif ANSI style.
  45. 01a,15jul90,jcf  written.
  46. */
  47. #ifndef __INCcacheLibh
  48. #define __INCcacheLibh
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52. #include "vxWorks.h"
  53. #include "vwModNum.h"
  54. #include "limits.h"
  55. /* Cache types */
  56. #define _INSTRUCTION_CACHE  0 /* Instruction Cache(s) */
  57. #define _DATA_CACHE 1 /* Data Cache(s) */
  58. #define _BRANCH_CACHE 2 /* Branch Cache(s) */
  59. #if (CPU==SH7700)
  60. #define _WAY2_CACHE 3 /* SH7729 only */
  61. #define _WAY3_CACHE 4 /* SH7729 only */
  62. #endif
  63. /* Cache mode soft bit masks */
  64. #define CACHE_DISABLED 0x00 /* No cache or disabled */
  65. #define CACHE_WRITETHROUGH 0x01 /* Write-through Mode */
  66. #define CACHE_COPYBACK 0x02 /* Copyback Mode */
  67. #define CACHE_WRITEALLOCATE 0x04 /* Write Allocate Mode */
  68. #define CACHE_NO_WRITEALLOCATE 0x08
  69. #define CACHE_SNOOP_ENABLE 0x10 /* Bus Snooping */
  70. #define CACHE_SNOOP_DISABLE 0x20
  71. #define CACHE_BURST_ENABLE 0x40 /* Cache Burst Cycles */
  72. #define CACHE_BURST_DISABLE 0x80
  73. /* Errno values */
  74. #define S_cacheLib_INVALID_CACHE (M_cacheLib | 1)
  75. /* Value for "entire cache" in length arguments */
  76. #define ENTIRE_CACHE ULONG_MAX
  77. #ifndef _ASMLANGUAGE
  78. typedef enum /* CACHE_TYPE */
  79.     {
  80. #if (CPU == MC68060)
  81.     BRANCH_CACHE      = _BRANCH_CACHE,
  82. #endif /* (CPU == MC68060) */
  83. #if (CPU == SH7700)
  84.     WAY2_CACHE        = _WAY2_CACHE,
  85.     WAY3_CACHE        = _WAY3_CACHE,
  86. #endif /* (CPU == SH7700) */
  87.     INSTRUCTION_CACHE = _INSTRUCTION_CACHE,
  88.     DATA_CACHE        = _DATA_CACHE
  89.     } CACHE_TYPE;
  90. typedef UINT CACHE_MODE; /* CACHE_MODE */
  91. typedef struct /* Cache Routine Pointers */
  92.     {
  93.     FUNCPTR enableRtn; /* cacheEnable() */
  94.     FUNCPTR disableRtn; /* cacheDisable() */
  95.     FUNCPTR lockRtn; /* cacheLock() */
  96.     FUNCPTR unlockRtn; /* cacheUnlock() */
  97.     FUNCPTR flushRtn; /* cacheFlush() */
  98.     FUNCPTR invalidateRtn; /* cacheInvalidate() */
  99.     FUNCPTR clearRtn; /* cacheClear() */
  100.     FUNCPTR textUpdateRtn; /* cacheTextUpdate() */
  101.     FUNCPTR pipeFlushRtn; /* cachePipeFlush() */
  102.     FUNCPTR dmaMallocRtn; /* cacheDmaMalloc() */
  103.     FUNCPTR dmaFreeRtn; /* cacheDmaFree() */
  104.     FUNCPTR dmaVirtToPhysRtn; /* virtual-to-Physical Translation */
  105.     FUNCPTR dmaPhysToVirtRtn; /* physical-to-Virtual Translation */
  106.     } CACHE_LIB;
  107. /* Cache flush and invalidate support for general use and drivers */
  108. typedef struct /* Driver Cache Routine Pointers */
  109.     {
  110.     FUNCPTR flushRtn; /* cacheFlush() */
  111.     FUNCPTR invalidateRtn; /* cacheInvalidate() */
  112.     FUNCPTR virtToPhysRtn; /* Virtual-to-Physical Translation */
  113.     FUNCPTR physToVirtRtn; /* Physical-to-Virtual Translation */
  114.     } CACHE_FUNCS;
  115. /* Cache macros */
  116. #define CACHE_TEXT_UPDATE(adrs, bytes)
  117.         ((cacheLib.textUpdateRtn == NULL) ? OK :
  118.  (cacheLib.textUpdateRtn) ((adrs), (bytes)))
  119. #define CACHE_PIPE_FLUSH()
  120.         ((cacheLib.pipeFlushRtn == NULL) ? OK :
  121.  (cacheLib.pipeFlushRtn) ())
  122. #define CACHE_DRV_FLUSH(pFuncs, adrs, bytes)
  123.         (((pFuncs)->flushRtn == NULL) ? OK :
  124.          ((pFuncs)->flushRtn) (DATA_CACHE, (adrs), (bytes)))
  125. #define CACHE_DRV_INVALIDATE(pFuncs, adrs, bytes)
  126.         (((pFuncs)->invalidateRtn == NULL) ? OK :
  127.          ((pFuncs)->invalidateRtn) (DATA_CACHE, (adrs), (bytes)))
  128. #define CACHE_DRV_VIRT_TO_PHYS(pFuncs, adrs)
  129.         (((pFuncs)->virtToPhysRtn == NULL) ? (void *) (adrs) :
  130.  (void *) (((pFuncs)->virtToPhysRtn) (adrs)))
  131. #define CACHE_DRV_PHYS_TO_VIRT(pFuncs, adrs)
  132.         (((pFuncs)->physToVirtRtn == NULL) ? (void *) (adrs) :
  133.  ((void *) ((pFuncs)->physToVirtRtn) (adrs)))
  134. #define CACHE_DRV_IS_WRITE_COHERENT(pFuncs)
  135. ((pFuncs)->flushRtn == NULL)
  136. #define CACHE_DRV_IS_READ_COHERENT(pFuncs)
  137. ((pFuncs)->invalidateRtn == NULL)
  138. #define CACHE_DMA_FLUSH(adrs, bytes)
  139. CACHE_DRV_FLUSH (&cacheDmaFuncs, (adrs), (bytes))
  140. #define CACHE_DMA_INVALIDATE(adrs, bytes)
  141. CACHE_DRV_INVALIDATE (&cacheDmaFuncs, (adrs), (bytes))
  142. #define CACHE_DMA_VIRT_TO_PHYS(adrs)
  143. CACHE_DRV_VIRT_TO_PHYS (&cacheDmaFuncs, (adrs))
  144. #define CACHE_DMA_PHYS_TO_VIRT(adrs)
  145. CACHE_DRV_PHYS_TO_VIRT (&cacheDmaFuncs, (adrs))
  146. #define CACHE_DMA_IS_WRITE_COHERENT()
  147. CACHE_DRV_IS_WRITE_COHERENT (&cacheDmaFuncs)
  148. #define CACHE_DMA_IS_READ_COHERENT()
  149. CACHE_DRV_IS_READ_COHERENT (&cacheDmaFuncs)
  150. #define CACHE_USER_FLUSH(adrs, bytes)
  151. CACHE_DRV_FLUSH (&cacheUserFuncs, (adrs), (bytes))
  152. #define CACHE_USER_INVALIDATE(adrs, bytes)
  153. CACHE_DRV_INVALIDATE (&cacheUserFuncs, (adrs), (bytes))
  154. #define CACHE_USER_IS_WRITE_COHERENT()
  155. CACHE_DRV_IS_WRITE_COHERENT (&cacheUserFuncs)
  156. #define CACHE_USER_IS_READ_COHERENT()
  157. CACHE_DRV_IS_READ_COHERENT (&cacheUserFuncs)
  158. /* variable declarations */
  159. IMPORT CACHE_LIB cacheLib;
  160. IMPORT CACHE_FUNCS cacheNullFuncs; /* functions for non-cached memory */
  161. IMPORT CACHE_FUNCS cacheDmaFuncs; /* functions for dma memory */
  162. IMPORT CACHE_FUNCS cacheUserFuncs; /* functions for user memory */
  163. IMPORT FUNCPTR cacheDmaMallocRtn;
  164. IMPORT FUNCPTR cacheDmaFreeRtn;
  165. IMPORT CACHE_MODE cacheDataMode; /* data cache modes for funcptrs */
  166. IMPORT BOOL cacheDataEnabled;
  167. IMPORT BOOL cacheMmuAvailable;
  168. /* function declarations */
  169. #if defined(__STDC__) || defined(__cplusplus)
  170. extern STATUS cacheLibInit (CACHE_MODE inst, CACHE_MODE data);
  171. #if (CPU_FAMILY != ARM)
  172. extern STATUS cacheArchLibInit (CACHE_MODE inst, CACHE_MODE data);
  173. #endif
  174. extern STATUS cacheEnable (CACHE_TYPE cache);
  175. extern STATUS cacheDisable (CACHE_TYPE cache);
  176. extern STATUS cacheLock (CACHE_TYPE cache, void * adrs, size_t bytes);
  177. extern STATUS cacheUnlock (CACHE_TYPE cache, void * adrs, size_t bytes);
  178. extern STATUS cacheFlush (CACHE_TYPE cache, void * adrs, size_t bytes);
  179. extern STATUS cacheInvalidate (CACHE_TYPE cache, void *adrs, size_t bytes);
  180. extern STATUS cacheClear (CACHE_TYPE cache, void * adrs, size_t bytes);
  181. extern STATUS cacheTextUpdate (void * adrs, size_t bytes);
  182. extern STATUS cachePipeFlush (void);
  183. extern void * cacheDmaMalloc (size_t bytes);
  184. extern STATUS cacheDmaFree (void * pBuf);
  185. extern STATUS cacheDrvFlush (CACHE_FUNCS * pFuncs, void * adrs, size_t bytes);
  186. extern STATUS cacheDrvInvalidate (CACHE_FUNCS * pFuncs, void * adrs,
  187.     size_t bytes);
  188. extern void *   cacheDrvVirtToPhys (CACHE_FUNCS * pFuncs, void * adrs);
  189. extern void *   cacheDrvPhysToVirt (CACHE_FUNCS * pFuncs, void * adrs);
  190. extern void cacheFuncsSet (void);
  191. #else
  192. extern STATUS cacheLibInit ();
  193. #if (CPU_FAMILY != ARM)
  194. extern STATUS cacheArchLibInit ();
  195. #endif
  196. extern STATUS cacheEnable ();
  197. extern STATUS cacheDisable ();
  198. extern STATUS cacheLock ();
  199. extern STATUS cacheUnlock ();
  200. extern STATUS cacheFlush ();
  201. extern STATUS cacheInvalidate ();
  202. extern STATUS cacheClear ();
  203. extern STATUS cacheTextUpdate ();
  204. extern STATUS cachePipeFlush ();
  205. extern void * cacheDmaMalloc ();
  206. extern STATUS cacheDmaFree ();
  207. extern STATUS cacheDrvFlush ();
  208. extern STATUS cacheDrvInvalidate ();
  209. extern void *   cacheDrvVirtToPhys ();
  210. extern void *   cacheDrvPhysToVirt ();
  211. extern void cacheSetFuncs ();
  212. #endif /* __STDC__ */
  213. #endif /* _ASMLANGUAGE */
  214. /* Architecture-specific cache headers */
  215. #if (CPU_FAMILY == MC680X0)
  216. #include "arch/mc68k/cacheMc68kLib.h"
  217. #endif  /* (CPU_FAMILY == MC680X0) */
  218. #if (CPU_FAMILY == COLDFIRE)
  219. #include "arch/coldfire/cacheColdfireLib.h"
  220. #endif  /* (CPU_FAMILY == COLDFIRE) */
  221. #if (CPU_FAMILY == SPARC)
  222. #include "arch/sparc/cacheSparcLib.h"
  223. #endif
  224. #if (CPU_FAMILY == MIPS)
  225. #include "arch/mips/cacheMipsLib.h"
  226. #endif  /* (CPU_FAMILY == MIPS) */
  227. #if (CPU_FAMILY == PPC)
  228. #include "arch/ppc/cachePpcLib.h"
  229. #endif /* CPU_FAMILY == PPC */
  230. #if (CPU_FAMILY == I960)
  231. #include "arch/i960/vxI960Lib.h"
  232. #endif  /* CPU_FAMILY == I960 */
  233. #if (CPU_FAMILY == I80X86)
  234. #include "arch/i86/cacheI86Lib.h"
  235. #endif  /* CPU_FAMILY == I80X86 */
  236. #if (CPU_FAMILY == AM29XXX)
  237. #include "arch/am29k/cacheAm29kLib.h"
  238. #endif  /* CPU_FAMILY == AM29XXX */
  239. #if (CPU_FAMILY == SH)
  240. #include "arch/sh/cacheShLib.h"
  241. #endif /* CPU_FAMILY == SH */
  242. #if     (CPU_FAMILY == ARM)
  243. #include "arch/arm/cacheArmLib.h"
  244. #endif  /* CPU_FAMILY == ARM */
  245. #ifdef __cplusplus
  246. }
  247. #endif
  248. #endif /* __INCcacheLibh */