URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/trunk/rtos/ecos-2.0/packages/devs/flash/arm/iq80310
- from Rev 27 to Rev 174
- ↔ Reverse comparison
Rev 27 → Rev 174
/v2_0/cdl/flash_iq80310.cdl
0,0 → 1,110
# ==================================================================== |
# |
# flash_iq80310.cdl |
# |
# FLASH memory - Hardware support on IQ80200/80310 |
# |
# ==================================================================== |
#####ECOSGPLCOPYRIGHTBEGIN#### |
## ------------------------------------------- |
## This file is part of eCos, the Embedded Configurable Operating System. |
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
## Copyright (C) 2002 Gary Thomas |
## |
## eCos is free software; you can redistribute it and/or modify it under |
## the terms of the GNU General Public License as published by the Free |
## Software Foundation; either version 2 or (at your option) any later version. |
## |
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
## WARRANTY; without even the implied warranty of MERCHANTABILITY or |
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
## for more details. |
## |
## You should have received a copy of the GNU General Public License along |
## with eCos; if not, write to the Free Software Foundation, Inc., |
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
## |
## As a special exception, if other files instantiate templates or use macros |
## or inline functions from this file, or you compile this file and link it |
## with other works to produce a work based on this file, this file does not |
## by itself cause the resulting work to be covered by the GNU General Public |
## License. However the source code for this file must still be made available |
## in accordance with section (3) of the GNU General Public License. |
## |
## This exception does not invalidate any other reasons why a work based on |
## this file might be covered by the GNU General Public License. |
## |
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
## at http://sources.redhat.com/ecos/ecos-license/ |
## ------------------------------------------- |
#####ECOSGPLCOPYRIGHTEND#### |
# ==================================================================== |
######DESCRIPTIONBEGIN#### |
# |
# Author(s): msalter |
# Original data: msalter, gthomas |
# Contributors: |
# Date: 2000-10-10 |
# |
#####DESCRIPTIONEND#### |
# |
# ==================================================================== |
|
cdl_package CYGPKG_DEVS_FLASH_ARM_XSCALE_IQ80310 { |
display "Cyclone IQ80310 FLASH memory support" |
|
parent CYGPKG_IO_FLASH |
active_if CYGPKG_IO_FLASH |
requires CYGPKG_HAL_ARM_XSCALE_IOP310 |
|
implements CYGHWR_IO_FLASH_DEVICE |
implements CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM |
implements CYGHWR_IO_FLASH_BLOCK_LOCKING |
|
include_dir . |
include_files ; # none _exported_ whatsoever |
description "FLASH memory device support for Cyclone IQ80310" |
compile iq80310_flash.c |
|
make -priority 1 { |
flash_erase_block.o: $(REPOSITORY)/$(PACKAGE)/src/flash_erase_block.c |
$(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_erase_block.c |
echo " .globl flash_erase_block_end" >>flash_erase_block.s |
echo "flash_erase_block_end:" >>flash_erase_block.s |
$(CC) $(CFLAGS) -c -o flash_erase_block.o flash_erase_block.s |
$(AR) rcs $(PREFIX)/lib/libtarget.a flash_erase_block.o |
} |
make -priority 1 { |
flash_program_buf.o: $(REPOSITORY)/$(PACKAGE)/src/flash_program_buf.c |
$(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_program_buf.c |
echo " .globl flash_program_buf_end" >>flash_program_buf.s |
echo "flash_program_buf_end:" >>flash_program_buf.s |
$(CC) $(CFLAGS) -c -o flash_program_buf.o flash_program_buf.s |
$(AR) rcs $(PREFIX)/lib/libtarget.a flash_program_buf.o |
} |
make -priority 1 { |
flash_query.o: $(REPOSITORY)/$(PACKAGE)/src/flash_query.c |
$(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_query.c |
echo " .globl flash_query_end" >>flash_query.s |
echo "flash_query_end:" >>flash_query.s |
$(CC) $(CFLAGS) -c -o flash_query.o flash_query.s |
$(AR) rcs $(PREFIX)/lib/libtarget.a flash_query.o |
} |
make -priority 1 { |
flash_lock_block.o: $(REPOSITORY)/$(PACKAGE)/src/flash_lock_block.c |
$(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_lock_block.c |
echo " .globl flash_lock_block_end" >>flash_lock_block.s |
echo "flash_lock_block_end:" >>flash_lock_block.s |
$(CC) $(CFLAGS) -c -o flash_lock_block.o flash_lock_block.s |
$(AR) rcs $(PREFIX)/lib/libtarget.a flash_lock_block.o |
} |
make -priority 1 { |
flash_unlock_block.o: $(REPOSITORY)/$(PACKAGE)/src/flash_unlock_block.c |
$(CC) -S $(INCLUDE_PATH) $(CFLAGS) -g0 -fno-function-sections $(REPOSITORY)/$(PACKAGE)/src/flash_unlock_block.c |
echo " .globl flash_unlock_block_end" >>flash_unlock_block.s |
echo "flash_unlock_block_end:" >>flash_unlock_block.s |
$(CC) $(CFLAGS) -c -o flash_unlock_block.o flash_unlock_block.s |
$(AR) rcs $(PREFIX)/lib/libtarget.a flash_unlock_block.o |
} |
} |
|
/v2_0/ChangeLog
0,0 → 1,81
2002-11-12 Gary Thomas <gary@mlbassoc.com> |
|
* cdl/flash_iq80310.cdl: New Xscale platforms layout. |
|
2002-04-16 Jonathan Larmour <jlarmour@redhat.com> |
|
* cdl/flash_iq80310.cdl: Invoke $(CC) with $(CFLAGS) to ensure the |
correct flags are passed. |
|
2001-09-28 Jonathan Larmour <jlarmour@redhat.com> |
|
* src/iq80310_flash.c (flash_hwr_init): Only re-enable icache if it |
was enabled before. |
|
2001-08-04 Mark Salter <msalter@redhat.com> |
|
* src/flash.h (FLASH_P2V): First 4K of flash now mapped at 0xd0000000. |
|
2001-06-11 Gary Thomas <gthomas@redhat.com> |
|
* src/iq80310_flash.c: Remove dependency on printf() via user functions. |
|
2001-05-23 Jesper Skov <jskov@redhat.com> |
|
* cdl/flash_iq80310.cdl: Needs IO controller to copy functions to |
RAM. |
|
2000-12-05 Jonathan Larmour <jlarmour@redhat.com> |
|
* src/iq80310_flash.c (flash_code_overlaps): Define stext/etext |
as array types so no assumptions can be made by the compiler about |
location. |
|
2000-11-22 Mark Salter <msalter@redhat.com> |
|
* src/flash_unlock_block.c (flash_unlock_block): Fix broken |
read of lock bits. |
|
2000-11-19 Mark Salter <msalter@redhat.com> |
|
* src/flash_unlock_block.c (flash_unlock_block): Fix lock state |
query to properly use FLASH_P2V macro. Don't issue lock state |
query for block we are unlocking. |
|
* src/flash_program_buf.c (flash_program_buf): Fix code to skip |
over Yavapai registers in flash memory space. |
|
//=========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//=========================================================================== |
/v2_0/src/flash_lock_block.c
0,0 → 1,96
//========================================================================== |
// |
// flash_lock_block.c |
// |
// Flash programming |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas, msalter |
// Date: 2000-09-10 |
// Purpose: |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#include "flash.h" |
|
#include <cyg/hal/hal_cache.h> |
|
// |
// CAUTION! This code must be copied to RAM before execution. Therefore, |
// it must not contain any code which might be position dependent! |
// |
|
int |
flash_lock_block(volatile unsigned char *block) |
{ |
volatile unsigned char *ROM; |
unsigned short stat; |
int timeout = 5000000; |
int cache_on; |
|
ROM = FLASH_P2V((unsigned long)block & 0xFF800000); |
|
HAL_DCACHE_IS_ENABLED(cache_on); |
if (cache_on) { |
HAL_DCACHE_SYNC(); |
HAL_DCACHE_DISABLE(); |
} |
|
// Clear any error conditions |
ROM[0] = FLASH_Clear_Status; |
|
// Set lock bit |
FLASH_P2V(block)[0] = FLASH_Set_Lock; |
FLASH_P2V(block)[0] = FLASH_Set_Lock_Confirm; // Confirmation |
while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { |
if (--timeout == 0) break; |
} |
|
// Restore ROM to "normal" mode |
ROM[0] = FLASH_Reset; |
|
if (cache_on) { |
HAL_DCACHE_ENABLE(); |
} |
|
return stat; |
} |
/v2_0/src/flash_program_buf.c
0,0 → 1,156
//========================================================================== |
// |
// flash_program_buf.c |
// |
// Flash programming |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas, msalter |
// Date: 2000-07-14 |
// Purpose: |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#include "flash.h" |
|
#include <pkgconf/hal.h> |
#include <cyg/hal/hal_arch.h> |
#include <cyg/hal/hal_cache.h> |
|
// |
// CAUTION! This code must be copied to RAM before execution. Therefore, |
// it must not contain any code which might be position dependent! |
// |
|
int |
flash_program_buf(volatile unsigned char *addr, unsigned char *data, int len) |
{ |
volatile unsigned char *ROM; |
volatile unsigned char *BA; |
unsigned short stat; |
int timeout = 5000000; |
int i, wc, cache_on; |
|
HAL_DCACHE_IS_ENABLED(cache_on); |
if (cache_on) { |
HAL_DCACHE_SYNC(); |
HAL_DCACHE_DISABLE(); |
} |
|
ROM = FLASH_P2V((unsigned long)addr & 0xFF800000); |
BA = FLASH_P2V((unsigned long)addr & 0xFFFE0000); |
|
// Clear any error conditions |
ROM[0] = FLASH_Clear_Status; |
|
wc = 32; |
while (len >= wc) { |
len -= wc; |
|
// The IQ803010 has a hole in flash which must be avoided. |
if (((unsigned char *)0x1000) <= addr && addr < ((unsigned char *)0x2000)) { |
addr += wc; |
data += wc; |
continue; |
} |
|
*BA = FLASH_Write_Buffer; |
timeout = 5000000; |
while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { |
if (--timeout == 0) { |
stat |= 0x0100; |
goto bad; |
} |
*BA = FLASH_Write_Buffer; |
} |
*BA = wc-1; // Count is 0..N-1 |
if (FLASH_P2V(addr) != addr) { |
volatile unsigned char *tmp; |
|
tmp = FLASH_P2V(addr); |
for (i = 0; i < wc; i++) |
*tmp++ = *data++; |
addr += wc; |
} else { |
for (i = 0; i < wc; i++) |
*addr++ = *data++; |
} |
*BA = FLASH_Confirm; |
stat = *BA; |
} |
|
ROM[0] = FLASH_Read_Status; |
timeout = 5000000; |
while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { |
if (--timeout == 0) { |
stat |= 0x0200; |
goto bad; |
} |
} |
|
while (len > 0) { |
ROM[0] = FLASH_Program; |
|
*FLASH_P2V(addr) = *data++; |
addr++; |
timeout = 5000000; |
while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { |
if (--timeout == 0) { |
stat |= 0x0300; |
goto bad; |
} |
} |
--len; |
} |
|
// Restore ROM to "normal" mode |
bad: |
ROM[0] = FLASH_Reset; |
|
if (cache_on) { |
HAL_DCACHE_ENABLE(); |
} |
|
return stat; |
} |
|
|
/v2_0/src/flash.h
0,0 → 1,106
//========================================================================== |
// |
// flash.h |
// |
// Flash programming - device constants, etc. |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas, msalter |
// Date: 2000-07-26 |
// Purpose: |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#ifndef _FLASH_HWR_H_ |
#define _FLASH_HWR_H_ |
|
// First 4K page of flash at physical address zero is |
// virtually mapped at address 0xa0000000. |
#define FLASH_P2V(x) ((volatile unsigned char *)(((unsigned)(x) < 0x1000) ? \ |
((unsigned)(x) | 0xd0000000) : \ |
(unsigned)(x))) |
|
#define FLASH_BOOT_BLOCK_SIZE 0x4000 |
|
#define FLASH_Intel_code 0x89 |
|
#define FLASH_Read_ID 0x90 |
#define FLASH_Read_Query 0x98 |
#define FLASH_Read_Status 0x70 |
#define FLASH_Clear_Status 0x50 |
#define FLASH_Status_Ready 0x80 |
#define FLASH_Write_Buffer 0xE8 |
#define FLASH_Program 0x10 |
#define FLASH_Block_Erase 0x20 |
#define FLASH_Set_Lock 0x60 |
#define FLASH_Set_Lock_Confirm 0x01 |
#define FLASH_Clear_Locks 0x60 |
#define FLASH_Clear_Locks_Confirm 0xD0 |
#define FLASH_Confirm 0xD0 |
#define FLASH_Configure 0xB8 |
#define FLASH_Configure_ReadyWait 0x00 |
#define FLASH_Configure_PulseOnErase 0x01 |
#define FLASH_Configure_PulseOnProgram 0x02 |
#define FLASH_Configure_PulseOnBoth 0x03 |
#define FLASH_Reset 0xFF |
|
#define FLASH_BLOCK_SIZE 0x10000 |
#define FLASH_WBUF_SIZE 32 |
|
#define FLASH_Intel_code 0x89 |
|
// Extended query information |
struct FLASH_query { |
unsigned char manuf_code; |
unsigned char device_code; |
unsigned char _unused0[14]; |
unsigned char id[3]; // Q Q R |
unsigned char _unused1[20]; |
unsigned char device_size; |
unsigned char device_interface[2]; |
unsigned char buffer_size[2]; |
unsigned char is_block_oriented; |
unsigned char num_regions[2]; |
unsigned char region_size[2]; |
}; |
|
#endif // _FLASH_HWR_H_ |
/v2_0/src/flash_query.c
0,0 → 1,94
//========================================================================== |
// |
// flash_query.c |
// |
// Flash programming - query device |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas |
// Date: 2000-07-26 |
// Purpose: |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#include "flash.h" |
|
#include <pkgconf/hal.h> |
#include <cyg/hal/hal_arch.h> |
#include <cyg/hal/hal_cache.h> |
#include CYGHWR_MEMORY_LAYOUT_H |
|
// |
// CAUTION! This code must be copied to RAM before execution. Therefore, |
// it must not contain any code which might be position dependent! |
// |
|
#define CNT 200*1000*10 // Approx 20ms |
|
int |
flash_query(unsigned char *data) |
{ |
volatile unsigned short *ROM; |
int i, cnt; |
int cache_on; |
|
HAL_DCACHE_IS_ENABLED(cache_on); |
if (cache_on) { |
HAL_DCACHE_SYNC(); |
HAL_DCACHE_DISABLE(); |
} |
|
ROM = FLASH_P2V(0); |
ROM[0] = FLASH_Read_Query; |
for (cnt = CNT; cnt > 0; cnt--) ; |
for (i = 0; i < sizeof(struct FLASH_query); i++) { |
*data++ = ROM[i]; |
} |
|
ROM[0] = FLASH_Reset; |
|
if (cache_on) { |
HAL_DCACHE_ENABLE(); |
} |
|
return 0; |
} |
/v2_0/src/flash_unlock_block.c
0,0 → 1,136
//========================================================================== |
// |
// flash_unlock_block.c |
// |
// Flash programming |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas, msalter |
// Date: 2000-09-10 |
// Purpose: |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#include "flash.h" |
|
#include <cyg/hal/hal_cache.h> |
|
// |
// CAUTION! This code must be copied to RAM before execution. Therefore, |
// it must not contain any code which might be position dependent! |
// |
|
// |
// The difficulty with this operation is that the hardware does not support |
// unlocking single blocks. However, the logical layer would like this to |
// be the case, so this routine emulates it. The hardware can clear all of |
// the locks in the device at once. This routine will use that approach and |
// then reset the regions which are known to be locked. |
// |
|
#define MAX_FLASH_BLOCKS 128 |
|
int |
flash_unlock_block(volatile unsigned char *block, int block_size, int blocks) |
{ |
volatile unsigned short *ROM, *bp; |
unsigned short stat; |
int timeout = 5000000; |
unsigned short is_locked[MAX_FLASH_BLOCKS]; |
int i, cache_on; |
|
HAL_DCACHE_IS_ENABLED(cache_on); |
if (cache_on) { |
HAL_DCACHE_SYNC(); |
HAL_DCACHE_DISABLE(); |
} |
|
ROM = FLASH_P2V((unsigned long)block & 0xFF800000); |
|
// Clear any error conditions |
ROM[0] = FLASH_Clear_Status; |
|
// Get current block lock state. This needs to access each block on |
// the device so currently locked blocks can be re-locked. |
bp = (unsigned short *)((unsigned long)block & 0xFF800000); |
for (i = 0; i < blocks; i++) { |
if (bp == block) { |
is_locked[i] = 0; |
} else { |
*(volatile unsigned short *)FLASH_P2V(bp) = FLASH_Read_Query; |
is_locked[i] = ((volatile unsigned short *)FLASH_P2V(bp))[2]; |
} |
bp += block_size / sizeof(*bp); |
} |
|
// Clears all lock bits |
FLASH_P2V(block)[0] = FLASH_Clear_Locks; |
FLASH_P2V(block)[0] = FLASH_Clear_Locks_Confirm; // Confirmation |
timeout = 5000000; |
while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { |
if (--timeout == 0) goto done; |
} |
|
// Restore the lock state |
bp = (unsigned char *)((unsigned long)block & 0xFF800000); |
for (i = 0; i < blocks; i++) { |
if (is_locked[i]) { |
*FLASH_P2V(bp) = FLASH_Set_Lock; |
*FLASH_P2V(bp) = FLASH_Set_Lock_Confirm; // Confirmation |
timeout = 5000000; |
while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { |
if (--timeout == 0) goto done; |
} |
} |
bp += block_size / sizeof(*bp); |
} |
|
done: |
// Restore ROM to "normal" mode |
ROM[0] = FLASH_Reset; |
|
if (cache_on) { |
HAL_DCACHE_ENABLE(); |
} |
|
return stat; |
} |
/v2_0/src/iq80310_flash.c
0,0 → 1,132
//========================================================================== |
// |
// iq80310_flash.c |
// |
// Flash programming |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas, msalter |
// Date: 2000-07-26 |
// Purpose: |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#include <pkgconf/hal.h> |
#include <cyg/hal/hal_arch.h> |
#include <cyg/hal/hal_cache.h> |
|
#define _FLASH_PRIVATE_ |
#include <cyg/io/flash.h> |
|
#include "flash.h" |
|
#define _si(p) ((p[1]<<8)|p[0]) |
|
int |
flash_hwr_init(void) |
{ |
struct FLASH_query data, *qp; |
extern char flash_query, flash_query_end; |
typedef int code_fun(unsigned char *); |
code_fun *_flash_query; |
int code_len, stat, num_regions, region_size, icache_isenabled; |
|
// Copy 'program' code to RAM for execution |
code_len = (unsigned long)&flash_query_end - (unsigned long)&flash_query; |
_flash_query = (code_fun *)flash_info.work_space; |
memcpy(_flash_query, &flash_query, code_len); |
HAL_ICACHE_IS_ENABLED(icache_isenabled); |
HAL_DCACHE_SYNC(); // Should guarantee this code will run |
HAL_ICACHE_DISABLE(); // is also required to avoid old contents |
|
memset(&data,0,sizeof(data)); |
stat = (*_flash_query)((void*)&data); |
if (icache_isenabled) |
HAL_ICACHE_ENABLE(); |
|
qp = &data; |
if (/*(qp->manuf_code == FLASH_Intel_code) && */ |
(strncmp(qp->id, "QRY", 3) == 0)) { |
num_regions = _si(qp->num_regions)+1; |
region_size = _si(qp->region_size)*256; |
|
flash_info.block_size = region_size; |
flash_info.blocks = num_regions; |
flash_info.start = (void *)0x00000000; |
flash_info.end = (void *)(0x00000000+(num_regions*region_size)); |
return FLASH_ERR_OK; |
} else { |
(*flash_info.pf)("Can't identify FLASH sorry\n"); |
diag_dump_buf(data, sizeof(data)); |
return FLASH_ERR_HWR; |
} |
} |
|
// Map a hardware status to a package error |
int |
flash_hwr_map_error(int err) |
{ |
if (err & 0x7E) { |
(*flash_info.pf)("Err = %x\n", err); |
if (err & 0x10) { |
return FLASH_ERR_PROGRAM; |
} else |
if (err & 0x20) { |
return FLASH_ERR_ERASE; |
} else |
return FLASH_ERR_HWR; // FIXME |
} else { |
return FLASH_ERR_OK; |
} |
} |
|
// See if a range of FLASH addresses overlaps currently running code |
bool |
flash_code_overlaps(void *start, void *end) |
{ |
extern char _stext[], _etext[]; |
|
return ((((unsigned long)&_stext >= (unsigned long)start) && |
((unsigned long)&_stext < (unsigned long)end)) || |
(((unsigned long)&_etext >= (unsigned long)start) && |
((unsigned long)&_etext < (unsigned long)end))); |
} |
/v2_0/src/flash_erase_block.c
0,0 → 1,114
//========================================================================== |
// |
// flash_erase_block.c |
// |
// Flash programming |
// |
//========================================================================== |
//####ECOSGPLCOPYRIGHTBEGIN#### |
// ------------------------------------------- |
// This file is part of eCos, the Embedded Configurable Operating System. |
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
// |
// eCos is free software; you can redistribute it and/or modify it under |
// the terms of the GNU General Public License as published by the Free |
// Software Foundation; either version 2 or (at your option) any later version. |
// |
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
// for more details. |
// |
// You should have received a copy of the GNU General Public License along |
// with eCos; if not, write to the Free Software Foundation, Inc., |
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
// |
// As a special exception, if other files instantiate templates or use macros |
// or inline functions from this file, or you compile this file and link it |
// with other works to produce a work based on this file, this file does not |
// by itself cause the resulting work to be covered by the GNU General Public |
// License. However the source code for this file must still be made available |
// in accordance with section (3) of the GNU General Public License. |
// |
// This exception does not invalidate any other reasons why a work based on |
// this file might be covered by the GNU General Public License. |
// |
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
// at http://sources.redhat.com/ecos/ecos-license/ |
// ------------------------------------------- |
//####ECOSGPLCOPYRIGHTEND#### |
//========================================================================== |
//#####DESCRIPTIONBEGIN#### |
// |
// Author(s): gthomas |
// Contributors: gthomas, msalter |
// Date: 2000-07-14 |
// Purpose: |
// Description: |
// |
//####DESCRIPTIONEND#### |
// |
//========================================================================== |
|
#include "flash.h" |
|
#include <pkgconf/hal.h> |
#include <cyg/hal/hal_arch.h> |
#include <cyg/hal/hal_cache.h> |
|
// |
// CAUTION! This code must be copied to RAM before execution. Therefore, |
// it must not contain any code which might be position dependent! |
// |
|
int flash_erase_block(volatile unsigned char *block) |
{ |
volatile unsigned char *ROM; |
unsigned short stat; |
int timeout = 50000; |
int cache_on; |
int len; |
|
HAL_DCACHE_IS_ENABLED(cache_on); |
if (cache_on) { |
HAL_DCACHE_SYNC(); |
HAL_DCACHE_DISABLE(); |
} |
|
|
// First 4K page of flash at physcial address zero is |
// virtually mapped to address 0xa0000000. |
ROM = FLASH_P2V((unsigned)block & 0xFF800000); |
|
// Clear any error conditions |
ROM[0] = FLASH_Clear_Status; |
|
// Erase block |
ROM[0] = FLASH_Block_Erase; |
*FLASH_P2V(block) = FLASH_Confirm; |
timeout = 5000000; |
while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { |
if (--timeout == 0) break; |
} |
|
// Restore ROM to "normal" mode |
ROM[0] = FLASH_Reset; |
|
// If an error was reported, see if the block erased anyway |
if (stat & 0x7E) { |
len = FLASH_BLOCK_SIZE; |
while (len > 0) { |
if (*FLASH_P2V(block) != 0xFF) |
break; |
block++; |
len -= sizeof(*block); |
} |
if (len == 0) stat = 0; |
} |
|
if (cache_on) { |
HAL_DCACHE_ENABLE(); |
} |
|
return stat; |
} |