Article 13080 of alt.sources:
Newsgroups: alt.sources
Path: nntpd.lkg.dec.com!sousa.amt.tay1.dec.com!pa.dec.com!decwrl!genmagic!sgigate.sgi.com!swrinde!newsfeed.internetmci.com!howland.reston.ans.net!ix.netcom.com!netcom.com!henderso
From: henderso@netcom.com (Mark C. Henderson)
Subject: change sun hostid 1.6.1 -- part 5/5
Message-ID: <hendersoDJyJ0B.2zw@netcom.com>
Organization: Netcom
Date: Thu, 21 Dec 1995 22:12:11 GMT
Lines: 1644
Sender: henderso@netcom12.netcom.com

#!/bin/sh
# This is part 05 of a multipart archive
# ============= hid-1.6.1/dloverlay.c ==============
if test ! -d 'hid-1.6.1'; then
    echo 'x - creating directory hid-1.6.1'
    mkdir 'hid-1.6.1'
fi
if test -f 'hid-1.6.1/dloverlay.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/dloverlay.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/dloverlay.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/dloverlay.c' &&
/*
X * dloverlay.c - dynamic library system call pre-emption
X * brian.s.walden	mcmxciii
X *
X * for Solaris 1.x
X * 
X * cc -O -PIC -c dloverlay.c;ld dloverlay.o -assert pure-text -o dloverlay.so
X * LD_PRELOAD=dloverlay.so
X *
X * currently only overlays gettimeofday(2), hostid(2),
X *  gethostname(2), getdomainname(2), uname(2), and open(2)
X *
X * set any of these envrinment variables:
X *	TIMEOFDAY	set clock offest in seconds: +/- or absolute
X *	HOSTID		hex hostid (0x prefix is OK, non-hex will make it 0)
X *	HOSTNAME	hostname
X *	DOMAINNAME	domainname
X *	SYSNAME		system os type (eg. SunOS)
X *	RELEASE		system os release (eg. 4.1.3)
X *	VERSION		system os version (eg. 5)
X *	MACHINE		machine type (eg. sun4c)
X *	OPEN_DEBUG	setting it in env prints opens on stderr
X *
X * Note: the env vars must be unset and not just nulled out to get back
X * the real syscall operations.
X *
X */
X
#include <string.h>
#include <sys/syscall.h>
X
extern char *getenv();
X
#include <sys/time.h>
X
gettimeofday(tp, tzp)
struct timeval *tp;
struct timezone *tzp;
{
X	int rc;
X	if((rc = syscall(SYS_gettimeofday, tp, tzp)) == 0) {
X		char *tmmod = getenv("TIMEOFDAY");
X		if(tmmod) {
X			long delta = atol(tmmod);
X			switch (*tmmod) {
X			case '-':
X			case '+':
X				tp->tv_sec += delta;
X				break;
X			default:
X				tp->tv_sec = delta;
X				break;
X			}
X		}
X	}
X	return rc;
}
X
gethostid()
{
X	char *strhostid = getenv("HOSTID");
X	long hostid = strhostid ?
X		 strtol(strhostid, (char **)0, 16) : syscall(SYS_gethostid);
X	return hostid;
}
X
gethostname(name, len)
char *name;
{
X	char *hostname = getenv("HOSTNAME");
X	if(hostname && name) {
X		strncpy(name, hostname, len);
X		return 0;
X	}
X	return syscall(SYS_gethostname, name, len);
}
X
getdomainname(name, len)
char *name;
{
X	char *domainname = getenv("DOMAINNAME");
X	if(domainname && name) {
X		strncpy(name, domainname, len);
X		return 0;
X	}
X	return syscall(SYS_getdomainname, name, len);
}
X
#include <sys/utsname.h>
X
uname(name)
struct utsname *name;
{
X	int rc;
X	char *env;
X
X	if( (rc = syscall(SYS_uname, name)) == 0) {
X		/* you have to "know" the utsname structure sizes */
X		if(env=getenv("SYSNAME")) strncpy(name->sysname, env, 8);
X		if(env=getenv("HOSTNAME")) strncpy(name->nodename, env, 64);
X		if(env=getenv("RELEASE")) strncpy(name->release, env, 8);
X		if(env=getenv("VERSION")) strncpy(name->version, env, 8);
X		if(env=getenv("MACHINE")) strncpy(name->machine, env, 8);
X	}
X	return rc;
}
X
#include <stdio.h> /* for stderr */
extern errno;
X
/* WARNING1: this open does not implement the system v
X * style error if given a null path name, see open(2)
X * WARNING2: this does I/O, caveat if you overlay write(2).
X * NB: this should be expanded to decode the flags and errno
X */
open(path, flags, mode)
char *path;
{	
X	char *odebug = getenv("OPEN_DEBUG");
X	int fd;
X
X	if(odebug) fprintf(stderr, "[pid=%d/uid=%d] open(\"%s\", %o, %o) = ",
X			getpid(), getuid(), path, flags, mode);
X	fd = syscall(SYS_open, path, flags, mode);
X	if(odebug) fprintf(stderr, fd==(-1)?"[errno %d]\n":"%d\n",
X			fd==(-1)?errno:fd);
X	return fd;
}
SHAR_EOF
chmod 0600 hid-1.6.1/dloverlay.c ||
echo 'restore of hid-1.6.1/dloverlay.c failed'
Wc_c="`wc -c < 'hid-1.6.1/dloverlay.c'`"
test 3026 -eq "$Wc_c" ||
	echo 'hid-1.6.1/dloverlay.c: original size 3026, current size' "$Wc_c"
