Ignore:
Timestamp:
Jul 4, 2011, 9:26:19 AM (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
9f816ad4
Parents:
7032a458
Message:

2011-07-04 Sebastian Huber <sebastian.huber@…>

  • misc/nand-mlc-erase-block-safe.c, misc/nand-mlc-write-blocks.c, include/nand-mlc.h: Fixed write blocks.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-erase-block-safe.c

    r7032a458 r542d350e  
    44 * @ingroup lpc32xx_nand_mlc
    55 *
    6  * @brief lpc32xx_mlc_erase_block_safe() and lpc32xx_mlc_erase_block_safe_3()
    7  * implementation.
     6 * @brief lpc32xx_mlc_erase_block_safe(), lpc32xx_mlc_erase_block_safe_3(), and
     7 * lpc32xx_mlc_zero_block() implementation.
    88 */
    99
     
    2828#include <bsp.h>
    2929
    30 static void zero_block(uint32_t first_page_of_block, uint32_t pages_per_block)
     30void lpc32xx_mlc_zero_pages(uint32_t page_begin, uint32_t page_end)
    3131{
    3232  uint32_t page = 0;
    3333
    34   for (page = 0; page < pages_per_block; ++page) {
     34  for (page = page_begin; page < page_end; ++page) {
    3535    lpc32xx_mlc_write_page_with_ecc(
    36       first_page_of_block + page,
     36      page,
    3737      lpc32xx_magic_zero_begin,
    3838      lpc32xx_magic_zero_begin
     
    4242
    4343static bool is_bad_page(
    44   uint32_t first_page_of_block,
    45   uint32_t page
     44  uint32_t page_begin,
     45  uint32_t page_offset
    4646)
    4747{
     
    5050  memset(spare, 0, MLC_LARGE_SPARE_SIZE);
    5151  lpc32xx_mlc_read_page(
    52     first_page_of_block + page,
     52    page_begin + page_offset,
    5353    lpc32xx_magic_zero_begin,
    5454    spare
     
    5959rtems_status_code lpc32xx_mlc_erase_block_safe_3(
    6060  uint32_t block_index,
    61   uint32_t first_page_of_block,
    62   uint32_t pages_per_block
     61  uint32_t page_begin,
     62  uint32_t page_end
    6363)
    6464{
    6565  rtems_status_code sc = RTEMS_SUCCESSFUL;
    6666
    67   if (is_bad_page(first_page_of_block, 0)) {
     67  if (is_bad_page(page_begin, 0)) {
    6868    return RTEMS_INCORRECT_STATE;
    6969  }
    7070
    71   if (is_bad_page(first_page_of_block, 1)) {
     71  if (is_bad_page(page_begin, 1)) {
    7272    return RTEMS_INCORRECT_STATE;
    7373  }
     
    7575  sc = lpc32xx_mlc_erase_block(block_index);
    7676  if (sc != RTEMS_SUCCESSFUL) {
    77     zero_block(first_page_of_block, pages_per_block);
     77    lpc32xx_mlc_zero_pages(page_begin, page_end);
    7878
    7979    return RTEMS_IO_ERROR;
     
    8686{
    8787  uint32_t pages_per_block = lpc32xx_mlc_pages_per_block();
     88  uint32_t page_begin = block_index * pages_per_block;
     89  uint32_t page_end = page_begin + pages_per_block;
    8890
    8991  return lpc32xx_mlc_erase_block_safe_3(
    9092    block_index,
    91     block_index * pages_per_block,
    92     pages_per_block
     93    page_begin,
     94    page_end
    9395  );
    9496}
Note: See TracChangeset for help on using the changeset viewer.