AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
kmsg.c File Reference

/dev/kmsg (character device 1, 11): the kernel's messages. More...

#include <core/system.h>
#include <dev/dev.h>
#include <fs/posix.h>
#include <ds/ringbuf.h>
#include <sys/sched.h>
#include <console/earlycon.h>
#include <memdev.h>

Go to the source code of this file.

Functions

static ssize_t kmsgdev_read (struct devid *dd, off_t offset, struct iobuf *io)
 Reads the kernel's messages from offset on, a piece at a time through a small buffer.
static ssize_t kmsgdev_write (struct devid *dd, off_t offset, struct iobuf *io)
 Prints what is written as a kernel message.
static int kmsg_file_open (struct file *file)
 Opens /dev/kmsg: its readers wait on the kernel's message queue.

Variables

struct dev kmsgdev
struct ringbuf * kmsg
struct waitq * kmsg_wait

Detailed Description

/dev/kmsg (character device 1, 11): the kernel's messages.

Reading it gives what printk() printed, from the kernel's message ring (kmsg), at the offset the reader is at. Writing to it prints what is written as a kernel message.

Definition in file kmsg.c.

Function Documentation

◆ kmsg_file_open()

int kmsg_file_open ( struct file * file)
static

Opens /dev/kmsg: its readers wait on the kernel's message queue.

Definition at line 75 of file kmsg.c.

References kmsg_file_open(), kmsg_wait, and posix_file_open().

Referenced by kmsg_file_open().

◆ kmsgdev_read()

ssize_t kmsgdev_read ( struct devid * dd,
off_t offset,
struct iobuf * io )
static

Reads the kernel's messages from offset on, a piece at a time through a small buffer.

Definition at line 24 of file kmsg.c.

References iobuf_out(), kmsg, kmsgdev_read(), MIN, and iobuf::resid.

Referenced by kmsgdev_read().

◆ kmsgdev_write()

ssize_t kmsgdev_write ( struct devid * dd,
off_t offset,
struct iobuf * io )
static

Prints what is written as a kernel message.

Definition at line 50 of file kmsg.c.

References iobuf::fault, iobuf_in(), kmsgdev_write(), MIN, printk(), and iobuf::resid.

Referenced by kmsgdev_write().

Variable Documentation

◆ kmsg

struct ringbuf* kmsg
extern

Definition at line 25 of file printk.c.

Referenced by kmsgdev_read(), putc(), puts(), and vt_kmsg_replay().

◆ kmsg_wait

struct waitq* kmsg_wait
extern

Definition at line 26 of file printk.c.

Referenced by kmsg_file_open().

◆ kmsgdev

struct dev kmsgdev
Initial value:
= {
.read = kmsgdev_read,
.write = kmsgdev_write,
.fops = {
.open = kmsg_file_open,
.read = posix_file_read,
.write = posix_file_write,
.close = posix_file_close,
.can_read = __vfs_can_always,
.can_write = __vfs_can_always,
.eof = __vfs_eof_never,
},
}
static ssize_t kmsgdev_read(struct devid *dd, off_t offset, struct iobuf *io)
Reads the kernel's messages from offset on, a piece at a time through a small buffer.
Definition kmsg.c:24
static int kmsg_file_open(struct file *file)
Opens /dev/kmsg: its readers wait on the kernel's message queue.
Definition kmsg.c:75
static ssize_t kmsgdev_write(struct devid *dd, off_t offset, struct iobuf *io)
Prints what is written as a kernel message.
Definition kmsg.c:50
int posix_file_close(struct file *file)
Closes an open file by dropping its reference to its vnode.
Definition close.c:15
ssize_t posix_file_read(struct file *file, struct iobuf *io)
Reads from an open file at its offset, and moves the offset past what was read.
Definition read.c:29
ssize_t posix_file_write(struct file *file, struct iobuf *io)
Writes to an open file at its offset, and moves the offset past what was written.
Definition write.c:25

Definition at line 18 of file kmsg.c.

Referenced by memdev_mux().