linux/drivers/char/ttyprintk.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  linux/drivers/char/ttyprintk.c
 *
 *  Copyright (C) 2010  Samo Pogacnik
 */

/*
 * This pseudo device allows user to make printk messages. It is possible
 * to store "console" messages inline with kernel messages for better analyses
 * of the boot process, for example.
 */

#include <linux/console.h>
#include <linux/device.h>
#include <linux/serial.h>
#include <linux/tty.h>
#include <linux/module.h>
#include <linux/spinlock.h>

struct ttyprintk_port {};

static struct ttyprintk_port tpk_port;

/*
 * Our simple preformatting supports transparent output of (time-stamped)
 * printk messages (also suitable for logging service):
 * - any cr is replaced by nl
 * - adds a ttyprintk source tag in front of each line
 * - too long message is fragmented, with '\'nl between fragments
 * - TPK_STR_SIZE isn't really the write_room limiting factor, because
 *   it is emptied on the fly during preformatting.
 */
#define TPK_STR_SIZE
#define TPK_MAX_ROOM
#define TPK_PREFIX

static int tpk_curr;

static u8 tpk_buffer[TPK_STR_SIZE + 4];

static void tpk_flush(void)
{}

static int tpk_printk(const u8 *buf, size_t count)
{}

/*
 * TTY operations open function.
 */
static int tpk_open(struct tty_struct *tty, struct file *filp)
{}

/*
 * TTY operations close function.
 */
static void tpk_close(struct tty_struct *tty, struct file *filp)
{}

/*
 * TTY operations write function.
 */
static ssize_t tpk_write(struct tty_struct *tty, const u8 *buf, size_t count)
{}

/*
 * TTY operations write_room function.
 */
static unsigned int tpk_write_room(struct tty_struct *tty)
{}

/*
 * TTY operations hangup function.
 */
static void tpk_hangup(struct tty_struct *tty)
{}

/*
 * TTY port operations shutdown function.
 */
static void tpk_port_shutdown(struct tty_port *tport)
{}

static const struct tty_operations ttyprintk_ops =;

static const struct tty_port_operations tpk_port_ops =;

static struct tty_driver *ttyprintk_driver;

static struct tty_driver *ttyprintk_console_device(struct console *c,
						   int *index)
{}

static struct console ttyprintk_console =;

static int __init ttyprintk_init(void)
{}

static void __exit ttyprintk_exit(void)
{}

device_initcall(ttyprintk_init);
module_exit(ttyprintk_exit);

MODULE_DESCRIPTION();
MODULE_LICENSE();