diff --git a/configs/boardctl.c b/configs/boardctl.c index d8229c29c5..79a0235796 100644 --- a/configs/boardctl.c +++ b/configs/boardctl.c @@ -424,6 +424,57 @@ int boardctl(unsigned int cmd, uintptr_t arg) break; #endif +#ifdef CONFIG_NXTERM + /* CMD: BOARDIOC_NXTERM + * DESCRIPTION: Create an NX terminal device + * ARG: A reference readable/writable instance of struct + * boardioc_nxterm_create_s + * CONFIGURATION: CONFIG_NXTERM + * DEPENDENCIES: Base NX terminal logic provides nx_register() and + * nxtk_register() + */ + + case BOARDIOC_NXTERM: + { + FAR struct boardioc_nxterm_create_s *nxterm = + (FAR struct boardioc_nxterm_create_s *)arg; + + if (nxterm == NULL) + { + ret = -EINVAL; + } + else if (nxterm->type == BOARDIOC_XTERM_RAW) + { + nxterm->nxterm = nx_register((NXWINDOW)nxterm->hwnd, + &nxterm->wndo, + (int)nxterm->minor); + + ret = nxterm->nxterm == NULL ? -ENODEV : OK; + } + else if (nxterm->type == BOARDIOC_XTERM_FRAMED) + { + nxterm->nxterm = nxtk_register((NXTKWINDOW)nxterm->hwnd, + &nxterm->wndo, + (int)nxterm->minor); + + ret = nxterm->nxterm == NULL ? -ENODEV : OK; + } + else if (nxterm->type == BOARDIOC_XTERM_TOOLBAR) + { + nxterm->nxterm = nxtool_register((NXTKWINDOW)nxterm->hwnd, + &nxterm->wndo, + (int)nxterm->minor); + + ret = nxterm->nxterm == NULL ? -ENODEV : OK; + } + else + { + ret = -EINVAL; + } + } + break; +#endif + #ifdef CONFIG_BOARDCTL_TESTSET /* CMD: BOARDIOC_TESTSET * DESCRIPTION: Access architecture-specific up_testset() operation diff --git a/include/nuttx/nx/nxterm.h b/include/nuttx/nx/nxterm.h index dc11a9d106..a7c8d648f1 100644 --- a/include/nuttx/nx/nxterm.h +++ b/include/nuttx/nx/nxterm.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/nx/nxterm.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -221,6 +221,10 @@ extern "C" * Register a console device on a raw NX window. The device will be * registered at /dev/nxtermN where N is the provided minor number. * + * This is an internal NuttX interface and should not be called directly + * from applications. Application access is supported only indirectly via + * the boardctl(BOARDIOC_NXTERM) interface. + * * Input Parameters: * hwnd - A handle that will be used to access the window. The window must * persist and this handle must be valid for the life of the NX console. @@ -244,6 +248,10 @@ NXTERM nx_register(NXWINDOW hwnd, FAR struct nxterm_window_s *wndo, * Register a console device on a framed NX window. The device will be * registered at /dev/nxtermN where N is the provided minor number. * + * This is an internal NuttX interface and should not be called directly + * from applications. Application access is supported only indirectly via + * the boardctl(BOARDIOC_NXTERM) interface. + * * Input Parameters: * hfwnd - A handle that will be used to access the window. The window must * persist and this handle must be valid for the life of the NX console. @@ -266,7 +274,12 @@ NXTERM nxtk_register(NXTKWINDOW hfwnd, FAR struct nxterm_window_s *wndo, * Description: * Register a console device on a toolbar of a framed NX window. The * device will be registered at /dev/nxtermN where N is the provided minor - * number. + * number. Application access is supported only indirectly via + * the boardctl(BOARDIOC_NXTERM) interface. + * + * This is an internal NuttX interface and should not be called directly + * from applications. Application access is supported only indirectly via + * the boardctl(BOARDIOC_NXTERM) interface. * * Input Parameters: * hfwnd - A handle that will be used to access the toolbar. The toolbar @@ -291,6 +304,9 @@ NXTERM nxtool_register(NXTKWINDOW hfwnd, FAR struct nxterm_window_s *wndo, * Description: * Un-register to NX console device. * + * This is an internal NuttX interface and should not be called directly + * from applications. + * * Input Parameters: * handle - A handle previously returned by nx_register, nxtk_register, or * nxtool_register. @@ -309,6 +325,9 @@ void nxterm_unregister(NXTERM handle); * Re-draw a portion of the NX console. This function should be called * from the appropriate window callback logic. * + * This is an internal NuttX interface and should not be called directly + * from applications. + * * Input Parameters: * handle - A handle previously returned by nx_register, nxtk_register, or * nxtool_register. @@ -339,6 +358,9 @@ void nxterm_redraw(NXTERM handle, FAR const struct nxgl_rect_s *rect, * cannot be shared between different windows. Chaos will ensue if you * try to support multiple NxTerm windows without CONFIG_NXTERM_NXKBDIN * + * This is an internal NuttX interface and should not be called directly + * from applications. + * * Input Parameters: * handle - A handle previously returned by nx_register, nxtk_register, or * nxtool_register. diff --git a/include/sys/boardctl.h b/include/sys/boardctl.h index ee3477494f..e66599971f 100644 --- a/include/sys/boardctl.h +++ b/include/sys/boardctl.h @@ -45,6 +45,10 @@ #include +#ifdef CONFIG_NXTERM +# include +#endif + #ifdef CONFIG_LIB_BOARDCTL /**************************************************************************** @@ -115,6 +119,14 @@ * CONFIGURATION: CONFIG_NX * DEPENDENCIES: Base graphics logic provides nxmu_start() * + * CMD: BOARDIOC_NXTERM + * DESCRIPTION: Create an NX terminal device + * ARG: A reference readable/writable instance of struct + * boardioc_nxterm_create_s + * CONFIGURATION: CONFIG_NXTERM + * DEPENDENCIES: Base NX terminal logic provides nx_register() and + * nxtk_register() + * * CMD: BOARDIOC_TESTSET * DESCRIPTION: Access architecture-specific up_testset() operation * ARG: A pointer to a write-able spinlock object. On success @@ -133,7 +145,8 @@ #define BOARDIOC_OS_SYMTAB _BOARDIOC(0x0007) #define BOARDIOC_USBDEV_CONTROL _BOARDIOC(0x0008) #define BOARDIOC_NX_START _BOARDIOC(0x0009) -#define BOARDIOC_TESTSET _BOARDIOC(0x000a) +#define BOARDIOC_NXTERM _BOARDIOC(0x000a) +#define BOARDIOC_TESTSET _BOARDIOC(0x000b) /* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support. * In this case, all commands not recognized by boardctl() will be forwarded @@ -142,7 +155,7 @@ * User defined board commands may begin with this value: */ -#define BOARDIOC_USER _BOARDIOC(0x000b) +#define BOARDIOC_USER _BOARDIOC(0x000c) /**************************************************************************** * Public Type Definitions @@ -240,6 +253,25 @@ struct boardioc_usbdev_ctrl_s }; #endif /* CONFIG_BOARDCTL_USBDEVCTRL */ +#ifdef CONFIG_NXTERM +enum boardioc_termtype_e +{ + BOARDIOC_XTERM_RAW = 0, /* Raw NX terminal window */ + BOARDIOC_XTERM_FRAMED, /* Framed NxTK terminal window */ + BOARDIOC_XTERM_TOOLBAR /* Tooolbar of framed NxTK terminal window */ +}; + +struct boardioc_nxterm_create_s +{ + NXTERM nxterm; /* Returned NXTERM handle */ + FAR void *hwnd; /* Window handle (NXWINDOW or NXTKWINDOW). */ + struct nxterm_window_s wndo; /* Describes the initial window: color, size, font */ + enum boardioc_termtype_e type; /* Terminal window type */ + uint8_t minor; /* Terminal device minor number, N, in + * /dev/nxtermN. 0 <= N <= 255 */ +}; +#endif /* CONFIG_NXTERM */ + /**************************************************************************** * Public Data ****************************************************************************/