summaryrefslogtreecommitdiff
path: root/ports/c667x/ccs/readme_threadx.txt
blob: 989f0b4926f440b555b952271e35ca71b86940b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
                  Microsoft's Azure RTOS ThreadX for TMS320C667x

                       Using the TI Code Composer Tools

1.  Installation

TI Code Composer Studio and the TI MCSDK must be installed prior to
building ThreadX. The following links can be used to download these
packages:


http://processors.wiki.ti.com/index.php/Download_CCS
http://software-dl.ti.com/sdoemb/sdoemb_public_sw/bios_mcsdk/latest/index_FDS.html

It is assumed the tools are installed in the default directories:

CCS path by default - c:\ti\ccsv(version number)
MCSDK path by default - c:\ti

If the packages are installed in different directories, the ThreadX project
settings must be adjusted.

2. Open the Azure RTOS Workspace

In order to build the ThreadX library and the ThreadX demonstration first open
the Azure RTOS Workspace inside your ThreadX installation directory.


3. Building the ThreadX run-time Library

Building the ThreadX library is easy; simply import the CCS project file
"tx" and then select the build button. You should now observe the compilation
and assembly of the ThreadX library. This project build produces the ThreadX
library file tx.lib.


4.  Demonstration System

The ThreadX demonstration is designed to execute on the C6678EVM evaluation board.

Building the demonstration is easy; simply import the "sample_threadx_c6678evm" project.
Now select "Project -> Build Active Project" to build the ThreadX demonstration,
which produces the sample_threadx.out file in the "Debug" directory. You are now
ready to run the ThreadX demonstration on the C6678EVM evaluation board.

Please refer to Chapter 6 of the ThreadX User Guide for a complete description
of this demonstration.


5.  System Initialization

The entry point in ThreadX for the TMS320C667x using the TI tools is at label
_c_int00. This is defined within the TI library. In addition, this is
where all static and global pre-set C variable initialization processing
takes place.

The ThreadX initialization file tx_initialize_low_level.asm is responsible
for setting up various system data structures, the vector area, and a periodic
timer interrupt source. By default, the vector area is defined to be located in
the "vectors" section, which is defined at the top of tx_initialize_low_level.asm.
This area is located at address 0 for the demonstration.

tx_initialize_low_level.asm is also where initialization of a periodic timer
interrupt source should take place.

In addition, _tx_initialize_low_level determines the first available address
for use by the application. By default, free memory is assumed to start after
the .zend section in RAM (defined in tx_initialize_low_level). This section
must be placed at the end of your other RAM sections. Please see sample_threadx.cmd
for an example. The address of this section is passed to the application definition
function, tx_application_define.


6.  Register Usage and Stack Frames

The TI TMS320C667x compiler assumes that registers A0-A9, A16-A31, B0-B9, and
B16-B31 are scratch registers for each function. All other registers used by
a C function must be preserved by the function. ThreadX takes advantage of this
in situations where a context switch happens as a result of making a ThreadX
service call (which is itself a C function). In such cases, the saved context
of a thread is only the non-scratch registers.

