[comp.unix.xenix] uPort V/386 h/w clock

scott@helium.UUCP (Scott Hazen Mueller) (10/20/87)

For whatever reason, it's not possible to set the AT(-style) hardware clock
on a Microport V/386 system from Unix.  In other words, you've got to boot
the MsDos setup disk in order to reset the h/w clock, and if you're like me,
your built-in clock loses time and your system (software) clock gains time.
Not a pretty situation, nor terribly robust.  Unfortunately for me, the
support person at Microport seems to have been having a bit of difficulty
with the notion of there being two clocks, both of which are wrong.  So, I've
not been able to get them to admit to the existence of a clock setter; given
that, I just decided that I would poke around the /usr/include directory
until I figured out a little about what's going on.  Here's a little hackish
program to throw some settings into the clock, then.

Please note that I'm giving away all rights, such as they are, and have no
intentions of supporting this thing (not as a private citizen, anyway -
anybody wanna hire me? :-) though I'm obviously willing to junk it if it
proves to be a) dangerous or b) superfluous.

Program follows.

         \scott
----- Snip snip -----
/* Set hardware clock.  Input format is on the command line; e.g.

stime <year> <month> <day> <hour> <minute>

with white space separating the arguments (that is, don't concatenate them
into one big schlurg...).  Or, for the perverse the command

stime `date '+ %y %m %d %H %M'`

can be used.  This assumes that your s/w clock is more correct.  Since in
my case, both are usually wrong, I'll keep it simple.

Oh, yeah:  this was written under Microport System V/386, release 1.0.  It
probably won't work under V/AT; it may or may not work on other derivatives
of Interactive's port of System V to the 80386.

                 *****     NO ERROR CHECKING     *****

Scott Hazen Mueller   City of Turlock    901 S. Walnut Rd.  Turlock CA 95380
(209) 668-5590        lll-crg!csustan!helium!scott   uunet!zorch!helium!scott

Disclaimer:  this is *free*; I'm giving it away, hoping to stir someone with
some documentation into writing a real program, with error-checking and all.
I hereby release this program into the public domain and disclaim its fitness
for any purpose whatsoever.  Use at your own risk.

*/

#include <fcntl.h>
#include <sys/rtc.h>

main( argc, argv )
int argc;
char *argv[];
{
char buf[80];				/*	Overkill	*/
int  cd, i;

cd = open( "/dev/rtc", O_RDONLY );

/* This is the way these locations were when I first read them.  They
probably do neat stuff like set daylight savings mode and such.  It'd be
nice if they were documented.	*/

buf[0] = 0x0; buf[1] = buf[3] = buf[5] = 1; buf[6] = 6;

/* This is gross and disgusting.  For some reason, the time values to be
set are hex dates.  That is, if it's October, and you print the month in
decimal, you get '16', but if you use a hex format you get '10'.  What I've
got to do, then, is scan off the args in hex and stuff them into character-
sized locations.  There's probably a better way; what do you expect for
free?	*/

sscanf( argv[1], "%x", &i ); buf[9] |= i;
sscanf( argv[2], "%x", &i ); buf[8] |= i;
sscanf( argv[3], "%x", &i ); buf[7] |= i;
sscanf( argv[4], "%x", &i ); buf[4] |= i;
sscanf( argv[5], "%x", &i ); buf[2] |= i;

/* The year had all of this crud; I dunno why.  Real easy to mask it in,
though.  */

buf[9] |= 0xffffff00;

/* Once you've gotten this far, the actual work is trivially simple.  */

ioctl( cd, RTCSTIME, buf );
close( cd );
}

cam@ptisea.UUCP (Cameron Elliott) (10/22/87)

In article <222@helium.UUCP>, scott@helium.UUCP (Scott Hazen Mueller) writes:
> For whatever reason, it's not possible to set the AT(-style) hardware clock
> on a Microport V/386 system from Unix.  In other words, you've got to boot
> the MsDos setup disk in order to reset the h/w clock, and if you're like me,
> your built-in clock loses time and your system (software) clock gains time.

You should try /etc/cmos_setup to change your cmos parameters,
(including the time.)
 a couple of other interesting utils are /etc/setcolor and /etc/setkey.

	Cameron Elliott 
	Portable Technologies	(I'm lost and don't know my path)

neighorn@qiclab.UUCP (Steve Neighorn) (10/23/87)

In article <222@helium.UUCP> scott@helium.UUCP (Scott Hazen Mueller) writes:
>For whatever reason, it's not possible to set the AT(-style) hardware clock
>on a Microport V/386 system from Unix.  In other words, you've got to boot
>the MsDos setup disk in order to reset the h/w clock, and if you're like me,
>your built-in clock loses time and your system (software) clock gains time.
>Not a pretty situation, nor terribly robust.  Unfortunately for me, the
>support person at Microport seems to have been having a bit of difficulty
>with the notion of there being two clocks, both of which are wrong.  So, I've
>not been able to get them to admit to the existence of a clock setter......
>
I must admit to a bit of confusion, since the 'setup' program that allows
configuration of the V/386 system allows setting of the clock. In fact, the
time zone, date, and time questions are the first questions asked when
running setup. The differences we are experiencing might be due to different
versions of the operating system release. I am running 3.0-U2.2 1 (uname -a).

Thanks for the program though, I will include it in my collection of V/386
specific stuff I am accumulating.

If you are running an older version of the kernel, you might want to see
about upgrading. The version 2.1x kernel has a bunch of fixes over
PreRelease 1.0.
-- 
Steven C. Neighorn                tektronix!{psu-cs,reed}!qiclab!neighorn
Portland Public Schools      "Where we train young Star Fighters to defend the
(503) 249-2000 ext 337           frontier against Xur and the Ko-dan Armada"

scott@helium.UUCP (Scott Hazen Mueller) (10/26/87)

>In article <222@helium.UUCP>, I wrote:
> For whatever reason, it's not possible to set the AT(-style) hardware clock
> on a Microport V/386 system from Unix.  In other words, you've got to boot
> the MsDos setup disk in order to reset the h/w clock, and if you're like me,
> your built-in clock loses time and your system (software) clock gains time.

Various folks have written or posted, including the 386 support person from
Microport.  This is taken care of in the 2.1 release of V/386; since I'm
running pre-release 1.0 still, I didn't have the fix.  Now all I have to do
is wait for my copy of 2.1 to get here...

        \scott
-- 
Scott Hazen Mueller   City of Turlock    901 S. Walnut Rd.  Turlock CA 95380
(209) 668-5590        lll-crg!csustan!helium!scott   uunet!zorch!helium!scott