1 
2 // automatically generated by m4 from headers in proto subdir
3 
4 
5 #ifndef __DISKIO_H__
6 #define __DISKIO_H__
7 
8 #include <arch.h>
9 #include <stdint.h>
10 
11 /*
12  * Disk Status Bits DSTATUS (uint8_t)
13  *
14  */
15 
16 #define STA_NOINIT		0x01	/* Drive not initialised */
17 #define STA_NODISK		0x02	/* No medium in the drive */
18 #define STA_PROTECT		0x04	/* Write protected */
19 
20 /*
21  * Command codes for disk_ioctrl function
22  *
23  */
24 
25 /* Generic command (Used by FatFs) */
26 #define CTRL_SYNC			0	/* Complete pending write process (needed at _FS_READONLY == 0) */
27 #define GET_SECTOR_COUNT	1	/* Get media size (needed at _USE_MKFS == 1) */
28 #define GET_SECTOR_SIZE		2	/* Get sector size (needed at _MAX_SS != _MIN_SS) */
29 #define GET_BLOCK_SIZE		3	/* Get erase block size (needed at _USE_MKFS == 1) */
30 
31 /* Generic command (not used by FatFs) */
32 #define CTRL_POWER			5	/* Get/Set power status */
33 #define CTRL_LOCK			6	/* Lock/Unlock media removal */
34 #define CTRL_EJECT			7	/* Eject media */
35 #define CTRL_FORMAT			8	/* Create physical format on the media */
36 
37 /* MMC/SDC specific ioctl command */
38 #define MMC_GET_TYPE		10	/* Get card type */
39 #define MMC_GET_CSD			11	/* Get CSD */
40 #define MMC_GET_CID			12	/* Get CID */
41 #define MMC_GET_OCR			13	/* Get OCR */
42 #define MMC_GET_SDSTAT		14	/* Get SD status */
43 #define ISDIO_READ			55	/* Read data form SD iSDIO register */
44 #define ISDIO_WRITE			56	/* Write data to SD iSDIO register */
45 #define ISDIO_MRITE			57	/* Masked write data to SD iSDIO register */
46 
47 /* ATA/CF specific ioctl command */
48 #define ATA_GET_REV			20	/* Get F/W revision */
49 #define ATA_GET_MODEL		21	/* Get model name */
50 #define ATA_GET_SN			22	/* Get serial number */
51 
52 /* NAND specific ioctl command */
53 #define NAND_FORMAT			30	/* Create physical format */
54 
55 /* MMC card type flags (MMC_GET_TYPE) */
56 #define CT_MMC				0x01		/* MMC ver 3 */
57 #define CT_SD1				0x02		/* SD ver 1 */
58 #define CT_SD2				0x04		/* SD ver 2 */
59 #define CT_SDC				(CT_SD1|CT_SD2)	/* SD */
60 #define CT_BLOCK			0x08		/* Block addressing */
61 
62 
63 
64 /* Status of Disk Functions */
65 typedef BYTE DSTATUS;
66 
67 /* Results of Disk Functions */
68 typedef enum {
69     RES_OK = 0,	    /* 0: Successful */
70     RES_ERROR = 1,  /* 1: R/W Error */
71     RES_WRPRT = 2,  /* 2: Write Protected */
72     RES_NOTRDY = 3, /* 3: Not Ready */
73     RES_PARERR = 4  /* 4: Invalid Parameter */
74 } DRESULT;
75 
76 /* FatFS for non exFAT file systems */
77 typedef DWORD LBA_t;
78 
79 //
80 // IDE DISK COMMANDS
81 //
82 
83 extern DSTATUS disk_initialize(BYTE pdrv) __preserves_regs(iyh,iyl);
84 extern DSTATUS disk_initialize_fastcall(BYTE pdrv) __preserves_regs(iyh,iyl) __z88dk_fastcall;
85 #define disk_initialize(a) disk_initialize_fastcall(a)
86 
87 
88 extern DSTATUS disk_status(BYTE pdrv) __preserves_regs(iyh,iyl);
89 extern DSTATUS disk_status_fastcall(BYTE pdrv) __preserves_regs(iyh,iyl) __z88dk_fastcall;
90 #define disk_status(a) disk_status_fastcall(a)
91 
92 
93 extern DRESULT disk_read(BYTE pdrv,BYTE* buff,LBA_t sector,UINT count) __preserves_regs(iyh,iyl);
94 extern DRESULT disk_read_callee(BYTE pdrv,BYTE* buff,LBA_t sector,UINT count) __preserves_regs(iyh,iyl) __z88dk_callee;
95 #define disk_read(a,b,c,d) disk_read_callee(a,b,c,d)
96 
97 
98 extern DRESULT disk_write(BYTE pdrv,const BYTE* buff,LBA_t sector,UINT count) __preserves_regs(iyh,iyl);
99 extern DRESULT disk_write_callee(BYTE pdrv,const BYTE* buff,LBA_t sector,UINT count) __preserves_regs(iyh,iyl) __z88dk_callee;
100 #define disk_write(a,b,c,d) disk_write_callee(a,b,c,d)
101 
102 
103 extern DRESULT disk_ioctl(BYTE pdrv,BYTE cmd,void* buff) __preserves_regs(iyh,iyl);
104 extern DRESULT disk_ioctl_callee(BYTE pdrv,BYTE cmd,void* buff) __preserves_regs(iyh,iyl) __z88dk_callee;
105 #define disk_ioctl(a,b,c) disk_ioctl_callee(a,b,c)
106 
107 
108 
109 #endif
110