==========================================================================
                            FlashOperation Project                             
==========================================================================
               Fujitsu Microelectronics (Shanghai) Co., LTD.
                                                                                                 
/* **********************************************************************/
/* The following software is for demonstration purposes only.           */
/* It is not fully tested, nor validated in order to fullfill           */
/* its task under all circumstances. Therefore, this software           */
/* or any part of it must only be used in an evaluation                 */
/* laboratory environment.                                              */
/* This software is subject to the rules of our standard DISCLAIMER     */
/* **********************************************************************/
==========================================================================
               
History
Date      Ver   Author      Softune  Description
17.03.08  1.00  Jacky Zhou  V30L31   original version

==========================================================================

This sample project demonstrates the flash operation. The routines itself 
are executed in RAM.
The code is permanently located in RAM during run-time.

To get I. Permanent RAMCODE working two mechanisms have to be used.

1. The linker has to link the program this way that addresses are resolved
   for RAM and the belonging code data are stored in ROM.
2. The start-up file has to copy the code from ROM to RAM
3. Placing code in RAMCODE sections
4. Jumping to RAM
 
1. Linking code for RAM and ROM
-------------------------------
The linker of the Softune Workbench provide a dedicated mechanism.
The linker is informed of a code section to be located in RAM:
     -sc RAMCODE/Code=_INRAM01 (done by linker set section option)
     
By setting an "@" section with same name the linker will recognise the 
wish to store the initialisation data in ROM:
     -sc @RAMCODE/Const=_INROM01 (done by linker set section option)

The appropriate settings in the Workbench can be checked in this project.
See Project->Setup Project->Linker->Disposition->SetSection

In order to be able to handle these sections the linker provides generic
labels for the start addresses of the sections in RAM and ROM.
     _RAM_ + name
     _ROM_ + name

In this example the section is named "RAMCODE". Therefore, the following
lables are generated:
     _RAM_RAMCODE
     _ROM_RAMCODE
     
These labels have to be imported by the modules, which copy the files.


2. Copying code from ROM to RAM
-------------------------------
For copying code from ROM to RAM,four have to be added in current startup file.
;--------------------------------------------------------------------------
; external declaration of symbols
;--------------------------------------------------------------------------
        .IMPORT     _RAM_RAMCODE   ;added here
		.IMPORT		_ROM_RAMCODE   ;added here
;--------------------------------------------------------------------------
; definition to start address of data, const and code section
;--------------------------------------------------------------------------
		.SECTION	RAMCODE,  CODE,     ALIGN=1  ;added here

This way the start-up file will add a descriptor of of the sections in
ROM and RAM and their size.
Then Start-up file is prepared to copy a section with name "RAMCODE".

;--------------------------------------------------------------------------
; copy initial value *CONST(ROM) section to *INIT(RAM) section
;--------------------------------------------------------------------------
		ICOPY	_ROM_RAMCODE,	_RAM_RAMCODE,	RAMCODE  ;added here
When it's implemented,it has to copy the ramcode from ROM to RAM.

3. Placing code in RAMCODE
--------------------------
This can be done in Assembly language modules via the statement:
     .SECTION RAMCODE, CODE
     
In C-language the following statement should be used:
      #pragma section CODE=RAMCODE

This line forces to locate all Asm-code of its module to RAMCODE.

A separate module (file with extension 'asm') should be used for RAMCODE
functions only.

4. Jumping to RAM
-----------------
It is mandatory that the RAMCODE functions are called via instructions.

In this example the RAMCODE is called by
     CALL _EraseStart
     CALL _WriteStart
Then they are executed within RAM.


