blob: 735e96b1e856413977f9d2fe3161e05f62da6124 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (c) 2018 MediaTek Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23#pragma once
24
25#include <list.h>
26#include <sys/types.h>
27
28struct nftl_info {
29 char *name;
30 char *label;
31 u64 total_size;
32 u32 erase_size;
33 u32 write_size;
34
35 int (*block_isbad)(struct nftl_info *info, u32 page);
36 ssize_t (*erase)(struct nftl_info *info, off_t offset, ssize_t len);
37 ssize_t (*read)(struct nftl_info *info, void *buf, off_t offset,
38 ssize_t len);
39 ssize_t (*write)(struct nftl_info *info, const void *buf, off_t offset,
40 ssize_t len);
41 int (*ioctl)(struct nftl_info *info, int request, void *argp);
42};
43
44int nftl_mount_bdev(struct nftl_info *info);
45struct nftl_info *nftl_search_by_address(u64 address, u64 *start);
46struct nftl_info *nftl_open(const char *name);
47void nftl_close(struct nftl_info *info);
48int nftl_add_part(const char *main_part, const char *sub_part,
49 const char *sub_label, u64 offset, u64 len);
50struct nftl_info *nftl_add_master(const char *name);
51int nftl_delete_part(const char *name);
52void nftl_dump_parts(void);
53int nftl_block_mapping(struct nftl_info *info, u32 *page);
54int nftl_block_isbad(struct nftl_info *info, u32 page);
55ssize_t nftl_erase(struct nftl_info *info, off_t offset, ssize_t len);
56ssize_t nftl_read(struct nftl_info *info, void *buf, off_t offset, ssize_t len);
57ssize_t nftl_write(struct nftl_info *info, const void *buf, off_t offset,
58 ssize_t len);