Article 12784 of alt.sources:
Path: nntpd.lkg.dec.com!crl.dec.com!crl.dec.com!caen!uwm.edu!fnnews.fnal.gov!watson.math.niu.edu!mp.cs.niu.edu!vixen.cso.uiuc.edu!news.uoregon.edu!tank.news.pipex.net!pipex!news.mathworks.com!newsfeed.internetmci.com!news.sprintlink.net!in2.uu.net!van-bc!vanbc.wimsey.com!not-for-mail
From: markh@vanbc.wimsey.com (Mark C. Henderson)
Newsgroups: alt.sources
Subject: change sun hostid 1.5.0 -- part 3/4
Date: 8 Sep 1995 09:16:11 -0700
Organization: Online at Wimsey Information Services Inc - Vancouver, Canada
Lines: 1708
Message-ID: <42pq8b$ls1@vanbc.wimsey.com>
NNTP-Posting-Host: vanbc.wimsey.com


#!/bin/sh
# This is `hid150.03' (part 3 of a multipart archive).
# Do not concatenate these parts, unpack them in order with `/bin/sh'.
# File `hid-1.5.0/nvram.c' is being continued...
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  echo 'WARNING: not restoring timestamps.  Consider getting and'
  echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
if test ! -r _sharseq.tmp; then
  echo 'Please unpack part 1 first!'
  exit 1
fi
shar_sequence=`cat _sharseq.tmp`
if test "$shar_sequence" != 3; then
  echo "Please unpack part $shar_sequence next!"
  exit 1
fi
if test ! -f _sharnew.tmp; then
  echo 'x - still skipping hid-1.5.0/nvram.c'
else
  echo 'x - continuing file hid-1.5.0/nvram.c'
  sed 's/^X//' << 'SHAR_EOF' >> 'hid-1.5.0/nvram.c' &&