The following defines the saved context stack frames for context switches
that occur as a result of interrupt handling or from thread-level API calls.
All suspended threads have one of these two types of stack frames. The top
of the suspended thread's stack is pointed to by tx_thread_stack_ptr in the
associated thread control block TX_THREAD.



    Offset        Interrupted Stack Frame        Non-Interrupt Stack Frame

     0x04                   1                           0
     0x08                   CSR                         CSR
     0x0C                   IPR                         B3
     0x10                   AMR                         AMR
     0x14                   A0                          A10
     0x18                   A1                          A11
     0x1C                   A2                          A12
     0x20                   A3                          A13
     0x24                   A4                          A14
     0x28                   A5                          A15
     0x2C                   A6                          B10
     0x30                   A7                          B11
     0x34                   A8                          B12
     0x38                   A9                          B13
     0x3C                   A10                         ILC
     0x40                   A11                         RILC
     0x44                   A12
     0x48                   A13
     0x4C                   A14
     0x50                   A15
     0x54                   B0
     0x58                   B1
     0x5C                   B2
     0x60                   B3
     0x64                   B4
     0x68                   B5
     0x6C                   B6
     0x70                   B7
     0x74                   B8
     0x78                   B9
     0x7C                   B10
     0x80                   B11
     0x84                   B12
     0x88                   B13
     0x8C                   A16
     0x90                   A17
     0x94                   A18
     0x98                   A19
     0x9C                   A20
     0xA0                   A21
     0xA4                   A22
     0xA8                   A23
     0xAC                   A24
     0xB0                   A25
     0xB4                   A26
     0xB8                   A27
     0xBC                   A28
     0xC0                   A29
     0xC4                   A30
     0xC8                   A31
     0xCC                   B16
     0xD0                   B17
     0xD4                   B18
     0xD8                   B19
     0xDC                   B20
     0xE0                   B21
     0xE4                   B22
     0xE8                   B23
     0xEC                   B24
     0xF0                   B25
     0xF4                   B26
     0xF8                   B27
     0xFC                   B28
     0x100                  B29
     0x104                  B30
     0x108                  B31
     0x10C                  ILC
     0x110                  RILC
     0x114                  ITSR


7.  Improving Performance

The distribution version of ThreadX is built without any compiler
optimizations. This makes it easy to debug because you can trace or set
breakpoints inside of ThreadX itself. Of course, this costs some performance.
To make it run faster, you can replace the -g compiler option
to a -O3 in the ThreadX project file to enable all compiler optimizations.

In addition, you can eliminate the ThreadX basic API error checking by
compiling your application code with the symbol TX_DISABLE_ERROR_CHECKING
defined.


8.  Interrupt Handling

ThreadX provides complete and high-performance interrupt handling for
TMS320C667x targets. There are a certain set of requirements that are
defined in the following sub-sections:


8.1  Vector Area

The TMS320C667x interrupt vectors at in the section "vectors" and is defined at
the top of tx_initialize_low_level.asm. Each interrupt vector entry contains
a jump to a template interrupt processing shell.


8.2  Interrupt Service Routine Shells

The following interrupt processing shells are defined at the bottom of
tx_initialize_low_level.asm:


    __tx_int4_ISR
    __tx_int5_ISR
    __tx_int6_ISR
    __tx_int7_ISR
    __tx_int8_ISR
    __tx_int9_ISR
    __tx_int10_ISR
    __tx_int11_ISR
    __tx_int12_ISR
    __tx_int13_ISR
    __tx_int14_ISR
    __tx_int15_ISR

Each interrupt ISR is entered with B3, A0-A4 is available (these registers are
saved in the initial vector processing). The default interrupt handling
includes calls to __tx_thread_context_save and __tx_thread_context_restore.
Application ISR processing can be added between the context save/restore
calls. Note that only the compiler scratch registers are available for use
after context save return to the ISR.

High-frequency interrupt handlers might not want to perform context
save/restore processing on each interrupt. If this is the case, any
additional registers used must be saved and restored by the ISR and
the interrupt return processing must restore the registers saved by the
initial vector processing. This can be accomplished by adding the
following code to the end of the custom ISR handling:

        LDW         *+SP(20),A0                         ; Recover A0
        LDW         *+SP(24),A1                         ; Recover A1
        LDW         *+SP(28),A2                         ; Recover A2
        LDW         *+SP(32),A3                         ; Recover A3
        B           IRP                                 ; Return to point of interrupt
||      LDW         *+SP(36),A4                         ; Recover A4
        LDW         *+SP(96),B3                         ; Recover B3
        ADDK.S2     288,SP                              ; Recover stack space
        NOP         3                                   ; Delay slots


9.  Revision History

For generic code revision information, please refer to the readme_threadx_generic.txt
file, which is included in your distribution. The following details the revision
information associated with this specific port of ThreadX:

04-02-2021  Release 6.1.6 changes:
            tx_port.h                           Updated macro definition

09-30-2020  Initial ThreadX 6.1 version for TMS320C667x using TI Code Composer tools.


Copyright(c) 1996-2020 Microsoft Corporation


https://azure.com/rtos