+ if (_piPartitionOffset == 0xFFFFFFFF) {
+ if (freePartitionSize > 0x20) {
+ // Set the signature to 0xa1.
+ _nvramImage[freePartitionOffset] = 0xa1;
+ // Set the checksum to 0.
+ _nvramImage[freePartitionOffset + 1] = 0;
+ // Set the name for the Panic Info partition.
+ strncpy((char *)(_nvramImage + freePartitionOffset + 4),
+ kIODTNVRAMPanicInfoPartitonName, 12);
+
+ // Calculate the partition offset and size.
+ _piPartitionOffset = freePartitionOffset + 0x10;
+ _piPartitionSize = 0x800;
+ if (_piPartitionSize + 0x20 > freePartitionSize)
+ _piPartitionSize = freePartitionSize - 0x20;
+
+ _piImage = _nvramImage + _piPartitionOffset;
+
+ // Zero the new partition.
+ bzero(_piImage, _piPartitionSize);
+
+ // Set the partition size.
+ *(UInt16 *)(_nvramImage + freePartitionOffset + 2) =
+ (_piPartitionSize / 0x10) + 1;
+
+ // Set the partition checksum.
+ _nvramImage[freePartitionOffset + 1] =
+ calculatePartitionChecksum(_nvramImage + freePartitionOffset);
+
+ // Calculate the free partition offset and size.
+ freePartitionOffset += _piPartitionSize + 0x10;
+ freePartitionSize -= _piPartitionSize + 0x10;
+
+ // Set the signature to 0x7f.
+ _nvramImage[freePartitionOffset] = 0x7f;
+ // Set the checksum to 0.
+ _nvramImage[freePartitionOffset + 1] = 0;
+ // Set the name for the free partition.
+ strncpy((char *)(_nvramImage + freePartitionOffset + 4),
+ kIODTNVRAMFreePartitionName, 12);
+ // Set the partition size.
+ *(UInt16 *)(_nvramImage + freePartitionOffset + 2) =
+ freePartitionSize / 0x10;
+ // Set the partition checksum.
+ _nvramImage[freePartitionOffset + 1] =
+ calculatePartitionChecksum(_nvramImage + freePartitionOffset);
+
+ // Set the nvram image as dirty.
+ _nvramImageDirty = true;
+ }
+ } else {
+ _piImage = _nvramImage + _piPartitionOffset;
+ }
+