boards/sim: Defconfigs for nand and mnemofs

Adds nand and mnemofs sim configs.

Signed-off-by: Saurav Pal <resyfer.dev@gmail.com>
This commit is contained in:
Saurav Pal
2024-09-02 14:24:52 +00:00
committed by Xiang Xiao
parent a2ed0ddd72
commit fc31c61730
14 changed files with 254 additions and 108 deletions

View File

@@ -557,7 +557,8 @@ static ssize_t mnemofs_read(FAR struct file *filep, FAR char *buffer,
f = filep->f_priv;
DEBUGASSERT(f != NULL);
finfo("Mnemofs read %lu bytes from %u offset", buflen, f->com->off);
finfo("Mnemofs read %zu bytes from %" PRIu32 " offset", buflen,
f->com->off);
/* Check if allowed to read. */
@@ -579,7 +580,7 @@ static ssize_t mnemofs_read(FAR struct file *filep, FAR char *buffer,
buffer, buflen);
if (ret < 0)
{
finfo("Error while reading. Ret: %d.", ret);
finfo("Error while reading. Ret: %zd.", ret);
goto errout_with_lock;
}
@@ -593,7 +594,7 @@ errout_with_lock:
nxmutex_unlock(&MFS_LOCK(sb));
errout:
finfo("Mnemofs read exited with %d.", ret);
finfo("Mnemofs read exited with %zd.", ret);
return ret;
}
@@ -642,7 +643,8 @@ static ssize_t mnemofs_write(FAR struct file *filep, FAR const char *buffer,
f = filep->f_priv;
DEBUGASSERT(f != NULL);
finfo("Mnemofs write %lu bytes at offset %u.", buflen, f->com->off);
finfo("Mnemofs write %zu bytes at offset %" PRIu32, buflen,
f->com->off);
/* Check if allowed to write. */
@@ -674,7 +676,7 @@ errout_with_lock:
finfo("Lock released.");
errout:
finfo("Mnemofs write exited with %d.", ret);
finfo("Mnemofs write exited with %zd.", ret);
return ret;
}
@@ -800,7 +802,7 @@ static int mnemofs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
FAR struct inode *drv;
FAR struct mfs_sb_s *sb;
finfo("Mnemofs ioctl with cmd %u and arg %ld", cmd, arg);
finfo("Mnemofs ioctl with cmd %" PRIu32 "and arg %zu.", cmd, arg);
inode = filep->f_inode;
sb = inode->i_private;

View File

