PDK API Guide for J721E
FATFS.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
46 #ifndef FATFS_H
47 #define FATFS_H
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 #include <stdint.h>
54 #include <stddef.h>
55 #include <ti/fs/fatfs/ff.h>
56 #include <ti/fs/fatfs/diskio.h>
57 
63 #define FATFS_OK 0
64 
69 #define FATFS_ERR (-(1))
70 
76 #define FATFS_VOLUME_FULL_ERR (-(10))
77 
83 #define FATFS_VOLUME_DISK_AVL (0)
84 
85 /*Offset macros of MBR table */
90 #define FATFS_MBR_TABLE (446)
91 
96 #define FATFS_SZ_PTE (16)
97 
102 #define FATFS_NUM_OF_PARTITIONS (4)
103 
108 #define FATFS_MBR_PT_TYPE_OFFSET (4)
109 
114 #define FATFS_DFLT_VOLUME_PD (0xf)
115 
120 #define FATFS_DFLT_VOLUME_PT (0xf)
121 
126 #define FATFS_MOUNT_IMMEDIATE (1)
127 
132 #define FATFS_MOUNT_LATER (0)
133 
139 #define FATFS_MEDIA_BOOT_SEC_OFFSET (21)
140 
146 #define FATFS_JUMP_BOOT_SEC_OFFSET (0)
147 
152 #define FATFS_BOOT_MEDIA_TYPE_NON_REM (0xF0)
153 
158 #define FATFS_BOOT_MEDIA_REM_TYPE_MIN (0xF8)
159 
164 #define FATFS_BOOT_MEDIA_REM_TYPE_MAX (0xFF)
165 
170 #define FATFS_JUMP_BOOT_SEC_JMP_INS_0 (0xEB)
171 
176 #define FATFS_JUMP_BOOT_SEC_JMP_INS_1 (0xE9)
177 
186 typedef int32_t FATFS_Error;
187 
191 typedef void *FATFS_Handle;
192 
196 typedef void *FATFS_Params;
197 
201 typedef void *FATFS_DrvHandle;
202 
206 typedef void *FATFS_DrvParams;
207 
213 typedef struct FATFS_DrvFxnTable_s FATFS_DrvFxnTable;
214 
223 typedef struct FATFS_ConfigParams_s {
226  FATFS_DrvFxnTable *drvFxnTablePtr;
228  void *custom;
231 
237 
243  uint32_t cmd,
244  void *arg);
245 
250 typedef FATFS_Error (*FATFS_InitDrvFxn) (void);
251 
256 typedef FATFS_Error (*FATFS_OpenDrvFxn) (uint32_t index,
257  FATFS_DrvParams drvParams,
258  FATFS_DrvHandle *drvHandle);
259 
265  uint8_t *buf,
266  uint32_t block,
267  uint32_t numBlks);
268 
274  uint8_t *buf,
275  uint32_t block,
276  uint32_t numBlks);
277 
286 
289 
292 
295 
298 
301 };
302 
303 /* SD function table pointer */
304 extern FATFS_DrvFxnTable FATFS_drvFxnTable;
305 
309 typedef struct FATFS_HwAttrs_s {
310  uint32_t drvInst;
311 } FATFS_HwAttrs;
312 
318 typedef struct FATFS_Object_s {
320  uint32_t drvInst;
322  uint32_t driveNumber;
323  DSTATUS diskState;
324  FATFS filesystem[FATFS_NUM_OF_PARTITIONS];
328  uint32_t isOpen;
330 } FATFS_Object;
331 
343 typedef struct FATFS_Config_s {
345  FATFS_DrvFxnTable *drvFxnTablePtr;
346 
349 
352 } FATFS_Config;
353 
354 
355 /* Avoid Misra warning "MISRA.DECL.ARRAY_SIZE" by pairing config array type
356  * with its array size to avoid externs with [] (no size) */
357 typedef FATFS_Config FATFSConfigList[((uint32_t)_VOLUMES) + (uint32_t)1U];
358 
359 
369 extern FATFS_Error FATFS_close(FATFS_Handle handle);
370 
394 extern FATFS_Error FATFS_open(uint32_t index,
395  FATFS_Params params,
396  FATFS_Handle *handle);
397 
406 
415 extern FATFS_Error FATFS_init(void);
416 
417 #ifdef __cplusplus
418 }
419 #endif
420 
421 #endif /* FATFS_H */
uint16_t index
Definition: tisci_rm_proxy.h:153
FATFS_Error(* FATFS_ControlDrvFxn)(FATFS_DrvHandle drvHandle, uint32_t cmd, void *arg)
A function pointer to a driver specific implementation of FATFS_control().
Definition: FATFS.h:242
void * FATFS_Params
Parameters that is required for FATFS_open() call.
Definition: FATFS.h:196
FATFS_Object * object
Definition: FATFS.h:348
FATFS_ControlDrvFxn controlDrvFxn
Definition: FATFS.h:288
uint32_t drvInst
Definition: FATFS.h:320
FATFS_Error FATFS_init(void)
Function to initializes the FATFS module.
#define FATFS_NUM_OF_PARTITIONS
Definition: FATFS.h:102
uint32_t driveNumber
Definition: FATFS.h:322
void * FATFS_DrvParams
Parameters that is required to open driver.
Definition: FATFS.h:206
uint32_t isOpen
Definition: FATFS.h:328
FATFS_ReadDrvFxn readDrvFxn
Definition: FATFS.h:300
FATFS_DrvHandle drvHandle
Definition: FATFS.h:319
FATFS_Error FATFS_close(FATFS_Handle handle)
Function to close a SD peripheral specified by the SD handle.
FATFS_ConfigParams FATFSConfigParams
Definition: FATFS.h:326
FATFS_Error(* FATFS_WriteDrvFxn)(FATFS_DrvHandle drvHandle, uint8_t *buf, uint32_t block, uint32_t numBlks)
A function pointer to a driver specific implementation of FATFS_transfer().
Definition: FATFS.h:264
FATFS_DrvFxnTable * drvFxnTablePtr
Definition: FATFS.h:226
FATFS_DrvHandle drvHandle
Definition: FATFS.h:224
FATFS_Error(* FATFS_OpenDrvFxn)(uint32_t index, FATFS_DrvParams drvParams, FATFS_DrvHandle *drvHandle)
A function pointer to a driver specific implementation of FATFS_open().
Definition: FATFS.h:256
SDAm57x Hardware attributes.
Definition: FATFS.h:309
The definition of a SD function table that contains the required set of functions to control a specif...
Definition: FATFS.h:283
FATFS_Error FATFS_open(uint32_t index, FATFS_Params params, FATFS_Handle *handle)
Function to initialize a given SD peripheral specified by the particular index value....
FATFS_OpenDrvFxn openDrvFxn
Definition: FATFS.h:294
DSTATUS diskState
Definition: FATFS.h:323
FATFS_DrvParams drvParams
Definition: FATFS.h:225
void * custom
Definition: FATFS.h:228
SD Parameters.
Definition: FATFS.h:223
FATFS_Error(* FATFS_ReadDrvFxn)(FATFS_DrvHandle drvHandle, uint8_t *buf, uint32_t block, uint32_t numBlks)
A function pointer to a driver specific implementation of FATFS_transfer().
Definition: FATFS.h:273
FATFS_DrvFxnTable FATFS_drvFxnTable
int32_t FATFS_Error
Return status of FATFS.
Definition: FATFS.h:186
FATFS_CloseDrvFxn closeDrvFxn
Definition: FATFS.h:285
void * FATFS_Handle
A handle that is returned from a FATFS_open() call.
Definition: FATFS.h:191
void * FATFS_DrvHandle
A handle that is returned to open driver.
Definition: FATFS.h:201
gptp_ipc_command_t cmd
Definition: gptpipc.h:140
FATFS_Config FATFSConfigList[((uint32_t) _VOLUMES)+(uint32_t) 1U]
Definition: FATFS.h:357
SD Global configuration.
Definition: FATFS.h:343
FATFS_Error FATFS_Params_init(FATFS_Params params)
Function to initialize the FATFS_Params struct to its defaults.
FATFS_HwAttrs * hwAttrs
Definition: FATFS.h:351
SDAm572x Object.
Definition: FATFS.h:318
FATFS_InitDrvFxn initDrvFxn
Definition: FATFS.h:291
FATFS_Error(* FATFS_CloseDrvFxn)(FATFS_DrvHandle drvHandle)
A function pointer to a driver specific implementation of FATFS_close().
Definition: FATFS.h:236
FATFS_Error(* FATFS_InitDrvFxn)(void)
A function pointer to a driver specific implementation of FATFS_init().
Definition: FATFS.h:250
FATFS_DrvFxnTable * drvFxnTablePtr
Definition: FATFS.h:345
FATFS_WriteDrvFxn writeDrvFxn
Definition: FATFS.h:297
uint32_t drvInst
Definition: FATFS.h:310