mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Implement SD-based paging for EA3131
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2931 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -1266,3 +1266,11 @@
|
|||||||
data and prefectch aborts which are within this zeroed region.
|
data and prefectch aborts which are within this zeroed region.
|
||||||
|
|
||||||
5.11 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
5.11 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
|
||||||
|
* configs/ea3131/src/up_fillpage.c - Added new configuration item
|
||||||
|
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. up_fillpage.c implements logic to perform page
|
||||||
|
files using the CONFIG_PAGING_BINPATH file.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<tr align="center" bgcolor="#e4e4e4">
|
<tr align="center" bgcolor="#e4e4e4">
|
||||||
<td>
|
<td>
|
||||||
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
||||||
<p>Last Updated: September 7, 2010</p>
|
<p>Last Updated: September 8, 2010</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -1950,6 +1950,14 @@ buildroot-1.8 2009-12-21 <spudmonkey@racsa.co.cr>
|
|||||||
<ul><pre>
|
<ul><pre>
|
||||||
nuttx-5.11 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
nuttx-5.11 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
|
||||||
|
* configs/ea3131/src/up_fillpage.c - Added new configuration item
|
||||||
|
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. up_fillpage.c implements logic to perform page
|
||||||
|
files using the CONFIG_PAGING_BINPATH file.
|
||||||
|
|
||||||
pascal-2.1 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
pascal-2.1 2010-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
|
||||||
buildroot-1.9 2010-xx-xx <spudmonkey@racsa.co.cr>
|
buildroot-1.9 2010-xx-xx <spudmonkey@racsa.co.cr>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<h1><big><font color="#3c34ec">
|
<h1><big><font color="#3c34ec">
|
||||||
<i>NuttX RTOS Porting Guide</i>
|
<i>NuttX RTOS Porting Guide</i>
|
||||||
</font></big></h1>
|
</font></big></h1>
|
||||||
<p>Last Updated: August 29, 2010</p>
|
<p>Last Updated: September 8, 2010</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -2294,6 +2294,7 @@ build
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h2>General OS setup</h2>
|
<h2>General OS setup</h2>
|
||||||
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<code>CONFIG_DEBUG</code>: enables built-in debug options
|
<code>CONFIG_DEBUG</code>: enables built-in debug options
|
||||||
</li>
|
</li>
|
||||||
@@ -2569,6 +2570,11 @@ build
|
|||||||
<code>CONFIG_PAGING_VECL2VADDR</code>:
|
<code>CONFIG_PAGING_VECL2VADDR</code>:
|
||||||
This is the virtual address of the L2 page table entry to use for the vector mapping.
|
This is the virtual address of the L2 page table entry to use for the vector mapping.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<code>CONFIG_PAGING_BINPATH</code>:
|
||||||
|
If <code>CONFIG_PAGING_BINPATH</code> 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.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
The following can be used to disable categories of APIs supported
|
The following can be used to disable categories of APIs supported
|
||||||
|
|||||||
@@ -401,6 +401,11 @@ defconfig -- This is a configuration file similar to the Linux
|
|||||||
page table entry to use for the vector mapping.
|
page table entry to use for the vector mapping.
|
||||||
CONFIG_PAGING_VECL2VADDR - This is the virtual address of the L2
|
CONFIG_PAGING_VECL2VADDR - This is the virtual address of the L2
|
||||||
page table entry to use for the vector mapping.
|
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.
|
||||||
|
|
||||||
The following can be used to disable categories of APIs supported
|
The following can be used to disable categories of APIs supported
|
||||||
by the OS. If the compiler supports weak functions, then it
|
by the OS. If the compiler supports weak functions, then it
|
||||||
|
|||||||
@@ -416,8 +416,41 @@ On-Demand Paging
|
|||||||
The references and issues related to this are discussed in (2)
|
The references and issues related to this are discussed in (2)
|
||||||
and (3) above.
|
and (3) above.
|
||||||
|
|
||||||
|
Alternative:
|
||||||
|
------------
|
||||||
|
|
||||||
|
I have implemented an alternative within configs/ea3131/src/up_fillpage.c
|
||||||
|
which is probably only useful for testing. Here is the usage module
|
||||||
|
for this alternative
|
||||||
|
|
||||||
|
1. Place the nuttx.bin file on an SD card.
|
||||||
|
2. Insert the SD card prior to booting
|
||||||
|
3. In up_fillpage(), use the virtual miss address (minus the virtual
|
||||||
|
base address) as an offset into the nuttx.bin file, and read the
|
||||||
|
required page from that offset in the nuttx.bin file:
|
||||||
|
|
||||||
|
off_t offset = (off_t)vpage - PG_LOCKED_VBASE;
|
||||||
|
off_t pos = lseek(fd, offset, SEEK_SET);
|
||||||
|
if (pos != (off_t)-1)
|
||||||
|
{
|
||||||
|
int ret = read(fd, vpage, PAGESIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
In this way, the paging implementation can do on-demand paging
|
||||||
|
from an image file on the SD card. Problems/issues with this
|
||||||
|
approach probably make it only useful for testing:
|
||||||
|
|
||||||
|
1. You would still have to boot the locked section over serial or
|
||||||
|
using a bootloader -- it is not clear how the power up boot
|
||||||
|
would occur. For testing, the nuttx.bin file could be both
|
||||||
|
provided on the SD card and loaded over serial.
|
||||||
|
2. If the SD card is not in place, the system will crash.
|
||||||
|
3. This means that all of the file system logic and FAT file
|
||||||
|
system would have to reside in the locked text region.
|
||||||
|
|
||||||
ARM/EA3131-specific Configuration Options
|
ARM/EA3131-specific Configuration Options
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
CONFIG_ARCH - Identifies the arch/ subdirectory. This should
|
CONFIG_ARCH - Identifies the arch/ subdirectory. This should
|
||||||
be set to:
|
be set to:
|
||||||
|
|
||||||
@@ -500,7 +533,7 @@ ARM/EA3131-specific Configuration Options
|
|||||||
|
|
||||||
CONFIG_LPC313X_MCI, CONFIG_LPC313X_SPI, CONFIG_LPC313X_UART
|
CONFIG_LPC313X_MCI, CONFIG_LPC313X_SPI, CONFIG_LPC313X_UART
|
||||||
|
|
||||||
xernal memory available on the board (see also CONFIG_MM_REGIONS)
|
External memory available on the board (see also CONFIG_MM_REGIONS)
|
||||||
|
|
||||||
CONFIG_LPC313X_EXTSRAM0 - Select if external SRAM0 is present
|
CONFIG_LPC313X_EXTSRAM0 - Select if external SRAM0 is present
|
||||||
CONFIG_LPC313X_EXTSRAM0HEAP - Select if external SRAM0 should be
|
CONFIG_LPC313X_EXTSRAM0HEAP - Select if external SRAM0 should be
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ function checkzero () {
|
|||||||
echo "n"
|
echo "n"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
# Interrupt Handlers
|
# Interrupt Handlers
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|||||||
@@ -47,15 +47,38 @@
|
|||||||
#include <nuttx/page.h>
|
#include <nuttx/page.h>
|
||||||
|
|
||||||
#ifdef CONFIG_PAGING
|
#ifdef CONFIG_PAGING
|
||||||
|
#ifdef CONFIG_PAGING_BINPATH
|
||||||
|
# include <sys/stat.h>
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <stdbool.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Definitions
|
* Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PAGING_BINPATH
|
||||||
|
struct pg_source_s
|
||||||
|
{
|
||||||
|
bool initialized; /* TRUE: we are initialized */
|
||||||
|
int fd; /* File descriptor of the nuttx.bin file */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PAGING_BINPATH
|
||||||
|
static struct pg_source_s g_pgsrc;
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -117,20 +140,80 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PAGING_BLOCKINGFILL
|
#ifdef CONFIG_PAGING_BLOCKINGFILL
|
||||||
|
|
||||||
|
/* Version 1: Supports blocking fill operations */
|
||||||
|
|
||||||
int up_fillpage(FAR _TCB *tcb, FAR void *vpage)
|
int up_fillpage(FAR _TCB *tcb, FAR void *vpage)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_PAGING_BINPATH
|
||||||
|
ssize_t nbytes;
|
||||||
|
off_t offset;
|
||||||
|
off_t pos;
|
||||||
|
#endif
|
||||||
|
|
||||||
pglldbg("TCB: %p vpage: %p far: %08x\n", tcb, vpage, tcb->xcp.far);
|
pglldbg("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
|
||||||
|
* 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 */
|
||||||
|
|
||||||
|
g_pgsrc.fd = open(CONFIG_PAGING_BINPATH, O_RDONLY);
|
||||||
|
DEBUGASSERT(g_pgsrc.fd >= 0);
|
||||||
|
g_pgsrc.initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create an offset into the binary image that corresponds to the
|
||||||
|
* virtual address. File offset 0 corresponds to PG_LOCKED_VBASE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
offset = (off_t)vpage - PG_LOCKED_VBASE;
|
||||||
|
|
||||||
|
/* Seek to that position */
|
||||||
|
|
||||||
|
pos = lseek(g_pgsrc.fd, offset, SEEK_SET);
|
||||||
|
DEBUGASSERT(pos != (off_t)-1);
|
||||||
|
|
||||||
|
/* And read the page data from that offset */
|
||||||
|
|
||||||
|
nbytes = read(g_pgsrc.fd, vpage, PAGESIZE);
|
||||||
|
DEBUGASSERT(nbytes == PAGESIZE);
|
||||||
|
return OK;
|
||||||
|
|
||||||
|
#else /* CONFIG_PAGING_BINPATH */
|
||||||
|
|
||||||
# warning "Not implemented"
|
# warning "Not implemented"
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
|
|
||||||
|
#endif /* CONFIG_PAGING_BINPATH */
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
/* Version 2: Supports non-blocking, asynchronous fill operations */
|
||||||
|
|
||||||
int up_fillpage(FAR _TCB *tcb, FAR void *vpage, up_pgcallback_t pg_callback)
|
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);
|
pglldbg("TCB: %p vpage: %d far: %08x\n", tcb, vpage, tcb->xcp.far);
|
||||||
# warning "Not implemented"
|
DEBUGASSERT(tcb->xcp.far >= PG_PAGED_VBASE && tcb->xcp.far < PG_PAGED_VEND);
|
||||||
|
|
||||||
|
#ifdef CONFIG_PAGING_BINPATH
|
||||||
|
# error "File system-based paging must always be implemented with blocking calls"
|
||||||
|
#else
|
||||||
|
# warning "Not implemented"
|
||||||
|
#endif
|
||||||
|
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
#endif /* CONFIG_PAGING_BLOCKINGFILL */
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: lpc313x_pginitialize
|
* Name: lpc313x_pginitialize
|
||||||
@@ -154,6 +237,16 @@ void weak_function lpc313x_pginitialize(void)
|
|||||||
* - Do whatever else is necessary to make up_fillpage() ready for the first time
|
* - Do whatever else is necessary to make up_fillpage() ready for the first time
|
||||||
* that it is called.
|
* that it is called.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PAGING_BINPATH
|
||||||
|
/* If BINPATH is defined, then it is the full path to a file on a mounted file
|
||||||
|
* system. However, in this case, initialization will involve some higher level
|
||||||
|
* file system operations. Since this function is called from a low level (before
|
||||||
|
* os_start() is even called), it may not be possible to perform file system
|
||||||
|
* operations yet. Therefore, initialization will be deferred until the first
|
||||||
|
* time that up_fillpage() is called.
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_PAGING */
|
#endif /* CONFIG_PAGING */
|
||||||
|
|||||||
Reference in New Issue
Block a user