Changeset 542d350e in rtems


Ignore:
Timestamp:
Jul 4, 2011, 9:26:19 AM (8 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.
Location:
c/src/lib/libbsp/arm/lpc32xx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/lpc32xx/ChangeLog

    r7032a458 r542d350e  
     12011-07-04      Sebastian Huber <sebastian.huber@embedded-brains.de>
     2
     3        * misc/nand-mlc-erase-block-safe.c, misc/nand-mlc-write-blocks.c,
     4        include/nand-mlc.h: Fixed write blocks.
     5
    162011-07-01      Stephan Hoffmann <sho@reLinux.de>
    27                Sebastian Huber <sebastian.huber@embedded-brains.de>
  • c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h

    r7032a458 r542d350e  
    287287 *
    288288 * Variant of lpc32xx_mlc_erase_block_safe() with more parameters for
    289  * efficiency reasons.
     289 * efficiency reasons.  The @a page_begin must be the index of the first page
     290 * of the block.  The @a page_end must be the page index of the last page of
     291 * the block plus one.
    290292 */
    291293rtems_status_code lpc32xx_mlc_erase_block_safe_3(
    292294  uint32_t block_index,
    293   uint32_t first_page_of_block,
    294   uint32_t pages_per_block
    295 );
     295  uint32_t page_begin,
     296  uint32_t page_end
     297);
     298
     299/**
     300 * @brief Writes zero values to the pages specified by @a page_begin and
     301 * @a page_end.
     302 *
     303 * The data and spare area are cleared to zero.  This marks the pages as bad.
     304 */
     305void lpc32xx_mlc_zero_pages(uint32_t page_begin, uint32_t page_end);
    296306
    297307/**
  • 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}
  • c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-write-blocks.c

    r7032a458 r542d350e  
    6464
    6565  for (block = block_begin; block != block_end; ++block) {
    66     uint32_t first_page_of_block = block * pages_per_block;
     66    uint32_t page_begin = block * pages_per_block;
     67    uint32_t page_end = page_begin + pages_per_block;
    6768    uint32_t page = 0;
    6869
    69     sc = lpc32xx_mlc_erase_block_safe_3(
    70       block,
    71       first_page_of_block,
    72       pages_per_block
    73     );
     70    sc = lpc32xx_mlc_erase_block_safe_3(block, page_begin, page_end);
    7471    if (sc != RTEMS_SUCCESSFUL) {
    7572      continue;
    7673    }
    7774
    78     for (page = 0; page < pages_per_block; ++page) {
     75    for (page = page_begin; page < page_end; ++page) {
    7976      uintptr_t remainder = (uintptr_t) end - (uintptr_t) current;
    8077      size_t delta = remainder < page_size ? remainder : page_size;
     
    8380        memcpy(page_data_buffer, current, delta);
    8481        sc = lpc32xx_mlc_write_page_with_ecc(
    85           first_page_of_block + page,
     82          page,
    8683          page_data_buffer,
    8784          ones_spare
    8885        );
    8986        if (sc != RTEMS_SUCCESSFUL) {
    90           erase_block(block, first_page_of_block, pages_per_block);
    91           zero_block(first_page_of_block, pages_per_block);
     87          lpc32xx_mlc_erase_block_safe_3(block, page_begin, page_end);
     88          lpc32xx_mlc_zero_pages(page_begin, page_end);
    9289          current = last;
    9390          continue;
Note: See TracChangeset for help on using the changeset viewer.