1 /***************************************************************************
2 * Copyright (C) 2008 Øyvind Harboe *
3 * oyvind.harboe@zylin.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
22 #define _FLASH_PRIVATE_
23 #include <cyg/io/flash.h>
27 int myprintf(char *format, ...)
32 extern char _start_bss_clear;
33 extern char __bss_end__;
37 // set up runtime environment
39 for (t=&_start_bss_clear; t<&__bss_end__; t++)
43 return flash_init((_printf *)&myprintf);
48 int checkFlash(void *addr, int len)
50 // Return error for illegal addresses
51 if ((addr<flash_info.start)||(addr>flash_info.end))
52 return FLASH_ERR_INVALID;
53 if ((((cyg_uint8 *)addr)+len)>(cyg_uint8 *)flash_info.end)
54 return FLASH_ERR_INVALID;
59 int erase(void *address, int len)
64 retval=checkFlash(address, len);
71 return flash_erase(address, len, &failAddress);
78 // Data follows immediately after program, long word aligned.
79 int program(void *buffer, void *address, int len)
83 retval=checkFlash(address, len);
90 //int flash_program(void *_addr, void *_data, int len, void **err_addr)
91 return flash_program(address, buffer, len, &failAddress);