beautypg.com

Intel Extensible Firmware Interface User Manual

Page 1000

background image

Extensible Firmware Interface Specification

I-8

12/01/02

Version 1.10

if (Start[17] != 0) {/*(1U << 16)*/
return (UINT16)BAD_TABLE;
}

JuBits = (UINT16)(16 - TableBits);

for (i = 1; i <= TableBits; i ++) {
Start[i] >>= JuBits;
Weight[i] = (UINT16)(1U << (TableBits - i));
}

while (i <= 16) {
Weight[i++] = (UINT16)(1U << (16 - i));
}

i = (UINT16)(Start[TableBits + 1] >> JuBits);

if (i != 0) {
k = (UINT16)(1U << TableBits);
while (i != k) {
Table[i++] = 0;
}
}

Avail = NumOfChar;
Mask = (UINT16)(1U << (15 - TableBits));

for (Char = 0; Char < NumOfChar; Char++) {

Len = BitLen[Char];
if (Len == 0) {
continue;
}

NextCode = (UINT16)(Start[Len] + Weight[Len]);

if (Len <= TableBits) {

for (i = Start[Len]; i < NextCode; i ++) {
Table[i] = Char;
}

} else {

k = Start[Len];
p = &Table[k >> JuBits];
i = (UINT16)(Len - TableBits);

while (i != 0) {
if (*p == 0) {
Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
*p = Avail ++;
}

if (k & Mask) {
p = &Sd->mRight[*p];
} else {
p = &Sd->mLeft[*p];
}