aboutsummaryrefslogtreecommitdiff
path: root/nuttx/include/nuttx/arch.h
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/include/nuttx/arch.h')
-rw-r--r--nuttx/include/nuttx/arch.h290
1 files changed, 259 insertions, 31 deletions
diff --git a/nuttx/include/nuttx/arch.h b/nuttx/include/nuttx/arch.h
index bf6be1ce0..8b4b10ade 100644
--- a/nuttx/include/nuttx/arch.h
+++ b/nuttx/include/nuttx/arch.h
@@ -46,6 +46,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <sched.h>
+
#include <arch/arch.h>
/****************************************************************************
@@ -67,10 +68,8 @@ typedef CODE void (*sig_deliver_t)(FAR _TCB *tcb);
****************************************************************************/
#ifdef __cplusplus
-#define EXTERN extern "C"
-extern "C" {
-#else
-#define EXTERN extern
+extern "C"
+{
#endif
/****************************************************************************
@@ -98,7 +97,7 @@ extern "C" {
*
****************************************************************************/
-EXTERN void up_initialize(void);
+void up_initialize(void);
/****************************************************************************
* Name: up_idle
@@ -114,7 +113,7 @@ EXTERN void up_initialize(void);
*
****************************************************************************/
-EXTERN void up_idle(void);
+void up_idle(void);
/****************************************************************************
* Name: up_initial_state
@@ -130,7 +129,7 @@ EXTERN void up_idle(void);
*
****************************************************************************/
-EXTERN void up_initial_state(FAR _TCB *tcb);
+void up_initial_state(FAR _TCB *tcb);
/****************************************************************************
* Name: up_create_stack
@@ -155,7 +154,7 @@ EXTERN void up_initial_state(FAR _TCB *tcb);
****************************************************************************/
#ifndef CONFIG_CUSTOM_STACK
-EXTERN int up_create_stack(FAR _TCB *tcb, size_t stack_size);
+int up_create_stack(FAR _TCB *tcb, size_t stack_size);
#endif
/****************************************************************************
@@ -180,7 +179,7 @@ EXTERN int up_create_stack(FAR _TCB *tcb, size_t stack_size);
****************************************************************************/
#ifndef CONFIG_CUSTOM_STACK
-EXTERN int up_use_stack(FAR _TCB *tcb, FAR void *stack, size_t stack_size);
+int up_use_stack(FAR _TCB *tcb, FAR void *stack, size_t stack_size);
#endif
/****************************************************************************
@@ -193,7 +192,7 @@ EXTERN int up_use_stack(FAR _TCB *tcb, FAR void *stack, size_t stack_size);
****************************************************************************/
#ifndef CONFIG_CUSTOM_STACK
-EXTERN void up_release_stack(FAR _TCB *dtcb);
+void up_release_stack(FAR _TCB *dtcb);
#endif
/****************************************************************************
@@ -216,7 +215,7 @@ EXTERN void up_release_stack(FAR _TCB *dtcb);
*
****************************************************************************/
-EXTERN void up_unblock_task(FAR _TCB *tcb);
+void up_unblock_task(FAR _TCB *tcb);
/****************************************************************************
* Name: up_block_task
@@ -242,7 +241,7 @@ EXTERN void up_unblock_task(FAR _TCB *tcb);
*
****************************************************************************/
-EXTERN void up_block_task(FAR _TCB *tcb, tstate_t task_state);
+void up_block_task(FAR _TCB *tcb, tstate_t task_state);
/****************************************************************************
* Name: up_release_pending
@@ -261,7 +260,7 @@ EXTERN void up_block_task(FAR _TCB *tcb, tstate_t task_state);
*
****************************************************************************/
-EXTERN void up_release_pending(void);
+void up_release_pending(void);
/****************************************************************************
* Name: up_reprioritize_rtr
@@ -287,7 +286,7 @@ EXTERN void up_release_pending(void);
*
****************************************************************************/
-EXTERN void up_reprioritize_rtr(FAR _TCB *tcb, uint8_t priority);
+void up_reprioritize_rtr(FAR _TCB *tcb, uint8_t priority);
/****************************************************************************
* Name: _exit
@@ -349,7 +348,7 @@ EXTERN void up_reprioritize_rtr(FAR _TCB *tcb, uint8_t priority);
****************************************************************************/
#ifndef CONFIG_DISABLE_SIGNALS
-EXTERN void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver);
+void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver);
#endif
/****************************************************************************
@@ -363,7 +362,7 @@ EXTERN void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver);
****************************************************************************/
#ifndef CONFIG_HEAP_BASE
-EXTERN void up_allocate_heap(FAR void **heap_start, size_t *heap_size);
+void up_allocate_heap(FAR void **heap_start, size_t *heap_size);
#endif
/****************************************************************************
@@ -383,6 +382,214 @@ EXTERN void up_allocate_heap(FAR void **heap_start, size_t *heap_size);
#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 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:
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ADDRENV
+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
+
+/****************************************************************************
+ * Name: up_addrenv_share
+ *
+ * Description:
+ * This function is called from the core scheduler logic when a thread
+ * is created that needs to share the address ennvironment of its parent
+ * task. In this case, the parent's address environment needs to be
+ * "cloned" for the child.
+ *
+ * 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:
+ * Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ADDRENV
+int up_addrenv_share(FAR const _TCB *ptcb, FAR _TCB *ctcb);
+#endif
+
+/****************************************************************************
+ * Name: up_addrenv_release
+ *
+ * Description:
+ * This function is called when a task or thread exits in order to release
+ * its reference to an address environment. When there are no further
+ * references to an address environment, that address environment should
+ * be destroyed.
+ *
+ * Input Parameters:
+ * tcb - The TCB of the task or thread whose the address environment will
+ * be released.
+ *
+ * Returned Value:
+ * Zero (OK) on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ADDRENV
+int up_addrenv_release(FAR _TCB *tcb);
+#endif
+
+/****************************************************************************
* Name: up_interrupt_context
*
* Description:
@@ -391,7 +598,7 @@ EXTERN void up_allocate_heap(FAR void **heap_start, size_t *heap_size);
*
****************************************************************************/
-EXTERN bool up_interrupt_context(void);
+bool up_interrupt_context(void);
/****************************************************************************
* Name: up_enable_irq
@@ -413,7 +620,7 @@ EXTERN bool up_interrupt_context(void);
****************************************************************************/
#ifndef CONFIG_ARCH_NOINTC
-EXTERN void up_enable_irq(int irq);
+void up_enable_irq(int irq);
#endif
/****************************************************************************
@@ -431,7 +638,7 @@ EXTERN void up_enable_irq(int irq);
****************************************************************************/
#ifndef CONFIG_ARCH_NOINTC
-EXTERN void up_disable_irq(int irq);
+void up_disable_irq(int irq);
#endif
/****************************************************************************
@@ -446,7 +653,7 @@ EXTERN void up_disable_irq(int irq);
****************************************************************************/
#ifdef CONFIG_ARCH_IRQPRIO
-EXTERN int up_prioritize_irq(int irq, int priority);
+int up_prioritize_irq(int irq, int priority);
#endif
/****************************************************************************
@@ -483,7 +690,7 @@ EXTERN int up_prioritize_irq(int irq, int priority);
****************************************************************************/
#ifdef CONFIG_ARCH_ROMGETC
-EXTERN char up_romgetc(FAR const char *ptr);
+char up_romgetc(FAR const char *ptr);
#else
# define up_romgetc(ptr) (*ptr)
#endif
@@ -497,8 +704,8 @@ EXTERN char up_romgetc(FAR const char *ptr);
*
***************************************************************************/
-EXTERN void up_mdelay(unsigned int milliseconds);
-EXTERN void up_udelay(useconds_t microseconds);
+void up_mdelay(unsigned int milliseconds);
+void up_udelay(useconds_t microseconds);
/****************************************************************************
* Name: up_cxxinitialize
@@ -517,7 +724,7 @@ EXTERN void up_udelay(useconds_t microseconds);
***************************************************************************/
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
-EXTERN void up_cxxinitialize(void);
+void up_cxxinitialize(void);
#endif
/****************************************************************************
@@ -537,7 +744,7 @@ EXTERN void up_cxxinitialize(void);
*
****************************************************************************/
-EXTERN void sched_process_timer(void);
+void sched_process_timer(void);
/****************************************************************************
* Name: irq_dispatch
@@ -549,7 +756,7 @@ EXTERN void sched_process_timer(void);
*
***************************************************************************/
-EXTERN void irq_dispatch(int irq, FAR void *context);
+void irq_dispatch(int irq, FAR void *context);
/****************************************************************************
* Board-specific button interfaces exported by the board-specific logic
@@ -571,7 +778,7 @@ EXTERN void irq_dispatch(int irq, FAR void *context);
****************************************************************************/
#ifdef CONFIG_ARCH_BUTTONS
-EXTERN void up_buttoninit(void);
+void up_buttoninit(void);
#endif
/****************************************************************************
@@ -592,7 +799,7 @@ EXTERN void up_buttoninit(void);
****************************************************************************/
#ifdef CONFIG_ARCH_BUTTONS
-EXTERN uint8_t up_buttons(void);
+uint8_t up_buttons(void);
#endif
/****************************************************************************
@@ -613,7 +820,29 @@ EXTERN uint8_t up_buttons(void);
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
-EXTERN xcpt_t up_irqbutton(int id, xcpt_t irqhandler);
+xcpt_t up_irqbutton(int id, xcpt_t irqhandler);
+#endif
+
+/************************************************************************************
+ * Relay control functions
+ *
+ * Description:
+ * Non-standard functions for relay control.
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_ARCH_RELAYS
+void up_relaysinit(void);
+void relays_setstat(int relays, bool stat);
+bool relays_getstat(int relays);
+void relays_setstats(uint32_t relays_stat);
+uint32_t relays_getstats(void);
+void relays_onoff(int relays, uint32_t mdelay);
+void relays_onoffs(uint32_t relays_stat, uint32_t mdelay);
+void relays_resetmode(int relays);
+void relays_powermode(int relays);
+void relays_resetmodes(uint32_t relays_stat);
+void relays_powermodes(uint32_t relays_stat);
#endif
/****************************************************************************
@@ -628,9 +857,8 @@ EXTERN xcpt_t up_irqbutton(int id, xcpt_t irqhandler);
*
****************************************************************************/
-EXTERN int up_putc(int ch);
+int up_putc(int ch);
-#undef EXTERN
#ifdef __cplusplus
}
#endif