Newsgroups: comp.os.minix
Path: utzoo!utgpu!watserv1!hbetel
From: hbetel@watserv1.uwaterloo.ca (Heather Betel)
Subject: Port I/O and readclock
Message-ID: <1991Jun1.151257.23988@watserv1.waterloo.edu>
Sender: hbetel@watserv1.waterloo.edu (Heather Betel)
Organization: University of Waterloo
Date: Sat, 1 Jun 1991 15:12:57 GMT
Lines: 49


[ From kernel/memory.c in function do_mem() ]
 
#ifdef PORT_DEV
  /* Do special case of /dev/port. */
  if (device == PORT_DEV) {
	port = mem_phys;
	mem_phys = umap(proc_ptr, D, (vir_bytes) &portval, (vir_bytes) 1);
	for (endport = port + count; port != endport; ++port) {
		if (m_ptr->m_type == DISK_READ) {
			portval = in_byte(port);
			phys_copy(mem_phys, user_phys++, (phys_bytes) 1);
		} else {
			phys_copy(user_phys++, mem_phys, (phys_bytes) 1);
			out_byte(port, portval);
		}
	}
	return(count);
  }
#endif
 
This may be slightly wrong, I haven't gotten as far as 1.5.10, I'm at 1.5.6 
or something, but I would love to know what the hell is going on in this code!
 
A program that does:
 
fd=open("/dev/port",O_WRONLY,0);
lseek(fd,port,0);
write(fd,buffer,sizeof(char));
 
*SHOULD* be equivalent to :
out_byte(port, *buffer);
 
But it seems to be:
for (x=0;x!=count;x++){
	out_byte(x,*buffer);
}
This is totally meaningless. I am trying to get readclock to work, and
I am not having any success. Any suggestions would be helpfull.

My system is an AT, with one meg of ram, two harddrives (one is an
eighty meg with three usable partitions, the other is a twenty meg,
with a ten meg partition), two floppy drives, etc... Everything works
fine except readclock, and the fact that my cursor disappears at
random intervals...

BTW, my port device is set up as c,1,4. World read/writeable.


