From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 13 Jul 2004 07:57:15 -0600 From: ron minnich To: 9fans@cse.psu.edu Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: [9fans] port/devcons.c is not port-able Topicbox-Message-UUID: bf86fe80-eacd-11e9-9e20-41e7f4b1d025 working with Xen has convinced me that devcons.c is not totally portable. The key problems are assumptions that certain devices are there, such as a uart. Also, there is the /* * how many different output devices do we need? */ comment, which leads me to believe whoever wrote it was thinking that all the permuations of devices for devcons were getting out of hand. There are a lot of cases in there. Your kernel has to define some symbols it might not really want to. If you don't have a uart, what do you do about uartputs? You have to define a dummy of course. So I got to wondering: what if we used the fact that namec is so simple and easy in the kernel? Define the following two files in devcons.c: consout consin Let me take the case of consout first. If you write this: +file to consout, devcons driver does a namec of 'file' and adds it to the list of files it writes to when it does output. So, e.g., echo +/dev/eia0 >>/dev/consout will add serial output for console output. Of course it can go to a file: echo +/log/console >>/dev/consout or a socket: echo +/net/tcp/blahblah >>/dev/consout (console logging to a remote machine) or a window you want: echo +/dev/wsys/9/cons >>/dev/consout console output goes to the window of your choice (try doing that in X!) or a pipe or whatever. to remove a file that is used as console output echo -file >>/dev/consout you can select some devices: cat /dev/consout | sed '/eai0/s/\+/-/' > /dev/consout eliminates console output to eia0 Now, we've got a really portable console output design. You can do the initial setup in main() in the kernel, you remove all the special cases, and you don't need special things like uartputs in devcons.c OK, what about input? I don't know. The multiple output case is easy to do, the input case I don't understand in all variants due to the use of interrupts for console input devices. I don't know how to hook them up. Currently, as interrupts happen on (e.g.) /dev/eia0, there is a callback (what else to call it?) that is provided by /dev/console to buffer up the characters and lower interrupt overhead. The driver for a console device has to know it is a driver for a console device, and it has to call the right thing in devcons. You get multiple console devices by making sure that each device that *might* be a console knows to call one of several console handlers from their own interrupt handler (I have the Xen stuff call echo()). Unlike almost everything else in Plan 9, you can't really use any random file for a console. So: echo +/dev/eia0 >>/dev/consin echo +/dev/xencons >>/dev/consin is not going to work, since xencons might be a socket. So does that kill this whole idea, or is there a way to do it, or is it just a bad idea? ron