@@ -282,7 +282,6 @@ static int is_blk_writeable(FAR struct mfs_sb_s * const sb, const mfs_t blk)
int mfs_ba_fmt(FAR struct mfs_sb_s * const sb)
{
int ret = OK;
uint8_t log;
/* We need at least 5 blocks, as one is occupied by superblock, at least
* one for the journal, 2 for journal's master blocks, and at least one for
@@ -306,8 +305,6 @@ int mfs_ba_fmt(FAR struct mfs_sb_s * const sb)
MFS_BA(sb).c_pg = MFS_BLK2PG(sb, MFS_BA(sb).s_blk);
log = ceil(log2(MFS_NBLKS(sb)));
/* MFS_BA(sb).k_del_elemsz = ((log + 7) & (-8)) / 8; */
MFS_BA(sb).k_del = kmm_zalloc(sizeof(size_t) * MFS_NBLKS(sb));

View File

@@ -325,7 +325,6 @@ int mfs_ctz_rdfromoff(FAR const struct mfs_sb_s * const sb,
{
int ret = OK;
mfs_t i;
mfs_t rd_sz;
mfs_t cur_pg;
mfs_t cur_idx;
mfs_t cur_pgoff;
@@ -351,7 +350,6 @@ int mfs_ctz_rdfromoff(FAR const struct mfs_sb_s * const sb,
}
cur_pg = mfs_ctz_travel(sb, ctz.idx_e, ctz.pg_e, cur_idx);
rd_sz = 0;
if (predict_false(cur_pg == 0))
{
@@ -444,8 +442,7 @@ int mfs_ctz_wrtnode(FAR struct mfs_sb_s * const sb,
struct mfs_ctz_s ctz;
FAR struct mfs_delta_s *delta;
finfo("Write LRU node %p at depth %u, with %u delta(s) to flash.", node,
node->depth, list_length(&node->delta));
finfo("Write LRU node %p at depth %u.", node, node->depth);
/* Traverse common CTZ blocks. */
@@ -487,8 +484,8 @@ int mfs_ctz_wrtnode(FAR struct mfs_sb_s * const sb,
upper = MIN(prev + lower + ctz_blkdatasz(sb, cur_idx), rem_sz);
upper_og = upper;
finfo("Remaining Size %u. Lower %u, Upper %u, Current Offset %u",
rem_sz, lower, upper, tmp - buf);
finfo("Remaining Size %" PRIu32 ". Lower %" PRIu32 ", Upper %" PRIu32
", Current Offset %zd.", rem_sz, lower, upper, tmp - buf);
/* Retrieving original data. */
@@ -501,8 +498,8 @@ int mfs_ctz_wrtnode(FAR struct mfs_sb_s * const sb,
list_for_every_entry(&node->delta, delta, struct mfs_delta_s, list)
{
finfo("Checking delta %p in node %p. Offset %u, bytes %u.", delta,
node, delta->off, delta->n_b);
finfo("Checking delta %p in node %p. Offset %" PRIu32 ", bytes %"
PRIu32, delta, node, delta->off, delta->n_b);
lower_upd = MAX(lower, delta->off);
upper_upd = MIN(upper, delta->off + delta->n_b);
@@ -569,7 +566,7 @@ int mfs_ctz_wrtnode(FAR struct mfs_sb_s * const sb,
written = true;
finfo("Written data to page %u.", new_pg);
finfo("Written data to page %" PRIu32, new_pg);
}
else
{
@@ -655,8 +652,8 @@ mfs_t mfs_ctz_travel(FAR const struct mfs_sb_s * const sb,
}
}
finfo("Travel from index %u at page %u to index %u at page %u.", idx_src,
pg_src, idx_dest, pg);
finfo("Travel from index %" PRIu32 " at page %" PRIu32 " to index %" PRIu32
" at page %" PRIu32 ".", idx_src, pg_src, idx_dest, pg);
return pg;
}

View File

@@ -626,7 +626,6 @@ int mfs_jrnl_wrlog(FAR struct mfs_sb_s * const sb,
{
int ret = OK;
mfs_t jrnl_pg;
mfs_t jrnl_blk;
FAR char *buf = NULL;
FAR char *tmp = NULL;
const mfs_t log_sz = sizeof(mfs_t) + MFS_LOGSZ(node->depth);
@@ -655,7 +654,6 @@ int mfs_jrnl_wrlog(FAR struct mfs_sb_s * const sb,
/* Store */
jrnl_blk = mfs_jrnl_blkidx2blk(sb, MFS_JRNL(sb).log_cblkidx);
jrnl_pg = MFS_JRNL(sb).log_cpg;
/* TODO: It assumes it takes only one page per log. */

View File

@@ -193,8 +193,8 @@ static void lru_nodesearch(FAR const struct mfs_sb_s * const sb,
if (found)
{
finfo("Node search ended with match of node %p at depth %u"
" for CTZ of %u size with range [%u, %u).", n, n->depth, n->sz,
n->range_min, n->range_max);
" for CTZ of %" PRIu32 " size with range [%" PRIu32 ", %" PRIi32
").", n, n->depth, n->sz, n->range_min, n->range_max);
}
else
{
@@ -325,9 +325,9 @@ static int lru_nodeflush(FAR struct mfs_sb_s * const sb,
if (rm_node)
{
finfo("Deleting node. Old size: %u.", list_length(&MFS_LRU(sb)));
finfo("Deleting node. Old size: %zu.", list_length(&MFS_LRU(sb)));
list_delete_init(&node->list);
finfo("Deleted node. New size: %u.", list_length(&MFS_LRU(sb)));
finfo("Deleted node. New size: %zu.", list_length(&MFS_LRU(sb)));
}
else
{
@@ -428,13 +428,13 @@ static int lru_wrtooff(FAR struct mfs_sb_s * const sb, const mfs_t data_off,
struct mfs_node_s, list);
list_delete_init(&last_node->list);
list_add_tail(&MFS_LRU(sb), &node->list);
finfo("LRU flushing node complete, now only %u nodes",
finfo("LRU flushing node complete, now only %zu nodes",
list_length(&MFS_LRU(sb)));
}
else
{
list_add_tail(&MFS_LRU(sb), &node->list);
finfo("Node inserted into LRU, and it now %u node(s).",
finfo("Node inserted into LRU, and it now %zu node(s).",
list_length(&MFS_LRU(sb)));
}
}
@@ -502,10 +502,10 @@ static int lru_wrtooff(FAR struct mfs_sb_s * const sb, const mfs_t data_off,
}
}
finfo("Delta attached to node %p. Now there are %lu nodes and the node has"
" %lu deltas. Node with range [%u, %u).", node,
list_length(&MFS_LRU(sb)), list_length(&node->delta),
node->range_min, node->range_max);
finfo("Delta attached to node %p. Now there are %zu nodes and the"
" node has %zu deltas. Node with range [%" PRIu32 ", %"
PRIu32 ").", node, list_length(&MFS_LRU(sb)),
list_length(&node->delta), node->range_min, node->range_max);
return ret;
@@ -730,7 +730,7 @@ int mfs_lru_flush(FAR struct mfs_sb_s * const sb)
* big), the stack depth for this will be 7.
*/
finfo("Sorting the LRU. No. of nodes: %u.", list_length(&MFS_LRU(sb)));
finfo("Sorting the LRU. No. of nodes: %zu", list_length(&MFS_LRU(sb)));
lru_sort(sb, MFS_LRU(sb).next, MFS_LRU(sb).prev);
MFS_FLUSH(sb) = true;

View File

@@ -191,13 +191,12 @@ static FAR const char *deser_mn(FAR const char * const in,
int mfs_mn_init(FAR struct mfs_sb_s * const sb, const mfs_t jrnl_blk)
{
int ret = OK;
bool found = false;
mfs_t i = 0;
mfs_t mblk1;
mfs_t mblk2;
mfs_t jrnl_blk_tmp;
mfs_t blkidx;
mfs_t pg_in_blk;
bool found = false;
mfs_t jrnl_blk_tmp;
uint16_t hash;
struct mfs_mn_s mn;
const mfs_t sz = sizeof(struct mfs_mn_s) - sizeof(mn.pg);
@@ -206,7 +205,7 @@ int mfs_mn_init(FAR struct mfs_sb_s * const sb, const mfs_t jrnl_blk)
struct mfs_jrnl_log_s log;
mblk1 = mfs_jrnl_blkidx2blk(sb, MFS_JRNL(sb).n_blks);
mblk2 = mfs_jrnl_blkidx2blk(sb, MFS_JRNL(sb).n_blks + 1);
mn.jrnl_blk = jrnl_blk;
mn.mblk_idx = 0;
mn.pg = MFS_BLK2PG(sb, mblk1);
@@ -362,8 +361,6 @@ int mfs_mn_move(FAR struct mfs_sb_s * const sb, struct mfs_ctz_s root,
const mfs_t root_sz)
{
int ret = OK;
mfs_t mblk1;
mfs_t mblk2;
struct mfs_mn_s mn;
const mfs_t sz = sizeof(struct mfs_mn_s) - sizeof(mn.pg);
char buf[sz + 1];
@@ -373,9 +370,7 @@ int mfs_mn_move(FAR struct mfs_sb_s * const sb, struct mfs_ctz_s root,
/* TODO: Move journal. Master blocks are full. */
}
mblk1 = mfs_jrnl_blkidx2blk(sb, MFS_JRNL(sb).n_blks);
mblk2 = mfs_jrnl_blkidx2blk(sb, MFS_JRNL(sb).n_blks + 1);
mn = MFS_MN(sb);
mn = MFS_MN(sb);
mn.root_ctz = root;
mn.root_sz = root_sz;

View File

@@ -102,7 +102,7 @@ uint8_t mfs_arrhash(FAR const char *arr, ssize_t len)
hash %= (1 << 8);
}
finfo("Hash calculated for size %ld to be %d.", len, hash % (1 << 8));
finfo("Hash calculated for size %zd to be %d.", len, hash % (1 << 8));
return hash % (1 << 8);
}
@@ -123,7 +123,7 @@ uint16_t mfs_hash(FAR const char *arr, ssize_t len)
hash %= (1 << MFS_HASHSZ);
}
finfo("Hash calculated for size %ld to be %u.", len, hash);
finfo("Hash calculated for size %zd to be %" PRIi32, len, hash);
return hash;
}