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 51 52 53 54 55 56 57 58 59 60 61
|
/*
* (C) Copyright 2014
* Stefano Babic <stefano.babic@swupdate.org>
*
* SPDX-License-Identifier: GPL-2.0-only
*/
#pragma once
#include <stdint.h>
#include <libmtd.h>
#include <libubi.h>
#include "bsdqueue.h"
#define DEFAULT_CTRL_DEV "/dev/ubi_ctrl"
#define FLASH_EMPTY_BYTE 0xFF
struct ubi_part {
struct ubi_vol_info vol_info;
LIST_ENTRY(ubi_part) next;
};
LIST_HEAD(ubilist, ubi_part);
struct mtd_ubi_info {
struct ubi_dev_info dev_info;
struct ubilist ubi_partitions;
struct ubi_attach_request req;
struct mtd_dev_info mtd;
int skipubi; /* set if no UBI scan must run */
int has_ubi; /* set if MTD must always have UBI */
int scanned;
};
struct flash_description {
libubi_t libubi;
libmtd_t libmtd;
struct ubi_info ubi_info;
struct mtd_info mtd;
struct mtd_ubi_info *mtd_info;
};
void ubi_mount(struct ubi_vol_info *vol, const char *mntpoint);
void ubi_umount(const char *mntpoint);
void mtd_init(void);
void mtd_set_ubiblacklist(char *mtdlist);
void ubi_init(void);
int scan_mtd_devices (void);
void mtd_cleanup (void);
int get_mtd_from_device(char *s);
int get_mtd_from_name(const char *s);
long long get_mtd_size(int mtdnum);
int flash_erase(int mtdnum);
int flash_erase_sector(int mtdnum, off_t start, size_t size);
struct flash_description *get_flash_info(void);
#define isNand(flash, index) \
(flash->mtd_info[index].mtd.type == MTD_NANDFLASH || \
flash->mtd_info[index].mtd.type == MTD_MLCNANDFLASH)
|