Exemple #1
0
FRESULT FatFs::fdisk(Storage* storage, const uint32_t partitionSizes[], void* sectorBuffer)
{
    int drive;
    for (drive = 0; drive < _FF_PHYS_DRIVES; drive++)
        if (ff_device[drive] == storage) return f_fdisk(drive, partitionSizes, sectorBuffer);
    for (drive = 0; drive < _FF_PHYS_DRIVES; drive++)
        if (!ff_device[drive]) break;
    if (drive >= _FF_PHYS_DRIVES) return FR_TOO_MANY_OPEN_FILES;
    ff_device[drive] = storage;
    FRESULT result = f_fdisk(drive, partitionSizes, sectorBuffer);
    ff_device[drive] = NULL;
    return result;
}
Exemple #2
0
FRESULT DFATFS::fsfdisk(uint8_t pdrv, const uint32_t szt[], void* work)
{
    return(f_fdisk (pdrv, szt, work));
}
static msg_t ThreadFatFSWorker(void *arg) {
    (void)arg;

    Thread* p;

    chRegSetThreadName("fatfsWorker");
    while (!chThdShouldTerminate()) {

        /* Wait for msg with work to do. */
        p = chMsgWait();


        struct wrapper_msg_base* msg = (struct wrapper_msg_base*) chMsgGet(p);

        msg->result = FR_INVALID_PARAMETER;

        switch(msg->action) {

        case eTERMINATE: {
            break;
        }

#if HAS_MOUNT
        case eFMOUNT: {
            const struct wrapper_msg_vBYTEpFATFS* exmsg = \
                    (const struct wrapper_msg_vBYTEpFATFS*) msg;
            msg->result = f_mount(exmsg->byte, exmsg->fatfsp);
            break;
        }
#endif /* HAS_MOUNT */

#if HAS_OPEN
        case eFOPEN: {
            const struct wrapper_msg_pFILpTCHARvBYTE* exmsg = \
                    (const struct wrapper_msg_pFILpTCHARvBYTE*) msg;

            msg->result = f_open(exmsg->filep, exmsg->string, exmsg->byte);
            break;
        }
#endif /* HAS_OPEN */

#if HAS_READ
        case eFREAD: {
            const struct wrapper_msg_pFILpVOIDvUINTpUINT* exmsg = \
                    (const struct wrapper_msg_pFILpVOIDvUINTpUINT*) msg;

            msg->result = f_read(exmsg->filep, exmsg->voidp, exmsg->uint,
                                 exmsg->uintp);
            break;
        }
#endif /* HAS_READ */

#if HAS_WRITE
        case eFWRITE: {
            const struct wrapper_msg_pFILpVOIDvUINTpUINT* exmsg = \
                    (const struct wrapper_msg_pFILpVOIDvUINTpUINT*) msg;
            msg->result = f_write(exmsg->filep, exmsg->voidp, exmsg->uint,
                                  exmsg->uintp);
            break;
        }
#endif /* HAD_WRITE */

#if HAS_SYNC
        case eFSYNC: {
            const struct wrapper_msg_pFIL* exmsg = \
                                                   (const struct wrapper_msg_pFIL*) msg;
            msg->result = f_sync(exmsg->filep);
            break;
        }
#endif /* HAS_SYNC */

#if HAS_CHDRIVE
        case eFCHDRIVE: {
            const struct wrapper_msg_vBYTE* exmsg = \
                                                    (const struct wrapper_msg_vBYTE*) msg;
            msg->result = f_chdrive(exmsg->byte);
            break;
        }
#endif

#if HAS_CHDIR
        case eFCHDIR: {
            const struct wrapper_msg_pTCHAR* exmsg = \
                    (const struct wrapper_msg_pTCHAR*) msg;

            msg->result = f_chdir(exmsg->string);
            break;
        }
#endif /* HAS_CHDIR */

#if HAS_GETCWD
        case eFGETCWD: {
            const struct wrapper_msg_pTCHARvUINT* exmsg = \
                    (const struct wrapper_msg_pTCHARvUINT*) msg;
            msg->result = f_getcwd(exmsg->string, exmsg->uint);
            break;
        }
#endif

#if HAS_LSEEK
        case eFLSEEK: {
            const struct wrapper_msg_pFILvDWORD* exmsg = \
                    (const struct wrapper_msg_pFILvDWORD*) msg;
            msg->result = f_lseek(exmsg->filep, exmsg->dword);
            break;
        }
#endif /* HAS_LSEEK */

#if HAS_CLOSE
        case eFCLOSE: {
            const struct wrapper_msg_pFIL* exmsg = \
                                                   (const struct wrapper_msg_pFIL*) msg;
            msg->result = f_close(exmsg->filep);
            break;
        }
#endif /* HAS_CLOSE */

#if HAS_OPENDIR
        case eFOPENDIR: {
            const struct wrapper_msg_pDIRpTCHAR* exmsg = \
                    (const struct wrapper_msg_pDIRpTCHAR*) msg;
            msg->result = f_opendir(exmsg->dirp, exmsg->string);
            break;
        }
#endif /* HAD_OPENDIR */

#if HAS_READDIR
        case eFREADDIR: {
            const struct wrapper_msg_pDIRpFILINFO* exmsg = \
                    (const struct wrapper_msg_pDIRpFILINFO*) msg;
            msg->result = f_readdir(exmsg->dirp, exmsg->filinfop);
            break;
        }
#endif /* HAS_READDIR */

#if HAS_STAT
        case eFSTAT: {
            const struct wrapper_msg_pTCHARpFILINFO* exmsg = \
                    (const struct wrapper_msg_pTCHARpFILINFO*) msg;
            msg->result = f_stat(exmsg->string, exmsg->filinfop);
            break;
        }
#endif /* HAS_STAT */

#if HAS_GETFREE
        case eFGETFREE: {
            const struct wrapper_msg_pTCHARpDWORDppFATFS* exmsg = \
                    (const struct wrapper_msg_pTCHARpDWORDppFATFS*) msg;
            msg->result = f_getfree(exmsg->string, exmsg->dwordp, exmsg->fatfspp);
            break;
        }
#endif /* HAS_GETFREE */

#if HAS_TRUNCATE
        case eFTRUNCATE: {
            const struct wrapper_msg_pFIL* exmsg = \
                                                   (const struct wrapper_msg_pFIL*) msg;
            msg->result = f_truncate(exmsg->filep);
            break;
        }
#endif /* HAS_TRUNCATE */

#if HAS_UNLINK
        case eFUNLINK: {
            const struct wrapper_msg_pTCHAR* exmsg = \
                    (const struct wrapper_msg_pTCHAR*) msg;
            msg->result = f_unlink(exmsg->string);
            break;
        }
#endif /* HAS_UNLINK */

#if HAS_MKDIR
        case eFMKDIR: {
            const struct wrapper_msg_pTCHAR* exmsg = \
                    (const struct wrapper_msg_pTCHAR*) msg;
            msg->result = f_mkdir(exmsg->string);
            break;
        }
#endif /* HAS_MKDIR */

#if HAS_CHMOD
        case eFCHMOD: {
            const struct wrapper_msg_pTCHARvBYTEvBYTE* exmsg = \
                    (const struct wrapper_msg_pTCHARvBYTEvBYTE*) msg;
            msg->result = f_chmod(exmsg->string, exmsg->byte1, exmsg->byte2);
            break;
        }
#endif /* HAS_CHMOD */

#if HAS_UTIME
        case eFUTIME: {
            const struct wrapper_msg_pTCHARpFILINFO* exmsg = \
                    (const struct wrapper_msg_pTCHARpFILINFO*) msg;
            msg->result = f_utime(exmsg->string, exmsg->filinfop);
            break;
        }
#endif /* HAD_UTIME */

#if HAS_RENAME
        case eFRENAME: {
            const struct wrapper_msg_pTCHARpTCHAR* exmsg = \
                    (const struct wrapper_msg_pTCHARpTCHAR*) msg;

            msg->result = f_rename(exmsg->string1, exmsg->string2);
            break;
        }
#endif /* HAS_RENAME */

#if HAS_MKFS
        case eFMKFS: {
            const struct wrapper_msg_vBYTEvBYTEvUINT* exmsg = \
                    (const struct wrapper_msg_vBYTEvBYTEvUINT*) msg;
            msg->result = f_mkfs(exmsg->byte1, exmsg->byte2, exmsg->uint);
            break;
        }
#endif /* HAS_MKFS */

#if HAS_FDISK
        case eFFDISK: {
            const struct wrapper_msg_vBYTEpDWORDpVOID* exmsg = \
                    (const struct wrapper_msg_vBYTEpDWORDpVOID*) msg;
            msg->result = f_fdisk(exmsg->byte, exmsg->dwordp, exmsg->voidp);
            break;
        }
#endif /* HAS_FDISK */

#if HAS_GETS
        case eFGETS: {
            struct wrapper_msg_pTCHARvINTpFILpTCHAR* exmsg = \
                    (struct wrapper_msg_pTCHARvINTpFILpTCHAR*) msg;

            exmsg->string2 = f_gets(exmsg->string, exmsg->n, exmsg->filep);
            break;
        }
#endif /* HAS_GETS */

#if HAS_PUTC
        case eFPUTC: {
            const struct wrapper_msg_vTCHARpFIL* exmsg = \
                    (const struct wrapper_msg_vTCHARpFIL*) msg;

            msg->result = f_putc(exmsg->tchar, exmsg->filep);
            break;
        }
#endif /* HAS_PUTC */

#if HAS_PUTS
        case eFPUTS: {
            const struct wrapper_msg_pTCHARpFIL* exmsg = \
                    (const struct wrapper_msg_pTCHARpFIL*) msg;

            msg->result = f_puts(exmsg->string, exmsg->filep);
            break;
        }
#endif /* HAS_PUTS */

        }

        /* Done, release msg again. */
        chMsgRelease(p, 0);
    }

    return 0;
}