Add a ROMFS file system for testing the P-Code binary format
This commit is contained in:
parent
e2b8eb6aad
commit
7fffa72ee5
@ -7312,5 +7312,5 @@
|
|||||||
From Jussi Kivilinna (2014-5-8).
|
From Jussi Kivilinna (2014-5-8).
|
||||||
* arch/arm/include/stm32 and src/stm32: Add support for the STM32152 and
|
* arch/arm/include/stm32 and src/stm32: Add support for the STM32152 and
|
||||||
STM32162 Medium+ density parts (plus miscellaneous other improvements to
|
STM32162 Medium+ density parts (plus miscellaneous other improvements to
|
||||||
the original STM32151 logi). From Jussi Kivilinna and Sami Pelkonen
|
the original STM32151 logic). From Jussi Kivilinna and Sami Pelkonen
|
||||||
(2014-5-8).
|
(2014-5-8).
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<tr align="center" bgcolor="#e4e4e4">
|
<tr align="center" bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<h1><big><font color="#3c34ec"><i>NuttX README Files</i></font></big></h1>
|
<h1><big><font color="#3c34ec"><i>NuttX README Files</i></font></big></h1>
|
||||||
<p>Last Updated: April 20, 2014</p>
|
<p>Last Updated: May 8, 2014</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -45,6 +45,9 @@
|
|||||||
| | | |- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/arch/z80/src/z180/README.txt">README.txt</a>
|
| | | |- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/arch/z80/src/z180/README.txt">README.txt</a>
|
||||||
| | | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/arch/z80/src/z180/z180_mmu.txt">z180_mmu.txt</a>
|
| | | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/arch/z80/src/z180/z180_mmu.txt">z180_mmu.txt</a>
|
||||||
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/arch/README.txt"><b><i>README.txt</i></b></a>
|
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/arch/README.txt"><b><i>README.txt</i></b></a>
|
||||||
|
| |- binfmt/
|
||||||
|
| | |- libpcode/
|
||||||
|
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/binfmt/libpcode/README.txt"><b><i>README.txt</i></b></a>
|
||||||
| |- audio/
|
| |- audio/
|
||||||
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/audio/README.txt"><b><i>README.txt</i></b></a>
|
| | `- <a href="http://sourceforge.net/p/nuttx/git/ci/master/tree/nuttx/audio/README.txt"><b><i>README.txt</i></b></a>
|
||||||
| |- configs/
|
| |- configs/
|
||||||
|
@ -914,6 +914,9 @@ nuttx
|
|||||||
| `- README.txt
|
| `- README.txt
|
||||||
|- audio/
|
|- audio/
|
||||||
| `-README.txt
|
| `-README.txt
|
||||||
|
|- binfmt/
|
||||||
|
| `-libpcode/
|
||||||
|
| `-README.txt
|
||||||
|- configs/
|
|- configs/
|
||||||
| |- 16z/
|
| |- 16z/
|
||||||
| | `- README.txt
|
| | `- README.txt
|
||||||
|
@ -15,6 +15,38 @@ config PCODE_PRIORITY
|
|||||||
---help---
|
---help---
|
||||||
This is the task_priority that will be used when starting P-code interpreter.
|
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
|
config PCODE_DUMPBUFFER
|
||||||
bool "Dump P-code buffers"
|
bool "Dump P-code buffers"
|
||||||
default n
|
default n
|
||||||
|
@ -37,16 +37,21 @@ ifeq ($(CONFIG_PCODE),y)
|
|||||||
|
|
||||||
# P-code application interfaces
|
# P-code application interfaces
|
||||||
|
|
||||||
# BINFMT_CSRCS +=
|
BINFMT_CSRCS += pcode.c
|
||||||
|
|
||||||
# P-code library interfaces
|
# P-code library interfaces
|
||||||
|
|
||||||
# BINFMT_CSRCS +=
|
# 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
|
||||||
|
|
||||||
#VPATH += libbuiltin
|
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" "$(TOPDIR)$(DELIM)binfmt$(DELIM)libpcode"}
|
||||||
#SUBDIRS += libbuiltin
|
|
||||||
#DEPPATH += --dep-path libbuiltin
|
# Hook the libpcode subdirectory into the build
|
||||||
|
|
||||||
|
#VPATH += libpcode
|
||||||
|
#SUBDIRS += libpcode
|
||||||
|
#DEPPATH += --dep-path libpcode
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
51
binfmt/libpcode/README.txt
Normal file
51
binfmt/libpcode/README.txt
Normal file
@ -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.
|
5
binfmt/libpcode/hello.pas
Normal file
5
binfmt/libpcode/hello.pas
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
program hello(output);
|
||||||
|
begin
|
||||||
|
writeln('Hello world!!!');
|
||||||
|
end.
|
||||||
|
|
BIN
binfmt/libpcode/hello.pex
Normal file
BIN
binfmt/libpcode/hello.pex
Normal file
Binary file not shown.
139
binfmt/libpcode/romfs.h
Normal file
139
binfmt/libpcode/romfs.h
Normal file
@ -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 */
|
BIN
binfmt/libpcode/romfs.img
Normal file
BIN
binfmt/libpcode/romfs.img
Normal file
Binary file not shown.
147
binfmt/pcode.c
147
binfmt/pcode.c
@ -39,12 +39,16 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <sys/mount.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/poff.h>
|
#include <nuttx/poff.h>
|
||||||
|
#include <nuttx/fs/ramdisk.h>
|
||||||
#include <nuttx/binfmt/binfmt.h>
|
#include <nuttx/binfmt/binfmt.h>
|
||||||
#include <nuttx/binfmt/pcode.h>
|
#include <nuttx/binfmt/pcode.h>
|
||||||
|
|
||||||
@ -53,6 +57,48 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* 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
|
||||||
|
|
||||||
|
#ifdef CONFIG_BINFMT_DISABLE
|
||||||
|
# error "The binary loader is disabled (CONFIG_BINFMT_DISABLE)!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_PCODE
|
||||||
|
# error "You must select CONFIG_PCODE in your configuration file"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_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_PCODE_TEST_DEVMINOR
|
||||||
|
# define CONFIG_PCODE_TEST_DEVMINOR 0
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef CONFIG_PCODE_TEST_DEVPATH
|
||||||
|
# define CONFIG_PCODE_TEST_DEVPATH "/dev/ram0"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef CONFIG_PCODE_TEST_MOUNTPOINT
|
||||||
|
# define CONFIG_PCODE_TEST_MOUNTPOINT "/bin"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Describe the ROMFS file system */
|
||||||
|
|
||||||
|
#define SECTORSIZE 512
|
||||||
|
#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
@ -70,10 +116,70 @@ static struct binfmt_s g_pcode_binfmt =
|
|||||||
pcode_loadbinary, /* load */
|
pcode_loadbinary, /* load */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_PCODE_TEST_FS
|
||||||
|
# include "romfs.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: pcode_mount_testfs
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* If so configured, then mount the P-Code test file system
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PCODE_TEST_FS
|
||||||
|
static int pcode_mount_testfs(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Create a ROM disk for the ROMFS filesystem */
|
||||||
|
|
||||||
|
bvdbg("Registering romdisk at /dev/ram%d\n", CONFIG_PCODE_TEST_DEVMINOR);
|
||||||
|
ret = romdisk_register(CONFIG_PCODE_TEST_DEVMINOR, (FAR uint8_t *)romfs_img,
|
||||||
|
NSECTORS(ROMFS_IMG_LEN), SECTORSIZE);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
bdbg("ERROR: romdisk_register failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mount the test file system */
|
||||||
|
|
||||||
|
bvdbg("Mounting ROMFS filesystem at target=%s with source=%s\n",
|
||||||
|
CONFIG_PCODE_TEST_MOUNTPOINT, CONFIG_PCODE_TEST_DEVPATH);
|
||||||
|
|
||||||
|
ret = mount(CONFIG_PCODE_TEST_DEVPATH, CONFIG_PCODE_TEST_MOUNTPOINT,
|
||||||
|
"romfs", MS_RDONLY, NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errval = errno;
|
||||||
|
DEBUGASSERT(errval > 0);
|
||||||
|
|
||||||
|
bdbg("ERROR: mount(%s,%s,romfs) failed: %d\n",
|
||||||
|
CONFIG_PCODE_TEST_DEVPATH, CONFIG_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_BINFMT_EXEPATH) && !defined(CONFIG_PATH_INITIAL)
|
||||||
|
(void)setenv("PATH", CONFIG_PCODE_TEST_MOUNTPOINT, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define pcode_mount_testfs() (OK)
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: pcode_proxy
|
* Name: pcode_proxy
|
||||||
*
|
*
|
||||||
@ -105,7 +211,6 @@ static int pcode_proxy(int argc, char **argv)
|
|||||||
static int pcode_loadbinary(struct binary_s *binp)
|
static int pcode_loadbinary(struct binary_s *binp)
|
||||||
{
|
{
|
||||||
FAR struct poff_fileheader_s hdr;
|
FAR struct poff_fileheader_s hdr;
|
||||||
FAR const struct pcode_s *b;
|
|
||||||
FAR uint8_t *ptr;
|
FAR uint8_t *ptr;
|
||||||
size_t remaining;
|
size_t remaining;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
@ -154,7 +259,7 @@ static int pcode_loadbinary(struct binary_s *binp)
|
|||||||
{
|
{
|
||||||
/* Set up for the next gulp */
|
/* Set up for the next gulp */
|
||||||
|
|
||||||
DEBUASSERT(nread > 0 && nread <=remaining);
|
DEBUGASSERT(nread > 0 && nread <=remaining);
|
||||||
remaining -= nread;
|
remaining -= nread;
|
||||||
ptr += nread;
|
ptr += nread;
|
||||||
}
|
}
|
||||||
@ -213,6 +318,15 @@ int pcode_initialize(void)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* Mount the test file system */
|
||||||
|
|
||||||
|
ret = pcode_mount_testfs();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
bdbg("ERROR: Failed to mount test file system: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Register ourselves as a binfmt loader */
|
/* Register ourselves as a binfmt loader */
|
||||||
|
|
||||||
bvdbg("Registering P-Code Loader\n");
|
bvdbg("Registering P-Code Loader\n");
|
||||||
@ -239,8 +353,31 @@ int pcode_initialize(void)
|
|||||||
|
|
||||||
void pcode_uninitialize(void)
|
void pcode_uninitialize(void)
|
||||||
{
|
{
|
||||||
unregister_binfmt(&g_pcode_binfmt);
|
int ret;
|
||||||
|
|
||||||
|
/* Unregister the binary format */
|
||||||
|
|
||||||
|
ret = unregister_binfmt(&g_pcode_binfmt);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errval = errno;
|
||||||
|
DEBUGASSERT(errval > 0);
|
||||||
|
|
||||||
|
bdbg("ERROR: unregister_binfmt() failed: %d\n", errval);
|
||||||
|
UNUSED(errval);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PCODE_TEST_FS
|
||||||
|
ret = umount(CONFIG_PCODE_TEST_MOUNTPOINT);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
int errval = errno;
|
||||||
|
DEBUGASSERT(errval > 0);
|
||||||
|
|
||||||
|
bdbg("ERROR: umount(%s) failed: %d\n", CONFIG_PCODE_TEST_MOUNTPOINT, errval);
|
||||||
|
UNUSED(errval);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_PCODE */
|
#endif /* CONFIG_PCODE */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user