extmod/fsusermount: Move BP_IOCTL_xxx constants to fsusermount.h.

This commit is contained in:
Damien George 2016-02-10 23:36:19 +00:00
parent b33a770596
commit e372e83b30
4 changed files with 17 additions and 17 deletions

View File

@ -29,6 +29,13 @@
#define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount #define FSUSER_FREE_OBJ (0x0002) // fs_user_mount_t obj should be freed on umount
#define FSUSER_HAVE_IOCTL (0x0004) // new protocol with ioctl #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 { typedef struct _fs_user_mount_t {
const char *str; const char *str;
uint16_t len; // length of str uint16_t len; // length of str

View File

@ -37,13 +37,6 @@
#include "lib/fatfs/diskio.h" /* FatFs lower layer API */ #include "lib/fatfs/diskio.h" /* FatFs lower layer API */
#include "extmod/fsusermount.h" #include "extmod/fsusermount.h"
// constants for block protocol ioctl
#define BP_IOCTL_INIT (1)
//#define BP_IOCTL_DEINIT (2) // unused
#define BP_IOCTL_SYNC (3)
#define BP_IOCTL_SEC_COUNT (4)
#define BP_IOCTL_SEC_SIZE (5)
STATIC fs_user_mount_t *disk_get_device(uint id) { STATIC fs_user_mount_t *disk_get_device(uint id) {
if (id < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount))) { if (id < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount))) {
return MP_STATE_PORT(fs_user_mount)[id]; return MP_STATE_PORT(fs_user_mount)[id];

View File

@ -377,24 +377,24 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_sdcard_writeblocks_obj, pyb_sdcard_writeblo
STATIC mp_obj_t pyb_sdcard_ioctl(mp_obj_t self, mp_obj_t cmd_in, mp_obj_t arg_in) { STATIC mp_obj_t pyb_sdcard_ioctl(mp_obj_t self, mp_obj_t cmd_in, mp_obj_t arg_in) {
mp_int_t cmd = mp_obj_get_int(cmd_in); mp_int_t cmd = mp_obj_get_int(cmd_in);
switch (cmd) { switch (cmd) {
case 1: // INIT case BP_IOCTL_INIT:
if (!sdcard_power_on()) { if (!sdcard_power_on()) {
return MP_OBJ_NEW_SMALL_INT(-1); // error return MP_OBJ_NEW_SMALL_INT(-1); // error
} }
return MP_OBJ_NEW_SMALL_INT(0); // success return MP_OBJ_NEW_SMALL_INT(0); // success
case 2: // DEINIT case BP_IOCTL_DEINIT:
sdcard_power_off(); sdcard_power_off();
return MP_OBJ_NEW_SMALL_INT(0); // success return MP_OBJ_NEW_SMALL_INT(0); // success
case 3: // SYNC case BP_IOCTL_SYNC:
// nothing to do // nothing to do
return MP_OBJ_NEW_SMALL_INT(0); // success return MP_OBJ_NEW_SMALL_INT(0); // success
case 4: // SEC_COUNT case BP_IOCTL_SEC_COUNT:
return MP_OBJ_NEW_SMALL_INT(0); // TODO return MP_OBJ_NEW_SMALL_INT(0); // TODO
case 5: // SEC_SIZE case BP_IOCTL_SEC_SIZE:
return MP_OBJ_NEW_SMALL_INT(SDCARD_BLOCK_SIZE); return MP_OBJ_NEW_SMALL_INT(SDCARD_BLOCK_SIZE);
default: // unknown command default: // unknown command

View File

@ -363,11 +363,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(pyb_flash_writeblocks_obj, pyb_flash_writeblock
STATIC mp_obj_t pyb_flash_ioctl(mp_obj_t self, mp_obj_t cmd_in, mp_obj_t arg_in) { STATIC mp_obj_t pyb_flash_ioctl(mp_obj_t self, mp_obj_t cmd_in, mp_obj_t arg_in) {
mp_int_t cmd = mp_obj_get_int(cmd_in); mp_int_t cmd = mp_obj_get_int(cmd_in);
switch (cmd) { switch (cmd) {
case 1: storage_init(); return MP_OBJ_NEW_SMALL_INT(0); // INIT case BP_IOCTL_INIT: storage_init(); return MP_OBJ_NEW_SMALL_INT(0);
case 2: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0); // DEINIT; TODO properly case BP_IOCTL_DEINIT: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0); // TODO properly
case 3: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0); // SYNC case BP_IOCTL_SYNC: storage_flush(); return MP_OBJ_NEW_SMALL_INT(0);
case 4: return MP_OBJ_NEW_SMALL_INT(storage_get_block_count()); // SEC_COUNT case BP_IOCTL_SEC_COUNT: return MP_OBJ_NEW_SMALL_INT(storage_get_block_count());
case 5: return MP_OBJ_NEW_SMALL_INT(storage_get_block_size()); // SEC_SIZE case BP_IOCTL_SEC_SIZE: return MP_OBJ_NEW_SMALL_INT(storage_get_block_size());
default: return mp_const_none; default: return mp_const_none;
} }
} }