Intel Extensible Firmware Interface Network Router User Manual


  Open as PDF
of 1084
 
EFI Byte Code Virtual Machine
Version 1.10 12/01/02 19-5
19.4 Natural Indexing
The natural indexing mechanism is the critical functionality that enables EBC to be executed
unchanged on 32- or 64-bit systems. Natural indexing is used to specify the offset of data relative
to a base address. However, rather than specifying the offset as a fixed number of bytes, the offset
is encoded in a form that specifies the actual offset in two parts: a constant offset, and an offset
specified as a number of natural units (where one natural unit = sizeof (VOID *)). These two
values are used to compute the actual offset to data at runtime. When the VM decodes an index
during execution, the resultant offset is computed based on the natural processor size. The encoded
indexes themselves may be 16, 32, or 64 bits in size. Table 19-4 describes the fields in a natural
index encoding.
Table 19-4. Index Encoding
Bit # Description
N Sign bit (sign), most significant bit
N-3..N-1 Bits assigned to natural units (w)
A..N-4 Constant units (c)
0..A-1 Natural units (n)
As shown in Table 19-4, for a given encoded index, the most significant bit (bit N) specifies the
sign of the resultant offset after it has been calculated. The sign bit is followed by three bits
(N-3..N-1) that are used to compute the width of the natural units field (n). The value (w) from
this field is multiplied by the index size in bytes to determine the actual width (A) of the natural
units field (n). Once the width of the natural units field has been determined, then the natural units
(n) and constant units (c) can be extracted. The offset is then calculated at runtime according to the
following equation:
Offset = (c + n * (sizeof (VOID *))) * sign
The following sections describe each of these fields in more detail.
19.4.1 Sign Bit
The sign bit determines the sign of the index once the offset calculation has been performed. All
index computations using n and c are done with positive numbers, and the sign bit is only used
to set the sign of the final offset computed.