From c309b18982aa8ed31fd796bcd813732f5f312e6e Mon Sep 17 00:00:00 2001 From: Jiri Svoboda Date: Mon, 27 Nov 2017 17:35:20 +0100 Subject: [PATCH] Move sending side of MSIM console driver out of output server. --- uspace/drv/char/msim-con/msim-con.c | 9 ++++ uspace/drv/char/msim-con/msim-con.h | 2 + uspace/srv/hid/output/Makefile | 1 - uspace/srv/hid/output/output.c | 2 - uspace/srv/hid/output/port/chardev.c | 2 + uspace/srv/hid/output/port/kchar.c | 98 ------------------------------------ uspace/srv/hid/output/port/kchar.h | 41 --------------- 7 files changed, 13 insertions(+), 142 deletions(-) delete mode 100644 uspace/srv/hid/output/port/kchar.c delete mode 100644 uspace/srv/hid/output/port/kchar.h diff --git a/uspace/drv/char/msim-con/msim-con.c b/uspace/drv/char/msim-con/msim-con.c index 07294e817..88c8f67d6 100644 --- a/uspace/drv/char/msim-con/msim-con.c +++ b/uspace/drv/char/msim-con/msim-con.c @@ -105,6 +105,12 @@ int msim_con_add(msim_con_t *con, msim_con_res_t *res) goto error; } + rc = pio_enable((void *)res->base, 1, (void **) &con->out_reg); + if (rc != EOK) { + ddf_msg(LVL_ERROR, "Error enabling I/O"); + goto error; + } + ddf_fun_set_conn_handler(fun, msim_con_connection); con->irq_range[0].base = res->base; @@ -131,6 +137,8 @@ int msim_con_add(msim_con_t *con, msim_con_res_t *res) goto error; } + ddf_fun_add_to_category(fun, "console"); + return EOK; error: if (subscribed) @@ -156,6 +164,7 @@ int msim_con_gone(msim_con_t *con) static void msim_con_putchar(msim_con_t *con, uint8_t ch) { + pio_write_8(con->out_reg, ch); } /** Read from msim console device */ diff --git a/uspace/drv/char/msim-con/msim-con.h b/uspace/drv/char/msim-con/msim-con.h index a86b70c03..821bf6846 100644 --- a/uspace/drv/char/msim-con/msim-con.h +++ b/uspace/drv/char/msim-con/msim-con.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -65,6 +66,7 @@ typedef struct { uint8_t buf[msim_con_buf_size]; fibril_mutex_t buf_lock; fibril_condvar_t buf_cv; + ioport8_t *out_reg; } msim_con_t; extern int msim_con_add(msim_con_t *, msim_con_res_t *); diff --git a/uspace/srv/hid/output/Makefile b/uspace/srv/hid/output/Makefile index e954ff780..e725222c8 100644 --- a/uspace/srv/hid/output/Makefile +++ b/uspace/srv/hid/output/Makefile @@ -34,7 +34,6 @@ LIBS = drv SOURCES = \ ctl/serial.c \ port/ega.c \ - port/kchar.c \ port/chardev.c \ proto/vt100.c \ output.c diff --git a/uspace/srv/hid/output/output.c b/uspace/srv/hid/output/output.c index 460b3833d..5ad499886 100644 --- a/uspace/srv/hid/output/output.c +++ b/uspace/srv/hid/output/output.c @@ -35,7 +35,6 @@ #include #include #include "port/ega.h" -#include "port/kchar.h" #include "port/chardev.h" #include "output.h" @@ -476,7 +475,6 @@ int main(int argc, char *argv[]) if (!config_key_exists("console")) { ega_init(); - kchar_init(); } chardev_init(); diff --git a/uspace/srv/hid/output/port/chardev.c b/uspace/srv/hid/output/port/chardev.c index 4b0cfa120..900226d65 100644 --- a/uspace/srv/hid/output/port/chardev.c +++ b/uspace/srv/hid/output/port/chardev.c @@ -189,6 +189,8 @@ int chardev_init(void) /* OK */ #elif defined(UARCH_sparc64) && defined(PROCESSOR_sun4v) /* OK */ +#elif defined(MACHINE_msim) + /* OK */ #else return EOK; #endif diff --git a/uspace/srv/hid/output/port/kchar.c b/uspace/srv/hid/output/port/kchar.c deleted file mode 100644 index 918787639..000000000 --- a/uspace/srv/hid/output/port/kchar.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2006 Ondrej Palkovsky - * Copyright (c) 2008 Martin Decky - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** @file - */ - -#include -#include -#include -#include -#include -#include -#include -#include "../ctl/serial.h" -#include "kchar.h" - -typedef struct { - uint8_t *addr; -} kchar_t; - -static kchar_t kchar; - -static void kchar_putchar(wchar_t ch) -{ - if (ascii_check(ch)) - *kchar.addr = ch; - else - *kchar.addr = '?'; -} - -static void kchar_control_puts(const char *str) -{ - while (*str) - *kchar.addr = *(str++); -} - -int kchar_init(void) -{ - sysarg_t present; - int rc = sysinfo_get_value("fb", &present); - if (rc != EOK) - present = false; - - if (!present) - return ENOENT; - - sysarg_t kind; - rc = sysinfo_get_value("fb.kind", &kind); - if (rc != EOK) - kind = (sysarg_t) -1; - - if (kind != 3) - return EINVAL; - - sysarg_t paddr; - rc = sysinfo_get_value("fb.address.physical", &paddr); - if (rc != EOK) - return rc; - - kchar.addr = AS_AREA_ANY; - - rc = physmem_map(paddr, - ALIGN_UP(1, PAGE_SIZE) >> PAGE_WIDTH, - AS_AREA_READ | AS_AREA_WRITE, (void *) &kchar.addr); - if (rc != EOK) - return rc; - - return serial_init(kchar_putchar, kchar_control_puts); -} - -/** @} - */ diff --git a/uspace/srv/hid/output/port/kchar.h b/uspace/srv/hid/output/port/kchar.h deleted file mode 100644 index 4354eb470..000000000 --- a/uspace/srv/hid/output/port/kchar.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2006 Ondrej Palkovsky - * Copyright (c) 2008 Martin Decky - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** @file - */ - -#ifndef OUTPUT_PORT_KCHAR_H_ -#define OUTPUT_PORT_KCHAR_H_ - -extern int kchar_init(void); - -#endif - -/** @} - */ -- 2.11.4.GIT