BACstac/32 v6.5
Porting Guide for Embedded
Platforms
Document Version: 1.0
Cimetrics, Inc.
141 Tremont Street, Floor 11
BOSTON, MASSACHUSETTS 02111
USA
TELEPHONE: +1 (617) 350-7550
FAX: +1 (617) 350-7552
E-MAIL: products@cimetrics.com (sales), support@cimetrics.com (tech. support)
WEB: http://www.cimetrics.com
BACstac/32 v6.5Porting Guide for Embedded Platforms
by Cimetrics, Inc.
Document Version: 1.0 Edition
Copyright © 1999-2012 Cimetrics, Inc.
BACstac and BACstac/32 are trademarks of Cimetrics Inc. BACnet is a registered trademark of the American Society of Heating, Refrigeration
and Air-Conditioning Engineers, Inc. (ASHRAE). LonTalk is a trademark of Echelon Corp. All other trademarks are owned by their respective
companies.
Table of Contents
1. Introduction...............................................................................................................................................................1
2. Source Code...............................................................................................................................................................2
Overview ...............................................................................................................................................................2
arch ..............................................................................................................................................................2
apil ...............................................................................................................................................................2
examples ......................................................................................................................................................2
include..........................................................................................................................................................3
test................................................................................................................................................................3
tsml ..............................................................................................................................................................3
dl ..................................................................................................................................................................3
nl ..................................................................................................................................................................3
osa ................................................................................................................................................................3
oslib..............................................................................................................................................................3
utils ..............................................................................................................................................................4
unit_test........................................................................................................................................................4
Build variables for makefiles.................................................................................................................................4
Steps to Build BACstac/32 on your Platform........................................................................................................8
3. How to Write the OSA............................................................................................................................................10
Terminology ........................................................................................................................................................10
OSA Initialization and Deinitialization...............................................................................................................11
OSAInit() ...................................................................................................................................................12
OSAClose()................................................................................................................................................12
Threads ................................................................................................................................................................13
General description....................................................................................................................................13
OSACreateThread() ...................................................................................................................................13
OSATerminateThread()..............................................................................................................................14
OSAWaitForThread().................................................................................................................................14
Semaphores .........................................................................................................................................................15
General description....................................................................................................................................15
OSAInitSemaphore() .................................................................................................................................15
OSAWaitForSemaphore() ..........................................................................................................................15
OSAReleaseSemaphore() ..........................................................................................................................16
OSADestroySemaphore() ..........................................................................................................................16
Recursive mutexes...............................................................................................................................................16
OSAInitRecursiveMutex().........................................................................................................................16
OSALockRecursiveMutex() ......................................................................................................................17
OSAUnlockRecursiveMutex()...................................................................................................................17
OSADestroyRecursiveMutex()..................................................................................................................17
Fast mutexes ........................................................................................................................................................18
OSAInitFastMutex() ..................................................................................................................................18
OSALockFastMutex() ...............................................................................................................................18
OSAUnlockFastMutex() ............................................................................................................................19
OSADestroyFastMutex() ...........................................................................................................................19
Atomic variables..................................................................................................................................................19
General description....................................................................................................................................19
OSAAtomicGet().......................................................................................................................................20
OSAAtomicSet()........................................................................................................................................20
iii
OSAAtomicInc()........................................................................................................................................20
OSAAtomicIncTest().................................................................................................................................20
OSAAtomicDec() ......................................................................................................................................20
OSAAtomicDecTest()................................................................................................................................21
OSAAtomicAdd()......................................................................................................................................21
OSAAtomicSub() ......................................................................................................................................21
Dynamic memory................................................................................................................................................21
General description....................................................................................................................................22
OSAAlloc()................................................................................................................................................22
OSAFree()..................................................................................................................................................22
Time.....................................................................................................................................................................22
General description....................................................................................................................................23
OSAGetTickCount() ..................................................................................................................................23
OSASleep()................................................................................................................................................23
System logging utilities.......................................................................................................................................23
General description....................................................................................................................................24
OSALogMessage() ....................................................................................................................................24
Byte ordering and floating point format utilities.................................................................................................25
General description....................................................................................................................................25
Cardinal byte order ....................................................................................................................................25
IEEE-754 compliance................................................................................................................................26
OSAFPClassify() .......................................................................................................................................26
OSAGenerateSpecFPValue() .....................................................................................................................27
Debugging support utilities .................................................................................................................................27
General description....................................................................................................................................27
OSAPanic()................................................................................................................................................27
4. How to Write the Configuration Module..............................................................................................................29
Using Configuration Structures...........................................................................................................................29
OSA Configuration..............................................................................................................................................29
Tuning Parameters...............................................................................................................................................30
5. How to Add a Data Link Layer .............................................................................................................................31
Abbreviations ......................................................................................................................................................31
What is a sub-DL?...............................................................................................................................................32
How Does the Sub-DL Operate?.........................................................................................................................34
System resources .......................................................................................................................................35
Interface with hardware .............................................................................................................................35
Sub-DL ⇔ DL-common interface.............................................................................................................36
Data Message ...................................................................................................................................36
Data Message Interface....................................................................................................................36
List of sub-DLs ................................................................................................................................42
Sub-DL operations ...........................................................................................................................42
Operation Init..........................................................................................................................43
Operation Close ......................................................................................................................43
Operation Accept....................................................................................................................44
Operation Bind .......................................................................................................................44
Operation Unbind ...................................................................................................................46
Operation SendTo...................................................................................................................46
Operations Connect and Disconnect ......................................................................................47
Operation Ioctl........................................................................................................................47
iv
Support functions .............................................................................................................................48
Null sub-DL example.......................................................................................................................49
Porting Ethernet Sub-DL.....................................................................................................................................52
Porting B/IP (Addendum A) Sub-DL..................................................................................................................60
Porting PTP Sub-DL ...........................................................................................................................................64
Porting ARCNET sub-DL...................................................................................................................................68
Porting MS/TP Sub-DL.......................................................................................................................................81
6. Building Unit Tests & Examples............................................................................................................................85
Building the Test Programs .................................................................................................................................85
OSA Tests............................................................................................................................................................85
Data Link Layer Tests .........................................................................................................................................86
Network Layer Test.............................................................................................................................................86
Example Server Application - FEEDBACK .......................................................................................................86
Example Client Application - DUMPALL..........................................................................................................87
v
评论1