/src/barebox/fs/fat/diskio.h
Line | Count | Source |
1 | | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | | |
3 | | /*----------------------------------------------------------------------- |
4 | | / Low level disk interface modlue include file |
5 | | /-----------------------------------------------------------------------*/ |
6 | | |
7 | | #ifndef _DISKIO |
8 | | |
9 | | #ifdef __PBL__ |
10 | | #define _READONLY 1 /* 1: Remove write functions */ |
11 | | #else |
12 | | #define _READONLY 0 |
13 | | #endif |
14 | | |
15 | | #define _USE_IOCTL 1 /* 1: Use disk_ioctl fucntion */ |
16 | | |
17 | | #include "disks.h" |
18 | | #include "integer.h" |
19 | | |
20 | | |
21 | | /* Status of Disk Functions */ |
22 | | typedef BYTE DSTATUS; |
23 | | |
24 | | /* Results of Disk Functions */ |
25 | | typedef enum { |
26 | | RES_OK = 0, /* 0: Successful */ |
27 | | RES_ERROR, /* 1: R/W Error */ |
28 | | RES_WRPRT, /* 2: Write Protected */ |
29 | | RES_NOTRDY, /* 3: Not Ready */ |
30 | | RES_PARERR /* 4: Invalid Parameter */ |
31 | | } DRESULT; |
32 | | |
33 | | |
34 | | /*---------------------------------------*/ |
35 | | /* Prototypes for disk control functions */ |
36 | | |
37 | | int assign_drives (int, int); |
38 | | DSTATUS disk_initialize (FATFS *fatfs); |
39 | | DSTATUS disk_status (FATFS *fatfs); |
40 | | DRESULT disk_read (FATFS *fatfs, BYTE*, DWORD, BYTE); |
41 | | #if _READONLY == 0 |
42 | | DRESULT disk_write (FATFS *fatfs, const BYTE*, DWORD, BYTE); |
43 | | DRESULT disk_flush (FATFS *fatfs); |
44 | | #endif |
45 | | DRESULT disk_ioctl (FATFS *fatfs, BYTE, void*); |
46 | | |
47 | | #if IN_PROPER |
48 | | unsigned int disk_sector_size(FATFS *fat); |
49 | | #else |
50 | | static inline unsigned int disk_sector_size(FATFS *fat) |
51 | 0 | { |
52 | 0 | return SECTOR_SIZE; |
53 | 0 | } Unexecuted instantiation: fat-pbl.c:disk_sector_size Unexecuted instantiation: ff.c:disk_sector_size Unexecuted instantiation: fat-diskio.c:disk_sector_size |
54 | | #endif |
55 | | |
56 | | |
57 | | /* Disk Status Bits (DSTATUS) */ |
58 | | |
59 | | #define STA_NOINIT 0x01 /* Drive not initialized */ |
60 | | #define STA_NODISK 0x02 /* No medium in the drive */ |
61 | | #define STA_PROTECT 0x04 /* Write protected */ |
62 | | |
63 | | |
64 | | /* Command code for disk_ioctrl fucntion */ |
65 | | |
66 | | /* Generic command (defined for FatFs) */ |
67 | 0 | #define CTRL_SYNC 0 /* Flush disk cache (for write functions) */ |
68 | | #define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */ |
69 | 2.04k | #define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ |
70 | | #define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */ |
71 | | #define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */ |
72 | | |
73 | | /* Generic command */ |
74 | | #define CTRL_POWER 5 /* Get/Set power status */ |
75 | | #define CTRL_LOCK 6 /* Lock/Unlock media removal */ |
76 | | #define CTRL_EJECT 7 /* Eject media */ |
77 | | |
78 | | /* MMC/SDC specific ioctl command */ |
79 | | #define MMC_GET_TYPE 10 /* Get card type */ |
80 | | #define MMC_GET_CSD 11 /* Get CSD */ |
81 | | #define MMC_GET_CID 12 /* Get CID */ |
82 | | #define MMC_GET_OCR 13 /* Get OCR */ |
83 | | #define MMC_GET_SDSTAT 14 /* Get SD status */ |
84 | | |
85 | | /* ATA/CF specific ioctl command */ |
86 | | #define ATA_GET_REV 20 /* Get F/W revision */ |
87 | | #define ATA_GET_MODEL 21 /* Get model name */ |
88 | | #define ATA_GET_SN 22 /* Get serial number */ |
89 | | |
90 | | /* NAND specific ioctl command */ |
91 | | #define NAND_FORMAT 30 /* Create physical format */ |
92 | | |
93 | | |
94 | | #define _DISKIO |
95 | | #endif |