Figure9.11 storing data structures in scripts ram, 2 programming techniques when using scripts ram, Programming techniques when using scripts ram – Avago Technologies LSI53C1010 User Manual
Page 229: Storing data structures in scripts ram
![background image](https://www.manualsdir.com/files/864554/content/doc229.png)
Using the SCRIPTS RAM
9-31
Script_Inst_Bytes
is the number of instruction bytes to copy and
SRC_Phys_Addr
is the physical starting address of the static SCRIPTS
array being copied into SCRIPTS RAM.
Script_RAM_Phys_Addr
is the
physical base address of the SCRIPTS RAM, found in the SCRATCHB
register. To create data structures such as table indirect tables, create a
pointer to the location in SCRIPTS RAM that stores the data. An example
is shown in
.
Figure 9.11 Storing Data Structures in SCRIPTS RAM
The routine “PhystoVirt” converts the physical address of the table
location in the SCRIPT RAM to a virtual address that can be used as a
pointer in “C”.
9.7.2 Programming Techniques when Using SCRIPTS RAM
SCRIPTS programs may be stored on the chip, outside the chip, or both.
When the SCRIPTS code is located both internally and externally, the
following techniques allow the internal SCRIPTS to successfully
communicate with the external SCRIPTS and vice versa.
1.
Create two source (
.SS
) files, one with the SCRIPTS programs that
are to be located internally and the other with the SCRIPTS
programs that are to be located externally.
struct _table {/* Table indirect entry */
uquad count;
uquad address;
};
typedef struct table;
#define SCRAM_TABLE_OFFSET 0xC00; /* Locate table info at bottom 1K of SCRIPTS RAM*/
void main() {
table *buffer_table;
/* pointer to table indirect entries */
ulong SCRAM_Phys_Addr;
ulong Table_Phys_Addr;
/* Get RAM physical address */
outpw(ChipIOBase+CTEST2,
0x08);/* Set bit 3 */
/* Get RAM Base in ScratchB */
SCRAM_Phys_Addr = (ulong) ((ulong) (inpw(ChipBaseIO+
SCRATCHB2) << 16) | inpw(ChipIOBase+SCRATCHB));
/* Read Reg*/
outpw(ChipIOBase+CTEST2, 0x00);/* Clear bit 3 */
/* Create pointer to RAM for Table */
Table_Phys_Addr = SCRAM_Phys_Addr + SCRAM_Table_Offset;
buffer_table = PhystoVirt(Table_Phys_Addr);
}