From bed8e66d958c4cc177166b473f81ec26445d99a3 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 28 Mar 2012 19:29:30 +0000 Subject: The NX console appears to be fully functional git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4536 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/ChangeLog | 4 +++ nuttx/configs/sim/README.txt | 2 ++ nuttx/configs/sim/nx/defconfig | 2 +- nuttx/configs/sim/nx11/defconfig | 2 +- nuttx/configs/stm3210e-eval/README.txt | 23 +++++++++++++ nuttx/configs/stm3210e-eval/nsh2/defconfig | 2 +- nuttx/configs/stm3210e-eval/nx/defconfig | 2 +- nuttx/configs/stm3210e-eval/nxlines/defconfig | 2 +- nuttx/configs/stm3210e-eval/nxtext/defconfig | 2 +- nuttx/graphics/nxconsole/nxcon_font.c | 45 ++++++++++++++++++------- nuttx/graphics/nxconsole/nxcon_internal.h | 47 --------------------------- nuttx/graphics/nxconsole/nxcon_redraw.c | 21 ++++++++++++ nuttx/graphics/nxconsole/nxcon_register.c | 21 +++++++++++- nuttx/graphics/nxconsole/nxcon_unregister.c | 6 ++++ nuttx/graphics/nxmu/nx_disconnect.c | 2 +- nuttx/graphics/nxmu/nx_releasebkgd.c | 2 +- nuttx/graphics/nxmu/nxmu_server.c | 25 -------------- nuttx/include/nuttx/nx/nxconsole.h | 46 ++++++++++++++++++++++++++ 18 files changed, 164 insertions(+), 92 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 0e53645e7..45ce3331f 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2598,3 +2598,7 @@ DAC. Contriburted by by Lzzy. * graphics/nxconsole: Add a character driver that can be used as a console output device for text output (still under development on initial check-in). + * graphics/nxmu: Fix several compilation errors that have crept into the multi- + user NX server because of lack of use. + * graphics/nxconsole: The NX text console is basically function (in multi- + user NX mode only). diff --git a/nuttx/configs/sim/README.txt b/nuttx/configs/sim/README.txt index 58ce7d9ba..854cf585b 100644 --- a/nuttx/configs/sim/README.txt +++ b/nuttx/configs/sim/README.txt @@ -387,6 +387,8 @@ nx11 -#CONFIGURED_APPS += examples/nxconsole +CONFIGURED_APPS += examples/nxconsole + See apps/examples/README.txt for further details. + ostest Description diff --git a/nuttx/configs/sim/nx/defconfig b/nuttx/configs/sim/nx/defconfig index 05cfbf5ac..f8139b32c 100644 --- a/nuttx/configs/sim/nx/defconfig +++ b/nuttx/configs/sim/nx/defconfig @@ -457,7 +457,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=8 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/nuttx/configs/sim/nx11/defconfig b/nuttx/configs/sim/nx11/defconfig index d3962c49b..d8b1d6019 100644 --- a/nuttx/configs/sim/nx11/defconfig +++ b/nuttx/configs/sim/nx11/defconfig @@ -458,7 +458,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=32 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/nuttx/configs/stm3210e-eval/README.txt b/nuttx/configs/stm3210e-eval/README.txt index 0cf7f5cbd..ff90b2c15 100755 --- a/nuttx/configs/stm3210e-eval/README.txt +++ b/nuttx/configs/stm3210e-eval/README.txt @@ -17,6 +17,7 @@ Contents - Temperature Sensor - RTC - STM3210E-EVAL-specific Configuration Options + - NxConsole - Configurations Development Environment @@ -350,6 +351,28 @@ RTC overflow interrupt may be lost even if the STM32 is powered down only momentarily. Therefore hi-res solution is only useful in systems where the power is always on. +NxConsole +========= + + Several of the graphic-releted configurations are set to use the + examples/nxconsole test. To enable this configuration, + First, select NX Multi-User mode: + + CONFG_NX_MULTIUSER=y + CONFIG_DISABLE_MQUEUE=n + + Then add the following definition to the defconfig file to enable + the NxConsole driver: + + CONFIG_NXCONSOLE=y + + Make sure the that following is in place the appconfig file (perhaps + eliminating other examples): + + CONFIGURED_APPS += examples/nxconsole + + See apps/examples/README.txt for further details. + STM3210E-EVAL-specific Configuration Options ============================================ diff --git a/nuttx/configs/stm3210e-eval/nsh2/defconfig b/nuttx/configs/stm3210e-eval/nsh2/defconfig index 1891c7e21..228abf230 100644 --- a/nuttx/configs/stm3210e-eval/nsh2/defconfig +++ b/nuttx/configs/stm3210e-eval/nsh2/defconfig @@ -1076,7 +1076,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=16 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/nuttx/configs/stm3210e-eval/nx/defconfig b/nuttx/configs/stm3210e-eval/nx/defconfig index f1a5d46d3..02cafd33d 100644 --- a/nuttx/configs/stm3210e-eval/nx/defconfig +++ b/nuttx/configs/stm3210e-eval/nx/defconfig @@ -926,7 +926,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=16 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/nuttx/configs/stm3210e-eval/nxlines/defconfig b/nuttx/configs/stm3210e-eval/nxlines/defconfig index 0175dc9b5..fa067ae41 100644 --- a/nuttx/configs/stm3210e-eval/nxlines/defconfig +++ b/nuttx/configs/stm3210e-eval/nxlines/defconfig @@ -925,7 +925,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=16 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/nuttx/configs/stm3210e-eval/nxtext/defconfig b/nuttx/configs/stm3210e-eval/nxtext/defconfig index 0b92dac45..753b69190 100644 --- a/nuttx/configs/stm3210e-eval/nxtext/defconfig +++ b/nuttx/configs/stm3210e-eval/nxtext/defconfig @@ -925,7 +925,7 @@ CONFIG_NX_MXCLIENTMSGS=16 CONFIG_NXCONSOLE=n CONFIG_NXCONSOLE_BPP=16 # CONFIG_NXCONSOLE_NOGETRUN -# CONFIG_NXCONSOLE_MXCHARS +CONFIG_NXCONSOLE_MXCHARS=256 # CONFIG_NXCONSOLE_FONTCACHE # CONFIG_NXCONSOLE_CACHESIZE # CONFIG_NXCONSOLE_LINESEPARATION diff --git a/nuttx/graphics/nxconsole/nxcon_font.c b/nuttx/graphics/nxconsole/nxcon_font.c index c8336a289..436f91477 100644 --- a/nuttx/graphics/nxconsole/nxcon_font.c +++ b/nuttx/graphics/nxconsole/nxcon_font.c @@ -47,6 +47,8 @@ #include #include +#include + #include #include #include @@ -103,14 +105,16 @@ * Name: nxcon_freeglyph ****************************************************************************/ +#ifdef CONFIG_NXCONSOLE_FONTCACHE static void nxcon_freeglyph(FAR struct nxcon_glyph_s *glyph) { if (glyph->bitmap) { - free(glyph->bitmap); + kfree(glyph->bitmap); } memset(glyph, 0, sizeof(struct nxcon_glyph_s)); } +#endif /**************************************************************************** * Name: nxcon_allocglyph @@ -183,9 +187,6 @@ nxcon_allocglyph(FAR struct nxcon_state_s *priv) luglyph->usecnt = 1; return luglyph; #else - /* TODO: Instead allocating an freeing, just allocate the max glyph once */ - - nxcon_freeglyph(&priv->glyph); return &priv->glyph; #endif } @@ -236,7 +237,6 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, #if CONFIG_NXCONSOLE_BPP < 8 nxgl_mxpixel_t pixel; #endif - int bmsize; int row; int col; int ret; @@ -255,29 +255,50 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, glyph->width = fbm->metric.width + fbm->metric.xoffset; glyph->height = fbm->metric.height + fbm->metric.yoffset; - /* Allocate memory to hold the glyph with its offsets */ + /* Get the physical width of the glyph in bytes */ glyph->stride = (glyph->width * CONFIG_NXCONSOLE_BPP + 7) / 8; - bmsize = glyph->stride * glyph->height; - glyph->bitmap = (FAR uint8_t *)malloc(bmsize); + + /* Allocate memory to hold the glyph with its offsets */ + +#ifdef CONFIG_NXCONSOLE_FONTCACHE + { + DEBUGASSERT(glyph->bitmap == NULL); + int bmsize = glyph->stride * glyph->height; + glyph->bitmap = (FAR uint8_t *)kmalloc(bmsize); + } +#else + DEBUGASSERT(glyph->bitmap != NULL); +#endif if (glyph->bitmap) { - /* Initialize the glyph memory to the background color */ + /* Initialize the glyph memory to the background color using the + * hard-coded bits-per-pixel (BPP). + * + * TODO: The rest of NX is configured to support multiple devices + * with differing BPP. They logic should be extended to support + * differing BPP's as well. + */ #if CONFIG_NXCONSOLE_BPP < 8 pixel = priv->wcolor[0]; + # if CONFIG_NXCONSOLE_BPP == 1 + /* Pack 1-bit pixels into a 2-bits */ pixel &= 0x01; - pixel = (pixel) << 1 |pixel; + pixel = (pixel) << 1 | pixel; + # endif # if CONFIG_NXCONSOLE_BPP < 4 + /* Pack 2-bit pixels into a nibble */ pixel &= 0x03; - pixel = (pixel) << 2 |pixel; + pixel = (pixel) << 2 | pixel; + # endif /* Pack 4-bit nibbles into a byte */ @@ -323,7 +344,9 @@ nxcon_renderglyph(FAR struct nxcon_state_s *priv, /* Actually, the RENDERER never returns a failure */ gdbg("nxcon_renderglyph: RENDERER failed\n"); +#ifdef CONFIG_NXCONSOLE_FONTCACHE nxcon_freeglyph(glyph); +#endif glyph = NULL; } } diff --git a/nuttx/graphics/nxconsole/nxcon_internal.h b/nuttx/graphics/nxconsole/nxcon_internal.h index f5cbc9c6d..963511b29 100644 --- a/nuttx/graphics/nxconsole/nxcon_internal.h +++ b/nuttx/graphics/nxconsole/nxcon_internal.h @@ -55,53 +55,6 @@ /**************************************************************************** * Definitions ****************************************************************************/ -/* Configuration ************************************************************/ -/* The maximum number of characters that can be remembered */ - -#ifndef CONFIG_NXCONSOLE_MXCHARS -# define CONFIG_NXCONSOLE_MXCHARS 128 -#endif - -/* Font cache -- this is the number or pre-rendered font glyphs that can be - * remembered. - */ - -#ifdef CONFIG_NXCONSOLE_FONTCACHE -# ifndef CONFIG_NXCONSOLE_CACHESIZE -# define CONFIG_NXCONSOLE_CACHESIZE 16 -# endif -#else -# undef CONFIG_NXCONSOLE_CACHESIZE -#endif - -/* Pixel depth */ - -#ifndef CONFIG_NXCONSOLE_BPP -# if !defined(CONFIG_NX_DISABLE_1BPP) -# define CONFIG_NXCONSOLE_BPP 1 -# elif !defined(CONFIG_NX_DISABLE_2BPP) -# define CONFIG_NXCONSOLE_BPP 2 -# elif !defined(CONFIG_NX_DISABLE_4BPP) -# define CONFIG_NXCONSOLE_BPP 4 -# elif !defined(CONFIG_NX_DISABLE_8BPP) -# define CONFIG_NXCONSOLE_BPP 8 -# elif !defined(CONFIG_NX_DISABLE_16BPP) -# define CONFIG_NXCONSOLE_BPP 16 -//#elif !defined(CONFIG_NX_DISABLE_24BPP) -//# define CONFIG_NXCONSOLE_BPP 24 -# elif !defined(CONFIG_NX_DISABLE_32BPP) -# define CONFIG_NXCONSOLE_BPP 32 -# else -# error "No pixel depth provided" -# endif -#endif - -/* Space (in rows) between lines */ - -#ifndef CONFIG_NXCONSOLE_LINESEPARATION -# define CONFIG_NXCONSOLE_LINESEPARATION 2 -#endif - /* NxConsole Definitions ****************************************************/ /* Bitmap flags */ diff --git a/nuttx/graphics/nxconsole/nxcon_redraw.c b/nuttx/graphics/nxconsole/nxcon_redraw.c index 23bebd622..1a40a7ee1 100755 --- a/nuttx/graphics/nxconsole/nxcon_redraw.c +++ b/nuttx/graphics/nxconsole/nxcon_redraw.c @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -112,6 +113,25 @@ void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool mor priv = (FAR struct nxcon_state_s *)handle; + /* Get exclusive access to the state structure */ + + do + { + ret = sem_wait(&priv->exclsem); + + /* Check for errors */ + + if (ret < 0) + { + /* The only expected error is if the wait failed because of it + * was interrupted by a signal. + */ + + DEBUGASSERT(errno == EINTR); + } + } + while (ret < 0); + /* Fill the rectangular region with the window background color */ ret = priv->ops->fill(priv, rect, priv->wndo.wcolor); @@ -128,4 +148,5 @@ void nxcon_redraw(NXCONSOLE handle, FAR const struct nxgl_rect_s *rect, bool mor { nxcon_fillchar(priv, rect, &priv->bm[i]); } + ret = sem_post(&priv->exclsem); } diff --git a/nuttx/graphics/nxconsole/nxcon_register.c b/nuttx/graphics/nxconsole/nxcon_register.c index cc878b239..78f6a1051 100644 --- a/nuttx/graphics/nxconsole/nxcon_register.c +++ b/nuttx/graphics/nxconsole/nxcon_register.c @@ -120,13 +120,32 @@ FAR struct nxcon_state_s * priv->fwidth = fontset->mxwidth; priv->spwidth = fontset->spwidth; - /* Set up the text caches */ + /* Set up the text cache */ priv->maxchars = CONFIG_NXCONSOLE_MXCHARS; + + /* Set up the font glyph bitmap cache (if enabled) */ + #ifdef CONFIG_NXCONSOLE_FONTCACHE priv->maxglyphs = CONFIG_NXCONSOLE_CACHESIZE; #endif + /* Pre-allocate maximal sized glyph bitmap memory (only if we are not + * using the glyph cache. + */ + +#ifndef CONFIG_NXCONSOLE_FONTCACHE + { + int allocsize = (priv->fheight * priv->fwidth * CONFIG_NXCONSOLE_BPP + 7) >> 3; + priv->glyph.bitmap = (FAR uint8_t *)kmalloc(allocsize); + if (!priv->glyph.bitmap) + { + gdbg("Failed to allocate glyph memory\n"); + goto errout; + } + } +#endif + /* Set the initial display position */ nxcon_home(priv); diff --git a/nuttx/graphics/nxconsole/nxcon_unregister.c b/nuttx/graphics/nxconsole/nxcon_unregister.c index 8a19736ed..25dbd40c6 100644 --- a/nuttx/graphics/nxconsole/nxcon_unregister.c +++ b/nuttx/graphics/nxconsole/nxcon_unregister.c @@ -97,6 +97,12 @@ void nxcon_unregister(NXCONSOLE handle) priv = (FAR struct nxcon_state_s *)handle; sem_destroy(&priv->exclsem); + /* Free the pre-allocated glyph bitmap */ + +#ifndef CONFIG_NXCONSOLE_FONTCACHE + kfree(priv->glyph.bitmap); +#endif + /* Unregister the driver */ snprintf(devname, NX_DEVNAME_SIZE, NX_DEVNAME_FORMAT, priv->minor); diff --git a/nuttx/graphics/nxmu/nx_disconnect.c b/nuttx/graphics/nxmu/nx_disconnect.c index 24fb114f4..f4711b005 100644 --- a/nuttx/graphics/nxmu/nx_disconnect.c +++ b/nuttx/graphics/nxmu/nx_disconnect.c @@ -94,7 +94,7 @@ void nx_disconnect(NXHANDLE handle) /* Inform the server that this client no longer exists */ - msg.msgid = NX_SVRMSG_CONNECT; + msg.msgid = NX_SVRMSG_DISCONNECT; msg.conn = conn; ret = mq_send(conn->cwrmq, &msg, sizeof(struct nxsvrmsg_s), NX_SVRMSG_PRIO); diff --git a/nuttx/graphics/nxmu/nx_releasebkgd.c b/nuttx/graphics/nxmu/nx_releasebkgd.c index 4e8a75679..99815b1e7 100644 --- a/nuttx/graphics/nxmu/nx_releasebkgd.c +++ b/nuttx/graphics/nxmu/nx_releasebkgd.c @@ -1,7 +1,7 @@ /**************************************************************************** * graphics/nxmu/nx_releasebkgd.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/graphics/nxmu/nxmu_server.c b/nuttx/graphics/nxmu/nxmu_server.c index 9cd9e578a..fbd03464f 100644 --- a/nuttx/graphics/nxmu/nxmu_server.c +++ b/nuttx/graphics/nxmu/nxmu_server.c @@ -129,31 +129,6 @@ static inline void nxmu_connect(FAR struct nxfe_conn_s *conn) } } -/**************************************************************************** - * Name: nxmu_release - ****************************************************************************/ - -static int nxmu_release(FAR struct nxfe_state_s *fe) -{ - FAR struct nxbe_window_s *wnd; - struct nxclimsg_s outmsg; - int ret; - - /* Don't want windows to close while we do this */ - - for (wnd = fe->be.topwnd; wnd; wnd = wnd->below) - { - outmsg.msgid = NX_CLIMSG_DISCONNECTED; - ret = mq_send(wnd->conn->swrmq, &outmsg, sizeof(struct nxclimsg_s), NX_CLIMSG_PRIO); - if (ret < 0) - { - gdbg("mq_send failed: %d\n", errno); - } - } - - return OK; -} - /**************************************************************************** * Name: nxmu_shutdown ****************************************************************************/ diff --git a/nuttx/include/nuttx/nx/nxconsole.h b/nuttx/include/nuttx/nx/nxconsole.h index 0a66e4c03..61d79860c 100644 --- a/nuttx/include/nuttx/nx/nxconsole.h +++ b/nuttx/include/nuttx/nx/nxconsole.h @@ -94,6 +94,52 @@ * that the text is simply truncated until a new line is encountered. */ +/* The maximum number of characters that can be remembered */ + +#ifndef CONFIG_NXCONSOLE_MXCHARS +# define CONFIG_NXCONSOLE_MXCHARS 128 +#endif + +/* Font cache -- this is the number or pre-rendered font glyphs that can be + * remembered. + */ + +#ifdef CONFIG_NXCONSOLE_FONTCACHE +# ifndef CONFIG_NXCONSOLE_CACHESIZE +# define CONFIG_NXCONSOLE_CACHESIZE 16 +# endif +#else +# undef CONFIG_NXCONSOLE_CACHESIZE +#endif + +/* Pixel depth */ + +#ifndef CONFIG_NXCONSOLE_BPP +# if !defined(CONFIG_NX_DISABLE_1BPP) +# define CONFIG_NXCONSOLE_BPP 1 +# elif !defined(CONFIG_NX_DISABLE_2BPP) +# define CONFIG_NXCONSOLE_BPP 2 +# elif !defined(CONFIG_NX_DISABLE_4BPP) +# define CONFIG_NXCONSOLE_BPP 4 +# elif !defined(CONFIG_NX_DISABLE_8BPP) +# define CONFIG_NXCONSOLE_BPP 8 +# elif !defined(CONFIG_NX_DISABLE_16BPP) +# define CONFIG_NXCONSOLE_BPP 16 +//#elif !defined(CONFIG_NX_DISABLE_24BPP) +//# define CONFIG_NXCONSOLE_BPP 24 +# elif !defined(CONFIG_NX_DISABLE_32BPP) +# define CONFIG_NXCONSOLE_BPP 32 +# else +# error "No pixel depth provided" +# endif +#endif + +/* Space (in rows) between lines */ + +#ifndef CONFIG_NXCONSOLE_LINESEPARATION +# define CONFIG_NXCONSOLE_LINESEPARATION 2 +#endif + /**************************************************************************** * Public Types ****************************************************************************/ -- cgit v1.2.3