beautypg.com

Figure7.6 data structure and type definition, Data structure and type definition, 10 sample sigp code – Avago Technologies LSI53C1010 User Manual

Page 172

background image

7-6

Integrating SCRIPTS Programs into “C” Language Drivers

Figure 7.6

Data Structure and Type Definition

7.1.2.6 Using a Table

The example in

Figure 7.7

creates two buffers,

identify_msg

and

test_unit_ready_cmd

. The byte counts and addresses for these buffers

are then loaded into the

CMD_ADR

and

SENDMSG

elements of the

DSA_table

array. These examples define a message and a command

buffer in the desired table and loads the bytes into the table. The
enumerated types are used in the Test Unit Ready example to index into
the table.

int init_table(void)
{

UBYTE *buf_ptr;

/* temp ptr to ti tables */

/* allocate space for table */
buf_ptr =

(UBYTE far *) malloc((TABLE_SIZE

sizeof(ti_entry))+ 4);

/* did we get the memory */
if (buf_ptr == NULL) return(COMMANDFAILED);

/* dword align the table buffer, ByteAlignBuffer does

this */

dsa_table = (ti_entry *) ByteAlignBuffer(buf_ptr, 0);

/* This initializes the DSA register to point to the

buffer table that was allocated above*/

IOWrite32(PCIDeviceIOBase+DSA, getPhysAddr(dsa_table));

return(GOOD);

}

This manual is related to the following products: