[comp.os.minix] UUPC amd READCLOCK under 1.5.0

clegg@tomcat.rtp.dg.com (Alan Clegg) (01/12/90)

Has anyone successfully compiled/run UUPC under 1.5.0?  I have compiled
libmodemcap.a and gotten everything
working OK there, but when it attempts to dial, it fails.  When I
attempt to use 'term' at that point,
I have to use E/7 and can't get 8 bit to work anymore.  One change I had
to make was to remove the
definition of ANYP from dial.h (used the one from /usr/include/sgtty.h).  

Also, has anyone gotten readclock to work?  With /dev/port being created
with 'mknod /dev/port b 1 4',
readclock will print all zeros then hard-hang the machine.  I have tried
fixing lib/other/portio.c to open
/dev/port as O_RDWR in both places, but that does not seem to help.

-abc



        Alan Clegg				clegg@dg-rtp.dg.com
	Industry Standard Applications		clegg@verity.uucp
	Data General Corp.			{...!mcnc!verity!clegg}

	   YRAC Rural Fire Department -- Wake County Station 29

evans@ditsyda.oz (Bruce Evans) (01/15/90)

In article <2124@xyzzy.UUCP> clegg@tomcat.rtp.dg.com (Alan Clegg) writes:
>Also, has anyone gotten readclock to work?  With /dev/port being created
>with 'mknod /dev/port b 1 4',
>readclock will print all zeros then hard-hang the machine.  I have tried

It is vital to make /dev/port a character device. When it is a block
device, the FS will "serve" you by padding out i/o requests to 1K, with
disastrous consequences.

David Dyck already reposted some of my old docs on setting up readclock.
I will repeat them in more detail. I broke lib/portio.c and lib/peekpoke.c
for 1.5.0 :-[ and enclose fixed versions (these should be in 1.5.1).

To make /dev/port:

    su bin                  # some suitably privileged user (maybe root)
    mknod /dev/port c 1 4   # must be character device
    chmod 600 /dev/port     # must not be writable, best not readable by all

If /dev/mem has a nonzero size in its inode, change the size to 0 with:

    su bin                  # if not already bin from above
    rm /dev/mem
    mknod /dev/mem c 1 1
    chmod 644 /dev/mem      # 600 for more security

My versions look like this:

crw-r--r--  1 bin      bin        1,  1 Mar 25  1989 /dev/mem
crw-------  1 bin      bin        1,  4 Jan 19  1989 /dev/port

Install the fixed library files. Then readclock should work. Of course you
have to be root or bin (or someone with read/write permissions on the
devices) to read the time, and root to set the time.

The only other program that I use which accesses the ports is 'fastkey'
(not in 1.5.0). It works OK without changes, but to be correct it should
check the values returned from port_in and port_out for -1 (no access to
devices).  Without this check, it gives a timeout error (after a *long*
time because the new interface is slow) when it can't access the ports,
because -1 doesn't look like the keyboard ack code.

I tried making /dev/port a block device, to see how bad the crash was. It
trashed the superblock of the root partition (/dev/hd3) in a strange way
which fortunately was easy to recover from! The superblock seemed to be
shifted 2 bytes to the right, padded by zeros. I edited the superblock and
all was well. I repeated the crash without meaning to by forgetting to
delete the bad /dev/port. The superblock was trashed again in exactly the
same way.

33070   1105 /usr/src/lib/other/peekpoke.c
47521   1026 /usr/src/lib/other/portio.c

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  peekpoke.c portio.c
# Wrapped by evans@ditsyda on Mon Jan 15 22:46:51 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'peekpoke.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'peekpoke.c'\"
else
echo shar: Extracting \"'peekpoke.c'\" \(1105 characters\)
sed "s/^X//" >'peekpoke.c' <<'END_OF_FILE'
X/* Peek and poke using /dev/mem.
X *
X * Callers now ought to check the return values.
X *
X * Calling peek() requires read permission on /dev/mem, and consumes
X * a file descriptor.  Calling poke() requires write permission, and
X * consumes another file descriptor.
X */
X
X#include <sys/types.h>
X#include <fcntl.h>
X#include <unistd.h>
X
X#define SEGSIZE 0x10
X
Xint peek(segment, offset)
Xunsigned segment;
Xunsigned offset;
X{
X  unsigned char chvalue;
X  static int infd = -1;
X
X  if (infd < 0) infd = open("/dev/mem", O_RDONLY);
X  if (infd < 0 ||
X      lseek(infd, (unsigned long) segment * SEGSIZE + offset, SEEK_SET) < 0 ||
X      read(infd, (char *) &chvalue, (unsigned) 1) != 1)
X	return(-1);
X  return(chvalue);
X}
X
Xint poke(segment, offset, value)
Xunsigned segment;
Xunsigned offset;
Xunsigned value;
X{
X  unsigned char chvalue;
X  static int outfd = -1;
X
X  chvalue = value;
X  if (outfd < 0) outfd = open("/dev/mem", O_WRONLY);
X  if (outfd < 0 ||
X      lseek(outfd, (unsigned long) segment * SEGSIZE + offset, SEEK_SET) < 0 ||
X      write(outfd, (char *) &chvalue, (unsigned) 1) != 1)
X	return(-1);
X  return(chvalue);
X}
END_OF_FILE
if test 1105 -ne `wc -c <'peekpoke.c'`; then
    echo shar: \"'peekpoke.c'\" unpacked with wrong size!
fi
# end of 'peekpoke.c'
fi
if test -f 'portio.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'portio.c'\"
else
echo shar: Extracting \"'portio.c'\" \(1026 characters\)
sed "s/^X//" >'portio.c' <<'END_OF_FILE'
X/* Port i/o functions using /dev/port.
X *
X * Callers now ought to check the return values.
X *
X * Calling port_in() requires read permission on /dev/port, and consumes
X * a file descriptor.  Calling port_out requires write permission, and
X * consumes another file descriptor.
X */
X
X#include <sys/types.h>
X#include <fcntl.h>
X#include <unistd.h>
X
Xint port_in(port, valuep)
Xunsigned port;
Xunsigned *valuep;
X{
X  unsigned char chvalue;
X  static int infd = -1;
X
X  if (infd < 0) infd = open("/dev/port", O_RDONLY);
X  if (infd < 0 ||
X      lseek(infd, (long) port, SEEK_SET) < 0 ||
X      read(infd, (char *) &chvalue, (unsigned) 1) != 1)
X	return(*valuep = -1);
X  return(*valuep = chvalue);
X}
X
Xint port_out(port, value)
Xunsigned port;
Xunsigned value;
X{
X  unsigned char chvalue;
X  static int outfd = -1;
X
X  chvalue = value;
X  if (outfd < 0) outfd = open("/dev/port", O_WRONLY);
X  if (outfd < 0 ||
X      lseek(outfd, (long) port, SEEK_SET) < 0 ||
X      write(outfd, (char *) &chvalue, (unsigned) 1) != 1)
X	return(-1);
X  return(chvalue);
X}
END_OF_FILE
if test 1026 -ne `wc -c <'portio.c'`; then
    echo shar: \"'portio.c'\" unpacked with wrong size!
fi
# end of 'portio.c'
fi
echo shar: End of shell archive.
exit 0
-- 
Bruce Evans		evans@ditsyda.oz.au