rel_1.6.0 init

This commit is contained in:
guocheng.kgc 2020-06-18 20:06:52 +08:00 committed by shengdong.dsd
commit 27b3e2883d
19359 changed files with 8093121 additions and 0 deletions

View file

@ -0,0 +1,4 @@
YAFFS2移植到AliOS-Things详细步骤见
https://yq.aliyun.com/articles/418865
此目录下yaffs_alios.c为AliOS-Things适配YAFFS2的操作系统相关接口yaffs_install_drv.c和yaffs_install_drv.h对接nand flash驱动的示例对接文件。

View file

@ -0,0 +1,8 @@
This software component is used to help users port third-party programs, but WITHOUT ANY WARRANTY. The entire risk as to the quality and performance of the program is with you. Should the program prove defective, you assume the cost of all necessary servicing, repair or correction. The use of third-party programs must also follow its own permissive license.
YAFFS2移植到AliOS-Things详细步骤见
https://yq.aliyun.com/articles/418865
此目录下yaffs_alios.c为AliOS-Things适配YAFFS2的操作系统相关接口yaffs_install_drv.c和yaffs_install_drv.h对接nand flash驱动的示例对接文件。
This directory include all the yaffs2 porting files.

View file

@ -0,0 +1,101 @@
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#include "yaffs_osglue.h"
#include "k_api.h"
#define YAFFS_BG_TASK_STACKSIZE 1024
static kmutex_t yaffs_mutex;
static ktask_t yaffs_bg_task_obj;
cpu_stack_t yaffs_bg_task_buf[YAFFS_BG_TASK_STACKSIZE];
void yaffsfs_Lock(void)
{
krhino_mutex_lock(&yaffs_mutex, RHINO_WAIT_FOREVER);
}
void yaffsfs_Unlock(void)
{
krhino_mutex_unlock(&yaffs_mutex);
}
u32 yaffsfs_CurrentTime(void)
{
return krhino_sys_time_get();
}
static int yaffsfs_lastError;
int yaffsfs_GetLastError(void)
{
return yaffsfs_lastError;
}
void yaffsfs_SetError(int err)
{
yaffsfs_lastError = err;
}
void *yaffsfs_malloc(size_t size)
{
return krhino_mm_alloc(size);
}
void yaffsfs_free(void *ptr)
{
krhino_mm_free(ptr);
}
int yaffsfs_CheckMemRegion(const void *addr, size_t size, int write_request)
{
/* add code according to the hardware configuration */
return 0;
}
static void bg_gc_func(void *dummy)
{
struct yaffs_dev *dev;
int urgent = 0;
int result = 0;
int next_urgent = 0;
(void)dummy;
/* Sleep for a bit to allow start up */
krhino_task_sleep(2);
while (1) {
/* Iterate through devices, do bg gc updating ungency */
yaffs_dev_rewind();
next_urgent = 0;
while ((dev = yaffs_next_dev()) != NULL) {
result = yaffs_do_background_gc_reldev(dev, urgent);
if (result > 0)
next_urgent = 1;
}
urgent = next_urgent;
if (next_urgent) {
krhino_task_sleep(1);
} else {
krhino_task_sleep(5);
}
}
}
void yaffsfs_OSInitialisation(void)
{
krhino_mutex_create(&yaffs_mutex, "mutex");
krhino_task_create(&yaffs_bg_task_obj, "yaffs_bg_task", 0, 20,
50, yaffs_bg_task_buf, YAFFS_BG_TASK_STACKSIZE, bg_gc_func, 1);
}
void yaffs_bug_fn(const char *file_name, int line_no)
{
printf("yaffs bug detected %s:%d\n", file_name, line_no);
}

View file

@ -0,0 +1,99 @@
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#include "yportenv.h"
#include "yaffs_guts.h"
#include "yaffs_install_drv.h"
static int nand_WriteChunk(struct yaffs_dev *dev, int nand_chunk,
const u8 *data, int data_len,
const u8 *oob, int oob_len)
{
/* add code according to your nand driver */
return YAFFS_OK;
}
static int nand_ReadChunk(struct yaffs_dev *dev, int nand_chunk,
u8 *data, int data_len,
u8 *oob, int oob_len,
enum yaffs_ecc_result *ecc_result)
{
/* add code according to your nand driver */
return YAFFS_OK;
}
static int nand_EraseBlock(struct yaffs_dev *dev, int block_no)
{
/* add code according to your nand driver */
return YAFFS_OK;
}
static int nand_MarkBad(struct yaffs_dev *dev, int block_no)
{
/* add code according to your nand driver */
return YAFFS_OK;
}
static int nand_CheckBad(struct yaffs_dev *dev, int block_no)
{
/* add code according to your nand driver */
return YAFFS_OK;
}
static int nand_Initialise(struct yaffs_dev *dev)
{
/* add code according to your nand driver */
return YAFFS_OK;
}
struct yaffs_dev *yaffs_install_drv(const char *name)
{
struct yaffs_dev *dev = NULL;
struct yaffs_param *param;
struct yaffs_driver *drv;
if(name == NULL) {
return NULL;
}
dev = malloc(sizeof(*dev));
if(dev == NULL)
{
return NULL;
}
memset(dev, 0, sizeof(*dev));
dev->param.name = name;
drv = &dev->drv;
drv->drv_write_chunk_fn = nand_WriteChunk;
drv->drv_read_chunk_fn = nand_ReadChunk;
drv->drv_erase_fn = nand_EraseBlock;
drv->drv_mark_bad_fn = nand_MarkBad;
drv->drv_check_bad_fn = nand_CheckBad;
drv->drv_initialise_fn = nand_Initialise;
param = &dev->param;
param->total_bytes_per_chunk = 2048;
param->chunks_per_block = 64;
param->start_block = 0;
param->end_block = 8192;
param->is_yaffs2 = 1;
param->use_nand_ecc=1;
param->n_reserved_blocks = 5;
param->wide_tnodes_disabled=0;
param->refresh_period = 1000;
param->n_caches = 10; // Use caches
param->enable_xattr = 1;
yaffs_add_device(dev);
return dev;
}

View file

@ -0,0 +1,13 @@
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/
#ifndef __YAFFS_INSTALL_DRV_H__
#define __YAFFS_INSTALL_DRV_H__
struct yaffs_dev;
struct yaffs_dev *yflash2_install_drv(const char *name);
#endif