summaryrefslogtreecommitdiff
path: root/nuttx/binfmt/libpcode
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-05-08 11:08:01 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-05-08 11:08:01 -0600
commit3b785276e679bc8be4cb3046d757fb6caa40927d (patch)
tree6daec662562b3453114111b9f596f576ee9e633e /nuttx/binfmt/libpcode
parent28c530634b32b793249bb66f0f08dd138d8de7bf (diff)
downloadpx4-nuttx-3b785276e679bc8be4cb3046d757fb6caa40927d.tar.gz
px4-nuttx-3b785276e679bc8be4cb3046d757fb6caa40927d.tar.bz2
px4-nuttx-3b785276e679bc8be4cb3046d757fb6caa40927d.zip
Add a ROMFS file system for testing the P-Code binary format
Diffstat (limited to 'nuttx/binfmt/libpcode')
-rw-r--r--nuttx/binfmt/libpcode/Kconfig32
-rw-r--r--nuttx/binfmt/libpcode/Make.defs15
-rw-r--r--nuttx/binfmt/libpcode/README.txt51
-rw-r--r--nuttx/binfmt/libpcode/hello.pas5
-rw-r--r--nuttx/binfmt/libpcode/hello.pexbin0 -> 232 bytes
-rw-r--r--nuttx/binfmt/libpcode/romfs.h139
-rw-r--r--nuttx/binfmt/libpcode/romfs.imgbin0 -> 1024 bytes
7 files changed, 237 insertions, 5 deletions
diff --git a/nuttx/binfmt/libpcode/Kconfig b/nuttx/binfmt/libpcode/Kconfig
index 4845eab31..03255ffab 100644
--- a/nuttx/binfmt/libpcode/Kconfig
+++ b/nuttx/binfmt/libpcode/Kconfig
@@ -15,6 +15,38 @@ config PCODE_PRIORITY
---help---
This is the task_priority that will be used when starting P-code interpreter.
+config PCODE_TEST_FS
+ bool "Mount a test file system"
+ depends on FS_ROMFS && !DISABLE_MOUNTPOINT
+ ---help---
+ Mount a test file system. This test file system was used to verify the P-Code binary format.
+
+if PCODE_TEST_FS
+
+config PCODE_TEST_DEVMINOR
+ int "Test file system 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 P-code files to be tested. Default: 0
+
+config PCODE_TEST_DEVPATH
+ string "Test file system device Path"
+ default "/dev/ram0"
+ ---help---
+ The path to the ROMFS block driver device. This must match PCODE_TEST_DEVMINOR.
+ Used for registering the RAM block driver that will hold the ROMFS file system
+ containing the P-code files to be tested. Default: "/dev/ram0"
+
+config PCODE_TEST_MOUNTPOINT
+ string "Test file system mount point"
+ default "/bin"
+ ---help---
+ Location where the test file system will be mounted
+
+endif # PCODE_TEST_FS
+
config PCODE_DUMPBUFFER
bool "Dump P-code buffers"
default n
diff --git a/nuttx/binfmt/libpcode/Make.defs b/nuttx/binfmt/libpcode/Make.defs
index a5d2fdc12..e84d0d325 100644
--- a/nuttx/binfmt/libpcode/Make.defs
+++ b/nuttx/binfmt/libpcode/Make.defs
@@ -37,16 +37,21 @@ ifeq ($(CONFIG_PCODE),y)
# P-code application interfaces
-# BINFMT_CSRCS +=
+BINFMT_CSRCS += pcode.c
# P-code library interfaces
# BINFMT_CSRCS +=
-# Hook the libbuiltin subdirectory into the build
+# Add an include path so that P-Code related header files may reside in
+# the libpcode sub-directory
+
+CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(TOPDIR)$(DELIM)binfmt$(DELIM)libpcode"}
+
+# Hook the libpcode subdirectory into the build
-#VPATH += libbuiltin
-#SUBDIRS += libbuiltin
-#DEPPATH += --dep-path libbuiltin
+#VPATH += libpcode
+#SUBDIRS += libpcode
+#DEPPATH += --dep-path libpcode
endif
diff --git a/nuttx/binfmt/libpcode/README.txt b/nuttx/binfmt/libpcode/README.txt
new file mode 100644
index 000000000..b7f896da0
--- /dev/null
+++ b/nuttx/binfmt/libpcode/README.txt
@@ -0,0 +1,51 @@
+libpcode README
+===============
+
+Configuration Dependencies
+--------------------------
+In order to use this module, you must first install the P-Code virtual
+machine. You can get this from the Pascal package or from misc/pascal in
+the GIT repository. See the README.txt file at misc/pascal for installation
+instructions. The correct location to install the P-code virtual machine is
+at apps/interpreters.
+
+Other required configuration settings:
+
+ CONFIG_NFILE_DESCRIPTORS > 3
+ CONFIG_BINFMT_DISABLE=n
+ CONFIG_PCODE=y
+
+Directory Contents
+------------------
+This directory holds support files for the P-Code binary format. For other
+binary formats, the library directory contains critical logic for the binary
+format. But this is not the case with the P-code binary format; since the
+binary file is interpreted, little additional support is necessary. As a
+result, this directory includes only a few files needed by the binfmt build
+logic and to support unit-level testing of the P-Code binary format.
+
+Files include in this directory include:
+
+1. This README.txt file
+
+2. Build support file:
+
+ Kconfig, Make.defs
+
+3. Unit test support files:
+
+ hello.pas -- Pascal "Hello, World!" source file
+ hello.pex -- P-Code POFF format file created by compiling hello.pas
+ romfs.img -- A ROMFS filsystem image created by:
+
+ make image
+ cp hello.pex image/.
+ genromfs -f romfs.img -d image -V pofftest
+ rm -rf image
+
+ romfs.h -- a C header file containing the ROMFS file system in an
+ initialized C structure. This file was created via:
+
+ xxd -g 1 -i romfs.img >romfs.h
+
+ then cleaned up with an editor to conform with NuttX coding standards.
diff --git a/nuttx/binfmt/libpcode/hello.pas b/nuttx/binfmt/libpcode/hello.pas
new file mode 100644
index 000000000..fe137f1b6
--- /dev/null
+++ b/nuttx/binfmt/libpcode/hello.pas
@@ -0,0 +1,5 @@
+program hello(output);
+begin
+ writeln('Hello world!!!');
+end.
+
diff --git a/nuttx/binfmt/libpcode/hello.pex b/nuttx/binfmt/libpcode/hello.pex
new file mode 100644
index 000000000..c23610598
--- /dev/null
+++ b/nuttx/binfmt/libpcode/hello.pex
Binary files differ
diff --git a/nuttx/binfmt/libpcode/romfs.h b/nuttx/binfmt/libpcode/romfs.h
new file mode 100644
index 000000000..833acceeb
--- /dev/null
+++ b/nuttx/binfmt/libpcode/romfs.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+ * binfmt/libpcode/romfs.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __BINFMT_LIBPCODE_ROMF_H
+#define __BINFMT_LIBPCODE_ROMF_H 1
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define ROMFS_IMG_LEN 1024
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static unsigned char romfs_img[] =
+{
+ 0x2d, 0x72, 0x6f, 0x6d, 0x31, 0x66, 0x73, 0x2d, 0x00, 0x00, 0x01, 0x70,
+ 0xd0, 0x89, 0x79, 0xd8, 0x70, 0x6f, 0x66, 0x66, 0x74, 0x65, 0x73, 0x74,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49,
+ 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0xd1, 0xff, 0xff, 0x97,
+ 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0xd1, 0xd1, 0xff, 0x80, 0x2e, 0x2e, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8,
+ 0xb0, 0x6c, 0x22, 0x45, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x70, 0x65,
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x4f, 0x46, 0x46,
+ 0x01, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x06, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
+ 0x00, 0x00, 0x00, 0x11, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x0f,
+ 0x05, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x04, 0x06, 0x00, 0x00, 0x08,
+ 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0,
+ 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x38,
+ 0xb1, 0x00, 0x00, 0x74, 0x0e, 0xf9, 0x00, 0x00, 0x25, 0xb5, 0xff, 0xfc,
+ 0xf9, 0x00, 0x00, 0x20, 0x3f, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77,
+ 0x6f, 0x72, 0x6c, 0x64, 0x21, 0x21, 0x21, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x48, 0x45, 0x4c, 0x4c, 0x4f, 0x00, 0x68,
+ 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x70, 0x61, 0x73, 0x00, 0x2e, 0x74, 0x65,
+ 0x78, 0x74, 0x00, 0x2e, 0x72, 0x6f, 0x64, 0x61, 0x74, 0x61, 0x00, 0x2e,
+ 0x66, 0x69, 0x6c, 0x65, 0x74, 0x61, 0x62, 0x00, 0x2e, 0x6c, 0x69, 0x6e,
+ 0x65, 0x6e, 0x6f, 0x00, 0x2e, 0x73, 0x74, 0x72, 0x74, 0x61, 0x62, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+
+#endif /* __BINFMT_LIBPCODE_ROMF_H */
diff --git a/nuttx/binfmt/libpcode/romfs.img b/nuttx/binfmt/libpcode/romfs.img
new file mode 100644
index 000000000..04237dd04
--- /dev/null
+++ b/nuttx/binfmt/libpcode/romfs.img
Binary files differ