Subversion Repositories NedoOS

Rev

Rev 10 | Rev 115 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1. /*-----------------------------------------------------------------------
  2. /  Low level disk interface modlue include file
  3. /-----------------------------------------------------------------------*/
  4.  
  5. #ifndef _DISKIO
  6.  
  7. #define _READONLY       0       /* 1: Remove write functions */
  8. #define _USE_IOCTL      1       /* 1: Use disk_ioctl fucntion */
  9.  
  10. #include "integer.h"
  11.  
  12.  
  13.  
  14. /* Status of Disk Functions */
  15. typedef BYTE    DSTATUS;
  16.  
  17. /* Results of Disk Functions */
  18. typedef enum {
  19.         RES_OK = 0,             /* 0: Successful */
  20.         RES_ERROR,              /* 1: R/W Error */
  21.         RES_WRPRT,              /* 2: Write Protected */
  22.         RES_NOTRDY,             /* 3: Not Ready */
  23.         RES_PARERR              /* 4: Invalid Parameter */
  24. } DRESULT;
  25.  
  26. //Parameters for disk_read and disk_write
  27. typedef struct {
  28.         DRESULT (*init)(BYTE,BYTE*);
  29.         DRESULT (*read)(void);
  30.         DRESULT (*write)(void);
  31.         unsigned char (*status)(BYTE);
  32.         void (*RTC)(DWORD*);
  33.         BYTE  drv;
  34.         const BYTE* buf;
  35.         DWORD* sec;
  36.         BYTE  num;
  37. } DIO_PAR;
  38. extern DIO_PAR drv_calls_struct;
  39. #define SET_DIO_PAR(dr_drv,dr_buf,dr_sec,dr_num) {\
  40.   drv_calls_struct.drv=dr_drv; \
  41.   drv_calls_struct.buf=dr_buf; \
  42.   drv_calls_struct.sec=&dr_sec; \
  43.   drv_calls_struct.num=dr_num;}
  44.  
  45.  
  46. /*---------------------------------------*/
  47. /* Prototypes for disk control functions */
  48.  
  49. int assign_drives (int, int);
  50.  
  51. #define disk_initialize drv_calls_struct.init
  52. //DSTATUS disk_initialize (BYTE,BYTE*);
  53.  
  54. #define disk_read drv_calls_struct.read
  55. //DRESULT disk_read (void);
  56.  
  57. #if     _READONLY == 0
  58. #define disk_write drv_calls_struct.write
  59. //DRESULT disk_write (void);
  60. #endif
  61. #define disk_ioctl(_ab,_ac,_ad) ((DRESULT)0)
  62. //extern BYTE ds_m[3];
  63. /* Disk Status Bits (DSTATUS) */
  64.  
  65. #define STA_NOINIT              0x01    /* Drive not initialized */
  66. #define STA_NODISK              0x02    /* No medium in the drive */
  67. #define STA_PROTECT             0x04    /* Write protected */
  68. #define disk_status drv_calls_struct.status
  69.  
  70. /* Command code for disk_ioctrl fucntion */
  71.  
  72. /* Generic command (defined for FatFs) */
  73. #define CTRL_SYNC                       0       /* Flush disk cache (for write functions) */
  74. #define GET_SECTOR_COUNT        1       /* Get media size (for only f_mkfs()) */
  75. #define GET_SECTOR_SIZE         2       /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
  76. #define GET_BLOCK_SIZE          3       /* Get erase block size (for only f_mkfs()) */
  77. #define CTRL_ERASE_SECTOR       4       /* Force erased a block of sectors (for only _USE_ERASE) */
  78.  
  79. /* Generic command */
  80. #define CTRL_POWER                      5       /* Get/Set power status */
  81. #define CTRL_LOCK                       6       /* Lock/Unlock media removal */
  82. #define CTRL_EJECT                      7       /* Eject media */
  83.  
  84. /* MMC/SDC specific ioctl command */
  85. #define MMC_GET_TYPE            10      /* Get card type */
  86. #define MMC_GET_CSD                     11      /* Get CSD */
  87. #define MMC_GET_CID                     12      /* Get CID */
  88. #define MMC_GET_OCR                     13      /* Get OCR */
  89. #define MMC_GET_SDSTAT          14      /* Get SD status */
  90.  
  91. /* ATA/CF specific ioctl command */
  92. #define ATA_GET_REV                     20      /* Get F/W revision */
  93. #define ATA_GET_MODEL           21      /* Get model name */
  94. #define ATA_GET_SN                      22      /* Get serial number */
  95.  
  96. /* NAND specific ioctl command */
  97. #define NAND_FORMAT                     30      /* Create physical format */
  98.  
  99.  
  100. #define _DISKIO
  101. #endif
  102.