fi
# ============= hid-1.6.1/CREDITS ==============
if test -f 'hid-1.6.1/CREDITS' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/CREDITS (File already exists)'
else
echo 'x - extracting hid-1.6.1/CREDITS (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/CREDITS' &&
Thanks to the following for help/code/resources/information.
If I've forgotten anyone, I apologize. Please drop me a note and I'll 
X   correct the list in the next release.
X
Jean-Louis Faraut
Kevin Murty
an anonymous contributor
bf078@cleveland.Freenet.Edu (Brian S Walden)
bogdan@xandau.com (Bogdan Urma)
coughlin@cfa0.harvard.edu (Michael Coughlin)
dowdy@cs.colorado.edu (Stephen Dowdy)
drzob@vectrex.login.qc.ca (Denis Solaro)
sameer@c2.org
weindlin@pcs.mot.com
yokoyama@tkl.iis.u-tokyo.ac.jp
"Roderick Murchison, Jr." <murchiso@Newbridge.COM>
SHAR_EOF
chmod 0600 hid-1.6.1/CREDITS ||
echo 'restore of hid-1.6.1/CREDITS failed'
Wc_c="`wc -c < 'hid-1.6.1/CREDITS'`"
test 547 -eq "$Wc_c" ||
	echo 'hid-1.6.1/CREDITS: original size 547, current size' "$Wc_c"
fi
# ============= hid-1.6.1/hid_solaris2x86.c ==============
if test -f 'hid-1.6.1/hid_solaris2x86.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/hid_solaris2x86.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/hid_solaris2x86.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/hid_solaris2x86.c' &&
/* change the hostid reported by sysinfo and gethostid on Solaris 2.4 x86
X   - run the script this produces on stdout to actually make the change. Note
X     that you must have adb installed to use this 
X
X    e.g. hid_solaris2 b0b1fb0b | sh -v
X
Mark Henderson <markh@wimsey.bc.ca>
Placed in the public domain by the author - June 1995
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
The hostid is stored in ASCII decimal form in the kernel variable
hw_serial. We simply change the in-core value of the string pointed
to by hw_serial.
X
*/
X
#include <stdio.h>
main(argc,argv)
int argc;
char *argv[];
{
X    unsigned int hid;
X    int i;
X    char obuf[15];
X    for (i=0; i<15; i++)
X        obuf[i] = '\0';
X
X    if (argc != 2) {
X        fprintf(stderr, "usage: %s hostid\n",argv[0]);
X        exit(1);
X    }
X    sscanf(argv[1],"%08x",&hid);
X    sprintf(obuf,"%u", hid);  /* should this be %010u ? */
X
X    printf("#!/bin/sh\n");
X    printf("# this script sets the hostid to %08x\n",hid);
X    printf("adb -w -k /dev/ksyms /dev/mem <<END\n");
X    printf("hw_serial/W 0x");
X    for (i=3; i>=0; i--)
X        printf("%02x", obuf[i]);
X    printf("\n");
X    printf("hw_serial+4/W 0x");
X    for (i=7; i>=4; i--)
X        printf("%02x", obuf[i]);
X    printf("\n");
X    printf("hw_serial+8/W 0x");
X    for (i=11; i>=8; i--)
X        printf("%02x", obuf[i]);
X    printf("\n");
X    printf("END\n");
}
SHAR_EOF
chmod 0600 hid-1.6.1/hid_solaris2x86.c ||
echo 'restore of hid-1.6.1/hid_solaris2x86.c failed'
Wc_c="`wc -c < 'hid-1.6.1/hid_solaris2x86.c'`"
test 2058 -eq "$Wc_c" ||
	echo 'hid-1.6.1/hid_solaris2x86.c: original size 2058, current size' "$Wc_c"
fi
# ============= hid-1.6.1/sethostid-simple-5.x/README ==============
if test ! -d 'hid-1.6.1/sethostid-simple-5.x'; then
    echo 'x - creating directory hid-1.6.1/sethostid-simple-5.x'
    mkdir 'hid-1.6.1/sethostid-simple-5.x'
