Added a mask value to bound the valid data coming back from a read

date	2000.03.27.21.26.00;	author mwalz;	state Exp;
This commit is contained in:
aystarik 2005-06-29 17:27:57 +00:00
parent 8f0803680a
commit 37a12d568d

View File

@ -258,10 +258,12 @@ AmlReadField (
UINT32 ThisFieldDatumOffset;
UINT32 PreviousRawDatum;
UINT32 ThisRawDatum;
// UINT32 ValidFieldBits;
UINT32 ValidFieldBits;
UINT32 Mask;
UINT32 MergedDatum = 0;
FUNCTION_TRACE ("AmlReadField");
/*
@ -288,8 +290,33 @@ AmlReadField (
if ((DatumLength == 1) && ((ObjDesc->Field.BitOffset + ObjDesc->FieldUnit.Length) <= (UINT16) BitGranularity))
{
MergedDatum = PreviousRawDatum;
ValidFieldBits = ((ObjDesc->FieldUnit.Length % BitGranularity) + ObjDesc->Field.BitOffset);
Mask = (((UINT32) 1 << ValidFieldBits) - (UINT32) 1);
/* Place the MergedDatum into the proper format and return buffer field */
switch (ByteGranularity)
{
case 1:
MergedDatum = (MergedDatum >> ObjDesc->Field.BitOffset) & Mask;
((UINT8 *) Buffer) [ThisFieldDatumOffset] = (UINT8) MergedDatum;
break;
case 2:
MergedDatum = (MergedDatum >> ObjDesc->Field.BitOffset) & Mask;
((UINT16 *) Buffer) [ThisFieldDatumOffset] = (UINT16) MergedDatum;
break;
case 4:
MergedDatum = (MergedDatum >> ObjDesc->Field.BitOffset) & Mask;
((UINT32 *) Buffer) [ThisFieldDatumOffset] = (UINT32) MergedDatum;
break;
}
ThisFieldByteOffset = 1;
ThisFieldDatumOffset = 1;
}
else