Remove all support for the ancient Pascal compiler and pcode interpreter.

This commit is contained in:
Gregory Nutt 2019-11-21 06:57:41 -06:00
parent 03a47a5fbd
commit 677b0bf47e
26 changed files with 2 additions and 2127 deletions

View File

@ -104,7 +104,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
<p>Last Updated: November 16, 2019</p>
<p>Last Updated: November 21, 2019</p>
</td>
</tr>
</table>
@ -1300,23 +1300,6 @@
</p>
</tr>
<tr>
<td valign="top" width="22"><img height="20" width="20" src="favicon.ico"></td>
<td bgcolor="#5eaee1">
<b>Pascal Compiler with NuttX runtime P-Code interpreter add-on</b>
</td>
</tr>
<tr>
<td><br></td>
<td>
<p>
<li>The Pascal add-on is available for download from the
<a href="https://bitbucket.org/nuttx/pascal/downloads/">Bitbucket.org</a>
website.</li>
</p>
</td>
</tr>
</table></center>
<p>
@ -1500,12 +1483,6 @@
As of NuttX-7.27, the content of the NxWidgets repository has been included within the <code>apps/</code> package and no longer has separate releases.
</p>
</li></ul>
<li><b>pascal</b>.
<ul><p>
Release notes for all released versions on pascal are available in the <a href="https://bitbucket.org/nuttx/pascal/ReleaseNotes" target="_blank">Bitbucket GIT</a>
The ChangeLog for all releases of pascal is available at the bottom of the ChangeLog file that can viewed in the <a href="https://bitbucket.org/nuttx/pascal/ChangeLog" target="_blank">Bitbucket GIT</a>.
</p>
</li></ul>
<li><b>buildroot</b>.
<ul><p>
Release notes for buildroot 1.14 are available <a href="https://bitbucket.org/nuttx/buildroot/downloads/">here</a>.

View File

