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

VxWorks

开发平台:

C/C++

  1. /*
  2.  * $Log:   P:/user/amir/lite/vcs/flsocket.h_v  $
  3.    
  4.       Rev 1.11   28 Sep 1997 18:23:28   danig
  5.    flExitSocket 
  6.    
  7.       Rev 1.10   10 Sep 1997 16:16:20   danig
  8.    Got rid of generic names
  9.    
  10.       Rev 1.9   28 Aug 1997 17:48:04   danig
  11.    Buffer & remapped per socket
  12.    
  13.       Rev 1.8   24 Jul 1997 18:05:24   amirban
  14.    FAR to FAR0
  15.    
  16.       Rev 1.7   20 Jul 1997 17:16:28   amirban
  17.    No watchDogTimer
  18.    
  19.       Rev 1.6   07 Jul 1997 15:23:46   amirban
  20.    Ver 2.0
  21.    
  22.       Rev 1.5   08 Jun 1997 17:03:16   amirban
  23.    power on callback
  24.    
  25.       Rev 1.4   08 Oct 1996 12:17:34   amirban
  26.    Defined remapped
  27.    
  28.       Rev 1.3   18 Aug 1996 13:47:44   amirban
  29.    Comments
  30.    
  31.       Rev 1.2   12 Aug 1996 15:47:42   amirban
  32.    Changed value of UNDEF_MAPPING
  33.    
  34.       Rev 1.1   31 Jul 1996 14:29:08   amirban
  35.    Defined set/getMappingContext
  36.       Rev 1.0   20 Mar 1996 13:33:20   amirban
  37.    Initial revision.
  38.  */
  39. /************************************************************************/
  40. /*                                                                      */
  41. /* FAT-FTL Lite Software Development Kit */
  42. /* Copyright (C) M-Systems Ltd. 1995-1996 */
  43. /* */
  44. /************************************************************************/
  45. #ifndef FLSOCKET_H
  46. #define FLSOCKET_H
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50. #include "flbase.h"
  51. #include "flbuffer.h"
  52. #define ATTRIBUTE_SPACE_MAPPED 0x8000
  53. typedef enum {PowerOff, PowerGoingOff, PowerOn} PowerState;
  54. /* Socket state variables */
  55. typedef struct tSocket FLSocket; /* Forward definition */
  56. struct tSocket {
  57.   unsigned volNo; /* Volume no. of socket */
  58.   unsigned  serialNo;  /* Serial no. of socket on controller */
  59.   FLBoolean cardChanged; /* need media change notification */
  60.   int  VccUsers; /* No. of current VCC users */
  61.   int  VppUsers; /* No. of current VPP users */
  62.   PowerState VccState; /* Actual VCC state */
  63.   PowerState VppState; /* Actual VPP state */
  64.   FLBoolean remapped;       /* set to TRUE whenever the socket window is moved */
  65.   void (*powerOnCallback)(void *flash); /* Notification routine for Vcc on */
  66.   void * flash; /* Flash object for callback */
  67.   struct {                      /* Window state */
  68.     unsigned int baseAddress; /* Physical base as a 4K page */
  69.     unsigned int currentPage; /* Our current window page mapping */
  70.     void FAR0 * base; /* Pointer to window base */
  71.     long int size;           /* Window size (must by power of 2) */
  72.     unsigned speed; /* in nsec. */
  73.     unsigned  busWidth; /* 8 or 16 bits */
  74.   } window;
  75. /*----------------------------------------------------------------------*/
  76. /*                 c a r d D e t e c t e d */
  77. /* */
  78. /* Detect if a card is present (inserted) */
  79. /* */
  80. /* Parameters:                                                          */
  81. /* vol : Pointer identifying drive */
  82. /*                                                                      */
  83. /* Returns:                                                             */
  84. /* 0 = card not present, other = card present */
  85. /*----------------------------------------------------------------------*/
  86.   FLBoolean (*cardDetected)(FLSocket vol);
  87. /*----------------------------------------------------------------------*/
  88. /*                      V c c O n */
  89. /* */
  90. /* Turns on Vcc (3.3/5 Volts). Vcc must be known to be good on exit. */
  91. /* */
  92. /* Parameters:                                                          */
  93. /* vol : Pointer identifying drive */
  94. /*                                                                      */
  95. /*----------------------------------------------------------------------*/
  96.   void (*VccOn)(FLSocket vol);
  97. /*----------------------------------------------------------------------*/
  98. /*                    V c c O f f */
  99. /* */
  100. /* Turns off Vcc. */
  101. /* */
  102. /* Parameters:                                                          */
  103. /* vol : Pointer identifying drive */
  104. /*                                                                      */
  105. /*----------------------------------------------------------------------*/
  106.   void (*VccOff)(FLSocket vol);
  107. #ifdef SOCKET_12_VOLTS
  108. /*----------------------------------------------------------------------*/
  109. /*                      V p p O n */
  110. /* */
  111. /* Turns on Vpp (12 Volts. Vpp must be known to be good on exit. */
  112. /* */
  113. /* Parameters:                                                          */
  114. /* vol : Pointer identifying drive */
  115. /*                                                                      */
  116. /* Returns:                                                             */
  117. /* FLStatus : 0 on success, failed otherwise */
  118. /*----------------------------------------------------------------------*/
  119.   FLStatus (*VppOn)(FLSocket vol);
  120. /*----------------------------------------------------------------------*/
  121. /*                    V p p O f f */
  122. /* */
  123. /* Turns off Vpp. */
  124. /* */
  125. /* Parameters:                                                          */
  126. /* vol : Pointer identifying drive */
  127. /*                                                                      */
  128. /*----------------------------------------------------------------------*/
  129.   void (*VppOff)(FLSocket vol);
  130. #endif /* SOCKET_12_VOLTS */
  131. /*----------------------------------------------------------------------*/
  132. /*                 i n i t S o c k e t         */
  133. /* */
  134. /* Perform all necessary initializations of the socket or controller */
  135. /* */
  136. /* Parameters:                                                          */
  137. /* vol : Pointer identifying drive */
  138. /*                                                                      */
  139. /* Returns:                                                             */
  140. /* FLStatus : 0 on success, failed otherwise */
  141. /*----------------------------------------------------------------------*/
  142.   FLStatus (*initSocket)(FLSocket vol);
  143. /*----------------------------------------------------------------------*/
  144. /*                   s e t W i n d o w */
  145. /* */
  146. /* Sets in hardware all current window parameters: Base address, size,  */
  147. /* speed and bus width. */
  148. /* The requested settings are given in the 'vol.window' structure. */
  149. /* */
  150. /* If it is not possible to set the window size requested in */
  151. /* 'vol.window.size', the window size should be set to a larger value, */
  152. /* if possible. In any case, 'vol.window.size' should contain the */
  153. /* actual window size (in 4 KB units) on exit. */
  154. /* */
  155. /* Parameters:                                                          */
  156. /* vol : Pointer identifying drive */
  157. /*                                                                      */
  158. /*----------------------------------------------------------------------*/
  159.   void (*setWindow)(FLSocket vol);
  160. /*----------------------------------------------------------------------*/
  161. /*          s e t M a p p i n g C o n t e x t */
  162. /* */
  163. /* Sets the window mapping register to a card address. */
  164. /* */
  165. /* The window should be set to the value of 'vol.window.currentPage', */
  166. /* which is the card address divided by 4 KB. An address over 128KB, */
  167. /* (page over 32K) specifies an attribute-space address. */
  168. /* */
  169. /* The page to map is guaranteed to be on a full window-size boundary. */
  170. /* */
  171. /* Parameters:                                                          */
  172. /* vol : Pointer identifying drive */
  173. /*                                                                      */
  174. /*----------------------------------------------------------------------*/
  175.   void (*setMappingContext)(FLSocket vol, unsigned page);
  176. /*----------------------------------------------------------------------*/
  177. /*       g e t A n d C l e a r C a r d C h a n g e I n d i c a t o r    */
  178. /* */
  179. /* Returns the hardware card-change indicator and clears it if set. */
  180. /* */
  181. /* Parameters:                                                          */
  182. /* vol : Pointer identifying drive */
  183. /*                                                                      */
  184. /* Returns:                                                             */
  185. /* 0 = Card not changed, other = card changed */
  186. /*----------------------------------------------------------------------*/
  187.   FLBoolean (*getAndClearCardChangeIndicator)(FLSocket vol);
  188. /*----------------------------------------------------------------------*/
  189. /*                 w r i t e P r o t e c t e d */
  190. /* */
  191. /* Returns the write-protect state of the media */
  192. /* */
  193. /* Parameters:                                                          */
  194. /* vol : Pointer identifying drive */
  195. /*                                                                      */
  196. /* Returns:                                                             */
  197. /* 0 = not write-protected, other = write-protected */
  198. /*----------------------------------------------------------------------*/
  199.   FLBoolean (*writeProtected)(FLSocket vol);
  200. /*----------------------------------------------------------------------*/
  201. /*                 f r e e S o c k e t */
  202. /* */
  203. /* Free resources that were allocated for this socket. */
  204. /* This function is called when FLite exits. */
  205. /* */
  206. /* Parameters:                                                          */
  207. /* vol : Pointer identifying drive */
  208. /*                                                                      */
  209. /*----------------------------------------------------------------------*/
  210. #ifdef EXIT
  211.   void (*freeSocket)(FLSocket vol);
  212. #endif
  213. };
  214. #define UNDEFINED_MAPPING 0x7fff
  215. typedef unsigned long CardAddress; /* Physical offset on card */
  216. /* See interface documentation of functions in socket.c */
  217. extern FLStatus flInitSockets(void);
  218. #ifdef EXIT
  219. extern void flExitSocket(FLSocket *);
  220. #endif
  221. extern unsigned flSocketNoOf(const FLSocket *);
  222. extern FLSocket * flSocketOf(unsigned volNo);
  223. extern FLBuffer *flBufferOf(unsigned volNo);
  224. extern void flNeedVcc(FLSocket *);
  225. extern void flDontNeedVcc(FLSocket *);
  226. #ifdef SOCKET_12_VOLTS
  227. extern FLStatus flNeedVpp(FLSocket *);
  228. extern void flDontNeedVpp(FLSocket *);
  229. #endif
  230. extern void flSocketSetBusy(FLSocket *, FLBoolean); /* entry/exit operations */
  231. extern FLBoolean  flWriteProtected(FLSocket *); /* write-protection status */
  232. #ifndef FIXED_MEDIA
  233. extern FLStatus flMediaCheck(FLSocket *); /* check for media status change */
  234. extern void flResetCardChanged(FLSocket *);
  235. #endif
  236. extern unsigned flGetMappingContext(FLSocket *);  /* Currently mapped 4KB page */
  237. extern void FAR0 *flMap(FLSocket *, CardAddress); /* map and point at card address */
  238. extern void flSetWindowBusWidth(FLSocket *, unsigned); /* set window data-path */
  239. extern void flSetWindowSpeed(FLSocket *, unsigned); /* set window speed (nsec.) */
  240. extern void flSetWindowSize(FLSocket *, unsigned); /* in 4KB units */
  241. extern void flSetPowerOnCallback(FLSocket *, void (*)(void *), void *);
  242. /* Set MTD notification for socket power on */
  243. extern void  flIntervalRoutine(FLSocket *); /* socket interval routine */
  244. extern unsigned noOfDrives; /* No. of drives actually registered */
  245. /* The milliseconds counter is active when socket polling is enabled. When
  246.    the socket interval routine is called, the counter is incremented by
  247.    the interval in milliseconds.
  248.    The counter can be used to avoid getting in a loop that is not guaranteed
  249.    to terminate (such as waiting for a flash status register). Save the counter
  250.    at entry to the loop, and check in the loop the amount of time that
  251.    was spent in the loop. */
  252. extern unsigned long  flMsecCounter;
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256. #endif