xref: /reactos/sdk/tools/fatten/fatfs/diskio.h (revision c2c66aff)
1 /*-----------------------------------------------------------------------/
2 /  Low level disk interface modlue include file   (C)ChaN, 2014          /
3 /-----------------------------------------------------------------------*/
4 
5 #ifndef _DISKIO_DEFINED
6 #define _DISKIO_DEFINED
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #define _USE_WRITE	1	/* 1: Enable disk_write function */
13 #define _USE_IOCTL	1	/* 1: Enable disk_ioctl fucntion */
14 
15 #include <typedefs.h>
16 
17 
18 /* Status of Disk Functions */
19 typedef BYTE	DSTATUS;
20 
21 /* Results of Disk Functions */
22 typedef enum {
23 	RES_OK = 0,		/* 0: Successful */
24 	RES_ERROR,		/* 1: R/W Error */
25 	RES_WRPRT,		/* 2: Write Protected */
26 	RES_NOTRDY,		/* 3: Not Ready */
27 	RES_PARERR		/* 4: Invalid Parameter */
28 } DRESULT;
29 
30 
31 /*---------------------------------------*/
32 /* Prototypes for disk control functions */
33 
34 DSTATUS disk_openimage(BYTE pdrv, const char* imageFileName);
35 VOID disk_cleanup(BYTE pdrv);
36 
37 DSTATUS disk_initialize (BYTE pdrv);
38 DSTATUS disk_status (BYTE pdrv);
39 DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
40 DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
41 DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
42 
43 
44 /* Disk Status Bits (DSTATUS) */
45 
46 #define STA_NOINIT		0x01	/* Drive not initialized */
47 #define STA_NODISK		0x02	/* No medium in the drive */
48 #define STA_PROTECT		0x04	/* Write protected */
49 
50 
51 /* Command code for disk_ioctrl fucntion */
52 
53 /* Generic command (Used by FatFs) */
54 #define CTRL_SYNC			0	/* Complete pending write process (needed at _FS_READONLY == 0) */
55 #define GET_SECTOR_COUNT	1	/* Get media size (needed at _USE_MKFS == 1) */
56 #define GET_SECTOR_SIZE		2	/* Get sector size (needed at _MAX_SS != _MIN_SS) */
57 #define GET_BLOCK_SIZE		3	/* Get erase block size (needed at _USE_MKFS == 1) */
58 #define CTRL_TRIM			4	/* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
59 
60 /* Custom command for image file resizing */
61 #define SET_SECTOR_COUNT	126
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif
68