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

VxWorks

开发平台:

C/C++

  1. /* usrFd.c - floppy disk initialization */
  2. /* Copyright 1992-2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01h,21sep01,jkf  cbio API changes.
  7. 01g,21jun00,rsh  upgrade to dosFs 2.0
  8. 01f,04nov98,lrn  fixed return value checking for dosFsDevCreate()
  9. 01e,14oct98,lrn  modified for DosFs 2.0
  10. 01d,28jun95,hdn  doc change.
  11. 01c,24jan95,jdi  doc cleanup.
  12. 01b,25oct94,hdn  swapped 1st and 2nd parameter of fdDevCreate() and
  13.  usrFdConfig().
  14. 01a,25oct93,hdn  written.
  15. */
  16. /*
  17. DESCRIPTION
  18. This file is used to configure and initialize the VxWorks floppy disk support.
  19. This file is included by the prjConfig.c configuration file created by thge Project Manager.
  20. NOMANUAL
  21. */
  22. #include "vxWorks.h"
  23. #include "dosFsLib.h"
  24. #include "dpartCbio.h"
  25. #include "dcacheCbio.h"
  26. #include "usrFdiskPartLib.h"
  27. /* forward declaration */
  28. /* macro's */
  29. #ifndef FD_CACHE_SIZE
  30. #define FD_CACHE_SIZE 0x0
  31. #endif /* !FD_CACHE_SIZE */
  32. /*******************************************************************************
  33. *
  34. * usrFdConfig - mount a DOS file system from a floppy disk
  35. *
  36. * This routine mounts a DOS file system from a floppy disk device.
  37. *
  38. * The <drive> parameter is the drive number of the floppy disk;
  39. * valid values are 0 to 3.
  40. *
  41. * The <type> parameter specifies the type of diskette, which is described
  42. * in the structure table `fdTypes[]' in sysLib.c.  <type> is an index to
  43. * the table.  Currently the table contains two diskette types:
  44. * .iP "" 4
  45. * A <type> of 0 indicates the first entry in the table (3.5" 2HD, 1.44MB);
  46. * .iP
  47. * A <type> of 1 indicates the second entry in the table (5.25" 2HD, 1.2MB).
  48. * .LP
  49. *
  50. * The <fileName> parameter is the mount point, e.g., `/fd0/'.
  51. *
  52. * RETURNS: OK or ERROR.
  53. *
  54. * SEE ALSO:
  55. * .pG "I/O System, Local File Systems, Intel i386/i486 Appendix"
  56. */
  57. STATUS usrFdConfig
  58.     (
  59.     int     drive, /* drive number of floppy disk (0 - 3) */
  60.     int     type, /* type of floppy disk */
  61.     char *  fileName /* mount point */
  62.     )
  63.     {
  64.     BLK_DEV *pBootDev;
  65.     CBIO_DEV_ID cbio ;
  66.     char bootDir [BOOT_FILE_LEN];
  67.     if( type == NONE)
  68. return OK;
  69.     if ((UINT)drive >= FD_MAX_DRIVES)
  70. {
  71. printErr ("drive is out of range (0-%d).n", FD_MAX_DRIVES - 1);
  72. return (ERROR);
  73. }
  74.     /* create a block device spanning entire disk (non-distructive!) */
  75.     if ((pBootDev = fdDevCreate (drive, type, 0, 0)) == NULL)
  76. {
  77.         printErr ("fdDevCreate failed.n");
  78.         return (ERROR);
  79. }
  80.     /* create a disk cache to speed up Floppy operation */
  81.     cbio = dcacheDevCreate( (CBIO_DEV_ID) pBootDev, NULL, 
  82.                            FD_CACHE_SIZE, bootDir );
  83.     if( cbio == NULL )
  84. {
  85. /* insufficient memory, will avoid the cache */
  86. cbio = cbioWrapBlkDev (pBootDev);
  87. }
  88.     /* split off boot device from boot file */
  89.     devSplit (fileName, bootDir);
  90.     /* initialize device as a dosFs device named <bootDir> */
  91.     if (dosFsDevCreate (bootDir, cbio, 20, NONE) == ERROR)
  92. {
  93.         printErr ("dosFsDevCreate failed.n");
  94.         return (ERROR);
  95. }
  96.     return (OK);
  97.     }