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

VxWorks

开发平台:

C/C++

  1. /*
  2. ** File:     dpconfig.h
  3. ** Version:  1.0.1
  4. **
  5. ** Copyright 1996 Applied Microsystems, Inc.  All rights reserved.
  6. **
  7. ** This file contains configuration information which needs to be ported
  8. ** to new platforms running the netrom dualport communication code.  Sections 
  9. ** requiring porting are marked with:
  10. **
  11. ** *** PORT THIS SECTION ***
  12. */
  13. #ifndef _dpconfig_h
  14. #define _dpconfig_h
  15. /* Generic macros */
  16. #define True 1
  17. #define False 0
  18. /* 
  19. ** This section contains configuration information for the dualport protocols.
  20. ** These parameters essentially become inputs to the config_dpram() call
  21. ** which initializes the target side of the protocols.  The semantics of 
  22. ** these parameters are:
  23. **
  24. **  ROM_START      is the 32-bit target address of the start of the ROM
  25. **                 words containing dualport memory.  This is**not*
  26. **                 the address of dualport memory itself, but is the base
  27. **                 address of the rom word containing pod 0.
  28. ** 
  29. **  ROMWORDWIDTH   is the number of bytes making up a 'word'.  The
  30. **                 value describes the memory sybsystem of the target,
  31. **                 not the word size of the CPU.  For example,
  32. **                 if ROM memory is organized as an array of 16 bit
  33. **                 words, this number is two.  If the processor has a
  34. **                 32-bit architecture, but only one 8-bit ROM is
  35. **                 used to provide ROM memory, this value is 1.
  36. **
  37. **  POD_0_INDEX    is the index within a rom word of pod 0.  This number
  38. **                 reflects the ROM byte emulated by pod 0.  The following
  39. **                 table shows what value to use for common word sizes
  40. **                 and podorder environment variable:
  41. **                      
  42. **
  43. **                          Word size      podorder        POD_0_INDEX
  44. **                          --------       --------        -----------
  45. **                           8-bits     (any podorder)         0
  46. **                          16-bits     podorder == 0:1        0
  47. **                                      podorder == 1:0        1
  48. **                          32-bits     podorder == 0:1:2:3    0
  49. **                                      podorder == 3:2:1:0    3
  50. **
  51. **  NUMACCESSES    is the number of accesses the target processor makes
  52. **                 to pod 0 in the course of reading a single 8-bit
  53. **                 value from the pod.
  54. **
  55. **  ROMSIZE        is the number of bytes in an individual ROM.  This
  56. **                 number should agree with NetROM's romtype environment
  57. **                 variable.
  58. **
  59. **  DP_BASE        is the 32-bit target address of the first byte of dualport
  60. **                 memory.  Dualport memory is always in pod 0.  The default
  61. **                 location is 2K from the end of pod 0.  The formula below
  62. **                 is correct for this default location.  If you have moved
  63. **                 dualport RAM, you must adjust the formula to give the
  64. **                 correct address.  This define should be the first argument
  65. **                 in your call to config_dpram().
  66. **
  67. ** Consult the NetROM user's manual for more information on the readaddress
  68. ** protocol and on the parameters to config_dpram().
  69. **
  70. */
  71. /* Sizes of common rom types */
  72. #define RS_64K         (64  * 1024L)
  73. #define RS_128K        (128 * 1024L)
  74. #define RS_256K        (256 * 1024L)
  75. #define RS_512K        (512 * 1024L)
  76. #define RS_1MEG        (1   * 1048576L)
  77. #define RS_2MEG        (2   * 1048576L)
  78. #define RS_4MEG        (4   * 1048576L)
  79. #define RS_27C010 RS_128K
  80. #define RS_27C020 RS_256K
  81. #define RS_27C040 RS_512K
  82. #define RS_27C080 RS_1MEG
  83. /*---------------------------------------------------------------*/
  84. /* *** PORT THIS SECTION      ***               */
  85. /*---------------------------------------------------------------*/
  86. #define VxWorks
  87. #ifndef VxWorks
  88. #define ROMSTART        0xFFF00000L 
  89. #define ROMWORDWIDTH     2
  90. #define POD_0_INDEX      0
  91. #define ROMSIZE          RS_27C020
  92. /* MAX_WAIT_FTN_SIZE is used on read-only targets only.
  93. ** The wait_ftn() must execute from RAM while NetROM sets Podmem.
  94. ** MAX_WAIT_FTN_SIZE is the amount of memory to allocate in RAM
  95. ** for the wait_ftn().  nr_ConfigDP() copies wait_fnt() to RAM.
  96. ** If too little memory is set aside, nr_ConfigDP() will return
  97. ** with an error.  If extra memory is set aside, no problem...
  98. ** the nr_ConfigDP() only copies the minimum amount to RAM.
  99. **
  100. ** Note: Using an MRI compiler w/ an i960 target,
  101. **
  102. ** sizeof(wait_ftn()) = _nr_WaitEnd  -  _nr_Wait
  103. **                    =  0xE0051400  -  0xE00514F0
  104. **                    = 0xF0
  105. */
  106. #define MAX_WAIT_FTN_SIZE  0x200
  107. /* The following formula is correct ONLY if dualport is at the default 
  108. ** location, at the top of pod 0.
  109. ** If you move dualport RAM to somewhere else, redefine DP_BASE !!!
  110. */
  111. #define DP_BASE (ROMSTART + ((ROMSIZE - DUALPORT_SIZE) * ROMWORDWIDTH))
  112. /* The following #define locates DP_BASE at the beginning of Pod 0 */
  113. /* #define DP_BASE (ROMSTART) */
  114. /* Do NOT modify ROMEND */
  115. #define ROMEND  (ROMSTART + ROMSIZE * ROMWORDWIDTH)
  116. /* If your target CAN write to the memory emulated by NetROM,
  117. ** define READONLY_TARGET as False;
  118. ** If your target CANNOT write to the memory emulated by NetROM,
  119. **   define READONLY_TARGET as True
  120. */
  121. #define READONLY_TARGET True
  122. /* Set to True  if your target is little-endian, for example, Intel
  123. ** Set to False if your target is big-endian,    for example, Motorola
  124. */
  125. #define LITTLE_ENDIAN_TGT True 
  126.     /* Big-endian / little-endian conversion routine */
  127. #if(LITTLE_ENDIAN_TGT == True )
  128.   #define swap32(x) 
  129.     (( (long)(x) & 0x000000FF) << 24)  +  
  130.     (( (long)(x) & 0x0000FF00) << 8 )  +  
  131.     (( (long)(x) & 0x00FF0000) >> 8 )  +  
  132.     (( (long)(x) & 0xFF000000) >> 24) 
  133.   #define swap16(x) 
  134.     (( (int)(x) & 0x00FF) << 8 ) + (( (int)(x) & 0xFF00) >> 8 )
  135. #else
  136.   #define swap32(x) x
  137.   #define swap16(x) x
  138. #endif  /* LITTLE_ENDIAN_TGT */
  139. /* Define VETHER only if you are using Virtual Ethernet */
  140. /* #define VETHER */
  141. /* macro to allow other processes to run in a multitasking system */
  142. /* If you are NOT using vxWorks, define YIELD_CPU for your RTOS */
  143. #ifdef vxworks
  144. #include "taskLib.h"
  145. #define nr_YieldCPU() taskDelay(1) /* closest thing in VxWorks */
  146. #else
  147. #define nr_YieldCPU()
  148. #endif
  149. /* Macros to turn interrupts ON and OFF 
  150. ** Required for nr_SetMem() which MUST be atomic. In multitasking 
  151. ** systems, unless your code assures that the channel will not be
  152. ** written to by another function while nr_SetMem() is running, you'll
  153. ** need to define these macros.  These macros are
  154. ** target-specific, you must supply them.
  155. */
  156. #define nr_InterruptsOFF()
  157. #define nr_InterruptsON() 
  158. /* The following three macros control target caching.  They are
  159. ** required for dualport communication protocol on targets that
  160. ** cache the memory region emulated by NetROM. 
  161. **
  162. ** Cache-related macros:
  163. **   nr_HasCache      Boolean; equals True if your target caches
  164. **                    the memory emulated by NetROM, False otherwise.
  165. **   nr_DataCacheOff  Turns caching OFF--you must supply this for your target
  166. **   nr_DataCacheOn   Restores caching--you must supply this for your target
  167. */
  168. #define nr_HasCache       False /* True */
  169. #define nr_DataCacheOff()
  170. #define nr_DataCacheOn()
  171. #else /* VxWorks */
  172. /* VxWorks - specific definitions */
  173. extern int wdbNetromKey; /* interrupt lockout key */
  174. #define ROMSTART ROM_BASE_ADRS
  175. #define ROMWORDWIDTH WDB_NETROM_WIDTH
  176. #define POD_0_INDEX WDB_NETROM_INDEX
  177. #define ROMSIZE         WDB_NETROM_ROMSIZE
  178. #define DP_BASE (ROMSTART + ((ROMSIZE - DUALPORT_SIZE) * ROMWORDWIDTH))
  179. #define ROMEND (ROMSTART + ROMSIZE * ROMWORDWIDTH)
  180. #define MAX_WAIT_FTN_SIZE  0x200
  181. #define READONLY_TARGET True
  182. #if (_BYTE_ORDER == _LITTLE_ENDIAN)
  183.   #define LITTLE_ENDIAN_TGT True 
  184.   #define swap32(x) 
  185.     (( (long)(x) & 0x000000FF) << 24)  +  
  186.     (( (long)(x) & 0x0000FF00) << 8 )  +  
  187.     (( (long)(x) & 0x00FF0000) >> 8 )  +  
  188.     (( (long)(x) & 0xFF000000) >> 24) 
  189.   #define swap16(x) 
  190.     (( (int)(x) & 0x00FF) << 8 ) + (( (int)(x) & 0xFF00) >> 8 )
  191. #else
  192.   #define LITTLE_ENDIAN_TGT False
  193.   #define swap32(x) x
  194.   #define swap16(x) x
  195. #endif
  196. #define nr_YieldCPU()
  197. #define nr_InterruptsOFF() {wdbNetromLock = intLock();}
  198. #define nr_InterruptsON()  {intUnlock (wdbNetromLock);}
  199. #define nr_HasCache       False /* True */
  200. #define nr_DataCacheOff()
  201. #define nr_DataCacheOn()
  202. #endif /* VxWorks */
  203. #endif /* _dpconfig_h */