Merge pull request #2 from andrzej-kaczmarek/dev
Rename 'glue' to 'os'
diff --git a/include/nffs/config.h b/include/nffs/config.h
index a9808e5..c4a118e 100644
--- a/include/nffs/config.h
+++ b/include/nffs/config.h
@@ -3,7 +3,7 @@
#if __ZEPHYR__
-typedef struct k_mem_slab nffs_mempool_t;
+typedef struct k_mem_slab nffs_os_mempool_t;
#define NFFS_CONFIG_USE_HEAP 0
#define NFFS_CONFIG_MAX_AREAS CONFIG_NFFS_FILESYSTEM_MAX_AREAS
@@ -13,7 +13,7 @@
/* Default to Mynewt */
-typedef struct os_mempool nffs_mempool_t;
+typedef struct os_mempool nffs_os_mempool_t;
#define NFFS_CONFIG_USE_HEAP 1
#define NFFS_CONFIG_MAX_AREAS 256
diff --git a/include/nffs/glue.h b/include/nffs/glue.h
deleted file mode 100644
index 1d4c887..0000000
--- a/include/nffs/glue.h
+++ /dev/null
@@ -1,70 +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 H_GLUE_
-#define H_GLUE_
-
-#include <stdint.h>
-#include <kernel.h>
-#include <nffs/config.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern nffs_mempool_t nffs_file_pool;
-extern nffs_mempool_t nffs_dir_pool;
-extern nffs_mempool_t nffs_inode_entry_pool;
-extern nffs_mempool_t nffs_block_entry_pool;
-extern nffs_mempool_t nffs_cache_inode_pool;
-extern nffs_mempool_t nffs_cache_block_pool;
-
-/* Initialize mempools */
-int nffs_glue_mempool_init(void);
-
-/* Get block from mempool */
-void *nffs_glue_mempool_get(nffs_mempool_t *pool);
-
-/* Free block from mempool */
-int nffs_glue_mempool_free(nffs_mempool_t *pool, void *block);
-
-/* Read from flash */
-int nffs_glue_flash_read(uint8_t id, uint32_t address, void *dst,
- uint32_t num_bytes);
-
-/* Write to flash */
-int nffs_glue_flash_write(uint8_t id, uint32_t address, const void *src,
- uint32_t num_bytes);
-
-/* Erase flash */
-int nffs_glue_flash_erase(uint8_t id, uint32_t address, uint32_t num_bytes);
-
-/* Get flash sector information */
-int nffs_glue_flash_info(uint8_t id, uint32_t sector, uint32_t *address,
- uint32_t *size);
-
-/* CRC16-CCIT implementation */
-uint16_t nffs_glue_crc16_ccitt(uint16_t initial_crc, const void *buf, int len,
- int final);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/include/nffs/os.h b/include/nffs/os.h
new file mode 100644
index 0000000..ff84324
--- /dev/null
+++ b/include/nffs/os.h
@@ -0,0 +1,70 @@
+/*
+ * 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 H_GLUE_
+#define H_GLUE_
+
+#include <stdint.h>
+#include <kernel.h>
+#include <nffs/config.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern nffs_os_mempool_t nffs_file_pool;
+extern nffs_os_mempool_t nffs_dir_pool;
+extern nffs_os_mempool_t nffs_inode_entry_pool;
+extern nffs_os_mempool_t nffs_block_entry_pool;
+extern nffs_os_mempool_t nffs_cache_inode_pool;
+extern nffs_os_mempool_t nffs_cache_block_pool;
+
+/* Initialize mempools */
+int nffs_os_mempool_init(void);
+
+/* Get block from mempool */
+void *nffs_os_mempool_get(nffs_os_mempool_t *pool);
+
+/* Free block from mempool */
+int nffs_os_mempool_free(nffs_os_mempool_t *pool, void *block);
+
+/* Read from flash */
+int nffs_os_flash_read(uint8_t id, uint32_t address, void *dst,
+ uint32_t num_bytes);
+
+/* Write to flash */
+int nffs_os_flash_write(uint8_t id, uint32_t address, const void *src,
+ uint32_t num_bytes);
+
+/* Erase flash */
+int nffs_os_flash_erase(uint8_t id, uint32_t address, uint32_t num_bytes);
+
+/* Get flash sector information */
+int nffs_os_flash_info(uint8_t id, uint32_t sector, uint32_t *address,
+ uint32_t *size);
+
+/* CRC16-CCIT implementation */
+uint16_t nffs_os_crc16_ccitt(uint16_t initial_crc, const void *buf, int len,
+ int final);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/nffs_block.c b/src/nffs_block.c
index 6609e84..19c1e0d 100644
--- a/src/nffs_block.c
+++ b/src/nffs_block.c
@@ -21,14 +21,14 @@
#include <assert.h>
#include <string.h>
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
struct nffs_hash_entry *
nffs_block_entry_alloc(void)
{
struct nffs_hash_entry *entry;
- entry = nffs_glue_mempool_get(&nffs_block_entry_pool);
+ entry = nffs_os_mempool_get(&nffs_block_entry_pool);
if (entry != NULL) {
memset(entry, 0, sizeof *entry);
}
@@ -40,7 +40,7 @@
nffs_block_entry_free(struct nffs_hash_entry *block_entry)
{
assert(nffs_hash_id_is_block(block_entry->nhe_id));
- nffs_glue_mempool_free(&nffs_block_entry_pool, block_entry);
+ nffs_os_mempool_free(&nffs_block_entry_pool, block_entry);
}
/**
diff --git a/src/nffs_cache.c b/src/nffs_cache.c
index 57942c5..8324a55 100644
--- a/src/nffs_cache.c
+++ b/src/nffs_cache.c
@@ -20,7 +20,7 @@
#include <assert.h>
#include <string.h>
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
TAILQ_HEAD(nffs_cache_inode_list, nffs_cache_inode);
static struct nffs_cache_inode_list nffs_cache_inode_list =
@@ -33,7 +33,7 @@
{
struct nffs_cache_block *entry;
- entry = nffs_glue_mempool_get(&nffs_cache_block_pool);
+ entry = nffs_os_mempool_get(&nffs_cache_block_pool);
if (entry != NULL) {
memset(entry, 0, sizeof *entry);
}
@@ -45,7 +45,7 @@
nffs_cache_block_free(struct nffs_cache_block *entry)
{
if (entry != NULL) {
- nffs_glue_mempool_free(&nffs_cache_block_pool, entry);
+ nffs_os_mempool_free(&nffs_cache_block_pool, entry);
}
}
@@ -88,7 +88,7 @@
{
struct nffs_cache_inode *entry;
- entry = nffs_glue_mempool_get(&nffs_cache_inode_pool);
+ entry = nffs_os_mempool_get(&nffs_cache_inode_pool);
if (entry != NULL) {
memset(entry, 0, sizeof *entry);
TAILQ_INIT(&entry->nci_block_list);
@@ -113,7 +113,7 @@
{
if (entry != NULL) {
nffs_cache_inode_free_blocks(entry);
- nffs_glue_mempool_free(&nffs_cache_inode_pool, entry);
+ nffs_os_mempool_free(&nffs_cache_inode_pool, entry);
}
}
diff --git a/src/nffs_crc.c b/src/nffs_crc.c
index f9b87ba..1da8b61 100644
--- a/src/nffs_crc.c
+++ b/src/nffs_crc.c
@@ -18,7 +18,7 @@
*/
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
int
nffs_crc_flash(uint16_t initial_crc, uint8_t area_idx, uint32_t area_offset,
@@ -44,7 +44,7 @@
return rc;
}
- crc = nffs_glue_crc16_ccitt(crc, nffs_flash_buf, chunk_len, 0);
+ crc = nffs_os_crc16_ccitt(crc, nffs_flash_buf, chunk_len, 0);
area_offset += chunk_len;
len -= chunk_len;
@@ -59,7 +59,7 @@
{
uint16_t crc;
- crc = nffs_glue_crc16_ccitt(0, disk_block, NFFS_DISK_BLOCK_OFFSET_CRC, 0);
+ crc = nffs_os_crc16_ccitt(0, disk_block, NFFS_DISK_BLOCK_OFFSET_CRC, 0);
return crc;
}
@@ -81,7 +81,7 @@
}
/* Finish CRC */
- crc = nffs_glue_crc16_ccitt(crc, NULL, 0, 1);
+ crc = nffs_os_crc16_ccitt(crc, NULL, 0, 1);
*out_crc = crc;
return 0;
@@ -112,7 +112,7 @@
uint16_t crc16;
crc16 = nffs_crc_disk_block_hdr(disk_block);
- crc16 = nffs_glue_crc16_ccitt(crc16, data, disk_block->ndb_data_len, 1);
+ crc16 = nffs_os_crc16_ccitt(crc16, data, disk_block->ndb_data_len, 1);
disk_block->ndb_crc16 = crc16;
}
@@ -122,7 +122,7 @@
{
uint16_t crc;
- crc = nffs_glue_crc16_ccitt(0, disk_inode, NFFS_DISK_INODE_OFFSET_CRC, 1);
+ crc = nffs_os_crc16_ccitt(0, disk_inode, NFFS_DISK_INODE_OFFSET_CRC, 1);
return crc;
}
@@ -144,7 +144,7 @@
}
/* Finish CRC */
- crc = nffs_glue_crc16_ccitt(crc, NULL, 0, 1);
+ crc = nffs_os_crc16_ccitt(crc, NULL, 0, 1);
*out_crc = crc;
return 0;
@@ -176,7 +176,7 @@
uint16_t crc16;
crc16 = nffs_crc_disk_inode_hdr(disk_inode);
- crc16 = nffs_glue_crc16_ccitt(crc16, filename,
+ crc16 = nffs_os_crc16_ccitt(crc16, filename,
disk_inode->ndi_filename_len, 1);
disk_inode->ndi_crc16 = crc16;
diff --git a/src/nffs_dir.c b/src/nffs_dir.c
index 311c68e..5d8bc90 100644
--- a/src/nffs_dir.c
+++ b/src/nffs_dir.c
@@ -20,14 +20,14 @@
#include <assert.h>
#include <string.h>
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
static struct nffs_dir *
nffs_dir_alloc(void)
{
struct nffs_dir *dir;
- dir = nffs_glue_mempool_get(&nffs_dir_pool);
+ dir = nffs_os_mempool_get(&nffs_dir_pool);
if (dir != NULL) {
memset(dir, 0, sizeof *dir);
}
@@ -41,7 +41,7 @@
int rc;
if (dir != NULL) {
- rc = nffs_glue_mempool_free(&nffs_dir_pool, dir);
+ rc = nffs_os_mempool_free(&nffs_dir_pool, dir);
if (rc != 0) {
return FS_EOS;
}
diff --git a/src/nffs_file.c b/src/nffs_file.c
index 08cdb70..4be4f5f 100644
--- a/src/nffs_file.c
+++ b/src/nffs_file.c
@@ -20,14 +20,14 @@
#include <assert.h>
#include <string.h>
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
static struct nffs_file *
nffs_file_alloc(void)
{
struct nffs_file *file;
- file = nffs_glue_mempool_get(&nffs_file_pool);
+ file = nffs_os_mempool_get(&nffs_file_pool);
if (file != NULL) {
memset(file, 0, sizeof *file);
}
@@ -41,7 +41,7 @@
int rc;
if (file != NULL) {
- rc = nffs_glue_mempool_free(&nffs_file_pool, file);
+ rc = nffs_os_mempool_free(&nffs_file_pool, file);
if (rc != 0) {
return FS_EOS;
}
diff --git a/src/nffs_flash.c b/src/nffs_flash.c
index 8e6dbcc..4e27e25 100644
--- a/src/nffs_flash.c
+++ b/src/nffs_flash.c
@@ -19,7 +19,7 @@
#include <assert.h>
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
/** A buffer used for flash reads; shared across all of nffs. */
uint8_t nffs_flash_buf[NFFS_FLASH_BUF_SZ];
@@ -54,7 +54,7 @@
}
STATS_INC(nffs_stats, nffs_iocnt_read);
- rc = nffs_glue_flash_read(area->na_flash_id, area->na_offset + area_offset, data,
+ rc = nffs_os_flash_read(area->na_flash_id, area->na_offset + area_offset, data,
len);
if (rc != 0) {
return FS_EHW;
@@ -96,7 +96,7 @@
}
STATS_INC(nffs_stats, nffs_iocnt_write);
- rc = nffs_glue_flash_write(area->na_flash_id, area->na_offset + area_offset,
+ rc = nffs_os_flash_write(area->na_flash_id, area->na_offset + area_offset,
data, len);
if (rc != 0) {
return FS_EHW;
diff --git a/src/nffs_format.c b/src/nffs_format.c
index bfa7216..5fe4bf0 100644
--- a/src/nffs_format.c
+++ b/src/nffs_format.c
@@ -20,7 +20,7 @@
#include <assert.h>
#include <string.h>
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
/**
* Turns a scratch area into a non-scratch area. If the specified area is not
@@ -71,7 +71,7 @@
area = nffs_areas + area_idx;
- rc = nffs_glue_flash_erase(area->na_flash_id, area->na_offset, area->na_length);
+ rc = nffs_os_flash_erase(area->na_flash_id, area->na_offset, area->na_length);
if (rc != 0) {
return FS_EHW;
}
diff --git a/src/nffs_inode.c b/src/nffs_inode.c
index db8b74b..10776b6 100644
--- a/src/nffs_inode.c
+++ b/src/nffs_inode.c
@@ -21,7 +21,7 @@
#include <string.h>
#include <assert.h>
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
/* Partition the flash buffer into two equal halves; used for filename
* comparisons.
@@ -39,7 +39,7 @@
{
struct nffs_inode_entry *inode_entry;
- inode_entry = nffs_glue_mempool_get(&nffs_inode_entry_pool);
+ inode_entry = nffs_os_mempool_get(&nffs_inode_entry_pool);
if (inode_entry != NULL) {
memset(inode_entry, 0, sizeof *inode_entry);
}
@@ -53,7 +53,7 @@
if (inode_entry != NULL) {
assert(!nffs_inode_getflags(inode_entry, NFFS_INODE_FLAG_INHASH));
assert(nffs_hash_id_is_inode(inode_entry->nie_hash_entry.nhe_id));
- nffs_glue_mempool_free(&nffs_inode_entry_pool, inode_entry);
+ nffs_os_mempool_free(&nffs_inode_entry_pool, inode_entry);
}
}
diff --git a/src/nffs_misc.c b/src/nffs_misc.c
index b6f26c7..fd55ef9 100644
--- a/src/nffs_misc.c
+++ b/src/nffs_misc.c
@@ -22,7 +22,7 @@
#include <string.h>
#include <kernel.h>
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
/**
* Determines if the file system contains a valid root directory. For the root
@@ -366,7 +366,7 @@
nffs_cache_clear();
- nffs_glue_mempool_init();
+ nffs_os_mempool_init();
rc = nffs_hash_init();
if (rc != 0) {
@@ -425,7 +425,7 @@
*cnt = 0;
for (i = 0; i < flash->sector_count; i++) {
- nffs_glue_flash_info(flash->id, i, &start, &size);
+ nffs_os_flash_info(flash->id, i, &start, &size);
if (start >= flash->area_offset && start < flash->area_offset + flash->area_size) {
if (first_idx == -1) {
first_idx = i;
@@ -443,7 +443,7 @@
move_on = 1;
for (i = first_idx, j = 0; i < last_idx + 1; i++) {
- nffs_glue_flash_info(flash->id, i, &start, &size);
+ nffs_os_flash_info(flash->id, i, &start, &size);
if (move_on) {
nad[j].nad_flash_id = flash->id;
nad[j].nad_offset = start;
diff --git a/src/nffs_restore.c b/src/nffs_restore.c
index c61155a..4f02264 100644
--- a/src/nffs_restore.c
+++ b/src/nffs_restore.c
@@ -21,7 +21,7 @@
#include <stdio.h>
#include <string.h>
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
/**
* The size of the largest data block encountered during detection. This is
@@ -1104,7 +1104,7 @@
int rc;
STATS_INC(nffs_stats, nffs_readcnt_detect);
- rc = nffs_glue_flash_read(flash_id, area_offset, out_disk_area,
+ rc = nffs_os_flash_read(flash_id, area_offset, out_disk_area,
sizeof *out_disk_area);
if (rc != 0) {
return FS_EHW;
diff --git a/src/nffs_write.c b/src/nffs_write.c
index abcb603..ae56945 100644
--- a/src/nffs_write.c
+++ b/src/nffs_write.c
@@ -20,7 +20,7 @@
#include <assert.h>
#include <string.h>
#include <nffs/nffs.h>
-#include <nffs/glue.h>
+#include <nffs/os.h>
static int
nffs_write_fill_crc16_overwrite(struct nffs_disk_block *disk_block,
@@ -52,7 +52,7 @@
/* Write the new data into the data block. This may extend the block's
* length beyond its old value.
*/
- crc16 = nffs_glue_crc16_ccitt(crc16, new_data, new_data_len, 0);
+ crc16 = nffs_os_crc16_ccitt(crc16, new_data, new_data_len, 0);
block_off += new_data_len;
/* Copy data from the end of the old block, in case the new data doesn't
@@ -70,7 +70,7 @@
assert(block_off == sizeof *disk_block + disk_block->ndb_data_len);
/* Finish CRC */
- crc16 = nffs_glue_crc16_ccitt(crc16, NULL, 0, 1);
+ crc16 = nffs_os_crc16_ccitt(crc16, NULL, 0, 1);
disk_block->ndb_crc16 = crc16;