Skip to content

Commit bc8bed4

Browse files
authored
Added thumb mode support under IAR for module manager on Cortex-A7 pl… (#289)
* Added thumb mode support under IAR for module manager on Cortex-A7 platform. * update code for comments.
1 parent 7fa087d commit bc8bed4

33 files changed

Lines changed: 801 additions & 686 deletions

common_modules/module_manager/src/txm_module_manager_thread_create.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@
9494
/* 03-08-2023 Scott Larson Check module stack for */
9595
/* overlap, */
9696
/* resulting in version 6.2.1 */
97-
/* xx-xx-xxxx Xiuwen Cai Modified comment(s), */
97+
/* xx-xx-xxxx Xiuwen Cai, Yajun xia Modified comment(s), */
9898
/* added option for random */
9999
/* number stack filling, */
100+
/* fixed the kernel stack */
101+
/* allocation issue, */
100102
/* resulting in version 6.x */
101103
/* */
102104
/**************************************************************************/
@@ -327,9 +329,8 @@ ULONG i;
327329
/* Initialize thread control block to all zeros. */
328330
TX_MEMSET(thread_ptr, 0, sizeof(TX_THREAD));
329331

330-
#if TXM_MODULE_MEMORY_PROTECTION
331-
/* If this is a memory protected module, allocate a kernel stack. */
332-
if((module_instance -> txm_module_instance_property_flags) & TXM_MODULE_MEMORY_PROTECTION)
332+
/* If the thread runs on user mode, allocate the kernel stack for syscall. */
333+
if((module_instance -> txm_module_instance_property_flags) & TXM_MODULE_USER_MODE)
333334
{
334335
ULONG status;
335336

@@ -354,6 +355,7 @@ ULONG i;
354355
thread_ptr -> tx_thread_module_kernel_stack_size = TXM_MODULE_KERNEL_STACK_SIZE;
355356
}
356357

358+
#if TXM_MODULE_MEMORY_PROTECTION
357359
/* Place the stack parameters into the thread's control block. */
358360
thread_ptr -> tx_thread_module_stack_start = stack_start;
359361
thread_ptr -> tx_thread_module_stack_size = stack_size;

ports_module/cortex_a7/gnu/example_build/txm_module_preamble.s

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ __txm_module_preamble:
1414
.dc.l 0x1 // Module Minor Version
1515
.dc.l 32 // Module Preamble Size in 32-bit words
1616
.dc.l 0x12345678 // Module ID (application defined)
17-
.dc.l 0x01000001 // Module Properties where:
17+
.dc.l 0x02000001 // Module Properties where:
1818
// Bits 31-24: Compiler ID
1919
// 0 -> IAR
2020
// 1 -> RVDS
2121
// 2 -> GNU
22-
// Bits 23-1: Reserved
23-
// Bit 0: 0 -> Privileged mode execution (no MMU protection)
24-
// 1 -> User mode execution (MMU protection)
22+
// Bits 23-3: Reserved
23+
// Bit 2: 0 -> Disable shared/external memory access
24+
// 1 -> Enable shared/external memory access
25+
// Bit 1: 0 -> No MPU protection
26+
// 1 -> MPU protection (must have user mode selected - bit 0 set)
27+
// Bit 0: 0 -> Privileged mode execution
28+
// 1 -> User mode execution
2529
.dc.l _txm_module_thread_shell_entry // Module Shell Entry Point
2630
.dc.l demo_module_start // Module Start Thread Entry Point
2731
.dc.l 0 // Module Stop Thread Entry Point

ports_module/cortex_a7/gnu/inc/txm_module_port.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ UINT _txm_module_manager_inside_data_check(ULONG pointer);
410410

411411
#define TXM_MODULE_MANAGER_VERSION_ID \
412412
CHAR _txm_module_manager_version_id[] = \
413-
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX Module Cortex-A7/MMU/GNU Version 6.2.1 *";
413+
"Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX Module Cortex-A7/MMU/GNU Version 6.x *";
414414

415415
#endif
416416

ports_module/cortex_a7/gnu/module_manager/src/tx_thread_context_save.s

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
.global _tx_thread_system_state
3131
.global _tx_thread_current_ptr
3232
.global __tx_irq_processing_return
33-
33+
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
34+
.global _tx_execution_isr_enter
35+
#endif
3436

3537
/* No 16-bit Thumb mode veneer code is needed for _tx_thread_context_save
3638
since it will never be called 16-bit mode. */

ports_module/cortex_a7/gnu/module_manager/src/tx_thread_stack_build.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ CPSR_MASK = 0xFF // Mask initial CPSR, T, IRQ & F
3838
CPSR_MASK = 0xBF // Mask initial CPSR, T, IRQ interrupts enabled
3939
#endif
4040

41+
.global _tx_thread_schedule
42+
4143
.text
4244
.align 2
4345
/**************************************************************************/

ports_module/cortex_a7/iar/example_build/sample_threadx_module.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,6 @@ void thread_0_entry(ULONG thread_input)
232232

233233
UINT status;
234234

235-
/* Test external/shared memory. */
236-
*(ULONG *) 0x90000000 = 0xdeadbeef;
237-
*(ULONG *) 0x90000FFC = 0xfeed0add;
238-
*(ULONG *) 0x90001000 = 0xfedcba01;
239-
240235
/* This thread simply sits in while-forever-sleep loop. */
241236
while(1)
242237
{

ports_module/cortex_a7/iar/example_build/sample_threadx_module.ewp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,21 @@
125125
<option>
126126
<name>FPU2</name>
127127
<version>0</version>
128-
<state>3</state>
128+
<state>5</state>
129129
</option>
130130
<option>
131131
<name>NrRegs</name>
132132
<version>0</version>
133-
<state>1</state>
133+
<state>2</state>
134134
</option>
135135
<option>
136136
<name>NEON</name>
137-
<state>0</state>
137+
<state>1</state>
138138
</option>
139139
<option>
140140
<name>GFPUCoreSlave2</name>
141141
<version>31</version>
142-
<state>42</state>
142+
<state>52</state>
143143
</option>
144144
<option>
145145
<name>OGCMSISPackSelectDevice</name>
@@ -353,7 +353,7 @@
353353
</option>
354354
<option>
355355
<name>IProcessorMode2</name>
356-
<state>1</state>
356+
<state>0</state>
357357
</option>
358358
<option>
359359
<name>CCOptLevel</name>
@@ -983,7 +983,7 @@
983983
</option>
984984
<option>
985985
<name>IlinkTrustzoneImportLibraryOut</name>
986-
<state>###Unitialized###</state>
986+
<state>sample_threadx_module_import_lib.o</state>
987987
</option>
988988
<option>
989989
<name>OILinkExtraOption</name>

ports_module/cortex_a7/iar/example_build/sample_threadx_module_manager.ewd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
</option>
4545
<option>
4646
<name>MemFile</name>
47-
<state>$TOOLKIT_DIR$\CONFIG\debugger\TexasInstruments\RM48L952ZWT.ddf</state>
47+
<state></state>
4848
</option>
4949
<option>
5050
<name>RunToEnable</name>
51-
<state>0</state>
51+
<state>1</state>
5252
</option>
5353
<option>
5454
<name>RunToName</name>
@@ -88,7 +88,7 @@
8888
</option>
8989
<option>
9090
<name>OCLastSavedByProductVersion</name>
91-
<state>8.50.4.26131</state>
91+
<state>9.20.4.46976</state>
9292
</option>
9393
<option>
9494
<name>UseFlashLoader</name>
@@ -112,7 +112,7 @@
112112
</option>
113113
<option>
114114
<name>FlashLoadersV3</name>
115-
<state>$TOOLKIT_DIR$\config\flashloader\TexasInstruments\FlashRM48L950.board</state>
115+
<state>$TOOLKIT_DIR$\config\flashloader\</state>
116116
</option>
117117
<option>
118118
<name>OCImagesSuppressCheck1</name>

ports_module/cortex_a7/iar/example_build/sample_threadx_module_manager.ewp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
</option>
8383
<option>
8484
<name>GEndianModeBE</name>
85-
<state>0</state>
85+
<state>1</state>
8686
</option>
8787
<option>
8888
<name>OGBufferedTerminalOutput</name>
@@ -99,7 +99,7 @@
9999
<option>
100100
<name>GBECoreSlave</name>
101101
<version>31</version>
102-
<state>42</state>
102+
<state>52</state>
103103
</option>
104104
<option>
105105
<name>OGUseCmsis</name>
@@ -279,7 +279,7 @@
279279
<option>
280280
<name>CCAllowList</name>
281281
<version>1</version>
282-
<state>11111110</state>
282+
<state>00000000</state>
283283
</option>
284284
<option>
285285
<name>CCDebugInfo</name>
@@ -353,11 +353,11 @@
353353
</option>
354354
<option>
355355
<name>IProcessorMode2</name>
356-
<state>1</state>
356+
<state>0</state>
357357
</option>
358358
<option>
359359
<name>CCOptLevel</name>
360-
<state>3</state>
360+
<state>1</state>
361361
</option>
362362
<option>
363363
<name>CCOptStrategy</name>
@@ -366,7 +366,7 @@
366366
</option>
367367
<option>
368368
<name>CCOptLevelSlave</name>
369-
<state>3</state>
369+
<state>1</state>
370370
</option>
371371
<option>
372372
<name>CCPosIndRopi</name>

ports_module/cortex_a7/iar/example_build/tx.ewp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@
658658
<data>
659659
<extensions></extensions>
660660
<cmdline></cmdline>
661-
<hasPrio>0</hasPrio>
661+
<hasPrio>1</hasPrio>
662662
<buildSequence>inputOutputBased</buildSequence>
663663
</data>
664664
</settings>
@@ -1053,7 +1053,7 @@
10531053
</option>
10541054
<option>
10551055
<name>IarchiveOutput</name>
1056-
<state>C:\Users\cindydeng\AzureRTOS\threadx\modules\cortex-a-port\threadx\ports_module\cortex_a7\iar\example_build\Debug\Exe\tx.a</state>
1056+
<state>C:\tmp\threadx\ports_module\cortex_a7\iar\example_build\Debug\Exe\tx.a</state>
10571057
</option>
10581058
</data>
10591059
</settings>

0 commit comments

Comments
 (0)