fi
if test -f 'hid-1.6.1/sethostid-simple-5.x/README' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/sethostid-simple-5.x/README (File already exists)'
else
echo 'x - extracting hid-1.6.1/sethostid-simple-5.x/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/sethostid-simple-5.x/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
Look at the define NSYSCALL in /usr/include/sys/systm.h under 2.5
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. If you fail to do this, you'll get a message like:
can't load module: Out of memory or no room in system tables
when you try to load the module
X
2. Look at the makefile and check that the location of the C compiler is
right for your system. Also if you are running Solaris 2.3 or 2.4 you
must uncomment the define -DPRE_SOLARIS_2_5 in the makefile (otherwise
the result will be unpredictable)
X
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
./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 with the sethostid call will restore the default.
SHAR_EOF
chmod 0600 hid-1.6.1/sethostid-simple-5.x/README ||
echo 'restore of hid-1.6.1/sethostid-simple-5.x/README failed'
Wc_c="`wc -c < 'hid-1.6.1/sethostid-simple-5.x/README'`"
test 2232 -eq "$Wc_c" ||
	echo 'hid-1.6.1/sethostid-simple-5.x/README: original size 2232, current size' "$Wc_c"
fi
# ============= hid-1.6.1/sethostid-simple-5.x/makefile ==============
if test -f 'hid-1.6.1/sethostid-simple-5.x/makefile' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/sethostid-simple-5.x/makefile (File already exists)'
else
echo 'x - extracting hid-1.6.1/sethostid-simple-5.x/makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/sethostid-simple-5.x/makefile' &&
# be sure to uncomment the -DPRE_SOLARIS_2_5 for Solaris 2.3 and 2.4
# otherwise this module may cause unpredictable results
CFLAGS = -D_KERNEL  # -DPRE_SOLARIS_2_5
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
chmod 0600 hid-1.6.1/sethostid-simple-5.x/makefile ||
echo 'restore of hid-1.6.1/sethostid-simple-5.x/makefile failed'
Wc_c="`wc -c < 'hid-1.6.1/sethostid-simple-5.x/makefile'`"
test 641 -eq "$Wc_c" ||
	echo 'hid-1.6.1/sethostid-simple-5.x/makefile: original size 641, current size' "$Wc_c"
fi
# ============= hid-1.6.1/sethostid-simple-5.x/sethostid.c ==============
if test -f 'hid-1.6.1/sethostid-simple-5.x/sethostid.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/sethostid-simple-5.x/sethostid.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/sethostid-simple-5.x/sethostid.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/sethostid-simple-5.x/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 outsethostide of business hours.
X
before you install this modify /etc/name_to_sysnum to bind sethostid to 
an _unused_ system call number
X
As far as I can determine the details of how to load system calls in
Solaris 2.3 are undocumented. I've done this by poking around in the
header files in sys and the man pages, and extrapolating from what 
I know about how loadable device drivers work and how the procedure 
works in Solaris 1.1
X
Mark Henderson <markh@wimsey.bc.ca>
14 Aug 1994
*/
X
#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/systm.h>
#include <sys/user.h>
#include <sys/modctl.h>
#include <sys/cred.h>
#include <sys/systeminfo.h>
X
static char serial[16];
char xyzzy_rbuf[16];
X
int sethostid();
X
struct sysent sethostid_sysent = {1,0,sethostid,0};
X
extern struct mod_ops mod_syscallops;
X
static struct modlsys modlsys = {
&mod_syscallops,
"simple sethostid v1.1", 
&sethostid_sysent,
};
X
#ifdef PRE_SOLARIS_2_5
extern systeminfo();
#else
extern longlong_t systeminfo();
#endif
X
static struct modlinkage modlinkage = {
X    MODREV_1, /* magic number */
X    &modlsys, 
X    0
};
X
#ifdef PRE_SOLARIS_2_5
struct as2 {int command; char *buf; long count;};
int new_systeminfo(struct as2 *uap, rval_t *foo)
{
X    int ret,i,bsize;
X    systeminfo(uap,foo);
X    ret = foo->r_val1;
X    if (uap->command == SI_HW_SERIAL) {
X        bsize = (uap->count > 16) ? 16 : uap->count; /* min(16,count)*/
X        if (serial[0]) {
X            for (i=0;i < bsize - 1;i++)
X                xyzzy_rbuf[i]  = serial[i];
X            xyzzy_rbuf[bsize - 1] = 0;
X            ret = strlen(xyzzy_rbuf) + 1;
X            if (copyout(xyzzy_rbuf,uap->buf,ret) < 0)
X                return EFAULT;
X        }
X    }
X    foo->r_val1 = ret;
X    return 0;
}
#else 
longlong_t new_systeminfo(int command, char *buf, long count) 
{
X	longlong_t ret;
X	int bsize,i;
X	int modified = 0;
X	ret = systeminfo(command, buf, count);
X	if (command == SI_HW_SERIAL && serial[0]) {
X       bsize = (count > 16) ? 16 : count; /* min(16,count)*/
X	   for (i=0;i < bsize - 1;i++)
X			xyzzy_rbuf[i]  = serial[i];
X		xyzzy_rbuf[bsize - 1] = 0;
X		ret = strlen(xyzzy_rbuf) + 1;
X		modified = 1;
X		if (copyout(xyzzy_rbuf,buf,ret) < 0)
X			return EFAULT;
X	}
X	if (modified)
X		return (ret << 32);
X	else
X		return ret;
}
#endif
X
struct as {int hostid; };
X
sethostid(struct as *uap, rval_t *foo)
{
X    cred_t *creds = CRED();
X    if (!suser(creds)) {
X        return EACCES;
X    }
X
X    if (!uap->hostid) {
X        serial[0] = '\0';
X        foo->r_val1 = 0;
X    }
X    else {
X        numtos( (unsigned long)uap->hostid, &serial[0]);
X        foo->r_val1 = uap->hostid;
X    }
X    return 0;
}
X
_init(void)
{
X    int status;
X    status = mod_install(&modlinkage);
X    if (!status) {
X        sysent[SYS_systeminfo].sy_narg = 3;
#ifdef PRE_SOLARIS_2_5
X        sysent[SYS_systeminfo].sy_call = new_systeminfo;
#else
X        sysent[SYS_systeminfo].sy_callc = new_systeminfo;
#endif
X        serial[0] = 0;
X    }
X    return status;
}
_fini(void)
{
X    int status;
X    status = mod_remove(&modlinkage);
X    if (!status) {
X        sysent[SYS_systeminfo].sy_narg = 3;
#ifdef PRE_SOLARIS_2_5
X        sysent[SYS_systeminfo].sy_call = systeminfo;
#else
X		/* for Solaris 2.5 and (hopefully) later */
X        sysent[SYS_systeminfo].sy_callc = systeminfo;
#endif
X    }
X    return status;
}
X
_info(struct modinfo *modinfop)
{
X    return (mod_info(&modlinkage, modinfop));
}
SHAR_EOF
chmod 0600 hid-1.6.1/sethostid-simple-5.x/sethostid.c ||
echo 'restore of hid-1.6.1/sethostid-simple-5.x/sethostid.c failed'
Wc_c="`wc -c < 'hid-1.6.1/sethostid-simple-5.x/sethostid.c'`"
test 4092 -eq "$Wc_c" ||
	echo 'hid-1.6.1/sethostid-simple-5.x/sethostid.c: original size 4092, current size' "$Wc_c"
