📄 flash.asm
字号:
/****************************************************************************
ANALOG DEVICES
EUROPEAN DSP APPLICATIONS
FLASH API server for memory mapped AMD FLASH Devices
History:
1.0.1.0 15-JUN-99 HS
****************************************************************************/
/****************************************************************************
Below stated defines represent the memory where the FLASH memory device is
connected to and must be changed accordingly to reflect the actual device
pleacement. Please consult the ADSP-2106x USER'S MANUAL to figure out the
correct values for memory offset to the external memory bank and by what
strobes the FLASH can be accessed.
****************************************************************************/
#define mem_offset 0x400000 /* offset to memory bank of FLASH */
#define memory_bank 0x0 /* selected memory bank */
/****************************************************************************
Ulock1_a and Ulock1_b represent the first combination of address and data
required to access the embedded algorithm. Ulock2_a and Ulock2_b are the
second pair of address and data to enter embedded algorithms. Ulock1_a and
Ulock2_a can change depending on the FLASH type and connection (8/16bit).
Please consult the AMD Flash memory datasheet for a complete listing.
****************************************************************************/
#define ulock1_a 0x5555
#define ulock1_b 0x00AA
#define ulock2_a 0x2AAA
#define ulock2_b 0x0055
#define u_mem1_a ulock1_a + mem_offset
#define u_mem2_a ulock2_a + mem_offset
/****************************************************************************
The global definition exports the functions and the labels to a calling
main program.
****************************************************************************/
.global flash_setup; /* entry to memory setup */
.global prog_byte; /* entry to program a byte */
.global sect_erase; /* entry to erase a sector */
.global flash_erase; /* entry to erase complete FLASH */
.global flash_ident; /* entry to identify FLASH */
.global sect_protect; /* entry to sector protect read */
.global address; /* user defined address for FLASH operation */
.global d_byte; /* data byte to be written to FLASH */
.global error; /* result register for FLASH operation */
#include <def21060.h>
/****************************************************************************
Declaration of few memory cells required for accessing the API
****************************************************************************/
.segment/dm seg_dmda;
.var address;
.var d_byte;
.var error;
.endseg;
/****************************************************************************
Program code of the API fuctions
****************************************************************************/
.segment/pm seg_pmco;
/****************************************************************************
*
* Global setup for the mapped meory area
*
* REGISTER usage summary:
*
* input : none
* modify : WAIT (0x2) register of IOP area
* output : none
* destroy : r12, r13, r14, r15
* calls : none
*
****************************************************************************/
flash_setup:
r12 = memory_bank; /* get assigned memory bank */
r13 = 0x5;
r12 = r12 * r13 (UUI); /* compute position */
r13 = 0x1f; /* compute the mask out */
r13 = lshift r13 by r12; /* shift it to memory bank */
r13 = NOT r13; /* and invert it */
r14 = 0x16; /* set-up of memory */
r14 = lshift r14 by r12; /* shift it into position */
r15 = dm(WAIT);
r15 = r15 AND r13;
r15 = r15 OR r14;
dm(WAIT) = r15; /* adapt the settings */
rts;
/****************************************************************************
*
* FLASH Application Server
*
* API: program byte to FLASH memory
*
* d_byte : value to be written
* address : destination address of value
*
* REGISTER usage summary:
*
* input : none
* modify : error flagged with dm(error) <> 0 for error condition
* output : none
* destroy : r12, i4, m4
* calls : init_seq, DQ7_poll
*
****************************************************************************/
prog_byte:
call init_seq;
r12 = 0xA0; /* load command byte */
dm(u_mem1_a) = r12; /* write command byte to FLASH */
i4 = dm(address); /* load user address */
m4 = mem_offset; /* load memory offset */
r12 = dm(d_byte); /* read byte to program */
dm(m4,i4) = r12; /* perform the access */
call DQ7_poll; /* check for end of sequence */
rts (db);
nop;
nop;
/****************************************************************************
*
* FLASH Application Server
*
* API: erase specified sector of FLASH memory
*
* address : destination address of sector to erase
*
* REGISTER usage summary:
*
* input : none
* modify : error flagged with dm(error) <> 0 for error condition
* output : none;
* destroy : r12, i4, m4
* calls : init_seq, DQ7_poll
*
****************************************************************************/
sect_erase:
call init_seq;
call init_seq(db);
r12 = 0x80; /* load first command byte */
dm(u_mem1_a) = r12; /* write command byte to FLASH */
i4 = dm(address); /* load user address */
m4 = mem_offset; /* load memory offset */
r12 = 0x30; /* load second command byte */
dm(m4,i4) = r12; /* perform the access */
call DQ7_poll; /* check for end of sequence */
rts (db);
nop;
nop;
/****************************************************************************
*
* FLASH Application Server
*
* API: erase complete FLASH memory
*
* REGISTER usage summary:
*
* input : none
* modify : error flagged with dm(error) <> 0 for error condition
* output : none
* destroy : r12
* calls : init_seq, DQ7_poll
*
****************************************************************************/
flash_erase:
call init_seq;
call init_seq (db);
r12 = 0x80; /* load first command byte */
dm(u_mem1_a) = r12; /* write command byte to FLASH */
r12 = 0x10; /* load second command byte */
dm(u_mem1_a) = r12; /* perform the access */
call DQ7_poll; /* check for end of sequence */
rts (db);
nop;
nop;
/****************************************************************************
*
* FLASH Application Server
*
* API: identify connected FLASH memory
*
* d_byte : holds readback of device ID
* r12 : holds readback of bootblock location
*
* REGISTER usage summary:
*
* input : none
* modify : none
* output : d_byte, r12
* destroy : r12, i4
* calls : init_seq
*
****************************************************************************/
flash_ident:
call init_seq;
r12 = 0x90; /* load command byte */
dm(u_mem1_a) = r12; /* write command byte to FLASH */
i4 = mem_offset;
r12 = dm(i4,2); /* read back manufacturer ID */
dm(d_byte)=r12;
r12 = dm(i4,2); /* read back boot block location */
rts(db);
r13 = 0xF0; /* reset FLASH memory */
dm(0,i4) = r13;
/****************************************************************************
*
* FLASH Application Server
*
* API: check for hard sector protection
*
* address : sector to be interrogated
* d_byte : holds readback of sector protection
*
* REGISTER usage summary:
*
* input : none
* modify : none
* output : none
* destroy : r12, r13, i4, m4
* calls : init_seq
*
****************************************************************************/
sect_protect:
call init_seq;
r12 = 0x90; /* load command byte */
dm(u_mem1_a) = r12; /* write command byte to FLASH */
i4 = mem_offset;
m4 = dm(address);
r12 = dm(m4, i4); /* read back protect info */
dm(d_byte)=r12;
rts(db);
r13 = 0xF0; /* reset FLASH memory */
dm(0,i4) = r13;
/****************************************************************************
*
* FLASH Application Server
*
* SUB init sequence
*
* REGISTER usage summary:
*
* input : none
* modify : none
* output : none
* destroy : r12
* calls : none
*
****************************************************************************/
init_seq:
r12 = ulock1_b; /* load first unlock byte */
dm(u_mem1_a) = r12; /* write first unlock byte to FLASH */
rts(db); /* return to calling module */
r12 = ulock2_b; /* load second unlock byte */
dm(u_mem2_a) = r12; /* write second unlock byte to FLASH */
/****************************************************************************
*
* FLASH Application Server
*
* SUB poll end of algorithm
*
* REGISTER usage summary:
*
* input : none
* modify : ASTAT
* output : none
* destroy : r12, r13, r14, i4, m4
* calls : none
*
****************************************************************************/
DQ7_poll:
r13 = dm(m4,i4); /* first read */
r14 = dm(m4,i4); /* second read */
comp(r13,r14); /* equal ? */
if eq jump (pc,DQ7_exit), r12=r12-r12; /* no toggle, exit */
btst r14 by 0x5; /* timeout ? */
if sz jump (pc,DQ7_poll); /* no, re-read status */
r13 = dm(m4,i4); /* first read */
r14 = dm(m4,i4); /* second read */
comp(r13,r14); /* equal ? */
if eq jump (pc,DQ7_exit), r12=r12-r12; /* yes, exit */
btst r14 by 0x5; /* timeout ? */
if sz jump (pc,DQ7_exit), r12=r12-r12; /* no, exit */
r12 = 0xF0; /* reset FLASH */
dm(m4,i4) = r12;
DQ7_exit:
rts (db);
dm (error) = r12;
nop;
.endseg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -