configs/boardctl.c: Add boardctl() commands to replace direct calls to nxterm_redraw() and nxterm_kbdin().

This commit is contained in:
Gregory Nutt 2019-03-06 15:21:29 -06:00
parent 7696731f19
commit aca114d895
5 changed files with 108 additions and 21 deletions

5
TODO
View File

@ -2485,11 +2485,6 @@ o Graphics Subsystem (graphics/)
Within the OS, NxTK currently used only in graphics/nxterm. With
some effort, I think NxTerm could be moved to apps/ as well.
Currently, nxterm violates POSIX interface. nxterm_redraw() and
nxterm_kbdin() are called from applications. see apps/examples/nxterm
and apps/graphics/NxWidgets/nxwm./src/cnxterm.cxx.
Status: Open
Priority: Low
o Build system

View File

@ -473,7 +473,49 @@ int boardctl(unsigned int cmd, uintptr_t arg)
}
}
break;
/* CMD: BOARDIOC_NXTERM_REDRAW
* DESCRIPTION: Re-draw a portion of the NX console. This function
* should be called from the appropriate window callback
* logic.
* ARG: A reference readable instance of struct
* boardioc_nxterm_redraw_s
* CONFIGURATION: CONFIG_NXTERM
* DEPENDENCIES: Base NX terminal logic provides nxterm_redraw()
*/
case BOARDIOC_NXTERM_REDRAW:
{
FAR struct boardioc_nxterm_redraw_s *redraw =
(FAR struct boardioc_nxterm_redraw_s *)((uintptr_t)arg);
nxterm_redraw(redraw->handle, &redraw->rect, redraw->more);
ret = OK;
}
break;
/* CMD: BOARDIOC_NXTERM_KBDIN
* DESCRIPTION: Provide NxTerm keyboard input to NX.
* ARG: A reference readable instance of struct
* boardioc_nxterm_kbdin_s
* CONFIGURATION: CONFIG_NXTERM_NXKBDIN
* DEPENDENCIES: Base NX terminal logic provides nxterm_kbdin()
*/
case BOARDIOC_NXTERM_KBDIN:
{
#ifdef CONFIG_NXTERM_NXKBDIN
FAR struct boardioc_nxterm_kbdin_s *kbdin =
(FAR struct boardioc_nxterm_kbdin_s *)((uintptr_t)arg);
nxterm_kbdin(kbdin->handle, kbdin-buffer, kbdin->buflen);
ret = OK;
#else
ret = -ENOSYS;
#endif
}
break;
#endif /* CONFIG_NXTERM */
#ifdef CONFIG_BOARDCTL_TESTSET
/* CMD: BOARDIOC_TESTSET

View File

@ -405,9 +405,8 @@ Configuration Directories
STATUS:
2019-03-06: This configuration was created. It doew not yet link
correctly, however, because certain nxterm interfaces are improperly
exported: nxterm_redraw() and nxterm_kbdin(). I am thinking that
these might be moved into libc/libnx with a little repartitioning
effort.
exported: nxterm_redraw() and nxterm_kbdin(). There were replaced
with boardctl() calls but have not yet been verified.
nsh
---

View File

@ -50,7 +50,9 @@
/****************************************************************************
* Pre-processor definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Nx Console prerequistes */
#ifndef CONFIG_NX
@ -129,6 +131,17 @@
/* Pixel depth */
#if defined(CONFIG_NXTERM_BPP) && \
CONFIG_NXTERM_BPP != 1 && \
CONFIG_NXTERM_BPP != 2 && \
CONFIG_NXTERM_BPP != 4 && \
CONFIG_NXTERM_BPP != 8 && \
CONFIG_NXTERM_BPP != 16 && \
CONFIG_NXTERM_BPP != 32
# error Invalid selection for CONFIG_NXTERM_BPP
# undef CONFIG_NXTERM_BPP
#endif
#ifndef CONFIG_NXTERM_BPP
# if !defined(CONFIG_NX_DISABLE_1BPP)
# define CONFIG_NXTERM_BPP 1
@ -306,7 +319,8 @@ NXTERM nxtool_register(NXTKWINDOW hfwnd, FAR struct nxterm_window_s *wndo,
* from the appropriate window callback logic.
*
* This is an internal NuttX interface and should not be called directly
* from applications.
* from applications. Application access is supported only indirectly via
* the boardctl(BOARDIOC_REDRAW) interface.
*
* Input Parameters:
* handle - A handle previously returned by nx_register, nxtk_register, or
@ -327,19 +341,20 @@ void nxterm_redraw(NXTERM handle, FAR const struct nxgl_rect_s *rect,
* Name: nxterm_kbdin
*
* Description:
* This function should be driven by the window kbdin callback function
* (see nx.h). When the NxTerm is the top window and keyboard input is
* received on the top window, that window callback should be directed to
* this function. This function will buffer the keyboard data and make
* it available to the NxTerm as stdin.
* This function should be driven by the window kbdin callback function
* (see nx.h). When the NxTerm is the top window and keyboard input is
* received on the top window, that window callback should be directed to
* this function. This function will buffer the keyboard data and make
* it available to the NxTerm as stdin.
*
* If CONFIG_NXTERM_NXKBDIN is not selected, then the NxTerm will
* receive its input from stdin (/dev/console). This works great but
* cannot be shared between different windows. Chaos will ensue if you
* try to support multiple NxTerm windows without CONFIG_NXTERM_NXKBDIN
* If CONFIG_NXTERM_NXKBDIN is not selected, then the NxTerm will
* receive its input from stdin (/dev/console). This works great but
* 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.
* from applications. Application access is supported only indirectly via
* the boardctl(BOARDIOC_KBDIN) interface.
*
* Input Parameters:
* handle - A handle previously returned by nx_register, nxtk_register, or

View File

@ -127,6 +127,22 @@
* DEPENDENCIES: Base NX terminal logic provides nx_register() and
* nxtk_register()
*
* CMD: BOARDIOC_NXTERM_REDRAW
* DESCRIPTION: Re-draw a portion of the NX console. This function
* should be called from the appropriate window callback
* logic.
* ARG: A reference readable instance of struct
* boardioc_nxterm_redraw_s
* CONFIGURATION: CONFIG_NXTERM
* DEPENDENCIES: Base NX terminal logic provides nxterm_redraw()
*
* CMD: BOARDIOC_NXTERM_KBDIN
* DESCRIPTION: Provide NxTerm keyboard input to NX.
* ARG: A reference readable instance of struct
* boardioc_nxterm_kbdin_s
* CONFIGURATION: CONFIG_NXTERM_NXKBDIN
* DEPENDENCIES: Base NX terminal logic provides nxterm_kbdin()
*
* CMD: BOARDIOC_TESTSET
* DESCRIPTION: Access architecture-specific up_testset() operation
* ARG: A pointer to a write-able spinlock object. On success
@ -146,7 +162,9 @@
#define BOARDIOC_USBDEV_CONTROL _BOARDIOC(0x0008)
#define BOARDIOC_NX_START _BOARDIOC(0x0009)
#define BOARDIOC_NXTERM _BOARDIOC(0x000a)
#define BOARDIOC_TESTSET _BOARDIOC(0x000b)
#define BOARDIOC_NXTERM_REDRAW _BOARDIOC(0x000b)
#define BOARDIOC_NXTERM_KBDIN _BOARDIOC(0x000c)
#define BOARDIOC_TESTSET _BOARDIOC(0x000d)
/* If CONFIG_BOARDCTL_IOCTL=y, then board-specific commands will be support.
* In this case, all commands not recognized by boardctl() will be forwarded
@ -155,7 +173,7 @@
* User defined board commands may begin with this value:
*/
#define BOARDIOC_USER _BOARDIOC(0x000c)
#define BOARDIOC_USER _BOARDIOC(0x000e)
/****************************************************************************
* Public Type Definitions
@ -270,6 +288,24 @@ struct boardioc_nxterm_create_s
uint8_t minor; /* Terminal device minor number, N, in
* /dev/nxtermN. 0 <= N <= 255 */
};
/* Structures used with IOCTL commands */
struct boardioc_nxterm_redraw_s
{
NXTERM handle; /* NxTerm handle */
struct nxgl_rect_s rect; /* Rectangle to be re-drawn */
bool more; /* True: More redraw commands follow */
};
#ifdef CONFIG_NXTERM_NXKBDIN
struct boardioc_nxterm_kbdin_s
{
NXTERM handle; /* NxTerm handle */
FAR const uint8_t *buffer; /* Buffered keyboard data */
uint8_t buflen; /* Amount of data in buffer */
};
#endif
#endif /* CONFIG_NXTERM */
/****************************************************************************