From: James S. <jsi...@ac...> - 2000-09-16 02:02:00
|
> My name is Kirti Desai. I am trying to write a new > console driver. No problem. What are you looking to do? > * Is console related to a tty_driver? A tty is a posix terminals which cover alot of different types of hardware. Everything from modems to serial consoles to video terminals which use hardware like VGA video cards. If you are talking about video consoles (VTs) then they are a subset of ttys types. Remember their are many types of ttys. > We have two functions register_console and register_tty_driver? How are > these two related? As for register_console you are talking about the system console. This is the console where things like kernel errors printed via printk go. Note any kind of tty can be a system console. > In tty_init(tty_io.c) we register dev_tty_driver and > dev_syscons_driver? > In console_init(tty_io.c) con_init(tty_io.c for > CONFIG_VT=y) is > called. It registers console_driver and calls > register_console(vt_console_driver). This is registering a video terminal (VT) as a system console. Thus printks will be sent to this terminal. > * To do printk we need not open the /dev/console file? Printk is handled inside the kernel. Take a look at linux/kernel/printk.c. What do you mean by open? Via userland ? > What I found was > start_kernel(init/main.c) calls console_init and > kernel_thread(init..) > which calls init is called later which opens > /dev/console. Right. First we initalize the the basic termios structure and startup up hardware that can be started early. Later on other types of hardware which depend on other subsystems running such as the PCI bus are called in tty_init. Next /dev/console is opened. I believe this is the first opened file in a linux system thus its file descriptor is 0. It is stdin. With dup we set stdin, stdout, and stderr all equal to each other. if (open("/dev/console", O_RDWR, 0) < 0) printk("Warning: unable to open an initial console.\n"); (void) dup(0); (void) dup(0); Then init is started after the kernel is done. It is the father of all process. It uses the file /etc/inittab to setup all your consoles. > * How are stdin/stdout/stderr mapped to the tty's? See above. > What want to know > if that when we call say printf in user > program,finally write(1,..) gets called which calls > tty_write ,con_write. How does tty come in > picture? printf sends by default data to stdout whcih goes to /dev/console threw the tty layer to con_write if it is VT. > * What are /dev/console /dev/tty0, /dev/tty1 files? /dev/console is the system console (where the printk go). /dev/tty represents the current console for the current process. If I'm on a serial console and do a echo "hi" > /dev/tty it will print out on the screen. If I'm using a console run by fbcon it will do the same thing. Now /dev/tty0 represents the current foreground video console. If you do a echo to /dev/tty0 it will be printed on the current video display. /dev/tty1 and so on represent the virtaul consoles for VTs. Those are the consoles you switch to when you press Alt-F[1-6]. > Any pointer to documentation ..would be of great > help? Not alot. This is a linux console project which just started. See the address in my sig. MS: (n) 1. A debilitating and surprisingly widespread affliction that renders the sufferer barely able to perform the simplest task. 2. A disease. James Simmons [jsi...@li...] ____/| fbdev/console/gfx developer \ o.O| http://www.linux-fbdev.org =(_)= http://linuxgfx.sourceforge.net U http://linuxconsole.sourceforge.net |