GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
obj-y += ubispl.o ../ubi/crc32.o
|
||||
@@ -0,0 +1,105 @@
|
||||
/* SPDX-License-Identifier: GPL 2.0+ OR BSD-3-Clause */
|
||||
/*
|
||||
* The parts taken from the kernel implementation are:
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2006
|
||||
*
|
||||
* UBISPL specific defines:
|
||||
*
|
||||
* Copyright (c) Thomas Gleixner <tglx@linutronix.de>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Contains various defines copy&pasted from ubi.h and ubi-user.h to make
|
||||
* the upstream fastboot code happy.
|
||||
*/
|
||||
#ifndef __UBOOT_UBI_WRAPPER_H
|
||||
#define __UBOOT_UBI_WRAPPER_H
|
||||
|
||||
/*
|
||||
* Error codes returned by the I/O sub-system.
|
||||
*
|
||||
* UBI_IO_FF: the read region of flash contains only 0xFFs
|
||||
* UBI_IO_FF_BITFLIPS: the same as %UBI_IO_FF, but also also there was a data
|
||||
* integrity error reported by the MTD driver
|
||||
* (uncorrectable ECC error in case of NAND)
|
||||
* UBI_IO_BAD_HDR: the EC or VID header is corrupted (bad magic or CRC)
|
||||
* UBI_IO_BAD_HDR_EBADMSG: the same as %UBI_IO_BAD_HDR, but also there was a
|
||||
* data integrity error reported by the MTD driver
|
||||
* (uncorrectable ECC error in case of NAND)
|
||||
* UBI_IO_BITFLIPS: bit-flips were detected and corrected
|
||||
*
|
||||
* UBI_FASTMAP_ANCHOR: u-boot SPL add on to tell the caller that the fastmap
|
||||
* anchor block has been found
|
||||
*
|
||||
* Note, it is probably better to have bit-flip and ebadmsg as flags which can
|
||||
* be or'ed with other error code. But this is a big change because there are
|
||||
* may callers, so it does not worth the risk of introducing a bug
|
||||
*/
|
||||
enum {
|
||||
UBI_IO_FF = 1,
|
||||
UBI_IO_FF_BITFLIPS,
|
||||
UBI_IO_BAD_HDR,
|
||||
UBI_IO_BAD_HDR_EBADMSG,
|
||||
UBI_IO_BITFLIPS,
|
||||
UBI_FASTMAP_ANCHOR,
|
||||
};
|
||||
|
||||
/*
|
||||
* UBI volume type constants.
|
||||
*
|
||||
* @UBI_DYNAMIC_VOLUME: dynamic volume
|
||||
* @UBI_STATIC_VOLUME: static volume
|
||||
*/
|
||||
enum {
|
||||
UBI_DYNAMIC_VOLUME = 3,
|
||||
UBI_STATIC_VOLUME = 4,
|
||||
};
|
||||
|
||||
/*
|
||||
* Return codes of the fastmap sub-system
|
||||
*
|
||||
* UBI_NO_FASTMAP: No fastmap super block was found
|
||||
* UBI_BAD_FASTMAP: A fastmap was found but it's unusable
|
||||
*/
|
||||
enum {
|
||||
UBI_NO_FASTMAP = 1,
|
||||
UBI_BAD_FASTMAP,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ubi_fastmap_layout - in-memory fastmap data structure.
|
||||
* @e: PEBs used by the current fastmap
|
||||
* @to_be_tortured: if non-zero tortured this PEB
|
||||
* @used_blocks: number of used PEBs
|
||||
* @max_pool_size: maximal size of the user pool
|
||||
* @max_wl_pool_size: maximal size of the pool used by the WL sub-system
|
||||
*/
|
||||
struct ubi_fastmap_layout {
|
||||
struct ubi_wl_entry *e[UBI_FM_MAX_BLOCKS];
|
||||
int to_be_tortured[UBI_FM_MAX_BLOCKS];
|
||||
int used_blocks;
|
||||
int max_pool_size;
|
||||
int max_wl_pool_size;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ubi_fm_pool - in-memory fastmap pool
|
||||
* @pebs: PEBs in this pool
|
||||
* @used: number of used PEBs
|
||||
* @size: total number of PEBs in this pool
|
||||
* @max_size: maximal size of the pool
|
||||
*
|
||||
* A pool gets filled with up to max_size.
|
||||
* If all PEBs within the pool are used a new fastmap will be written
|
||||
* to the flash and the pool gets refilled with empty PEBs.
|
||||
*
|
||||
*/
|
||||
struct ubi_fm_pool {
|
||||
int pebs[UBI_FM_MAX_POOL_SIZE];
|
||||
int used;
|
||||
int size;
|
||||
int max_size;
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,142 @@
|
||||
/* SPDX-License-Identifier: GPL 2.0+ OR BSD-3-Clause */
|
||||
/*
|
||||
* Copyright (c) Thomas Gleixner <tglx@linutronix.de>
|
||||
*/
|
||||
|
||||
#ifndef _UBOOT_MTD_UBISPL_H
|
||||
#define _UBOOT_MTD_UBISPL_H
|
||||
|
||||
#include "../ubi/ubi-media.h"
|
||||
#include "ubi-wrapper.h"
|
||||
|
||||
/*
|
||||
* The maximum number of volume ids we scan. So you can load volume id
|
||||
* 0 to (CONFIG_SPL_UBI_VOL_ID_MAX - 1)
|
||||
*/
|
||||
#define UBI_SPL_VOL_IDS CONFIG_SPL_UBI_VOL_IDS
|
||||
/*
|
||||
* The size of the read buffer for the fastmap blocks. In theory up to
|
||||
* UBI_FM_MAX_BLOCKS * CONFIG_SPL_MAX_PEB_SIZE. In practice today
|
||||
* one or two blocks.
|
||||
*/
|
||||
#define UBI_FM_BUF_SIZE (UBI_FM_MAX_BLOCKS*CONFIG_SPL_UBI_MAX_PEB_SIZE)
|
||||
/*
|
||||
* The size of the bitmaps for the attach/ scan
|
||||
*/
|
||||
#define UBI_FM_BM_SIZE ((CONFIG_SPL_UBI_MAX_PEBS / BITS_PER_LONG) + 1)
|
||||
/*
|
||||
* The maximum number of logical erase blocks per loadable volume
|
||||
*/
|
||||
#define UBI_MAX_VOL_LEBS CONFIG_SPL_UBI_MAX_VOL_LEBS
|
||||
/*
|
||||
* The bitmap size for the above to denote the found blocks inside the volume
|
||||
*/
|
||||
#define UBI_VOL_BM_SIZE ((UBI_MAX_VOL_LEBS / BITS_PER_LONG) + 1)
|
||||
|
||||
/**
|
||||
* struct ubi_vol_info - UBISPL internal volume represenation
|
||||
* @last_block: The last block (highest LEB) found for this volume
|
||||
* @found: Bitmap to mark found LEBS
|
||||
* @lebs_to_pebs: LEB to PEB translation table
|
||||
*/
|
||||
struct ubi_vol_info {
|
||||
u32 last_block;
|
||||
unsigned long found[UBI_VOL_BM_SIZE];
|
||||
u32 lebs_to_pebs[UBI_MAX_VOL_LEBS];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct ubi_scan_info - UBISPL internal data for FM attach and full scan
|
||||
*
|
||||
* @read: Read function to access the flash provided by the caller
|
||||
* @peb_count: Number of physical erase blocks in the UBI FLASH area
|
||||
* aka MTD partition.
|
||||
* @peb_offset: Offset of PEB0 in the UBI FLASH area (aka MTD partition)
|
||||
* to the real start of the FLASH in erase blocks.
|
||||
* @fsize_mb: Size of the scanned FLASH area in MB (stats only)
|
||||
* @vid_offset: Offset from the start of a PEB to the VID header
|
||||
* @leb_start: Offset from the start of a PEB to the data area
|
||||
* @leb_size: Size of the data area
|
||||
*
|
||||
* @fastmap_pebs: Counter of PEBs "attached" by fastmap
|
||||
* @fastmap_anchor: The anchor PEB of the fastmap
|
||||
* @fm_sb: The fastmap super block data
|
||||
* @fm_vh: The fastmap VID header
|
||||
* @fm: Pointer to the fastmap layout
|
||||
* @fm_layout: The fastmap layout itself
|
||||
* @fm_pool: The pool of PEBs to scan at fastmap attach time
|
||||
* @fm_wl_pool: The pool of PEBs scheduled for wearleveling
|
||||
*
|
||||
* @fm_enabled: Indicator whether fastmap attachment is enabled.
|
||||
* @fm_used: Bitmap to indicate the PEBS covered by fastmap
|
||||
* @scanned: Bitmap to indicate the PEBS of which the VID header
|
||||
* hase been physically scanned.
|
||||
* @corrupt: Bitmap to indicate corrupt blocks
|
||||
* @toload: Bitmap to indicate the volumes which should be loaded
|
||||
*
|
||||
* @blockinfo: The vid headers of the scanned blocks
|
||||
* @volinfo: The volume information of the interesting (toload)
|
||||
* volumes
|
||||
* @vtbl_corrupted: Flag to indicate status of volume table
|
||||
* @vtbl: Volume table
|
||||
*
|
||||
* @fm_buf: The large fastmap attach buffer
|
||||
*/
|
||||
struct ubi_scan_info {
|
||||
ubispl_read_flash read;
|
||||
unsigned int fsize_mb;
|
||||
unsigned int peb_count;
|
||||
unsigned int peb_offset;
|
||||
|
||||
unsigned long vid_offset;
|
||||
unsigned long leb_start;
|
||||
unsigned long leb_size;
|
||||
|
||||
/* Fastmap: The upstream required fields */
|
||||
int fastmap_pebs;
|
||||
int fastmap_anchor;
|
||||
size_t fm_size;
|
||||
struct ubi_fm_sb fm_sb;
|
||||
struct ubi_vid_hdr fm_vh;
|
||||
struct ubi_fastmap_layout *fm;
|
||||
struct ubi_fastmap_layout fm_layout;
|
||||
struct ubi_fm_pool fm_pool;
|
||||
struct ubi_fm_pool fm_wl_pool;
|
||||
|
||||
/* Fastmap: UBISPL specific data */
|
||||
int fm_enabled;
|
||||
unsigned long fm_used[UBI_FM_BM_SIZE];
|
||||
unsigned long scanned[UBI_FM_BM_SIZE];
|
||||
unsigned long corrupt[UBI_FM_BM_SIZE];
|
||||
unsigned long toload[UBI_FM_BM_SIZE];
|
||||
|
||||
/* Data for storing the VID and volume information */
|
||||
struct ubi_vol_info volinfo[UBI_SPL_VOL_IDS];
|
||||
struct ubi_vid_hdr blockinfo[CONFIG_SPL_UBI_MAX_PEBS];
|
||||
|
||||
#ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME
|
||||
/* Volume table */
|
||||
int vtbl_valid;
|
||||
struct ubi_vtbl_record vtbl[UBI_SPL_VOL_IDS];
|
||||
#endif
|
||||
/* The large buffer for the fastmap */
|
||||
uint8_t fm_buf[UBI_FM_BUF_SIZE];
|
||||
};
|
||||
|
||||
#ifdef CFG_DEBUG
|
||||
#define ubi_dbg(fmt, ...) printf("UBI: debug:" fmt "\n", ##__VA_ARGS__)
|
||||
#else
|
||||
#define ubi_dbg(fmt, ...)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_UBI_SPL_SILENCE_MSG
|
||||
#define ubi_msg(fmt, ...)
|
||||
#else
|
||||
#define ubi_msg(fmt, ...) printf("UBI: " fmt "\n", ##__VA_ARGS__)
|
||||
#endif
|
||||
/* UBI warning messages */
|
||||
#define ubi_warn(fmt, ...) printf("UBI warning: " fmt "\n", ##__VA_ARGS__)
|
||||
/* UBI error messages */
|
||||
#define ubi_err(fmt, ...) printf("UBI error: " fmt "\n", ##__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user