@ -53,9 +53,6 @@ nuttx/
| | |- <a href="https://bitbucket.org/nuttx/nuttx/src/master/arch/z80/src/z180/README.txt" target="_blank">README.txt</a>
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/arch/z80/src/z180/z180_mmu.txt" target="_blank">z180_mmu.txt</a>
| `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/arch/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|- binfmt/
| |- libpcode/
| `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/binfmt/libpcode/README.txt" target="_blank"><b><i>README.txt</i></b></a>
|- audio/
| `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/audio/README.txt" target="_blank"><b><i>README.txt</i></b></a>
@ -640,9 +637,6 @@ tools/
uClibc++/
`- <a href="https://bitbucket.org/nuttx/uclibc/src/master/README.txt" target="_blank"><b><i>README.txt</i></b></a>
pascal/
`- <a href="https://bitbucket.org/nuttx/pascal/src/master/README" target="_blank"><b><i>README</i></b></a>
</pre></ul>
</body>
</html>

View File

@ -555,11 +555,6 @@ Related Repositories
There are snapshots of some tools here that you will need to work with
NuttX: kconfig-frontends, genromfs, and others.
* https://bitbucket.org/nuttx/pascal
Yes, this really is a Pascal compiler. The Pascal p-code run-time and
pcode debugger can be built as a part of NuttX.
Notes about Header Files
------------------------
@ -1753,9 +1748,6 @@ nuttx/
| `- README.txt
|- audio/
| `-README.txt
|- binfmt/
| `-libpcode/
| `-README.txt
|- boards/
| |- arm/
| | |- a1x/
@ -2351,5 +2343,3 @@ tools/
uClibc++/
`- README.txt
pascal/
`- README.txt

24
TODO
View File

@ -1,4 +1,4 @@
NuttX TODO List (Last updated September 26, 2019)
NuttX TODO List (Last updated November 21, 2019)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This file summarizes known NuttX bugs, limitations, inconsistencies with
@ -36,7 +36,6 @@ apps/ and other Add-Ons:
(1) NuttShell (NSH) (apps/nshlib)
(1) System libraries apps/system (apps/system)
(1) Modbus (apps/modbus)
(1) Pascal add-on (pcode/)
(5) Other Applications & Tests (apps/examples/)
o Task/Scheduler (sched/)
@ -2760,27 +2759,6 @@ o Modbus (apps/modbus)
Status: Open
Priority: Low. This is really an enhancement request: Modbus was never
designed to work with removable serial devices.
o Pascal Add-On (pcode/)
^^^^^^^^^^^^^^^^^^^^^^
Title: P-CODES IN MEMORY UNTESTED
Description: Need APIs to verify execution of P-Code from memory buffer.
Status: Open
Priority: Low
Title: SMALLER LOADER AND OBJECT FORMAT
Description: Loader and object format may be too large for some small
memory systems. Consider ways to reduce memory footprint.
Status: Open
Priority: Medium
Title: PDBG
Description: Move the pascal p-code debugger into the NuttX apps/ tree
where it can be used from the NSH command line.
Status: Open
Priority: Low
o Other Applications & Tests (apps/examples/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -57,31 +57,6 @@ config ELF
if ELF
source binfmt/libelf/Kconfig
endif
config BINFMT_PCODE
bool "Support P-Code Applications"
default n
depends on INTERPRETERS_PCODE && ((!BUILD_PROTECTED && !BUILD_KERNEL) || EXPERIMENTAL)
---help---
Enable support for interpreted P-Code binaries. P-Code binaries are
generated by the NuttX Pascal compiler.
NOTE: You must first install and select the Pascal P-Code
interpreter before you can select this binary format. The P-Code
interpreter is in the Pascal download package and can also be found
in the NuttX Pascal GIT repository. Read the README.txt file in the
Pascal package directory for more details. The correct installation
directory is: apps/interpreters.
ISSUES: This feature is highly coupled with logic in the apps/
directory and, as a consequence, cannot be used in environments that
do not include the standard NuttX apps/ directory nor in build
configurations using BUILD_PROTECTED or BUILD_KERNEL.
if BINFMT_PCODE
source binfmt/libpcode/Kconfig
endif
endif
config BINFMT_CONSTRUCTORS

View File

@ -71,7 +71,6 @@ DEPPATH = --dep-path .
include libnxflat$(DELIM)Make.defs
include libelf$(DELIM)Make.defs
include libpcode$(DELIM)Make.defs
BINFMT_AOBJS = $(BINFMT_ASRCS:.S=$(OBJEXT))
BINFMT_COBJS = $(BINFMT_CSRCS:.c=$(OBJEXT))

View File

@ -41,7 +41,6 @@
#include <nuttx/binfmt/binfmt.h>
#include <nuttx/binfmt/elf.h>
#include <nuttx/binfmt/pcode.h>
#include <nuttx/binfmt/nxflat.h>
#include <nuttx/lib/builtin.h>
@ -81,14 +80,6 @@ void binfmt_initialize(void)
}
#endif
#ifdef CONFIG_BINFMT_PCODE
ret = pcode_initialize();
if (ret < 0)
{
berr("ERROR: pcode_initialize failed: %d\n", ret);
}
#endif
#ifdef CONFIG_NXFLAT
ret = nxflat_initialize();
if (ret < 0)

View File

@ -1,72 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config BINFMT_PCODE_STACKSIZE
int "P-code interpreter stack size"
default 2048
---help---
This is the stack size that will be used when starting P-code interpreter.
config BINFMT_PCODE_PRIORITY
int "P-code interpreter priority"
default 100
---help---
This is the task_priority that will be used when starting P-code interpreter.
config BINFMT_PCODE_VARSTACKSIZE
int "P-code variable stack size"
default 1024
---help---
This size of the P-Code variable storage area to be allocated by the
P-Code runtime.
config BINFMT_PCODE_STRSTACKSIZE
int "P-code string stack size"
default 128
---help---
This size of the P-Code string stack area to be allocated by the
P-Code runtime.
config BINFMT_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 BINFMT_PCODE_TEST_FS
config BINFMT_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 BINFMT_PCODE_TEST_DEVPATH
string "Test file system device Path"
default "/dev/ram0"
---help---
The path to the ROMFS block driver device. This must match
BINFMT_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 BINFMT_PCODE_TEST_MOUNTPOINT
string "Test file system mount point"
default "/bin"
---help---
Location where the test file system will be mounted
endif # BINFMT_PCODE_TEST_FS
config BINFMT_PCODE_DUMPBUFFER
bool "Dump P-code buffers"
default n
depends on DEBUG_INFO
---help---
Dump various P-code buffers for debug purposes

View File

@ -1,65 +0,0 @@
############################################################################
# binfmt/libpcode/Make.defs
#
# Copyright (C) 2014, 2016 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.
#
############################################################################
ifeq ($(CONFIG_BINFMT_PCODE),y)
# P-code application interfaces
BINFMT_CSRCS += pcode.c
# P-code library interfaces
# BINFMT_CSRCS +=
# 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"}
# FIXME: This also depends upon header files installed at
# apps/interpreters/pcode
PCODE_DIR = $(TOPDIR)$(DELIM)$(CONFIG_APPS_DIR)$(DELIM)interpreters$(DELIM)pcode
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" \
"$(PCODE_DIR)$(DELIM)include" "$(PCODE_DIR)$(DELIM)insn$(DELIM)include"}
# Hook the libpcode subdirectory into the build
#VPATH += libpcode
#SUBDIRS += libpcode
#DEPPATH += --dep-path libpcode
endif

View File

@ -1,168 +0,0 @@
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 the NuttX Pascal
GIT repository. See the README.txt file at the top-level Pascal for
installation instructions. The correct location to install the P-code
virtual machine is at apps/interpreters (assuming that you are using
the NuttX apps/ package and that you have named the directory apps/).
Other required configuration settings:
CONFIG_BINFMT_DISABLE=n
CONFIG_BINFMT_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.
Also, the data definitions in the romfs.h file should be marked with
'const' qualifier the so that the data will be stored in FLASH.
Test Configuration
------------------
Here is a simple test configuration using the NuttX simulator:
1. Install the sim/nsh configuration:
cd tools
./configure.sh sim:nsh
cd ..
2. Install p-code virtual machine as described above.
3. Modify the configuration using 'make menuconfig'. Change the following
selections:
This enables general BINFMT support:
CONFIG_DEBUG_BINFMT=y
CONFIG_LIB_ENVPATH=y
This enables building of the P-Code virtual machine:
CONFIG_INTERPRETERS_PCODE=y
And the P-Code runtime support:
CONFIG_SYSTEM_PRUN=y
This enables building the PCODE binary format
CONFIG_BINFMT_PCODE=y
CONFIG_BINFMT_PCODE_PRIORITY=100
CONFIG_BINFMT_PCODE_STACKSIZE=2048
This enables building and mount a test filesystem:
CONFIG_BINFMT_PCODE_TEST_FS=y
CONFIG_BINFMT_PCODE_TEST_DEVMINOR=3
CONFIG_BINFMT_PCODE_TEST_DEVPATH="/dev/ram3"
CONFIG_BINFMT_PCODE_TEST_MOUNTPOINT="/bin"
Debug options can also be enabled with:
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_BINFMT=y
CONFIG_DEBUG_INFO=y
4. In lieu of a a real test application, this Quick'n'Dirty patch can be used
to initialize the P-Code binary format:
@@ -115,6 +115,7 @@ const struct symtab_s CONFIG_EXECFUNCS_SYMTAB_ARRAY[1];
/****************************************************************************
* Name: nsh_main
****************************************************************************/
+int pcode_initialize(void);
int nsh_main(int argc, char *argv[])
{
@@ -143,6 +144,7 @@ int nsh_main(int argc, char *argv[])
exitval = 1;
}
#endif
+(void)pcode_initialize();
/* Initialize the NSH library */
5. Then after building nuttx.exe you should be able to run the P-Code hello
world example like:
nsh> hello.pex
Issues
------
1. As implemented now, there is a tight coupling between the nuttx/binfmt
directory and the apps/interpreters/pcode directory. That should not
be the case; the nuttx/ logic should be completely independent of apps/
logic (but not vice versa).
2. The current implementation will not work in the CONFIG_BUILD_PROTECTED or
CONFIG_BUILD_KERNEL configurations. That is because of the little proxy
logic (function pcode_proxy() and prun() in the file pcode.c). (a) That
logic would attempt to link with P-code logic that resides in user space.
That will not work. And (2) that proxy would be started in user mode but
in the kernel address space which will certainly crash immediately.
The general idea to fix both of these problems is as follows:
1. Eliminate the pcode_proxy. Instead start a P-Code execution program that
resides in the file system. That P-Code execution program already
exists. This program should be built as, say, an ELF binary and
installed in a file system.
2. Add a configuration setting that gives the full path to where the pexec
program is stored in the filesystem.
3. Modify the logic so that the P-Code execution program runs (instead of
the requested program) an it received the full path the P-Code file
on the command line. This might be accomplished by simply modifying the
argv[] structure in the struct binary_s instance.
The current start-up logic in binfmt_execmodule.c would have modified to
handle this special start-up. Perhaps the struct binfmt_s could be
extended to include an exec() method that provides custom start up logic?
4. Add a task start hook to the program. Here is where we can setup up the
on_exit() function that will clean up after the P-Code program terminates.
There are many other smaller issues to be resolved, but those are the main
ones.
A more complex solution might include a user-space p-code daemon that
receives the P-Code path in a POSIX message and starts a P-Code interpreter
thread wholly in user space.

View File

@ -1,5 +0,0 @@
program hello(output);
begin
writeln('Hello world!!!');
end.

Binary file not shown.

View File

@ -1,139 +0,0 @@
/****************************************************************************
* 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 */

Binary file not shown.

View File

@ -1,602 +0,0 @@
/****************************************************************************
* binfmt/pcode.c
*
* Copyright (C) 2014-2018 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 <sys/mount.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/poff.h>
#include <nuttx/fs/fs.h>
#include <nuttx/drivers/ramdisk.h>
#include <nuttx/binfmt/binfmt.h>
#include <nuttx/binfmt/pcode.h>
#include "pexec.h"
#include "pedefs.h"
#ifdef CONFIG_BINFMT_PCODE
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Check configuration. This is not all of the configuration settings that
* are required -- only the more obvious.
*/
#ifdef CONFIG_BINFMT_DISABLE
# error The binary loader is disabled (CONFIG_BINFMT_DISABLE)!
#endif
#ifndef CONFIG_SCHED_ONEXIT
# error CONFIG_SCHED_ONEXIT is required
#endif
#ifndef CONFIG_BINFMT_PCODE_VARSTACKSIZE
# define CONFIG_BINFMT_PCODE_VARSTACKSIZE 1024
#endif
#ifndef CONFIG_BINFMT_PCODE_STRSTACKSIZE
# define CONFIG_BINFMT_PCODE_STRSTACKSIZE 128
#endif
#ifdef CONFIG_BINFMT_PCODE_TEST_FS
# 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
# ifndef CONFIG_BINFMT_PCODE_TEST_DEVMINOR
# define CONFIG_BINFMT_PCODE_TEST_DEVMINOR 0
# endif
# ifndef CONFIG_BINFMT_PCODE_TEST_DEVPATH
# define CONFIG_BINFMT_PCODE_TEST_DEVPATH "/dev/ram0"
# endif
# ifndef CONFIG_BINFMT_PCODE_TEST_MOUNTPOINT
# define CONFIG_BINFMT_PCODE_TEST_MOUNTPOINT "/bin"
# endif
#endif
/* Describe the ROMFS file system */
#define SECTORSIZE 512
#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
struct binfmt_handoff_s
{
sem_t exclsem; /* Supports mutually exclusive access */
FAR struct binary_s *binp; /* Binary format being handed off */
FAR char *fullpath; /* Full path to the P-Code file */
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int pcode_run(FAR char *exepath, size_t varsize, size_t strsize);
#ifdef CONFIG_BINFMT_PCODE_TEST_FS
static int pcode_mount_testfs(void);
#endif
#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)
static void pcode_onexit(int exitcode, FAR void *arg);
#endif
#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)
static int pcode_proxy(int argc, char **argv);
#endif
static int pcode_load(FAR struct binary_s *binp);
static int pcode_unload(FAR struct binary_s *binp);
/****************************************************************************
* Private Data
****************************************************************************/
static struct binfmt_s g_pcode_binfmt =
{
NULL, /* next */
pcode_load, /* load */
pcode_unload, /* unload */
};
struct binfmt_handoff_s g_pcode_handoff;
#ifdef CONFIG_BINFMT_PCODE_TEST_FS
# include "romfs.h"
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: pcode_run
*
* Description:
* Execute/interpret a P-Code file. This function does not return until
* the P-code program terminates or until a fatal error occurs.
*
* Input Parameters:
* exepath - The full path to the P-Code binary.
* varsize - Size of the P-Code variable stack
* strsize - the size of the P-Code string stack.
*
* Returned Value:
* OK if the P-Code program successfully terminated; A negated errno value
* is returned on the event of any failure.
*
****************************************************************************/
static int pcode_run(FAR char *exepath, size_t varsize, size_t strsize)
{
FAR struct pexec_s *st;
int errcode;
int ret = OK;
/* Load the POFF file into memory */
st = pload(exepath, varsize, varsize);
if (!st)
{
berr("ERROR: Could not load %s\n", exepath);
return -ENOEXEC;
}
binfo("Loaded %s\n", exepath);
/* Execute the P-Code program until a stopping condition occurs */
for (; ; )
{
/* Execute the instruction; Check for exceptional conditions */
errcode = pexec(st);
if (errcode != eNOERROR)
{
break;
}
}
if (errcode != eEXIT)
{
/* REVISIT: Select a more appropriated return errocode */
berr("ERROR: Runtime error 0x%02x -- Execution Stopped\n", errcode);
ret = -ENOEXEC;
}
/* Clean up resources used by the interpreter */
binfo("Execution terminated\n");
pexec_release(st);
return ret;
}
/****************************************************************************
* Name: pcode_mount_testfs
*
* Description:
* If so configured, then mount the P-Code test file system
*
****************************************************************************/
#ifdef CONFIG_BINFMT_PCODE_TEST_FS
static int pcode_mount_testfs(void)
{
int ret;
/* Create a ROM disk for the ROMFS filesystem */
binfo("Registering romdisk at /dev/ram%d\n", CONFIG_BINFMT_PCODE_TEST_DEVMINOR);
ret = romdisk_register(CONFIG_BINFMT_PCODE_TEST_DEVMINOR, (FAR uint8_t *)romfs_img,
NSECTORS(ROMFS_IMG_LEN), SECTORSIZE);
if (ret < 0)
{
berr("ERROR: romdisk_register failed: %d\n", ret);
return ret;
}
/* Mount the test file system */
binfo("Mounting ROMFS filesystem at target=%s with source=%s\n",
CONFIG_BINFMT_PCODE_TEST_MOUNTPOINT,
CONFIG_BINFMT_PCODE_TEST_DEVPATH);
ret = mount(CONFIG_BINFMT_PCODE_TEST_DEVPATH,
CONFIG_BINFMT_PCODE_TEST_MOUNTPOINT,
"romfs", MS_RDONLY, NULL);
if (ret < 0)
{
int errval = get_errno();
DEBUGASSERT(errval > 0);
berr("ERROR: mount(%s,%s,romfs) failed: %d\n",
CONFIG_BINFMT_PCODE_TEST_DEVPATH,
CONFIG_BINFMT_PCODE_TEST_MOUNTPOINT, errval);
return -errval;
}
/* Does the system support the PATH variable? Has the PATH variable
* already been set? If YES and NO, then set the PATH variable to
* the ROMFS mountpoint.
*/
#if defined(CONFIG_LIB_ENVPATH) && !defined(CONFIG_PATH_INITIAL)
(void)setenv("PATH", CONFIG_BINFMT_PCODE_TEST_MOUNTPOINT, 1);
#endif
return OK;
}
#else
# define pcode_mount_testfs() (OK)
#endif
/****************************************************************************
* Name: pcode_onexit
*
* Description:
* This is the proxy program that runs and starts the P-Code interpreter.
*
****************************************************************************/
#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)
static void pcode_onexit(int exitcode, FAR void *arg)
{
FAR struct binary_s *binp = (FAR struct binary_s *)arg;
DEBUGASSERT(binp);
/* And unload the module */
(void)unload_module(binp);
}
#endif
/****************************************************************************
* Name: pcode_proxy
*
* Description:
* This is the proxy program that runs and starts the P-Code interpreter.
*
* REVISIT: There are issues here when CONFIG_BUILD_PROTECTED or
* CONFIG_BUILD_KERNEL are selected. Also this implementation is too highly
* couple to logic in the apps/ directory.
*
****************************************************************************/
#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)
static int pcode_proxy(int argc, char **argv)
{
FAR struct binary_s *binp;
FAR char *fullpath;
int ret;
/* Get the struct binary_s instance from the handoff structure */
binp = g_pcode_handoff.binp;
g_pcode_handoff.binp = NULL;
fullpath = g_pcode_handoff.fullpath;
g_pcode_handoff.fullpath = NULL;
nxsem_post(&g_pcode_handoff.exclsem);
DEBUGASSERT(binp && fullpath);
binfo("Executing %s\n", fullpath);
/* Set-up the on-exit handler that will unload the module on exit */
ret = on_exit(pcode_onexit, binp);
if (ret < 0)
{
berr("ERROR: on_exit failed: %d\n", get_errno());
kmm_free(fullpath);
return EXIT_FAILURE;
}
/* Load the P-code file and execute it */
ret = pcode_run(fullpath, CONFIG_BINFMT_PCODE_VARSTACKSIZE,
CONFIG_BINFMT_PCODE_STRSTACKSIZE);
/* We no longer need the fullpath */
kmm_free(fullpath);
/* Check the result of the interpretation */
if (ret < 0)
{
berr("ERROR: Execution failed\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
#else
# error Missing logic for the case of CONFIG_BUILD_PROTECTED/KERNEL
#endif
/****************************************************************************
* Name: pcode_load
*
* Description:
* Verify that the file is a pcode binary.
*
****************************************************************************/
static int pcode_load(struct binary_s *binp)
{
FAR struct poff_fileheader_s hdr;
FAR uint8_t *ptr;
size_t remaining;
ssize_t nread;
int fd;
int ret;
binfo("Loading file: %s\n", binp->filename);
/* Open the binary file for reading (only) */
fd = nx_open(binp->filename, O_RDONLY);
if (fd < 0)
{
berr("ERROR: Failed to open binary %s: %d\n", binp->filename, fd);
return fd;
}
/* Read the POFF file header */
for (remaining = sizeof(struct poff_fileheader_s),
ptr = (FAR uint8_t *)&hdr; remaining > 0; )
{
/* Read the next GULP */
nread = nx_read(fd, ptr, remaining);
if (nread < 0)
{
/* If the failure is EINTR, then this is not an error; the
* nx_read() was simply interrupted by a signal.
*/
if (nread != -EINTR)
{
berr("ERROR: read failed: %d\n", (int)nread);
ret = nread;
goto errout_with_fd;
}
berr("Interrupted by a signal\n");
}
else
{
/* Set up for the next gulp */
DEBUGASSERT(nread > 0 && nread <= remaining);
remaining -= nread;
ptr += nread;
}
}
#ifdef CONFIG_BINFMT_PCODE_DUMPBUFFER
lib_dumpbuffer("POFF File Header", &hdr, sizeof(poff_fileheader_s));
#endif
/* Verify that the file is a P-Code executable */
if (memcmp(&hdr.fh_ident, FHI_POFF_MAG, 4) != 0 || hdr.fh_type != FHT_EXEC)
{
_err("ERROR: File is not a P-code executable: %d\n");
ret = -ENOEXEC;
goto errout_with_fd;
}
/* Return the load information.
* REVISIT: There are issues here when CONFIG_BUILD_PROTECTED or
* CONFIG_BUILD_KERNEL are selected.
*/
binp->entrypt = pcode_proxy;
binp->stacksize = CONFIG_BINFMT_PCODE_STACKSIZE;
binp->priority = CONFIG_BINFMT_PCODE_PRIORITY;
/* Get exclusive access to the p-code handoff structure */
do
{
ret = nxsem_wait(&g_pcode_handoff.exclsem);
DEBUGASSERT(ret == OK || ret == -EINTR);
}
while (ret == -EINTR);
/* Save the data that we need to handoff to the child thread */
DEBUGASSERT(g_pcode_handoff.binp == NULL &&
g_pcode_handoff.fullpath == NULL);
/* Duplicate the full path to the binary */
g_pcode_handoff.fullpath = strdup(binp->filename);
if (!g_pcode_handoff.fullpath)
{
berr("ERROR: Failed to duplicate the full path: %d\n",
binp->filename);
nxsem_post(&g_pcode_handoff.exclsem);
ret = -ENOMEM;
goto errout_with_fd;
}
g_pcode_handoff.binp = binp;
/* Successfully identified (but not really loaded) a p-code binary */
ret = OK;
errout_with_fd:
close(fd);
return ret;
}
/****************************************************************************
* Name: pcode_unload
*
* Description:
* Called when the pcode binary is unloaded. This is necessary primarily
* to handler error conditions where unload_module is called after
* pcode_load without having executed the P-Code module.
*
****************************************************************************/
static int pcode_unload(struct binary_s *binp)
{
/* Increment the semaphore count back to one if appropriate */
if (g_pcode_handoff.binp)
{
g_pcode_handoff.binp = NULL;
nxsem_post(&g_pcode_handoff.exclsem);
}
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: pcode_initialize
*
* Description:
* In order to use the P-code binary format, this function must be called
* during system initialization to register the P-Code binary format.
*
* Returned Value:
* This is a NuttX internal function so it follows the convention that
* 0 (OK) is returned on success and a negated errno is returned on
* failure.
*
****************************************************************************/
int pcode_initialize(void)
{
int ret;
/* Initialize globals */
nxsem_init(&g_pcode_handoff.exclsem, 0, 1);
/* Mount the test file system */
ret = pcode_mount_testfs();
if (ret < 0)
{
berr("ERROR: Failed to mount test file system: %d\n", ret);
return ret;
}
/* Register ourselves as a binfmt loader */
binfo("Registering P-Code Loader\n");
ret = register_binfmt(&g_pcode_binfmt);
if (ret != 0)
{
berr("Failed to register binfmt: %d\n", ret);
}
return ret;
}
/****************************************************************************
* Name: pcode_uninitialize
*
* Description:
* Unregister the pcode binary loader
*
* Returned Value:
* None
*
****************************************************************************/
void pcode_uninitialize(void)
{
int ret;
/* Unregister the binary format */
ret = unregister_binfmt(&g_pcode_binfmt);
if (ret < 0)
{
berr("ERROR: unregister_binfmt() failed: %d\n", ret);
}
#ifdef CONFIG_BINFMT_PCODE_TEST_FS
ret = umount(CONFIG_BINFMT_PCODE_TEST_MOUNTPOINT);
if (ret < 0)
{
int errval = get_errno();
DEBUGASSERT(errval > 0);
berr("ERROR: umount(%s) failed: %d\n",
CONFIG_BINFMT_PCODE_TEST_MOUNTPOINT, errval);
UNUSED(errval);
}
#endif
/* Uninitialize globals */
nxsem_destroy(&g_pcode_handoff.exclsem);
}
#endif /* CONFIG_BINFMT_PCODE */

View File

@ -863,10 +863,6 @@ ostest
The "standard" NuttX apps/examples/ostest configuration.
pashello
Configures to use apps/examples/pashello.
pf_ieee802154
This is the configuration that used for unit level test of the

View File

@ -1,26 +0,0 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
CONFIG_ARCH="sim"
CONFIG_ARCH_BOARD="sim"
CONFIG_ARCH_BOARD_SIM=y
CONFIG_ARCH_SIM=y
CONFIG_ARCH_CHIP="sim"
CONFIG_EXAMPLES_PASHELLO=y
CONFIG_FS_FAT=y
CONFIG_IDLETHREAD_STACKSIZE=4096
CONFIG_INTERPRETERS_PCODE=y
CONFIG_MAX_TASKS=64
CONFIG_NFILE_DESCRIPTORS=32
CONFIG_PTHREAD_STACK_DEFAULT=8192
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=27
CONFIG_START_MONTH=2
CONFIG_START_YEAR=2007
CONFIG_SYSTEM_PRUN=y
CONFIG_USERMAIN_STACKSIZE=4096
CONFIG_USER_ENTRYPOINT="pashello_main"

View File

@ -39,9 +39,6 @@ Version 4.11.0
- Not all NuttX logic will not run with the -regvars option. There is
at least one failure that has been reported to ZiLOG as incident 81400.
- The Pascal add-on interpreter includes a large switch statement and
exposes another compiler problem. This is reported as incident 81459.
Version 4.11.1
As of this writing (30 September 2010), the latest release of ZDS-II for the
@ -278,29 +275,4 @@ ostest
trailing bad characters are manually eliminated, then the build
will succeed on the next try.
pashello
--------
Configures to use examples/pashello for execution from FLASH
See examples/README.txt for information about pashello.
NOTES:
1. This configuration uses the mconf-based configuration tool. To
change this configuration using that tool, you should:
a. Build and install the kconfig-mconf tool. See nuttx/README.txt
see additional README.txt files in the NuttX tools repository.
b. Execute 'make menuconfig' in nuttx/ in order to start the
reconfiguration process.
2. The last time I tried building this configuration, there were
a few undefined symbols from the PCODE logic. It might require
a little TLC to get this all working again.
3. The native windows build has not been tried with this configuration
but should, in principle, work (see notes for the ostest configuration
above).
Check out any README.txt files in these <sub-directory>s.

View File

@ -1,5 +0,0 @@
pashello.hex
pashello.map
pashello.lod
pashello.wsp

View File

@ -1,12 +0,0 @@
README.txt
^^^^^^^^^^
pashello.zfpproj is a simple ZDS-II project that will allow you
to use the ZDS-II debugger. Before using, copy the following
files from the toplevel directory:
nuttx.hex, nuttx.map, nuttx.lod
to this directory as:
pashello.hex, pashello.map, pashello.lod

View File

@ -1,42 +0,0 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
CONFIG_ARCH_BOARD_Z16F2800100ZCOG=y
CONFIG_ARCH_BOARD="z16f2800100zcog"
CONFIG_ARCH_CHIP="z16f2811"
CONFIG_ARCH_CHIP_Z16F=y
CONFIG_ARCH_CHIP_Z16F2811=y
CONFIG_ARCH_Z16=y
CONFIG_ARCH="z16"
CONFIG_BOARD_LOOPSPERMSEC=1250
CONFIG_DEV_LOWCONSOLE=y
CONFIG_ENDIAN_BIG=y
CONFIG_EXAMPLES_PASHELLO=y
CONFIG_HOST_WINDOWS=y
CONFIG_IDLETHREAD_STACKSIZE=4096
CONFIG_INTERPRETERS_PCODE=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=4
CONFIG_PTHREAD_STACK_DEFAULT=4096
CONFIG_RAM_SIZE=65536
CONFIG_RR_INTERVAL=200
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=28
CONFIG_START_YEAR=2008
CONFIG_SYSTEM_PRUN=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_BAUD=57600
CONFIG_UART0_SERIAL_CONSOLE=y
CONFIG_UART1_BAUD=57600
CONFIG_USER_ENTRYPOINT="pashello_main"
CONFIG_USERMAIN_STACKSIZE=4096
CONFIG_WDOG_INTRESERVE=0

View File

@ -1,238 +0,0 @@
<project type="Standard" project-type="Standard" configuration="Debug" created-by="{{build_number}}" modified-by="c:4.11:07031901">
<cpu>Z16F2811AL</cpu>
<!-- file information -->
<files>
<file filter-key="flash">..\..\..\nuttx.hex</file>
</files>
<!-- configuration information -->
<configurations>
<configuration name="Debug" >
<tools>
<tool name="Assembler">
<options>
<option name="define" type="string" change-action="assemble">_Z16F2811AL=1,_Z16F_SERIES=1</option>
<option name="include" type="string" change-action="assemble"></option>
<option name="list" type="boolean" change-action="none">true</option>
<option name="listmac" type="boolean" change-action="none">false</option>
<option name="name" type="boolean" change-action="none">true</option>
<option name="pagelen" type="integer" change-action="none">56</option>
<option name="pagewidth" type="integer" change-action="none">80</option>
<option name="quiet" type="boolean" change-action="none">true</option>
</options>
</tool>
<tool name="Compiler">
<options>
<option name="chartype" type="string" change-action="compile">U</option>
<option name="define" type="string" change-action="compile">_Z16F2811AL,_Z16F_SERIES</option>
<option name="genprintf" type="boolean" change-action="compile">true</option>
<option name="keepasm" type="boolean" change-action="none">false</option>
<option name="keeplst" type="boolean" change-action="none">false</option>
<option name="list" type="boolean" change-action="none">false</option>
<option name="listinc" type="boolean" change-action="none">false</option>
<option name="model" type="string" change-action="compile">S</option>
<option name="modsect" type="boolean" change-action="compile">false</option>
<option name="stdinc" type="string" change-action="compile"></option>
<option name="usrinc" type="string" change-action="compile"></option>
<option name="regvar" type="boolean" change-action="compile">true</option>
<option name="regvarcache" type="boolean" change-action="none">false</option>
<option name="reduceopt" type="boolean" change-action="compile">false</option>
<option name="watch" type="boolean" change-action="none">false</option>
</options>
</tool>
<tool name="Debugger">
<options>
<option name="target" type="string" change-action="rebuild">Z16F2800100ZCOG</option>
<option name="debugtool" type="string" change-action="none">USBSmartCable</option>
<option name="usepageerase" type="boolean" change-action="none">true</option>
</options>
</tool>
<tool name="FlashProgrammer">
<options>
<option name="erasebeforeburn" type="boolean" change-action="none">false</option>
<option name="eraseinfopage" type="boolean" change-action="none">false</option>
<option name="enableinfopage" type="boolean" change-action="none">false</option>
<option name="includeserial" type="boolean" change-action="none">false</option>
<option name="offset" type="integer" change-action="none">0</option>
<option name="snenable" type="boolean" change-action="none">true</option>
<option name="sn" type="string" change-action="none">000000000000000000000000</option>
<option name="snsize" type="integer" change-action="none">1</option>
<option name="snstep" type="integer" change-action="none">000000000000000000000001</option>
<option name="snstepformat" type="integer" change-action="none">0</option>
<option name="snaddress" type="string" change-action="none">0</option>
<option name="snformat" type="integer" change-action="none">0</option>
<option name="snbigendian" type="boolean" change-action="none">true</option>
<option name="singleval" type="string" change-action="none">0</option>
<option name="singlevalformat" type="integer" change-action="none">0</option>
<option name="usepageerase" type="boolean" change-action="none">false</option>
<option name="autoselect" type="boolean" change-action="none">true</option>
</options>
</tool>
<tool name="General">
<options>
<option name="warn" type="boolean" change-action="none">true</option>
<option name="debug" type="boolean" change-action="assemble">true</option>
<option name="debugcache" type="boolean" change-action="none">true</option>
<option name="igcase" type="boolean" change-action="assemble">false</option>
<option name="outputdir" type="string" change-action="compile">.</option>
</options>
</tool>
<tool name="Librarian">
<options>
<option name="outfile" type="string" change-action="build"></option>
<option name="warn" type="boolean" change-action="none">false</option>
</options>
</tool>
<tool name="Linker">
<options>
<option name="directives" type="string" change-action="build"></option>
<option name="createnew" type="boolean" change-action="build">false</option>
<option name="eram" type="string" change-action="build">0-0</option>
<option name="erom" type="string" change-action="build">0-0</option>
<option name="exeform" type="string" change-action="build">OMF695,INTEL32</option>
<option name="fplib" type="string" change-action="build">Dummy</option>
<option name="iodata" type="string" change-action="build">0-0</option>
<option name="linkctlfile" type="string" change-action="build"></option>
<option name="map" type="boolean" change-action="none">true</option>
<option name="maxhexlen" type="integer" change-action="build">64</option>
<option name="objlibmods" type="string" change-action="build"></option>
<option name="of" type="string" change-action="build">.\pashello</option>
<option name="padhex" type="boolean" change-action="build">false</option>
<option name="quiet" type="boolean" change-action="none">false</option>
<option name="ram" type="string" change-action="build">FFB000-FFBFFF</option>
<option name="relist" type="boolean" change-action="build">false</option>
<option name="rom" type="string" change-action="build">000000-007FFF</option>
<option name="sort" type="string" change-action="none">name</option>
<option name="startuplnkcmds" type="boolean" change-action="build">true</option>
<option name="startuptype" type="string" change-action="build">1</option>
<option name="undefisfatal" type="boolean" change-action="none">true</option>
<option name="useadddirectives" type="boolean" change-action="build">false</option>
<option name="usecrun" type="boolean" change-action="build">true</option>
<option name="warnoverlap" type="boolean" change-action="none">false</option>
<option name="warnisfatal" type="boolean" change-action="none">false</option>
<option name="xref" type="boolean" change-action="none">false</option>
</options>
</tool>
</tools>
</configuration>
<configuration name="Release" >
<tools>
<tool name="Assembler">
<options>
<option name="define" type="string" change-action="assemble">_Z16F2811AL=1,_Z16F_SERIES=1</option>
<option name="include" type="string" change-action="assemble"></option>
<option name="list" type="boolean" change-action="none">true</option>
<option name="listmac" type="boolean" change-action="none">false</option>
<option name="name" type="boolean" change-action="none">true</option>
<option name="pagelen" type="integer" change-action="none">56</option>
<option name="pagewidth" type="integer" change-action="none">80</option>
<option name="quiet" type="boolean" change-action="none">true</option>
</options>
</tool>
<tool name="Compiler">
<options>
<option name="chartype" type="string" change-action="compile">U</option>
<option name="define" type="string" change-action="compile">_Z16F2811AL,_Z16F_SERIES</option>
<option name="genprintf" type="boolean" change-action="compile">true</option>
<option name="keepasm" type="boolean" change-action="none">false</option>
<option name="keeplst" type="boolean" change-action="none">false</option>
<option name="list" type="boolean" change-action="none">false</option>
<option name="listinc" type="boolean" change-action="none">false</option>
<option name="model" type="string" change-action="compile">S</option>
<option name="modsect" type="boolean" change-action="compile">false</option>
<option name="stdinc" type="string" change-action="compile"></option>
<option name="usrinc" type="string" change-action="compile"></option>
<option name="regvar" type="boolean" change-action="compile">true</option>
<option name="regvarcache" type="boolean" change-action="none">false</option>
<option name="reduceopt" type="boolean" change-action="compile">false</option>
<option name="watch" type="boolean" change-action="none">false</option>
</options>
</tool>
<tool name="Debugger">
<options>
<option name="target" type="string" change-action="rebuild"></option>
<option name="debugtool" type="string" change-action="none">ZPAKII</option>
<option name="usepageerase" type="boolean" change-action="none">true</option>
</options>
</tool>
<tool name="FlashProgrammer">
<options>
<option name="erasebeforeburn" type="boolean" change-action="none">false</option>
<option name="eraseinfopage" type="boolean" change-action="none">false</option>
<option name="enableinfopage" type="boolean" change-action="none">false</option>
<option name="includeserial" type="boolean" change-action="none">false</option>
<option name="offset" type="integer" change-action="none">0</option>
<option name="snenable" type="boolean" change-action="none">false</option>
<option name="sn" type="string" change-action="none">0</option>
<option name="snsize" type="integer" change-action="none">0</option>
<option name="snstep" type="integer" change-action="none">1</option>
<option name="snstepformat" type="integer" change-action="none">0</option>
<option name="snaddress" type="string" change-action="none">0</option>
<option name="snformat" type="integer" change-action="none">0</option>
<option name="snbigendian" type="boolean" change-action="none">true</option>
<option name="singleval" type="string" change-action="none">0</option>
<option name="singlevalformat" type="integer" change-action="none">0</option>
<option name="usepageerase" type="boolean" change-action="none">false</option>
<option name="autoselect" type="boolean" change-action="none">true</option>
</options>
</tool>
<tool name="General">
<options>
<option name="warn" type="boolean" change-action="none">true</option>
<option name="debug" type="boolean" change-action="assemble">false</option>
<option name="debugcache" type="boolean" change-action="none">true</option>
<option name="igcase" type="boolean" change-action="assemble">false</option>
<option name="outputdir" type="string" change-action="compile">.</option>
</options>
</tool>
<tool name="Librarian">
<options>
<option name="outfile" type="string" change-action="build"></option>
<option name="warn" type="boolean" change-action="none">false</option>
</options>
</tool>
<tool name="Linker">
<options>
<option name="directives" type="string" change-action="build"></option>
<option name="createnew" type="boolean" change-action="build">false</option>
<option name="eram" type="string" change-action="build">0-0</option>
<option name="erom" type="string" change-action="build">0-0</option>
<option name="exeform" type="string" change-action="build">OMF695,INTEL32</option>
<option name="fplib" type="string" change-action="build">Dummy</option>
<option name="iodata" type="string" change-action="build">0-0</option>
<option name="linkctlfile" type="string" change-action="build"></option>
<option name="map" type="boolean" change-action="none">true</option>
<option name="maxhexlen" type="integer" change-action="build">64</option>
<option name="objlibmods" type="string" change-action="build"></option>
<option name="of" type="string" change-action="build">.\pashello</option>
<option name="padhex" type="boolean" change-action="build">false</option>
<option name="quiet" type="boolean" change-action="none">false</option>
<option name="ram" type="string" change-action="build">FFB000-FFBFFF</option>
<option name="relist" type="boolean" change-action="build">false</option>
<option name="rom" type="string" change-action="build">000000-007FFF</option>
<option name="sort" type="string" change-action="none">name</option>
<option name="startuplnkcmds" type="boolean" change-action="build">true</option>
<option name="startuptype" type="string" change-action="build">1</option>
<option name="undefisfatal" type="boolean" change-action="none">true</option>
<option name="useadddirectives" type="boolean" change-action="build">false</option>
<option name="usecrun" type="boolean" change-action="build">true</option>
<option name="warnoverlap" type="boolean" change-action="none">false</option>
<option name="warnisfatal" type="boolean" change-action="none">false</option>
<option name="xref" type="boolean" change-action="none">false</option>
</options>
</tool>
</tools>
</configuration>
</configurations>
<!-- watch information -->
<watch-elements>
<watch-element expression="0x801d1a" />
</watch-elements>
<!-- breakpoint information -->
<breakpoints>
</breakpoints>
</project>

View File

@ -100,49 +100,6 @@ Configuring NuttX
the configure to Kconfig/mconf tool using SDCC 2.6.0 built to run
natively under Cygwin.nsh/defconfig:CONFIG_BOARD_LOOPSPERMSEC
pashello
Configures to use examples/pashello for execution from FLASH
See examples/README.txt for information about pashello.
This configuration is not usable because the resulting binary
is too large for the z80 address space.
This configuration can be selected by:
1) From a POSIX window:
tools/configure.sh [OPTIONS] z80sim:pashello
where you need to select the right [OPTIONS] for your build
environment. Do:
tools/configure.sh -h
to see the options.
2) Set the PATH environment variable to include the path to the SDCC
toolchain binaries.
3) Then build the binaries:
make
NOTES:
1. This configuration uses the mconf-based configuration tool. See the
"Reconfiguring" section below for information about changing this
configuration.
2. The default setup for this configuration uses a windows native build.
See the section entitled "Reconfiguring for Windows Native, Cygwin,
or macOS" which will give you the steps you would need to do to convert
this configuration to build in other environments.
3. This configuration was last verified successfully prior to the
the configure to Kconfig/mconf tool using SDCC 2.6.0 built to run
natively under Cygwin.nsh/defconfig:CONFIG_BOARD_LOOPSPERMSEC
Reconfiguring NuttX
^^^^^^^^^^^^^^^^^^^

View File

@ -1,45 +0,0 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_DISABLE_ENVIRON is not set
CONFIG_ARCH_BOARD_Z80SIM=y
CONFIG_ARCH_BOARD="z80sim"
CONFIG_ARCH_CHIP_Z80=y
CONFIG_ARCH_CHIP="z80"
CONFIG_ARCH_Z80=y
CONFIG_ARCH="z80"
CONFIG_BOARD_LOOPSPERMSEC=100
CONFIG_DEFAULT_SMALL=y
CONFIG_DEV_LOWCONSOLE=y
CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_DISABLE_MQUEUE=y
CONFIG_DISABLE_PTHREAD=y
CONFIG_EXAMPLES_PASHELLO=y
CONFIG_INTERPRETERS_PCODE=y
CONFIG_MAX_TASKS=8
CONFIG_MAX_WDOGPARMS=2
CONFIG_NFILE_DESCRIPTORS=4
CONFIG_NFILE_STREAMS=4
CONFIG_NUNGET_CHARS=0
CONFIG_PREALLOC_TIMERS=0
CONFIG_PREALLOC_WDOGS=4
CONFIG_PTHREAD_STACK_DEFAULT=1024
CONFIG_RAM_SIZE=65536
CONFIG_RAM_START=0x0000
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=7
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2012
CONFIG_STDIO_DISABLE_BUFFERING=y
CONFIG_SYSTEM_PRUN=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART_RXBUFSIZE=64
CONFIG_UART_SERIAL_CONSOLE=y
CONFIG_UART_TXBUFSIZE=64
CONFIG_USER_ENTRYPOINT="pashello_main"
CONFIG_USERMAIN_STACKSIZE=1024
CONFIG_WDOG_INTRESERVE=0

View File

@ -1,100 +0,0 @@
/****************************************************************************
* include/nuttx/binfmt/pcode.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 __INCLUDE_NUTTX_BINFMT_PCODE_H
#define __INCLUDE_NUTTX_BINFMT_PCODE_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: pcode_initialize
*
* Description:
* In order to use the P-code binary format, this function must be called
* during system initialization to register the P-Code binary format.
*
* Returned Value:
* This is a NuttX internal function so it follows the convention that
* 0 (OK) is returned on success and a negated errno is returned on
* failure.
*
****************************************************************************/
int pcode_initialize(void);
/****************************************************************************
* Name: pcode_uninitialize
*
* Description:
* Unregister the pcode binary loader
*
* Returned Value:
* None
*
****************************************************************************/
void pcode_uninitialize(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_NUTTX_BINFMT_PCODE_H */

View File

@ -1,435 +0,0 @@
/****************************************************************************
* include/nuttx/poff.h
* Definitions for the P-Code Object File Format (POFF)
*
* 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 __INCLUDE_NUTTX_POFF_H
#define __INCLUDE_NUTTX_POFF_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Definitions for the fh_ident field of the poffHdr_t */
#define FHI_MAG0 0 /* fh_ident[] indices */
#define FHI_MAG1 1
#define FHI_MAG2 2
#define FHI_MAG3 3
#define FHI_NIDENT 4
#define FHI_POFF_MAG0 'P'
#define FHI_POFF_MAG1 'O'
#define FHI_POFF_MAG2 'F'
#define FHI_POFF_MAG3 'F'
#define FHI_POFF_MAG "POFF"
/* Definitions for fh_version */
#define FHV_NONE 0
#define FHV_CURRENT 1
/* Definitions for the fh_type */
#define FHT_NONE 0 /* Shouldn't happen */
#define FHT_EXEC 1 /* Pascal program executable */
#define FHT_SHLIB 2 /* Pascal shared library */
#define FHT_PROGRAM 3 /* Pascal program object */
#define FHT_UNIT 4 /* Pascal unit object */
#define FHT_NTYPES 5
/* Definitions for fh_arch */
#define FHAW_INSN16 0 /* Data width is 16 bits */
#define FHAW_INSN32 1 /* Data width is 32 bits */
#define FHAC_PCODE 0 /* Stack oriented P-Code machine class */
#define FHAC_REGM 1 /* Generalized register machine class */
#define MK_FH_ARCH(c,w) (((c)<<4)|(w))
#define GET_FH_CLASS(fha) ((fha) >> 4)
#define GET_FH_WIDTH(fha) ((fha) & 0x0f)
#define FHA_PCODE_INSN16 MK_FH_ARCH(FHAC_PCODE,FHAW_INSN16)
#define FHA_PCODE_INSN32 MK_FH_ARCH(FHAC_PCODE,FHAW_INSN32)
#define FHA_REGM_INSN16 MK_FH_ARCH(FHAC_REGM,FHAW_INSN16)
#define FHA_REGM_INSN32 MK_FH_ARCH(FHAC_REGM,FHAW_INSN32)
#ifdef CONFIG_INSN16
# define FHA_PCODE FHA_PCODE_INSN16
# define FHA_REGM FHA_REGM_INSN16
#endif
#ifdef CONFIG_INSN32
# define FHA_PCODE FHA_PCODE_INSN32
# define FHA_REGM FHA_REGM_INSN16
#endif
/* Definitions for sh_type */
#define SHT_NULL 0 /* Shouldn't happen */
#define SHT_PROGDATA 1 /* Program data */
#define SHT_SYMTAB 2 /* Symbol table */
#define SHT_STRTAB 3 /* String table */
#define SHT_REL 4 /* Relocation data */
#define SHT_FILETAB 5 /* File table */
#define SHT_LINENO 6 /* Line number data */
#define SHT_DEBUG 7 /* Procedure/Function info */
#define SHT_NTYPES 8
/* Definitions for sh_flags */
#define SHF_WRITE 0x01 /* Section is write-able */
#define SHF_ALLOC 0x02 /* Memory must be allocated for setion */
#define SHF_EXEC 0x04 /* Section contains program data */
/* Values for st_type */
#define STT_NONE 0 /* Should not occur */
#define STT_DATA 1 /* Stack data section symbol */
#define STT_RODATA 2 /* Read only data section symbol */
#define STT_PROC 3 /* Procedure entry point */
#define STT_FUNC 4 /* Function entry point */
#define STT_NTYPES 5
/* Values for st_align. Any power of two numeric value can be
* used, but the following are defined for convenience.
*/
#define STA_NONE 0 /* Should not occur */
#define STA_8BIT 1 /* 8-bit byte alignment */
#define STA_16BIT 2 /* 16-bit half word alignment */
#define STA_32BIT 4 /* 32-bit word alignment */
#define STA_64BIT 8 /* 32-bit double word alignment */
/* Values for st_flags */
#define STF_NONE 0x00
#define STF_UNDEFINED 0x01 /* Symbol is undefined (imported) */
/* P-Code relocation types (see RLI_type) */
#define RLT_NONE 0 /* Should not occur */
#define RLT_PCAL 1 /* PCAL to external proc/func */
#define RLT_LDST 2 /* LA or LAX to external stack loc */
#define RLT_NTYPES 3
/* The following are used with relocation table rl_info field */
#define RLI_SYM(x) ((x) >> 8) /* Symbol index */
#define RLI_TYPE(x) ((x) & 0xff) /* Reloc type */
#define RLI_MAKE(s,t) (((uint32_t)(s) << 8) | ((t) & 0xff))
/****************************************************************************
* Public Types
****************************************************************************/
/* POFF file header */
struct poff_fileheader_s
{
/* fh_ident holds the four characters 'P', 'O', 'F', 'F'. See the FHI_
* definitions above.
*/
uint8_t fh_ident[FHI_NIDENT];
/* fh_version holds the version of the POFF file format. This should
* always be FHV_CURRENT.
*/
uint8_t fh_version;
/* fh_type holds the type of binary carry by the POFF file.
* See the FHT_ definitions above.
*/
uint8_t fh_type;
/* fh_arch holds the architecture identifier. See the FHA_
* definitions above.
*/
uint8_t fh_arch;
/* Pad so that the next field is aligned */
uint8_t fh_padding;
/* fh_shsize is the size a section header. This should be
* sizeof(poffSectionHeader_t)
*/
uint16_t fh_shsize;
/* fh_num is the number of section headers in section header
* list. The total size of the section header block is then
* fh_shsize * fh_shnum.
*/
uint16_t fh_shnum;
/* fh_name is an offset into the string table section data.
* It refers to a name associated with fh_type that determines
* the specific instances of the type.
*/
uint32_t fh_name;
/* For fhi_type = {FHI_EXEC or FHI_PROGRAM}, fh_entry holds the
* entry point into the program. For FHI_PROGRAM, this entry point
* is a instruction space label. For FHI_EXEC, this entry point
* is an instruction space address offset (from address zero).
*/
uint32_t fh_entry;
/* fh_shoff is the file offset to the beginning of the table of file
* headers. fh_shoff will most likely be sizeof(poffFileHeader_t).
*/
uint32_t fh_shoff;
};
typedef struct poff_fileheader_s poff_fileheader_t;
/* POFF section header */
struct poff_sectionhdr_s
{
/* sh_type is the type of section described by this header.
* See the SHT_ definitions above.
*/
uint8_t sh_type;
/* These flags describe the characteristics of the section. See the
* SHF_ definitions above.
*/
uint8_t sh_flags;
/* If the section holds a table of fixed sized entries, sh_entsize
* gives the size of one entry. The number of entries can then be
* obtained by dividing sh_size by sh_entsize.
*/
uint16_t sh_entsize;
/* sh_name is an offset into the string table section data.
* It refers to a name associated with section.
*/
uint32_t sh_name;
/* If the section is loaded into memory (SHF_ALLOC), then this
* address holds the address at which the data must be loaded
* (if applicable).
*/
uint32_t sh_addr;
/* sh_offset is the offset from the beginning of the file to
* beginning of data associated with this section.
*/
uint32_t sh_offset;
/* sh_size provides the total size of the section data in bytes.
* If the section holds a table of fixed sized entries, then
* sh_size be equal to sh_entsize times the number of entries.
*/
uint32_t sh_size;
};
typedef struct poff_sectionhdr_s poff_sectionhdr_t;
/* Structures which may appear as arrays in sections */
/* Relocation data section array entry structure */
struct poff_relocation_s
{
/* This value includes the symbol table index plus the
* relocation type. See the RLI_* macros above.
*/
uint32_t rl_info;
/* This is the section data offset to the instruction/data
* to be relocated. The effected section is implicit in the
* relocation type.
*/
uint32_t rl_offset; /* Offset to pcode */
};
typedef struct poff_relocation_s poff_relocation_t;
/* Symbol section array entry structure */
struct poff_symbol_s
{
/* st_type is the type of symbol described by this entry.
* See the STT_ definitions above.
*/
uint8_t st_type;
/* For data section symbols, the following provides the required
* data space alignment for the symbol memory representation. For
* procedures and functions, this value is ignored. See the STT_
* definitions above.
*/
uint8_t st_align;
/* These flags describe the characteristics of the symbol. See the
* STF_ definitions above.
*/
uint8_t st_flags;
uint8_t st_pad;
/* st_name is an offset into the string table section data.
* It refers to a name associated with symbol.
*/
uint32_t st_name;
/* st_value is the value associated with symbol. For defined data
* section symbols, this is the offset into the initialized data
* section data; for defined procedures and functions, this the
* offset into program section data. For undefined symbols, this
* valid can be used as as addend.
*/
uint32_t st_value;
/* For data section symbols, this is the size of the initialized
* data region associated with the symbol.
*/
uint32_t st_size;
};
typedef struct poff_symbol_s poff_symbol_t;
/* The file table section just consists of a list of offsets
* into the string table. The file table index is used elsewhere
* (such as in the line number array) to refer to a specific
* file.
*/
typedef uint32_t poffFileTab_t;
/* Line number section array entry structure. Line numbers are
* associated with executable program data sections.
*/
struct poff_linenumber_s
{
/* This is the source file line number */
uint16_t ln_lineno;
/* This is an index (not a byte offset) to an entry in the file
* section table. This can be used to identify the name of the
* file for which the line number applies.
*/
uint16_t ln_fileno;
/* This is an offset to the beginning of the instruction in the
* program data section. At present, this is limited to a single
* program data section.
*/
uint32_t ln_poffset;
};
typedef struct poff_linenumber_s poff_linenumber_t;
/* The debug info section consists of a list of poffDebugFuncInfo_t
* entries, each following a sublist of poffDebugArgInfo_t entries.
*/
/* poffDebugFuncInfo_t provides description of function input
* parameters and return values.
*/
struct poff_debugfuncinfo_s
{
/* This is the address or label of the function/procedure entry
* point.
*/
uint32_t df_value;
/* This is the size of the value returned by the function in
* bytes (zero for procedures).
*/
uint32_t df_size;
/* This is the number of parameters accepted by the function/
* procedure.
*/
uint32_t df_nparms;
};
typedef struct poff_debugfuncinfo_s poff_debugfuncinfo_t;
/* poffDebugArgInfo_t provides description of one function input
* parameter.
*/
struct poff_debugarginfo_s
{
/* This is the size, in bytes, of one input parameter */
uint32_t da_size;
};
typedef struct poff_debugarginfo_s poff_debugarginfo_t;
#endif /* __INCLUDE_NUTTX_POFF_H */