You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2017/01/19 17:36:23 UTC
[12/19] incubator-mynewt-core git commit: Fix compilation
Fix compilation
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6e9213fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6e9213fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6e9213fe
Branch: refs/heads/develop
Commit: 6e9213fe1136d369cbbbf141f46895e38441910a
Parents: 1a02962
Author: Fabio Utzig <ut...@utzig.org>
Authored: Mon Dec 19 07:46:07 2016 -0200
Committer: Fabio Utzig <ut...@utzig.org>
Committed: Thu Jan 12 10:51:46 2017 -0200
----------------------------------------------------------------------
fs/disk/include/disk/disk.h | 52 ++++
fs/disk/pkg.yml | 27 +++
fs/disk/src/disk.c | 62 +++++
fs/fatfs/src/mynewt_glue.c | 2 +-
fs/fatfs/src/mynewt_glue_2.c | 410 --------------------------------
fs/fs/include/fs/fs_if.h | 4 +-
fs/fs/src/fs_file.c | 118 +++++++--
fs/fs/src/fs_mount.c | 13 +-
fs/nffs/src/nffs.c | 2 +-
hw/drivers/mmc/include/mmc/mmc.h | 12 +-
hw/drivers/mmc/src/mmc.c | 16 +-
hw/hal/include/hal/hal_flash.h | 2 +-
hw/hal/src/hal_flash.c | 10 +-
sys/diskio/include/diskio/diskio.h | 51 ----
sys/diskio/pkg.yml | 27 ---
sys/diskio/src/diskio.c | 57 -----
16 files changed, 281 insertions(+), 584 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/fs/disk/include/disk/disk.h
----------------------------------------------------------------------
diff --git a/fs/disk/include/disk/disk.h b/fs/disk/include/disk/disk.h
new file mode 100644
index 0000000..e87fc7b
--- /dev/null
+++ b/fs/disk/include/disk/disk.h
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __DISK_H__
+#define __DISK_H__
+
+#include <stddef.h>
+#include <inttypes.h>
+#include <os/queue.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define DISK_EOK 0 /* Success */
+#define DISK_EHW 1 /* Error accessing storage medium */
+#define DISK_ENOMEM 2 /* Insufficient memory */
+#define DISK_ENOENT 3 /* No such file or directory */
+#define DISK_EOS 4 /* OS error */
+#define DISK_EUNINIT 5 /* File system not initialized */
+
+struct disk_ops {
+ int (*read)(uint8_t, uint32_t, void *, uint32_t);
+ int (*write)(uint8_t, uint32_t, const void *, uint32_t);
+ int (*ioctl)(uint8_t, uint32_t, void *);
+
+ SLIST_ENTRY(disk_ops) sc_next;
+};
+
+int disk_register(const char *disk_name, const char *fs_name, struct disk_ops *dops);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/fs/disk/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/disk/pkg.yml b/fs/disk/pkg.yml
new file mode 100644
index 0000000..61813a7
--- /dev/null
+++ b/fs/disk/pkg.yml
@@ -0,0 +1,27 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+pkg.name: fs/disk
+pkg.description: Disk management layer to glue filesystems to disk devices.
+pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
+pkg.homepage: "http://mynewt.apache.org/"
+pkg.keywords:
+
+pkg.deps:
+ - kernel/os
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/fs/disk/src/disk.c
----------------------------------------------------------------------
diff --git a/fs/disk/src/disk.c b/fs/disk/src/disk.c
new file mode 100644
index 0000000..803e1a5
--- /dev/null
+++ b/fs/disk/src/disk.c
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <syscfg/syscfg.h>
+#include <fs/fs.h>
+#include <disk/disk.h>
+#include <stdlib.h>
+#include <string.h>
+
+struct disk_info {
+ const char *disk_name;
+ const char *fs_name;
+ struct disk_ops *dops;
+
+ SLIST_ENTRY(disk_info) sc_next;
+};
+
+static SLIST_HEAD(, disk_info) disks = SLIST_HEAD_INITIALIZER();
+
+/**
+ *
+ */
+int disk_register(const char *disk_name, const char *fs_name, struct disk_ops *dops)
+{
+ struct disk_info *info = NULL;
+ struct disk_info *sc;
+
+ SLIST_FOREACH(sc, &disks, sc_next) {
+ if (strcmp(sc->disk_name, disk_name) == 0) {
+ return DISK_ENOENT;
+ }
+ }
+
+ info = malloc(sizeof(struct disk_info));
+ if (!info) {
+ return DISK_ENOMEM;
+ }
+
+ info->disk_name = disk_name;
+ info->fs_name = fs_name;
+ info->dops = dops;
+
+ SLIST_INSERT_HEAD(&disks, info, sc_next);
+
+ return 0;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/fs/fatfs/src/mynewt_glue.c
----------------------------------------------------------------------
diff --git a/fs/fatfs/src/mynewt_glue.c b/fs/fatfs/src/mynewt_glue.c
index f2382f8..f64bbb2 100644
--- a/fs/fatfs/src/mynewt_glue.c
+++ b/fs/fatfs/src/mynewt_glue.c
@@ -38,7 +38,7 @@ static int fatfs_dirent_is_dir(const struct fs_dirent *fs_dirent);
*/
static FILINFO filinfo;
-static const struct fs_ops fatfs_ops = {
+static struct fs_ops fatfs_ops = {
.f_open = fatfs_open,
.f_close = fatfs_close,
.f_read = fatfs_read,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/fs/fatfs/src/mynewt_glue_2.c
----------------------------------------------------------------------
diff --git a/fs/fatfs/src/mynewt_glue_2.c b/fs/fatfs/src/mynewt_glue_2.c
deleted file mode 100644
index 8be7265..0000000
--- a/fs/fatfs/src/mynewt_glue_2.c
+++ /dev/null
@@ -1,410 +0,0 @@
-#include <assert.h>
-#include <sysinit/sysinit.h>
-#include <hal/hal_flash.h>
-#include <flash_map/flash_map.h>
-#include <mmc/mmc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <fatfs/ff.h>
-#include <fatfs/diskio.h>
-
-#include <fs/fs.h>
-#include <fs/fs_if.h>
-
-static int fatfs_open(const char *path, uint8_t access_flags,
- struct fs_file **out_file);
-static int fatfs_close(struct fs_file *fs_file);
-static int fatfs_read(struct fs_file *fs_file, uint32_t len, void *out_data,
- uint32_t *out_len);
-static int fatfs_write(struct fs_file *fs_file, const void *data, int len);
-static int fatfs_seek(struct fs_file *fs_file, uint32_t offset);
-static uint32_t fatfs_getpos(const struct fs_file *fs_file);
-static int fatfs_file_len(const struct fs_file *fs_file, uint32_t *out_len);
-static int fatfs_unlink(const char *path);
-static int fatfs_rename(const char *from, const char *to);
-static int fatfs_mkdir(const char *path);
-static int fatfs_opendir(const char *path, struct fs_dir **out_fs_dir);
-static int fatfs_readdir(struct fs_dir *dir, struct fs_dirent **out_dirent);
-static int fatfs_closedir(struct fs_dir *dir);
-static int fatfs_dirent_name(const struct fs_dirent *fs_dirent, size_t max_len,
- char *out_name, uint8_t *out_name_len);
-static int fatfs_dirent_is_dir(const struct fs_dirent *fs_dirent);
-
-/* NOTE: to ease memory management of dirent structs, this single static
- * variable holds the latest entry found by readdir. This limits FAT to
- * working on a single thread, single opendir -> closedir cycle.
- */
-static FILINFO filinfo;
-
-static const struct fs_ops fatfs_ops = {
- .f_open = fatfs_open,
- .f_close = fatfs_close,
- .f_read = fatfs_read,
- .f_write = fatfs_write,
-
- .f_seek = fatfs_seek,
- .f_getpos = fatfs_getpos,
- .f_filelen = fatfs_file_len,
-
- .f_unlink = fatfs_unlink,
- .f_rename = fatfs_rename,
- .f_mkdir = fatfs_mkdir,
-
- .f_opendir = fatfs_opendir,
- .f_readdir = fatfs_readdir,
- .f_closedir = fatfs_closedir,
-
- .f_dirent_name = fatfs_dirent_name,
- .f_dirent_is_dir = fatfs_dirent_is_dir,
-
- .f_name = "fatfs"
-};
-
-int fatfs_to_vfs_error(FRESULT res)
-{
- int rc = FS_EOS;
-
- switch (res) {
- case FR_OK:
- rc = FS_EOK;
- break;
- case FR_DISK_ERR: /* (1) A hard error occurred in the low level disk I/O layer */
- rc = FS_EHW;
- break;
- case FR_INT_ERR: /* (2) Assertion failed */
- rc = FS_EOS;
- break;
- case FR_NOT_READY: /* (3) The physical drive cannot work */
- rc = FS_ECORRUPT;
- break;
- case FR_NO_FILE: /* (4) Could not find the file */
- /* passthrough */
- case FR_NO_PATH: /* (5) Could not find the path */
- rc = FS_ENOENT;
- break;
- case FR_INVALID_NAME: /* (6) The path name format is invalid */
- rc = FS_EINVAL;
- break;
- case FR_DENIED: /* (7) Access denied due to prohibited access or directory full */
- rc = FS_EACCESS;
- break;
- case FR_EXIST: /* (8) Access denied due to prohibited access */
- rc = FS_EEXIST;
- break;
- case FR_INVALID_OBJECT: /* (9) The file/directory object is invalid */
- rc = FS_EINVAL;
- break;
- case FR_WRITE_PROTECTED: /* (10) The physical drive is write protected */
- /* TODO: assign correct error */
- break;
- case FR_INVALID_DRIVE: /* (11) The logical drive number is invalid */
- rc = FS_EHW;
- break;
- case FR_NOT_ENABLED: /* (12) The volume has no work area */
- rc = FS_EUNEXP;
- break;
- case FR_NO_FILESYSTEM: /* (13) There is no valid FAT volume */
- rc = FS_EUNINIT;
- break;
- case FR_MKFS_ABORTED: /* (14) The f_mkfs() aborted due to any problem */
- /* TODO: assign correct error */
- break;
- case FR_TIMEOUT: /* (15) Could not get a grant to access the volume within defined period */
- /* TODO: assign correct error */
- break;
- case FR_LOCKED: /* (16) The operation is rejected according to the file sharing policy */
- /* TODO: assign correct error */
- break;
- case FR_NOT_ENOUGH_CORE: /* (17) LFN working buffer could not be allocated */
- rc = FS_ENOMEM;
- break;
- case FR_TOO_MANY_OPEN_FILES: /* (18) Number of open files > _FS_LOCK */
- /* TODO: assign correct error */
- break;
- case FR_INVALID_PARAMETER: /* (19) Given parameter is invalid */
- rc = FS_EINVAL;
- break;
- }
-
- return rc;
-}
-
-static int
-fatfs_open(const char *path, uint8_t access_flags, struct fs_file **out_fs_file)
-{
- FRESULT res;
- FIL *out_file;
- BYTE mode;
-
- out_file = malloc(sizeof(FIL));
- if (!out_file) {
- return FS_ENOMEM;
- }
-
- mode = FA_OPEN_EXISTING;
- if (access_flags & FS_ACCESS_READ) {
- mode |= FA_READ;
- }
- if (access_flags & FS_ACCESS_WRITE) {
- mode |= FA_WRITE;
- }
- if (access_flags & FS_ACCESS_APPEND) {
- mode |= FA_OPEN_APPEND;
- }
- if (access_flags & FS_ACCESS_TRUNCATE) {
- mode &= ~FA_OPEN_EXISTING;
- mode |= FA_CREATE_ALWAYS;
- }
-
- res = f_open(out_file, path, mode);
- if (res != FR_OK) {
- free(out_file);
- return fatfs_to_vfs_error(res);
- }
- *out_fs_file = (struct fs_file *)out_file;
- return FS_EOK;
-}
-
-static int
-fatfs_close(struct fs_file *fs_file)
-{
- FRESULT res;
- FIL *file = (FIL *)fs_file;
-
- if (file == NULL) {
- return FS_EOK;
- }
-
- res = f_close(file);
- free(file);
- return fatfs_to_vfs_error(res);
-}
-
-static int
-fatfs_seek(struct fs_file *fs_file, uint32_t offset)
-{
- FRESULT res;
- FIL *file = (FIL *)fs_file;
-
- res = f_lseek(file, offset);
- return fatfs_to_vfs_error(res);
-}
-
-static uint32_t
-fatfs_getpos(const struct fs_file *fs_file)
-{
- uint32_t offset;
- FIL *file = (FIL *)fs_file;
-
- offset = (uint32_t) f_tell(file);
- return offset;
-}
-
-static int
-fatfs_file_len(const struct fs_file *fs_file, uint32_t *out_len)
-{
- uint32_t offset;
- FIL *file = (FIL *)fs_file;
-
- offset = (uint32_t) f_size(file);
- return offset;
-}
-
-static int
-fatfs_read(struct fs_file *fs_file, uint32_t len, void *out_data,
- uint32_t *out_len)
-{
- FRESULT res;
- FIL *file = (FIL *)fs_file;
-
- res = f_read(file, out_data, len, (UINT *)out_len);
- return fatfs_to_vfs_error(res);
-}
-
-static int
-fatfs_write(struct fs_file *fs_file, const void *data, int len)
-{
- FRESULT res;
- UINT out_len;
- FIL *file = (FIL *)fs_file;
-
- res = f_write(file, data, len, &out_len);
- if (len != out_len) {
- return FS_EFULL;
- }
- return fatfs_to_vfs_error(res);
-}
-
-static int
-fatfs_unlink(const char *path)
-{
- FRESULT res;
-
- res = f_unlink(path);
- return fatfs_to_vfs_error(res);
-}
-
-static int
-fatfs_rename(const char *from, const char *to)
-{
- FRESULT res;
-
- res = f_rename(from, to);
- return fatfs_to_vfs_error(res);
-}
-
-static int
-fatfs_mkdir(const char *path)
-{
- FRESULT res;
-
- res = f_mkdir(path);
- return fatfs_to_vfs_error(res);
-}
-
-static int
-fatfs_opendir(const char *path, struct fs_dir **out_fs_dir)
-{
- FRESULT res;
- FATFS_DIR *out_dir;
-
- out_dir = malloc(sizeof(FATFS_DIR));
- if (!out_dir) {
- return FS_ENOMEM;
- }
-
- res = f_opendir(out_dir, path);
- if (res != FR_OK) {
- return fatfs_to_vfs_error(res);
- }
- *out_fs_dir = (struct fs_dir *)out_dir;
- return FS_EOK;
-}
-
-static int
-fatfs_readdir(struct fs_dir *fs_dir, struct fs_dirent **out_fs_dirent)
-{
- FRESULT res;
- FATFS_DIR *dir = (FATFS_DIR *)fs_dir;
-
- res = f_readdir(dir, &filinfo);
- if (res != FR_OK) {
- return fatfs_to_vfs_error(res);
- }
-
- *out_fs_dirent = (struct fs_dirent *)&filinfo;
- if (!filinfo.fname[0]) {
- return FS_ENOENT;
- }
- return FS_EOK;
-}
-
-static int
-fatfs_closedir(struct fs_dir *fs_dir)
-{
- FRESULT res;
- FATFS_DIR *dir = (FATFS_DIR *)fs_dir;
-
- res = f_closedir(dir);
- free(dir);
- return fatfs_to_vfs_error(res);
-}
-
-static int
-fatfs_dirent_name(const struct fs_dirent *fs_dirent, size_t max_len,
- char *out_name, uint8_t *out_name_len)
-{
- const FILINFO *dirent = (const FILINFO *)fs_dirent;
- size_t out_len;
-
- assert(dirent != NULL);
- out_len = max_len < sizeof(dirent->fname) ? max_len : sizeof(dirent->fname);
- memcpy(out_name, dirent->fname, out_len);
- *out_name_len = out_len;
- return FS_EOK;
-}
-
-static int
-fatfs_dirent_is_dir(const struct fs_dirent *fs_dirent)
-{
- const FILINFO *dirent = (const FILINFO *)fs_dirent;
-
- assert(dirent != NULL);
- return dirent->fattrib & AM_DIR;
-}
-
-DSTATUS
-disk_initialize(BYTE pdrv)
-{
- /* Don't need to do anything while using hal_flash */
- return RES_OK;
-}
-
-DSTATUS
-disk_status(BYTE pdrv)
-{
- /* Always OK on native emulated flash */
- return RES_OK;
-}
-
-DRESULT
-disk_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count)
-{
- int rc;
- uint32_t address;
- uint32_t num_bytes;
-
- /* NOTE: safe to assume sector size as 512 for now, see ffconf.h */
- address = (uint32_t) sector * 512;
- num_bytes = (uint32_t) count * 512;
- //rc = hal_flash_read(pdrv, address, (void *) buff, num_bytes);
- rc = mmc_read(pdrv, address, (void *) buff, num_bytes);
- if (rc < 0) {
- return STA_NOINIT;
- }
-
- return RES_OK;
-}
-
-DRESULT
-disk_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count)
-{
- int rc;
- uint32_t address;
- uint32_t num_bytes;
-
- /* NOTE: safe to assume sector size as 512 for now, see ffconf.h */
- address = (uint32_t) sector * 512;
- num_bytes = (uint32_t) count * 512;
- //rc = hal_flash_write(pdrv, address, (const void *) buff, num_bytes);
- rc = mmc_write(pdrv, address, (const void *) buff, num_bytes);
- if (rc < 0) {
- return STA_NOINIT;
- }
-
- return RES_OK;
-}
-
-DRESULT
-disk_ioctl(BYTE pdrv, BYTE cmd, void* buff)
-{
- return RES_OK;
-}
-
-/* FIXME: _FS_NORTC=1 because there is not hal_rtc interface */
-DWORD
-get_fattime(void)
-{
- return 0;
-}
-
-void
-fatfs_pkg_init(void)
-{
- /* Ensure this function only gets called by sysinit. */
- SYSINIT_ASSERT_ACTIVE();
-
- fs_register(&fatfs_ops);
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/fs/fs/include/fs/fs_if.h
----------------------------------------------------------------------
diff --git a/fs/fs/include/fs/fs_if.h b/fs/fs/include/fs/fs_if.h
index 842f070..015d832 100644
--- a/fs/fs/include/fs/fs_if.h
+++ b/fs/fs/include/fs/fs_if.h
@@ -24,6 +24,8 @@
extern "C" {
#endif
+#include <os/queue.h>
+
/*
* Common interface filesystem(s) provide.
*/
@@ -63,7 +65,7 @@ struct fs_ops {
*
* @return 0 on success, non-zero on failure
*/
-int fs_register(const struct fs_ops *fops);
+int fs_register(struct fs_ops *fops);
/**
* Retrieve a filesystem's operations table
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/fs/fs/src/fs_file.c
----------------------------------------------------------------------
diff --git a/fs/fs/src/fs_file.c b/fs/fs/src/fs_file.c
index fdcecda..a18d0ba 100644
--- a/fs/fs/src/fs_file.c
+++ b/fs/fs/src/fs_file.c
@@ -22,27 +22,113 @@
#include "fs_priv.h"
static int
-not_initialized(const void *v, ...)
+fake_open(const char *filename, uint8_t access_flags,
+ struct fs_file **out_file)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_close(struct fs_file *file)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_read(struct fs_file *file, uint32_t len, void *out_data,
+ uint32_t *out_len)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_write(struct fs_file *file, const void *data, int len)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_seek(struct fs_file *file, uint32_t offset)
+{
+ return FS_EUNINIT;
+}
+
+static uint32_t
+fake_getpos(const struct fs_file *file)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_filelen(const struct fs_file *file, uint32_t *out_len)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_unlink(const char *filename)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_rename(const char *from, const char *to)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_mkdir(const char *path)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_opendir(const char *path, struct fs_dir **out_dir)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_readdir(struct fs_dir *dir, struct fs_dirent **out_dirent)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_closedir(struct fs_dir *dir)
+{
+ return FS_EUNINIT;
+}
+
+static int fake_dirent_name(const struct fs_dirent *dirent, size_t max_len,
+ char *out_name, uint8_t *out_name_len)
+{
+ return FS_EUNINIT;
+}
+
+static int
+fake_dirent_is_dir(const struct fs_dirent *dirent)
{
return FS_EUNINIT;
}
static struct fs_ops not_initialized_ops = {
- .f_open = not_initialized,
- .f_close = not_initialized,
- .f_read = not_initialized,
- .f_write = not_initialized,
- .f_seek = not_initialized,
- .f_getpos = not_initialized,
- .f_filelen = not_initialized,
- .f_unlink = not_initialized,
- .f_rename = not_initialized,
- .f_mkdir = not_initialized,
- .f_opendir = not_initialized,
- .f_readdir = not_initialized,
- .f_closedir = not_initialized,
- .f_dirent_name = not_initialized,
- .f_dirent_is_dir = not_initialized,
+ .f_open = &fake_open,
+ .f_close = &fake_close,
+ .f_read = &fake_read,
+ .f_write = &fake_write,
+ .f_seek = &fake_seek,
+ .f_getpos = &fake_getpos,
+ .f_filelen = &fake_filelen,
+ .f_unlink = &fake_unlink,
+ .f_rename = &fake_rename,
+ .f_mkdir = &fake_mkdir,
+ .f_opendir = &fake_opendir,
+ .f_readdir = &fake_readdir,
+ .f_closedir = &fake_closedir,
+ .f_dirent_name = &fake_dirent_name,
+ .f_dirent_is_dir = &fake_dirent_is_dir,
.f_name = "fakefs",
};
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/fs/fs/src/fs_mount.c
----------------------------------------------------------------------
diff --git a/fs/fs/src/fs_mount.c b/fs/fs/src/fs_mount.c
index 174fac8..5f020cf 100644
--- a/fs/fs/src/fs_mount.c
+++ b/fs/fs/src/fs_mount.c
@@ -21,13 +21,19 @@
#include "fs/fs.h"
#include "fs/fs_if.h"
#include "fs_priv.h"
+#include <string.h>
static SLIST_HEAD(, fs_ops) root_fops = SLIST_HEAD_INITIALIZER();
-static bool g_cli_initialized = false;
+
+#if MYNEWT_VAL(FS_CLI)
+static int g_cli_initialized = 0;
+#endif
int
-fs_register(const struct fs_ops *fops)
+fs_register(struct fs_ops *fops)
{
+ struct fs_ops *sc;
+
SLIST_FOREACH(sc, &root_fops, sc_next) {
if (strcmp(sc->f_name, fops->f_name) == 0) {
return FS_EEXIST;
@@ -39,7 +45,7 @@ fs_register(const struct fs_ops *fops)
#if MYNEWT_VAL(FS_CLI)
if (!g_cli_initialized) {
fs_cli_init();
- g_cli_initialized = true;
+ g_cli_initialized = 1;
}
#endif
@@ -50,6 +56,7 @@ struct fs_ops *
fs_ops_for(const char *fs_name)
{
struct fs_ops *fops = NULL;
+ struct fs_ops *sc;
SLIST_FOREACH(sc, &root_fops, sc_next) {
if (strcmp(sc->f_name, fs_name) == 0) {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/fs/nffs/src/nffs.c
----------------------------------------------------------------------
diff --git a/fs/nffs/src/nffs.c b/fs/nffs/src/nffs.c
index 8f25cb5..eacec07 100644
--- a/fs/nffs/src/nffs.c
+++ b/fs/nffs/src/nffs.c
@@ -81,7 +81,7 @@ static int nffs_dirent_name(const struct fs_dirent *fs_dirent, size_t max_len,
char *out_name, uint8_t *out_name_len);
static int nffs_dirent_is_dir(const struct fs_dirent *fs_dirent);
-static const struct fs_ops nffs_ops = {
+static struct fs_ops nffs_ops = {
.f_open = nffs_open,
.f_close = nffs_close,
.f_read = nffs_read,
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/hw/drivers/mmc/include/mmc/mmc.h
----------------------------------------------------------------------
diff --git a/hw/drivers/mmc/include/mmc/mmc.h b/hw/drivers/mmc/include/mmc/mmc.h
index a13b682..4b14e27 100644
--- a/hw/drivers/mmc/include/mmc/mmc.h
+++ b/hw/drivers/mmc/include/mmc/mmc.h
@@ -21,7 +21,7 @@
#define __MMC_H__
#include <os/os_dev.h>
-#include <diskio/diskio.h>
+#include <disk/disk.h>
#ifdef __cplusplus
extern "C" {
@@ -69,7 +69,7 @@ mmc_init(int spi_num, void *spi_cfg, int ss_pin);
* @return 0 on success, non-zero on failure
*/
int
-mmc_read(uint8_t mmc_id, uint32_t addr, void *buf, size_t len);
+mmc_read(uint8_t mmc_id, uint32_t addr, void *buf, uint32_t len);
/**
* Write data to the MMC
@@ -82,7 +82,13 @@ mmc_read(uint8_t mmc_id, uint32_t addr, void *buf, size_t len);
* @return 0 on success, non-zero on failure
*/
int
-mmc_write(uint8_t mmc_id, uint32_t addr, const void *buf, size_t len);
+mmc_write(uint8_t mmc_id, uint32_t addr, const void *buf, uint32_t len);
+
+/**
+ * TODO
+ */
+int
+mmc_ioctl(uint8_t mmc_id, uint32_t cmd, void *arg);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/hw/drivers/mmc/src/mmc.c
----------------------------------------------------------------------
diff --git a/hw/drivers/mmc/src/mmc.c b/hw/drivers/mmc/src/mmc.c
index 0b2aa98..cae8c29 100644
--- a/hw/drivers/mmc/src/mmc.c
+++ b/hw/drivers/mmc/src/mmc.c
@@ -19,9 +19,8 @@
#include <hal/hal_spi.h>
#include <hal/hal_gpio.h>
-
+#include <disk/disk.h>
#include <mmc/mmc.h>
-
#include <stdio.h>
#define MIN(n, m) (((n) < (m)) ? (n) : (m))
@@ -361,7 +360,7 @@ wait_busy(struct mmc_cfg *mmc)
* @return 0 on success, non-zero on failure
*/
int
-mmc_read(uint8_t mmc_id, uint32_t addr, void *buf, size_t len)
+mmc_read(uint8_t mmc_id, uint32_t addr, void *buf, uint32_t len)
{
uint8_t cmd;
uint8_t res;
@@ -449,7 +448,7 @@ out:
* @return 0 on success, non-zero on failure
*/
int
-mmc_write(uint8_t mmc_id, uint32_t addr, const void *buf, size_t len)
+mmc_write(uint8_t mmc_id, uint32_t addr, const void *buf, uint32_t len)
{
uint8_t cmd;
uint8_t res;
@@ -587,7 +586,8 @@ out:
/*
*
*/
-int mmc_ioctl(int cmd, void *arg)
+int
+mmc_ioctl(uint8_t mmc_id, uint32_t cmd, void *arg)
{
return 0;
}
@@ -596,7 +596,7 @@ int mmc_ioctl(int cmd, void *arg)
*
*/
struct disk_ops mmc_ops = {
- .read = mmc_read,
- .write = mmc_write,
- .ioctl = mmc_ioctl,
+ .read = &mmc_read,
+ .write = &mmc_write,
+ .ioctl = &mmc_ioctl,
};
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/hw/hal/include/hal/hal_flash.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_flash.h b/hw/hal/include/hal/hal_flash.h
index 1fdc91e..bd4f6f3 100644
--- a/hw/hal/include/hal/hal_flash.h
+++ b/hw/hal/include/hal/hal_flash.h
@@ -25,7 +25,7 @@ extern "C" {
#endif
#include <inttypes.h>
-#include <diskio/diskio.h>
+#include <disk/disk.h>
extern struct disk_ops hal_flash_ops;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/hw/hal/src/hal_flash.c
----------------------------------------------------------------------
diff --git a/hw/hal/src/hal_flash.c b/hw/hal/src/hal_flash.c
index a95b57b..ada6e23 100644
--- a/hw/hal/src/hal_flash.c
+++ b/hw/hal/src/hal_flash.c
@@ -24,7 +24,7 @@
#include "hal/hal_flash.h"
#include "hal/hal_flash_int.h"
-#include <diskio/diskio.h>
+#include <disk/disk.h>
int
hal_flash_init(void)
@@ -176,8 +176,8 @@ hal_flash_ioctl(uint8_t id, uint32_t cmd, void *args)
return 0;
}
-static struct disk_ops hal_flash_ops = {
- .read = hal_flash_read,
- .write = hal_flash_write,
- .ioctl = hal_flash_ioctl,
+struct disk_ops hal_flash_ops = {
+ .read = &hal_flash_read,
+ .write = &hal_flash_write,
+ .ioctl = &hal_flash_ioctl,
};
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/sys/diskio/include/diskio/diskio.h
----------------------------------------------------------------------
diff --git a/sys/diskio/include/diskio/diskio.h b/sys/diskio/include/diskio/diskio.h
deleted file mode 100644
index a0a68f6..0000000
--- a/sys/diskio/include/diskio/diskio.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef __DISKIO_H__
-#define __DISKIO_H__
-
-#include <stddef.h>
-#include <inttypes.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DISKIO_EOK 0 /* Success */
-#define DISKIO_EHW 1 /* Error accessing storage medium */
-#define DISKIO_ENOMEM 2 /* Insufficient memory */
-#define DISKIO_ENOENT 3 /* No such file or directory */
-#define DISKIO_EOS 4 /* OS error */
-#define DISKIO_EUNINIT 5 /* File system not initialized */
-
-struct disk_ops {
- int (*read)(int, uint32_t, void *, uint32_t);
- int (*write)(int, uint32_t, const void *, uint32_t);
- int (*ioctl)(int, uint32_t, const void *);
-
- SLIST_ENTRY(disk_ops) sc_next;
-};
-
-int diskio_register(const char *disk_name, const char *fs_name, struct disk_ops *dops);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/sys/diskio/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/diskio/pkg.yml b/sys/diskio/pkg.yml
deleted file mode 100644
index 8981937..0000000
--- a/sys/diskio/pkg.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-pkg.name: sys/diskio
-pkg.description: Disk IO layer to glue filesystems to disk devices.
-pkg.author: "Apache Mynewt <de...@mynewt.incubator.apache.org>"
-pkg.homepage: "http://mynewt.apache.org/"
-pkg.keywords:
-
-pkg.deps:
- - kernel/os
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e9213fe/sys/diskio/src/diskio.c
----------------------------------------------------------------------
diff --git a/sys/diskio/src/diskio.c b/sys/diskio/src/diskio.c
deleted file mode 100644
index e74eae3..0000000
--- a/sys/diskio/src/diskio.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include "syscfg/syscfg.h"
-#include "fs/fs.h"
-#include <diskio/diskio.h>
-
-static struct disk_info {
- char *disk_name;
- char *fs_name;
- struct disk_ops *dops;
-};
-
-static SLIST_HEAD(, disk_info) disks = SLIST_HEAD_INITIALIZER();
-
-/**
- *
- */
-int diskio_register(const char *disk_name, const char *fs_name, struct disk_ops *dops)
-{
- struct disk_info *info = NULL;
-
- SLIST_FOREACH(sc, &disks, sc_next) {
- if (strcmp(sc->disk_name, disk_name) == 0) {
- return DISKIO_EEXIST;
- }
- }
-
- info = malloc(sizeof(struct disk_info));
- if (!info) {
- return DISKIO_ENOMEM;
- }
-
- info.disk_name = disk_name;
- info.fs_name = fs_name;
- info.dops = dops;
-
- SLIST_INSERT_HEAD(&disks, info, sc_next);
-
- return 0;
-}