eCos Reference Manual - MicroBlaze 2020. 9. 1. · All other brand and product names, trademarks,...

596
eCos Reference Manual

Transcript of eCos Reference Manual - MicroBlaze 2020. 9. 1. · All other brand and product names, trademarks,...

  • eCos Reference Manual

  • eCos Reference ManualCopyright © 1998, 1999, 2000, 2001, 2002, 2003 by Red Hat, Inc.Nick Garnett (eCosCentric)Jonathan Larmour(eCosCentric)Andrew Lunn (Ascom)Gary Thomas (MLB Associates)Bart Veer (eCosCentric)

    Documentation licensing terms

    This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is

    presently available at http://www.opencontent.org/openpub/).

    Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder.

    Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright

    holder.

    Trademarks

    Altera® and Excalibur™ are trademarks of Altera Corporation.

    AMD® is a registered trademark of Advanced Micro Devices, Inc.

    ARM®, StrongARM®, Thumb®, ARM7™, ARM9™ is a registered trademark of Advanced RISC Machines, Ltd.

    Cirrus Logic® and Maverick™ are registered trademarks of Cirrus Logic, Inc.

    Cogent™ is a trademark of Cogent Computer Systems, Inc.

    Compaq® is a registered trademark of the Compaq Computer Corporation.

    Fujitsu® is a registered trademark of Fujitsu Limited.

    IBM®, and PowerPC™ are trademarks of International Business Machines Corporation.

    IDT® is a registered trademark of Integrated Device Technology Inc.

    Intel®, i386™, Pentium®, StrataFlash® and XScale™ are trademarks of Intel Corporation.

    Intrinsyc® and Cerf™ are trademarks of Intrinsyc Software, Inc.

    Linux® is a registered trademark of Linus Torvalds.

    Matsushita™ and Panasonic® are trademarks of the Matsushita Electric Industrial Corporation.

    Microsoft®, Windows®, Windows NT® and Windows XP® are registered trademarks of Microsoft Corporation, Inc.

    MIPS®, MIPS32™ MIPS64™, 4K™, 5K™ Atlas™ and Malta™ are trademarks of MIPS Technologies, Inc.

    Motorola®, ColdFire® is a trademark of Motorola, Inc.

    NEC® V800™, V850™, V850/SA1™, V850/SB1™, VR4300™, and VRC4375™ are trademarks of NEC Corporation.

    PMC-Sierra® RM7000™ and Ocelot™ are trademarks of PMC-Sierra Incorporated.

    Red Hat, eCos™, RedBoot™, GNUPro®, and Insight™ are trademarks of Red Hat, Inc.

    Samsung® and CalmRISC™ are trademarks or registered trademarks of Samsung, Inc.

    Sharp® is a registered trademark of Sharp Electronics Corp.

    SPARC® is a registered trademark of SPARC International, Inc., and is used under license by Sun Microsystems, Inc.

    Sun Microsystems® and Solaris® are registered trademarks of Sun Microsystems, Inc.

    SuperH™ and Renesas™ are trademarks owned by Renesas Technology Corp.

    Texas Instruments®, OMAP™ and Innovator™ are trademarks of Texas Instruments Incorporated.

    Toshiba® is a registered trademark of the Toshiba Corporation.

    UNIX® is a registered trademark of The Open Group.

    All other brand and product names, trademarks, and copyrights are the property of their respective owners.

    Warranty

    eCos and RedBoot are open source software, covered by a modified version of the GNU General Public Licence (http://www.gnu.org/copyleft/gpl.html),

    and you are welcome to change it and/or distribute copies of it under certain conditions. See http://ecos.sourceware.org/license-overview.html for more

    information about the license.

    eCos and RedBoot software have NO WARRANTY.

  • Because this software is licensed free of charge, there are no warranties for it, to the extent permitted by applicable law. Except when otherwise stated in

    writing, the copyright holders and/or other parties provide the software “as is” without warranty of any kind, either expressed or implied, including, but

    not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the

    software is with you. Should the software prove defective, you assume the cost of all necessary servicing, repair or correction.

    In no event, unless required by applicable law or agreed to in writing, will any copyright holder, or any other party who may modify and/or redistribute

    the program as permitted above, be liable to you for damages, including any general, special, incidental or consequential damages arising out of the use

    or inability to use the program (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a

    failure of the program to operate with any other programs), even if such holder or other party has been advised of the possibility of such damages.

  • Table of ContentsI. The eCos Kernel.......................................................................................................................................... ??

    Kernel Overview..................................................................................................................................... ??SMP Support........................................................................................................................................... ??Thread creation....................................................................................................................................... ??Thread information................................................................................................................................. ??Thread control......................................................................................................................................... ??Thread termination.................................................................................................................................. ??Thread priorities...................................................................................................................................... ??Per-thread data........................................................................................................................................ ??Thread destructors................................................................................................................................... ??Exception handling................................................................................................................................. ??Counters.................................................................................................................................................. ??Clocks...................................................................................................................................................... ??Alarms..................................................................................................................................................... ??Mutexes................................................................................................................................................... ??Condition Variables................................................................................................................................. ??Semaphores............................................................................................................................................. ??Mail boxes............................................................................................................................................... ??Event Flags.............................................................................................................................................. ??Spinlocks................................................................................................................................................. ??Scheduler Control................................................................................................................................... ??Interrupt Handling................................................................................................................................... ??Kernel Real-time Characterization.......................................................................................................... ??

    II. The eCos Hardware Abstraction Layer (HAL) ...................................................................................... ??

    1. Introduction......................................................................................................................................... ??2. Architecture, Variant and Platform..................................................................................................... ??3. General principles............................................................................................................................... ??4. HAL Interfaces.................................................................................................................................... ??

    Base Definitions............................................................................................................................. ??Byte order............................................................................................................................. ??Label Translation................................................................................................................. ??Base types............................................................................................................................ ??Atomic types........................................................................................................................ ??

    Architecture Characterization........................................................................................................ ??Register Save Format........................................................................................................... ??Thread Context Initialization............................................................................................... ??Thread Context Switching................................................................................................... ??Bit indexing.......................................................................................................................... ??Idle thread activity............................................................................................................... ??Reorder barrier..................................................................................................................... ??Breakpoint support............................................................................................................... ??GDB support........................................................................................................................ ??Setjmp and longjmp support................................................................................................ ??Stack Sizes........................................................................................................................... ??Address Translation............................................................................................................. ??Global Pointer...................................................................................................................... ??

    Interrupt Handling......................................................................................................................... ??Vector numbers.................................................................................................................... ??Interrupt state control........................................................................................................... ??

    i

  • ISR and VSR management.................................................................................................. ??Interrupt controller management.......................................................................................... ??

    Clocks and Timers......................................................................................................................... ??Clock Control....................................................................................................................... ??Microsecond Delay.............................................................................................................. ??Clock Frequency Definition................................................................................................. ??

    HAL I/O......................................................................................................................................... ??Register address................................................................................................................... ??Register read........................................................................................................................ ??Register write....................................................................................................................... ??

    Cache Control................................................................................................................................ ??Cache Dimensions............................................................................................................... ??Global Cache Control.......................................................................................................... ??Cache Line Control.............................................................................................................. ??

    Linker Scripts................................................................................................................................ ??Diagnostic Support........................................................................................................................ ??SMP Support................................................................................................................................. ??

    Target Hardware Limitations............................................................................................... ??HAL Support........................................................................................................................ ??

    CPU Control............................................................................................................... ??Test-and-set Support................................................................................................... ??Spinlocks.................................................................................................................... ??Scheduler Lock........................................................................................................... ??Interrupt Routing........................................................................................................ ??

    5. Exception Handling............................................................................................................................. ??HAL Startup.................................................................................................................................. ??Vectors and VSRs.......................................................................................................................... ??Default Synchronous Exception Handling.................................................................................... ??Default Interrupt Handling............................................................................................................ ??

    6. Porting Guide...................................................................................................................................... ??Introduction................................................................................................................................... ??HAL Structure............................................................................................................................... ??

    HAL Classes........................................................................................................................ ??File Descriptions.................................................................................................................. ??

    Common HAL............................................................................................................ ??Architecture HAL....................................................................................................... ??Variant HAL............................................................................................................... ??Platform HAL............................................................................................................. ??Auxiliary HAL ........................................................................................................... ??

    Virtual Vectors (eCos/ROM Monitor Calling Interface)............................................................... ??Virtual Vectors..................................................................................................................... ??

    Initialization (or Mechanism vs. Policy).................................................................... ??Pros and Cons of Virtual Vectors............................................................................... ??Available services....................................................................................................... ??

    The COMMS channels........................................................................................................ ??Console and Debugging Channels............................................................................. ??Mangling.................................................................................................................... ??Controlling the Console Channel............................................................................... ??Footnote: Design Reasoning for Control of Console Channel................................... ??

    The calling Interface API..................................................................................................... ??Implemented Services................................................................................................ ??Compatibility.............................................................................................................. ??

    ii

  • Implementation details............................................................................................... ??New Platform Ports.................................................................................................... ??New architecture ports................................................................................................ ??

    IO channels.......................................................................................................................... ??Available Procedures.................................................................................................. ??Usage.......................................................................................................................... ??Compatibility.............................................................................................................. ??Implementation Details.............................................................................................. ??New Platform Ports.................................................................................................... ??

    HAL Coding Conventions............................................................................................................. ??Implementation issues.......................................................................................................... ??Source code details.............................................................................................................. ??Nested Headers.................................................................................................................... ??

    Platform HAL Porting................................................................................................................... ??HAL Platform Porting Process............................................................................................ ??

    Brief overview............................................................................................................ ??Step-by-step................................................................................................................ ??

    Minimal requirements....................................................................................... ??Adding features................................................................................................. ??

    Hints........................................................................................................................... ??HAL Platform CDL............................................................................................................. ??

    eCos Database............................................................................................................ ??CDL File Layout........................................................................................................ ??Startup Type............................................................................................................... ??Build options.............................................................................................................. ??Common Target Options............................................................................................ ??

    Platform Memory Layout.................................................................................................... ??Layout Files................................................................................................................ ??Reserved Regions....................................................................................................... ??

    Platform Serial Device Support........................................................................................... ??Variant HAL Porting...................................................................................................................... ??

    HAL Variant Porting Process............................................................................................... ??HAL Variant CDL................................................................................................................ ??Cache Support...................................................................................................................... ??

    Architecture HAL Porting............................................................................................................. ??HAL Architecture Porting Process...................................................................................... ??CDL Requirements.............................................................................................................. ??

    7. Future developments........................................................................................................................... ??

    III. The ISO Standard C and Math Libraries ............................................................................................. ??

    8. C and math library overview............................................................................................................... ??Included non-ISO functions.......................................................................................................... ??Math library compatibility modes................................................................................................. ??

    matherr().............................................................................................................................. ??Thread-safety and re-entrancy............................................................................................. ??

    Some implementation details........................................................................................................ ??Thread safety................................................................................................................................. ??C library startup............................................................................................................................. ??

    IV. I/O Package (Device Drivers).................................................................................................................. ??

    9. Introduction......................................................................................................................................... ??10. User API............................................................................................................................................ ??11. Serial driver details............................................................................................................................ ??

    iii

  • Raw Serial Driver.......................................................................................................................... ??Runtime Configuration........................................................................................................ ??API Details........................................................................................................................... ??

    cyg_io_write............................................................................................................... ??cyg_io_read................................................................................................................ ??cyg_io_get_config...................................................................................................... ??cyg_io_set_config....................................................................................................... ??

    TTY driver..................................................................................................................................... ??Runtime configuration......................................................................................................... ??API details............................................................................................................................ ??

    12. How to Write a Driver....................................................................................................................... ??How to Write a Serial Hardware Interface Driver......................................................................... ??

    DevTab Entry....................................................................................................................... ??Serial Channel Structure...................................................................................................... ??Serial Functions Structure.................................................................................................... ??Callbacks.............................................................................................................................. ??

    Serial testing with ser_filter........................................................................................................... ??Rationale.............................................................................................................................. ??The Protocol......................................................................................................................... ??The Serial Tests.................................................................................................................... ??Serial Filter Usage................................................................................................................ ??A Note on Failures............................................................................................................... ??Debugging............................................................................................................................ ??

    13. Device Driver Interface to the Kernel............................................................................................... ??Interrupt Model.............................................................................................................................. ??Synchronization............................................................................................................................. ??SMP Support................................................................................................................................. ??Device Driver Models.................................................................................................................... ??Synchronization Levels................................................................................................................. ??The API......................................................................................................................................... ??

    cyg_drv_isr_lock.................................................................................................................. ??cyg_drv_isr_unlock.............................................................................................................. ??cyg_drv_spinlock_init.......................................................................................................... ??cyg_drv_spinlock_destroy................................................................................................... ??cyg_drv_spinlock_spin........................................................................................................ ??cyg_drv_spinlock_clear....................................................................................................... ??cyg_drv_spinlock_try.......................................................................................................... ??cyg_drv_spinlock_test......................................................................................................... ??cyg_drv_spinlock_spin_intsave........................................................................................... ??cyg_drv_spinlock_clear_intsave.......................................................................................... ??cyg_drv_dsr_lock................................................................................................................. ??cyg_drv_dsr_unlock............................................................................................................. ??cyg_drv_mutex_init............................................................................................................. ??cyg_drv_mutex_destroy....................................................................................................... ??cyg_drv_mutex_lock............................................................................................................ ??cyg_drv_mutex_trylock....................................................................................................... ??cyg_drv_mutex_unlock........................................................................................................ ??cyg_drv_mutex_release....................................................................................................... ??cyg_drv_cond_init............................................................................................................... ??cyg_drv_cond_destroy......................................................................................................... ??cyg_drv_cond_wait.............................................................................................................. ??cyg_drv_cond_signal........................................................................................................... ??

    iv

  • cyg_drv_cond_broadcast..................................................................................................... ??cyg_drv_interrupt_create..................................................................................................... ??cyg_drv_interrupt_delete..................................................................................................... ??cyg_drv_interrupt_attach..................................................................................................... ??cyg_drv_interrupt_detach.................................................................................................... ??cyg_drv_interrupt_mask...................................................................................................... ??cyg_drv_interrupt_mask_intunsafe...................................................................................... ??cyg_drv_interrupt_unmask.................................................................................................. ??cyg_drv_interrupt_unmask_intunsafe.................................................................................. ??cyg_drv_interrupt_acknowledge.......................................................................................... ??cyg_drv_interrupt_configure................................................................................................ ??cyg_drv_interrupt_level....................................................................................................... ??cyg_drv_interrupt_set_cpu.................................................................................................. ??cyg_drv_interrupt_get_cpu.................................................................................................. ??cyg_ISR_t............................................................................................................................ ??cyg_DSR_t........................................................................................................................... ??

    V. File System Support Infrastructure ......................................................................................................... ??

    14. Introduction....................................................................................................................................... ??15. File System Table.............................................................................................................................. ??16. Mount Table...................................................................................................................................... ??17. File Table........................................................................................................................................... ??18. Directories......................................................................................................................................... ??19. Synchronization................................................................................................................................ ??20. Initialization and Mounting............................................................................................................... ??21. Sockets.............................................................................................................................................. ??22. Select................................................................................................................................................. ??23. Devices.............................................................................................................................................. ??24. Writing a New Filesystem................................................................................................................. ??

    VI. PCI Library .............................................................................................................................................. ??

    25. The eCos PCI Library....................................................................................................................... ??PCI Library.................................................................................................................................... ??

    PCI Overview....................................................................................................................... ??Initializing the bus................................................................................................................ ??Scanning for devices............................................................................................................ ??Generic config information.................................................................................................. ??Specific config information.................................................................................................. ??Allocating memory.............................................................................................................. ??Interrupts.............................................................................................................................. ??Activating a device............................................................................................................... ??Links .................................................................................................................................... ??

    PCI Library reference.................................................................................................................... ??PCI Library API................................................................................................................... ??Definitions............................................................................................................................ ??Types and data structures..................................................................................................... ??Functions.............................................................................................................................. ??Resource allocation.............................................................................................................. ??PCI Library Hardware API.................................................................................................. ??HAL PCI support................................................................................................................. ??

    VII. FLASH Library ...................................................................................................................................... ??

    26. The eCos FLASH Library................................................................................................................. ??

    v

  • FLASH Library ............................................................................................................................. ??Initializing the FLASH library............................................................................................. ??Retrieving information about the FLASH........................................................................... ??Reading from FLASH.......................................................................................................... ??Erasing areas of FLASH...................................................................................................... ??Programming the FLASH.................................................................................................... ??Locking and unlocking blocks............................................................................................. ??Return values and errors...................................................................................................... ??Notes on using the FLASH library...................................................................................... ??Danger, Will Robinson! Danger!......................................................................................... ??

    VIII. SPI Support ............................................................................................................................................ ??

    Overview................................................................................................................................................. ??SPI Interface............................................................................................................................................ ??Porting to New Hardware........................................................................................................................ ??

    IX. eCos POSIX compatibility layer ............................................................................................................. ??

    27. POSIX Standard Support.................................................................................................................. ??Process Primitives [POSIX Section 3].......................................................................................... ??

    Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Process Environment [POSIX Section 4]...................................................................................... ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Files and Directories [POSIX Section 5]....................................................................................... ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Input and Output [POSIX Section 6]............................................................................................. ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Device and Class Specific Functions [POSIX Section 7].............................................................. ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    C Language Services [POSIX Section 8]...................................................................................... ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    System Databases [POSIX Section 9]........................................................................................... ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Data Interchange Format [POSIX Section 10].............................................................................. ??Synchronization [POSIX Section 11]............................................................................................ ??

    Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Memory Management [POSIX Section 12].................................................................................. ??Functions Implemented........................................................................................................ ??

    vi

  • Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Execution Scheduling [POSIX Section 13]................................................................................... ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Clocks and Timers [POSIX Section 14]........................................................................................ ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Message Passing [POSIX Section 15]........................................................................................... ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Thread Management [POSIX Section 16]..................................................................................... ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Thread-Specific Data [POSIX Section 17].................................................................................... ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Thread Cancellation [POSIX Section 18]..................................................................................... ??Functions Implemented........................................................................................................ ??Functions Omitted................................................................................................................ ??Notes.................................................................................................................................... ??

    Non-POSIX Functions................................................................................................................... ??General I/O Functions.......................................................................................................... ??Socket Functions.................................................................................................................. ??Notes.................................................................................................................................... ??

    References and Bibliography.................................................................................................................. ??

    X. µITRON ...................................................................................................................................................... ??

    28.µITRON API..................................................................................................................................... ??Introduction toµITRON................................................................................................................ ??µITRON andeCos......................................................................................................................... ??Task Management Functions......................................................................................................... ??

    Error checking...................................................................................................................... ??Task-Dependent Synchronization Functions................................................................................. ??

    Error checking...................................................................................................................... ??Synchronization and Communication Functions........................................................................... ??

    Error checking...................................................................................................................... ??Extended Synchronization and Communication Functions.......................................................... ??Interrupt management functions.................................................................................................... ??

    Error checking...................................................................................................................... ??Memory pool Management Functions........................................................................................... ??

    Error checking...................................................................................................................... ??Time Management Functions........................................................................................................ ??

    Error checking...................................................................................................................... ??System Management Functions..................................................................................................... ??

    Error checking...................................................................................................................... ??Network Support Functions........................................................................................................... ??

    vii

  • µITRON Configuration FAQ......................................................................................................... ??

    XI. TCP/IP Stack Support for eCos.............................................................................................................. ??

    29. Ethernet Driver Design...................................................................................................................... ??30. Sample Code..................................................................................................................................... ??31. Configuring IP Addresses................................................................................................................. ??32. Tests and Demonstrations................................................................................................................. ??

    Loopback tests............................................................................................................................... ??Building the Network Tests........................................................................................................... ??Standalone Tests............................................................................................................................ ??Performance Test........................................................................................................................... ??Interactive Tests............................................................................................................................. ??Maintenance Tools......................................................................................................................... ??

    33. Support Features............................................................................................................................... ??TFTP.............................................................................................................................................. ??DHCP............................................................................................................................................ ??

    34. TCP/IP Library Reference................................................................................................................ ??getdomainname.............................................................................................................................. ??gethostname................................................................................................................................... ??byteorder........................................................................................................................................ ??ethers.............................................................................................................................................. ??getaddrinfo..................................................................................................................................... ??gethostbyname............................................................................................................................... ??getifaddrs....................................................................................................................................... ??getnameinfo................................................................................................................................... ??getnetent........................................................................................................................................ ??getprotoent..................................................................................................................................... ??getrrsetbyname.............................................................................................................................. ??getservent....................................................................................................................................... ??if_nametoindex.............................................................................................................................. ??inet................................................................................................................................................. ??inet6_option_space........................................................................................................................ ??inet6_rthdr_space.......................................................................................................................... ??inet_net.......................................................................................................................................... ??ipx .................................................................................................................................................. ??iso_addr......................................................................................................................................... ??link_addr........................................................................................................................................ ??net_addrcmp.................................................................................................................................. ??ns.................................................................................................................................................... ??resolver.......................................................................................................................................... ??accept............................................................................................................................................. ??bind................................................................................................................................................ ??connect........................................................................................................................................... ??getpeername................................................................................................................................... ??getsockname.................................................................................................................................. ??getsockopt...................................................................................................................................... ??ioctl ................................................................................................................................................ ??poll ................................................................................................................................................. ??select.............................................................................................................................................. ??send................................................................................................................................................ ??shutdown........................................................................................................................................ ??socket............................................................................................................................................. ??

    viii

  • socketpair....................................................................................................................................... ??

    XII. FreeBSD TCP/IP Stack port for eCos................................................................................................... ??

    35. Networking Stack Features............................................................................................................... ??36. Freebsd TCP/IP stack port................................................................................................................ ??

    Targets........................................................................................................................................... ??Building the Network Stack.......................................................................................................... ??

    37. APIs................................................................................................................................................... ??Standard networking...................................................................................................................... ??Enhanced Select().......................................................................................................................... ??

    XIII. OpenBSD TCP/IP Stack port for eCos ............................................................................................... ??

    38. Networking Stack Features............................................................................................................... ??Introduction................................................................................................................................... ??

    39. OpenBSD TCP/IP stack port............................................................................................................. ??Targets........................................................................................................................................... ??Building the Network Stack.......................................................................................................... ??Inclusion of bridge code................................................................................................................ ??

    40. APIs................................................................................................................................................... ??Standard networking...................................................................................................................... ??Enhanced Select().......................................................................................................................... ??OpenBSD networking facilities..................................................................................................... ??Bridging......................................................................................................................................... ??Spanning Tree Protocol................................................................................................................. ??

    XIV. DNS for eCos and RedBoot.................................................................................................................. ??

    41. DNS................................................................................................................................................... ??DNS API........................................................................................................................................ ??DNS Client Testing........................................................................................................................ ??

    XV. IPSEC for eCos........................................................................................................................................ ??

    42. Installation and Configuration........................................................................................................... ??43. libipsec Reference............................................................................................................................. ??

    ipsec_set_policy............................................................................................................................ ??ipsec_strerror................................................................................................................................. ??

    XVI. eCos PPP User Guide............................................................................................................................ ??

    44. Features............................................................................................................................................. ??45. Using PPP......................................................................................................................................... ??46. PPP Interface..................................................................................................................................... ??

    cyg_ppp_options_init().................................................................................................................. ??cyg_ppp_up()................................................................................................................................. ??cyg_ppp_down()............................................................................................................................ ??cyg_ppp_wait_up()........................................................................................................................ ??cyg_ppp_wait_down()................................................................................................................... ??cyg_ppp_chat().............................................................................................................................. ??

    47. Installing and Configuring PPP......................................................................................................... ??Including PPP in a Configuration.................................................................................................. ??Configuring PPP............................................................................................................................ ??

    48. CHAT Scripts.................................................................................................................................... ??Chat Script..................................................................................................................................... ??ABORT Strings............................................................................................................................. ??TIMEOUT ..................................................................................................................................... ??Sending EOT................................................................................................................................. ??Escape Sequences.......................................................................................................................... ??

    ix

  • 49. PPP Enabled Device Drivers............................................................................................................. ??50. Testing............................................................................................................................................... ??

    Test Programs................................................................................................................................ ??Test Script...................................................................................................................................... ??

    XVII. Ethernet Device Drivers ...................................................................................................................... ??

    51. Generic Ethernet Device Driver........................................................................................................ ??Generic Ethernet API.................................................................................................................... ??Review of the functions................................................................................................................. ??

    Init function.......................................................................................................................... ??Start function........................................................................................................................ ??Stop function........................................................................................................................ ??Control function................................................................................................................... ??Can-send function................................................................................................................ ??Send function....................................................................................................................... ??Deliver function................................................................................................................... ??Receive function.................................................................................................................. ??Poll function......................................................................................................................... ??Interrupt-vector function...................................................................................................... ??

    Upper Layer Functions.................................................................................................................. ??Callback Init function.......................................................................................................... ??Callback Tx-Done function.................................................................................................. ??Callback Receive function................................................................................................... ??

    Calling graph for Transmission and Reception............................................................................. ??Transmission........................................................................................................................ ??Receive................................................................................................................................. ??

    XVIII. Ethernet PHY Device Support .......................................................................................................... ??

    52. Ethernet PHY Device Support.......................................................................................................... ??Ethernet PHY Device API............................................................................................................. ??

    XIX. SNMP ...................................................................................................................................................... ??

    53. SNMP foreCos................................................................................................................................. ??Version........................................................................................................................................... ??SNMP packages in theeCossource repository............................................................................. ??MIBs supported............................................................................................................................. ??Changes to eCos sources............................................................................................................... ??Starting the SNMP Agent.............................................................................................................. ??Configuring eCos........................................................................................................................... ??

    Version usage (v1, v2 or v3)................................................................................................ ??Traps..................................................................................................................................... ??snmpd.conf file ................................................................................................................... ??

    Test cases....................................................................................................................................... ??SNMP clients and package use...................................................................................................... ??Unimplemented features................................................................................................................ ??MIB Compiler ............................................................................................................................... ??snmpd.conf.................................................................................................................................... ??

    XX. Embedded HTTP Server........................................................................................................................ ??

    54. Embedded HTTP Server................................................................................................................... ??Intrduction..................................................................................................................................... ??Server Organization....................................................................................................................... ??Server Configuration..................................................................................................................... ??

    CYGNUM_HTTPD_SERVER_PORT............................................................................................. ??

    x

  • CYGDAT_HTTPD_SERVER_ID................................................................................................. ??CYGNUM_HTTPD_THREAD_COUNT........................................................................................... ??CYGNUM_HTTPD_THREAD_PRIORITY..................................................................................... ??CYGNUM_HTTPD_THREAD_STACK_SIZE................................................................................. ??CYGNUM_HTTPD_SERVER_BUFFER_SIZE............................................................................... ??CYGNUM_HTTPD_SERVER_AUTO_START................................................................................. ??CYGNUM_HTTPD_SERVER_DELAY........................................................................................... ??

    Support Functions and Macros...................................................................................................... ??HTTP Support...................................................................................................................... ??General HTML Support....................................................................................................... ??Table Support....................................................................................................................... ??Forms Support...................................................................................................................... ??Predefined Handlers............................................................................................................. ??

    System Monitor............................................................................................................................. ??

    XXI. FTP Client for eCos TCP/IP Stack ...................................................................................................... ??

    55. FTP Client Features.......................................................................................................................... ??FTP Client API.............................................................................................................................. ??

    ftp_get.................................................................................................................................. ??ftp_put.................................................................................................................................. ??ftpclient_printf..................................................................................................................... ??

    XXII. Simple Network Time Protocol Client ............................................................................................... ??

    56. The SNTP Client............................................................................................................................... ??Starting the SNTP client................................................................................................................ ??What it does................................................................................................................................... ??Configuring the unicast list of NTP servers.................................................................................. ??Warning: timestamp wrap around.................................................................................................. ??The SNTP test program................................................................................................................. ??

    XXIII. CRC Algorithms ................................................................................................................................. ??

    57. CRC Functions.................................................................................................................................. ??CRC API........................................................................................................................................ ??

    cyg_posix_crc32.................................................................................................................. ??cyg_crc32............................................................................................................................. ??cyg_ether_crc32................................................................................................................... ??cyg_crc16............................................................................................................................. ??

    XXIV. CPU load measurements.................................................................................................................... ??

    58. CPU Load Measurements................................................................................................................. ??CPU Load API............................................................................................................................... ??

    cyg_cpuload_calibrate......................................................................................................... ??cyg_cpuload_create.............................................................................................................. ??cyg_cpuload_delete.............................................................................................................. ??cyg_cpuload_get.................................................................................................................. ??Implementation details......................................................................................................... ??

    XXV. Application profiling ............................................................................................................................ ??

    59. Profiling functions............................................................................................................................. ??API................................................................................................................................................. ??

    profile_on............................................................................................................................. ??

    XXVI. eCos Power Management Support.................................................................................................... ??

    Introduction............................................................................................................................................. ??Power Management Information............................................................................................................. ??

    xi

  • Changing Power Modes.......................................................................................................................... ??Support for Policy Modules.................................................................................................................... ??Attached and Detached Controllers........................................................................................................ ??Implementing a Power Controller........................................................................................................... ??

    XXVII. eCos USB Slave Support................................................................................................................... ??

    Introduction............................................................................................................................................. ??USB Enumeration Data........................................................................................................................... ??Starting up a USB Device....................................................................................................................... ??Devtab Entries......................................................................................................................................... ??Receiving Data from the Host................................................................................................................. ??Sending Data to the Host........................................................................................................................ ??Halted Endpoints..................................................................................................................................... ??Control Endpoints................................................................................................................................... ??Data Endpoints........................................................................................................................................ ??Writing a USB Device Driver................................................................................................................. ??Testing..................................................................................................................................................... ??

    XXVIII. eCos Support for Developing USB-ethernet Peripherals............................................................. ??

    Introduction............................................................................................................................................. ??Initializing the USB-ethernet Package.................................................................................................... ??USB-ethernet Data Transfers.................................................................................................................. ??USB-ethernet State Handling.................................................................................................................. ??Network Device for the eCos TCP/IP Stack........................................................................................... ??Example Host-side Device Driver........................................................................................................... ??Communication Protocol........................................................................................................................ ??

    XXIX. eCos Synthetic Target......................................................................................................................... ??

    Overview................................................................................................................................................. ??Installation............................................................................................................................................... ??Running a Synthetic Target Application................................................................................................. ??The I/O Auxiliary’s User Interface......................................................................................................... ??The Console Device................................................................................................................................ ??System Calls............................................................................................................................................ ??Writing New Devices - target.................................................................................................................. ??Writing New Devices - host.................................................................................................................... ??Porting..................................................................................................................................................... ??

    XXX. SA11X0 USB Device Driver................................................................................................................ ??

    SA11X0 USB Device Driver.................................................................................................................. ??

    XXXI. NEC uPD985xx USB Device Driver.................................................................................................. ??

    NEC uPD985xx USB Device Driver...................................................................................................... ??

    XXXII. Synthetic Target Ethernet Driver .................................................................................................... ??

    Synthetic Target Ethernet Driver............................................................................................................. ??

    XXXIII. Synthetic Target Watchdog Device ................................................................................................ ??

    Synthetic Target Watchdog Device......................................................................................................... ??

    xii

  • List of Tables8-1. Behavior of math exception handling........................................................................................................ ??

    i

  • I. The eCos Kernel

  • Kernel Overview

    NameKernel — Overview of the eCos Kernel

    DescriptionThe kernel is one of the key packages in all of eCos. It provides the core functionality needed for developingmulti-threaded applications:

    1. The ability to create new threads in the system, either during startup or when the system is already running.

    2. Control over the various threads in the system, for example manipulating their priorities.

    3. A choice of schedulers, determining which thread should currently be running.

    4. A range of synchronization primitives, allowing threads to interact and share data safely.

    5. Integration with the system’s support for interrupts and exceptions.

    In some other operating systems the kernel provides additional functionality. For example the kernel may alsoprovide memory allocation functionality, and device drivers may be part of the kernel as well. This is not thecase for eCos. Memory allocation is handled by a separate package. Similary each device driver will typicallybe a separate package. Various packages are combine