BIOS v6.33 Real-time Operating System User's Guide (Rev. K)

更新时间:2023-04-25 07:03:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

TI SYS/BIOS v6.33 Real-time Operating System User's Guide

Literature Number: SPRUEX3K

December 2011

SPRUEX3K—December 2011

Contents 2Submit Documentation Feedback

Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91About SYS/BIOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1.1What is SYS/BIOS? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.2How is SYS/BIOS Different from DSP/BIOS?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.3How are SYS/BIOS and XDCtools Related? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

1.3.1SYS/BIOS as a Set of Packages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

1.3.2Configuring SYS/BIOS Using XDCtools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

1.3.3XDCtools Modules and Runtime APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

1.4SYS/BIOS Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

1.5Using C++ with SYS/BIOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

1.5.1Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

1.5.2Name Mangling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

1.5.3Calling Class Methods from the Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

1.5.4Class Constructors and Destructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

1.6For More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

1.6.1Using the API Reference Help System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222SYS/BIOS Configuration and Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

2.1Creating a SYS/BIOS Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.1.1Adding SYS/BIOS Support to a Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

2.1.2Creating a Separate Configuration Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

2.2Configuring SYS/BIOS Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2.2.1Opening a Configuration File with XGCONF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

2.2.2Performing Tasks with XGCONF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

2.2.3Saving the Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

2.2.4About the XGCONF views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

2.2.5Using the Available Products View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

2.2.6Using the Outline View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

2.2.7Using the Property View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

2.2.8Using the Problems View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

2.2.9Finding and Fixing Errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

2.3Building SYS/BIOS Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

2.3.1Understanding the Build Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

2.3.2Rules for Working with CCS Project Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

2.3.3Building an Application with GCC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

2.3.4Running and Debugging an Application in CCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

2.3.5Compiler and Linker Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433

Threading Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

3.1SYS/BIOS Startup Sequence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

3.2Overview of Threading Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

3.2.1Types of Threads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

SPRUEX3K—December 2011Contents 3Submit Documentation Feedback 9f752a73f46527d3240ce0a5

Contents

3.2.2Choosing Which Types of Threads to Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503.2.3 A Comparison of Thread Characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513.2.4Thread Priorities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533.2.5Yielding and Preemption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543.2.6Hooks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.3

Hardware Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573.3.1Creating Hwi Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583.3.2Hardware Interrupt Nesting and System Stack Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593.3.3Hwi Hooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593.4

Software Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663.4.1Creating Swi Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663.4.2Setting Software Interrupt Priorities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673.4.3Software Interrupt Priorities and System Stack Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683.4.4Execution of Software Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693.4.5Using a Swi Object’s Trigger Variable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693.4.6Benefits and Tradeoffs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733.4.7Synchronizing Swi Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743.4.8Swi Hooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743.5

Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813.5.1Creating Tasks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823.5.2Task Execution States and Scheduling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833.5.3Task Stacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853.5.4Testing for Stack Overflow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 863.5.5Task Hooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 863.5.6Task Yielding for Time-Slice Scheduling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 933.6

The Idle Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 993.7

Example Using Hwi, Swi, and Task Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1004Synchronization Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

4.1Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

4.1.1Semaphore Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

4.2Event Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

4.2.1Implicitly Posted Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

4.3Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

4.3.1Preemption-Based Gate Implementations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

4.3.2Semaphore-Based Gate Implementations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

4.3.3Priority Inversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

4.4Mailboxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

4.5Queues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

4.5.1Basic FIFO Operation of a Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

4.5.2Iterating Over a Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

4.5.3Inserting and Removing Queue Elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

4.5.4Atomic Queue Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

5Timing Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

5.1Overview of Timing Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

5.2Clock. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

5.3Timer Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

5.4Timestamp Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

4Contents SPRUEX3K—December 2011Submit Documentation Feedback Contents

9f752a73f46527d3240ce0a5

6Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

6.1Background. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

6.2Memory Map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

6.2.1Choosing an Available Platform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

6.2.2Creating a Custom Platform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

6.3Placing Sections into Memory Segments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

6.3.1Configuring Simple Section Placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

6.3.2Configuring Section Placement Using a SectionSpec. . . . . . . . . . . . . . . . . . . . . . . . . . . 139

6.3.3Providing a Supplemental Linker Command File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

6.3.4Default Linker Command File and Customization Options . . . . . . . . . . . . . . . . . . . . . . . 141

6.4Sections and Memory Mapping for MSP430, Stellaris M3, and C28x . . . . . . . . . . . . . . . . . . . . . 142

