Figure7.7 creating buffers, 2 patching, Masking – Avago Technologies LSI53C1010 User Manual
Page 173: Creating buffers

Patching
7-7
Figure 7.7
Creating Buffers
7.2 Patching
Sometimes it is necessary for the “C” code to modify some elements of
the SCRIPTS array after buffer allocation. This is called patching.
Patching is required when relative transfer control instructions or table
indirect addressing are not used. However, most applications will take
advantage of these features, so patching is not often required. When
patching is necessary, the general format of the patch in “C” is
SCRIPT[patch_offset] = patch_value;
When only part of the 32-bit value in the SCRIPTS array must be
modified, a Read-Modify-Write can be used. The format for this type of
operation is
SCRIPT[patch_offset]|= patch_value;
Any arithmetic or logical operator can be used in place of the logical OR
(|) symbol to make the desired modification.
The
patch_offset
is an index into the SCRIPTS array where the patch
must be made. This value is usually obtained from one of the sections
of the NASM output file. Please see
Chapter 5, “The NASM Output File,”
for more information on the NASM output file and the patch offsets it
contains.
static ubyte identify_msg[] = {
0xc0
/* 0xc0 = allow disconnect, 0x80 = no disconnect */
};
static ubyte test_unit_ready_cmd[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* drive is the destination ID for the I/O*/
DSA_table[DEVICE].count=(ULONG)drive<< 16;
DSA_table[CMD_ADR].count = sizeof(test_unit_ready_cmd);
DSA_table[CMD_ADR].address=getPhyAddr(test_unit_ready_cmd;
DSA_table[SENDMSG].count = 1;
DSA_table[SENDMSG].address = getPhysAddr(identify_msg);
DSA_table[STATUS_ADR].count = 1;
DSA_table[STATUS_ADR].address = getPhysAddr(status);