#include <assert.h>
#include <console/core.h>
#include <console/driver.h>
#include <interrupt.h>
#include <stdarg.h>
#include <string.h>
#include <util.h>

Go to the source code of this file.
Data Structures | |
| struct | printf_conversion |
| Conversion data for vprintf(). More... | |
Enumerations | |
| enum | conversion_state { STATE_NORMAL, STATE_FLAG, STATE_WIDTH, STATE_PERIOD, STATE_PRECISION, STATE_LENGTH, STATE_CONVSPEC } |
| vprintf() format conversion state. More... | |
Functions | |
| static void | console_drv_putchar (struct console_driver *drv, char c) |
| Push one character onto the output buffer. | |
| static void | console_drv_write (struct console_driver *drv, const char *data, size_t len) |
| Write one or more characters to the output buffer. | |
| static int | console_drv_putstr (struct console_driver *drv, const char *str) |
| Push a nul-terminated string onto the output buffer. | |
| static void | console_drv_commit (struct console_driver *drv) |
| Commit the output buffer to the driver. | |
| int | console_putstr (struct console *con, const char *str) |
| Write a string to a console. | |
| int | console_putchar (struct console *con, int c) |
| Write a single character to a console. | |
| static int | console_drv_print_signed (struct console_driver *drv, struct printf_conversion *conv) |
| Print a signed integer according to the conversion specification. | |
| static int | console_drv_print_unsigned (struct console_driver *drv, struct printf_conversion *conv) |
| Print an unsigned integer according to the conversion specification. | |
| int | console_vprintf (struct console *con, const char *format, va_list ap) |
| Formatted output conversion. | |
| int | console_printf (struct console *con, const char *format,...) |
| Formatted output conversion. | |
This is the console core layer, providing simple buffering support and a printf() implementation.
Definition in file console.c.
| enum conversion_state |
vprintf() format conversion state.
This indicates what the parser will be looking for next. The parser may pass through several states for each character in the format conversion spec, as many of the fields are optional.
| STATE_NORMAL | Normal state, passing characters through to the console. |
| STATE_FLAG | Parsing an optional conversion flag. |
| STATE_WIDTH | Parsing an optional field width specifier. |
| STATE_PERIOD | Looking for a period indicating a precision specifier. |
| STATE_PRECISION | Parsing an optional precision specifier. |
| STATE_LENGTH | Parsing an optional length modifier. |
| STATE_CONVSPEC | Parsing the conversion specifier. |
| static void console_drv_commit | ( | struct console_driver * | drv | ) | [static] |
Commit the output buffer to the driver.
This will tell the console driver that the output buffer contains new data, which may trigger the driver to push the data to the hardware.
| drv | The console driver which will eventually handle the data. |
Definition at line 189 of file console.c.
References console_driver::tx_commit.
Referenced by console_putchar(), console_putstr(), and console_vprintf().
| static int console_drv_print_signed | ( | struct console_driver * | drv, | |
| struct printf_conversion * | conv | |||
| ) | [static] |
Print a signed integer according to the conversion specification.
| drv | The console driver that handles the output. | |
| conv | conversion data parsed from the format string. |
Definition at line 237 of file console.c.
References printf_conversion::arg, console_drv_putchar(), console_drv_write(), printf_conversion::d, printf_conversion::pad_char, and printf_conversion::width.
Referenced by console_vprintf().

| static int console_drv_print_unsigned | ( | struct console_driver * | drv, | |
| struct printf_conversion * | conv | |||
| ) | [static] |
Print an unsigned integer according to the conversion specification.
| drv | The console driver that handles the output. | |
| conv | Conversion data parsed from the format string. |
Definition at line 287 of file console.c.
References printf_conversion::arg, console_drv_write(), printf_conversion::pad_char, printf_conversion::spec, printf_conversion::u, and printf_conversion::width.
Referenced by console_vprintf().

| static void console_drv_putchar | ( | struct console_driver * | drv, | |
| char | c | |||
| ) | [static] |
Push one character onto the output buffer.
| drv | The console driver which will eventually handle the data. | |
| c | Character to be appended to the buffer. |
Definition at line 116 of file console.c.
References console_buf_insert_char(), console_buf_unused(), cpu_irq_restore(), cpu_irq_save(), console_driver::tx_buf, and console_driver::tx_make_room.
Referenced by console_drv_print_signed(), console_putchar(), and console_vprintf().

| static int console_drv_putstr | ( | struct console_driver * | drv, | |
| const char * | str | |||
| ) | [static] |
Push a nul-terminated string onto the output buffer.
| drv | The console driver which will eventually handle the data. | |
| str | Nul-terminated string to be appended to the buffer. |
Definition at line 170 of file console.c.
References console_drv_write(), and strlen().
Referenced by console_putstr(), and console_vprintf().

| static void console_drv_write | ( | struct console_driver * | drv, | |
| const char * | data, | |||
| size_t | len | |||
| ) | [static] |
Write one or more characters to the output buffer.
| drv | The console driver which will eventually handle the data. | |
| data | Pointer to the character buffer. | |
| len | Length of the character buffer in bytes. |
Definition at line 141 of file console.c.
References CONSOLE_BUF_SIZE, console_buf_unused(), console_buf_unused_before_end(), cpu_irq_restore(), cpu_irq_save(), console_buffer::data, memcpy(), min, console_buffer::ring, ring_get_head(), ring_insert_entries(), console_driver::tx_buf, and console_driver::tx_make_room.
Referenced by console_drv_print_signed(), console_drv_print_unsigned(), console_drv_putstr(), and console_vprintf().

| int console_printf | ( | struct console * | con, | |
| const char * | format, | |||
| ... | ||||
| ) |
Formatted output conversion.
This is simply a convenience wrapper around console_vprintf() taking a variable number of arguments.
Definition at line 515 of file console.c.
References console_vprintf().

| int console_putchar | ( | struct console * | con, | |
| int | c | |||
| ) |
Write a single character to a console.
| con | The console instance. | |
| c | The character to write. |
Definition at line 217 of file console.c.
References console_drv_commit(), console_drv_putchar(), and console::drv.
Referenced by dbg_priv_putchar().

| int console_putstr | ( | struct console * | con, | |
| const char * | str | |||
| ) |
Write a string to a console.
| con | The console instance. | |
| str | NUL-terminated string. |
Definition at line 202 of file console.c.
References console_drv_commit(), console_drv_putstr(), and console::drv.
Referenced by dbg_priv_putstr().

| int console_vprintf | ( | struct console * | con, | |
| const char * | format, | |||
| va_list | ap | |||
| ) |
Formatted output conversion.
Produce output according to format on the given console. format is interpreted as a regular printf()-style format string with a few limitations (some specifiers are accepted but ignored.)
| con | The console instance. | |
| format | Format specification. | |
| ap | Format arguments as a vararg list. |
Definition at line 361 of file console.c.
References printf_conversion::arg, console_drv_commit(), console_drv_print_signed(), console_drv_print_unsigned(), console_drv_putchar(), console_drv_putstr(), console_drv_write(), printf_conversion::d, console::drv, isdigit(), printf_conversion::length, printf_conversion::n, printf_conversion::p, printf_conversion::pad_char, printf_conversion::precision, printf_conversion::s, printf_conversion::spec, STATE_CONVSPEC, STATE_FLAG, STATE_LENGTH, STATE_NORMAL, STATE_PERIOD, STATE_PRECISION, STATE_WIDTH, printf_conversion::u, and printf_conversion::width.
Referenced by console_printf(), and dbg_priv_vprintf().

1.5.8