BAS: Rename examples/bas to examples/bastest. Hook into build and configuration system. Finish ROMFS logic
This commit is contained in:
parent
ae574b0251
commit
e0b6137de7
@ -4,6 +4,7 @@
|
||||
#
|
||||
|
||||
source "$APPSDIR/examples/adc/Kconfig"
|
||||
source "$APPSDIR/examples/bastest/Kconfig"
|
||||
source "$APPSDIR/examples/buttons/Kconfig"
|
||||
source "$APPSDIR/examples/can/Kconfig"
|
||||
source "$APPSDIR/examples/cc3000/Kconfig"
|
||||
|
@ -37,7 +37,7 @@
|
||||
|
||||
# Sub-directories
|
||||
|
||||
SUBDIRS = adc buttons can cc3000 cpuhog cxxtest dhcpd discover elf
|
||||
SUBDIRS = adc bastest buttons can cc3000 cpuhog cxxtest dhcpd discover elf
|
||||
SUBDIRS += flash_test ftpc ftpd hello helloxx hidkbd igmp i2schar json
|
||||
SUBDIRS += keypadtest lcdrw mm modbus mount mtdpart mtdrwb netpkt nettest
|
||||
SUBDIRS += nrf24l01_term nsh null nx nxterm nxffs nxflat nxhello nximage
|
||||
|
@ -48,6 +48,22 @@ examples/adc
|
||||
CONFIG_EXAMPLES_ADC_GROUPSIZE - The number of samples to read at once.
|
||||
Default: 4
|
||||
|
||||
examples/bastest
|
||||
^^^^^^^^^^^^^^^^
|
||||
This directory contains a small program that will mount a ROMFS file system
|
||||
containing the BASIC test files extracted from the BAS 2.4 release. See
|
||||
examples/bastest/README.txt for licensing and usage information.
|
||||
|
||||
CONFIG_EXAMPLES_BASTEST_DEVMINOR - The minor device number of the ROMFS block
|
||||
driver. For example, the N in /dev/ramN. Used for registering the RAM
|
||||
block driver that will hold the ROMFS file system containing the BASIC
|
||||
files to be tested. Default: 0
|
||||
|
||||
CONFIG_EXAMPLES_BASTEST_DEVPATH - The path to the ROMFS block driver device. This
|
||||
must match EXAMPLES_BASTEST_DEVMINOR. Used for registering the RAM block driver
|
||||
that will hold the ROMFS file system containing the BASIC files to be
|
||||
tested. Default: "/dev/ram0"
|
||||
|
||||
examples/buttons
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
|
11
examples/bastest/.gitignore
vendored
Normal file
11
examples/bastest/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/Make.dep
|
||||
/.depend
|
||||
/.built
|
||||
/*.asm
|
||||
/*.obj
|
||||
/*.rel
|
||||
/*.lst
|
||||
/*.sym
|
||||
/*.adb
|
||||
/*.lib
|
||||
/*.src
|
31
examples/bastest/Kconfig
Normal file
31
examples/bastest/Kconfig
Normal file
@ -0,0 +1,31 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config EXAMPLES_BASTEST
|
||||
bool "Setup Test Files for BAS"
|
||||
default n
|
||||
depends on INTERPRETERS_BAS
|
||||
---help---
|
||||
Mount the ROMFS file system containing the BAS test files.
|
||||
|
||||
if EXAMPLES_BASTEST
|
||||
|
||||
config EXAMPLES_BASTEST_DEVMINOR
|
||||
int "ROMFS Minor Device Number"
|
||||
default 0
|
||||
---help---
|
||||
The minor device number of the ROMFS block. For example, the N in /dev/ramN.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the BASIC files to be tested. Default: 0
|
||||
|
||||
config EXAMPLES_BASTEST_DEVPATH
|
||||
string "ROMFS Device Path"
|
||||
default "/dev/ram0"
|
||||
---help---
|
||||
The path to the ROMFS block driver device. This must match EXAMPLES_BASTEST_DEVMINOR.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the BASIC files to be tested. Default: "/dev/ram0"
|
||||
|
||||
endif
|
153
examples/bastest/Makefile
Normal file
153
examples/bastest/Makefile
Normal file
@ -0,0 +1,153 @@
|
||||
############################################################################
|
||||
# apps/examples/bastest/Makefile
|
||||
#
|
||||
# Copyright (C) 2014 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
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# BAS test volume mounter
|
||||
|
||||
APPNAME = bastest
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = 2048
|
||||
|
||||
# Hello, World! Example
|
||||
|
||||
ASRCS =
|
||||
CSRCS =
|
||||
MAINSRC = bastest_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
|
||||
|
||||
SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
|
||||
OBJS = $(AOBJS) $(COBJS)
|
||||
|
||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
OBJS += $(MAINOBJ)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
ifeq ($(WINTOOL),y)
|
||||
BIN = ..\\..\\libapps$(LIBEXT)
|
||||
else
|
||||
BIN = ../../libapps$(LIBEXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
|
||||
else
|
||||
INSTALL_DIR = $(BIN_DIR)
|
||||
endif
|
||||
|
||||
BASTEST_DIR = $(APPDIR)$(DELIM)examples$(DELIM)bastest
|
||||
TESTS_DIR = $(BASTEST_DIR)$(DELIM)tests
|
||||
ROMFS_IMG = $(BASTEST_DIR)$(DELIM)romfs.img
|
||||
ROMFS_HDR = $(BASTEST_DIR)$(DELIM)romfs.h
|
||||
|
||||
PROGNAME = bastest$(EXEEXT)
|
||||
|
||||
ROOTDEPPATH = --dep-path .
|
||||
|
||||
# Common build
|
||||
|
||||
VPATH =
|
||||
|
||||
all: .built
|
||||
.PHONY: clean depend distclean
|
||||
|
||||
$(AOBJS): %$(OBJEXT): %.S
|
||||
$(call ASSEMBLE, $<, $@)
|
||||
|
||||
$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
# Create the romfs.h header file from the tests/ directory
|
||||
|
||||
$(ROMFS_HDR) : $(ROMFS_IMG)
|
||||
$(Q) genromfs -f $@ -d $(TESTS_DIR) -V "BASTEST"
|
||||
$(Q) (xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@)
|
||||
|
||||
# Link and install the program binary
|
||||
|
||||
ifeq ($(CONFIG_BUILD_KERNEL),y)
|
||||
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
|
||||
@echo "LD: $(PROGNAME)"
|
||||
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
|
||||
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME)
|
||||
|
||||
install: $(BIN_DIR)$(DELIM)$(PROGNAME)
|
||||
|
||||
else
|
||||
install:
|
||||
|
||||
endif
|
||||
|
||||
# Register the NSH builtin appliation
|
||||
|
||||
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
|
||||
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
|
||||
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
|
||||
|
||||
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
|
||||
else
|
||||
context:
|
||||
endif
|
||||
|
||||
# Housekeeping stuff
|
||||
|
||||
.depend: Makefile $(SRCS)
|
||||
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
|
||||
@touch $@
|
||||
|
||||
depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
$(call DELFILE, Make.dep)
|
||||
$(call DELFILE, .depend)
|
||||
|
||||
-include Make.dep
|
@ -1,3 +1,55 @@
|
||||
README
|
||||
======
|
||||
|
||||
This directory contains a small program that will mount a ROMFS file system
|
||||
containing the BASIC test files extracted from the BAS 2.4 release.
|
||||
|
||||
Background
|
||||
==========
|
||||
Bas is an interpreter for the classic dialect of the programming language
|
||||
BASIC. It is pretty compatible to typical BASIC interpreters of the 1980s,
|
||||
unlike some other UNIX BASIC interpreters, that implement a different
|
||||
syntax, breaking compatibility to existing programs. Bas offers many ANSI
|
||||
BASIC statements for structured programming, such as procedures, local
|
||||
variables and various loop types. Further there are matrix operations,
|
||||
automatic LIST indentation and many statements and functions found in
|
||||
specific classic dialects. Line numbers are not required.
|
||||
|
||||
The interpreter tokenises the source and resolves references to variables
|
||||
and jump targets before running the program. This compilation pass
|
||||
increases efficiency and catches syntax errors, type errors and references
|
||||
to variables that are never initialised. Bas is written in ANSI C for
|
||||
UNIX systems.
|
||||
|
||||
License
|
||||
=======
|
||||
BAS 2.4 is released as part of NuttX under the standard 3-clause BSD license
|
||||
use by all components of NuttX. This is not incompatible with the original
|
||||
BAS 2.4 licensing
|
||||
|
||||
Copyright (c) 1999-2014 Michael Haardt
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
TEST OVERVIEW
|
||||
=============
|
||||
|
||||
test01.bas
|
||||
==========
|
||||
Scalar variable assignment
|
121
examples/bastest/bastest_main.c
Normal file
121
examples/bastest/bastest_main.c
Normal file
@ -0,0 +1,121 @@
|
||||
/****************************************************************************
|
||||
* examples/bastest/bastest_main.c
|
||||
*
|
||||
* Copyright (C) 2014 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "romfs.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Check configuration. This is not all of the configuration settings that
|
||||
* are required -- only the more obvious.
|
||||
*/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS < 1
|
||||
# error "You must provide file descriptors via CONFIG_NFILE_DESCRIPTORS in your configuration file"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FS_ROMFS
|
||||
# error "You must select CONFIG_FS_ROMFS in your configuration file"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DISABLE_MOUNTPOINT
|
||||
# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file"
|
||||
#endif
|
||||
|
||||
/* Describe the ROMFS file system */
|
||||
|
||||
#define SECTORSIZE 512
|
||||
#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
|
||||
#define MOUNTPT "/mnt/romfs"
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_BASTEST_DEVMINOR
|
||||
# define CONFIG_EXAMPLES_BASTEST_DEVMINOR 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_BASTEST_DEVPATH
|
||||
# define CONFIG_EXAMPLES_BASTEST_DEVPATH "/dev/ram0"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* bastest_main
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_BUILD_KERNEL
|
||||
int main(int argc, FAR char *argv[])
|
||||
#else
|
||||
int bastest_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
/* Create a ROM disk for the ROMFS filesystem */
|
||||
|
||||
printf("Registering romdisk at /dev/ram%d\n", CONFIG_EXAMPLES_BASTEST_DEVMINOR);
|
||||
ret = romdisk_register(CONFIG_EXAMPLES_BASTEST_DEVMINOR, (FAR uint8_t *)romfs_img,
|
||||
NSECTORS(romfs_img_len), SECTORSIZE);
|
||||
if (ret < 0)
|
||||
{
|
||||
err("ERROR: romdisk_register failed: %d\n", ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Mount the file system */
|
||||
|
||||
message("Mounting ROMFS filesystem at target=%s with source=%s\n",
|
||||
MOUNTPT, CONFIG_EXAMPLES_BASTEST_DEVPATH);
|
||||
|
||||
ret = mount(CONFIG_EXAMPLES_BASTEST_DEVPATH, MOUNTPT, "romfs", MS_RDONLY, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
err("ERROR: mount(%s,%s,romfs) failed: %s\n",
|
||||
CONFIG_EXAMPLES_BASTEST_DEVPATH, MOUNTPT, errno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
README
|
||||
======
|
||||
|
||||
Introductions
|
||||
=============
|
||||
Introduction
|
||||
============
|
||||
Bas is an interpreter for the classic dialect of the programming language
|
||||
BASIC. It is pretty compatible to typical BASIC interpreters of the 1980s,
|
||||
unlike some other UNIX BASIC interpreters, that implement a different
|
||||
@ -18,9 +18,6 @@ Introductions
|
||||
to variables that are never initialised. Bas is written in ANSI C for
|
||||
UNIX systems.
|
||||
|
||||
Please do "make check" after compiling bas to run a couple regression
|
||||
tests.
|
||||
|
||||
License
|
||||
=======
|
||||
BAS 2.4 is released as part of NuttX under the standard 3-clause BSD license
|
||||
|
Loading…
Reference in New Issue
Block a user