6.5Stacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

6.5.1System Stack. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

6.5.2Task Stacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

6.5.3ROV for System Stacks and Task Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

6.6Cache Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

6.6.1Configure Cache Size Registers at Startup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

6.6.2Configure Parameters to Set MAR Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

6.6.3Cache Runtime APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

6.7Dynamic Memory Allocation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

6.7.1Memory Policy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

6.7.2Specifying the Default System Heap. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

6.7.3Using the xdc.runtime.Memory Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

6.7.4Specifying a Heap for Module Dynamic Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

6.7.5Using malloc() and free(). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

6.8Heap Implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

6.8.1HeapMem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

6.8.2HeapBuf. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

6.8.3HeapMultiBuf. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

7Hardware Abstraction Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

7.1Hardware Abstraction Layer APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

7.2HWI Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

7.2.1Associating a C Function with a System Interrupt Source. . . . . . . . . . . . . . . . . . . . . . . . 157

7.2.2Hwi Instance Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

7.2.3Creating a Hwi Object Using Non-Default Instance Configuration Parameters. . . . . . . . 158

7.2.4Enabling and Disabling Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

7.2.5 A Simple Example Hwi Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

7.2.6The Interrupt Dispatcher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

7.2.7Registers Saved and Restored by the Interrupt Dispatcher. . . . . . . . . . . . . . . . . . . . . . . 162

7.2.8Additional Target/Device-Specific Hwi Module Functionality. . . . . . . . . . . . . . . . . . . . . . 162

7.3Timer Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

7.3.1Target/Device-Specific Timer Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

7.4Cache Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

7.4.1Cache Interface Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

7.5HAL Package Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1708Instrumentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

8.1Overview of Instrumentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

8.2Load Module. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

SPRUEX3K—December 2011Contents 5Submit Documentation Feedback 9f752a73f46527d3240ce0a5

Contents

8.2.1Load Module Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1758.2.2Obtaining Load Statistics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1758.3

Error Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1768.4

Instrumentation Tools in Code Composer Studio. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1778.5

RTA Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1788.5.1Getting Log Data from a Halted Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1798.5.2Automatic System Logging Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1798.6

RTA Tools in CCS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1808.6.1Raw Logs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1818.6.2Printf Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1828.6.3Exec Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1838.6.4Exec Graph Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1858.6.5CPU Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1858.6.6Thread Load. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1868.6.7CPU Load Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1868.6.8RTA Control Panel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1878.7Performance Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

8.7.1Configuring Logging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

8.7.2Configuring Diagnostics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

8.7.3Choosing a Heap Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

8.7.4Hwi Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

8.7.5Stack Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

9Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

9.1Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

9.2Configuring Drivers in the Device Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

9.2.1Configuring the GIO Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

9.3Using GIO APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

9.3.1Constraints When Using GIO APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

9.3.2Creating and Deleting GIO Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

9.3.3Using GIO_read() and GIO_write() — The Standard Model . . . . . . . . . . . . . . . . . . . . . . 201

9.3.4Using GIO_issue(), GIO_reclaim(), and GIO_prime() — The Issue/Reclaim Model . . . . 203

9.3.5GIO_abort() and Error Handling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

9.4Using GIO in Various Thread Contexts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

9.4.1Using GIO with Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

9.4.2Using GIO with Swis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

9.4.3Using GIO with Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

9.5GIO and Synchronization Mechanisms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

9.5.1Using GIO with Generic Callbacks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

A Rebuilding SYS/BIOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

A.1Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

A.2Prerequisites. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

A.3Building SYS/BIOS Using the bios.mak Makefile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

A.4Building Your Project Using a Rebuilt SYS/BIOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213B

Timing Benchmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

B.1Timing Benchmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

B.2Interrupt Latency. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

B.3Hwi-Hardware Interrupt Benchmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

6Contents SPRUEX3K—December 2011Submit Documentation Feedback Contents

9f752a73f46527d3240ce0a5

B.4

Swi-Software Interrupt Benchmarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217B.5

Task Benchmarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218B.6

Semaphore Benchmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220C Size Benchmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223

C.1Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

C.2Comparison to DSP/BIOS 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

C.3Default Configuration Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

C.4Static Module Application Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

C.4.1Hwi Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

C.4.2Clock Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

C.4.3Clock Object Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

C.4.4Swi Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

C.4.5Swi Object Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

C.4.6Task Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

C.4.7Task Object Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228

C.4.8Semaphore Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228

C.4.9Semaphore Object Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228