fi
# ============= hid-1.6.1/sethostid-simple-5.x/sid.c ==============
if test -f 'hid-1.6.1/sethostid-simple-5.x/sid.c' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/sethostid-simple-5.x/sid.c (File already exists)'
else
echo 'x - extracting hid-1.6.1/sethostid-simple-5.x/sid.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/sethostid-simple-5.x/sid.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  hostid=strtoul(argv[1], NULL, 16);
X  if (syscall(SYS_sethostid, hostid)==-1) {
X    perror(argv[0]);
X    exit(1);
X  }
}  
X
SHAR_EOF
chmod 0600 hid-1.6.1/sethostid-simple-5.x/sid.c ||
echo 'restore of hid-1.6.1/sethostid-simple-5.x/sid.c failed'
Wc_c="`wc -c < 'hid-1.6.1/sethostid-simple-5.x/sid.c'`"
test 1086 -eq "$Wc_c" ||
	echo 'hid-1.6.1/sethostid-simple-5.x/sid.c: original size 1086, current size' "$Wc_c"
fi
# ============= hid-1.6.1/sethostid-simple-5.x/sethostid.c~ ==============
if test -f 'hid-1.6.1/sethostid-simple-5.x/sethostid.c~' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/sethostid-simple-5.x/sethostid.c~ (File already exists)'
else
echo 'x - extracting hid-1.6.1/sethostid-simple-5.x/sethostid.c~ (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/sethostid-simple-5.x/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 outsethostide of business hours.
X
before you install this modify /etc/name_to_sysnum to bind sethostid to 
an _unused_ system call number
X
As far as I can determine the details of how to load system calls in
Solaris 2.3 are undocumented. I've done this by poking around in the
header files in sys and the man pages, and extrapolating from what 
I know about how loadable device drivers work and how the procedure 
works in Solaris 1.1
X
Mark Henderson <markh@wimsey.bc.ca>
14 Aug 1994
*/
X
#include <sys/param.h>
#include <sys/syscall.h>
#include <sys/systm.h>
#include <sys/user.h>
#include <sys/modctl.h>
#include <sys/cred.h>
#include <sys/systeminfo.h>
X
static char serial[16];
char xyzzy_rbuf[16];
X
int sethostid();
X
struct sysent sethostid_sysent = {1,0,sethostid,0};
X
extern struct mod_ops mod_syscallops;
X
static struct modlsys modlsys = {
&mod_syscallops,
"simple sethostid v1.0", 
&sethostid_sysent,
};
X
extern systeminfo();
X
static struct modlinkage modlinkage = {
X    MODREV_1, /* magic number */
X    &modlsys, 
X    0
};
X
struct as2 {int command; char *buf; long count;};
int new_systeminfo(struct as2 *uap, rval_t *foo)
{
X    int ret,i,bsize;
X    systeminfo(uap,foo);
X    ret = foo->r_val1;
X    if (uap->command == SI_HW_SERIAL) {
X        bsize = (uap->count > 16) ? 16 : uap->count; /* min(16,count)*/
X        if (serial[0]) {
X            for (i=0;i < bsize - 1;i++)
X                xyzzy_rbuf[i]  = serial[i];
X            xyzzy_rbuf[bsize - 1] = 0;
X            ret = strlen(xyzzy_rbuf) + 1;
X            if (copyout(xyzzy_rbuf,uap->buf,ret) < 0)
X                return EFAULT;
X        }
X    }
X    foo->r_val1 = ret;
X    return 0;
}
X
struct as {int hostid; };
X
sethostid(struct as *uap, rval_t *foo)
{
X    cred_t *creds = CRED();
X    if (!suser(creds)) {
X        return EACCES;
X    }
X
X    if (!uap->hostid) {
X        serial[0] = '\0';
X        foo->r_val1 = 0;
X    }
X    else {
X        numtos( (unsigned long)uap->hostid, &serial[0]);
X        foo->r_val1 = uap->hostid;
X    }
X    return 0;
}
X
_init(void)
{
X    int status;
X    status = mod_install(&modlinkage);
X    if (!status) {
X        sysent[SYS_systeminfo].sy_narg = 3;
X        sysent[SYS_systeminfo].sy_call = new_systeminfo;
X        serial[0] = 0;
X    }
X    return status;
}
_fini(void)
{
X    int status;
X    status = mod_remove(&modlinkage);
X    if (!status) {
X        sysent[SYS_systeminfo].sy_narg = 3;
X        sysent[SYS_systeminfo].sy_call = systeminfo;
X    }
X    return status;
}
X
_info(struct modinfo *modinfop)
{
X    return (mod_info(&modlinkage, modinfop));
}
SHAR_EOF
chmod 0600 hid-1.6.1/sethostid-simple-5.x/sethostid.c~ ||
echo 'restore of hid-1.6.1/sethostid-simple-5.x/sethostid.c~ failed'
Wc_c="`wc -c < 'hid-1.6.1/sethostid-simple-5.x/sethostid.c~'`"
test 3237 -eq "$Wc_c" ||
	echo 'hid-1.6.1/sethostid-simple-5.x/sethostid.c~: original size 3237, current size' "$Wc_c"
