public override void Write(AcpiObject valueObj) { if ((startBitIndex % 8) != 0 || (numBits % 8) != 0) { throw new AmlTypeException("TODO: Non-byte-aligned buffer fields"); } ulong value = valueObj.GetAsInt().Value; // We ignore high bits above the number of bits fitting in the field. // Used to check this, but some code actually depends on the behavior of // truncating high bits, like this from VPC: // Method (_CRS, 0, NotSerialized) // { // CreateDWordField (CRS, \_SB.SYSM._Y10._BAS, BAS4) // CreateDWordField (CRS, \_SB.SYSM._Y10._LEN, LEN4) // Subtract (0x00, BAS4, LEN4) // } // NB write in little endian byte-order ulong end = startBitIndex / 8u + numBits / 8u; for (ulong idx = startBitIndex / 8u; idx < end; idx++) { sourceBuffer.SetIndex(idx, new Integer(value & 0xFF)); value >>= 8; } }
public override void Visit(JumpIfNonZero node) { AcpiObject.AcpiObject predicate = thread.Pop().Read(); if (predicate.GetAsInt().Value != 0) { Frame.JumpTo(node.ThenTarget - 1); // Minus one because IP will still advance } }
public override void Write(AcpiObject value) { if (this == IntegerConstant.Zero || this == IntegerConstant.One || this == IntegerConstant.Ones) { throw new AmlTypeException("Cannot write to reserved integer constant objects"); } this.value = value.GetAsInt().Value; }
public override void Visit(AmlParser.DefOpRegion defOpRegion) { AcpiObject.AcpiObject startIndexObj = LoadTimeEvaluate(defOpRegion.regionOffset.integer); AcpiObject.AcpiObject lengthObj = LoadTimeEvaluate(defOpRegion.regionLen.integer); CheckObjectType(lengthObj, AcpiObjectType.Integer); Node node = acpiNamespace.LookupNode(defOpRegion.nameString.nodePath, currentPath); node.Value = new AcpiObject.OperationRegion(loader.OperationRegionAccessor, (RegionSpace)defOpRegion.regionSpace.byteData, startIndexObj.GetAsInt().Value, ((AcpiObject.Integer)(lengthObj.GetTarget())).Value); }
/// <summary> /// This is currently just used by IndexField, will probably become accessible /// from AML when implementing stores. /// </summary> public override void Write(AcpiObject valueObj) { ulong value = valueObj.GetAsInt().Value; Debug.Assert(AcpiObjectUtils.GetNumBits(value) <= (ulong)numBits, "Writing value too large for field"); if (numBits == 8 && (startBitIndex % 8) == 0) { operationRegion.Write8At((ulong)(startBitIndex / 8), (byte)value); } else if (numBits == 16 && (startBitIndex % 8) == 0) { operationRegion.Write16At((ulong)(startBitIndex / 8), (byte)value); } else if (numBits == 32 && (startBitIndex % 8) == 0) { operationRegion.Write32At((ulong)(startBitIndex / 8), (byte)value); } else { throw new Exception("Unimplemented operation region field size"); } }
public override void SetIndex(ulong index, AcpiObject value) { contents[index] = (byte)value.GetAsInt().Value; }