Comtrol DM-2xxx | LT | PRO | RTS | Serial Hub, DeviceMaster 500, DeviceMaster Software Development Kit Reference guide

  • Hello! I am an AI chatbot trained to assist you with the Comtrol DM-2xxx | LT | PRO | RTS | Serial Hub Reference guide. I’ve already reviewed the document and can help you find the information you need or explain it in simple terms. Just ask your questions, and providing more details will help me assist you more effectively!
eCos Reference Manual
eCos Reference Manual
Copyright © 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
Red Hat, the Red Hat Shadow Man logo®, eCos™, RedBoot™, GNUPro®, and Insight™ are trademarks of Red Hat, Inc.
Sun Microsystems® and Solaris® are registered trademarks of Sun Microsystems, Inc.
SPARC® is a registered trademark of SPARC International, Inc., and is used under license by Sun Microsystems, Inc.
Intel® is a registered trademark of Intel Corporation.
Motorola™ is a trademark of Motorola, Inc.
ARM® is a registered trademark of Advanced RISC Machines, Ltd.
MIPS™ is a trademark of MIPS Technologies, Inc.
Toshiba® is a registered trademark of the Toshiba Corporation.
NEC® is a registered trademark if the NEC Corporation.
Cirrus Logic® is a registered trademark of Cirrus Logic, Inc.
Compaq® is a registered trademark of the Compaq Computer Corporation.
Matsushita™ is a trademark of the Matsushita Electric Corporation.
Samsung® and CalmRISC™ are trademarks or registered trademarks of Samsung, Inc.
Linux® is a registered trademark of Linus Torvalds.
UNIX® is a registered trademark of The Open Group.
Microsoft®, Windows®, and Windows NT® are registered trademarks of Microsoft Corporation, Inc.
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://sources.redhat.com/ecos/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 Contents
I. The eCos Kernel ...............................................................................................................................................xxv
Kernel Overview ............................................................................................................................................27
SMP Support..................................................................................................................................................35
Thread creation ..............................................................................................................................................39
Thread information ........................................................................................................................................43
Thread control................................................................................................................................................47
Thread termination.........................................................................................................................................49
Thread priorities.............................................................................................................................................51
Per-thread data ...............................................................................................................................................53
Thread destructors..........................................................................................................................................55
Exception handling ........................................................................................................................................57
Counters .........................................................................................................................................................59
Clocks.............................................................................................................................................................61
Alarms............................................................................................................................................................63
Mutexes..........................................................................................................................................................65
Condition Variables........................................................................................................................................71
Semaphores....................................................................................................................................................75
Mail boxes......................................................................................................................................................77
Event Flags.....................................................................................................................................................79
Spinlocks........................................................................................................................................................83
Scheduler Control ..........................................................................................................................................85
Interrupt Handling..........................................................................................................................................87
Kernel Real-time Characterization.................................................................................................................93
II. RedBoot™ User’s Guide.................................................................................................................................ciii
1. Getting Started with RedBoot......................................................................................................................1
More information about RedBoot on the web........................................................................................1
Installing RedBoot..................................................................................................................................1
User Interface .........................................................................................................................................2
RedBoot Editing Commands..................................................................................................................2
RedBoot Startup Mode...........................................................................................................................3
RedBoot Resource Usage.......................................................................................................................4
Flash Resources ............................................................................................................................4
RAM Resources............................................................................................................................5
Configuring the RedBoot Environment..................................................................................................5
Target Network Configuration......................................................................................................5
Host Network Configuration.........................................................................................................6
Enable TFTP on Red Hat Linux 6.2....................................................................................7
Enable TFTP on Red Hat Linux 7 (or newer).....................................................................7
Enable BOOTP/DHCP server on Red Hat Linux................................................................7
Enable DNS server on Red Hat Linux ................................................................................8
RedBoot network gateway ..................................................................................................9
Verification..................................................................................................................................10
2. RedBoot Commands and Examples...........................................................................................................11
Introduction ..........................................................................................................................................11
Common Commands............................................................................................................................13
v
alias.............................................................................................................................................13
baudrate.......................................................................................................................................15
cache ...........................................................................................................................................17
channel........................................................................................................................................19
cksum..........................................................................................................................................21
disks ............................................................................................................................................23
dump ...........................................................................................................................................25
help..............................................................................................................................................27
ip_address ...................................................................................................................................29
load..............................................................................................................................................31
mcmp...........................................................................................................................................35
mfill.............................................................................................................................................37
ping .............................................................................................................................................39
reset.............................................................................................................................................41
version.........................................................................................................................................43
Flash Image System (FIS)....................................................................................................................45
fis init ..........................................................................................................................................45
fis list...........................................................................................................................................47
fis free..........................................................................................................................................49
fis create......................................................................................................................................51
fis load.........................................................................................................................................55
fis delete......................................................................................................................................57
fis lock.........................................................................................................................................59
fis unlock.....................................................................................................................................61
fis erase........................................................................................................................................63
fis write........................................................................................................................................65
Persistent State Flash-based Configuration and Control......................................................................67
Executing Programs from RedBoot......................................................................................................70
go.................................................................................................................................................71
exec .............................................................................................................................................73
3. Rebuilding RedBoot...................................................................................................................................75
Introduction ..........................................................................................................................................75
Rebuilding RedBoot using ecosconfig........................................................................................75
Rebuilding RedBoot from the Configuration Tool .....................................................................76
4. Updating RedBoot......................................................................................................................................79
Introduction ..........................................................................................................................................79
Load and start a RedBoot RAM instance ...................................................................................79
Update the primary RedBoot flash image...................................................................................80
Reboot; run the new RedBoot image..........................................................................................81
5. Installation and Testing ..............................................................................................................................83
AM3x/MN103E010 Matsushita MN103E010 (AM33/2.0) ASB2305 Board .....................................83
Overview.....................................................................................................................................83
Initial Installation........................................................................................................................83
Preparing to program the board.........................................................................................83
Preparing to use the JTAG debugger.................................................................................84
Loading the RAM-based RedBoot via JTAG....................................................................84
Loading the boot PROM-based RedBoot via the RAM mode RedBoot...........................85
Additional Commands................................................................................................................86
vi
Memory Maps.............................................................................................................................87
Rebuilding RedBoot....................................................................................................................87
ARM/ARM7 ARM Evaluator7T..........................................................................................................88
Overview.....................................................................................................................................88
Initial Installation........................................................................................................................88
Quick download instructions ......................................................................................................88
Special RedBoot Commands ......................................................................................................89
Memory Maps.............................................................................................................................89
Rebuilding RedBoot....................................................................................................................89
ARM/ARM7+ARM9 ARM Integrator.................................................................................................90
Overview.....................................................................................................................................90
Initial Installation........................................................................................................................90
Quick download instructions ......................................................................................................90
Special RedBoot Commands ......................................................................................................91
Memory Maps.............................................................................................................................91
Rebuilding RedBoot....................................................................................................................92
ARM/ARM7+ARM9 ARM PID Board and EPI Dev7+Dev9.............................................................92
Overview.....................................................................................................................................93
Initial Installation Method...........................................................................................................93
Special RedBoot Commands ......................................................................................................93
Memory Maps.............................................................................................................................93
Rebuilding RedBoot....................................................................................................................93
ARM/ARM7 Atmel AT91 Evaluation Board (EB40)..........................................................................94
Overview.....................................................................................................................................94
Initial Installation Method...........................................................................................................94
Special RedBoot Commands ......................................................................................................95
Memory Maps.............................................................................................................................95
Rebuilding RedBoot....................................................................................................................96
ARM/ARM7 Cirrus Logic EP7xxx (EDB7211, EDB7212, EDB7312)..............................................96
Overview.....................................................................................................................................96
Initial Installation Method...........................................................................................................97
Special RedBoot Commands ......................................................................................................97
Memory Maps.............................................................................................................................97
Platform Resource Usage............................................................................................................98
Rebuilding RedBoot....................................................................................................................98
ARM/ARM9 Agilent AAED2000........................................................................................................98
Overview.....................................................................................................................................98
Initial Installation Method...........................................................................................................98
RedBoot as Primary Bootmonitor.....................................................................................98
Special RedBoot Commands ....................................................................................................100
Memory Maps...........................................................................................................................101
Rebuilding RedBoot..................................................................................................................101
ARM/ARM9 Altera Excalibur...........................................................................................................102
Overview...................................................................................................................................102
Initial Installation Method.........................................................................................................102
Flash management ....................................................................................................................103
Special RedBoot Commands ....................................................................................................103
Memory Maps...........................................................................................................................103
vii
Rebuilding RedBoot..................................................................................................................104
ARM/StrongARM(SA110) Intel EBSA 285......................................................................................104
Overview...................................................................................................................................104
Initial Installation Method.........................................................................................................105
Communication Channels.........................................................................................................105
Special RedBoot Commands ....................................................................................................105
Memory Maps...........................................................................................................................105
Platform Resource Usage..........................................................................................................105
Rebuilding RedBoot..................................................................................................................106
ARM/StrongARM(SA1100) Intel Brutus ..........................................................................................106
Overview...................................................................................................................................106
Initial Installation Method.........................................................................................................106
Special RedBoot Commands ....................................................................................................106
Memory Maps...........................................................................................................................106
Platform Resource Usage..........................................................................................................107
Rebuilding RedBoot..................................................................................................................107
ARM/StrongARM(SA1100) Intel SA1100 Multimedia Board .........................................................108
Overview...................................................................................................................................108
Initial Installation Method.........................................................................................................108
Special RedBoot Commands ....................................................................................................108
Memory Maps...........................................................................................................................108
Platform Resource Usage..........................................................................................................109
Rebuilding RedBoot..................................................................................................................109
ARM/StrongARM(SA1110) Intel SA1110 (Assabet)........................................................................109
Overview...................................................................................................................................110
Initial Installation Method.........................................................................................................110
Special RedBoot Commands ....................................................................................................110
Memory Maps...........................................................................................................................110
Platform Resource Usage..........................................................................................................111
Rebuilding RedBoot..................................................................................................................111
ARM/StrongARM(SA11X0) Bright Star Engineering commEngine and nanoEngine.....................111
Overview...................................................................................................................................111
Initial Installation......................................................................................................................112
Download Instructions..............................................................................................................112
Cohabiting with POST in Flash................................................................................................113
Special RedBoot Commands ....................................................................................................113
Memory Maps...........................................................................................................................114
Nano Platform Port...................................................................................................................115
Ethernet Driver..........................................................................................................................115
Rebuilding RedBoot..................................................................................................................115
ARM/StrongARM(SA11X0) Compaq iPAQ PocketPC.....................................................................116
Overview...................................................................................................................................116
Initial Installation......................................................................................................................116
Installing RedBoot on the iPAQ using Windows/CE ......................................................116
Installing RedBoot on the iPAQ - using the Compaq boot loader...................................117
Setting up and testing RedBoot.......................................................................................117
Installing RedBoot permanently......................................................................................118
Restoring Windows/CE...................................................................................................119
viii
Additional commands...............................................................................................................119
Memory Maps...........................................................................................................................119
Rebuilding RedBoot..................................................................................................................120
ARM/StrongARM(SA11X0) Intrinsyc CerfCube..............................................................................120
Overview...................................................................................................................................121
Initial Installation......................................................................................................................121
Additional commands...............................................................................................................121
Memory Maps...........................................................................................................................122
Rebuilding RedBoot..................................................................................................................122
ARM/Xscale Cyclone IQ80310 .........................................................................................................123
Overview...................................................................................................................................123
Initial Installation Method.........................................................................................................123
Error codes................................................................................................................................124
Using RedBoot with ARM Bootloader.....................................................................................124
Special RedBoot Commands ....................................................................................................125
IQ80310 Hardware Tests ..........................................................................................................125
Rebuilding RedBoot..................................................................................................................126
Interrupts...................................................................................................................................126
Memory Maps...........................................................................................................................128
Platform Resource Usage..........................................................................................................129
ARM/Xscale Intel IQ80321 ...............................................................................................................129
Overview...................................................................................................................................129
Initial Installation Method.........................................................................................................129
Switch Settings .........................................................................................................................130
LED Codes................................................................................................................................130
Special RedBoot Commands ....................................................................................................132
Memory Tests..................................................................................................................133
Repeating Memory Tests.................................................................................................133
Repeat-On-Fail Memory Tests........................................................................................133
Rotary Switch S1 Test.....................................................................................................133
7 Segment LED Tests......................................................................................................133
i82544 Ethernet Configuration........................................................................................134
Battery Status Test...........................................................................................................134
Battery Backup SDRAM Memory Test ..........................................................................134
Timer Test........................................................................................................................134
PCI Bus Test....................................................................................................................134
CPU Cache Loop.............................................................................................................135
Rebuilding RedBoot..................................................................................................................135
Interrupts...................................................................................................................................135
Memory Maps...........................................................................................................................136
Platform Resource Usage..........................................................................................................137
CalmRISC/CalmRISC16 Samsung CalmRISC16 Core Evaluation Board........................................137
Overview...................................................................................................................................137
Initial Installation Method.........................................................................................................138
Special RedBoot Commands ....................................................................................................138
Special Note on Serial Channel ................................................................................................138
Rebuilding RedBoot..................................................................................................................138
CalmRISC/CalmRISC32 Samsung CalmRISC32 Core Evaluation Board........................................139
ix
Overview...................................................................................................................................139
Initial Installation Method.........................................................................................................139
Special RedBoot Commands ....................................................................................................140
Special Note on Serial Channel ................................................................................................140
Rebuilding RedBoot..................................................................................................................140
FRV/FRV400 Fujitsu FR-V 400 (MB-93091)....................................................................................140
Overview...................................................................................................................................140
Initial Installation Method.........................................................................................................141
Special RedBoot Commands ....................................................................................................141
Memory Maps...........................................................................................................................141
Rebuilding RedBoot..................................................................................................................141
IA32/x86 x86-Based PC.....................................................................................................................142
Overview...................................................................................................................................142
Initial Installation......................................................................................................................142
Flash management ....................................................................................................................143
Special RedBoot Commands ....................................................................................................143
Memory Maps...........................................................................................................................143
Rebuilding RedBoot..................................................................................................................143
MIPS/MIPS32(CoreLV 4Kc)+MIPS64(CoreLV 5Kc) Atlas Board ..................................................143
Overview...................................................................................................................................143
Initial Installation......................................................................................................................144
Quick download instructions...........................................................................................144
Atlas download format....................................................................................................144
Flash management ....................................................................................................................145
Additional config options................................................................................................145
Additional commands...............................................................................................................145
Interrupts...................................................................................................................................146
Memory Maps...........................................................................................................................146
Rebuilding RedBoot..................................................................................................................147
MIPS/MIPS32(CoreLV 4Kc)+MIPS64(CoreLV 5Kc) Malta Board..................................................147
Overview...................................................................................................................................147
Initial Installation......................................................................................................................147
Quick download instructions...........................................................................................148
Malta download format...................................................................................................148
Additional commands...............................................................................................................148
Interrupts...................................................................................................................................149
Memory Maps...........................................................................................................................150
Rebuilding RedBoot..................................................................................................................150
MIPS/RM7000 PMC-Sierra Ocelot ...................................................................................................150
Overview...................................................................................................................................151
Additional commands...............................................................................................................151
Memory Maps...........................................................................................................................151
Rebuilding RedBoot..................................................................................................................152
MIPS/VR4375 NEC DDB-VRC4375................................................................................................152
Overview...................................................................................................................................152
Initial Installation Method.........................................................................................................153
Special RedBoot Commands ....................................................................................................153
Memory Maps...........................................................................................................................153
x
Ethernet Driver..........................................................................................................................154
Rebuilding RedBoot..................................................................................................................154
PowerPC/MPC860T Analogue & Micro PowerPC 860T..................................................................154
Overview...................................................................................................................................154
Initial Installation Method.........................................................................................................154
Special RedBoot Commands ....................................................................................................155
Memory Maps...........................................................................................................................155
Rebuilding RedBoot..................................................................................................................155
PowerPC/MPC8XX Motorola MBX..................................................................................................155
Overview...................................................................................................................................155
Initial Installation Method.........................................................................................................156
Special RedBoot Commands ....................................................................................................156
Memory Maps...........................................................................................................................156
Rebuilding RedBoot..................................................................................................................157
SuperH/SH3(SH7708) Hitachi EDK7708..........................................................................................157
Overview...................................................................................................................................157
Initial Installation Method.........................................................................................................157
Memory Maps...........................................................................................................................157
Rebuilding RedBoot..................................................................................................................158
SuperH/SH3(SH7709) Hitachi Solution Engine 7709.......................................................................158
Overview...................................................................................................................................158
Initial Installation Method.........................................................................................................158
Special RedBoot Commands ....................................................................................................159
Memory Maps...........................................................................................................................160
Ethernet Driver..........................................................................................................................160
Rebuilding RedBoot..................................................................................................................160
SuperH/SH3(SH7729) Hitachi HS7729PCI.......................................................................................160
Overview...................................................................................................................................161
Initial Installation Method.........................................................................................................161
Special RedBoot Commands ....................................................................................................161
Memory Maps...........................................................................................................................162
Rebuilding RedBoot..................................................................................................................163
SuperH/SH3(SH77X9) Hitachi Solution Engine 77X9 .....................................................................163
Overview...................................................................................................................................163
Initial Installation Method.........................................................................................................163
Special RedBoot Commands ....................................................................................................164
Memory Maps...........................................................................................................................165
Ethernet Driver..........................................................................................................................165
Rebuilding RedBoot..................................................................................................................165
SuperH/SH4(SH7751) Hitachi Solution Engine 7751.......................................................................165
Overview...................................................................................................................................165
Initial Installation Method.........................................................................................................166
Special RedBoot Commands ....................................................................................................166
Memory Maps...........................................................................................................................167
Ethernet Driver..........................................................................................................................167
Rebuilding RedBoot..................................................................................................................167
xi
III. The eCos Hardware Abstraction Layer (HAL)..........................................................................................169
6. Introduction..............................................................................................................................................171
7. Architecture, Variant and Platform ..........................................................................................................173
8. General principles ....................................................................................................................................175
9. HAL Interfaces.........................................................................................................................................177
Base Definitions..................................................................................................................................177
Byte order..................................................................................................................................177
Label Translation ......................................................................................................................177
Base types .................................................................................................................................177
Atomic types.............................................................................................................................178
Architecture Characterization.............................................................................................................178
Register Save Format................................................................................................................178
Thread Context Initialization....................................................................................................178
Thread Context Switching ........................................................................................................179
Bit indexing...............................................................................................................................180
Idle thread activity ....................................................................................................................180
Reorder barrier..........................................................................................................................180
Breakpoint support....................................................................................................................180
GDB support.............................................................................................................................181
Setjmp and longjmp support.....................................................................................................181
Stack Sizes................................................................................................................................181
Address Translation ..................................................................................................................182
Global Pointer...........................................................................................................................182
Interrupt Handling..............................................................................................................................182
Vector numbers .........................................................................................................................182
Interrupt state control................................................................................................................183
ISR and VSR management .......................................................................................................184
Interrupt controller management...............................................................................................184
Clock control.............................................................................................................................186
Microsecond Delay...................................................................................................................186
HAL I/O..............................................................................................................................................186
Register address........................................................................................................................186
Register read .............................................................................................................................187
Register write............................................................................................................................187
Cache Control.....................................................................................................................................187
Cache Dimensions ....................................................................................................................188
Global Cache Control ...............................................................................................................189
Cache Line Control...................................................................................................................190
Linker Scripts .....................................................................................................................................191
Diagnostic Support.............................................................................................................................192
SMP Support ......................................................................................................................................192
Target Hardware Limitations....................................................................................................192
HAL Support.............................................................................................................................193
CPU Control....................................................................................................................193
Test-and-set Support........................................................................................................194
Spinlocks.........................................................................................................................194
Scheduler Lock................................................................................................................195
Interrupt Routing.............................................................................................................196
xii
10. Exception Handling................................................................................................................................197
HAL Startup .......................................................................................................................................197
Vectors and VSRs...............................................................................................................................198
Default Synchronous Exception Handling.........................................................................................200
Default Interrupt Handling.................................................................................................................200
11. Porting Guide.........................................................................................................................................203
Introduction ........................................................................................................................................203
HAL Structure....................................................................................................................................203
HAL Classes .............................................................................................................................203
File Descriptions.......................................................................................................................204
Common HAL.................................................................................................................205
Architecture HAL............................................................................................................205
Variant HAL....................................................................................................................206
Platform HAL..................................................................................................................207
Auxiliary HAL ................................................................................................................208
Virtual Vectors (eCos/ROM Monitor Calling Interface)....................................................................208
Virtual Vectors ..........................................................................................................................208
Initialization (or Mechanism vs. Policy).........................................................................208
Pros and Cons of Virtual Vectors ....................................................................................209
Available services............................................................................................................210
The COMMS channels .............................................................................................................210
Console and Debugging Channels ..................................................................................210
Mangling .........................................................................................................................211
Controlling the Console Channel....................................................................................211
Footnote: Design Reasoning for Control of Console Channel........................................212
The calling Interface API..........................................................................................................213
Implemented Services .....................................................................................................213
Compatibility...................................................................................................................214
Implementation details....................................................................................................215
New Platform Ports.........................................................................................................215
New architecture ports.....................................................................................................215
IO channels ...............................................................................................................................215
Available Procedures.......................................................................................................216
Usage...............................................................................................................................217
Compatibility...................................................................................................................218
Implementation Details ...................................................................................................218
New Platform Ports.........................................................................................................218
HAL Coding Conventions..................................................................................................................219
Implementation issues...............................................................................................................219
Source code details ...................................................................................................................220
Nested Headers .........................................................................................................................221
Platform HAL Porting........................................................................................................................221
HAL Platform Porting Process .................................................................................................222
Brief overview.................................................................................................................222
Step-by-step.....................................................................................................................222
Minimal requirements............................................................................................223
Adding features......................................................................................................224
Hints ................................................................................................................................225
xiii
HAL Platform CDL ..................................................................................................................226
eCos Database .................................................................................................................226
CDL File Layout .............................................................................................................227
Startup Type ....................................................................................................................228
Build options...................................................................................................................228
Common Target Options .................................................................................................230
Platform Memory Layout .........................................................................................................233
Layout Files.....................................................................................................................233
Reserved Regions............................................................................................................233
Platform Serial Device Support ................................................................................................233
Variant HAL Porting...........................................................................................................................235
HAL Variant Porting Process....................................................................................................235
HAL Variant CDL.....................................................................................................................236
Cache Support...........................................................................................................................237
Architecture HAL Porting..................................................................................................................238
HAL Architecture Porting Process ...........................................................................................238
CDL Requirements ...................................................................................................................244
12. Future developments ..............................................................................................................................247
IV. The ISO Standard C and Math Libraries...................................................................................................249
13. C and math library overview..................................................................................................................251
Included non-ISO functions ...............................................................................................................251
Math library compatibility modes......................................................................................................252
matherr() ...................................................................................................................................252
Thread-safety and re-entrancy ..................................................................................................254
Some implementation details .............................................................................................................254
Thread safety......................................................................................................................................256
C library startup..................................................................................................................................256
V. I/O Package (Device Drivers).........................................................................................................................259
14. Introduction............................................................................................................................................261
15. User API.................................................................................................................................................263
16. Serial driver details.................................................................................................................................265
Raw Serial Driver...............................................................................................................................265
Runtime Configuration .............................................................................................................265
API Details................................................................................................................................267
cyg_io_write....................................................................................................................267
cyg_io_read.....................................................................................................................267
cyg_io_get_config...........................................................................................................267
cyg_io_set_config............................................................................................................270
TTY driver..........................................................................................................................................271
Runtime configuration ..............................................................................................................271
API details.................................................................................................................................272
17. How to Write a Driver............................................................................................................................275
How to Write a Serial Hardware Interface Driver..............................................................................276
DevTab Entry............................................................................................................................277
Serial Channel Structure...........................................................................................................277
Serial Functions Structure.........................................................................................................278
Callbacks...................................................................................................................................279
xiv
Serial testing with ser_filter................................................................................................................281
Rationale...................................................................................................................................281
The Protocol..............................................................................................................................281
The Serial Tests.........................................................................................................................282
Serial Filter Usage.....................................................................................................................282
A Note on Failures....................................................................................................................284
Debugging.................................................................................................................................284
18. Device Driver Interface to the Kernel ....................................................................................................285
Interrupt Model...................................................................................................................................285
Synchronization..................................................................................................................................285
SMP Support ......................................................................................................................................286
Device Driver Models.........................................................................................................................286
Synchronization Levels ......................................................................................................................287
The API ..............................................................................................................................................288
cyg_drv_isr_lock.......................................................................................................................288
cyg_drv_isr_unlock...................................................................................................................289
cyg_drv_spinlock_init...............................................................................................................289
cyg_drv_spinlock_destroy........................................................................................................289
cyg_drv_spinlock_spin.............................................................................................................290
cyg_drv_spinlock_clear............................................................................................................290
cyg_drv_spinlock_try ...............................................................................................................291
cyg_drv_spinlock_test ..............................................................................................................291
cyg_drv_spinlock_spin_intsave................................................................................................292
cyg_drv_spinlock_clear_intsave...............................................................................................292
cyg_drv_dsr_lock......................................................................................................................293
cyg_drv_dsr_unlock..................................................................................................................293
cyg_drv_mutex_init ..................................................................................................................294
cyg_drv_mutex_destroy............................................................................................................294
cyg_drv_mutex_lock.................................................................................................................295
cyg_drv_mutex_trylock ............................................................................................................295
cyg_drv_mutex_unlock.............................................................................................................296
cyg_drv_mutex_release ............................................................................................................296
cyg_drv_cond_init ....................................................................................................................296
cyg_drv_cond_destroy..............................................................................................................297
cyg_drv_cond_wait...................................................................................................................297
cyg_drv_cond_signal................................................................................................................298
cyg_drv_cond_broadcast ..........................................................................................................298
cyg_drv_interrupt_create..........................................................................................................299
cyg_drv_interrupt_delete..........................................................................................................300
cyg_drv_interrupt_attach..........................................................................................................300
cyg_drv_interrupt_detach.........................................................................................................301
cyg_drv_interrupt_mask...........................................................................................................301
cyg_drv_interrupt_mask_intunsafe...........................................................................................301
cyg_drv_interrupt_unmask.......................................................................................................302
cyg_drv_interrupt_unmask_intunsafe.......................................................................................302
cyg_drv_interrupt_acknowledge...............................................................................................303
cyg_drv_interrupt_configure.....................................................................................................303
cyg_drv_interrupt_level............................................................................................................304
xv
cyg_drv_interrupt_set_cpu .......................................................................................................304
cyg_drv_interrupt_get_cpu.......................................................................................................305
cyg_ISR_t .................................................................................................................................305
cyg_DSR_t................................................................................................................................306
VI. File System Support Infrastructure.............................................................................................................309
19. Introduction............................................................................................................................................311
20. File System Table...................................................................................................................................313
21. Mount Table ...........................................................................................................................................315
22. File Table................................................................................................................................................317
23. Directories..............................................................................................................................................319
24. Synchronization .....................................................................................................................................321
25. Initialization and Mounting....................................................................................................................323
26. Sockets ...................................................................................................................................................325
27. Select......................................................................................................................................................327
28. Devices...................................................................................................................................................329
29. Writing a New Filesystem......................................................................................................................331
VII. PCI Library..................................................................................................................................................335
30. The eCos PCI Library ............................................................................................................................337
PCI Library.........................................................................................................................................337
PCI Overview............................................................................................................................337
Initializing the bus.....................................................................................................................337
Scanning for devices.................................................................................................................337
Generic config information.......................................................................................................338
Specific config information.......................................................................................................339
Allocating memory ...................................................................................................................339
Interrupts...................................................................................................................................340
Activating a device....................................................................................................................340
Links .........................................................................................................................................341
PCI Library reference.........................................................................................................................341
PCI Library API........................................................................................................................341
Definitions.................................................................................................................................342
Types and data structures..........................................................................................................342
Functions...................................................................................................................................342
Resource allocation...................................................................................................................344
PCI Library Hardware API.......................................................................................................345
HAL PCI support......................................................................................................................346
VIII. eCos POSIX compatibility layer...............................................................................................................349
31. POSIX Standard Support .......................................................................................................................351
Process Primitives [POSIX Section 3] ...............................................................................................351
Functions Implemented.............................................................................................................351
Functions Omitted.....................................................................................................................352
Notes.........................................................................................................................................352
Process Environment [POSIX Section 4]...........................................................................................352
Functions Implemented.............................................................................................................352
Functions Omitted.....................................................................................................................353
Notes.........................................................................................................................................353
Files and Directories [POSIX Section 5]............................................................................................354
xvi
Functions Implemented.............................................................................................................354
Functions Omitted.....................................................................................................................354
Notes.........................................................................................................................................354
Input and Output [POSIX Section 6]..................................................................................................355
Functions Implemented.............................................................................................................355
Functions Omitted.....................................................................................................................355
Notes.........................................................................................................................................355
Device and Class Specific Functions [POSIX Section 7]...................................................................355
Functions Implemented.............................................................................................................355
Functions Omitted.....................................................................................................................356
Notes.........................................................................................................................................356
C Language Services [POSIX Section 8]...........................................................................................356
Functions Implemented.............................................................................................................356
Functions Omitted.....................................................................................................................357
Notes.........................................................................................................................................357
System Databases [POSIX Section 9]................................................................................................357
Functions Implemented.............................................................................................................357
Functions Omitted.....................................................................................................................357
Notes.........................................................................................................................................357
Data Interchange Format [POSIX Section 10]...................................................................................358
Synchronization [POSIX Section 11].................................................................................................358
Functions Implemented.............................................................................................................358
Functions Omitted.....................................................................................................................358
Notes.........................................................................................................................................359
Memory Management [POSIX Section 12].......................................................................................359
Functions Implemented.............................................................................................................359
Functions Omitted.....................................................................................................................359
Notes.........................................................................................................................................359
Execution Scheduling [POSIX Section 13]........................................................................................360
Functions Implemented.............................................................................................................360
Functions Omitted.....................................................................................................................360
Notes.........................................................................................................................................360
Clocks and Timers [POSIX Section 14].............................................................................................361
Functions Implemented.............................................................................................................361
Functions Omitted.....................................................................................................................361
Notes.........................................................................................................................................361
Message Passing [POSIX Section 15]................................................................................................362
Functions Implemented.............................................................................................................362
Functions Omitted.....................................................................................................................362
Notes.........................................................................................................................................362
Thread Management [POSIX Section 16]..........................................................................................362
Functions Implemented.............................................................................................................363
Functions Omitted.....................................................................................................................363
Notes.........................................................................................................................................363
Thread-Specific Data [POSIX Section 17].........................................................................................364
Functions Implemented.............................................................................................................364
Functions Omitted.....................................................................................................................364
Notes.........................................................................................................................................364
xvii
Thread Cancellation [POSIX Section 18] ..........................................................................................364
Functions Implemented.............................................................................................................364
Functions Omitted.....................................................................................................................365
Notes.........................................................................................................................................365
Non-POSIX Functions........................................................................................................................365
General I/O Functions...............................................................................................................365
Socket Functions.......................................................................................................................365
Notes.........................................................................................................................................366
References and Bibliography.......................................................................................................................367
IX. µITRON .........................................................................................................................................................367
32. µITRON API..........................................................................................................................................369
Introduction to µITRON.....................................................................................................................369
µITRON and eCos..............................................................................................................................369
Task Management Functions..............................................................................................................370
Error checking...........................................................................................................................371
Task-Dependent Synchronization Functions......................................................................................372
Error checking...........................................................................................................................372
Synchronization and Communication Functions................................................................................373
Error checking...........................................................................................................................374
Extended Synchronization and Communication Functions ...............................................................375
Interrupt management functions.........................................................................................................375
Error checking...........................................................................................................................376
Memory pool Management Functions................................................................................................376
Error checking...........................................................................................................................378
Time Management Functions.............................................................................................................379
Error checking...........................................................................................................................379
System Management Functions..........................................................................................................380
Error checking...........................................................................................................................380
Network Support Functions................................................................................................................380
µITRON Configuration FAQ..............................................................................................................381
X. TCP/IP Stack Support for eCos.....................................................................................................................387
33. Ethernet Driver Design...........................................................................................................................389
34. Sample Code ..........................................................................................................................................391
35. Configuring IP Addresses ......................................................................................................................393
36. Tests and Demonstrations ......................................................................................................................395
Loopback tests....................................................................................................................................395
Building the Network Tests................................................................................................................395
Standalone Tests.................................................................................................................................395
Performance Test................................................................................................................................396
Interactive Tests..................................................................................................................................397
Maintenance Tools..............................................................................................................................398
37. Support Features ....................................................................................................................................401
TFTP...................................................................................................................................................401
DHCP .................................................................................................................................................401
38. TCP/IP Library Reference .....................................................................................................................403
getdomainname...................................................................................................................................403
gethostname........................................................................................................................................404
xviii
byteorder.............................................................................................................................................405
ethers...................................................................................................................................................407
getaddrinfo..........................................................................................................................................408
gethostbyname....................................................................................................................................414
getifaddrs............................................................................................................................................417
getnameinfo........................................................................................................................................418
getnetent .............................................................................................................................................422
getprotoent..........................................................................................................................................423
getrrsetbyname ...................................................................................................................................425
getservent............................................................................................................................................427
if_nametoindex...................................................................................................................................428
inet......................................................................................................................................................429
inet6_option_space.............................................................................................................................433
inet6_rthdr_space ...............................................................................................................................437
inet_net...............................................................................................................................................440
ipx.......................................................................................................................................................442
iso_addr ..............................................................................................................................................443
link_addr.............................................................................................................................................444
net_addrcmp.......................................................................................................................................445
ns.........................................................................................................................................................446
resolver...............................................................................................................................................447
accept..................................................................................................................................................450
bind.....................................................................................................................................................452
connect................................................................................................................................................453
getpeername........................................................................................................................................455
getsockname.......................................................................................................................................457
getsockopt...........................................................................................................................................458
ioctl.....................................................................................................................................................462
poll......................................................................................................................................................463
select...................................................................................................................................................465
send.....................................................................................................................................................467
shutdown.............................................................................................................................................470
socket..................................................................................................................................................471
socketpair............................................................................................................................................473
XI. FreeBSD TCP/IP Stack port for eCos.........................................................................................................475
39. Networking Stack Features....................................................................................................................477
40. Freebsd TCP/IP stack port .....................................................................................................................479
Targets ................................................................................................................................................479
Building the Network Stack ...............................................................................................................479
41. APIs........................................................................................................................................................481
Standard networking...........................................................................................................................481
Enhanced Select()...............................................................................................................................481
XII. OpenBSD TCP/IP Stack port for eCos......................................................................................................483
42. Networking Stack Features....................................................................................................................485
43. OpenBSD TCP/IP stack port..................................................................................................................487
Targets ................................................................................................................................................487
Building the Network Stack ...............................................................................................................487
xix
44. APIs........................................................................................................................................................489
Standard networking...........................................................................................................................489
Enhanced Select()...............................................................................................................................489
XIII. DNS for eCos and RedBoot .......................................................................................................................491
45. DNS........................................................................................................................................................493
DNS API.............................................................................................................................................493
XIV. Ethernet Device Drivers.............................................................................................................................495
46. Generic Ethernet Device Driver.............................................................................................................497
Generic Ethernet API .........................................................................................................................497
Review of the functions......................................................................................................................499
Init function...............................................................................................................................499
Start function.............................................................................................................................500
Stop function.............................................................................................................................500
Control function........................................................................................................................501
Can-send function.....................................................................................................................502
Send function............................................................................................................................502
Deliver function ........................................................................................................................503
Receive function .......................................................................................................................503
Poll function..............................................................................................................................504
Interrupt-vector function...........................................................................................................504
Upper Layer Functions.......................................................................................................................504
Callback Init function ...............................................................................................................505
Callback Tx-Done function.......................................................................................................505
Callback Receive function ........................................................................................................505
Calling graph for Transmission and Reception..................................................................................505
Transmission.............................................................................................................................505
Receive......................................................................................................................................506
XV. SNMP............................................................................................................................................................509
47. SNMP for eCos......................................................................................................................................511
Version................................................................................................................................................511
SNMP packages in the eCos source repository..................................................................................511
MIBs supported..................................................................................................................................511
Changes to eCos sources....................................................................................................................512
Starting the SNMP Agent...................................................................................................................512
Configuring eCos................................................................................................................................513
Version usage (v1, v2 or v3).....................................................................................................513
Traps..........................................................................................................................................514
snmpd.conf file........................................................................................................................514
Test cases............................................................................................................................................515
SNMP clients and package use...........................................................................................................516
Unimplemented features.....................................................................................................................516
MIB Compiler ....................................................................................................................................517
snmpd.conf .........................................................................................................................................518
xx
/