diff --git a/cc3200/ftp/ftp.c b/cc3200/ftp/ftp.c index c8a52149cbfbc59cfb184b6b8b3d264d359c91dd..679c3256131ef001f830e5a5b77750222996e901 100644 --- a/cc3200/ftp/ftp.c +++ b/cc3200/ftp/ftp.c @@ -32,7 +32,7 @@ #include "py/obj.h" #include "lib/oofatfs/ff.h" #include "extmod/vfs.h" -#include "extmod/fsusermount.h" +#include "extmod/vfs_fat.h" #include "inc/hw_types.h" #include "inc/hw_ints.h" #include "inc/hw_memmap.h" diff --git a/cc3200/mods/pybflash.c b/cc3200/mods/pybflash.c index 0779f4a05c587af795d8ceccf70338f6cd361bda..f5af79dbf626933a6c2c1fa98f388583e5688122 100644 --- a/cc3200/mods/pybflash.c +++ b/cc3200/mods/pybflash.c @@ -31,7 +31,6 @@ #include "lib/oofatfs/ff.h" #include "lib/oofatfs/diskio.h" #include "extmod/vfs_fat.h" -#include "extmod/fsusermount.h" #include "fatfs/src/drivers/sflash_diskio.h" #include "mods/pybflash.h" diff --git a/cc3200/mods/pybsd.c b/cc3200/mods/pybsd.c index bac5a270c8293f29557064e924be68d457bb749c..937b8599dc8e7e3c9c707179efd998db44d0f455 100644 --- a/cc3200/mods/pybsd.c +++ b/cc3200/mods/pybsd.c @@ -29,7 +29,7 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" #include "lib/oofatfs/diskio.h" -#include "extmod/fsusermount.h" +#include "extmod/vfs_fat.h" #include "inc/hw_types.h" #include "inc/hw_gpio.h" #include "inc/hw_ints.h" diff --git a/cc3200/mptask.c b/cc3200/mptask.c index 476561c6d83e59a4369b88f2e54d612ddd627682..c7c1832edbdfdd2831eba74a5e0789b2406c04d6 100644 --- a/cc3200/mptask.c +++ b/cc3200/mptask.c @@ -36,7 +36,7 @@ #include "lib/oofatfs/ff.h" #include "lib/oofatfs/diskio.h" #include "extmod/vfs.h" -#include "extmod/fsusermount.h" +#include "extmod/vfs_fat.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_ints.h" diff --git a/extmod/fsusermount.h b/extmod/fsusermount.h deleted file mode 100644 index af6867d23c0264435e757eac12a3860906bad353..0000000000000000000000000000000000000000 --- a/extmod/fsusermount.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the Micro Python project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// these are the values for fs_user_mount_t.flags -#define FSUSER_NATIVE (0x0001) // readblocks[2]/writeblocks[2] contain native func -#define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount -#define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl - -// constants for block protocol ioctl -#define BP_IOCTL_INIT (1) -#define BP_IOCTL_DEINIT (2) -#define BP_IOCTL_SYNC (3) -#define BP_IOCTL_SEC_COUNT (4) -#define BP_IOCTL_SEC_SIZE (5) - -typedef struct _fs_user_mount_t { - mp_obj_base_t base; - const char *str; - uint16_t len; // length of str - uint16_t flags; - mp_obj_t readblocks[4]; - mp_obj_t writeblocks[4]; - // new protocol uses just ioctl, old uses sync (optional) and count - union { - mp_obj_t ioctl[4]; - struct { - mp_obj_t sync[2]; - mp_obj_t count[2]; - } old; - } u; - FATFS fatfs; -} fs_user_mount_t; - -fs_user_mount_t *fatfs_mount_mkfs(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, bool mkfs); -mp_obj_t fatfs_umount(mp_obj_t bdev_or_path_in); - -MP_DECLARE_CONST_FUN_OBJ_KW(fsuser_mount_obj); -MP_DECLARE_CONST_FUN_OBJ_1(fsuser_umount_obj); -MP_DECLARE_CONST_FUN_OBJ_KW(fsuser_mkfs_obj); diff --git a/extmod/vfs.c b/extmod/vfs.c index 97c9077a255bf4dc3941e8ea779e770ceedf32e7..1eb26acf1658df5f669e1dea7f8ca3ffca57f7f7 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -31,10 +31,13 @@ #include "py/objstr.h" #include "py/mperrno.h" #include "extmod/vfs.h" -#include "extmod/vfs_fat.h" #if MICROPY_VFS +#if MICROPY_VFS_FAT +#include "extmod/vfs_fat.h" +#endif + // path is the path to lookup and *path_out holds the path within the VFS // object (starts with / if an absolute path). // Returns MP_VFS_ROOT for root dir (and then path_out is undefined) and diff --git a/extmod/vfs.h b/extmod/vfs.h index 92e53b305169cda1c542d81261d87a45c63a28cf..4a1c225a03851bce8c26677dd98319cd0977d568 100644 --- a/extmod/vfs.h +++ b/extmod/vfs.h @@ -35,6 +35,13 @@ #define MP_VFS_NONE ((mp_vfs_mount_t*)1) #define MP_VFS_ROOT ((mp_vfs_mount_t*)0) +// constants for block protocol ioctl +#define BP_IOCTL_INIT (1) +#define BP_IOCTL_DEINIT (2) +#define BP_IOCTL_SYNC (3) +#define BP_IOCTL_SEC_COUNT (4) +#define BP_IOCTL_SEC_SIZE (5) + typedef struct _mp_vfs_mount_t { const char *str; // mount point with leading / size_t len; diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index ecbbdb59ab16b2382fbc90a24bbeb30ce2b4ead7..b32bf7ad9d1cac5531359371df13b2c3c4575cae 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -38,7 +38,6 @@ #include "py/mperrno.h" #include "lib/oofatfs/ff.h" #include "extmod/vfs_fat.h" -#include "extmod/fsusermount.h" #include "timeutils.h" #if _MAX_SS == _MIN_SS diff --git a/extmod/vfs_fat.h b/extmod/vfs_fat.h index bc5be0c672b647b3e739cf743f56b6c2e24a19b0..fefae776c9475e534579ab33219416fa7d776514 100644 --- a/extmod/vfs_fat.h +++ b/extmod/vfs_fat.h @@ -25,8 +25,32 @@ */ #include "py/lexer.h" +#include "py/obj.h" +#include "lib/oofatfs/ff.h" +#include "extmod/vfs.h" -struct _fs_user_mount_t; +// these are the values for fs_user_mount_t.flags +#define FSUSER_NATIVE (0x0001) // readblocks[2]/writeblocks[2] contain native func +#define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount +#define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl + +typedef struct _fs_user_mount_t { + mp_obj_base_t base; + const char *str; + uint16_t len; // length of str + uint16_t flags; + mp_obj_t readblocks[4]; + mp_obj_t writeblocks[4]; + // new protocol uses just ioctl, old uses sync (optional) and count + union { + mp_obj_t ioctl[4]; + struct { + mp_obj_t sync[2]; + mp_obj_t count[2]; + } old; + } u; + FATFS fatfs; +} fs_user_mount_t; extern const byte fresult_to_errno_table[20]; extern const mp_obj_type_t mp_fat_vfs_type; diff --git a/extmod/vfs_fat_diskio.c b/extmod/vfs_fat_diskio.c index e12c4597e403ddec35333d586ec3de75a4621cf6..7efcc22f20e3a8c79febf43fb3790cce87b8a3f6 100644 --- a/extmod/vfs_fat_diskio.c +++ b/extmod/vfs_fat_diskio.c @@ -38,7 +38,7 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" #include "lib/oofatfs/diskio.h" -#include "extmod/fsusermount.h" +#include "extmod/vfs_fat.h" #if _MAX_SS == _MIN_SS #define SECSIZE(fs) (_MIN_SS) diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index bb5903575d9c946fbf124515bcd14a047e2790c7..0f2a7a1aa49ad870721b60c6e85eabba8214a699 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -35,7 +35,6 @@ #include "py/stream.h" #include "py/mperrno.h" #include "lib/oofatfs/ff.h" -#include "extmod/fsusermount.h" #include "extmod/vfs_fat.h" #if MICROPY_VFS_FAT diff --git a/extmod/vfs_fat_misc.c b/extmod/vfs_fat_misc.c index ba513ef923dd8435400860e3d6eb69a266b74f32..97d2675cdc26673f88df744f7c2164f732d02644 100644 --- a/extmod/vfs_fat_misc.c +++ b/extmod/vfs_fat_misc.c @@ -32,7 +32,6 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" #include "extmod/vfs_fat.h" -#include "extmod/fsusermount.h" #include "py/lexer.h" // TODO: actually, the core function should be ilistdir() diff --git a/stmhal/main.c b/stmhal/main.c index 9eab50061f6ea61011e0a7deb5ab4622fc8e5ef6..3a0bd7a6bbf32d33ff79efd917fc0cc040456044 100644 --- a/stmhal/main.c +++ b/stmhal/main.c @@ -39,7 +39,7 @@ #include "lib/utils/pyexec.h" #include "lib/oofatfs/ff.h" #include "extmod/vfs.h" -#include "extmod/fsusermount.h" +#include "extmod/vfs_fat.h" #include "systick.h" #include "pendsv.h" diff --git a/stmhal/modmachine.c b/stmhal/modmachine.c index aec8e29c5185de6f9ddce743fa846853f604d22f..b10bca8197d0e9949777bff091087f5434a7fe32 100644 --- a/stmhal/modmachine.c +++ b/stmhal/modmachine.c @@ -37,7 +37,7 @@ #include "lib/utils/pyexec.h" #include "lib/oofatfs/ff.h" #include "extmod/vfs.h" -#include "extmod/fsusermount.h" +#include "extmod/vfs_fat.h" #include "gccollect.h" #include "irq.h" #include "rng.h" diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c index 52ede492bbea1e747ea1ce9fa6fefeca7b4036c2..b1d67f62ab1217748f6011e58c3b0b6b3c028a1a 100644 --- a/stmhal/sdcard.c +++ b/stmhal/sdcard.c @@ -30,7 +30,6 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" #include "extmod/vfs_fat.h" -#include "extmod/fsusermount.h" #include "mphalport.h" #include "sdcard.h" diff --git a/stmhal/storage.c b/stmhal/storage.c index 6130d6fb8ec4c8e8840b73d844ff2eb6df3d3d2d..c1daad4c25d1fa3eda2146715c5fa68778650247 100644 --- a/stmhal/storage.c +++ b/stmhal/storage.c @@ -31,7 +31,6 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" #include "extmod/vfs_fat.h" -#include "extmod/fsusermount.h" #include "systick.h" #include "led.h"