+OSDictionary *IODTNVRAM::getNVRAMPartitions(void)
+{
+ return _nvramPartitionLengths;
+}
+
+IOReturn IODTNVRAM::readNVRAMPartition(const OSSymbol *partitionID,
+ IOByteCount offset, UInt8 *buffer,
+ IOByteCount length)
+{
+ OSNumber *partitionOffsetNumber, *partitionLengthNumber;
+ UInt32 partitionOffset, partitionLength;
+
+ partitionOffsetNumber =
+ (OSNumber *)_nvramPartitionOffsets->getObject(partitionID);
+ partitionLengthNumber =
+ (OSNumber *)_nvramPartitionLengths->getObject(partitionID);
+
+ if ((partitionOffsetNumber == 0) || (partitionLengthNumber == 0))
+ return kIOReturnNotFound;
+
+ partitionOffset = partitionOffsetNumber->unsigned32BitValue();
+ partitionLength = partitionLengthNumber->unsigned32BitValue();
+
+ if ((buffer == 0) || (length == 0) ||
+ (offset + length > partitionLength))
+ return kIOReturnBadArgument;
+
+ bcopy(_nvramImage + partitionOffset + offset, buffer, length);
+
+ return kIOReturnSuccess;
+}
+
+IOReturn IODTNVRAM::writeNVRAMPartition(const OSSymbol *partitionID,
+ IOByteCount offset, UInt8 *buffer,
+ IOByteCount length)
+{
+ OSNumber *partitionOffsetNumber, *partitionLengthNumber;
+ UInt32 partitionOffset, partitionLength;
+
+ partitionOffsetNumber =
+ (OSNumber *)_nvramPartitionOffsets->getObject(partitionID);
+ partitionLengthNumber =
+ (OSNumber *)_nvramPartitionLengths->getObject(partitionID);
+
+ if ((partitionOffsetNumber == 0) || (partitionLengthNumber == 0))
+ return kIOReturnNotFound;
+
+ partitionOffset = partitionOffsetNumber->unsigned32BitValue();
+ partitionLength = partitionLengthNumber->unsigned32BitValue();
+
+ if ((buffer == 0) || (length == 0) ||
+ (offset + length > partitionLength))
+ return kIOReturnBadArgument;
+
+ bcopy(buffer, _nvramImage + partitionOffset + offset, length);
+
+ _nvramImageDirty = true;
+
+ return kIOReturnSuccess;
+}
+
+IOByteCount IODTNVRAM::savePanicInfo(UInt8 *buffer, IOByteCount length)
+{
+ if ((_piImage == 0) || (length <= 0)) return 0;
+
+ if (length > (_piPartitionSize - 4))
+ length = _piPartitionSize - 4;
+
+ // Save the Panic Info.
+ bcopy(buffer, _piImage + 4, length);
+
+ // Save the Panic Info length.
+ *(UInt32 *)_piImage = length;
+
+ _nvramImageDirty = true;
+ /*
+ * This prevents OF variables from being committed if the system has panicked
+ */
+ _systemPaniced = true;
+ /* The call to sync() forces the NVRAM controller to write the panic info
+ * partition to NVRAM.
+ */
+ sync();
+
+ return length;
+}