Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

355 lines
16 KiB

  1. /*
  2. * $Log: V:/Flite/archives/TrueFFS5/Src/DOCSOC.C_V $
  3. *
  4. * Rev 1.5 Jan 17 2002 22:59:06 oris
  5. * mtdVars for DiskOnChip MTD were moved from diskonc.c and mdocplus.c to save RAM.
  6. * Added include for NANDDEFS.H
  7. *
  8. * Rev 1.4 Jun 17 2001 16:39:10 oris
  9. * Improved documentation and remove warnings.
  10. *
  11. * Rev 1.3 Apr 10 2001 16:41:46 oris
  12. * Restored all DiskOnChip socket routines from flsocket.c
  13. *
  14. * Rev 1.2 Apr 09 2001 14:59:50 oris
  15. * Added an empty routine to avoid warnings.
  16. *
  17. * Rev 1.1 Apr 01 2001 07:44:38 oris
  18. * Updated copywrite notice
  19. *
  20. * Rev 1.0 Feb 02 2001 13:26:30 oris
  21. * Initial revision.
  22. *
  23. */
  24. /***********************************************************************************/
  25. /* M-Systems Confidential */
  26. /* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2001 */
  27. /* All Rights Reserved */
  28. /***********************************************************************************/
  29. /* NOTICE OF M-SYSTEMS OEM */
  30. /* SOFTWARE LICENSE AGREEMENT */
  31. /* */
  32. /* THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE */
  33. /* AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT */
  34. /* FOR THE SPECIFIC TERMS AND CONDITIONS OF USE, */
  35. /* OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE: */
  36. /* E-MAIL = [email protected] */
  37. /***********************************************************************************/
  38. #include "flsocket.h"
  39. #include "nanddefs.h"
  40. #ifdef NT5PORT
  41. #include "scsi.h"
  42. #include "tffsport.h"
  43. extern NTsocketParams driveInfo[SOCKETS];
  44. NTSTATUS updateDocSocketParams(PDEVICE_EXTENSION fdoExtension)
  45. {
  46. NTSTATUS status;
  47. ULONG device;
  48. device = (fdoExtension->UnitNumber &0x0f);
  49. driveInfo[device].windowSize = fdoExtension->pcmciaParams.windowSize;
  50. driveInfo[device].physWindow = fdoExtension->pcmciaParams.physWindow;
  51. driveInfo[device].winBase = fdoExtension->pcmciaParams.windowBase;
  52. driveInfo[device].fdoExtension = (PVOID) fdoExtension;
  53. driveInfo[device].interfAlive = 1;
  54. return STATUS_SUCCESS;
  55. }
  56. #endif /* NT5PORT */
  57. NFDC21Vars docMtdVars[SOCKETS];
  58. /************************************************************************/
  59. /* */
  60. /* Beginning of controller-customizable code */
  61. /* */
  62. /* The function prototypes and interfaces in this section are standard */
  63. /* and are used in this form by the non-customizable code. However, the */
  64. /* function implementations are specific to the 82365SL controller. */
  65. /* */
  66. /* You should replace the function bodies here with the implementation */
  67. /* that is appropriate for your controller. */
  68. /* */
  69. /* All the functions in this section have no parameters. This is */
  70. /* because the parameters needed for an operation may be themselves */
  71. /* dependent on the controller. Instead, you should use the value in */
  72. /* the 'vol' structure as parameters. */
  73. /* If you need socket-state variables specific to your implementation, */
  74. /* it is recommended to add them to the 'vol' structure rather than */
  75. /* define them as separate static variables. */
  76. /* */
  77. /************************************************************************/
  78. /************************************************************************/
  79. /* c a r d D e t e c t e d */
  80. /* */
  81. /* Detect if a card is present (inserted) */
  82. /* */
  83. /* Parameters: */
  84. /* vol : Pointer identifying drive */
  85. /* */
  86. /* Returns: */
  87. /* 0 = card not present, other = card present */
  88. /************************************************************************/
  89. static FLBoolean cardDetected(FLSocket vol)
  90. {
  91. return TRUE;
  92. }
  93. /************************************************************************/
  94. /* V c c O n */
  95. /* */
  96. /* Turns on Vcc (3.3/5 Volts). Vcc must be known to be good on exit. */
  97. /* */
  98. /* Parameters: */
  99. /* vol : Pointer identifying drive */
  100. /* */
  101. /************************************************************************/
  102. static void VccOn(FLSocket vol)
  103. {
  104. }
  105. /************************************************************************/
  106. /* V c c O f f */
  107. /* */
  108. /* Turns off Vcc. */
  109. /* */
  110. /* Parameters: */
  111. /* vol : Pointer identifying drive */
  112. /* */
  113. /************************************************************************/
  114. static void VccOff(FLSocket vol)
  115. {
  116. }
  117. #ifdef SOCKET_12_VOLTS
  118. /************************************************************************/
  119. /* V p p O n */
  120. /* */
  121. /* Turns on Vpp (12 Volts. Vpp must be known to be good on exit.) */
  122. /* */
  123. /* Parameters: */
  124. /* vol : Pointer identifying drive */
  125. /* */
  126. /* Returns: */
  127. /* FLStatus : 0 on success, failed otherwise */
  128. /************************************************************************/
  129. static FLStatus VppOn(FLSocket vol)
  130. {
  131. return flOK;
  132. }
  133. /************************************************************************/
  134. /* V p p O f f */
  135. /* */
  136. /* Turns off Vpp. */
  137. /* */
  138. /* Parameters: */
  139. /* vol : Pointer identifying drive */
  140. /* */
  141. /************************************************************************/
  142. static void VppOff(FLSocket vol)
  143. {
  144. }
  145. #endif /* SOCKET_12_VOLTS */
  146. /************************************************************************/
  147. /* i n i t S o c k e t */
  148. /* */
  149. /* Perform all necessary initializations of the socket or controller */
  150. /* */
  151. /* Parameters: */
  152. /* vol : Pointer identifying drive */
  153. /* */
  154. /* Returns: */
  155. /* FLStatus : 0 on success, failed otherwise */
  156. /************************************************************************/
  157. static FLStatus initSocket(FLSocket vol)
  158. {
  159. return flOK;
  160. }
  161. /************************************************************************/
  162. /* s e t W i n d o w */
  163. /* */
  164. /* Sets in hardware all current window parameters: Base address, size, */
  165. /* speed and bus width. */
  166. /* The requested settings are given in the 'vol.window' structure. */
  167. /* */
  168. /* If it is not possible to set the window size requested in */
  169. /* 'vol.window.size', the window size should be set to a larger value, */
  170. /* if possible. In any case, 'vol.window.size' should contain the */
  171. /* actual window size (in 4 KB units) on exit. */
  172. /* */
  173. /* Parameters: */
  174. /* vol : Pointer identifying drive */
  175. /* */
  176. /************************************************************************/
  177. static void setWindow(FLSocket vol)
  178. {
  179. #ifdef NT5PORT
  180. vol.window.size = driveInfo[vol.volNo].windowSize;
  181. vol.window.base = driveInfo[vol.volNo].winBase;
  182. #endif/*NT5PORT*/
  183. }
  184. /************************************************************************/
  185. /* s e t M a p p i n g C o n t e x t */
  186. /* */
  187. /* Sets the window mapping register to a card address. */
  188. /* */
  189. /* The window should be set to the value of 'vol.window.currentPage', */
  190. /* which is the card address divided by 4 KB. An address over 128KB, */
  191. /* (page over 32K) specifies an attribute-space address. */
  192. /* */
  193. /* The page to map is guaranteed to be on a full window-size boundary. */
  194. /* */
  195. /* Parameters: */
  196. /* vol : Pointer identifying drive */
  197. /* page : page to map */
  198. /* */
  199. /************************************************************************/
  200. static void setMappingContext(FLSocket vol, unsigned page)
  201. {
  202. }
  203. /************************************************************************/
  204. /* 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 */
  205. /* */
  206. /* Returns the hardware card-change indicator and clears it if set. */
  207. /* */
  208. /* Parameters: */
  209. /* vol : Pointer identifying drive */
  210. /* */
  211. /* Returns: */
  212. /* 0 = Card not changed, other = card changed */
  213. /************************************************************************/
  214. static FLBoolean getAndClearCardChangeIndicator(FLSocket vol)
  215. {
  216. /* Note: On the 365, the indicator is turned off by the act of reading */
  217. return FALSE;
  218. }
  219. /************************************************************************/
  220. /* w r i t e P r o t e c t e d */
  221. /* */
  222. /* Returns the write-protect state of the media */
  223. /* */
  224. /* Parameters: */
  225. /* vol : Pointer identifying drive */
  226. /* */
  227. /* Returns: */
  228. /* 0 = not write-protected, other = write-protected */
  229. /************************************************************************/
  230. static FLBoolean writeProtected(FLSocket vol)
  231. {
  232. return FALSE;
  233. }
  234. #ifdef EXIT
  235. /************************************************************************/
  236. /* f r e e S o c k e t */
  237. /* */
  238. /* Free resources that were allocated for this socket. */
  239. /* This function is called when TrueFFS exits. */
  240. /* */
  241. /* Parameters: */
  242. /* vol : Pointer identifying drive */
  243. /* */
  244. /************************************************************************/
  245. static void freeSocket(FLSocket vol)
  246. {
  247. freePointer(vol.window.base,vol.window.size);
  248. }
  249. #endif /* EXIT */
  250. void docSocketInit(FLSocket vol)
  251. {
  252. vol.cardDetected = cardDetected;
  253. vol.VccOn = VccOn;
  254. vol.VccOff = VccOff;
  255. #ifdef SOCKET_12_VOLTS
  256. vol.VppOn = VppOn;
  257. vol.VppOff = VppOff;
  258. #endif
  259. vol.initSocket = initSocket;
  260. vol.setWindow = setWindow;
  261. vol.setMappingContext = setMappingContext;
  262. vol.getAndClearCardChangeIndicator = getAndClearCardChangeIndicator;
  263. vol.writeProtected = writeProtected;
  264. vol.updateSocketParams = NULL /* updateSocketParameters */;
  265. #ifdef EXIT
  266. vol.freeSocket = freeSocket;
  267. #endif
  268. }
  269. #ifdef NT5PORT
  270. /*----------------------------------------------------------------------*/
  271. /* f l R e g i s t e r D O C S O C */
  272. /* */
  273. /* Installs routines for DiskOnChip. */
  274. /* */
  275. /* Parameters: */
  276. /* None */
  277. /* */
  278. /* Returns: */
  279. /* FLStatus : 0 on success, otherwise failure */
  280. /*----------------------------------------------------------------------*/
  281. ULONG windowBaseAddress(ULONG driveNo)
  282. {
  283. return (ULONG) (driveInfo[driveNo].physWindow >> 12);
  284. }
  285. FLStatus flRegisterDOCSOC(ULONG startAddr,ULONG stopAddr)
  286. {
  287. if (noOfSockets >= DOC_DRIVES)
  288. return flTooManyComponents;
  289. for (; noOfSockets < DOC_DRIVES; noOfSockets++) {
  290. FLSocket vol = flSocketOf(noOfSockets);
  291. vol.volNo = noOfSockets;
  292. docSocketInit(&vol);
  293. flSetWindowSize(&vol, 2); /* 4 KBytes */
  294. //vol.window.baseAddress = flDocWindowBaseAddress(vol.volNo, 0, 0, NULL);
  295. vol.window.baseAddress = windowBaseAddress(vol.volNo);
  296. vol.window.base = pdriveInfo[vol.volNo & 0x0f].winBase;
  297. // if(((void *)vol.window.baseAddress) == NULL){
  298. // }
  299. }
  300. if (noOfSockets == 0)
  301. return flAdapterNotFound;
  302. return flOK;
  303. }
  304. #endif /*NT5PORT*/