C.4.10Memory Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

C.5Dynamic Module Application Sizes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230

C.5.1Dynamic Task Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230

C.5.2Dynamic Semaphore Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230

C.6Timing Application Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230D Minimizing the Application Footprint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

D.1Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

D.2Reducing Data Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

D.2.1Removing the malloc Heap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

D.2.2Reducing Space for Arguments to main() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

D.2.3Reducing the Size of Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

D.2.4Disabling Named Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

D.2.5Leaving Text Strings Off the Target. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

D.2.6Disabling the Module Function Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

D.2.7Reduce the Number of atexit Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

D.3Reducing Code Size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

D.3.1Use the Custom Build SYS/BIOS Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

D.3.2Disabling Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

D.3.3Setting Memory Policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

D.3.4Disabling Core Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

D.3.5Eliminating printf() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

D.3.6Disabling RTS Thread Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

D.3.7Disable Task Stack Overrun Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

D.4Basic Size Benchmark Configuration Script. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236E IOM Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

E.1Mini-Driver Interface Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

9f752a73f46527d3240ce0a5

List of Figures

3-1Thread Priorities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3-2Preemption Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 3-3Using Swi_inc() to Post a Swi. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 3-4Using Swi_andn() to Post a Swi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 3-5Using Swi_dec() to Post a Swi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 3-6Using Swi_or() to Post a Swi.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 3-7Execution Mode Variations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 4-1Trace Window Results from Example 4-4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 B–1 Hardware Interrupt to Blocked Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 B–2 Hardware Interrupt to Software Interrupt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 B–3 Post of Software Interrupt Again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 B–4 Post Software Interrupt without Context Switch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 B–5 Post Software Interrupt with Context Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 B–6 Create a New Task without Context Switch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 B–7 Create a New Task with Context Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 B–8 Set a Task's Priority without a Context Switch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 B–9 Lower the Current Task's Priority, Context Switch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 B–10 Raise a Ready Task's Priority, Context Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 B–11 Task Yield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 B–12 Post Semaphore, No Waiting Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 B–13 Post Semaphore, No Context Switch. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 B–14 Post Semaphore with Task Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 B–15 Pend on Semaphore, No Context Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 B–16 Pend on Semaphore with Task Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

SPRUEX3K—December 20117 Submit Documentation Feedback

9f752a73f46527d3240ce0a5

List of Tables

1–1XDCtools Modules Using in C Code and Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 1–2Packages and Modules Provided by SYS/BIOS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3-1Comparison of Thread Characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 3-2Thread Preemption. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 3–3Hook Functions by Thread Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3–4System Stack Use for Hwi Nesting by Target Family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 3–5System Stack Use for Swi Nesting by Target Family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 3-6Swi Object Function Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 3–7Task Stack Use by Target Family . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 5–1Timeline for One-shot and Continuous Clocks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 6–1Heap Implementation Comparison. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 7–1Proxy to Delegate Mappings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 C–1Comparison of Benchmark Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

8 SPRUEX3K—December 2011

Submit Documentation Feedback

SPRUEX3K—December 2011

Read This First 9Submit Documentation Feedback Preface

SPRUEX3K—December 2011

Read This First

About This Manual

This manual describes the TI SYS/BIOS Real-time Operating System, which is also called "SYS/BIOS". The latest version number as of the publication of this manual is SYS/BIOS 6.33.01. Versions of

SYS/BIOS prior to 6.30 were called DSP/BIOS. The new name reflects that this operating system can also be use on processors other than DSPs.

SYS/BIOS gives developers of mainstream applications on Texas Instruments devices the ability to develop embedded real-time software. SYS/BIOS provides a small firmware real-time library and easy-to-use tools for real-time tracing and analysis.

Notational Conventions

This document uses the following conventions:

?Program listings, program examples, and interactive displays are shown in a special typeface.

Examples use a bold version of the special typeface for emphasis.

Here is a sample program listing:

?Square brackets ( [ and ] ) identify an optional parameter. If you use an optional parameter, you

specify the information within the brackets. Unless the square brackets are in a bold typeface, do not enter the brackets themselves.

Related Documentation From Texas Instruments

See the detailed list and links in Section 1.6.

Related Documentation

You can use the following books to supplement this reference guide:

The C Programming Language (second edition), by Brian W. Kernighan and Dennis M. Ritchie, published by Prentice-Hall, Englewood Cliffs, New Jersey, 1988

Programming in C , Kochan, Steve G., Hayden Book Company

