changeset 1216:d1c242cb506b

* src/flash_erase_block.c (flash_erase_block): * src/flash_query.c (flash_query): * src/flash_program_buf.c (flash_program_buf): Put flash functions in RAM using section attributes instead of the old method. * src/sa1100mm_flash.c (flash_hwr_init): Use generic flash_query_dev.
author asl
date Sun, 14 Sep 2003 13:15:23 +0000
parents 52985887e49e
children 0e1c2770aa9d
files packages/devs/flash/arm/sa1100mm/current/ChangeLog packages/devs/flash/arm/sa1100mm/current/cdl/flash_sa1100mm.cdl packages/devs/flash/arm/sa1100mm/current/src/flash_erase_block.c packages/devs/flash/arm/sa1100mm/current/src/flash_program_buf.c packages/devs/flash/arm/sa1100mm/current/src/flash_query.c packages/devs/flash/arm/sa1100mm/current/src/sa1100mm_flash.c
diffstat 6 files changed, 21 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/packages/devs/flash/arm/sa1100mm/current/ChangeLog
+++ b/packages/devs/flash/arm/sa1100mm/current/ChangeLog
@@ -1,3 +1,11 @@
+2003-09-12  Jani Monoses <jani@iv.ro>
+
+	* src/flash_erase_block.c (flash_erase_block): 
+	* src/flash_query.c (flash_query): 
+	* src/flash_program_buf.c (flash_program_buf): Put flash functions
+	in RAM using section attributes instead of the old method.
+	* src/sa1100mm_flash.c (flash_hwr_init): Use generic flash_query_dev. 
+
 2002-04-03  Jani Monoses <jani@iv.ro>
 
 	* src/flash_erase_block.c (flash_erase_block): 
--- a/packages/devs/flash/arm/sa1100mm/current/cdl/flash_sa1100mm.cdl
+++ b/packages/devs/flash/arm/sa1100mm/current/cdl/flash_sa1100mm.cdl
@@ -57,36 +57,11 @@ cdl_package CYGPKG_DEVS_FLASH_SA1100MM {
     requires	  CYGPKG_HAL_ARM_SA11X0
 
     implements    CYGHWR_IO_FLASH_DEVICE
-    implements    CYGHWR_IO_FLASH_DEVICE_NOT_IN_RAM
 
     include_dir   .
     include_files ; # none _exported_ whatsoever
     description   "FLASH memory device support for StrongARM SA1100 Multimedia"
-    compile       sa1100mm_flash.c
+    compile       sa1100mm_flash.c flash_query.c flash_erase_block.c flash_program_buf.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) -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) -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) -c -o flash_query.o flash_query.s
-        $(AR) rcs $(PREFIX)/lib/libtarget.a flash_query.o
-    }
 }
 
--- a/packages/devs/flash/arm/sa1100mm/current/src/flash_erase_block.c
+++ b/packages/devs/flash/arm/sa1100mm/current/src/flash_erase_block.c
@@ -55,12 +55,11 @@
 #include <pkgconf/hal.h>
 #include <cyg/hal/hal_arch.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 long *block) 
+	__attribute__ ((section (".2ram.flash_erase_block")));
+int
 flash_erase_block(volatile unsigned long *block)
 {
     unsigned long stat;
--- a/packages/devs/flash/arm/sa1100mm/current/src/flash_program_buf.c
+++ b/packages/devs/flash/arm/sa1100mm/current/src/flash_program_buf.c
@@ -55,13 +55,12 @@
 #include <pkgconf/hal.h>
 #include <cyg/hal/hal_arch.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 long *addr, unsigned long *data, int len)
+	__attribute__ ((section (".2ram.flash_program_buf")));
+int
+flash_program_buf(volatile unsigned long *addr, unsigned long *data, int len)
 {
     unsigned long stat = 0;
     int timeout = 5000000;
--- a/packages/devs/flash/arm/sa1100mm/current/src/flash_query.c
+++ b/packages/devs/flash/arm/sa1100mm/current/src/flash_query.c
@@ -55,14 +55,13 @@
 #include <pkgconf/hal.h>
 #include <cyg/hal/hal_arch.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 20*1000*10  // Approx 200ms
 
 int
+flash_query(unsigned char *data) 
+	__attribute__ ((section (".2ram.flash_query")));
+int
 flash_query(unsigned char *data)
 {
     volatile unsigned long *lROM;
--- a/packages/devs/flash/arm/sa1100mm/current/src/sa1100mm_flash.c
+++ b/packages/devs/flash/arm/sa1100mm/current/src/sa1100mm_flash.c
@@ -52,7 +52,6 @@
 
 #include <pkgconf/hal.h>
 #include <cyg/hal/hal_arch.h>
-#include <cyg/hal/hal_cache.h>
 
 #define  _FLASH_PRIVATE_
 #include <cyg/io/flash.h>
@@ -63,24 +62,10 @@ int
 flash_hwr_init(void)
 {
     unsigned char data[96];
-    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;
+    int num_regions, region_size;
 
-    // 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
-
-    stat = (*_flash_query)(data);
-
-    if (icache_isenabled)
-        HAL_ICACHE_ENABLE();
-
+    flash_dev_query(&data);
+	
     if ((data[0] == FLASH_Intel_code) &&
         (data[4] == FLASH_28F016SV_low) &&
         (data[5] == FLASH_28F016SV_hi)) {