1 /*
2 * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "wm_littlefs.h"
17 #include "wm_internal_flash.h"
18
littlefs_block_read(const struct lfs_config * c,lfs_block_t block,lfs_off_t off,void * dst,lfs_size_t size)19 int32_t littlefs_block_read(const struct lfs_config *c, lfs_block_t block,
20 lfs_off_t off, void *dst, lfs_size_t size)
21 {
22 uint32_t addr = INSIDE_FLS_BASE_ADDR + c->block_size * ((lfs_off_t)c->context + block) + off;
23 return tls_fls_read(addr, dst, size);
24 }
25
littlefs_block_write(const struct lfs_config * c,lfs_block_t block,lfs_off_t off,const void * dst,lfs_size_t size)26 int32_t littlefs_block_write(const struct lfs_config *c, lfs_block_t block,
27 lfs_off_t off, const void *dst, lfs_size_t size)
28 {
29 uint32_t addr = INSIDE_FLS_BASE_ADDR + c->block_size * ((lfs_off_t)c->context + block) + off;
30 return tls_fls_write(addr, dst, size);
31 }
32
littlefs_block_erase(const struct lfs_config * c,lfs_block_t block)33 int32_t littlefs_block_erase(const struct lfs_config *c, lfs_block_t block)
34 {
35 uint32_t addr = INSIDE_FLS_BASE_ADDR + c->block_size * ((lfs_off_t)c->context + block);
36 return tls_fls_erase(addr/INSIDE_FLS_SECTOR_SIZE);
37 }
38
littlefs_block_sync(const struct lfs_config * c)39 int32_t littlefs_block_sync(const struct lfs_config *c)
40 {
41 return 0;
42 }
43