Programming Embedded Systems in C and C++, by Michael Barr, Andy Oram (Editor), published by O'Reilly & Associates; ISBN: 1565923545, February 1999

Real-Time Systems , by Jane W. S. Liu, published by Prentice Hall; ISBN: 013099651, June 2000 #include

int main(){

System_printf("Hello World!\n");

return (0);

}

10Read This First SPRUEX3K—December 2011Submit Documentation Feedback Trademarks

9f752a73f46527d3240ce0a5

Principles of Concurrent and Distributed Programming (Prentice Hall International Series in

Computer Science), by M. Ben-Ari, published by Prentice Hall; ISBN: 013711821X, May 1990

American National Standard for Information Systems-Programming Language C X3.159-1989, American National Standards Institute (ANSI standard for C); (out of print)

Trademarks

The Texas Instruments logo and Texas Instruments are registered trademarks of Texas Instruments. Trademarks of Texas Instruments include: TI, Code Composer, Code Composer Studio, DSP/BIOS, SPOX, TMS320, TMS320C54x, TMS320C55x, TMS320C62x, TMS320C64x, TMS320C67x,

TMS320C28x, TMS320C5000, TMS320C6000 and TMS320C2000.

Windows is a registered trademark of Microsoft Corporation.

Linux is a registered trademark of Linus Torvalds.

All other brand or product names are trademarks or registered trademarks of their respective companies or organizations.

December 22, 2011

SPRUEX3K—December 2011

About SYS/BIOS 11Submit Documentation Feedback Chapter 1

SPRUEX3K—December 2011

About SYS/BIOS

This chapter provides an overview of SYS/BIOS and describes its relationship to XDCtools. 1.1What is SYS/BIOS?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.2How is SYS/BIOS Different from DSP/BIOS? . . . . . . . . . . . . . . . . . . . 12

1.3How are SYS/BIOS and XDCtools Related? . . . . . . . . . . . . . . . . . . . . 13

1.4SYS/BIOS Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

1.5Using C++ with SYS/BIOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

1.6

For More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Topic

Page

12About SYS/BIOS SPRUEX3K—December 2011Submit Documentation Feedback What is SYS/BIOS?

9f752a73f46527d3240ce0a5

1.1What is SYS/BIOS?

SYS/BIOS is a scalable real-time kernel. It is designed to be used by applications that require real-time scheduling and synchronization or real-time instrumentation. SYS/BIOS provides preemptive multi-

threading, hardware abstraction, real-time analysis, and configuration tools. SYS/BIOS is designed to minimize memory and CPU requirements on the target. See the video introducing SYS/BIOS for an

overview.

SYS/BIOS provides the following benefits:

?

All SYS/BIOS objects can be configured statically or dynamically. ?

To minimize memory size, the APIs are modularized so that only those APIs that are used by the program need to be bound into the executable program. In addition, statically-configured objects reduce code size by eliminating the need to include object creation calls.?

Error checking and debug instrumentation is configurable and can be completely removed from production code versions to maximize performance and minimize memory size.?

Almost all system calls provide deterministic performance to enable applications to reliably meet real-time deadlines.?

To improve performance, instrumentation data (such as logs and traces) is formatted on the host.?

The threading model provides thread types for a variety of situations. Hardware interrupts, software interrupts, tasks, idle functions, and periodic functions are all supported. You can control the priorities and blocking characteristics of threads through your choice of thread types.?

Structures to support communication and synchronization between threads are provided. These include semaphores, mailboxes, events, gates, and variable-length messaging.?

Dynamic memory management services offering both variable-sized and fixed-sized block allocation.?

An interrupt dispatcher handles low-level context save/restore operations and enables interrupt service routines to be written entirely in C.

?System services support the enabling/disabling of interrupts and the plugging of interrupt vectors,

including multiplexing interrupt vectors onto multiple sources.

1.2How is SYS/BIOS Different from DSP/BIOS?

This book describes SYS/BIOS 6.x, a release that introduced significant changes from DSP/BIOS 5.x. If you have used previous versions, you will encounter these major changes to basic functionality:

?

The name DSP/BIOS has been changed to SYS/BIOS to reflect the fact that it can be used on processors other than DSPs.?

SYS/BIOS uses the configuration technology in XDCtools. For more information, see Section 1.3 of this book.

?The APIs have changed. A compatibility layer ensures that DSP/BIOS 5.4x or earlier applications will

work unmodified. However, note that the PIP module is no longer supported. For details, see the

