diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index 0fbea39576..62e5702dcb 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -180,7 +180,7 @@

- The second release of NuttX (nuttx-0.1.2) is avalable for download + The third release of NuttX (nuttx-0.1.2) is avalable for download from the SourceForge website.

diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html index 1065d00977..dee837cd7b 100644 --- a/Documentation/NuttxPortingGuide.html +++ b/Documentation/NuttxPortingGuide.html @@ -11,12 +11,12 @@
-

Nuttx Operating System

+

NuttX Operating System

Porting Guide

by

Gregory Nutt

-

Last Update: February 8, 2007

+

Last Update: March 20, 2007

Table of Contents

@@ -25,6 +25,12 @@
  • 3.0 Configuring and Building
  • +
  • 4.0 Architecture APIs
  • +

    1.0 Introduction

    Overview - This document provides and overview of the Nuttx build and configuration + This document provides and overview of the NuttX build and configuration logic and provides hints for the incorporation of new processor/board archectures into the build.

    @@ -53,7 +90,7 @@

    2.0 Directory Structure

    -

    The general directly layout for Nuttx is very similar to the directory structure +

    The general directly layout for NuttX is very similar to the directory structure of the Linux kernel -- at least at the most superficial layers. At the top level is the main makefile and a series of sub-directories identified below and discussed in the following paragraphs:

    @@ -105,19 +142,834 @@ below and discussed in the following paragraphs:

    2.1 Documentation

    + +

    + General documentation for the NuttX OS resides in this directory. +

    +

    2.2 arch

    + +

    2.2.1 Subdirectory Structure

    +

    + This directory contains several sub-directories, each containing + architecture-specific logic. + The task of porting NuttX to a new processor or board consists of + add a new sudirectory under arch/ containing logic specific + to the new architecuture. + Each architecture must provide a subdirectory, <arch-name> + under arch/ with the folling characteristics: +

    + + +

    2.2.2 Summary of Files

    + + +

    2.2.3 Supported Architectures

    + +

    + Other ports for the for the TI TMS320DM270 and for MIPS are in various states + of progress +

    + +

    2.2.4 Configuring NuttX

    +

    + Configuring NuttX requires only copying: +

    +
    +

    + There is a script that automates these steps. The following steps will + accomplish the same configuration: +

    + +

    2.3 drivers

    + +

    + This directory holds architecture-independent device drivers. +

    +

    2.4 examples

    + +

    + Example and test programs to build against. +

    +

    2.5 fs

    + +

    + This directory contains the NuttX filesystem. + The NuttX filesystem is very simple; it does not involve any block drivers or + particular filesystem (like FAT or EXT2 etc.). + The NuttX filesystem simply supports a set a filesystem APIs + (open(), close(), read(), write, etc.) + and a registration mechanism that allows devices drivers to a associated with nodes + in a file-system-like name space. +

    +

    2.6 include

    +

    + This directory holds NuttX header files. + Standard header files file retained in can be included in the normal fashion: +

    + +

    2.7 lib

    + +

    + This directory holds a collection of standard libc-like functions with custom + interfaces into Nuttx. +

    +

    2.8 mm

    + +

    + This is the NuttX memory manager. +

    +

    2.9 sched

    + +

    + The files forming core of the NuttX RTOS reside here. +

    +

    2.10 tools

    +

    + This directory holds a collection of tools and scripts to simplify + configuring and building NuttX. +

    +

    3.0 Configuring and Building

    +

    4.0 Architecture APIs

    + +

    + The file include/nuttx/arch.h identifies by prototype all of the APIs that must + be provided by the architecture specific logic. + The internal OS APIs that architecture-specific logic must + interface with also also identified in include/nuttx/arch.h or in + other header files. +

    + +

    4.1 APIs Exported by Architecture-Specific Logic to NuttX

    +

    4.1.1 up_initialize()

    + +

    Prototype: void up_initialize(void);

    + +

    Description. + up_initialize() will be called once during OS + initialization after the basic OS services have been + initialized. The architecture specific details of + initializing the OS will be handled here. Such things as + setting up interrupt service routines, starting the + clock, and registering device drivers are some of the + things that are different for each processor and hardware + platform. +

    +

    + up_initialize() is called after the OS initialized but + before the init process has been started and before the + libraries have been initialized. OS services and driver + services are available. +

    + +

    4.1.2 up_idle()

    +

    Prototype: void up_idle(void);

    + +

    Description. + up_idle() is the logic that will be executed + when their is no other ready-to-run task. This is processor + idle time and will continue until some interrupt occurs to + cause a context switch from the idle task. +

    +

    + Processing in this state may be processor-specific. e.g., + this is where power management operations might be performed. +

    + +

    4.1.3 up_initial_state()

    +

    Prototype: void up_initial_state(FAR _TCB *tcb);

    + +

    Description. + A new thread is being started and a new TCB + has been created. This function is called to initialize + the processor specific portions of the new TCB. +

    +

    + This function must setup the intial architecture registers + and/or stack so that execution will begin at tcb->start + on the next context switch. +

    + +

    4.1.4 up_create_stack()

    +

    Prototype: STATUS up_create_stack(FAR _TCB *tcb, size_t stack_size);

    + +

    Description. + Allocate a stack for a new thread and setup + up stack-related information in the TCB. +

    +

    + The following TCB fields must be initialized: +

    + +

    + This API is NOT required if CONFIG_CUSTOM_STACK + is defined. +

    + +

    Inputs: +

  • + tcb: The TCB of new task. +
  • +
  • + stack_size: The requested stack size. At least this much + must be allocated. +
  • + + +

    4.1.5 up_use_stack()

    +

    Prototype: + STATUS up_use_stack(FAR _TCB *tcb, FAR void *stack, size_t stack_size); +

    + +

    Description. + Setup up stack-related information in the TCB + using pre-allocated stack memory. +

    +

    + The following TCB fields must be initialized: +

    + +

    + This API is NOT required if CONFIG_CUSTOM_STACK + is defined. +

    + +

    Inputs:

    + + +

    4.1.6 up_release_stack()

    +

    Prototype: void up_release_stack(FAR _TCB *dtcb);

    + +

    Description. + A task has been stopped. Free all stack + related resources retained int the defunct TCB. +

    +

    + This API is NOT required if CONFIG_CUSTOM_STACK + is defined. +

    + +

    4.1.7 up_unblock_task()

    +

    Prototype: void up_unblock_task(FAR _TCB *tcb);

    + +

    Description. + A task is currently in an inactive task list + but has been prepped to execute. Move the TCB to the + ready-to-run list, restore its context, and start execution. +

    +

    + This function is called only from the NuttX scheduling + logic. Interrupts will always be disabled when this + function is called. +

    + +

    Inputs: +

    + +

    4.1.8 up_block_task()

    +

    Prototype: void up_block_task(FAR _TCB *tcb, tstate_t task_state);

    + +

    Description. + The currently executing task at the head of + the ready to run list must be stopped. Save its context + and move it to the inactive list specified by task_state. + + This function is called only from the NuttX scheduling + logic. Interrupts will always be disabled when this + function is called. + +

    Inputs:

    + + +

    4.1.9 up_release_pending()

    +

    Prototype: void up_release_pending(void);

    + +

    Description. + When tasks become ready-to-run but cannot run because pre-emption + is disabled, they are placed into a pending task list. + This function releases and makes ready-to-run all of the tasks that have + collected in the pending task list. This can cause a + context switch if a new task is placed at the head of + the ready to run list. +

    +

    + This function is called only from the NuttX scheduling logic when + pre-emption is re-enabled. Interrupts will always be disabled when this + function is called. +

    + +

    4.1.10 up_reprioritize_rtr()

    +

    Prototype: void up_reprioritize_rtr(FAR _TCB *tcb, ubyte priority);

    + +

    Description. + Called when the priority of a running or + ready-to-run task changes and the reprioritization will + cause a context switch. Two cases: +

    +
      +
    1. + The priority of the currently running task drops and the next + task in the ready to run list has priority. +
    2. +
    3. + An idle, ready to run task's priority has been raised above the + the priority of the current, running task and it now has the + priority. +
    4. +
    +

    + This function is called only from the NuttX scheduling + logic. Interrupts will always be disabled when this + function is called. +

    + +

    Inputs:

    + + +

    4.1.11 _exit()

    +

    Prototype: void _exit(int status) noreturn_function;

    + +

    Description. + This function causes the currently executing task to cease + to exist. This is a special case of task_delete(). +

    +

    + Unlike other UP APIs, this function may be called + directly from user programs in various states. The + implementation of this function should diable interrupts + before performing scheduling operations. +

    + +

    4.1.12 up_assert()

    +

    Prototype:
    + void up_assert(FAR const ubyte *filename, int linenum);
    + void up_assert_code(FAR const ubyte *filename, int linenum, int error_code);
    +

    + +

    Description. + Assertions may be handled in an architecture-specific + way. +

    + +

    4.1.13 up_schedule_sigaction()

    +

    Prototype: + void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver); +

    + +

    Description. + This function is called by the OS when one or more + signal handling actions have been queued for execution. + The architecture specific code must configure things so + that the 'igdeliver' callback is executed on the thread + specified by 'tcb' as soon as possible. +

    +

    + This function may be called from interrupt handling logic. +

    +

    + This operation should not cause the task to be unblocked + nor should it cause any immediate execution of sigdeliver. + Typically, a few cases need to be considered: +

    +
      +
    1. + This function may be called from an interrupt handler + During interrupt processing, all xcptcontext structures + should be valid for all tasks. That structure should + be modified to invoke sigdeliver() either on return + from (this) interrupt or on some subsequent context + switch to the recipient task. +
    2. +
    3. + If not in an interrupt handler and the tcb is NOT + the currently executing task, then again just modify + the saved xcptcontext structure for the recipient + task so it will invoke sigdeliver when that task is + later resumed. +
    4. +
    5. + If not in an interrupt handler and the tcb IS the + currently executing task -- just call the signal + handler now. +
    6. +
    +

    + This API is NOT required if CONFIG_DISABLE_SIGNALS + is defined. +

    + +

    4.1.14 up_allocate_heap()

    +

    Prototype: void up_allocate_heap(FAR void **heap_start, size_t *heap_size);

    + +

    Description. + The heap may be statically allocated by + defining CONFIG_HEAP_BASE and CONFIG_HEAP_SIZE. If these + are not defined, then this function will be called to + dynamically set aside the heap region. +

    +

    + This API is NOT required if CONFIG_HEAP_BASE + is defined. +

    + +

    4.1.15 up_interrupt_context()

    +

    Prototype: boolean up_interrupt_context(void)

    + +

    Description. + Return TRUE is we are currently executing in + the interrupt handler context. +

    + +

    4.1.16 up_disable_irq()

    +

    Prototype: void up_disable_irq(int irq);

    + +

    Description. + Disable the IRQ specified by 'irq' +

    + +

    4.1.17 up_enable_irq()

    +

    Prototype: void up_enable_irq(int irq);

    + +

    Description. + Enable the IRQ specified by 'irq' +

    + +

    4.1.18 up_putc()

    + +

    Prototype: int up_putc(int ch);

    +

    Description. + This is a debug interface exported by the architecture-specific logic. + Output one character on the console +

    + This API is NOT required if CONFIG_HEAP_BASE + is defined. +

    + +

    4.2 APIs Exported by NuttX to Architecture-Specific Logic

    +

    + These are standard interfaces that are exported by the OS + for use by the architecture specific logic. +

    + +

    4.2.1 os_start()

    +

    + To be provided +

    + +

    4.2.2 OS List Management APIs

    +

    + To be provided +

    + +

    4.2.3 sched_process_timer()

    +

    Prototype: void sched_process_timer(void);

    + +

    Description. + This function handles system timer events. + The timer interrupt logic itself is implemented in the + architecture specific code, but must call the following OS + function periodically -- the calling interval must be + MSEC_PER_TICK. +

    + +

    4.2.4 irq_dispatch()

    +

    Prototype: void irq_dispatch(int irq, FAR void *context);

    + +

    Description. + This function must be called from the achitecture- + specific logic in order to dispaly an interrupt to + the appropriate, registered handling logic. +

    + +

    Appendix A: NuttX Configuration Settings

    + +

    + The following variables are recognized by the build (you may + also include architecture-specific settings). +

    + +

    Architecture selection

    + + + +

    General OS setup

    + + + +

    + The following can be used to disable categories of APIs supported + by the OS. If the compiler supports weak functions, then it + should not be necessary to disable functions unless you want to + restrict usage of those APIs. +

    +

    + There are certain dependency relationships in these features. +

    + + + + +

    Miscellaneous libc settings

    + + + +

    Allow for architecture optimized implementations

    + +

    + The architecture can provide optimized versions of the + following to improve sysem performance. +

    + + + +

    Sizes of configurable things (0 disables)

    + + + +

    Stack and heap information

    + + +