Mike Crowe
Mike Crowe

Reputation: 2284

Writing to linux console without using printk

This may be a stupid question, but is there a way to write to the linux console from within a driver without using printk (i.e. syslog)?

For instance, working in a linux driver, I need to output a single character as an event happens. I'd like to output 'w' as an write event starts, and a 'W' when it finishes. This happens frequently, so sending that through syslog isn't ideal.

Ideally, it would be great if I could just do the equivalent of printf("W") or putc('W') and have that simply go out the default console.

TIA Mike

Upvotes: 2

Views: 2067

Answers (2)

ugoren
ugoren

Reputation: 16441

Writing to the console isn't something you want to do frequently. If printk is too expensive for you, you shouldn't try the console any way.

But if you insist:

Within printk, printing to the console is handled by call_console_drivers. This function finds the console (registered via register_console) and calls it to print the data. The actual driver depends on what console you're using. The VGA screen is one option, the serial port is another (depending on boot parameters).

You can try to use the functions in console.h to interact with the console directly. I don't know how hard it would be to make it work.

Upvotes: 4

Toote
Toote

Reputation: 3413

Unfortunately no, as there is no concept of "console" in the kernel (that is a userspace process). You may try other kernel debugging options

Upvotes: 0

Related Questions