First, a mea culpa - I've revised my earlier post to note that
Cmd-Opt-P-R
actually
does clear RTCRAM; my notes were clear on this, but I managed to overlook that part when I posted.
Btw, Apple used Macronix MX25L3206E with mid-2012s.
That whole family (MX25L3205*, MX25L3206*, MX25L3233*, MX25L3235*) shares the same JEDEC ID, so they all look the same to the Apple EFI.
the regular GC when the 1st stream is nearly full is a complete other thing what leaves vss2 not empty
The regular garbage collection seems to be the
only thing that actually uses VSS2; GC is what populates VSS2 in the first place. During GC, VSS2 gets a condensed copy of VSS1, then VSS2 gets copied to VSS1.
The only time the consistency of VSS2 is operationally relevant is when VSS1 has the "Garbage Collection In Progress" bit set at boot time, which indicates that GC got interrupted (normal completion would have reset that bit). If that happens, and VSS2 looks valid, VSS2 will be copied to VSS1. Otherwise, VSS2 will either be ignored, or erased if it looks invalid/corrupted.
While this may be absent in MP51 and/or MP41, I recollect
@tsialex finding such a count in the MP31 BootROM.
(
sigh) One more thing added to the seemingly endless pile of stuff I'd eventually like to look into...
Another fun(?) fact: the command-line program
nvram
has a hidden feature:
nvram -s
will forcibly sync the NVRAM cache to the actual NVRAM. (99% of the time, you won't really care about this, but when you do, it's nice to know.)
I've thrown together a quick-and-dirty command-line program to offer a deeper look at the NVRAM variables. It uses the memory-mapped copy of the NVRAM, therefore it requires
DirectHW.kext
to be loaded (not included here; I'd expect any flavor of
DirectHW.kext
to work, including the one bundled with FlashROM). This program looks at the raw data, does a quick analysis of the headers for validity, and displays all of the variables (including deleted ones, and from all GUIDs). Optionally, you can display the variable values (as a hex dump), the VSS and variable header raw values, the raw variable GUIDs, etc. At the end of each VSS, it displays statistics (total number of variables found, number of deleted variables found, free space available, dead space that can be reclaimed when GC eventually runs, etc.). See attached (use
scanvss -h
to display valid options; since it uses
DirectHW.kext
, you may need to run it with
sudo
). The output isn't particularly pretty (n.b. "quick-and-dirty"), but I think it's interesting nonetheless. (This has only been tested on Mac Pro, ROM 144.0.0.0.0; it may or may not work on other Macs or other ROM versions. It's read-only, so it's not going to make a mess of anything; if your ROM is sufficiently different, the output will just be nonsensical.)
Because it uses the memory-mapped copy of the NVRAM, it's displaying a snapshot of the VSS the last time Boot Services exited (either at boot time or when waking from S3 sleep). That means if you run it, save the stats, then add or delete some variables and run it again, you probably won't see any changes until you either reboot or put the Mac completely to sleep and wake it up again.
If I ever decide to finish this program, I'll try to find a way to use the "live" copy of the NVRAM, add a feature to (optionally) fill the VSS just past the GC threshold (so that the next reboot will force GC), and I'll also try to remove the
DirectHW.kext
dependency.
(Current versions attached: v0.14 uses fixed offsets for parsing. v0.17 actually parses the FFV to locate the VSS records instead of making MacPro-specific assumptions. It also allows parsing individually extracted FFV files instead of requiring a complete ROM dump. This
should work on more Macs than just the Mac Pro. It also handles the case where only one VSS is present (such as Mac Pro 3,1). Because its internals are significantly different, I've left both v0.14 and v0.17 attached to this message; use whichever one best suits your needs. Hopefully, the v0.14 branch will be completely replaced by the newer methodology, but only time will tell. v0.17 has also been tested on Mac Pro 3,1 (both "live" NVRAM and file dumps).)