<commit_before>/*
  This file is part of UFFS, the Ultra-low-cost Flash File System.
  
  Copyright (C) 2005-2009 <NAME> <<EMAIL>>

  UFFS is free software; you can redistribute it and/or modify it under
  the GNU Library General Public License as published by the Free Software 
  Foundation; either version 2 of the License, or (at your option) any
  later version.

  UFFS is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  or GNU Library General Public License, as applicable, for more details.
 
  You should have received a copy of the GNU General Public License
  and GNU Library General Public License along with UFFS; if not, write
  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA  02110-1301, USA.

  As a special exception, if other files instantiate templates or use
  macros or inline functions from this file, or you compile this file
  and link it with other works to produce a work based on this file,
  this file does not by itself cause the resulting work to be covered
  by the GNU General Public License. However the source code for this
  file must still be made available in accordance with section (3) of
  the GNU General Public License v2.
 
  This exception does not invalidate any other reasons why a work based
  on this file might be covered by the GNU General Public License.
*/

/** 
 * \file uffs_public.h
 * \brief flash interface for UFFS
 * \author <NAME>
 */

#ifndef _UFFS_FLASH_H_
#define _UFFS_FLASH_H_

#include "uffs/uffs_types.h"
#include "uffs/uffs_core.h"
#include "uffs/uffs_device.h"
#include "uffs/uffs_fs.h"