Migrating a DSP/BIOS 5 Application to SYS/BIOS 6 (SPRAAS7A) application note.

In addition, significant enhancements have been made in the areas that include the following:

?Up to 32 priority levels are available for both tasks and software interrupt (Swi) threads.

SPRUEX3K—December 2011About SYS/BIOS 13Submit Documentation Feedback 9f752a73f46527d3240ce0a5

How are SYS/BIOS and XDCtools Related?

?

A new timer module is provided that enables applications to configure and use timers directly rather than have time-driven events limited to using the system tick.?

All kernel objects may be created statically or dynamically.?

An additional heap manager, called HeapMultiBuf, enables fast, deterministic variable-sized memory allocation performance that does not degrade regardless of memory fragmentation.?

A more flexible memory manager supports the use of multiple, concurrent heaps and enables developers to easily add custom heaps.?

A new Event object enables tasks to pend on multiple events, including semaphores, mailboxes, message queues, and user-defined events.?

An additional Gate object supports priority inheritance.?

Hook functions are supported for hardware and software interrupt objects as well as tasks.?

An option is provided to build the operating system with parameter checking APIs that assert if invalid parameter values are passed to a system call.

? A standardized method allows SYS/BIOS APIs to handle errors, based on an error block approach.

This enables errors to be handled efficiently without requiring the application to catch return codes.

In addition, you can easily have the application halted whenever a SYS/BIOS error occurs, because

all errors now pass through a single handler.

?The system log and execution graph in the Real-Time Analysis (RTA) tools support both dynamically

and statically-created tasks.

?More powerful logging functions include a timestamp, up to 6 words per log entry, and the ability for

logging events to span more than one log if additional storage is required.

?

Per-task CPU load is now supported in addition to total CPU load.1.3How are SYS/BIOS and XDCtools Related?

XDCtools is a separate software component provided by Texas Instruments that provides the underlying tooling needed by SYS/BIOS. You must have both XDCtools and SYS/BIOS installed in order to use SYS/BIOS. The SYS/BIOS release notes in the top-level SYS/BIOS installation directory provide

information about the versions of XDCtools that are compatible with your version of SYS/BIOS. Typically, when you install a new version of SYS/BIOS, you will also need to install a new version of XDCtools.XDCtools is important to SYS/BIOS users because:

?

XDCtools provides the technology that users use to configure the SYS/BIOS and XDCtools modules used by the application. See Section 1.3.2.?

XDCtools provides the tools used to build the configuration file. This build step generates source code files that are then compiled and linked with your application code. See Section 1.3.2.

?XDCtools provides a number of modules and runtime APIs that SYS/BIOS leverages for memory

allocation, logging, system control, and more. See Section 1.3.3.

XDCtools is sometimes referred to as "RTSC" (pronounced "rit-see"—Real Time Software Components), which is the name for the open-source project within the 9f752a73f46527d3240ce0a5 ecosystem for providing reusable software components (called "packages") for use in embedded systems. For documentation about

XDCtools modules, see the online help within CCS. For information about packaging of reusable

software components and details about the tooling portion of XDCtools, see the RTSC-pedia web site .

14About SYS/BIOS SPRUEX3K—December 2011Submit Documentation Feedback How are SYS/BIOS and XDCtools Related?

9f752a73f46527d3240ce0a5

1.3.1SYS/BIOS as a Set of Packages

SYS/BIOS and XDCtools are sets of "packages," each of which delivers a subset of the product's

functionality. XDCtools uses a naming convention for packages to aid readability and to ensure that

packages delivered from different sources don't have namespace collisions that will pose problems for the system integrator. If you are familiar with the Java package naming convention, you will find it to be quite similar.

SYS/BIOS packages conform to this convention with names that consist of a hierarchical naming pattern; each level is separated by a period ("."). Usually, the highest level of the name is the vendor ("ti"), followed by the product ("sysbios"), and then followed by the module and submodule names (for example, "knl").These names have the added benefit of reflecting the physical layout of the package within the file system where SYS/BIOS has been installed. For example, the ti.sysbios.knl package files can be found in the following folder:

See Section 1.4 for a partial list of the packages provided by SYS/BIOS and Section 1.3.3 for a partial list of the modules provided by XDCtools.

You can picture the architecture of the tools used to create applications as shown in the following figure. The xdc.runtime package provided by XDCtools contains modules and APIs your application can use along with the modules and APIs in SYS/BIOS.BIOS_INSTALL_DIR\bios_6_3#_##\packages\ti\sysbios\knl

