summaryrefslogtreecommitdiff
path: root/bsp/phytium/libraries/port/fboard_port/mnt_ramdisk.c
blob: bf05816e076c689393edb5aa830d04e9323a97cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * Copyright (c) 2006-2023, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Email: [email protected]
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-04-27     huanghe      first version
 * 2023-07-14   liqiaozhong    add SD file sys mount func
 *
 */
#include <rtthread.h>
#include <rtdbg.h>
#ifndef RT_USING_SMART
#include <dfs_fs.h>
#include <dfs_file.h>

static int ram_disk_mount(const char *mount_point)
{
    extern struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size);

    rt_uint8_t *pool = RT_NULL;
    rt_size_t size = 8 * 1024 * 1024;

    pool = rt_malloc(size);
    if (pool == RT_NULL)
    {
        LOG_E("Malloc fail!");
    }

    if (dfs_mount(RT_NULL, mount_point, "ram", 0, (const void *)dfs_ramfs_create(pool, size)) == 0)
    {
        LOG_I("RAM file system initializated!");
    }
    else
    {
        LOG_E("RAM file system initializate failed!");
    }

    return RT_EOK;
}

static int filesystem_mount(void)
{
    return ram_disk_mount("/"); /* mount ramdisk as / */
}
INIT_APP_EXPORT(filesystem_mount);
#endif