#ifdef __cplusplus
extern "C"{
#endif


/** ECC options (uffs_StorageAttrSt.ecc_opt) */
#define UFFS_ECC_NONE		0	//!< do not use ECC
#define UFFS_ECC_SOFT		1	//!< UFFS calculate the ECC
#define UFFS_ECC_HW			2	//!< Flash driver(or by hardware) calculate the ECC
#define UFFS_ECC_HW_AUTO	3	//!< Hardware calculate the ECC and automatically write to spare.

#define UFFS_ECC_OPTION_STRING \
	{ "none", "soft", "hw", "auto" }	// index is the ecc option value.

/** spare layout options (uffs_StorageAttrSt.layout_opt) */
#define UFFS_LAYOUT_UFFS	0	//!< do layout by dev->attr information
#define UFFS_LAYOUT_FLASH	1	//!< flash driver do the layout

#define UFFS_SPARE_LAYOUT_SIZE	6	//!< maximum spare layout array size, 2 segments

/** flash operation return code */
#define UFFS_FLASH_NO_ERR		0		//!< no error
#define UFFS_FLASH_ECC_OK		1		//!< bit-flip found, but corrected by ECC
#define UFFS_FLASH_NOT_SEALED	2		//!< page spare area is not sealed properly (only for ReadPageWithLayout())
#define UFFS_FLASH_IO_ERR		-1		//!< I/O error
#define UFFS_FLASH_ECC_FAIL		-2		//!< ECC failed
#define UFFS_FLASH_BAD_BLK		-3		//!< bad block
#define UFFS_FLASH_CRC_ERR		-4		//!< CRC failed
#define UFFS_FLASH_UNKNOWN_ERR	-100	//!< unkown error?

#define UFFS_FLASH_HAVE_ERR(e)		((e) < 0)

#if defined(CONFIG_BAD_BLOCK_POLICY_STRICT)
# define UFFS_FLASH_IS_BAD_BLOCK(e)	\
	((e) == UFFS_FLASH_ECC_FAIL || (e) == UFFS_FLASH_ECC_OK || (e) == UFFS_FLASH_BAD_BLK || (e) == UFFS_FLASH_CRC_ERR)
#else
# define UFFS_FLASH_IS_BAD_BLOCK(e)	\
	((e) == UFFS_FLASH_ECC_FAIL || (e) == UFFS_FLASH_BAD_BLK || (e) == UFFS_FLASH_CRC_ERR)<commit_msg>Enlarge ECC/DATA layout array size.<commit_after>/*
  This file is part of UFFS, the Ultra-low-cost Flash File System.
  
  Copyright (C) 2005-2009 <NAME> <<EMAIL>>

  UFFS is free software; you can redistribute it and/or modify it under
  the GNU Library General Public License as published by the Free Software 
  Foundation; either version 2 of the License, or (at your option) any
  later version.

  UFFS is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  or GNU Library General Public License, as applicable, for more details.
 
  You should have received a copy of the GNU General Public License
  and GNU Library General Public License along with UFFS; if not, write
  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA  02110-1301, USA.

  As a special exception, if other files instantiate templates or use
  macros or inline functions from this file, or you compile this file
  and link it with other works to produce a work based on this file,
  this file does not by itself cause the resulting work to be covered
  by the GNU General Public License. However the source code for this
  file must still be made available in accordance with section (3) of
  the GNU General Public License v2.
 
  This exception does not invalidate any other reasons why a work based
  on this file might be covered by the GNU General Public License.
*/

/** 
 * \file uffs_public.h
 * \brief flash interface for UFFS
 * \author <NAME>
 */

#ifndef _UFFS_FLASH_H_
#define _UFFS_FLASH_H_

#include "uffs/uffs_types.h"
#include "uffs/uffs_core.h"
#include "uffs/uffs_device.h"
#include "uffs/uffs_fs.h"

#ifdef __cplusplus
extern "C"{
#endif


/** ECC options (uffs_StorageAttrSt.ecc_opt) */
#define UFFS_ECC_NONE		0	//!< do not use ECC
#define UFFS_ECC_SOFT		1	//!< UFFS calculate the ECC
#define UFFS_ECC_HW			2	//!< Flash driver(or by hardware) calculate the ECC
#define UFFS_ECC_HW_AUTO	3	//!< Hardware calculate the ECC and automatically write to spare.

#define UFFS_ECC_OPTION_STRING \
	{ "none", "soft", "hw", "auto" }	// index is the ecc option value.

/** spare layout options (uffs_StorageAttrSt.layout_opt) */
#define UFFS_LAYOUT_UFFS	0	//!< do layout by dev->attr information
#define UFFS_LAYOUT_FLASH	1	//!< flash driver do the layout

#define UFFS_SPARE_LAYOUT_SIZE	16	//!< maximum spare layout array size, 2 segments

/** flash operation return code */
#define UFFS_FLASH_NO_ERR		0		//!< no error
#define UFFS_FLASH_ECC_OK		1		//!< bit-flip found, but corrected by ECC
#define UFFS_FLASH_NOT_SEALED	2		//!< page spare area is not sealed properly (only for ReadPageWithLayout())
#define UFFS_FLASH_IO_ERR		-1		//!< I/O error
#define UFFS_FLASH_ECC_FAIL		-2		//!< ECC failed
#define UFFS_FLASH_BAD_BLK		-3		//!< bad block
#define UFFS_FLASH_CRC_ERR		-4		//!< CRC failed
#define UFFS_FLASH_UNKNOWN_ERR	-100	//!< unkown error?

#define UFFS_FLASH_HAVE_ERR(e)		((e) < 0)

#if defined(CONFIG_BAD_BLOCK_POLICY_STRICT)
# define UFFS_FLASH_IS_BAD_BLOCK(e)	\
	((e) == UFFS_FLASH_ECC_FAIL || (e) == UFFS_FLASH_ECC_OK || (e) == UFFS_FLASH_BAD_BLK || (e) == UFFS_FLASH_CRC_ERR)
#else
# define UFFS_FLASH_IS_BAD_BLOCK(e)	\
	((e) == UFFS_FLASH_ECC_FAIL || (e) == UFFS_FLASH_BAD_BLK || (e) == UFFS_FLASH_CRC_ERR)
{'fraction_non_alphanumeric': 0.08541451160041377, 'fraction_numerical': 0.012265405645042117, 'mean_word_length': 4.115646258503402, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3868836', 'n_tokens_mistral': 2450, 'n_tokens_neox': 2349, 'n_words': 865}