2010-08-17 21:28:51 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* configs/ea3131/src/up_fillpage.c
|
|
|
|
* arch/arm/src/board/up_fillpage.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
|
|
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
|
2010-08-18 02:35:53 +02:00
|
|
|
#include <errno.h>
|
2010-08-17 21:28:51 +02:00
|
|
|
#include <debug.h>
|
|
|
|
|
2010-08-18 02:35:53 +02:00
|
|
|
#include <nuttx/sched.h>
|
|
|
|
#include <nuttx/page.h>
|
2010-08-17 21:28:51 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_PAGING
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: up_fillpage()
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* After a page is allocated and mapped by up_allocpage(), the actual
|
|
|
|
* filling of the page with data from the non-volatile, must be performed
|
|
|
|
* by a separate call to the architecture-specific function, up_fillpage().
|
|
|
|
* This function is non-blocking, it will start an asynchronous page fill.
|
|
|
|
* The common paging logic will provide a callback function, pg_callback,
|
|
|
|
* that will be called when the page fill is finished (or an error occurs).
|
|
|
|
* This callback is assumed to occur from an interrupt level when the
|
|
|
|
* device driver completes the fill operation.
|
|
|
|
*
|
2010-09-02 01:52:38 +02:00
|
|
|
* NOTE 1: Allocating and filling a page is a two step process. up_allocpage()
|
2010-08-17 21:28:51 +02:00
|
|
|
* allocates the page, and up_fillpage() fills it with data from some non-
|
|
|
|
* volatile storage device. This distinction is made because up_allocpage()
|
|
|
|
* can probably be implemented in board-independent logic whereas up_fillpage()
|
|
|
|
* probably must be implemented as board-specific logic.
|
|
|
|
*
|
2010-09-02 01:52:38 +02:00
|
|
|
* NOTE 2: The initial mapping of vpage will be read-able, write-able,
|
|
|
|
* but non-cacheable. No special actions will be required of
|
|
|
|
* up_fillpage() in order to write into this allocated page. If the
|
|
|
|
* virtual address maps to a text region, however, this function should
|
|
|
|
* remap the region so that is is read/execute only. It should be made
|
|
|
|
* cache-able in any case.
|
|
|
|
|
2010-08-17 21:28:51 +02:00
|
|
|
* Input Parameters:
|
|
|
|
* tcb - A reference to the task control block of the task that needs to
|
|
|
|
* have a page fill. Architecture-specific logic can retrieve page
|
|
|
|
* fault information from the architecture-specific context
|
|
|
|
* information in this TCB to perform the fill.
|
|
|
|
* pg_callbck - The function to be called when the page fill is complete.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* This function will return zero (OK) if the page fill was successfully
|
|
|
|
* started (the result of the page fill is passed to the callback function
|
|
|
|
* as the result argument). A negated errno value may be returned if an
|
|
|
|
* error occurs. All errors, however, are fatal.
|
|
|
|
*
|
|
|
|
* NOTE: -EBUSY has a special meaning. It is used internally to mean that
|
|
|
|
* the callback function has not executed. Therefore, -EBUSY should
|
|
|
|
* never be provided in the result argument of pg_callback.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* - This function is called from the normal tasking context (but
|
|
|
|
* interrupts siabled). The implementation must take whatever actions
|
|
|
|
* are necessary to assure that the operation is safe within this context.
|
|
|
|
* - Upon return, the caller will sleep waiting for the page fill callback
|
|
|
|
* to occur. The callback function will perform the wakeup.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_PAGING_BLOCKINGFILL
|
|
|
|
int up_fillpage(FAR _TCB *tcb, FAR void *vpage)
|
|
|
|
{
|
2010-08-31 04:21:12 +02:00
|
|
|
pglldbg("TCB: %p vpage: %d far: %08x\n", tcb, vpage, tcb->xcp.far);
|
2010-08-17 21:28:51 +02:00
|
|
|
# warning "Not implemented"
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
int up_fillpage(FAR _TCB *tcb, FAR void *vpage, up_pgcallback_t pg_callback)
|
|
|
|
{
|
2010-08-31 04:21:12 +02:00
|
|
|
pglldbg("TCB: %p vpage: %d far: %08x\n", tcb, vpage, tcb->xcp.far);
|
2010-08-17 21:28:51 +02:00
|
|
|
# warning "Not implemented"
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* CONFIG_PAGING */
|