[net.unix-wizards] CPU ID under UNIX

abbajay@oracle.UUCP (Dave Abbajay) (11/07/85)

The VAX hardware supports the ability of obtaining the CPU id. Under
VMS its obtained by the call to LIB$GETSYI. Has anyone done this
under UNIX. It is a priveleged instruction, therefore it probably
means a kernel hack or a device driver to get it (unless there
is another way for a user to execute in kernel mode that I'm
not aware of). Any help would be appreciated.

As an aside, wouldn't this be an appropriate discussion for,
say, mod.std.unix (or is it mod.unix.std). I'd like to see
a standard system call in UNIX for doing this (provided hardware
support, of course).

-- 
Dave Abbajay
Senior Technical Staff
ORACLE Corporation
(415)854-7350                                    hplabs!oracle!abbajay

guy@sun.uucp (Guy Harris) (11/09/85)

> The VAX hardware supports the ability of obtaining the CPU id.

I don't remember seeing this in the 750 or 730 CPU descriptions, but it may
be there.

> Under VMS its obtained by the call to LIB$GETSYI. Has anyone done this
> under UNIX.
> ...
> I'd like to see a standard system call in UNIX for doing this (provided
> hardware support, of course).

Sun threw out "sethostid" from 4.2 and changed "gethostid" to return the
host ID from the ID PROM.  The 4.2 manual says that this 32-bit identifier
is "intended to be unique among all UNIX systems in existence."  It also
says that it is normally the Internet address of the machine; this begs the
question of gateway machines which don't have something which can be called
*the* Internet address of the machine.  I don't think any 4.2 code uses this
number as the Internet address (all the code either does a "gethostname" and
a "gethostbyname", or looks at the address the host has *on a particular
interface*).  I suspect the only reason the Internet address is mentioned is
that it will be a 32-bit number which is guaranteed to be unique; of course,
if you're not on the Internet (or, at least, don't have a properly-assigned
Internet address), you're out of luck.

If all VAXes have a (32 bit) serial number register, this register's
contents (or the serial number part; it may contain hardware or microcode
rev levels and the like as well) could serve the same purpose on a VAX; just
rip out "sethostid" and change "gethostid" to get the CPU ID.

Of course, if not all VAX CPUs *have* a machine-readable CPU serial number,
the whole discussion is somewhat moot (I think it just contains rev levels,
plant IDs, and the like on other VAXes).

	Guy Harris

rees@apollo.uucp (Jim Rees) (11/11/85)

Under Apollo unix (domain/ix) it's a standard environment variable,
NODEID, and gets set when you log in.

rml@hpfcla.UUCP (11/14/85)

> The VAX hardware supports the ability of obtaining the CPU id. Under
> VMS its obtained by the call to LIB$GETSYI. Has anyone done this
> under UNIX. 

At HP we have extended the utsname structure returned by uname(2) to
include a field (array of char) for the CPU id.  The field contains all
nulls for hardware without a machine-readable id.

		Bob Lenk
		{hplabs, ihnp4}!hpfcla!rml

jensen@muscat.UUCP (Paul Jensen) (11/14/85)

If you want to access the VAX SID register in order to generate a unique
per CPU number, it will not work.  The format of the VAX SID register is

            31        23     14      11           0
           +---------+------+-------+--------------+
           |  type=1 | ECO  | plant | serial #     |  for a 780
           +---------+------+-------+--------------+

            31        23        15        7       0
           +---------+---------+---------+---------+
           |  type   |    0    | uc rev  | hdw rev |  for most other VAXes
           +---------+---------+---------+---------+

Even for the 780, there are only 4096 unique serial numbers per plant,
and I suspect this has rolled over many times.  As for getting the
number itself, you need to be in kernel mode to execute the MFPR
instruction: this is a relatively straightforward kernel hack.

If your main interest is generating a unique number, you might
instead try reading the physical ethernet address of your DEUNA
(assuming you have one).  Be forewarned, that even a unique number
will not protect proprietary software against the clever (& privileged)
end-user.

Regards,


					/Paul Jensen


-- 
# remove this line - this signature is appended to any news you post #
					My Name
					DEC Western Region Operations
					decwrl!muscat!username
					decwrl!dec-rhea!dec-wer521!username
					WER521::USERNAME

aps@decwrl.UUCP (Armando P. Stettner) (11/22/85)

	From hpfcla!rml Thu Nov 21 02:11:52 1985
	Newsgroups: net.unix-wizards
	Subject: Re: Cpu ID under UNIX
	Message-Id: <12700001@hpfcls.UUCP>
	Date: 13 Nov 85 21:16:00 GMT
	Apparently-To: aps
	Status: RO
	
	
	> The VAX hardware supports the ability of obtaining the CPU id. Under
	> VMS its obtained by the call to LIB$GETSYI. Has anyone done this
	> under UNIX. 
	
	At HP we have extended the utsname structure returned by uname(2) to
	include a field (array of char) for the CPU id.  The field contains all
	nulls for hardware without a machine-readable id.
	
			Bob Lenk
			{hplabs, ihnp4}!hpfcla!rml
	

It has been said in this news group in the past but just a reminder: the VAX
CPUID register may not contain anything akin to a serial number.  The 780's
serial number is some small number with respect to a manufacturing location
which has certainly turned over a few times.  The 750 has no such thing
in the SID.  Info about revision levels and such are driven by jumpers
on the CPU backplane so one can't really trust that unless you know that
your field service person has set those properly.

In my opinion, allowing non-system management type programs to know
about processor type is a little precarious.  What would it be used
for (in non-system management type programs that is; and even in
system management type programs ...)?
	aps.