but without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose. You use
this program at your own risk. The author disclaims responsibility for
any damages that might result from the use of this program, even
if they result from negligence on the part of the author.
X
Also, please don't use this program to steal software. The intended
use is for emergency situations where an application has to be moved from
one computer to another (e.g. in the event of a hardware malfunction)
and licence keys cannot be obtained quickly from the vendor. Many
vendors will not supply licence keys outside of business hours.
X
Sorry about all the legal BS, but given that use of this program is
dangerous and inexperienced people will use it, I don't have much choice
from both an ethical and legal point of view.
X
*/
X
X
#define OFFSET1 017730       /* for Sun 4m, Sun OS 4.1.3 */
#define OFFSET2 03730     /* for Sun 4c, SUN OS 4.1.1 */
X
#define SANITY_CHECK        /* don't turn this off unless you need to. If this
X                               fails it generally means that the program won't
X                               work and very well may be destructive */
X
/* #define TEST        /* doesn't actually do mods if TEST is defined */
unsigned char buf[17];  /* larger than it needs to be */ 
X
/* offset table -- in ascending order of magnitude */
off_t offtab[2] = { OFFSET2, OFFSET1 };
#define nofftab  (sizeof(offtab) / sizeof(off_t))
off_t offset;
X
struct nlist nl[2];
void check_eeprom_driver()
{
X    int kmem;
X    off_t where;
X    unsigned int kbuf[12];
X    if ((kmem = open("/dev/kmem", O_RDONLY)) < 0) {
X        fprintf(stderr, "cannot open /dev/kmem\n");
X        exit(1);
X    }
X    fprintf(stderr,"nvram - Mark Henderson <markh@wimsey.bc.ca>\n");
X    fprintf(stderr,
X        "Placed in the public domain by the author - 23 June 1994\n\n");
X    fprintf(stderr,
X        "This program is distributed in the hope that it will be useful,\n");
X    fprintf(stderr,
X        "but without any warranty; without even the implied warranty of\n");
X    fprintf(stderr,
X        "merchantability or fitness for a particular purpose. You use\n");
X    fprintf(stderr,
X    "this program at your own risk. The author disclaims responsibility for\n");
X    fprintf(stderr,
X        "any damages that might result from the use of this program, even\n");
X    fprintf(stderr,
X        "if they result from negligence on the part of the author.\n");
X    fprintf(stderr, 
X        "Malfunction or misuse of this program can damage your computer.\n\n");
X    nl[0].n_name="_mmeeprom";
X    nl[1].n_name = NULL;
X    if (nlist("/vmunix", nl) < 0) {
X        fprintf(stderr, "cannot read namelist out of /vmunix\n");
X        exit(1);
X    }
X    if ((where = nl[0].n_value) == 0) {
X        fprintf(stderr, "unknown kernel variable _mmeeprom\n");
X        fprintf(stderr, 
X            "your kernel is strange - nvram modifier won't operate\n");
X        exit(1);
X    }
X    if (lseek(kmem, where, SEEK_SET) == (-1)) {
X        fprintf(stderr, "lseek on /dev/kmem failed\n");
X        fprintf(stderr, 
X            "your kernel is strange - nvram modifier won't operate\n");
X        exit(1);
X    }
X    if (read(kmem, (char *)&kbuf[0], 48) < 48) {
X        fprintf(stderr, "read from /dev/kmem failed\n");
X        fprintf(stderr, 
X            "your kernel is strange - nvram modifier won't operate\n");
X        exit(1);
X    }
X    close(kmem);
X    if (kbuf[1] == 0x80a6a7d8 && kbuf[10] == 0x80a6a7d8) {
X        fprintf(stderr, "please execute the following:\n");
X        fprintf(stderr, 
X            "adb -w -k /vmunix /dev/mem <<END\n_mmeeprom+4/W 80a6a7ff\n");
X        fprintf(stderr, "_mmeeprom+0x28/W 80a6a7ff\nEND\n");
X        exit(0);
X    }
X    if (kbuf[2] == 0x901223d8) {
X        fprintf(stderr, "please execute the following:\n");
X        fprintf(stderr, 
X            "adb -k -w /vmunix /dev/mem <<END\n_mmeeprom+8/W 901223ff\nEND\n");
X        exit(0);
X    }
X    if (kbuf[1] == 0x80a6a7ff && kbuf[10] == 0x80a6a7ff) {
X        fprintf(stderr, "your kernel looks good (sun4c)\n");
X    }
X    if (kbuf[2] == 0x901223ff) {
X        fprintf(stderr, "your kernel looks good (sun4m)\n");
X    }
}
X    
X
main(argc,argv)
int argc;
char *argv[];
{
X    unsigned int hid;
X    int fd;
X    int i;
X    int j;
X    unsigned int acc;
X    int read_hostid;
X    unsigned int hid_reported_by_gethostid = gethostid();
X
X    if (argc == 1) {
X        /* no args - just get hostid from prom */
X        read_hostid = 1;
X    }
X    else if (argc == 2) {
X        read_hostid = 0;
X        sscanf(argv[1],"%08x",&hid);
X    }
X    else {
X        fprintf(stderr, "usage: %s [hostid]\n",argv[0]);
X        fprintf(stderr, "  e.g. %s b0b1fb0b\n", argv[0]);
X        exit(1);
X    }
X    check_eeprom_driver(); /* note: if you know what you are doing you might 
X                                want to comment this line out. */
X    if (read_hostid) {
X        if ((fd = open("/dev/eeprom", O_RDONLY)) < 0) {
X            fprintf(stderr, "cannot open /dev/eeprom for read\n");
X            exit(1);
X        }
X    } 
X    else {
#ifdef TEST
X        if ((fd = open("/dev/eeprom", O_RDONLY)) < 0) {
X            fprintf(stderr, "cannot open /dev/eeprom for read\n");
X            exit(1);
X        }
#else
X        if ((fd = open("/dev/eeprom", O_RDWR)) < 0) {
X            fprintf(stderr, "cannot open /dev/eeprom for write\n");
X            exit(1);
X        }
#endif
X    }
X
X    offset = 0xffffffff;     /* dummy value */
X
X    for (j = 0; j < nofftab; j++) {
X        if (lseek(fd,offtab[j],SEEK_SET) < 0) { 
X            fprintf(stderr, "lseek failed for %o\n", offtab[j]);
X            continue;
X        }
X        if (read(fd,buf,16) < 16) {
X            fprintf(stderr, "read of /dev/eeprom failed for %o\n", offtab[j]);
X            continue;
X        }
#ifdef TEST
X        for (i=0; i<16; i++)
X            printf("%02x ", buf[i]);
X        printf("\n");
#endif
/* this will fail if you have modified the value returned by
X   gethostid by using one of the other programs in this package.
X   In that case I wouldn't disable this check, but restore your old 
X   gethostid behaviour or replace the gethostid call in this code 
X   with a reference to your "real" hostid. If your architecture 
X   is weird this should detect the problem and not try and
X   write into places we shouldn't. (remember the AT YOUR OWN RISK comment
X  */
X
X        for (acc = 0 , i=0; i<15; i++) acc^=buf[i];
X        if ((acc != buf[15]) 
X            || (buf[1] != (hid_reported_by_gethostid >> 24) )
X            || (buf[12] != ((hid_reported_by_gethostid >> 16) &0xff))
X            || (buf[13] != ((hid_reported_by_gethostid >> 8) &0xff))
X            || (buf[14] != (hid_reported_by_gethostid &0xff))) {
X            continue;
X        }
X        offset = offtab[j];
X        break;
X    }
X    if (offset == 0xffffffff) {
X        fprintf(stderr, "perhaps you have a weird kernel -- failed\n");
X        exit(1);
X    }
X    printf("current hostid = %02x%02x%02x%02x\n", 
X    buf[1], buf[12], buf[13], buf[14]);
X
X    /* may as well print this out */
X    printf("enetaddr       = %02x:%02x:%02x:%02x:%02x:%02x\n", 
X    buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
X    if (!read_hostid) {
X        if (lseek(fd,offset,SEEK_SET) < 0) { 
X            fprintf(stderr, "lseek failed\n");
X            exit(1);
X        }
X
X        buf[1] = hid >> 24;
X        buf[12] = (hid >> 16) &0xff;
X        buf[13] = (hid >> 8) &0xff;
X        buf[14] = hid &0xff;
X        for (acc = 0 , i=0; i<15; i++) acc^=buf[i];
X        buf[15] = acc & 0xff;
#ifndef TEST
X        if (write(fd,buf,16) < 16) {
X            fprintf(stderr, "write failed\n");
X        }
X        fprintf(stderr, "gethostid now returns %08x\n", gethostid());
#else
X    for (i=0; i<16; i++)
X        printf("%02x ", buf[i]);
X    printf("\n");
#endif
X    }
X    close(fd);
}
X
SHAR_EOF
  echo 'File hid-1.5.0/nvram.c is complete' &&
  $shar_touch -am 0118171795 'hid-1.5.0/nvram.c' &&
  chmod 0600 'hid-1.5.0/nvram.c' ||
  echo 'restore of hid-1.5.0/nvram.c failed'
  shar_count="`wc -c < 'hid-1.5.0/nvram.c'`"
  test 11254 -eq "$shar_count" ||
    echo "hid-1.5.0/nvram.c: original size 11254, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/nvram.info ==============
if test -f 'hid-1.5.0/nvram.info' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/nvram.info (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/nvram.info (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/nvram.info' &&
USE THIS AT YOUR OWN RISK. IF THIS INFORMATION IS ABUSED OR INCORRECT
YOU CAN RENDER YOUR COMPUTER UNBOOTABLE AND MY BET IS THAT SUN WILL
CHARGE A LOT OF MONEY TO FIX THE DAMAGE.
X
Be careful, mistakes can cost a lot.
X
The information in this document is distributed in the hope that 
it will be useful, but without any warranty; without even the 
implied warranty of merchantability or fitness for a particular 
purpose. You use this document at your own risk. The author 
disclaims responsibility for any damages that might result from the 
use of this document, even if they result from negligence or errors 
on the part of the author.
X
Placed in the public domain by the author - Aug 1995
- Mark Henderson <markh@wimsey.bc.ca>
X
Thanks to Kevin Murty for the use of an SC1000 (and to the Sun FE
Handbook for the magic "update-system-idprom" command).
X
If you are reading this file because you are installing a new NVRAM
chip in a sun4c machine and don't care about details, go to the bottom
of this file (section entitled: A note on simplifying the computations
- and how to I really go about installing new SPARC 1/2/IPX/IPC/ELC/SLC
NVRAM.  Quick instructions for the lazy.)
X
This document describes a method for reprogramming your NVRAM from the
FORTH monitor, to change your hostid and ethernet address on a sun4c or
sun4m architecture machine.  Near the bottom of this file, there's also
some information on the Sun 3/80 (sun3x).
X
You can also change the hostid and ethernet address on an SC1000 with
only one extra step over the sun4c and sun4m machines. On the SC1000,
the hostid and ethernet address are programmed into a Flash EEPROM
(TMS29F816). This information is downloaded into NVRAM on boot.
Basically, you need to modify the NVRAM as for the sun4c and sun4m
class machines, and then use the update-system-idprom command to dump
the NVRAM information into the Flash EEPROM.
X
All numbers in here are in hex.
X
Also look at the NVRAM FAQ. anon ftp from 
thor.ece.uc.edu:/pub/sun-faq/FAQs/eeprom-nvram.faq
or the various other FAQs available from ftp.netcom.com:/pub/he/henderso
X
As far as I know, this is only applicable to Sun4m, sun4d, and Sun4c class
machines.  If you have a copy of the Sun Openprom manual (you can get it
off the Solaris 2.3 answerbook), it might be handy to have that on hand
as a reference. sun4 architecture machines (e.g. 4/1xx,4/2xx,4/3xx etc.)
have the hostid and ethernet address burned into PROMS.
X
These steps are not the easiest path to getting this changed. On the
other hand, something like this is necessary if you're trying to
recover from an NVRAM failure, because your OS will likely not boot if
the NVRAM has been erased.  The batteries on the NVRAM chips in the sun
3/80 and sun4c machines run out after about five years. The easiest way
to deal with this is to purchase a replacement chip and program in a
new hostid and ethernet address.
X
If you can boot SunOS/Solaris, you should take a look at nvram.c and
nvram-sol2.c. especially if you are just interested in modifying your
NVRAM and don't care how things work.  The information in this file
might also be useful in putting things back together if nvram.c
malfunctions.
X
Before doing anything else, write down a copy of the nvram "idprom" 
information. You can get it under Sun OS 4.1.x by running 
/usr/etc/devinfo -vp (on Solaris 2.x, /usr/sbin/prtconf -vp) or at 
the Openprom monitor prompt by typing the command
X.idprom
(yes the "." is part of the command)
You'll need this information if the NVRAM gets screwed up and you need
to try and back out. Having it does not guarantee that you'll be able
to restore it, but life will be easier if you have it.
X
Step 1.
Determine the physical address of the NVRAM (in the case of Sun4m machines
I'm interested in the second page). If you're system is on this table you 
can probably just read it off the table and skip to step 2.
X
X                                addr        space       arch
SS1,SS2,ELC,IPC,IPX,SLC         02000000    obio        sun4c
Classic,LX,SS5                  71201000    0           sun4m
SS20,SS10                       f1201000    f           sun4m
SC1000                          00281000    f           sun4d
X
Thanks to weindlin@pcs.mot.com for supplying some of the data in 
this table.
X
If your system is not in the table, and you are running Sun OS 4.1.x, do 
the following (Solaris 2.4 instructions follow in Step 1b):
X
Step 1a. (Sun OS 4.1.x)
X
While Sun OS 4.1.x is running (and while the system is idle!!) do the 
following. Modify the instructions accordingly if you have some of 
the security features installed.
X
hold down the L1/Stop key and type a 
you will get a prompt which says
ok
X
For Sun4m machines:
type the command
fefff000 pgmap?
X
the output will list a physical address which might look like
f.f120.1000
X
the part before the first dot is the address space and the rest is
the actual address. This is the SS20 case from the above table.
X
Now type 
go
to resume Sun OS operation.
--
X
For sun4c machines:
type the command
ffff8000 pgmap?
X
the physical address will probably list a space (in the ELC case the
address space is given as I/O) and an address (again for the ELC
02000000).
X
the monitor will want you to type in this address space as obio
later. The Sun Openprom manual also gives sbus and obmem as possible
address spaces.
X
Now type
go
to resume Sun OS operation.
--
X
At this point if you're really nice, you'll send me an Email message
with your Sun model and physical address/address space so I can add it 
to my table. Indicate whether or not you want me to give credit. Unless
you ask me not to, I'll credit you just below the table.
X
X
--
X
Step 1b. (Solaris 2.4)
X
Solaris 2.4 instructions for determining the physical address of the
NVRAM (sun4c/m/d).
X
0. If you are running a sun4m or sun4d machine (not sun4c) get the
X   eeprom driver from the Solaris 2.4 distribution disk. You'll need
X   to copy this driver into /kernel/drv (you should find it in
X   /cdrom_root_dir/export/exec/kvm/sparc.sun4c.Solaris_2.4/kernel/drv/eeprom)
X   and also 
X   mknod /dev/eeprom c 68 11
X
1. make sure the eeprom driver is loaded. An easy way to do this is to
X   cp /dev/eeprom /dev/null
X
2. execute
X   /usr/sbin/prtconf -vp 
X
X   and look for the information on eeprom
X   which should look something like:
X
X    Node 0xffec068c
X        name:  'eeprom'
X        model:  'mk48t02'
X        reg:  00000001.f2000000.00000800
X        address:  ffd04000      (*** note this address ***)
X
3. Press STOP-A to stop the machine
X
4. at the ok prompt type
X   ffd04000 pgmap?      (replace ffd04000 with the address given by prtconf)
X
5. you'll get output which specifies an address space and a physical address.
X
e.g. sun4c output looks something like: 
Onboard I/O Physical: 2000000 ...
X
so the address space is I/O
Physical address is 2000000
X
6. Now type
go
at the ok prompt to resume Sun OS operation.
X
--
X
Step 2. 
X
XFrom this point on it doesn't matter what version of Solaris you
are running.
X
Shut down  your system (e.g. with /etc/halt)
X
--
X
Step 3. 
X
Make sure you wrote down your original idprom info. You can 
get it by typing .idprom now. 
X
Figure out what your desired hostid and ethernet address are. Note that
you shouldn't change either the first hex byte of the hostid or the
first three bytes of the ethernet address. Doing so can cause problems.
X
--
Step 4. 
X
Map the physical address determined above to address 0 using
the map-page command. The format of the command is:
X
<physical address>  <address space>  <map_to>  map-page
X
e.g. ELC     02000000    obio 0   map-page
X     SS20    f1201000    f    0   map-page
X     Classic 71201000    0    0   map-page
X     SC1000  00281000    f    0   map-page
X
--
Step 5. 
X
If you are on a Sun4c the virtual address of the idprom information is now 7d8
On a Sun4m/d the virtual address of the idprom information is now fd8
X
type either
7d8 20 dump
for sun4c
or 
fd8 20 dump
for sun4m/d
X
as appropriate.
X
--
Step 6. 
X
The information which starts at f/7d8 is as follows:
byte    contents
d8      01    - version number - always 01
d9      first byte of hostid (system type)
da-df   6 byte ethernet address (first three bytes are 08,00,20)
e0-e3   date of manufacture. Often all 0s
e4      second byte of hostid
e5      third byte of hostid
e6      fourth byte of hostid
e7      idprom checksum  - xor of contents of bytes d8-e6
X
Verify that the information the dump command spits out is consistent
with the above. If not, DO NOT PROCEED. 
X
Stephen Dowdy <dowdy@cs.colorado.edu> has contributed the following
Forth program which can be run directly from the openprom monitor to
calculate the NVRAM checksum. Works nicely.
X
Change the 7d8 to fd8 for sun4m/d.
X
X    : idpcsum           ( Print IDPROM CheckSum value )
X      hex               ( set base 16 )
X      7d8 dup c@       ( set first address, get value )
X      e 0 do            ( for remaining 14 addresses...)
X        swap 1+ dup c@ rot xor  ( inc ptr, get value, XOR )
X      loop              ( continue )
X      ." Checksum should be " . ( print value )
X    ;
X
X
--
Step 7. 
X
Now you can make changes. Be very careful and be sure to recompute
the checksum after making changes. If you don't, you'll get nasty
warnings about an incorrect idprom checksum on boot. I'm know repeating
myself, but don't change the first byte of the hostid or the first three
bytes of the ethernet address. I'm told that the first byte of the
hostid is used to determine the architecture when booting from CDROM on
most current Sun models. If you alter the first three bytes of the
ethernet address you might get message which say that you have a
defective motherboard (but then I don't know of any other consequences
of changing this to some _reasonable_ value, especially avoid 
ff:ff:ff:ff:ff:ff !)
X
The openprom command to change a single byte is
X
<value> <addr> c!
e.g.
44 7dd c!
will change byte 7dd (virtual address) to 44.
X
7d8 20 dump      
or
fd8 20 dump
will give you a listing of this area of NVRAM.
X
X
--
Step 8.
X
X If you are on an SC1000, type
X update-system-idprom 
X at the ok prompt.
X
X For any of the above machines, now type reset at the ok prompt. You 
X should then reboot with your new hostid/enet addr. 
X
---------------------------------------------------------------------
Here's a table which matches system models with the first byte of the
hostid. This is from a posting to comp.sys.sun.admin by
Andy.Behrens@coat.com
X
X    01  2/1x0
X    02  2/50
X    11  3/160
X    12  3/50
X    13  3/2x0
X    14  3/110
X    17  3/60
X    18  3/e
X    21  4/2x0
X    22  4/1x0
X    23  4/3x0
X    24  4/4x0
X    31  386i/150 or 386i/250
X    41  3/4x0
X    42  3/80
X    51  SPARCstation 1   (4/60)
X    52  SPARCstation IPC (4/40)
X    53  SPARCstation 1+  (4/65)
X    54  SPARCstation SLC (4/20)
X    55  SPARCstation 2   (4/75)
X    56  SPARCstation ELC (4/25)
X    57  SPARCstation IPX (4/50)
X    61  4/e
X    71  4/6x0   (670)
X    72  SPARCstation 10,20
X    80  SPARCclassic, LX, SPARC 5, SC1000
X
X
X
X
Quick steps to modify NVRAM IDPROM info on a Sun 3/80 (people have
to do this because of the usual battery problem, as with the sun4c
machines)
X
This may not be the most elegant procedure, but this should allow you
to modify the NVRAM IDPROM info on a sun 3/80. At first glance you
might think that the q command would work, but it doesn't seem to
actually modify anything when given addresses >= 0x7d8
X
Hit L1-A after you turn it on
X
N.B.: ^t is a command. Don't try control-T. 
X
Only tested with 2.9.2 PROMS.
X
> ^t fef04000
you'll get output which includes the following (samples included)
TIA entry = 33FA500
TIB entry = 33FB80A
PTE = 64000049
X
Write these values down!!
X
now change the TIA entry for fedfa000 to match the above
X
> m a fedfa000
TIA MAP FEDFA000 [...] ? 33FA500
X   hit control-D at next ? prompt
X
now change the TIB entry to match the above
X
> m b fedfa000
TIB MAP FEDFA000 [...] ? 33FB80A
X
now change the pagemap entry to match the above
> p fedfa000
PageMap FEDFA000 [...] ? 64000049
X
> o fedfa7d8
X...
X
now enter new IDPROM values. You need to get the checksum right.
X
byte          contents
fedfa7d8      01    - version number - always 01
fedfa7d9      first byte of hostid (system type, 42 for sun 3/80)
fedfa7da-df   6 byte ethernet address (first three bytes are 08,00,20)
fedfa7e0-e3   date of manufacture. Often all 0s
fedfa7e4      second byte of hostid
fedfa7e5      third byte of hostid
fedfa7e6      fourth byte of hostid
fedfa7e7      idprom checksum  - xor of contents of bytes d8-e6
X
X
Note if you have SUN OS 4.1.1 booted (i.e. you're doing this for some other
reason than an IDPROM with invalid data), you can just write values into
fedfa7d8 ... fedfa7e7 with the o command. You don't need to do all the
mapping stuff.
X
X
Obtaining a new NVRAM chip for a sun4c or sun3x machine.
X
One possibility is that you are interested in this file because you
have had an NVRAM failure. Thanks to Mike Coughlin and 
"Roderick Murchison, Jr." <murchiso@Newbridge.COM> for providing
information on ordering a new chip.
X
Mauser electronics sells the SGS-Thomson Timekeeper chips
(800-346-6873,817-483-5712). The Mauser part number is
511-M48T02-20PC1.  You should also be able to get them from another
SGS-Thomson distributor. They may also go by the part numbers
MK48T02B-25 or M48T02-200PC1.  I have no affiliation with Mauser other
than as a customer. The price is ~$16/chip. If the 200ms part is not
available, you can also order either the 150ns or the 120ns part.
The part numbers from Mauser are 511-M48T02-15PC1 and 511-M48T02-12PC1
respectively.
X
There is also a clone of the SGS-Thomson chips made by Dallas
Semiconductor, the DS1642.  My experience is that these clone chips
only work in Suns some of the time.  At least, I have one IPX, one SS2
and one 3/80 that refuse to take the Dallas chips, but I have used them
in a number of machines without problems (SS1, IPC). You can order
these chips in 120ns or 150ns speeds (150ns is fine) directly from
Dallas in quantities up to 10 by calling 1-800-336-6933 and giving
Dallas a credit card number.  Data sheets and distrubutor lists for
Dallas are available from http://www.dalsemi.com
X
X
A note on simplifying the computations - and how to I really go about
installing new SPARC 1/2/IPX/IPC/ELC/SLC NVRAM. Quick instructions for
the lazy.
X
All numbers below are in hex.
X
Turn off the machine. Remove the old NVRAM chip (note the
orientation).  Insert the new NVRAM chip. Be sure to insert it in the
correct orientation. Power up the machine and bring it to the "ok"
prompt.
X
now at the "ok" prompt...
set-defaults
setenv diag-switch? false
02000000 obio 0 map-page
X
If you have your original hostid and ethernet address and want to
restore it, you're going to have to do the xor computation to get the
IDPROM checksum (see above - to do the XOR computations you can
use the CDE dtcalc, an HP 16C, perl, C, or just do them by hand). 
X
However, if you don't care too much about getting the exact same
values, the following is easy and just gives you the IDPROM checksum of
29.
X
Choose three one byte values, H1, H2 and H3. These will be the last
three bytes of your hostid and ethernet address. You should not
have two machines with the same ethernet address on the same subnet.
X
Get H0 from the following table (system type byte - more detailed table
above)
X
X    H0  SYSTEM TYPE
X    51  SPARCstation 1   (4/60)
X    52  SPARCstation IPC (4/40)
X    53  SPARCstation 1+  (4/65)
X    54  SPARCstation SLC (4/20)
X    55  SPARCstation 2   (4/75)
X    56  SPARCstation ELC (4/25)
X    57  SPARCstation IPX (4/50)
X
now fill in the NVRAM as follows, substituting your values for H0, H1, H2,
and H3 for the strings H0, H1, H2, H3. Keep in mind that all numbers are 
in hex.
X
01 7d8 c!
H0 7d9 c!
08 7da c!
0 7db c!
20 7dc c!
H1 7dd c!
H2 7de c!
H3 7df c!
H0 7e0 c!
0 7e1 c!
0 7e2 c!
0 7e3 c!
H1 7e4 c!
H2 7e5 c!
H3 7e6 c!
29 7e7 c!   
X
Then do a "reset" at the "ok" prompt. If you got everything right, the
system should boot and shouldn't complain about the IDPROM checksum during
the power on self test.
X
The checksum of 29 is correct because of some basic laws about xor and 
29 = 01 XOR 08 XOR 20      (all in hex)
X
X
X
simple examples:
X
N.B. AS I'VE SAID ABOVE, YOU SHOULD AVOID CHANGING THE FIRST BYTE OF THE 
X     HOSTID.
X
1. modify the hostid of an IPX to be 57c0ffee and the ethernet address
X   to be 08:00:20:c0:ff:ee
X
X   at the forth monitor prompt
X
X   02000000 obio 0 map-page
X   01 7d8 c!
X   57 7d9 c!
X   08 7da c!
X   0 7db c!
X   20 7dc c!
X   c0 7dd c!
X   ff 7de c!
X   ee 7df c!
X   57 7e0 c!
X   0 7e1 c!
X   0 7e2 c!
X   0 7e3 c!
X   c0 7e4 c!
X   ff 7e5 c!
X   ee 7e6 c!
X   29 7e7 c!
X
X   
2. modify the hostid of an SS10 to be 72c0ffee and the ethernet address
X   to be 08:00:20:c0:ff:ee
X
X   at the forth monitor prompt
X
X   f1201000 f 0 map-page
X   01 fd8 c!
X   72 fd9 c!
X   08 fda c!
X   0 fdb c!
X   20 fdc c!
X   c0 fdd c!
X   ff fde c!
X   ee fdf c!
X   72 fe0 c!
X   0 fe1 c!
X   0 fe2 c!
X   0 fe3 c!
X   c0 fe4 c!
X   ff fe5 c!
X   ee fe6 c!
X   29 fe7 c!
X
3. modify the hostid of an SC1000 to be 80c0ffee and the ethernet address
X   of 08:00:20:c0:ff:ee
X
X   at the forth monitor prompt
X
X   00281000 f 0 map-page
X   01 fd8 c!
X   80 fd9 c!
X   08 fda c!
X   0 fdb c!
X   20 fdc c!
X   c0 fdd c!
X   ff fde c!
X   ee fdf c!
X   80 fe0 c!
X   0 fe1 c!
X   0 fe2 c!
X   0 fe3 c!
X   c0 fe4 c!
X   ff fe5 c!
X   ee fe6 c!
X   29 fe7 c!
X   update-system-idprom
X
X
Resetting the NVRAM (when L1-N doesn't do it)
X
You might want to do this to recover from the loss of an NVRAM password
(in full security mode) or if you mess up your nvramrc. My take on this
situtation is that the safest thing to do is pay the $20 for a new
Timekeeper chip. But several people have reported to me that it is safe
to hot-swap the NVRAM when the system is on.
X
dowdy@cs.colorado.edu (Stephen Dowdy) writes:
> (this may apply to other SPARC models.)
> IPC --  remove NVRAM, power-up without.  *carefully* hot-plug it in when OK
>     prompt comes up (after it says CHECKSUM failure).  do:
>         OK set-defaults
>         OK set-defaults
>     then power-cycle
> 
> SS2 --  you need to boot from a good NVRAM, then hot-swap the "bad" one
>     and "set-defaults".  Only if the L1-N (or is it L1-D) thingy
>     doesn't work for you.
SHAR_EOF
  $shar_touch -am 0908090495 'hid-1.5.0/nvram.info' &&
  chmod 0600 'hid-1.5.0/nvram.info' ||
  echo 'restore of hid-1.5.0/nvram.info failed'
  shar_count="`wc -c < 'hid-1.5.0/nvram.info'`"
  test 18243 -eq "$shar_count" ||
    echo "hid-1.5.0/nvram.info: original size 18243, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/nvram_old.c ==============
if test -f 'hid-1.5.0/nvram_old.c' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/nvram_old.c (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/nvram_old.c (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/nvram_old.c' &&
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
X
/* 
get/change hostid in NVRAM --
X
old version -- I should throw this away. Less friendly but perhaps
X  easier to modify for other types of machines.
X
only tested on sun4m architecture and sun4c architecture. The
kernel patches will be different for Sun4 and I don't have one
to play with. 
X
This program is still experimental. Dangerous and tricky stuff.
If you are unwilling to experiment and clean up after disasters
don't use it. hid is probably safer. USE AT YOUR OWN RISK.
X
Note the define OFFSET below!
X
running this will invalidate the overall NVRAM checksum. So after it
make some trivial change with the eeprom command (change the baud
rate on a serial port or something like that
e.g.
/usr/etc/eeprom diag-switch?=false
)
X
first you need to turn off the protection in the OS to keep
you from modifying /dev/eeprom locations after 017730 
use adb
adb -k -w /vmunix /dev/mem
_mmeeprom+8/W 901223ff
X
which changes
or      %o1, 0x3d8, %o1
to
or      %o1, 0x3ff, %o1
X
X
Unfortunately this change with adb to the eeprom device seems to depend
on the exact version of Sun OS you are running. Don't assume it will
work without looking around intelligently.
X
e.g. For SUN OS 4.1.1 on a Sun 4c you need to:
adb -w /vmunix /dev/mem
_mmeeprom+4/W 80a6a7ff
_mmeeprom+0x28/W 80a6a7ff
which changes a couple of compare operations. 
X
Also be very careful. The first byte of the hostid identifies the type 
of system you are running. On modern Suns OS boot CDs depend on this 
information to get the correct architecture. If you change it you may 
be reduced to poking around in NVRAM from the monitor next time you have
to boot from CD.
X
Here's a mapping of what gets read into buf (at OFFSET)
buf[0] = always 01?
buf[1] = system id/first byte of hostid.
buf[2] \
buf[3]  \
buf[4]   \  HW ethernet address (6 bytes)
buf[5]    /  
buf[6]  /
buf[7]/
buf[8],...,buf[11] = always 00?
buf[12] = second byte of hostid
buf[13] = third byte of hostid
buf[14] = fourth byte of hostid
buf[15] = checksum
X
the checksum is buf[0] ^ buf[1] ^ ... ^ buf[14]
i.e. it must be the case that the  xor of buf[0] through buf[15] is 0
X
Without any parameters, it reports the hostid from NVRAM. Otherwise it
changes it. 
X
Mark Henderson <markh@wimsey.bc.ca>
Placed in the public domain by the author - 23 June 1994
X
This program is distributed in the hope that it will be useful,
but without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose. You use
this program at your own risk. The author disclaims responsibility for
any damages that might result from the use of this program, even
if they result from negligence on the part of the author.
X
Also, please don't use this program to steal software. The intended
use is for emergency situations where an application has to be moved from
one computer to another (e.g. in the event of a hardware malfunction)
and licence keys cannot be obtained quickly from the vendor. Many
vendors will not supply licence keys outside of business hours.
X
*/
X
X
#define OFFSET 017730       /* for Sun 4m, Sun OS 4.1.3 */
/* #define OFFSET 03730     /* for Sun 4c, SUN OS 4.1.1 */
X
#define SANITY_CHECK        /* don't turn this off unless you need to. If this
X                               fails it generally means that the program won't
X                               work and very well may be destructive */
X
#undef TEST         /* doesn't actually do mods if TEST is defined */
unsigned char buf[17]; 
X
main(argc,argv)
int argc;
char *argv[];
{
X    unsigned int hid;
X    int fd;
X    int i;
X    unsigned int acc;
X    int read_hostid;
X    unsigned int hid_reported_by_gethostid = gethostid();
X
X    if (argc == 1) {
X        /* no args - just get hostid from prom */
X        read_hostid = 1;
X    }
X    else if (argc == 2) {
X        read_hostid = 0;
X        sscanf(argv[1],"%08x",&hid);
X    }
X    else {
X        fprintf(stderr, "usage: %s [hostid]\n",argv[0]);
X        fprintf(stderr, "  e.g. %s b0b1fb0b\n", argv[0]);
X        exit(1);
X    }
X    if (read_hostid) {
X        if ((fd = open("/dev/eeprom", O_RDONLY)) < 0) {
X            fprintf(stderr, "cannot open /dev/eeprom for read\n");
X            exit(1);
X        }
X    } 
X    else {
#ifdef TEST
X        if ((fd = open("/dev/eeprom", O_RDONLY)) < 0) {
X            fprintf(stderr, "cannot open /dev/eeprom for read\n");
X            exit(1);
X        }
#else
X        if ((fd = open("/dev/eeprom", O_RDWR)) < 0) {
X            fprintf(stderr, "cannot open /dev/eeprom for read\n");
X            exit(1);
X        }
#endif
X    }
X
X    if (lseek(fd,OFFSET,SEEK_SET) < 0) { 
X        fprintf(stderr, "lseek failed\n");
X        exit(1);
X    }
X
X    if (read_hostid) {
X        if (read(fd,buf,16) < 16) {
X            fprintf(stderr, "read of /dev/eeprom failed\n");
X            exit(1);
X        }
X        printf("%02x%02x%02x%02x\n", buf[1], buf[12], buf[13], buf[14]);
X        for (acc = 0 , i=0; i<15; i++) acc^=buf[i];
X        if (acc != buf[15])  {
X            fprintf(stderr, "warning: ID CHKSUM INVALID\n");
X            fprintf(stderr,"^buf = %02x\n", acc & 0xff);
X            fprintf(stderr,"buf[15] = %02x\n", buf[15] & 0xff);
X        }
X    }
X    else {
#ifdef SANITY_CHECK 
/* this will fail if you have modified the value returned by
X   gethostid by using one of the other programs in this package.
X   In that case I wouldn't turn this off but restore your old 
X   gethostid behaviour or replace the gethostid call above with
X   a reference to your "real" hostid, if your architecture 
X   is weird this should detect the problem and not try and
X   write into places we shouldn't. */
X
X        if (read(fd,buf,16) < 16) {
X            fprintf(stderr, "read of /dev/eeprom failed\n");
X            exit(1);
X        }
#ifdef TEST
X        for (i=0; i<16; i++)
X            printf("%02x ", buf[i]);
X        printf("\n");
#endif
X        for (acc = 0 , i=0; i<15; i++) acc^=buf[i];
X        if ((acc != buf[15]) 
X            || (buf[1] != (hid_reported_by_gethostid >> 24) )
X            || (buf[12] != ((hid_reported_by_gethostid >> 16) &0xff))
X            || (buf[13] != ((hid_reported_by_gethostid >> 8) &0xff))
X            || (buf[14] != (hid_reported_by_gethostid &0xff))) {
X        
X            fprintf(stderr, "SANITY CHECK FAILED -- aborting\n");
X            fprintf(stderr, 
X                "perhaps the value of the define OFFSET is wrong\n");
X            exit(1);
X        }
X            
X        if (lseek(fd,OFFSET,SEEK_SET) < 0) { 
X            fprintf(stderr, "lseek failed\n");
X            exit(1);
X        }
X
#endif
X        buf[1] = hid >> 24;
X        buf[12] = (hid >> 16) &0xff;
X        buf[13] = (hid >> 8) &0xff;
X        buf[14] = hid &0xff;
X        for (acc = 0 , i=0; i<15; i++) acc^=buf[i];
X        buf[15] = acc & 0xff;
#ifndef TEST
X        if (write(fd,buf,16) < 16) {
X            fprintf(stderr, "write failed\n");
X        }
#else
X    for (i=0; i<16; i++)
X        printf("%02x ", buf[i]);
X    printf("\n");
X
#endif
X    }
X    close(fd);
}
X
SHAR_EOF
  $shar_touch -am 0811082994 'hid-1.5.0/nvram_old.c' &&
  chmod 0600 'hid-1.5.0/nvram_old.c' ||
  echo 'restore of hid-1.5.0/nvram_old.c failed'
  shar_count="`wc -c < 'hid-1.5.0/nvram_old.c'`"
  test 7012 -eq "$shar_count" ||
    echo "hid-1.5.0/nvram_old.c: original size 7012, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/run/README ==============
if test ! -d 'hid-1.5.0/run'; then
  echo 'x - creating directory hid-1.5.0/run'
  mkdir 'hid-1.5.0/run'
fi
if test -f 'hid-1.5.0/run/README' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/run/README (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/run/README (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/run/README' &&
run.c is a small program to run a program with any group in the
range 900,...,909 added to the group list.
X
You might want to install it in /usr/local/bin setuid root. Anyway,
that's what the install program does. I'm not an expert on writing
"safe" setuid programs, so please check this out carefully before you
install it. (General good instructios for any setuid root program!)
X
An example of its use (with the solaris 2 hostid-by-egid module) is
as follows:
X
(edit /etc/name_to_sysnum as described in the documentation for 
X hostid-by-egid-solaris2)
X
ratatosk# cd hostid-by-egid-solaris2
ratatosk# make load
/opt/SUNWspro/bin/cc -D_KERNEL  -c  sethostid.c
ld -r -o sethostid sethostid.o
/usr/sbin/modload ./sethostid
ratatosk# make sid
grep sethostid /etc/name_to_sysnum | sed 's/^/#define SYS_/' ratatosk#sethostid.h
/opt/SUNWspro/bin/cc -o sid -I. sid.c
ratatosk# ./sid 0 24000000
ratatosk# ./sid 1 25000000
ratatosk# cd ../run
ratatosk# make
cc -o run run.c
chmod 4755 run
ratatosk# hostid
80512f45
ratatosk# ./run 0 hostid
24000000
ratatosk# ./run 1 hostid
25000000
ratatosk# ./run 2 hostid
80512f45
ratatosk# ./run 0 lmhostid
lmhostid - Copyright (C) 1989, 1991 Highland Software, Inc.
The FLEXlm host ID of this machine is "24000000"
ratatosk# ./run 0 lmhostid
lmhostid - Copyright (C) 1989, 1991 Highland Software, Inc.
The FLEXlm host ID of this machine is "25000000"
ratstosk# ./run 0 csh
ratatosk# hostid
24000000
ratatosk# lmhostid
lmhostid - Copyright (C) 1989, 1991 Highland Software, Inc.
The FLEXlm host ID of this machine is "24000000"
ratatosk# modinfo
X...
X 78 fc6a50a0   a62 277   1  sethostid (kern_hostid v1.02)
X...
ratatosk# modunload -i 78
ratatosk# hostid
80512f45
ratatosk# ./run 0 hostid
80512f45
SHAR_EOF
  $shar_touch -am 0819115394 'hid-1.5.0/run/README' &&
  chmod 0600 'hid-1.5.0/run/README' ||
  echo 'restore of hid-1.5.0/run/README failed'
  shar_count="`wc -c < 'hid-1.5.0/run/README'`"
  test 1726 -eq "$shar_count" ||
    echo "hid-1.5.0/run/README: original size 1726, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/run/makefile ==============
if test -f 'hid-1.5.0/run/makefile' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/run/makefile (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/run/makefile (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/run/makefile' &&
run: run.c
X	$(CC) -o run run.c
X	chmod 4755 run
install: run
X	cp run /usr/local/bin
X	chmod 4755 /usr/local/bin/run
clean:
X	rm -f *.o core run
SHAR_EOF
  $shar_touch -am 0819114494 'hid-1.5.0/run/makefile' &&
  chmod 0600 'hid-1.5.0/run/makefile' ||
  echo 'restore of hid-1.5.0/run/makefile failed'
  shar_count="`wc -c < 'hid-1.5.0/run/makefile'`"
  test 141 -eq "$shar_count" ||
    echo "hid-1.5.0/run/makefile: original size 141, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/run/run.c ==============
if test -f 'hid-1.5.0/run/run.c' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/run/run.c (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/run/run.c (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/run/run.c' &&
/* 
X * run a program with a group from the range 900,...,909 added to the
X *   group list
X * Mark Henderson <markh@wimsey.bc.ca>
X * 11 Aug 1994 
X * e.g.
X *  run 0 hostid
X * executes hostid with group 900 added to the group list
X *
X * must be installed setuid root. I recommend 4755 or 4711 for the
X *  permissions
X */
X
X
#include <unistd.h>
#include <limits.h>
#include <stdio.h>
#include <sys/types.h>
X
#define GID_T int 
X  /* should be gid_t for Solaris 2, but it really doesn't matter */
X
GID_T grouplist[NGROUPS_MAX];
#define NHOSTID 10
main(argc,argv)
int argc;
char *argv[];
{
X    int i,j;
X
X    if (argc < 3) {
X        fprintf(stderr, "usage: run <int> command\n");
X        exit(1);
X    }
X    
X    i = getgroups(NGROUPS_MAX, grouplist);
#ifdef DEBUG
X    for (j=0; j< i ; j++)
X        fprintf(stderr, "%d\n", grouplist[j]);
#endif
X    grouplist[i] = (GID_T)(atoi(argv[1]) + 900);
X    if (grouplist[i] < 900 || grouplist[i] >= NHOSTID + 900) {
X        fprintf(stderr, "usage: run <int> command\n<int> is out of range\n");
X        exit(1);
X    }
X
X    if (i >= NGROUPS_MAX) {
X        fprintf(stderr, "already in NGROUPS_MAX groups\n");
X        exit(1);
X    }
X    i = setgroups(i+1, grouplist);
X    if (i < 0) {
X        fprintf(stderr, "setgroups failed\n");
X        exit(1);
X    }
X    seteuid(getuid());
X    execvp(argv[2], argv+2);
}
SHAR_EOF
  $shar_touch -am 0811160194 'hid-1.5.0/run/run.c' &&
  chmod 0600 'hid-1.5.0/run/run.c' ||
  echo 'restore of hid-1.5.0/run/run.c failed'
  shar_count="`wc -c < 'hid-1.5.0/run/run.c'`"
  test 1336 -eq "$shar_count" ||
    echo "hid-1.5.0/run/run.c: original size 1336, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/sethostid-simple-4.1/README ==============
if test ! -d 'hid-1.5.0/sethostid-simple-4.1'; then
  echo 'x - creating directory hid-1.5.0/sethostid-simple-4.1'
  mkdir 'hid-1.5.0/sethostid-simple-4.1'
fi
if test -f 'hid-1.5.0/sethostid-simple-4.1/README' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/sethostid-simple-4.1/README (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/sethostid-simple-4.1/README (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/sethostid-simple-4.1/README' &&
This is based, in part, upon an anonymous contribution. I've improved
it by making it loadable, so one does not have to build a new kernel.
You'll find the original contribution in ../hostid-by-egid
X
This will probably only work on versions of Sun OS later than 4.1.
X
I've tried it on both a Sun 3 and Sun 4.
X
to use this:
make load
make sethostid
X./sethostid 72000000
X
All numbers are in hex. Do NOT put in the leading 0x.
X
You can remove the sethostid call by using modunload. You can check
whether or not it is currently installed with modstat.
X
N.B. sethostid.exec must be executable. Depending upon where you got
the distribution you might have to chmod +x it.
X
Calling sethostid with the hostid of 0 will restore the hostid to the
default.
X
e.g.
X./sethostid 0
X
SHAR_EOF
  $shar_touch -am 0816104894 'hid-1.5.0/sethostid-simple-4.1/README' &&
  chmod 0600 'hid-1.5.0/sethostid-simple-4.1/README' ||
  echo 'restore of hid-1.5.0/sethostid-simple-4.1/README failed'
  shar_count="`wc -c < 'hid-1.5.0/sethostid-simple-4.1/README'`"
  test 767 -eq "$shar_count" ||
    echo "hid-1.5.0/sethostid-simple-4.1/README: original size 767, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/sethostid-simple-4.1/kern_hostid.c ==============
if test -f 'hid-1.5.0/sethostid-simple-4.1/kern_hostid.c' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/sethostid-simple-4.1/kern_hostid.c (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/sethostid-simple-4.1/kern_hostid.c (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/sethostid-simple-4.1/kern_hostid.c' &&
/*
This program is distributed in the hope that it will be useful,
but without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose. You use
this program at your own risk. The author disclaims responsibility for
any damages that might result from the use of this program, even
if they result from negligence on the part of the author.
X
Also, please don't use this program to steal software. The intended
use is for emergency situations where an application has to be moved from
one computer to another (e.g. in the event of a hardware malfunction)
and licence keys cannot be obtained quickly from the vendor. Many
vendors will not supply licence keys outside of business hours.
*/
X
#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/systm.h>
#include <sys/user.h>
#include <sun/vddrv.h>
X
static unsigned hostid = 0;
X
int sethostid();
X
static struct sysent sethostid_sysent = { 1, sethostid } ;
X
static struct vdlsys vd = {
X  VDMAGIC_SYS, /* magic number */
X  "sethostid", /* name */
X  0, /* syscall number (filled in automagically) */
X  &sethostid_sysent /* description of syscall */
};
X
X
Gethostid()
{
X    gethostid();
X
X    if (hostid)  
X    u.u_r.r_val1 = hostid;
X    u.u_error = 0;
X    return;
}
X
sethostid(uap)
X    register struct a {
X        unsigned hostid;
X    } *uap;
{
X    if (!suser()) {
X        u.u_error = EACCES;
X        return;
X    }
X
X    hostid = uap->hostid;
X
X    u.u_r.r_val1 = hostid;
X    u.u_error = 0;
X    return;
}
X
X
sethostidinit(function_code, vdp, vdi, vds)
unsigned int function_code;
struct vddrv *vdp;
addr_t vdi;
struct vdstat *vds;
{
X  switch (function_code) {
X  case VDLOAD:
X    vdp->vdd_vdtab = (struct vdlinkage *)&vd;
X    sysent[SYS_gethostid].sy_narg = 2;
X    sysent[SYS_gethostid].sy_call = Gethostid;
X    return 0;
X  case VDUNLOAD:
X    sysent[SYS_gethostid].sy_narg = 2;
X    sysent[SYS_gethostid].sy_call = gethostid;
X    return 0;
X  case VDSTAT:
X    return 0;
X  default:
X    return EIO;
X  }
}
X
SHAR_EOF
  $shar_touch -am 0816104894 'hid-1.5.0/sethostid-simple-4.1/kern_hostid.c' &&
  chmod 0600 'hid-1.5.0/sethostid-simple-4.1/kern_hostid.c' ||
  echo 'restore of hid-1.5.0/sethostid-simple-4.1/kern_hostid.c failed'
  shar_count="`wc -c < 'hid-1.5.0/sethostid-simple-4.1/kern_hostid.c'`"
  test 1992 -eq "$shar_count" ||
    echo "hid-1.5.0/sethostid-simple-4.1/kern_hostid.c: original size 1992, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/sethostid-simple-4.1/makefile ==============
if test -f 'hid-1.5.0/sethostid-simple-4.1/makefile' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/sethostid-simple-4.1/makefile (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/sethostid-simple-4.1/makefile (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/sethostid-simple-4.1/makefile' &&
CFLAGS = -DKERNEL
ASFLAGS = -P
X
load: kern_hostid.o
X	chmod +x sethostid.exec
X	/usr/etc/modload kern_hostid.o -v -entry _sethostidinit -exec sethostid.exec
X
sethostid: sethostid.o sethostid.h
X	cc -o sethostid -I. sethostid.c
X
clean:
X	rm -f core *.o sethostid kern_hostid sethostid.h
SHAR_EOF
  $shar_touch -am 0816064894 'hid-1.5.0/sethostid-simple-4.1/makefile' &&
  chmod 0600 'hid-1.5.0/sethostid-simple-4.1/makefile' ||
  echo 'restore of hid-1.5.0/sethostid-simple-4.1/makefile failed'
  shar_count="`wc -c < 'hid-1.5.0/sethostid-simple-4.1/makefile'`"
  test 282 -eq "$shar_count" ||
    echo "hid-1.5.0/sethostid-simple-4.1/makefile: original size 282, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/sethostid-simple-4.1/sethostid.c ==============
if test -f 'hid-1.5.0/sethostid-simple-4.1/sethostid.c' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/sethostid-simple-4.1/sethostid.c (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/sethostid-simple-4.1/sethostid.c (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/sethostid-simple-4.1/sethostid.c' &&
/*
This program is distributed in the hope that it will be useful,
but without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose. You use
this program at your own risk. The author disclaims responsibility for
any damages that might result from the use of this program, even
if they result from negligence on the part of the author.
X
Also, please don't use this program to steal software. The intended
use is for emergency situations where an application has to be moved from
one computer to another (e.g. in the event of a hardware malfunction)
and licence keys cannot be obtained quickly from the vendor. Many
vendors will not supply licence keys outside of business hours.
*/
X
#include <stdio.h>
#include <sys/syscall.h>
#include <errno.h>
#include "sethostid.h"
X
main(argc, argv)
int argc;
char *argv[];
{
X  unsigned hostid;
X
X  if (argc<2) {
X    fprintf(stderr, "%s <hostid>\n", argv[0]);
X    exit(1);
X  }
X  sscanf(argv[1], "%x", &hostid);
X  if (syscall(SYS_sethostid, hostid)==-1) {
X    perror(argv[0]);
X    exit(1);
X  }
}  
X
SHAR_EOF
  $shar_touch -am 0816104894 'hid-1.5.0/sethostid-simple-4.1/sethostid.c' &&
  chmod 0600 'hid-1.5.0/sethostid-simple-4.1/sethostid.c' ||
  echo 'restore of hid-1.5.0/sethostid-simple-4.1/sethostid.c failed'
  shar_count="`wc -c < 'hid-1.5.0/sethostid-simple-4.1/sethostid.c'`"
  test 1083 -eq "$shar_count" ||
    echo "hid-1.5.0/sethostid-simple-4.1/sethostid.c: original size 1083, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/sethostid-simple-4.1/sethostid.exec ==============
if test -f 'hid-1.5.0/sethostid-simple-4.1/sethostid.exec' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/sethostid-simple-4.1/sethostid.exec (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/sethostid-simple-4.1/sethostid.exec (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/sethostid-simple-4.1/sethostid.exec' &&
#!/bin/csh -f
echo "#define SYS_sethostid $3" > sethostid.h
SHAR_EOF
  $shar_touch -am 0816063494 'hid-1.5.0/sethostid-simple-4.1/sethostid.exec' &&
  chmod 0700 'hid-1.5.0/sethostid-simple-4.1/sethostid.exec' ||
  echo 'restore of hid-1.5.0/sethostid-simple-4.1/sethostid.exec failed'
  shar_count="`wc -c < 'hid-1.5.0/sethostid-simple-4.1/sethostid.exec'`"
  test 60 -eq "$shar_count" ||
    echo "hid-1.5.0/sethostid-simple-4.1/sethostid.exec: original size 60, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/sethostid-simple-5.3/README ==============
if test ! -d 'hid-1.5.0/sethostid-simple-5.3'; then
  echo 'x - creating directory hid-1.5.0/sethostid-simple-5.3'
  mkdir 'hid-1.5.0/sethostid-simple-5.3'
fi
if test -f 'hid-1.5.0/sethostid-simple-5.3/README' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/sethostid-simple-5.3/README (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/sethostid-simple-5.3/README (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/sethostid-simple-5.3/README' &&
Instructions:
X
You need to do everything below as root.
X
1. Add an entry to /etc/name_to_sysnum for the sethostid system call.
For instance, I use the following line.
sethostid		177
X
Do not put any leading whitespace on the line in /etc/name_to_sysnum.
X
The important thing is to pick an unused syscall number. There
is also a limit on the number you can pick, which is determined
by the size of the sysent table. To find out what the limit is
you can use adb (only in Solaris 2.3 - for 2.4 just be reasonable)
X
adb -k /dev/ksyms /dev/mem
sysentsize/D
^D        #  i.e. control-D
X
You should be able to pick any unused syscall number between 1 and the
number output by adb above minus 1. Alternatively just use an unused
number which is less than the largest number which occurs in
/etc/name_to_sysnum
X
After modifying /etc/name_to_sysnum you must reboot for the change
to take effect.
X
2. Look at the makefile and check that the location of the C compiler is
right for your system. You do NOT want to get /usr/ucb/cc. gcc should
be OK.
X
3. Type
make load
X
This should load the sethostid call. 
X
4. Type 
make sid
X
This makes the program that allows you to modify the hostid for
a particular group.
X
e.g. Now you can modify the hostid to be 23000000 by typing
X./sid 23000000
X
6. You can unload the system call as follows.
X
Type
/usr/sbin/modinfo
X
X You'll get output which includes a line which looks something like
76 fc42d000   621 177   1  sethostid (kern_hostid v1.0)
X
To remove the module type
/usr/sbin/modunload -i 76
Replace 76 by the first number in the line output by modinfo.
X
7. If you like you can install sid and sethostid by typing
make install
X
If you do this, when you reboot, the sethostid module will be
automatically loaded when sethostid is called (i.e. when you run sid).
X
setting the hostid to 0 will restore the default.
SHAR_EOF
  $shar_touch -am 0627001595 'hid-1.5.0/sethostid-simple-5.3/README' &&
  chmod 0600 'hid-1.5.0/sethostid-simple-5.3/README' ||
  echo 'restore of hid-1.5.0/sethostid-simple-5.3/README failed'
  shar_count="`wc -c < 'hid-1.5.0/sethostid-simple-5.3/README'`"
  test 1844 -eq "$shar_count" ||
    echo "hid-1.5.0/sethostid-simple-5.3/README: original size 1844, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/sethostid-simple-5.3/makefile ==============
if test -f 'hid-1.5.0/sethostid-simple-5.3/makefile' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/sethostid-simple-5.3/makefile (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/sethostid-simple-5.3/makefile (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/sethostid-simple-5.3/makefile' &&
CFLAGS = -D_KERNEL 
ASFLAGS = -P
CC = /opt/SUNWspro/bin/cc
X
load: sethostid
X	/usr/sbin/modload ./sethostid
X
sethostid: sethostid.o
X	/usr/ccs/bin/ld -r -o sethostid sethostid.o
X
sid: sid.c
X	grep sethostid /etc/name_to_sysnum | sed 's/^/#define SYS_/' >sethostid.h
X	$(CC) -o sid -I. sid.c
X
install: sethostid sid
X	/usr/sbin/install -f /kernel/sys -m 0755 -u root -g sys ./sethostid
X	/usr/sbin/install -f /usr/local/bin -m 0755 -u root -g sys ./sid
X
clean:
X	rm -f core *.o sid sethostid sethostid.h
SHAR_EOF
  $shar_touch -am 0113152695 'hid-1.5.0/sethostid-simple-5.3/makefile' &&
  chmod 0600 'hid-1.5.0/sethostid-simple-5.3/makefile' ||
  echo 'restore of hid-1.5.0/sethostid-simple-5.3/makefile failed'
  shar_count="`wc -c < 'hid-1.5.0/sethostid-simple-5.3/makefile'`"
  test 496 -eq "$shar_count" ||
    echo "hid-1.5.0/sethostid-simple-5.3/makefile: original size 496, current size $shar_count"
  rm -f _sharnew.tmp
fi
# ============= hid-1.5.0/sethostid-simple-5.3/sethostid.c ==============
if test -f 'hid-1.5.0/sethostid-simple-5.3/sethostid.c' && test X"$1" != X"-c"; then
  echo 'x - skipping hid-1.5.0/sethostid-simple-5.3/sethostid.c (file already exists)'
  rm -f _sharnew.tmp
else
  > _sharnew.tmp
  echo 'x - extracting hid-1.5.0/sethostid-simple-5.3/sethostid.c (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'hid-1.5.0/sethostid-simple-5.3/sethostid.c' &&
/*
This program is distributed in the hope that it will be useful,
but without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose. You use
this program at your own risk. The author disclaims responsibility for
any damages that might result from the use of this program, even
if they result from negligence on the part of the author.
X
Also, please don't use this program to steal software. The intended
use is for emergency situations where an application has to be moved from
one computer to another (e.g. in the event of a hardware malfunction)
and licence keys cannot be obtained quickly from the vendor. Many
SHAR_EOF
  : || echo 'restore of hid-1.5.0/sethostid-simple-5.3/sethostid.c failed'
fi
echo 'End of archive part 3'
echo 'File hid-1.5.0/sethostid-simple-5.3/sethostid.c is continued in part 4'
echo 4 > _sharseq.tmp
exit 0
-- 
Mark Henderson -- markh@wimsey.bc.ca, henderso@netcom.com, mch@squirrel.com
PGP 1024/C58015E3 fingerprint=21 F6 AF 2B 6A 8A 0B E1 A1 2A 2A 06 4A D5 92 46
cryptography archive maintainer  --  ftp://ftp.wimsey.com/pub/crypto
ftp://ftp.netcom.com/pub/he/henderso/change-sun-hostid-1.4.9.tar.gz


