diff options
author | Damien George <damien.p.george@gmail.com> | 2015-07-27 23:52:56 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-07-27 23:52:56 +0100 |
commit | f5d04750dbd13bfc10498e20428b1a285ec417af (patch) | |
tree | 819b5723bff4db7cb9f5f147f403430b7c40fa55 /stmhal/diskio.c | |
parent | 92e9a5e0a7f2634c670ffe8056430b94d210a4c0 (diff) |
stmhal: Put fs_user_mount pointer in root ptr section of global state.
Should fix issue #1393.
Diffstat (limited to 'stmhal/diskio.c')
-rw-r--r-- | stmhal/diskio.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/stmhal/diskio.c b/stmhal/diskio.c index 3b0c86d5b..abad2f41a 100644 --- a/stmhal/diskio.c +++ b/stmhal/diskio.c @@ -78,10 +78,10 @@ DSTATUS disk_initialize ( #endif case PD_USER: - if (fs_user_mount == NULL) { + if (MP_STATE_PORT(fs_user_mount) == NULL) { return STA_NODISK; } - if (fs_user_mount->writeblocks[0] == MP_OBJ_NULL) { + if (MP_STATE_PORT(fs_user_mount)->writeblocks[0] == MP_OBJ_NULL) { return STA_PROTECT; } return 0; @@ -110,10 +110,10 @@ DSTATUS disk_status ( #endif case PD_USER: - if (fs_user_mount == NULL) { + if (MP_STATE_PORT(fs_user_mount) == NULL) { return STA_NODISK; } - if (fs_user_mount->writeblocks[0] == MP_OBJ_NULL) { + if (MP_STATE_PORT(fs_user_mount)->writeblocks[0] == MP_OBJ_NULL) { return STA_PROTECT; } return 0; @@ -151,13 +151,13 @@ DRESULT disk_read ( #endif case PD_USER: - if (fs_user_mount == NULL) { + if (MP_STATE_PORT(fs_user_mount) == NULL) { // nothing mounted return RES_ERROR; } - fs_user_mount->readblocks[2] = MP_OBJ_NEW_SMALL_INT(sector); - fs_user_mount->readblocks[3] = mp_obj_new_bytearray_by_ref(count * 512, buff); - mp_call_method_n_kw(2, 0, fs_user_mount->readblocks); + MP_STATE_PORT(fs_user_mount)->readblocks[2] = MP_OBJ_NEW_SMALL_INT(sector); + MP_STATE_PORT(fs_user_mount)->readblocks[3] = mp_obj_new_bytearray_by_ref(count * 512, buff); + mp_call_method_n_kw(2, 0, MP_STATE_PORT(fs_user_mount)->readblocks); return RES_OK; } @@ -194,17 +194,17 @@ DRESULT disk_write ( #endif case PD_USER: - if (fs_user_mount == NULL) { + if (MP_STATE_PORT(fs_user_mount) == NULL) { // nothing mounted return RES_ERROR; } - if (fs_user_mount->writeblocks[0] == MP_OBJ_NULL) { + if (MP_STATE_PORT(fs_user_mount)->writeblocks[0] == MP_OBJ_NULL) { // read-only block device return RES_ERROR; } - fs_user_mount->writeblocks[2] = MP_OBJ_NEW_SMALL_INT(sector); - fs_user_mount->writeblocks[3] = mp_obj_new_bytearray_by_ref(count * 512, (void*)buff); - mp_call_method_n_kw(2, 0, fs_user_mount->writeblocks); + MP_STATE_PORT(fs_user_mount)->writeblocks[2] = MP_OBJ_NEW_SMALL_INT(sector); + MP_STATE_PORT(fs_user_mount)->writeblocks[3] = mp_obj_new_bytearray_by_ref(count * 512, (void*)buff); + mp_call_method_n_kw(2, 0, MP_STATE_PORT(fs_user_mount)->writeblocks); return RES_OK; } @@ -251,14 +251,14 @@ DRESULT disk_ioctl ( #endif case PD_USER: - if (fs_user_mount == NULL) { + if (MP_STATE_PORT(fs_user_mount) == NULL) { // nothing mounted return RES_ERROR; } switch (cmd) { case CTRL_SYNC: - if (fs_user_mount->sync[0] != MP_OBJ_NULL) { - mp_call_method_n_kw(0, 0, fs_user_mount->sync); + if (MP_STATE_PORT(fs_user_mount)->sync[0] != MP_OBJ_NULL) { + mp_call_method_n_kw(0, 0, MP_STATE_PORT(fs_user_mount)->sync); } return RES_OK; @@ -267,7 +267,7 @@ DRESULT disk_ioctl ( return RES_OK; case GET_SECTOR_COUNT: { - mp_obj_t ret = mp_call_method_n_kw(0, 0, fs_user_mount->count); + mp_obj_t ret = mp_call_method_n_kw(0, 0, MP_STATE_PORT(fs_user_mount)->count); *((DWORD*)buff) = mp_obj_get_int(ret); return RES_OK; } |