Skip to content
Snippets Groups Projects
Commit e596c1a3 authored by patacongo's avatar patacongo
Browse files

Add sim/nsh2 configuration

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4026 42af7a65-404d-4744-a932-0658087f49c3
parent bfc8712d
No related branches found
No related tags found
No related merge requests found
......@@ -2142,4 +2142,7 @@
errors than you would think.
* arch/arm/src/stm32/stm32_i2c.c: Fixed an error where I2C timeouts appeared
to be successful transfers.
* configs/sim/nsh2: Add another simulated NSH configuration. This one
supports X11 graphics, C++, and exercises graphic functions as built-in
commands.
......@@ -134,19 +134,24 @@ void up_idle(void)
/* Handle X11-related events */
#ifdef CONFIG_SIM_X11FB
#ifdef CONFIG_SIM_TOUCHSCREEN
if (g_eventloop)
if (g_x11initialized)
{
up_x11events();
}
/* Driver the X11 event loop */
#ifdef CONFIG_SIM_TOUCHSCREEN
if (g_eventloop)
{
up_x11events();
}
#endif
/* Update the display periodically */
/* Update the display periodically */
g_x11refresh += 1000000 / CLK_TCK;
if (g_x11refresh > 500000)
{
up_x11update();
g_x11refresh += 1000000 / CLK_TCK;
if (g_x11refresh > 500000)
{
up_x11update();
}
}
#endif
#endif
......
......@@ -116,9 +116,12 @@
#ifndef __ASSEMBLY__
#if defined(CONFIG_SIM_X11FB) && defined(CONFIG_SIM_TOUCHSCREEN)
#ifdef CONFIG_SIM_X11FB
extern int g_x11initialized;
#ifdef CONFIG_SIM_TOUCHSCREEN
extern volatile int g_eventloop;
#endif
#endif
/**************************************************************************
* Public Function Prototypes
......
......@@ -70,6 +70,7 @@
/* Also used in up_x11eventloop */
Display *g_display;
int g_x11initialized;
/****************************************************************************
* Private Variables
......@@ -112,9 +113,9 @@ static inline int up_x11createframe(void)
g_screen = DefaultScreen(g_display);
g_window = XCreateSimpleWindow(g_display, DefaultRootWindow(g_display),
0, 0, g_fbpixelwidth, g_fbpixelheight, 2,
BlackPixel(g_display, g_screen),
BlackPixel(g_display, g_screen));
0, 0, g_fbpixelwidth, g_fbpixelheight, 2,
BlackPixel(g_display, g_screen),
BlackPixel(g_display, g_screen));
XStringListToTextProperty(&winName, 1, &winprop);
XStringListToTextProperty(&iconName, 1, &iconprop);
......@@ -147,6 +148,7 @@ static inline int up_x11createframe(void)
gcval.graphics_exposures = 0;
g_gc = XCreateGC(g_display, g_window, GCGraphicsExposures, &gcval);
return 0;
}
......@@ -194,33 +196,38 @@ static int up_x11untraperrors(void)
static void up_x11uninitX(void)
{
fprintf(stderr, "Uninitalizing X\n");
#ifndef CONFIG_SIM_X11NOSHM
if (g_shmcheckpoint > 4)
if (g_x11initialized)
{
XShmDetach(g_display, &g_xshminfo);
}
#ifndef CONFIG_SIM_X11NOSHM
if (g_shmcheckpoint > 4)
{
XShmDetach(g_display, &g_xshminfo);
}
if (g_shmcheckpoint > 3)
{
shmdt(g_xshminfo.shmaddr);
}
if (g_shmcheckpoint > 3)
{
shmdt(g_xshminfo.shmaddr);
}
if (g_shmcheckpoint > 2)
{
shmctl(g_xshminfo.shmid, IPC_RMID, 0);
}
if (g_shmcheckpoint > 2)
{
shmctl(g_xshminfo.shmid, IPC_RMID, 0);
}
#endif
if (g_shmcheckpoint > 1)
{
XDestroyImage(g_image);
}
if (g_shmcheckpoint > 1)
{
XDestroyImage(g_image);
}
/* Un-grab the mouse buttons */
/* Un-grab the mouse buttons */
#ifdef CONFIG_SIM_TOUCHSCREEN
XUngrabButton(g_display, Button1, AnyModifier, g_window);
XUngrabButton(g_display, Button1, AnyModifier, g_window);
#endif
g_x11initialized = 0;
}
XCloseDisplay(g_display);
}
......@@ -362,41 +369,47 @@ int up_x11initialize(unsigned short width, unsigned short height,
int depth;
int ret;
/* Save inputs */
/* Check if we are already initialized */
g_fbpixelwidth = width;
g_fbpixelheight = height;
if (!g_x11initialized)
{
/* Save inputs */
/* Create the X11 window */
g_fbpixelwidth = width;
g_fbpixelheight = height;
ret = up_x11createframe();
if (ret < 0)
{
return ret;
}
/* Create the X11 window */
/* Determine the supported pixel bpp of the current window */
ret = up_x11createframe();
if (ret < 0)
{
return ret;
}
XGetWindowAttributes(g_display, DefaultRootWindow(g_display), &windowAttributes);
/* Determine the supported pixel bpp of the current window */
/* Get the pixel depth. If the depth is 24-bits, use 32 because X expects
* 32-bit aligment anyway.
*/
XGetWindowAttributes(g_display, DefaultRootWindow(g_display), &windowAttributes);
depth = windowAttributes.depth;
if (depth == 24)
{
depth = 32;
}
printf("Pixel bpp is %d bits (using %d)\n", windowAttributes.depth, depth);
/* Get the pixel depth. If the depth is 24-bits, use 32 because X expects
* 32-bit aligment anyway.
*/
*bpp = depth;
*stride = (depth * width / 8);
*fblen = (*stride * height);
depth = windowAttributes.depth;
if (depth == 24)
{
depth = 32;
}
printf("Pixel bpp is %d bits (using %d)\n", windowAttributes.depth, depth);
/* Map the window to shared memory */
*bpp = depth;
*stride = (depth * width / 8);
*fblen = (*stride * height);
up_x11mapsharedmem(windowAttributes.depth, *fblen);
/* Map the window to shared memory */
up_x11mapsharedmem(windowAttributes.depth, *fblen);
g_x11initialized = 1;
}
*fbmem = (void*)g_framebuffer;
return 0;
......
......@@ -181,6 +181,28 @@ nsh
cd <nuttx-directory>/tools
./configure.sh sim/nsh
nsh2
Description
-----------
This is another example that configures to use the NuttShell at examples/nsh.
Unlike nsh, this version uses NSH built-in functions. The nx, nxhello, and
nxlines examples are included as built-in functions.
X11 Configuration
-----------------
This configuration uses an X11-based framebuffer driver. Of course, this
configuration can only be used in environments that support X11! (And it
may not even be usable in all of those environments without some "tweaking"
See discussion below under the nx11 configuration).
Configuring
-----------
This configuration may be selected as follows:
cd <nuttx-directory>/tools
./configure.sh sim/nsh2
nx
Description
......@@ -223,7 +245,7 @@ nx11
Description
-----------
Configures to use examples/nx. This configuration is similar
to the nx configuration except that it addes support for an X11-
to the nx configuration except that it adds support for an X11-
based framebuffer driver. Of course, this configuration can only
be used in environments that support X11! (And it may not even
be usable in all of those environments without some "tweaking").
......@@ -343,4 +365,3 @@ touchscreen
See apps/examples/README.txt for further information about build
requirements and configuration settings.
############################################################################
# configs/sim/nsh2/Make.defs
#
# Copyright (C) Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. 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.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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
# COPYRIGHT OWNER OR CONTRIBUTORS 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.
#
############################################################################
include ${TOPDIR}/.config
HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"}
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
else
ARCHOPTIMIZATION = -O2
endif
ARCHCPUFLAGS = -fno-builtin
ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions
ARCHPICFLAGS = -fpic
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
ARCHWARNINGSXX = -Wall -Wshadow
ARCHDEFINES =
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
ARCHSCRIPT =
CROSSDEV =
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CXXFLAGS = $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGSXX) $(ARCHINCLUDESXX) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
OBJEXT = .o
LIBEXT = .a
ifeq ($(HOSTOS),Cygwin)
EXEEXT = .exe
else
EXEEXT =
endif
ifeq ("${CONFIG_DEBUG_SYMBOLS}","y")
LDFLAGS += -g
endif
define PREPROCESS
@echo "CPP: $1->$2"
@$(CPP) $(CPPFLAGS) $1 -o $2
endef
define COMPILE
@echo "CC: $1"
@$(CC) -c $(CFLAGS) $1 -o $2
endef
define COMPILEXX
@echo "CXX: $1"
@$(CXX) -c $(CXXFLAGS) $1 -o $2
endef
define ASSEMBLE
@echo "AS: $1"
@$(CC) -c $(AFLAGS) $1 -o $2
endef
define ARCHIVE
echo "AR: $2"; \
$(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; }
endef
define CLEAN
@rm -f *.o *.a
endef
MKDEP = $(TOPDIR)/tools/mkdeps.sh
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
$(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
HOSTLDFLAGS =
############################################################################
# configs/sim/nsh2/appconfig
#
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. 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.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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
# COPYRIGHT OWNER OR CONTRIBUTORS 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.
#
############################################################################
# Path to example in apps/examples containing the user_start entry point
CONFIGURED_APPS += examples/nsh
# The NSH Library
CONFIGURED_APPS += nshlib
# NSH Built-In Functions
CONFIGURED_APPS += examples/nx
CONFIGURED_APPS += examples/nxhello
CONFIGURED_APPS += examples/nxlines
CONFIGURED_APPS += examples/touchscreen
This diff is collapsed.
#!/bin/bash
# sim/nsh2/setenv.sh
#
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. 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.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "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
# COPYRIGHT OWNER OR CONTRIBUTORS 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.
#
if [ "$(basename $0)" = "setenv.sh" ] ; then
echo "You must source this script, not run it!" 1>&2
exit 1
fi
if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi
#export NUTTX_BIN=
#export PATH=${NUTTX_BIN}:/sbin:/usr/sbin:${PATH_ORIG}
echo "PATH : ${PATH}"
......@@ -94,9 +94,12 @@ int nxbe_colormap(FAR NX_DRIVERTYPE *dev)
int ret;
int i, j, k;
/* Allocate the color map tables */
/* Allocate the color map tables in one allocation:
*
* size = 3 colors x CONFIG_NX_COLORS each x 8-bits per color
*/
size = 3 * CONFIG_NX_NCOLORS * sizeof(uint16_t);
size = 3 * CONFIG_NX_NCOLORS * sizeof(uint8_t);
alloc = (uint8_t*)malloc(size);
if (alloc == NULL)
{
......@@ -104,12 +107,14 @@ int nxbe_colormap(FAR NX_DRIVERTYPE *dev)
}
memset(alloc, 0xff, size);
/* Then get pointers to each color table */
red = alloc;
green = &alloc[CONFIG_NX_NCOLORS];
blue = &alloc[2*CONFIG_NX_NCOLORS];
/* Initialize the color map tables. 6*6*6 = 216, the rest
* are (0xffff, 0xffff, 0xffff)
* are (0xff, 0xfff 0xff)
*/
ndx = 0;
......@@ -131,6 +136,7 @@ int nxbe_colormap(FAR NX_DRIVERTYPE *dev)
/* Now configure the cmap structure */
cmap.first = 0;
cmap.len = CONFIG_NX_NCOLORS;
cmap.red = red;
cmap.green = green;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment