Download pram-save-restore-c.hqx (155,035 KB)
From: oleg@ponder.csci.unt.edu (Kiselyov Oleg)
Subject: PRAM save/restore
Date: Wed, 9 Feb 94 09:35:36 -0600
What: save the PRAM and extended PRAM and restore it on start-up
Contents:
PRAM boss - System extension (but can run as application
if the file type changed from INIT to APPL)
PRAM boss.pi - Project for the application part of PRAM boss
PRAM save.cc - Source code for the application part of PRAM boss
PRAM reset.pi - Project for the INIT resource that restores PRAM
PRAM reset.c - source code for the INIT resource
PRAM guard.* - application and the source code to set/restore
just the regular PRAM at any time
The source code contains enough (I hope) comments to show what
a particular piece of code does, as well as some tricks involved
Language: Symantec C/C++ 6.0 and built-in Assembler
System: System 7.x, but probably 6.x is OK, too. Tested on IIsi, IIci,
Quadras and Centres.
Note: the source code uses a "standard" environment, see myenv-notify.cpt
Comments to: oleg@ponder.csci.unt.edu, oleg@unt.edu
References: DiskParam (/info-mac/util/), SetXParam (from redback.cs.uwa.edu.au
(130.95.80.61) as "/ComSci/LabUtilities/SetXParam.sit")
Special note: for a map of the extended PRAM, read on.
Explanation:
PRAM boss is a better version of DiskParam. The PRAM boss is a bundle
of an application and an INIT resource. The application (when
double-clicked) just dumps the contents of the 20-byte regular PRAM
plus the contents of the entire Extended PRAM into a 'HEXA' resource.
The INIT resets the regular PRAM and (a part of) the extended PRAM to
the values saved into the 'HEXA' resource. The date/time is not
spoiled! So, you can run the application on your computer and create
a HEXA resource with some 'standard' settings. Then you can change the
creator to INIT and drop the (now a 'System Extension') into the
Extensions folder. From that moment on, whenever you restart your Mac,
the PRAM and extended PRAM are reset to their "standard" values. You
can even delete the code resource with the Resource editor: that way
there is no way you can change the "standard" values. It's perfect for
computers in the Lab. The INIT that resets the PRAMs does NOT
patch the system, nor it takes any memory in the system heap,
etc. After it resets the PRAM, it quietly quits without leaving any
traces in the system. The distribution contains the compiled PRAM boss
in the guise of the System extension. To run it as an application,
change the file type to APPL.
PRAM guard is my early experiment, it works only with the regular
PRAM, but it's got a nice (I hope) user interface written in C++!
Map of the extended PRAM (for references)
from the article posted in comp.sys.mac.{programmer,system,
hardware} with comments from ez015670@othello.ucdavis.edu, quinn@cs.uwa.edu.au,
wolfson@ll.mit.edu, and small corrections
Extended PRAM Map
Loc Length Related to
(hex) (dec)
1 1 Used by a system program _InternalWait
8 4 Looks like the last 4 bytes of the regular PRAM
(See IM, Vol II, OS Util)
10 16 Looks like the first 16 bytes of the regular PRAM
(See IM, Vol II, OS Util)
76 1 Has something to do with the RAM disk size
78 4 Startup Disk info (apparently, SCSI id, or smth)
7C 2 System Beep. As was pointed out earlier, it's
in fact an id (short int) of the corresponding
'snd ' resource in the System file.
Accessed through the Sound control panel
7E 1 Used by a system program _InitProcMenu
7F 1 Apparently it has smth to do with the way windows
and dialogs appear on the screen
80 2 Used by a system program _GetVideoDefault
Apparently, some default video settings
82 6 Hilite Color, apparently in the RGB format.
Setup through the Color control panel
8A 1 Bit field: Memory/cache control flags
1xxx xxxx 68040 Cache is OFF | Toggled through Cache control
0xxx xxxx 68040 Cache is ON | panel
xxxx x1x1 32-bit addressing is ON (toggled through the Memory
control panel)
AF 1 Has something to do with the RAM disk size
BD 33 Used (and set!) by some system programs in ROM,
DE 2 at addresses 8009d544 and 8009D73C. BTW, the beginning
of the field at loc 0xBD looks like the name of a
default AppleTalk zone
E0 4 Network: contains info if AppleTalk is active
and the selected network access (say, LocalTalk
or EtherTalk). See Chooser and Network control panel
E4 12 Latitude/Longitude of the place the Mac is at
Setup through the Map Control panel
ez015670@othello.ucdavis.edu also commented that
> One thing that you left out was the total power on hours is also in
> the xpram. It is a 16 bit word. That contains the total time the
> computer has been on in 5 minute intervals.
> Supposedly there is also some creation stuff in their to that tells
> when the machine was made, but I can not make sense of it.
------------------------------------------------------------------------