SPRUEX3K—December 2011About SYS/BIOS 15Submit Documentation Feedback 9f752a73f46527d3240ce0a5

How are SYS/BIOS and XDCtools Related?

1.3.2Configuring SYS/BIOS Using XDCtools

Configuration is an essential part of using SYS/BIOS and is used for the following purposes:

?

It specifies the modules and packages that will be used by the application.?

It can statically create objects for the modules that are used by the application. ?

It validates the set of modules used explicitly and implicitly to make sure they are compatible.

?It statically sets parameters for the system, modules, and objects to change their runtime behavior.

An application's configuration is stored in one or more script files with a file extension of *.cfg. These are parsed by XDCtools to generate corresponding C source code, C header, and linker command files that are then compiled and linked into the end application. The following diagram depicts a build flow for a typical SYS/BIOS application.

The configuration .cfg file uses simple JavaScript syntax to set properties and call methods provided by objects. The combination of JavaScript and the script objects provided by XDCtools is referred to as an XDCscript.

You can create and modify a configuration file in two different ways:

?

Writing the textual .cfg file directly with a text editor or the XDCscript Editor in CCS.

?

Using the visual configuration tool (XGCONF) embedded in CCS.

16About SYS/BIOS SPRUEX3K—December 2011Submit Documentation Feedback How are SYS/BIOS and XDCtools Related?

9f752a73f46527d3240ce0a5

The following figure shows the XGCONF configuration tool in CCS being used to configure a static

SYS/BIOS Task instance. You can see this configuration for yourself in the "Static Example" SYS/BIOS project template in CCS. See Section 2.1 for how to create a CCS project using a SYS/BIOS template.The Task instance named "task0" set up in the configuration tool corresponds to the following XDCscript code:var Task = 9f752a73f46527d3240ce0a5eModule('ti.sysbios.knl.Task');Task.numPriorities = 16;

Task.idleTaskStackSize = 1024;var tskParams = new Task.Params;

tskParams.arg0 = 1;

tskParams.arg1 = 2;

tskParams.priority = 15;

tskParams.stack = null;

tskParams.stackSize = 1024;

var task0 = Task.create('&task0Fxn', tskParams);

SPRUEX3K—December 2011About SYS/BIOS 17Submit Documentation Feedback 9f752a73f46527d3240ce0a5

How are SYS/BIOS and XDCtools Related?

1.3.3XDCtools Modules and Runtime APIs

XDCtools contains several modules that provide basic system services your SYS/BIOS application will need to operate successfully. Most of these modules are located in the xdc.runtime package in XDCtools. By default, all SYS/BIOS applications automatically add the xdc.runtime package during build time.

The functionality provided by XDCtools for use in your C code and configuration file can be roughly

pided into four categories. The modules listed in the following table are in the xdc.runtime package, unless otherwise noted.

Table 1–1. XDCtools Modules Using in C Code and Configuration

Category

Modules Description System Services System Basic low-level "system" services. For example, character output,

printf-like output, and exit handling. See Section 8.3. Proxies that

plug into this module include xdc.runtime.SysMin and

xdc.runtime.SysStd. See Section D.4.

Startup Allows functions defined by different modules to be run before

main(). See Section 3.1.

Defaults Sets event logging, assertion checking, and memory use options for

all modules for which you do not explicitly set a value. See Section

6.7.1 and Section 8.7.1.1.

Main Sets event logging and assertion checking options that apply to your

application code.

Program Sets options for runtime memory sizes, program build options, and

memory sections and segments. This module is used as the "root"

for the configuration object model. This module is in the xdc.cfg

package. See Section 3.3.1 and Section 6.3.2.

Memory Management Memory Creates/frees memory heaps statically or dynamically. SeeSection

6.7.3.

Diagnostics Log and Loggers Allows events to be logged and then passes those events to a Log

handler. Proxies that plug into this module include

xdc.runtime.LoggerBuf and xdc.runtime.LoggerSys. See Section

8.2.1 and Section 3.5.4.

Error Allows raising, checking, and handling errors defined by any

modules. See Section 8.3.

Diags Allows diagnostics to be enabled/disabled at either configuration- or

runtime on a per-module basis. See Section 8.7.1.

Timestamp and Providers Provides time-stamping APIs that forward calls to a platform-specific

time stamper (or one provided by CCS). See Section 5.4,

