FlashOS.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Copyright (c) 2010 - 2018 Arm Ltd.
  2. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. - Redistributions of source code must retain the above copyright
  6. notice, this list of conditions and the following disclaimer.
  7. - Redistributions in binary form must reproduce the above copyright
  8. notice, this list of conditions and the following disclaimer in the
  9. documentation and/or other materials provided with the distribution.
  10. - Neither the name of Arm nor the names of its contributors may be used
  11. to endorse or promote products derived from this software without
  12. specific prior written permission.
  13. *
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  15. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17. ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
  18. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  19. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  20. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  21. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  22. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  23. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  24. POSSIBILITY OF SUCH DAMAGE.
  25. ---------------------------------------------------------------------------*/
  26. /***********************************************************************/
  27. /* */
  28. /* FlashOS.h: Data structures and entries */
  29. /* for Flash Programming Functions */
  30. /* */
  31. /***********************************************************************/
  32. #define VERS 1 // Interface Version 1.01
  33. #define UNKNOWN 0 // Unknown
  34. #define ONCHIP 1 // On-chip Flash Memory
  35. #define EXT8BIT 2 // External Flash Device on 8-bit Bus
  36. #define EXT16BIT 3 // External Flash Device on 16-bit Bus
  37. #define EXT32BIT 4 // External Flash Device on 32-bit Bus
  38. #define EXTSPI 5 // External Flash Device on SPI
  39. #define SECTOR_NUM 512 // Max Number of Sector Items
  40. #define PAGE_MAX 65536 // Max Page Size for Programming
  41. struct FlashSectors {
  42. unsigned long szSector; // Sector Size in Bytes
  43. unsigned long AddrSector; // Address of Sector
  44. };
  45. #define SECTOR_END 0xFFFFFFFF, 0xFFFFFFFF
  46. struct FlashDevice {
  47. unsigned short Vers; // Version Number and Architecture
  48. char DevName[128]; // Device Name and Description
  49. unsigned short DevType; // Device Type: ONCHIP, EXT8BIT, EXT16BIT, ...
  50. unsigned long DevAdr; // Default Device Start Address
  51. unsigned long szDev; // Total Size of Device
  52. unsigned long szPage; // Programming Page Size
  53. unsigned long Res; // Reserved for future Extension
  54. unsigned char valEmpty; // Content of Erased Memory
  55. unsigned long toProg; // Time Out of Program Page Function
  56. unsigned long toErase; // Time Out of Erase Sector Function
  57. struct FlashSectors sectors[SECTOR_NUM];
  58. };
  59. #define FLASH_DRV_VERS (0x0100+VERS) // Driver Version, do not modify!
  60. // Flash Programming Functions (Called by FlashOS)
  61. extern int Init (unsigned long adr, // Initialize Flash
  62. unsigned long clk,
  63. unsigned long fnc);
  64. extern int UnInit (unsigned long fnc); // De-initialize Flash
  65. extern int BlankCheck (unsigned long adr, // Blank Check
  66. unsigned long sz,
  67. unsigned char pat);
  68. extern int EraseChip (void); // Erase complete Device
  69. extern int EraseSector (unsigned long adr); // Erase Sector Function
  70. extern int ProgramPage (unsigned long adr, // Program Page Function
  71. unsigned long sz,
  72. unsigned char *buf);
  73. extern unsigned long Verify (unsigned long adr, // Verify Function
  74. unsigned long sz,
  75. unsigned char *buf);