summaryrefslogtreecommitdiff
path: root/nuttx/configs/ea3131
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-09-08 22:06:38 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-09-08 22:06:38 +0000
commit1218d6b44b4c1a7b28a8cebda1cf18cf0fc000bd (patch)
tree84f53c783121c4830102717e0c46380d747c8e3f /nuttx/configs/ea3131
parentf5072951cc0ddc165fea568a2733a19b51ed1cee (diff)
downloadpx4-nuttx-1218d6b44b4c1a7b28a8cebda1cf18cf0fc000bd.tar.gz
px4-nuttx-1218d6b44b4c1a7b28a8cebda1cf18cf0fc000bd.tar.bz2
px4-nuttx-1218d6b44b4c1a7b28a8cebda1cf18cf0fc000bd.zip
Add some SD file paging logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2932 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/ea3131')
-rwxr-xr-xnuttx/configs/ea3131/README.txt4
-rwxr-xr-xnuttx/configs/ea3131/pgnsh/defconfig23
-rwxr-xr-xnuttx/configs/ea3131/src/up_fillpage.c151
3 files changed, 167 insertions, 11 deletions
diff --git a/nuttx/configs/ea3131/README.txt b/nuttx/configs/ea3131/README.txt
index 556c4cb25..60fa974b2 100755
--- a/nuttx/configs/ea3131/README.txt
+++ b/nuttx/configs/ea3131/README.txt
@@ -448,6 +448,10 @@ On-Demand Paging
3. This means that all of the file system logic and FAT file
system would have to reside in the locked text region.
+ And the show-stopper:
+
+ 4. There is no MCI driver for the ea3131, yet!
+
ARM/EA3131-specific Configuration Options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/nuttx/configs/ea3131/pgnsh/defconfig b/nuttx/configs/ea3131/pgnsh/defconfig
index 8f5082eea..caf5a447f 100755
--- a/nuttx/configs/ea3131/pgnsh/defconfig
+++ b/nuttx/configs/ea3131/pgnsh/defconfig
@@ -405,6 +405,25 @@ CONFIG_SIG_SIGWORK=4
# page table entry to use for the vector mapping.
# CONFIG_PAGING_VECL2VADDR - This is the virtual address of the L2
# page table entry to use for the vector mapping.
+# CONFIG_PAGING_BINPATH - If CONFIG_PAGING_BINPATH is defined, then it
+# is the full path to a file on a mounted file system that contains
+# a binary image of the NuttX executable. Pages will be filled by
+# reading from offsets into this file that correspond to virtual
+# fault addresses.
+# CONFIG_PAGING_MOUNTPT - If CONFIG_PAGING_BINPATH is defined, additional
+# options may be provided to control the initialization of underlying
+# devices. CONFIG_PAGING_MOUNTPT identifies the mountpoint to be used
+# if a device is mounted.
+# CONFIG_PAGING_MINOR - Some mount operations require a "minor" number
+# to identify the specific device instance. Default: 0
+# CONFIG_PAGING_SDSLOT - If CONFIG_PAGING_BINPATH is defined, additional
+# options may be provided to control the initialization of underlying
+# devices. CONFIG_PAGING_SDSLOT identifies the slot number of the SD
+# device to initialize. This must be undefined if SD is not being used.
+# This should be defined to be zero for the typical device that has
+# only a single slot (See CONFIG_MMCSD_NSLOTS). If defined,
+# CONFIG_PAGING_SDSLOT will instruct certain board-specific logic to
+# initialize the media in this SD slot.
#
CONFIG_PAGING=y
CONFIG_PAGING_PAGESIZE=1024
@@ -422,6 +441,10 @@ CONFIG_PAGING_BLOCKINGFILL=y
#CONFIG_PAGING_VECPPAGE
#CONFIG_PAGING_VECL2PADDR
#CONFIG_PAGING_VECL2VADDR
+#CONFIG_PAGING_BINPATH="/mnt/pgsrc/nuttx.bin"
+CONFIG_PAGING_MOUNTPT="/mnt/pgsrc"
+CONFIG_PAGING_MINOR=0
+CONFIG_PAGING_SDSLOT=0
#
# The following can be used to disable categories of
diff --git a/nuttx/configs/ea3131/src/up_fillpage.c b/nuttx/configs/ea3131/src/up_fillpage.c
index 55c378152..716101693 100755
--- a/nuttx/configs/ea3131/src/up_fillpage.c
+++ b/nuttx/configs/ea3131/src/up_fillpage.c
@@ -53,12 +53,75 @@
# include <stdbool.h>
# include <unistd.h>
# include <fcntl.h>
+# ifdef CONFIG_PAGING_SDSLOT
+# include <stdio.h>
+# include <sys/mount.h>
+# include <nuttx/sdio.h>
+# include <nuttx/mmcsd.h>
+# include "lpc313x_internal.h"
+# endif
#endif
/****************************************************************************
* Definitions
****************************************************************************/
+/* Configuration ************************************************************/
+
+/* SD SLOT number might depend on the board configuration */
+
+#ifdef CONFIG_ARCH_BOARD_EA3131
+# define HAVE_SD 1
+# if defined(CONFIG_PAGING_SDSLOT) && CONFIG_PAGING_SDSLOT != 0
+# error "Only one SD slot"
+# undef CONFIG_PAGING_SDSLOT
+# endif
+#else
+ /* Add configuration for new LPC313X boards here */
+# error "Unrecognized LPC313X board"
+# undef CONFIG_PAGING_SDSLOT
+# undef HAVE_SD
+#endif
+
+/* Are we accessing the page source data through a file path? */
+
+#ifdef CONFIG_PAGING_BINPATH
+
+ /* Can't support SD if the board does not support SD (duh) */
+
+# if defined(CONFIG_PAGING_SDSLOT) && !defined(HAVE_SD)
+# error "This board does not support SD"
+# undef CONFIG_PAGING_SDSLOT
+# endif
+
+ /* Can't support SD if mountpoints are disabled or if SDIO support
+ * is not enabled.
+ */
+
+# if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_LPC313X_MCI)
+# ifdef CONFIG_PAGING_SDSLOT
+# error "Mountpoints and/or MCI disabled"
+# endif
+# undef CONFIG_PAGING_SDSLOT
+# undef HAVE_SD
+# endif
+
+ /* A mountpoint for the FAT file system must be provided */
+
+# if !defined(CONFIG_PAGING_MOUNTPT) && defined(CONFIG_PAGING_SDSLOT)
+# error "No CONFIG_PAGING_MOUNTPT provided"
+# undef CONFIG_PAGING_SDSLOT
+# undef HAVE_SD
+# endif
+
+ /* If no minor number is provided, default to zero */
+
+# ifndef CONFIG_PAGING_MINOR
+# define CONFIG_PAGING_MINOR 0
+# endif
+
+#endif /* CONFIG_PAGING_BINPATH */
+
/****************************************************************************
* Private Types
****************************************************************************/
@@ -84,10 +147,79 @@ static struct pg_source_s g_pgsrc;
****************************************************************************/
/****************************************************************************
+ * Name: lpc313x_initsrc()
+ *
+ * Description:
+ * Initialize the source device that will support paging.
+ * If BINPATH is defined, then it is the full path to a file on a mounted file
+ * system. In this case initialization will be deferred until the first
+ * time that up_fillpage() is called.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_PAGING_BINPATH
+static inline void lpc313x_initsrc(void)
+{
+#ifdef CONFIG_PAGING_SDSLOT
+ FAR struct sdio_dev_s *sdio;
+ int ret;
+#endif
+
+ /* Are we already initialized? */
+
+ if (!g_pgsrc.initialized)
+ {
+#ifdef CONFIG_PAGING_SDSLOT
+ char devname[16];
+#endif
+
+ pgvdbg("Initializing %s\n", CONFIG_PAGING_BINPATH);
+
+ /* No, do we need to mount an SD device? */
+
+#ifdef CONFIG_PAGING_SDSLOT
+
+ /* Yes.. First, get an instance of the SDIO interface */
+
+ sdio = sdio_initialize(CONFIG_PAGING_SDSLOT);
+ DEBUGASSERT(sdio != NULL);
+
+ /* Then bind the SDIO interface to the SD driver */
+
+ ret = mmcsd_slotinitialize(CONFIG_PAGING_MINOR, sdio);
+ DEBUGASSERT(ret == OK);
+
+ /* Then let's guess and say that there is a card in the slot.
+ * (We are basically jodido anyway if there is no card in the slot).
+ */
+
+ sdio_mediachange(sdio, true);
+
+ /* Now mount the file system */
+
+ snprintf(devname, 16, "/dev/mmcsd%d", CONFIG_PAGING_MINOR);
+ ret = mount(devname, CONFIG_PAGING_MOUNTPT, "vfat", MS_RDONLY, NULL);
+ DEBUGASSERT(ret == OK);
+
+#endif /* CONFIG_PAGING_SDSLOT */
+
+ /* Open the selected path for read-only access */
+
+ g_pgsrc.fd = open(CONFIG_PAGING_BINPATH, O_RDONLY);
+ DEBUGASSERT(g_pgsrc.fd >= 0);
+ g_pgsrc.initialized = true;
+ }
+}
+
+#else /* CONFIG_PAGING_BINPATH */
+# define lpc313x_initsrc()
+#endif /* CONFIG_PAGING_BINPATH */
+
+/****************************************************************************
* Public Functions
****************************************************************************/
- /****************************************************************************
+/****************************************************************************
* Name: up_fillpage()
*
* Description:
@@ -151,24 +283,21 @@ int up_fillpage(FAR _TCB *tcb, FAR void *vpage)
off_t pos;
#endif
- pglldbg("TCB: %p vpage: %p far: %08x\n", tcb, vpage, tcb->xcp.far);
+ pgdbg("TCB: %p vpage: %p far: %08x\n", tcb, vpage, tcb->xcp.far);
DEBUGASSERT(tcb->xcp.far >= PG_PAGED_VBASE && tcb->xcp.far < PG_PAGED_VEND);
/* If BINPATH is defined, then it is the full path to a file on a mounted file
- * system. In this caseinitialization will be deferred until the first
+ * system. In this case initialization will be deferred until the first
* time that up_fillpage() is called. Are we initialized?
*/
#ifdef CONFIG_PAGING_BINPATH
- if (!g_pgsrc.initialized)
- {
- /* Open the selected path for read-only access */
+ /* Perform initialization of the paging source device (if necessary and
+ * appropriate)
+ */
- g_pgsrc.fd = open(CONFIG_PAGING_BINPATH, O_RDONLY);
- DEBUGASSERT(g_pgsrc.fd >= 0);
- g_pgsrc.initialized = true;
- }
+ lpc313x_initsrc();
/* Create an offset into the binary image that corresponds to the
* virtual address. File offset 0 corresponds to PG_LOCKED_VBASE.
@@ -201,7 +330,7 @@ int up_fillpage(FAR _TCB *tcb, FAR void *vpage)
int up_fillpage(FAR _TCB *tcb, FAR void *vpage, up_pgcallback_t pg_callback)
{
- pglldbg("TCB: %p vpage: %d far: %08x\n", tcb, vpage, tcb->xcp.far);
+ pgdbg("TCB: %p vpage: %d far: %08x\n", tcb, vpage, tcb->xcp.far);
DEBUGASSERT(tcb->xcp.far >= PG_PAGED_VBASE && tcb->xcp.far < PG_PAGED_VEND);
#ifdef CONFIG_PAGING_BINPATH