Text Provides string management services to minimize the string data

required on the target. See Section D.2.5.

Synchronization Gate Protects against concurrent access to critical data structures. See

Section 4.3.

Sync

Provides basic synchronization between threads using wait() and signal() functions. See Section 9.5.

18About SYS/BIOS SPRUEX3K—December 2011Submit Documentation Feedback SYS/BIOS Packages

9f752a73f46527d3240ce0a5

1.4SYS/BIOS Packages

SYS/BIOS provides the following packages:

Table 1–2. Packages and Modules Provided by SYS/BIOS

1.5Using C++ with SYS/BIOS

SYS/BIOS applications can be written in C or C++. An understanding of several issues regarding C++ and SYS/BIOS can help to make C++ application development proceed smoothly. These issues concern memory management, name mangling, calling class methods from configured properties, and special considerations for class constructors and destructors.

SYS/BIOS provides an example that is written in C++. The example code is in the bigtime.cpp file in the packages\ti\sysbios\examples\generic\bigtime directory of the SYS/BIOS installation.

1.5.1Memory Management

The functions new and delete are the C++ operators for dynamic memory allocation and deallocation. For TI targets, these operators use malloc() and free(). SYS/BIOS provides reentrant versions of malloc() and free() that internally use the xdc.runtime.Memory module and (by default) the

ti.sysbios.heaps.HeapMem module.

Package

Description ti.sysbios.benchmarks

Contains specifications for benchmark tests. Provides no modules, APIs, or configuration. See Appendix B .ti.sysbios.family.*

Contains specifications for target/device-specific functions. See Section 7.5.ti.sysbios.gates Contains several implementations of the IGateProvider interface for use in various

situations. These include GateHwi, GateSwi, GateTask, GateMutex, and GateMu-

texPri. See Section 4.3.

ti.sysbios.hal Contains Hwi, Timer, and Cache modules. See Section 7.2, Section 7.3, and

Section 7.4.

ti.sysbios.heaps Provides several implementations of the XDCtools IHeap interface. These include

HeapBuf (fixed-size buffers), HeapMem (variable-sized buffers), and HeapMultiBuf

(multiple fixed-size buffers). See Chapter 6.

ti.sysbios.interfaces Contains interfaces for modules to be implemented, for example, on a device or

platform basis.

ti.sysbios.io Contains modules for performing input/output actions and interacting with peripheral

drivers. Chapter 9.

ti.sysbios.knl Contains modules for the SYS/BIOS kernel, including Swi, Task, Idle, and Clock.

See Chapter 3 and Chapter 5. Also contains modules related to inter-process

communication: Event, Mailbox, and Semaphore. See Chapter 4.

ti.sysbios.utils

Contains the Load module, which provides global CPU load as well as thread-specific load. See Section 8.2.

SPRUEX3K—December 2011About SYS/BIOS 19Submit Documentation Feedback 9f752a73f46527d3240ce0a5

Using C++ with SYS/BIOS

1.5.2Name Mangling

The C++ compiler implements function overloading, operator overloading, and type-safe linking by

encoding a function's signature in its link-level name. The process of encoding the signature into the linkname is referred to as name mangling.

Name mangling could potentially interfere with a SYS/BIOS application since you use function names within the configuration to refer to functions declared in your C++ source files. To prevent name mangling and thus to make your functions recognizable within the configuration, it is necessary to declare your functions in an extern C block as shown in the following code fragment from the bigtime.cpp example:This extern C block allows you to refer to the functions within the configuration file. For example, if you have a Task object that should run clockTask() every time the Task runs, you could configure a Task as follows:

Notice that in the configuration example above, the arg0 parameter of the Task is set to

$externPtr("cl3"). The C++ code to create a global clock object for this argument is as follows:

Functions declared within the extern C block are not subject to name mangling. Since function

overloading is accomplished through name mangling, function overloading has limitations for functions that are called from the configuration. Only one version of an overloaded function can appear within the extern C block. The code in the following example would result in an error.

While you can use name overloading in your SYS/BIOS C++ applications, only one version of the

overloaded function can be called from the configuration./*

* Extern "C" block to prevent name mangling

* of functions called within the Configuration Tool

*/extern "C" {

/* Wrapper functions to call Clock::tick() */

void clockTask(Clock clock);

void clockPrd(Clock clock); void clockIdle(void);

} // end extern "C"

var task0Params = new Task.Params();