fi
# ============= hid-1.6.1/nvram.info.old ==============
if test -f 'hid-1.6.1/nvram.info.old' -a X"$1" != X"-c"; then
	echo 'x - skipping hid-1.6.1/nvram.info.old (File already exists)'
else
echo 'x - extracting hid-1.6.1/nvram.info.old (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'hid-1.6.1/nvram.info.old' &&
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 - Dec 1995
- Mark Henderson <markh@wimsey.bc.ca>
X
Thanks to Kevin Murty for the use of an SS1000 (and to the Sun FE
Handbook for the magic "update-system-idprom" command). Other contributors
are noted in the body of the text.
X
I've broken this document into the following parts.
X
I.      Introduction and Hardware
II.     General sun4c, sun4m, sun4d IDPROM Programming
III.    A Quick-and-Dirty Guide to Restoring the NVRAM of a sun4c Machine
X        (SPARC 1/1+/2/IPX/IPC/ELC/SLC)
IV.     The Sun 3/80
V.      Examples
VI.     Odds and Ends
X
-----
X
I.      Introduction and Hardware
X
Every Sun 3/80, sun4c, and sun4m architecture machine contains an NVRAM
chip. This NVRAM chip stores various configuration parameters (e.g.
boot device, amount of RAM to test), maintains the clock, and also
contains the IDPROM data, which is composed of the ethernet address,
date of manufacture, hostid, a version number, and a checksum.  The
name IDPROM is historical.  On older machines (sun2, sun3) the hostid
and ethernet address were stored in a PROM
X
sun4d machines (e.g. SS1000) also have an NVRAM chip. However, the
IDPROM information is stored in a flash EEPROM and is downloaded into
the NVRAM during POST. You can also upload information from the NVRAM
chip to the flash EEPROM. So you can change the value of the flash
EEPROM by merely changing the NVRAM and uploading the new values.
X
At this point I have no information on the new UltraSPARC machines.
X
This document is for people who want to accomplish one of the
following tasks
X
1. Install a virgin NVRAM chip in a Sun 3/80, sun4c, or sun4m machine. 
X   Usually this will be due to NVRAM failure or loss of the NVRAM password in
X   full security mode.
2. Change the hostid/ethernet address of a Sun 3/80, sun4c, sun4m, or
X   sun4d machine.
3. Restore a machine with a corrupted NVRAM chip in a Sun 3/80, sun4c,
X   or sun4m machine to working order.
X
I'm going to focus on methods that involve reprogramming the chip from
the FORTH OPENPROM monitor ("ok" prompt).
X
The NVRAM chip has a usually will have a barcode on it (except for
sun4d).  Given the barcode, Sun can reconstruct your original hostid
and ethernet address. I have no idea how this is done, but the barcode
serves as an easy way to identify the chip.
X
The NVRAM chips are SGS-Thomson Timekeeper (formerly Mostek) chips. They
contain an embedded battery with a fixed life. When the machine is off,
the battery runs down.  It is very common for the battery embedded in
the Timekeeper chip in an older Sun (sun4c, sun3x) to fail.
X
X    Architecture        Chip Type
X    sun3x (3/80)        M48T02
X    sun4c               M48T02
X    sun4m               M48T08
X    sun4d               M48T08
X    sun4u               M48T08
X
X
These chips come in various speeds. The SGS-Thomson part numbers are
M48T02-200PC1 for the 200ns M48T02, M48T08-100PC1 for the 100ns M48T08.
200ns is adequate for any Sun, but often the faster chips are easier to
come by, and there is no harm in buying them. If you have trouble
tracking down a local SGS-Thomson distributor, Mauser electronics sells
the SGS-Thomson Timekeeper chips (800-346-6873, 817-483-5712). The
Mauser part numbers as of 1995 are slighly different and are as
follows:
X
Part no.            Mauser part no.     speed         capacity
M48T02-200PC1       511-M48T02-20PC1    200ns   M48T02  2kB
M48T02-150PC1       511-M48T02-15PC1    150ns   M48T02  2kB
M48T02-120PC1       511-M48T02-12PC1    120ns   M48T02  2kB
M48T08-150PC1       511-M48T08-15PC1    150ns   M48T08  8kB
M48T08-100PC1       511-M48T08-10PC1    100ns   M48T08  8kB
X
As of Oct 1995, the prices for these chips from Mauser range from
US$16.00-23.12.  I have no affiliation with Mauser other than as a
customer
X
Dallas Semicondutor makes a clone of the SGS-Thomson M48T02 chips, the
DS1642.  I've had mixed experience using the Dallas chips in a Sun. My
experience is that these chips do NOT work properly in the following
machines:  3/80, SS2, IPX (they fail POST, but otherwise seem OK)
X
However, I have successfully used them in an SS1 and an IPC.
X
I have no idea whether the Dallas chips work properly in the following:
SLC, ELC, SS1+
X
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
-----
II.     General sun4c, sun4m, sun4d IDPROM Programming
X
If you have a valid NVRAM chip installed (IDPROM is ok) then
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 "ok" prompt by typing the command
.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. 
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 just read it off the table and skip to step 2.
X
X                                addr        space       arch
SS1,SS1+,SS2,ELC,IPC,IPX,SLC    02000000    obio        sun4c
Classic,LX,SS5,SS4,Voyager      71201000    0           sun4m
SS20,SS10                       f1201000    f           sun4m
SS1000                          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/2.5 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   or 
X   /cdrom_root_dir/export/exec/kvm/sparc.Solaris_2.5/platform/sun4c/kernel/drv/eeprom
X
X   Then do a 
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, init 0)
X
--
X
Step 3. 
X
If your IDPROM data is valid, 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
For folks installing a virgin NVRAM, get the first byte of the hostid
from the table at the bottom of this section. The first three bytes
of the ethernet address should be (in hex) 08,00,20.
X
--
Step 4. 
X
Map the physical address determined in step 1 to virtual address 0
using the map-page command. The format of the command (type it at the
"ok" prompt) 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     SS1000  00281000    f    0   map-page
X
--
Step 5. 
X
If you are installing a virgin NVRAM type
set-defaults
Generally a machine will reset the NVRAM to the default values (excluding
the IDPROM information) when it detects a virgin NVRAM. Still, it is
good to do a "set-defaults" just in case this fails.
X
On a sun4c machine, the virtual address of your IDPROM is 7d8. On a 
sun4d or sun4m machine it is fd8.
X
If you are working from a valid or mostly valid IDPROM field, then 
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. Doesn't matter.
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
Unless you are installing a virgin NVRAM, verify that the information
the dump command spits out is consistent with the above and 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 compute 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 to something that doesn't
correspond to your system type (see table below) or the first three
bytes of the ethernet address from (0x08,0x00,0x20). The first byte of
the hostid is often 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 SS1000, 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, SPARC 4, SS1000, Voyager
X
X
-----
III.    A Quick-and-Dirty Guide to Restoring the NVRAM of a sun4c Machine
X        (SPARC 1/1+/2/IPX/IPC/ELC/SLC)
X
This is for folks who need to replace their NVRAM chip in a sun4c
machine and don't want to bother with cumbersome XOR calculations.
I am assuming that you want to replace your NVRAM chip, and you have
a virgin NVRAM chip in hand.
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 as installing it in the wrong orientation and
powering on the machine will generally destroy the chip. 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 section II. - 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
If this is unclear see the examples in section V.
X
-----
IV.     The Sun 3/80
X
Here's a way 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
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
If you are installing a virgin M48T02 chip, you'll also need to initialise
the other values in NVRAM, e.g. boot device, memory, etc. Unlike the
sun4c machines, the Sun 3/80 does not set these parameters to sane
defaults when it detects a virgin M48T02. To modify the rest of NVRAM 
you can use the "q" command in the monitor.
X
The following table of memory locations in NVRAM for the Sun 3 series
machines is from the Sun Hardware Reference 
by James W. Birdsall <jwbirdsa@picarefy.com>
X
I provide it here so you won't have to dig up the Sun Hardware Reference
to restore a 3/80 to working order.
X
X
X        SUN 3 EEPROM/NVRAM Parameters
X
X        0x14    Installed memory
X          Megabytes of memory installed
X
X        0x15    Tested memory
X          Megabytes of memory tested during power-on self test (POST)
X
X        0x16    Monitor screen size
X          0x00   1152 x 900 (standard resolution)
X          0x12   1024 x 1024 (1Kx1K)
X          0x13   1600 x 1280 (high resolution, see locations 0x50 and 0x51)
X          0x14   1440 x 1440
X          0x15   1024 x 768 (low resolution)
X
X        0x17    Watchdog reset action
X          0x00   invoke ROM monitor
X          0x12   imitate power-on reset (default)
X
X        0x18    Operating system boot device
X          0x00   poll (default)
X          0x12   boot from EEPROM/NVRAM specified boot device
X
X        0x19-0x1A  SunOS boot device name (in ASCII)
X          0x78 0x79 (xy)  Xylogics 450/451 SMD controller
X          0x78 0x64 (xd)  Xylogics 7053 SMD controller
X          0x73 0x64 (sd)  SCSI disk
X          0x69 0x65 (ie)  Ethernet (Intel-based controller)
X          0x69 0x64 (id)  IPI disk
X          0x67 0x6E (gn)  ???
X          0x6C 0x65 (le)  Ethernet (Lance-based controller)
X
X        0x1B-0x1D  SunOS boot device controller, unit, partition numbers
X          0x00 0x00 0x00 (0,0,0) (default)
X
X        0x1F    Primary terminal
X          0x00   monochrome framebuffer
X          0x10   serial port A
X          0x11   serial port B
X          0x12   VMEbus and 3/60-P4 color frame buffers (configure
X                  locations 0x60C-0x613 when VX and MVX graphics options
X                  are installed)
X          0x20   non-3/60 P4 color frame buffer
X
X        0x20    Power-up banner
X          0x00   Sun logo display
X          0x12   custom banner stored in 0x68-0xB7
X
X        0x21    Keyboard click
X          0x00   OFF
X          0x12   ON (default)
X
X        0x22-0x23  Diagnostic boot device name (in ASCII)
X          Used when NORM/DIAG switch in DIAG position. As 0x19-0x1A, or
X          0x00 0x00 to invoke ROM monitor.
X
X        0x24-0x26  Diagnotic boot device controller, unit, partition numbers
X          Used when NORM/DIAG switch in DIAG position. As 0x1B-0x1D.
X
X        0x28-0x4F  Diagnostic boot path
X          Used when NORM/DIAG switch in DIAG position. ASCII codes for
X           path and filename(?) to boot, or all zeroes to invoke ROM
X           monitor.
X
X        0x50    High resolution number of columns
X
X        0x51    High resolution number of rows
X
X        0x58    Serial port A default baud rate
X          0x00   9600 baud
X          0x12   use rate stored at 0x59-0x5A
X
X        0x59-0x5A  Serial port A baud rate
X          The baud rate as a 16-bit number, MSB first (e.g. 0x04 0xB0
X           for 1200, 0x12 0xC0 for 4800, 0x25 0x80 for 9600).
X
X        0x5B    Serial port A DTR/RTS
X          0x00   assert DTR and RTS signals
X          0x12   do not assert DTR and RTS signals
X
X        0x60    Serial port B default baud rate
X          0x00   9600 baud
X          0x12   use rate stored at 0x61-0x62
X           Note that when the NORM/DIAG switch is in the DIAG position,
X           port B runs at 1200 baud and the settings of locations
X           0x60-0x62 are ignored.
X
X        0x61-0x62  Serial port B baud rate
X          The baud rate as a 16-bit number, MSB first (e.g. 0x04 0xB0
X           for 1200, 0x12 0xC0 for 4800, 0x25 0x80 for 9600).
X
X        0x63    Serial port B DTR/RTS
X          0x00   assert DTR and RTS signals
X          0x12   do not assert DTR and RTS signals
X
X        0x68-0xB7  Custom banner
X          ASCII codes for desired banner, padded with spaces and ending
X           with 0x0D, 0x0A in locations 0xB6 and 0xB7
X
X        0x111   Sun386i CPU revision level
X          0x01   P1.5 CPU (should not be in the field)
X          0x02   501-1241/1324-xx
X          0x03   501-1413/1414-xx
X
X        0x112   Sun386i CPU revision level
X          0x00   P1.5 CPU (should not be in the field)  ([0x111] = 0x01)
X          0x00   <= 501-1241-02 Rev 15                  ([0x111] = 0x02)
X                 <= 501-1324-02 Rev 15
X          0x02   >= 501-1241-02 Rev 16                  ([0x111] = 0x02)
X                 >= 501-1324-02 Rev 16
X          0x00   501-1413/1414-xx                       ([0x111] = 0x03)
X
X        0x154   Sun386i SCSI spin-up delay (boot ROM >= 4.5 only)
X          0x00   no delay (default)
X          0xnn   delay nn seconds
X
X        0x162   Sun386i password mode select (boot ROM >= 4.5 only)
X          0x01   command secure mode
X          0x5E   fully secure mode
X          other  non-secure mode
X
X        0x163-0x16A  Sun386i password
X          Eight bytes of password in ASCII.
X
X        0x18F   Logo type
X          0x00   normal Sun logo
X          0x06   3D logo for cgsix framebuffers
X          0x12   custom logo
X
X        0x492   Sun386i power-on mode
X          0x02   bypass mode
X          0x06   diagnostic boot
X          0x07   normal boot
X
X                Sun-3 and Sun-4 password mode select (boot ROM >= 2.7.1 only)
X          0x01   command secure mode
X          0x5E   fully secure mode
X          other  non-secure mode
X
X        0x493-0x49A  Sun-3 and Sun-4 password (boot ROM >= 2.7.1 only)
X          Eight bytes of password in ASCII. If the ROM is 2.8, enter a
X          '@' character before each letter of the password. Enter one
X          letter per location, followed by <Return>. If the password is
X          less than eight letters, enter 0x00 in the remaining
X          locations. The hexadecimal values of the letters can also be
X          used to enter the password.
X
X        0x494   Sun386i autoconfig message flag
X          0x00   no messages
X          0x01   Sun-3 (UNIX expert type messages)
X          0x02   verbose messages
X
X        0x60C-0x60F  VX and MVX options boot code
X          0x31 0x40 0x00 0x00   use the VX/MVX as the system console
X
X        0x610-0x61e  VX and MVX options bus type
X          0xFC 0x00 0x00 0x00   use the VX/MVX as the system console
X
X        0x70B   3/80 power-on mode (boot ROM >= 2.3 only)
X          0x06   normal boot
X          0x12   diagnostic mode
X          other full diagnostic boot
X
-----
V.      Examples
X
N.B. AS I'VE SAID ABOVE, YOU SHOULD BE CAREFUL THAT THE FIRST BYTE OF THE 
X     HOSTID MATCHES YOUR SYSTEM TYPE.
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 SS1000 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
4. Install a virgin NVRAM in an IPX. Set the hostid to 57c0ffee and the
X   ethernet address to be 08:00:20:c0:ff:ee
X
X   Remove the old NVRAM
X   Install the new NVRAM (correct orientation!)
X
X   at the forth monitor prompt
X
X   set-defaults
X   02000000 obio 0 map-page
X   setenv diag-switch? false
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
-----
X
VI.     Odds and Ends
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.
X
---
Here is another way to determine the physical address of the NVRAM.
X
1. Use show-devs to find the name of the eeprom device
e.g.
X    ok show-devs
X    ...
X    /obio/eeprom@0,200000
X    ...
X
2. use the cd command to select that device. Then execute .attributes.
X   .attributes will give the virtual address of the NVRAM (and some other
X   information you can safely ignore)
e.g. 
X    ok cd /obio/eeprom@0,200000
X    ok .attributes
X    address: ffee9000
X
3. use pgmap? together with the address from .attributes to determine
X   the physical address
e.g.   
X    ok ffee9000 pgmap?
X    Page: ...
X    Physical: 0.7120.0000
X
4. at the ok prompt execute the following two commands
X   device-end
X   reset
X   
SHAR_EOF
chmod 0600 hid-1.6.1/nvram.info.old ||
echo 'restore of hid-1.6.1/nvram.info.old failed'
Wc_c="`wc -c < 'hid-1.6.1/nvram.info.old'`"
test 27831 -eq "$Wc_c" ||
	echo 'hid-1.6.1/nvram.info.old: original size 27831, current size' "$Wc_c"
fi
exit 0
-- 
Mark Henderson -- markh@wimsey.bc.ca, henderso@netcom.com (personal accounts)
ViaCrypt PGP Key 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.wimsey.com/pub/crypto/sun-stuff/change-sun-hostid-1.6.1.tar.gz


