forked from Imagelibrary/rtems
bsp/riscv: Simplify printk() support
This is a prepartion to add NS16550 driver support to the console driver. Update #3433.
This commit is contained in:
@@ -31,17 +31,13 @@ static htif_console_context htif_console_instance;
|
||||
|
||||
static struct {
|
||||
rtems_termios_device_context *context;
|
||||
void (*write_polled)(
|
||||
rtems_termios_device_context *base,
|
||||
const char *buf,
|
||||
size_t len
|
||||
);
|
||||
int (*poll_char)(rtems_termios_device_context *base);
|
||||
void (*putchar)(rtems_termios_device_context *base, char c);
|
||||
int (*getchar)(rtems_termios_device_context *base);
|
||||
} riscv_console;
|
||||
|
||||
static void riscv_output_char(char c)
|
||||
{
|
||||
(*riscv_console.write_polled)(riscv_console.context, &c, 1);
|
||||
(*riscv_console.putchar)(riscv_console.context, c);
|
||||
}
|
||||
|
||||
static int riscv_get_console_node(const void *fdt)
|
||||
@@ -76,8 +72,8 @@ static void riscv_console_probe(void)
|
||||
htif_console_context_init(&htif_console_instance.base, node);
|
||||
|
||||
riscv_console.context = &htif_console_instance.base;
|
||||
riscv_console.write_polled = htif_console_write_polled;
|
||||
riscv_console.poll_char = htif_console_poll_char;
|
||||
riscv_console.putchar = htif_console_putchar;
|
||||
riscv_console.getchar = htif_console_getchar;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ static void __set_tohost(uintptr_t dev, uintptr_t cmd, uintptr_t data)
|
||||
tohost = TOHOST_CMD(dev, cmd, data);
|
||||
}
|
||||
|
||||
int htif_console_poll_char(rtems_termios_device_context *base)
|
||||
int htif_console_getchar(rtems_termios_device_context *base)
|
||||
{
|
||||
__check_fromhost();
|
||||
int ch = htif_console_buf;
|
||||
@@ -85,7 +85,12 @@ int htif_console_poll_char(rtems_termios_device_context *base)
|
||||
return ch - 1;
|
||||
}
|
||||
|
||||
void htif_console_write_polled(
|
||||
void htif_console_putchar(rtems_termios_device_context *base, char c)
|
||||
{
|
||||
__set_tohost(1, 1, c);
|
||||
}
|
||||
|
||||
static void htif_console_write_polled(
|
||||
rtems_termios_device_context *base,
|
||||
const char *buf,
|
||||
size_t len
|
||||
@@ -94,7 +99,7 @@ void htif_console_write_polled(
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
__set_tohost(1, 1, buf[i]);
|
||||
htif_console_putchar(base, buf[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,6 +132,6 @@ static bool htif_console_first_open(
|
||||
const rtems_termios_device_handler htif_console_handler = {
|
||||
.first_open = htif_console_first_open,
|
||||
.write = htif_console_write_polled,
|
||||
.poll_read = htif_console_poll_char,
|
||||
.poll_read = htif_console_getchar,
|
||||
.mode = TERMIOS_POLLED
|
||||
};
|
||||
|
||||
@@ -41,13 +41,9 @@ void htif_console_context_init(
|
||||
int device_tree_node
|
||||
);
|
||||
|
||||
void htif_console_write_polled(
|
||||
rtems_termios_device_context *base,
|
||||
const char *buf,
|
||||
size_t len
|
||||
);
|
||||
void htif_console_putchar(rtems_termios_device_context *base, char c);
|
||||
|
||||
int htif_console_poll_char(rtems_termios_device_context *base);
|
||||
int htif_console_getchar(rtems_termios_device_context *base);
|
||||
|
||||
const rtems_termios_device_handler htif_console_handler;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user