diff --git a/tty/pc-tty/ttypc.c b/tty/pc-tty/ttypc.c index 8b5dc5b5..3d5310c7 100644 --- a/tty/pc-tty/ttypc.c +++ b/tty/pc-tty/ttypc.c @@ -117,13 +117,21 @@ static void ttypc_klogClbk(const char *data, size_t size) } -int main(void) +int main(int argc, char **argv) { unsigned int i; char path[12]; oid_t oid; int err; + int isconsole = 1; + if ((argc == 2) && (strcmp(argv[1], "-n") == 0)) { + isconsole = 0; + } + else if (argc != 1) { + return -1; + } + /* Initialize driver */ memset(&ttypc_common, 0, sizeof(ttypc_t)); @@ -198,13 +206,15 @@ int main(void) oid.port = ttypc_common.port; oid.id = 0; - if (create_dev(&oid, _PATH_CONSOLE) < 0) { - fprintf(stderr, "pc-tty: failed to register device %s\n", _PATH_CONSOLE); - } + if (isconsole != 0) { + if (create_dev(&oid, _PATH_CONSOLE) < 0) { + fprintf(stderr, "pc-tty: failed to register device %s\n", _PATH_CONSOLE); + } - libklog_init(ttypc_klogClbk); - oid_t kmsgctrl = { .port = ttypc_common.port, .id = KMSG_CTRL_ID }; - libklog_ctrlRegister(&kmsgctrl); + libklog_init(ttypc_klogClbk); + oid_t kmsgctrl = { .port = ttypc_common.port, .id = KMSG_CTRL_ID }; + libklog_ctrlRegister(&kmsgctrl); + } /* Register devices */ for (i = 0; i < NVTS; i++) { diff --git a/tty/uart16550/Makefile b/tty/uart16550/Makefile index 469188d5..cf29875e 100644 --- a/tty/uart16550/Makefile +++ b/tty/uart16550/Makefile @@ -12,6 +12,9 @@ ifeq ($(TARGET_FAMILY),riscv64) LOCAL_SRCS += uarthw-riscv.c else ifeq ($(TARGET_FAMILY),ia32) LOCAL_SRCS += uarthw-pc.c + ifneq ($(CONSOLE),serial) + LOCAL_CFLAGS += -DNCONSOLE + endif else ifeq ($(TARGET_SUBFAMILY),zynq7000) LOCAL_SRCS += uarthw-zynq7000.c endif diff --git a/tty/uart16550/uart16550.c b/tty/uart16550/uart16550.c index 47b67637..25bf769f 100644 --- a/tty/uart16550/uart16550.c +++ b/tty/uart16550/uart16550.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -269,7 +270,7 @@ static void uart_klogClbk(const char *data, size_t size) } -static void _uart_mkDev(uint32_t port) +static void _uart_mkDev(uint32_t port, int isconsole) { char path[12]; unsigned int i; @@ -277,7 +278,7 @@ static void _uart_mkDev(uint32_t port) for (i = 0; i < sizeof(uart_common.uarts) / sizeof(uart_common.uarts[0]); i++) { if (uart_common.uarts[i].init == 1) { uart_common.uarts[i].oid.port = port; - uart_common.uarts[i].oid.id = (i == UART16550_CONSOLE_USER) ? 0 : i + 1; + uart_common.uarts[i].oid.id = ((isconsole != 0) && (i == UART16550_CONSOLE_USER)) ? 0 : i + 1; snprintf(path, sizeof(path), "/dev/ttyS%u", i); if (create_dev(&uart_common.uarts[i].oid, path) < 0) { @@ -285,7 +286,7 @@ static void _uart_mkDev(uint32_t port) return; } - if (i == UART16550_CONSOLE_USER) { + if ((isconsole != 0) && (i == UART16550_CONSOLE_USER)) { libklog_init(uart_klogClbk); if (create_dev(&uart_common.uarts[i].oid, _PATH_CONSOLE) < 0) { @@ -350,12 +351,20 @@ static int _uart_init(uart_t *uart, unsigned int uartn, unsigned int speed) } -int main(void) +int main(int argc, char **argv) { unsigned int i; uint32_t port; int err; + int isconsole = 1; + if ((argc == 2) && (strcmp(argv[1], "-n") == 0)) { + isconsole = 0; + } + else if (argc != 1) { + return -1; + } + portCreate(&port); for (i = 0; i < sizeof(uart_common.uarts) / sizeof(uart_common.uarts[0]); i++) { @@ -371,7 +380,7 @@ int main(void) } beginthread(poolthr, 4, uart_common.stack, sizeof(uart_common.stack), (void *)(uintptr_t)port); - _uart_mkDev(port); + _uart_mkDev(port, isconsole); poolthr((void *)(uintptr_t)port); return EXIT_SUCCESS;