9f752a73f46527d3240ce0a5 = "task0";task0Params.arg0 = $externPtr("cl3");

Program.global.task0 = Task.create("&clockTask", task0Params);

/* Global clock objects */

Clock cl3(3); /* task clock */

extern “C” { // Example causes ERROR

Int addNums(Int x, Int y);

Int addNums(Int x, Int y, Int z); // error, only one version

// of addNums is allowed

}

20About SYS/BIOS SPRUEX3K—December 2011Submit Documentation Feedback Using C++ with SYS/BIOS

9f752a73f46527d3240ce0a5

Default parameters is a C++ feature that is not available for functions called from the configuration. C++ allows you to specify default values for formal parameters within the function declaration. However, a function called from the configuration must provide parameter values. If no values are specified, the actual parameter values are undefined.

1.5.3Calling Class Methods from the Configuration

Often, the function that you want to reference within the configuration is the member function of a class object. It is not possible to call these member functions directly from the configuration, but it is possible to accomplish the same action through wrapper functions. By writing a wrapper function which accepts a class instance as a parameter, you can invoke the class member function from within the wrapper.

A wrapper function for a class method is shown in the following code fragment from the bigtime.cpp

example:

Any additional parameters that the class method requires can be passed to the wrapper function.

1.5.4Class Constructors and Destructors

Any time that a C++ class object is instantiated, the class constructor executes. Likewise, any time that a class object is deleted, the class destructor is called. Therefore, when writing constructors and

destructors, you should consider the times at which the functions are expected to execute and tailor them accordingly. It is important to consider what type of thread will be running when the class constructor or destructor is invoked.

Various guidelines apply to which SYS/BIOS API functions can be called from different SYS/BIOS

threads (tasks, software interrupts, and hardware interrupts). For example, memory allocation APIs such as Memory_alloc() and Memory_calloc() cannot be called from within the context of a software interrupt. Thus, if a particular class is instantiated by a software interrupt, its constructor must avoid performing memory allocation.

Similarly, it is important to keep in mind the time at which a class destructor is expected to run. Not only does a class destructor execute when an object is explicitly deleted, but also when a local object goes out of scope. You need to be aware of what type of thread is executing when the class destructor is called and make only those SYS/BIOS API calls that are appropriate for that thread. For further information on function callability, see the CDOC online documentation./*

* ======== clockPrd ========

* Wrapper function for PRD objects calling

* Clock::tick()

*/

void clockPrd(Clock clock)

{

clock.tick();

return;

}

SPRUEX3K—December 2011About SYS/BIOS 21Submit Documentation Feedback 9f752a73f46527d3240ce0a5

For More Information

1.6For More Information

You can read the following additional documents to learn more about SYS/BIOS, XDCtools, and Code Composer Studio:

?SYS/BIOS

—SYS/BIOS Release Notes . Located in the top-level SYS/BIOS installation directory, or choose

Help > Help Contents in CCSv5.1 and expand the SYS/BIOS item.

—SYS/BIOS Getting Started Guide . In /docs/Bios_Getting_Started_Guide.pdf

—SYS/BIOS API Reference (also called "CDOC"). Run /docs/cdoc/index, or

choose Help > Help Contents in CCSv5.1 and expand the SYS/BIOS item. See Section 1.6.1.

—Migrating a DSP/BIOS 5 Application to SYS/BIOS 6 (SPRAAS7). In /docs/

Bios_Legacy_App_Note.pdf, or choose Help > Help Contents in CCSv5.1 and expand the

SYS/BIOS item. Also available on the Texas Instruments website .

—SYS/BIOS main page on TI Embedded Processors Wiki contains links to many SYS/BIOS

resources.

—BIOS forum on TI’s E2E Community lets you submit your questions.

—SYS/BIOS 6.x Product Folder on 9f752a73f46527d3240ce0a5

—Embedded Software Download Page

?XDCtools

—XDCtools API Reference (also called "CDOC"). Run /docs/xdctools.chm, or

choose Help > Help Contents in CCSv5.1 and expand the XDCtools item. See Section 1.6.1.

—RTSC-Pedia Wiki

—BIOS forum on TI’s E2E Community

—Embedded Software Download Page

?Code Composer Studio (CCS)

—CCS online help. Choose Help > Help Contents in CCSv5.1.

—CCSv5 on TI Embedded Processors Wiki

—Code Composer forum on TI’s E2E Community

本文来源:https://www.bwwdw.com/article/fjwq.html

Top