From e88d94ffdc7cede81da4da9d87c8f89fdd02db64 Mon Sep 17 00:00:00 2001
From: patacongo
- 1The
-
-filename must be the full, absolute path to the file to be executed unless CONFIG_BINFMT_EXEPATH is defined.
- In that case, filename may be a relative path;
- a set of candidate absolute paths will be generated using the PATH environment variable and load_module() will attempt to load each file that is found at those absolute paths.
-
+ 1The filename must be the full, absolute path to the file to be executed unless CONFIG_BINFMT_EXEPATH is defined.
+ In that case, filename may be a relative path;
+ a set of candidate absolute paths will be generated using the PATH environment variable and load_module() will attempt to load each file that is found at those absolute paths.
+
Where the types binfmt_ctor_t and binfmt_dtor_t define the type of one C++ constructor or destructor:
diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html
index 5361a28665e..526892d3ef9 100644
--- a/Documentation/NuttxPortingGuide.html
+++ b/Documentation/NuttxPortingGuide.html
@@ -12,7 +12,7 @@
Last Updated: December 17, 2012
+Last Updated: December 18, 2012
@@ -92,7 +92,8 @@ 4.1.17up_enable_irq()up_prioritize_irq()
4.1.19 up_putc()
- 4.1.20 System Time and Clock
+ 4.1.20 System Time and Clockmake.
is defined.
-Inputs:
+Input Parameters:
tcb: The TCB of new task.
@@ -1658,7 +1659,7 @@ The system can be re-made subsequently by just typing make.
is defined.
-Inputs:
+Input Parameters:
tcb: The TCB of new task.
@@ -1694,7 +1695,7 @@ The system can be re-made subsequently by just typing make.
function is called.
-Inputs: +
Input Parameters:
tcb: Refers to the tcb to be unblocked. This tcb is
in one of the waiting tasks lists. It must be moved to
@@ -1715,7 +1716,7 @@ The system can be re-made subsequently by just typing make.
logic. Interrupts will always be disabled when this
function is called.
-Inputs:
+Input Parameters:
tcb: Refers to a task in the ready-to-run list (normally
the task at the head of the list). It most be
@@ -1771,7 +1772,7 @@ The system can be re-made subsequently by just typing make.
function is called.
-Inputs:
+Input Parameters:
tcb: The TCB of the task that has been reprioritized
@@ -2110,6 +2111,236 @@ else
To retrieve that variable use:
+
+ CPUs that support memory management units (MMUs) may provide address environments within which tasks and their child threads execute.
+ The configuration indicates the CPUs ability to support address environments by setting the configuration varabile CONFIG_ADDRENV=y.
+ These address environments are created only when tasks are created via exec() or exec_module() (see include/nuttx/binfmt/binfmt.h).
+
+ When CONFIG_ADDRENV=y is set in the board configuration, the CPU-specific logic must provide a set of interfaces as defined in the header file include/nuttx/arch.h.
+ These interfaces are listed below and described in detail in the following paragraphs.
+
+ The CPU-specific logic must provide two categories in interfaces: +
+
+ Binary Loader Support.
+ These are low-level interfaces used in binfmt/ to instantiate tasks with address environments.
+ These interfaces all operate on type task_addrenv_t which is an abstract representation of a asks's address environment and must be defined in arch/arch.h if CONFIG_ADDRENVM is defined.
+ These low-level interfaces include:
+
up_addrenv_create():
+ Create an address environment.
+ up_addrenv_vaddr():
+ Returns the virtual base address of the address environment.
+ up_addrenv_select():
+ Instantiate an address environment.
+ up_addrenv_restore():
+ Restore an address environment.
+ up_addrenv_destroy():
+ Destroy an address environment.
+ up_addrenv_assign():
+ Assign an address environment to a TCB.
+
+ Tasking Support.
+ Other interfaces must be provided to support higher-level interfaces used by the NuttX tasking logic.
+ These interfaces are* used by the functions in sched/ and all operate on the TCB which as been assigned an address environment by up_addrenv_assign().
+
up_addrenv_share():
+ Clone the address environment assigned to one TCB to another.
+ This operation is done when a pthread is created that share's the same address environment.
+ up_addrenv_release():
+ ARelease the TCBs reference to an address environment when a task/thread exits.
+ up_addrenv_create()Prototype:
+int up_addrenv_create(size_t envsize, FAR task_addrenv_t *addrenv);
+Description:
+up_addrenv_create() is essentially the allocator of the physical memory for the new task.
+Input Parameters:
+envsize: The size (in bytes) of the address environment needed by the task.addrenv: The location to return the representation of the task address environment.Returned Value:
+OK) on success; a negated errno value on failure.
+up_addrenv_vaddr()Prototype:
+
int up_addrenv_vaddr(FAR task_addrenv_t addrenv, FAR void **vaddr);
+Description:
+Input Parameters:
+addrenv: The representation of the task address environment previously returned by up_addrenv_create.vaddr: The location to return the virtual address.Returned Value:
+OK) on success; a negated errno value on failure.
+up_addrenv_select()Prototype:
+
int up_addrenv_select(task_addrenv_t addrenv, hw_addrenv_t *oldenv);
+Description:
+up_addrenv_create()), this function may be called to to instantiate that address environment in the virtual address space.
+ This might be necessary, for example, to load the code for the task from a file or to access address environment private data.
+Input Parameters:
+addrenv: The representation of the task address environment previously returned by up_addrenv_create.oldenv:
+ The address environment that was in place before up_addrenv_select() was called.
+ This may be used with up_addrenv_restore() to restore the original address environment that was in place before up_addrenv_select() was called.
+ Note that this may be a task agnostic, hardware representation that is different from task_addrenv_t.
+ Returned Value:
+OK) on success; a negated errno value on failure.
+up_addrenv_restore()Prototype:
+
int up_addrenv_restore(hw_addrenv_t oldenv);
+Description:
+up_addrenv_select,
+ this function may be called to to restore the original address environment.
+Input Parameters:
+oldenv: The hardware representation of the address environment previously returned by up_addrenv_select().Returned Value:
+OK) on success; a negated errno value on failure.
+up_addrenv_destroy()Prototype:
+
int up_addrenv_destroy(task_addrenv_t addrenv);
+Description:
+up_addrenv_create().
+Input Parameters:
+addrenv: The representation of the task address environment previously returned by up_addrenv_create.Returned Value:
+OK) on success; a negated errno value on failure.
+up_addrenv_assign()Prototype:
+
int up_addrenv_assign(task_addrenv_t addrenv, FAR _TCB *tcb);
+Description:
+Input Parameters:
+addrenv: The representation of the task address environment previously returned by up_addrenv_create.tcb: The TCB of the task to receive the address environment.Returned Value:
+OK) on success; a negated errno value on failure.
+up_addrenv_share()Prototype:
+
int up_addrenv_share(FAR const _TCB *ptcb, FAR _TCB *ctcb);
+Description:
+Input Parameters:
+ptcb: The TCB of the parent task that has the address environment.ctcb: The TCB of the child thread needing the address environment.Returned Value:
+OK) on success; a negated errno value on failure.
+up_addrenv_release()Prototype:
+
int up_addrenv_release(FAR _TCB *tcb);
+Description:
+Input Parameters:
+tcb: The TCB of the task or thread whose the address environment will be released.Returned Value:
+OK) on success; a negated errno value on failure.
+
These are standard interfaces that are exported by the OS
@@ -3470,7 +3701,7 @@ extern void up_ledoff(int led);
All PM interfaces are declared in the file include/nuttx/power/pm.h.
pm_initialize()Function Prototype:
#include <nuttx/power/pm.h> @@ -3487,7 +3718,7 @@ None None -6.4.2.2 pm_register()
+6.4.2.2
pm_register()Function Prototype:
#include <nuttx/power/pm.h> @@ -3507,7 +3738,7 @@ int pm_register(FAR struct pm_callback_s *callbacks); Zero (OK) on success; otherwise a negatererrnovalue is returned. -6.4.2.3 pm_activity()
+6.4.2.3
pm_activity()Function Prototype:
#include <nuttx/power/pm.h> @@ -3534,7 +3765,7 @@ void pm_activity(int priority); This function may be called from an interrupt handler (this is the ONLY PM function that may be called from an interrupt handler!). -6.4.2.4 pm_checkstate()
+6.4.2.4
pm_checkstate()Function Prototype:
#include <nuttx/power/pm.h> @@ -3561,7 +3792,7 @@ enum pm_state_e pm_checkstate(void); The recommended power management state. -6.4.2.5 pm_changestate()
+6.4.2.5
pm_changestate()Function Prototype:
#include <nuttx/power/pm.h> @@ -3596,7 +3827,7 @@ enum pm_state_e pm_checkstate(void); These callback functions can be used to provide power management information to the driver. -6.4.3.1 prepare()
+6.4.3.1
prepare()Function Prototype:
int (*prepare)(FAR struct pm_callback_s *cb, enum pm_state_e pmstate);
@@ -3624,7 +3855,7 @@ int (*prepare)(FAR struct pm_callback_s *cb, enum pm_state_e pmstate);
consumption modes!
-6.4.3.1 notify()
+6.4.3.1 notify()
Function Prototype:
#include <nuttx/power/pm.h> diff --git a/arch/z80/include/z180/arch.h b/arch/z80/include/z180/arch.h index 9e219752223..d7cf82a268d 100644 --- a/arch/z80/include/z180/arch.h +++ b/arch/z80/include/z180/arch.h @@ -45,6 +45,12 @@ * Included Files ****************************************************************************/ +#include+ +#include + +#include + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -52,6 +58,23 @@ /**************************************************************************** * Public Types ****************************************************************************/ +/* The z180 address environment is represented in hardware as the 8-bit + * Common Base Register (CBR). CBR specifies the base address (on 4KB + * boundaries) used to generate a 20-bit physical address for Common Area 1 + * accesses. CBR is the upper 8-bits of the 20-bit address; the lower 14-bits + * of the base address are implicitly zero (hence the 4KB boundary alignment). + */ + +#ifdef CONFIG_ADDRENV +typedef uint8_t hw_addrenv_t; + +/* At the task-level, the z180 address environment is represented as struct + * z180_cbr_s which is defined in irq.h. + */ + +struct z180_cbr_s; +typedef FAR struct z180_cbr_s *task_addrenv_t; +#endif /**************************************************************************** * Public Variables diff --git a/arch/z80/src/z180/z180_mmu.c b/arch/z80/src/z180/z180_mmu.c index e24b22b8e1a..5f9b26be2bf 100644 --- a/arch/z80/src/z180/z180_mmu.c +++ b/arch/z80/src/z180/z180_mmu.c @@ -79,7 +79,7 @@ static struct z180_cbr_s g_cbrs[CONFIG_MAX_TASKS]; ****************************************************************************/ /**************************************************************************** - * Name: z180_mmu_findcbr + * Name: z180_mmu_alloccbr * * Description: * Find an unused struture in g_cbrs (i.e., one with reference count == 0). @@ -88,7 +88,7 @@ static struct z180_cbr_s g_cbrs[CONFIG_MAX_TASKS]; * ****************************************************************************/ -static FAR struct z180_cbr_s *z180_mmu_findcbr(void) +static inline FAR struct z180_cbr_s *z180_mmu_alloccbr(void) { int i; @@ -176,25 +176,54 @@ return g_physhandle ? OK : -ENOMEM; #endif } +/**************************************************************************** + * Address Environment Interfaces + * + * Low-level interfaces used in binfmt/ to instantiate tasks with address + * environments. These interfaces all operate on task_addrenv_t which is an + * abstract representation of the address environment and must be provided + * by arch/arch.h is CONFIG_ADDRENV is defined. + * + * up_addrenv_create - Create an address environment + * up_addrenv_vaddr - Returns the virtual base address of the address + * environment + * up_addrenv_select - Instantiate an address environment + * up_addrenv_destroy - Destroy an address environment. + * up_addrenv_assign - Assign an address environment to a TCB + * + * Higher-level interfaces used by the tasking logic. These interfaces are + * used by the functions in sched/ and all operate on the TCB which as been + * assigned an address environment by up_addrenv_assign(). + * + * up_addrenv_share - Clone the address environment assigned to one TCB + * to another. This operation is done when a pthread + * is created that share's the same address + * environment. + * up_addrenv_release - Release the TCBs reference to an address + * environment when a task/thread exists. + * + ****************************************************************************/ /**************************************************************************** * Name: up_addrenv_create * * Description: * This function is called from the binary loader logic when a new - * task is created in RAM in order to instantiate an address environment for - * the task. + * task is created in order to instantiate an address environment for the + * task. up_addrenv_create is essentially the allocator of the physical + * memory for the new task. * * Input Parameters: - * tcb - The TCB of the task needing the address environment. * envsize - The size (in bytes) of the address environment needed by the * task. + * addrenv - The location to return the representation of the task address + * environment. * * Returned Value: * Zero (OK) on success; a negated errno value on failure. * ****************************************************************************/ -int up_addrenv_create(FAR _TCB *tcb, size_t envsize) +int up_addrenv_create(size_t envsize, FAR task_addrenv_t *addrenv) { FAR struct z180_cbr_s *cbr; irqstate_t flags; @@ -202,10 +231,6 @@ int up_addrenv_create(FAR _TCB *tcb, size_t envsize) unsigned int npages; int ret; - /* Make sure that there is no address environment in place on this TCB */ - - DEBUGASSERT(tcb->xcp.cbr == NULL); - /* Convert the size from bytes to numbers of pages */ npages = PHYS_ALIGNUP(envsize); @@ -225,7 +250,7 @@ int up_addrenv_create(FAR _TCB *tcb, size_t envsize) */ flags = irqsave(); - cbr = z180_mmu_findcbr(); + cbr = z180_mmu_alloccbr(); if (!cbr) { sdbg("ERROR: No free CBR structures\n"); @@ -235,7 +260,6 @@ int up_addrenv_create(FAR _TCB *tcb, size_t envsize) /* Now allocate the physical memory to back up the address environment */ - #ifdef CONFIG_GRAN_SINGLE alloc = (uintptr_t)gran_alloc(npages); #else @@ -254,9 +278,9 @@ int up_addrenv_create(FAR _TCB *tcb, size_t envsize) DEBUGASSERT(alloc <= 0xff); - cbr->cbr = alloc; - cbr->pages = npages; - tcb->xcp.cbr = cbr; + cbr->cbr = (uint8_t)alloc; + cbr->pages = (uint8_t)npages; + *addrenv = (task_addrenv_t)cbr; irqrestore(flags); return OK; @@ -269,6 +293,165 @@ errout_with_irq: return ret; } +/**************************************************************************** + * Name: up_addrenv_vaddr + * + * Description: + * Return the virtual address associated with the newly create address + * environment. This function is used by the binary loaders in order + * get an address that can be used to initialize the new task.. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * vaddr - The location to return the virtual address. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_vaddr(FAR task_addrenv_t addrenv, FAR void **vaddr) +{ + return CONFIG_Z180_COMMON1AREA_VIRTBASE; +} + +/**************************************************************************** + * Name: up_addrenv_select + * + * Description: + * After an address environment has been established for a task (via + * up_addrenv_create()), this function may be called to to instantiate + * that address environment in the virtual address space. This might be + * necessary, for example, to load the code for the task from a file or + * to access address environment private data. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * oldenv + * The address environment that was in place before up_addrenv_select(). + * This may be used with up_addrenv_restore() to restore the original + * address environment that was in place before up_addrenv_select() was + * called. Note that this may be a task agnostic, hardware + * representation that is different from task_addrenv_t. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_select(task_addrenv_t addrenv, hw_addrenv_t *oldenv) +{ + FAR struct z180_cbr_s *cbr = (FAR struct z180_cbr_s *)addrenv; + irqstate_t flags; + + DEBUGASSERT(cbr && oldenv); + + /* Return the current CBR value from the CBR register */ + + flags = irqsave(); + *oldenv = (hw_addrenv_t)inp(Z180_MMU_CBR); + + /* Write the new CBR value into CBR register */ + + outp(Z180_MMU_CBR, cbr->cbr); + irqrestore(flags); + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_restore + * + * Description: + * After an address environment has been temporarilty instantiated by + * up_addrenv_select, this function may be called to to restore the + * original address environment. + * + * Input Parameters: + * oldenv - The hardware representation of the address environment + * previously returned by up_addrenv_select. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_restore(hw_addrenv_t oldenv) +{ + outp(Z180_MMU_CBR, (uint8_t)oldenv); + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_destroy + * + * Description: + * Called from the binary loader loader during error handling to destroy + * the address environment previously created by up_addrenv_create(). + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_destroy(task_addrenv_t addrenv) +{ + FAR struct z180_cbr_s *cbr = (FAR struct z180_cbr_s *)addrenv; + + DEBUGASSERT(cbr); + + /* Free the physical address space backing up the mapping */ + +#ifdef CONFIG_GRAN_SINGLE + gran_free((FAR void *)cbr->cbr, cbr->pages); +#else + gran_free(g_physhandle, (FAR void *)cbr->cbr, cbr->pages); +#endif + + /* And make the CBR structure available for re-use */ + + z180_mmu_freecbr(cbr); + return OK; +} + +/**************************************************************************** + * Name: up_addrenv_assign + * + * Description: + * Assign an address environment to a TCB. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * tcb - The TCB of the task to receive the address environment. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int up_addrenv_assign(task_addrenv_t addrenv, FAR _TCB *tcb) +{ + FAR struct z180_cbr_s *cbr = (FAR struct z180_cbr_s *)addrenv; + int ret; + + /* Make sure that there is no address environment in place on this TCB */ + + DEBUGASSERT(cbr && tcb->xcp.cbr == NULL); + + /* Save the CBR strucure in the TCB. This is an atomic operation so no + * special precautions should be needed. + */ + + tcb->xcp.cbr = cbr; + return OK; +} + /**************************************************************************** * Name: up_addrenv_share * @@ -312,72 +495,6 @@ int up_addrenv_share(FAR const _TCB *ptcb, FAR _TCB *ctcb) return OK; } -/**************************************************************************** - * Name: up_addrenv_instantiate - * - * Description: - * After an address environment has been established for a task (via - * up_addrenv_create(). This function may be called to to instantiate - * that address environment in the virtual address space. this might be - * necessary, for example, to load the code for the task from a file or - * to access address environment private data. - * - * Input Parameters: - * tcb - The TCB of the task or thread whose the address environment will - * be instantiated. - * - * Returned Value: - * A handle that may be used with up_addrenv_restore() to restore the - * address environment before up_addrenv_instantiate() was called. - * - ****************************************************************************/ - -FAR void *up_addrenv_instantiate(FAR _TCB *tcb) -{ - uint8_t oldcbr; - irqstate_t flags; - - /* Get the current CBR value from the CBR register */ - - flags = irqsave(); - oldcbr = inp(Z180_MMU_CBR); - - /* Check if the task has an address environment. */ - - if (tcb->xcp.cbr) - { - /* Yes.. Write the new CBR value into CBR register */ - - outp(Z180_MMU_CBR, tcb->xcp.cbr->cbr); - } - - irqrestore(flags); - return (FAR void *)oldcbr; -} - -/**************************************************************************** - * Name: up_addrenv_restore - * - * Description: - * Restore an address environment using a handle previously returned by - * up_addrenv_instantiate(). - * - * Input Parameters: - * handle - A handle previously returned by up_addrenv_instantiate. - * - * Returned Value: - * Zero (OK) on success; a negated errno value on failure. - * - ****************************************************************************/ - -int up_addrenv_restore(FAR void *handle) -{ - /* Restore the CBR value */ - - outp(Z180_MMU_CBR, (uint8_t)handle); - return OK; -} - /**************************************************************************** * Name: up_addrenv_release * @@ -407,7 +524,7 @@ int up_addrenv_release(FAR _TCB *tcb) cbr = tcb->xcp.cbr; if (cbr) { - /* Nullify the reference to the CBR structgure and decrement the number + /* Nullify the reference to the CBR structure and decrement the number * of references on the CBR. */ @@ -419,7 +536,7 @@ int up_addrenv_release(FAR _TCB *tcb) if (cbr->crefs <= 1) { - z180_mmu_freecbr(cbr); + up_addrenv_destroy(cbr); } else { diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 7c444602eb4..8b4b10ade9e 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -46,6 +46,7 @@ #include #include #include + #include /**************************************************************************** @@ -380,18 +381,48 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size); # define up_getpicbase(ppicbase) #endif +/**************************************************************************** + * Address Environment Interfaces + * + * Low-level interfaces used in binfmt/ to instantiate tasks with address + * environments. These interfaces all operate on type task_addrenv_t which + * is an abstract representation of a task's address environment and must be + * defined in arch/arch.h if CONFIG_ADDRENV is defined. + * + * up_addrenv_create - Create an address environment + * up_addrenv_vaddr - Returns the virtual base address of the address + * environment + * up_addrenv_select - Instantiate an address environment + * up_addrenv_restore - Restore an address environment + * up_addrenv_destroy - Destroy an address environment. + * up_addrenv_assign - Assign an address environment to a TCB + * + * Higher-level interfaces used by the tasking logic. These interfaces are + * used by the functions in sched/ and all operate on the TCB which as been + * assigned an address environment by up_addrenv_assign(). + * + * up_addrenv_share - Clone the address environment assigned to one TCB + * to another. This operation is done when a pthread + * is created that share's the same address + * environment. + * up_addrenv_release - Release the TCBs reference to an address + * environment when a task/thread exits. + * + ****************************************************************************/ /**************************************************************************** * Name: up_addrenv_create * * Description: * This function is called from the binary loader logic when a new - * task is created in RAM in order to instantiate an address environment for - * the task. + * task is created in order to instantiate an address environment for the + * task. up_addrenv_create is essentially the allocator of the physical + * memory for the new task. * * Input Parameters: - * tcb - The TCB of the task needing the address environment. * envsize - The size (in bytes) of the address environment needed by the * task. + * addrenv - The location to return the representation of the task address + * environment. * * Returned Value: * Zero (OK) on success; a negated errno value on failure. @@ -399,7 +430,119 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size); ****************************************************************************/ #ifdef CONFIG_ADDRENV -int up_addrenv_create(FAR _TCB *tcb, size_t envsize); +int up_addrenv_create(size_t envsize, FAR task_addrenv_t *addrenv); +#endif + +/**************************************************************************** + * Name: up_addrenv_vaddr + * + * Description: + * Return the virtual address associated with the newly create address + * environment. This function is used by the binary loaders in order + * get an address that can be used to initialize the new task. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * vaddr - The location to return the virtual address. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ADDRENV +int up_addrenv_vaddr(FAR task_addrenv_t addrenv, FAR void **vaddr); +#endif + +/**************************************************************************** + * Name: up_addrenv_select + * + * Description: + * After an address environment has been established for a task (via + * up_addrenv_create(). This function may be called to to instantiate + * that address environment in the virtual address space. this might be + * necessary, for example, to load the code for the task from a file or + * to access address environment private data. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * oldenv + * The address environment that was in place before up_addrenv_select(). + * This may be used with up_addrenv_restore() to restore the original + * address environment that was in place before up_addrenv_select() was + * called. Note that this may be a task agnostic, hardware + * representation that is different from task_addrenv_t. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ADDRENV +int up_addrenv_select(task_addrenv_t addrenv, hw_addrenv_t *oldenv); +#endif + +/**************************************************************************** + * Name: up_addrenv_restore + * + * Description: + * After an address environment has been temporarilty instantiated by + * up_addrenv_select, this function may be called to to restore the + * original address environment. + * + * Input Parameters: + * oldenv - The hardware representation of the address environment + * previously returned by up_addrenv_select. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ADDRENV +int up_addrenv_restore(hw_addrenv_t oldenv); +#endif + +/**************************************************************************** + * Name: up_addrenv_destroy + * + * Description: + * Called from the binary loader loader during error handling to destroy + * the address environment previously created by up_addrenv_create(). + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ADDRENV +int up_addrenv_destroy(task_addrenv_t addrenv); +#endif + +/**************************************************************************** + * Name: up_addrenv_assign + * + * Description: + * Assign an address environment to a TCB. + * + * Input Parameters: + * addrenv - The representation of the task address environment previously + * returned by up_addrenv_create. + * tcb - The TCB of the task to receive the address environment. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ADDRENV +int up_addrenv_assign(task_addrenv_t addrenv, FAR _TCB *tcb); #endif /**************************************************************************** @@ -424,49 +567,6 @@ int up_addrenv_create(FAR _TCB *tcb, size_t envsize); int up_addrenv_share(FAR const _TCB *ptcb, FAR _TCB *ctcb); #endif -/**************************************************************************** - * Name: up_addrenv_instantiate - * - * Description: - * After an address environment has been established for a task (via - * up_addrenv_create(). This function may be called to to instantiate - * that address environment in the virtual address space. this might be - * necessary, for example, to load the code for the task from a file or - * to access address environment private data. - * - * Input Parameters: - * tcb - The TCB of the task or thread whose the address environment will - * be instantiated. - * - * Returned Value: - * A handle that may be used with up_addrenv_restore() to restore the - * address environment before up_addrenv_instantiate() was called. - * - ****************************************************************************/ - -#ifdef CONFIG_ADDRENV -FAR void *up_addrenv_instantiate(FAR _TCB *tcb); -#endif - -/**************************************************************************** - * Name: up_addrenv_restore - * - * Description: - * Restore an address environment using a handle previously returned by - * up_addrenv_instantiate(). - * - * Input Parameters: - * handle - A handle previously returned by up_addrenv_instantiate. - * - * Returned Value: - * Zero (OK) on success; a negated errno value on failure. - * - ****************************************************************************/ - -#ifdef CONFIG_ADDRENV -int up_addrenv_restore(FAR void *handle); -#endif - /**************************************************************************** * Name: up_addrenv_release * diff --git a/include/nuttx/binfmt/binfmt.h b/include/nuttx/binfmt/binfmt.h index 200823bb843..2e2c6dda8a9 100644 --- a/include/nuttx/binfmt/binfmt.h +++ b/include/nuttx/binfmt/binfmt.h @@ -69,7 +69,7 @@ typedef FAR void (*binfmt_dtor_t)(void); /* This describes the file to be loaded. * - * NOTE: The 'filename' must be the full, absolute path to the file to be + * NOTE 1: The 'filename' must be the full, absolute path to the file to be * executed unless CONFIG_BINFMT_EXEPATH is defined. In that case, * 'filename' may be a relative path; a set of candidate absolute paths * will be generated using the PATH environment variable and load_module() @@ -81,7 +81,7 @@ struct binary_s { /* Information provided to the loader to load and bind a module */ - FAR const char *filename; /* Full path to the binary to be loaded (See NOTE above) */ + FAR const char *filename; /* Full path to the binary to be loaded (See NOTE 1 above) */ FAR const char **argv; /* Argument list */ FAR const struct symtab_s *exports; /* Table of exported symbols */ int nexports; /* The number of symbols in exports[] */