Mercurial > flash_v2
comparison packages/io/flash/current/src/flash.c @ 1769:8667859d61ab
* src/flash_legacy.h: Undef HAL_FLASH_CACHES_* macros if the HAL
supplied them and they're not needed.
* cdl/io_flash.cdl, src/flash.c, src/flash_legacy.h,
src/legacy_dev.c: add support for V2 drivers which can take care
of the cache and interrupts themselves.
| author | jlarmour |
|---|---|
| date | Wed, 27 Sep 2006 14:24:46 +0000 |
| parents | 96ec7e534d98 |
| children |
comparison
equal
deleted
inserted
replaced
| 1768:ef75ad79dfe3 | 1769:8667859d61ab |
|---|---|
| 7 //========================================================================== | 7 //========================================================================== |
| 8 //####ECOSGPLCOPYRIGHTBEGIN#### | 8 //####ECOSGPLCOPYRIGHTBEGIN#### |
| 9 // ------------------------------------------- | 9 // ------------------------------------------- |
| 10 // This file is part of eCos, the Embedded Configurable Operating System. | 10 // This file is part of eCos, the Embedded Configurable Operating System. |
| 11 // Copyright (C) 2004 Andrew Lunn | 11 // Copyright (C) 2004 Andrew Lunn |
| 12 // Copyright (C) 2004 eCosCentric Ltd. | 12 // Copyright (C) 2004, 2005, 2006 eCosCentric Ltd. |
| 13 // Copyright (C) 2003 Gary Thomas | 13 // Copyright (C) 2003 Gary Thomas |
| 14 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. | 14 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
| 15 // | 15 // |
| 16 // eCos is free software; you can redistribute it and/or modify it under | 16 // eCos is free software; you can redistribute it and/or modify it under |
| 17 // the terms of the GNU General Public License as published by the Free | 17 // the terms of the GNU General Public License as published by the Free |
| 160 dev->next = flash_head; | 160 dev->next = flash_head; |
| 161 flash_head = dev; | 161 flash_head = dev; |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 // If there are no devices, abort. This could happen because none | 165 // If there are no valid devices, abort. This might happen if |
| 166 // of the devices initialised. | 166 // all drivers failed to initialize. |
| 167 if (flash_head == NULL) { | 167 if (flash_head == NULL) { |
| 168 return false; | 168 return false; |
| 169 } | 169 } |
| 170 | 170 |
| 171 // Sort the linked list into ascending order of flash address. Use a | 171 // Sort the linked list into ascending order of flash address. Use a |
| 291 // Return information about the Nth driver | 291 // Return information about the Nth driver |
| 292 __externC int | 292 __externC int |
| 293 cyg_flash_get_info(cyg_uint32 Nth, cyg_flash_info_t * info) | 293 cyg_flash_get_info(cyg_uint32 Nth, cyg_flash_info_t * info) |
| 294 { | 294 { |
| 295 struct cyg_flash_dev * dev; | 295 struct cyg_flash_dev * dev; |
| 296 | 296 |
| 297 if (!init) return CYG_FLASH_ERR_NOT_INIT; | 297 if (!init) return CYG_FLASH_ERR_NOT_INIT; |
| 298 | 298 |
| 299 #if (1 == CYGHWR_IO_FLASH_DEVICE) | 299 #if (1 == CYGHWR_IO_FLASH_DEVICE) |
| 300 if ((0 == Nth) && cyg_flashdevtab[0].init) { | 300 if ((0 == Nth) && cyg_flashdevtab[0].init) { |
| 301 dev = &(cyg_flashdevtab[0]); | 301 dev = &(cyg_flashdevtab[0]); |
| 437 { | 437 { |
| 438 cyg_flashaddr_t block, end_addr; | 438 cyg_flashaddr_t block, end_addr; |
| 439 struct cyg_flash_dev * dev; | 439 struct cyg_flash_dev * dev; |
| 440 size_t erase_count; | 440 size_t erase_count; |
| 441 int stat = CYG_FLASH_ERR_OK; | 441 int stat = CYG_FLASH_ERR_OK; |
| 442 int d_cache, i_cache; | 442 HAL_FLASH_CACHES_STATE(d_cache, i_cache); |
| 443 | 443 |
| 444 dev = find_dev(flash_base, &stat); | 444 dev = find_dev(flash_base, &stat); |
| 445 if (!dev) return stat; | 445 if (!dev) return stat; |
| 446 | 446 |
| 447 CHECK_SOFT_WRITE_PROTECT(flash_base, len); | 447 CHECK_SOFT_WRITE_PROTECT(flash_base, len); |
| 527 struct cyg_flash_dev * dev; | 527 struct cyg_flash_dev * dev; |
| 528 cyg_flashaddr_t addr, end_addr, block; | 528 cyg_flashaddr_t addr, end_addr, block; |
| 529 const unsigned char * ram = ram_base; | 529 const unsigned char * ram = ram_base; |
| 530 size_t write_count, offset; | 530 size_t write_count, offset; |
| 531 int stat = CYG_FLASH_ERR_OK; | 531 int stat = CYG_FLASH_ERR_OK; |
| 532 int d_cache, i_cache; | 532 HAL_FLASH_CACHES_STATE(d_cache, i_cache); |
| 533 | 533 |
| 534 dev = find_dev(flash_base, &stat); | 534 dev = find_dev(flash_base, &stat); |
| 535 if (!dev) return stat; | 535 if (!dev) return stat; |
| 536 | 536 |
| 537 CHECK_SOFT_WRITE_PROTECT(flash_base, len); | 537 CHECK_SOFT_WRITE_PROTECT(flash_base, len); |
| 641 } | 641 } |
| 642 #else | 642 #else |
| 643 // We have to indirect through the device driver. | 643 // We have to indirect through the device driver. |
| 644 // The first read may be in the middle of a block. Do the necessary | 644 // The first read may be in the middle of a block. Do the necessary |
| 645 // adjustment here rather than inside the loop. | 645 // adjustment here rather than inside the loop. |
| 646 int d_cache, i_cache; | |
| 647 size_t offset; | 646 size_t offset; |
| 648 cyg_flashaddr_t block = flash_block_begin(flash_base, dev); | 647 cyg_flashaddr_t block = flash_block_begin(flash_base, dev); |
| 648 HAL_FLASH_CACHES_STATE(d_cache, i_cache); | |
| 649 if (addr == block) { | 649 if (addr == block) { |
| 650 offset = 0; | 650 offset = 0; |
| 651 } else { | 651 } else { |
| 652 offset = addr - block; | 652 offset = addr - block; |
| 653 } | 653 } |
| 699 { | 699 { |
| 700 cyg_flashaddr_t block, end_addr; | 700 cyg_flashaddr_t block, end_addr; |
| 701 struct cyg_flash_dev * dev; | 701 struct cyg_flash_dev * dev; |
| 702 size_t lock_count; | 702 size_t lock_count; |
| 703 int stat = CYG_FLASH_ERR_OK; | 703 int stat = CYG_FLASH_ERR_OK; |
| 704 int d_cache, i_cache; | 704 HAL_FLASH_CACHES_STATE(d_cache, i_cache); |
| 705 | 705 |
| 706 dev = find_dev(flash_base, &stat); | 706 dev = find_dev(flash_base, &stat); |
| 707 if (!dev) return stat; | 707 if (!dev) return stat; |
| 708 if (!dev->funs->flash_block_lock) return CYG_FLASH_ERR_INVALID; | 708 if (!dev->funs->flash_block_lock) return CYG_FLASH_ERR_INVALID; |
| 709 | 709 |
| 762 { | 762 { |
| 763 cyg_flashaddr_t block, end_addr; | 763 cyg_flashaddr_t block, end_addr; |
| 764 struct cyg_flash_dev * dev; | 764 struct cyg_flash_dev * dev; |
| 765 size_t unlock_count; | 765 size_t unlock_count; |
| 766 int stat = CYG_FLASH_ERR_OK; | 766 int stat = CYG_FLASH_ERR_OK; |
| 767 int d_cache, i_cache; | 767 HAL_FLASH_CACHES_STATE(d_cache, i_cache); |
| 768 | 768 |
| 769 dev = find_dev(flash_base, &stat); | 769 dev = find_dev(flash_base, &stat); |
| 770 if (!dev) return stat; | 770 if (!dev) return stat; |
| 771 if (!dev->funs->flash_block_unlock) return CYG_FLASH_ERR_INVALID; | 771 if (!dev->funs->flash_block_unlock) return CYG_FLASH_ERR_INVALID; |
| 772 | 772 |
