Glen Foster <gfoster%ibm-sj.csnet@CSNET-RELAY.ARPA> (11/28/84)
I'm very new to the wizards forum and relatively new to UNIX. However I have as much experience as anyone in our group so I have been given the task of writing a simple device driver. We are more or less trying to simulate pty's in XENIX on a PC-AT (4.2 is not currently an alternative). I have written a first pass device driver that works correctly, but is too slow. It uses the kernel routines passc and cpass to transfer data. I tried to use copyout and copyin, but they do not seem to be working correctly. Basically, I have replaced the code while (passc(c) != -1) { c = next char, etc... } with copyout(ptr_to_start_of_data, (char *) u.u_base, u.u_count); My device driver stopped working. Next, I wrote a simple device driver that used copyin on a write, and copyout on a static string for a read. These routines do not seem to work. Also, the returned value of copyin/copyout is -1 (actually, 65535). Here is the code that I tried. extern struct user u; vikwrite(dev) int dev; char buff[255]; int len = 0; int l; l = u.u_count; len = copyin((char *) u.u_base, buff, l); buff[l] = '?0'; u.u_r.r_reg.r_val1 = l; u.u_count -= l; printf("copyin returned len = %d ?n", len); printf("%s ?n", buff); } char buff[] = "0aaaaaaaaa1aaaaaaaaa2aaaaaaaaa3aaaaaaaaa4aaaaaaaa5"; vikread(dev) int dev; { int len = 0; int l; l = u.u_count; len = copyout(buff, (char *) u.u_base, l); u.u_r.r_reg.r_val1 = l; u.u_count -= l; printf("copyout returned len = %d ?n", len); } We do not have a source liscense so I cannot not look at the code for copyin and copyout. All I have is a brief description I found in a manual called "Writing UNIX Device Drivers" by Bob Nystrom from Momentum Computer Systems, International. I don't even know if the routines are supposed to return the number of bytes transfered. Has anyone out there used these routines and do you have any ideas what I am doing wrong ? I am really operating quite blindly and it can be very frustrating. I am also using tty structures and the standard line switch routines. Again, I don't have the source code. I would like to put data in the raw queue directly and not use ttin. However, when I do this, canon never seems to be called after a newline character is placed in the rawq. Thus, I never have data in canq. Whom does ttin wakeup when he recognizes a newline (or carriage return) ? I assume he does a wakeup on either the canq or rawq, but I don't know. Also, could someone give me a little better idea what else ttin does. What will I lose if I do not use ttin ? Thanks for listening to the plight of a novice UNIX hack. Glen