annotate src/nucleus/gcc/tct.S @ 163:a911ac771094

board preprocessor conditionals: prep for more FC hw in the future Please see the corresponding change in fc-magnetite for the explanation.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 01 Apr 2019 01:20:03 +0000
parents 6738273be0b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
74
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * Copyright Mentor Graphics Corporation 2002
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * All Rights Reserved.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 * THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 * THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 * SUBJECT TO LICENSE TERMS.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 * FILE NAME VERSION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 * tct.s Nucleus PLUS\ARM925\Code Composer 1.14.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 * COMPONENT
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 * TC - Thread Control
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 * This file contains the target processor dependent routines for
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 * performing target-dependent scheduling functions.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 * FUNCTIONS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 * TCT_Control_Interrupts Enable / disable interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 * by changing
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 * TCD_Interrupt_Level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 * TCT_Local_Control_Interrupts Enable/disable interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 * by not changing
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 * TCD_Interrupt_Level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 * TCT_Restore_Interrupts Restores interrupts to the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 * level in TCD_Interrupt_Level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 * TCT_Build_Task_Stack Build initial task stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 * TCT_Build_HISR_Stack Build initial HISR stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 * TCT_Build_Signal_Frame Build signal handler frame
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 * TCT_Check_Stack Check current stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 * TCT_Schedule Schedule the next thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 * TCT_Control_To_Thread Transfer control to a thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 * TCT_Control_To_System Transfer control from thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 * TCT_Signal_Exit Exit from signal handler
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 * TCT_Current_Thread Returns a pointer to current
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 * thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 * TCT_Set_Execute_Task Sets TCD_Execute_Task under
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 * protection from interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 * TCT_Protect Protect critical section
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 * TCT_Unprotect Unprotect critical section
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 * TCT_Unprotect_Specific Release specific protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 * TCT_Set_Current_Protect Set the thread's current
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 * protection field
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 * TCT_Protect_Switch Switch to protected thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 * TCT_Schedule_Protected Schedule the protected thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 * TCT_Interrupt_Context_Save Save interrupted context
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 * TCT_Interrupt_Context_Restore Restore interrupted context
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 * TCT_Activate_HISR Activate a HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 * TCT_HISR_Shell HISR execution shell
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 * DEPENDENCIES
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 * cs_extr.h Common Service functions
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 * tc_extr.h Thread Control functions
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 * B. Ronquillo 08-28-2002 Released version 1.14.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 #define NU_SOURCE_FILE
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 ******************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 * INCLUDE ASSEMBLY CONSTANTS *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 ******************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 * Define constants used in low-level initialization.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 #include "asm_defs.h"
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 .code 32
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 /* TCT_System_Limit is a global variable defined in this module */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 .comm TCT_System_Limit,4,4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 .text
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 **********************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 * LOCAL VARIABLE DECLARATIONS *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 **********************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 * Define pointers to system variables so their addresses may be obtained in a
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 * pc-relative manner.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 System_Limit:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 .word TCT_System_Limit
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 Int_Level:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 .word TCD_Interrupt_Level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 Task_Shell:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 .word TCC_Task_Shell
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 HISR_Shell:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 .word TCT_HISR_Shell
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 Signal_Shell:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 .word TCC_Signal_Shell
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 Current_Thread:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 .word TCD_Current_Thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 Execute_HISR:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 .word TCD_Execute_HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 Execute_Task:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 .word TCD_Execute_Task
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 Time_Slice:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 .word TMD_Time_Slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 Slice_State:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 .word TMD_Time_Slice_State
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 System_Stack:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 .word TCD_System_Stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 Int_Count:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 .word TCD_Interrupt_Count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 HISR_Tails:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 .word TCD_Active_HISR_Tails
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 HISR_Heads:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 .word TCD_Active_HISR_Heads
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 * TCT_Control_Interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 * This function enables and disables interrupts as specified by
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 * the caller. Interrupts disabled by this call are left disabled
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 * until the another call is made to enable them.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 * Application
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 * new_level New interrupt enable level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 * old_level Previous interrupt enable
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 * level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 * C. Meredith 03-01-1994 Lockout interrupts while setting
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 * up the new level, resutling in
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 * version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 * D. Lamie 03-18-1994 Verified version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 * M. Trippi 02-03-1997 Masked the return value to only
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 * return the interrupt bits.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 * (SPR0252)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 @INT TCT_Control_Interrupts (INT new_level)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 .globl TCT_Control_Interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 TCT_Control_Interrupts:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 @INT old_level; Old interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 @ lock out all interrupts before any checking or changing
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 @ Obtain the current interrupt lockout posture.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 @ old_level = TCD_Interrupt_Level;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 @ Setup new interrupt lockout posture.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 @ TCD_Interrupt_Level = new_level;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 @ renable interrupts for the specified lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 @ Return old interrupt lockout level.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 @ return(old_level);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 MRS r2,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 ORR r2,r2,#LOCKOUT @ Build lockout CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 MSR CPSR,r2 @ Lockout interrupts temporarily
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 LDR r1, Int_Level @ Pickup interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 LDR r3,[r1, #0] @ Pickup current interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 BIC r2,r2,#LOCK_MSK @ Clear lockout mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 ORR r2,r2,r0 @ Build new CPSR with appropriate
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 @ interrupts locked out
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 STR r0,[r1,#0] @ Save current lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 MSR CPSR,r2 @ Setup new CPSR lockout bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 AND r0,r3,#LOCK_MSK @ Return previous lockout (SPR0252)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 * TCT_Local_Control_Interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 * This function enables and disables interrupts as specified by
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 * the caller.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 * Application
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 * new_level New interrupt enable level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 * old_level Previous interrupt enable
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 * level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 * C. Meredith 03-01-1994 Created initial version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 * D. Lamie 03-18-1994 Verified version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 * M. Trippi 02-03-1997 Masked the return value to only
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 * return the interrupt bits.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 * (SPR0252)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 @INT TCT_Local_Control_Interrupts (INT new_level)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 .globl TCT_Local_Control_Interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 TCT_Local_Control_Interrupts:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 @INT old_level; Old interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 @ read in the old level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 @ old_level = current interrupt level of processor;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 MRS r2,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 MOV r3,r2 @ save the old level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 @ clear out the old level and set the new level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 @ current interrupt level of processor &= ~LOCKOUT;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 @ current interrupt level of processor |= new_level;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 BIC r2,r2,#LOCK_MSK @ Clear all current interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 ORR r2,r2,r0 @ Build new CPSR with new
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 @ interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 MSR CPSR,r2 @ Setup new CPSR interrupt bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 @ Return old interrupt lockout level.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 @ return(old_level);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296 AND r0,r3,#LOCK_MSK @ Return previous lockout (SPR0252)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 * TCT_Restore_Interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 * This function restores interrupts to that specified in the global
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 * TCD_Interrupt_Level variable.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 * Application
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 * None.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 * None.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 * C. Meredith 03-01-1994 Created initial version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335 * D. Lamie 03-18-1994 Verified version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 @VOID TCT_Restore_Interrupts (VOID)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 .globl TCT_Restore_Interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 TCT_Restore_Interrupts:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346 @ Lock out all interrupts before any checking or changing
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 @ Obtain the current interrupt lockout posture.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 @ Reload the level base on the TCD_Interrupt_Level variable
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 MOV r2,r1 @ save the CPSR value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 ORR r1,r1,#LOCKOUT @ Build lockout CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 MSR CPSR,r1 @ Lockout interrupts temporarily
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 BIC r2,r2,#LOCK_MSK @ Clear current interrupt levels
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355 LDR r1,Int_Level @ Load address of TCD_Interrupt_Level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 LDR r0,[r1, #0] @ Pickup current interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 ORR r2,r2,r0 @ Build new CPSR with appropriate
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358 @ interrupts locked out
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 MSR CPSR,r2 @ Setup new CPSR lockout bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
368 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 * TCT_Build_Task_Stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374 * This function builds an initial stack frame for a task. The
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375 * initial stack contains information concerning initial values of
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
376 * registers and the task's point of entry. Furthermore, the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377 * initial stack frame is in the same form as an interrupt stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
378 * frame.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
379 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
380 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
381 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
382 * TCC_Create_Task Create a new task
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
383 * TCC_Reset_Task Reset the specified task
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
384 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
385 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
386 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
387 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
388 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
389 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
390 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
391 * task Task control block pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
392 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
393 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
394 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
395 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
396 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
397 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
398 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
399 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
400 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
401 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
402 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
403 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
404 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
405 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
406
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
407 @VOID TCT_Build_Task_Stack(TC_TCB *task)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
408 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
409
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
410 .globl TCT_Build_Task_Stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
411 TCT_Build_Task_Stack:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
412
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
413 @ Pickup the stack base.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
414 @ REG_Stack_Base = (BYTE_PTR) task -> tc_stack_start;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
415
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
416 LDR r2,[r0,#0x24] @ Pickup the stack starting address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
417
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
418 @ Pickup the stack size.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
419 @ REG_Stack_Size = task -> tc_stack_size;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
420
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
421 LDR r1,[r0,#0x30] @ Pickup the stack size in bytes
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
422
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
423 @ Calculate the stack ending address.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
424 @ REG_Stack_End = REG_Stack_Base + REG_Stack_Size - 1;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
425
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
426 ADD r3,r1,r2 @ Compute the beginning of stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
427 BIC r3,r3,#3 @ Insure word alignment
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
428 SUB r3,r3,#4 @ Reserve a word
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
429
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
430 @ Save the stack ending address.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
431 @ task -> tc_stack_end = REG_Stack_End;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
432
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
433 STR r3,[r0,#0x28] @ Save the stack ending address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
434
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
435 @ Reference the task shell.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
436 @ REG_Function_Ptr = (VOID *) TCC_Task_Shell;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
437
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
438 @ Build an initial stack. This initial stack frame facilitates an
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
439 @ interrupt return to the TCC_Task_Shell function, which in turn
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
440 @ invokes the application task. The initial stack frame has the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
441 @ following format:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
442
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
443 @ (Lower Address) Stack Top -> 1 (Interrupt stack type)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
444 @ CPSR Saved CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
445 @ r0 Saved r0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
446 @ r1 Saved r1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
447 @ r2 Saved r2
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
448 @ r3 Saved r3
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
449 @ r4 Saved r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
450 @ r5 Saved r5
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
451 @ r6 Saved r6
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
452 @ r7 Saved r7
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
453 @ r8 Saved r8
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
454 @ r9/sb Saved r9/sl
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
455 @ r10/sl Saved r10/sl
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
456 @ fp Saved fp
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
457 @ r12 Saved r12
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
458 @ r13 Saved r13
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
459 @ r14 Saved r14
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
460 @ (Higher Address) Stack Bottom-> r15 Saved r15
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
461
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
462
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
463 LDR r2, Task_Shell @ Pickup address of shell entry
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
464 STR r2,[r3], #-4 @ Store entry address on stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
465 MOV r2,#0 @ Clear value for initial registers
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
466 STR r2,[r3], #-4 @ Store initial r14
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
467 ADD r2,r3,#8 @ Compute initial r13
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
468 STR r2,[r3], #-4 @ Store initial r13 (Stack Bottom)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
469 STR r2,[r3], #-4 @ Store initial r12
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
470 STR r2,[r3], #-4 @ Store initial fp
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
471 LDR r2,[r0,#0x24] @ Pickup the stack starting address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
472 STR r2,[r3], #-4 @ Store initial r10/sl
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
473 MOV r2,#0 @ Clear value for initial registers
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
474 STR r2,[r3], #-4 @ Store initial r9/sb
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
475 STR r2,[r3], #-4 @ Store initial r8
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
476 STR r2,[r3], #-4 @ Store initial r7
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
477 STR r2,[r3], #-4 @ Store initial r6
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
478 STR r2,[r3], #-4 @ Store initial r5
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
479 STR r2,[r3], #-4 @ Store initial r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
480 STR r2,[r3], #-4 @ Store initial r3
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
481 STR r2,[r3], #-4 @ Store initial r2
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
482 STR r2,[r3], #-4 @ Store initial r1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
483 STR r2,[r3], #-4 @ Store initial r0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
484 MSR CPSR_f,r2 @ Clear the flags
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
485 MRS r2,CPSR @ Pickup the CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
486 BIC r2,r2,#LOCK_MSK @ Clear initial interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
487 STR r2,[r3], #-4 @ Store CPSR on the initial stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
488 MOV r2,#1 @ Build interrupt stack type (1)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
489 STR r2,[r3, #0] @ Store stack type on the top
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
490
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
491 @ Save the minimum amount of remaining stack memory.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
492 @ task -> tc_stack_minimum = REG_Stack_Size - 72;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
493
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
494 MOV r2,#72 @ Size of interrupt stack frame
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
495 SUB r1,r1,r2 @ Compute minimum available bytes
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
496 STR r1,[r0, #0x34] @ Save in minimum stack area
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
497
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
498 @ Save the new stack pointer into the task's control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
499 @ task -> tc_stack_pointer = (VOID *) Stack_Top;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
500
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
501 STR r3,[r0, #0x2C] @ Save stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
502
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
503 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
504
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
505 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
506
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
507 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
508 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
509 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
510 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
511 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
512 * TCT_Build_HISR_Stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
513 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
514 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
515 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
516 * This function builds an HISR stack frame that allows quick
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
517 * scheduling of the HISR.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
518 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
519 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
520 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
521 * TCC_Create_HISR Create HISR function
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
522 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
523 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
524 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
525 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
526 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
527 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
528 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
529 * hisr HISR control block pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
530 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
531 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
532 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
533 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
534 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
535 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
536 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
537 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
538 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
539 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
540 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
541 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
542 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
543 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
544
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
545 @VOID TCT_Build_HISR_Stack(TC_HCB *hisr)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
546 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
547
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
548 .globl TCT_Build_HISR_Stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
549 TCT_Build_HISR_Stack:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
550
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
551 @ Pickup the stack base.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
552 @ REG_Stack_Base = (BYTE_PTR) hisr -> tc_stack_start;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
553
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
554 LDR r2,[r0,#0x24] @ Pickup the stack starting address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
555
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
556 @ Pickup the stack size.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
557 @ REG_Stack_Size = hisr -> tc_stack_size;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
558
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
559 LDR r1,[r0,#0x30] @ Pickup the stack size in bytes
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
560
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
561 @ Calculate the stack ending address.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
562 @ REG_Stack_End = REG_Stack_Base + REG_Stack_Size;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
563
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
564 ADD r3,r1,r2 @ Compute the beginning of stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
565 BIC r3,r3,#3 @ Insure word alignment
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
566 SUB r3,r3,#4 @ Reserve a word
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
567
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
568 @ Save the stack ending address.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
569 @ hisr -> tc_stack_end = REG_Stack_End;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
570
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
571 STR r3,[r0,#0x28] @ Save the stack ending address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
572
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
573 @ Reference the HISR shell.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
574 @ REG_Function_Ptr = (VOID *) TCT_HISR_Shell;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
575
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
576 @ Build an initial stack. This initial stack frame facilitates an
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
577 @ solicited return to the TCT_HISR_Shell function, which in turn
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
578 @ invokes the appropriate HISR. The initial HISR stack frame has the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
579 @ following format:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
580
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
581 @ (Lower Address) Stack Top -> 0 (Solicited stack type)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
582 @ !!FOR THUMB ONLY!! 0/0x20 Saved state mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
583 @ r4 Saved r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
584 @ r5 Saved r5
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
585 @ r6 Saved r6
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
586 @ r7 Saved r7
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
587 @ r8 Saved r8
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
588 @ r9/sb Saved r9/sl
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
589 @ r10/sl Saved r10/sl
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
590 @ fp Saved fp
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
591 @ r12 Saved r12
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
592 @ (Higher Address) Stack Bottom-> r15 Saved r15
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
593
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
594
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
595 LDR r2,HISR_Shell @ Pickup address of shell entry
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
596 STR r2,[r3], #-4 @ Store entry address on stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
597 ADD r2,r3,#4 @ Compute initial r13
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
598 STR r2,[r3], #-4 @ Store initial r12
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
599 STR r2,[r3], #-4 @ Store initial fp
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
600 LDR r2,[r0,#0x24] @ Pickup the stack starting address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
601 STR r2,[r3], #-4 @ Store initial r10/sl
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
602 MOV r2,#0 @ Clear value for initial registers
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
603 STR r2,[r3], #-4 @ Store initial r9/sb
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
604 STR r2,[r3], #-4 @ Store initial r8
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
605 STR r2,[r3], #-4 @ Store initial r7
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
606 STR r2,[r3], #-4 @ Store initial r6
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
607 STR r2,[r3], #-4 @ Store initial r5
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
608 STR r2,[r3], #-4 @ Store initial r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
609 #if 1 /* was .if THUMB */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
610 STR r2,[r3], #-4 @ Store initial state mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
611 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
612 STR r2,[r3, #0] @ Store solicited stack type on the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
613 @ top of the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
614
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
615 @ Save the minimum amount of remaining stack memory.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
616 @ hisr -> tc_stack_minimum = REG_Stack_Size - (ARM)44 or (THUMB)48;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
617
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
618 #if 1 /* was .if THUMB */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
619 MOV r2,#48 @ Size of solicited stack frame
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
620 #else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
621 MOV r2,#44 @ Size of solicited stack frame
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
622 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
623
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
624 SUB r1,r1,r2 @ Compute minimum available bytes
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
625 STR r1,[r0, #0x34] @ Save in minimum stack area
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
626
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
627 @ Save the new stack pointer into the task's control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
628 @ hisr -> tc_stack_pointer = (VOID *) Stack_Top;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
629
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
630 STR r3,[r0, #0x2C] @ Save stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
631
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
632 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
633
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
634 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
635
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
636 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
637 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
638 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
639 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
640 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
641 * TCT_Build_Signal_Frame
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
642 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
643 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
644 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
645 * This function builds a frame on top of the task's stack to
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
646 * cause the task's signal handler to execute the next time
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
647 * the task is executed.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
648 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
649 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
650 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
651 * TCC_Send_Signals Send signals to a task
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
652 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
653 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
654 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
655 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
656 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
657 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
658 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
659 * task Task control block pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
660 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
661 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
662 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
663 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
664 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
665 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
666 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
667 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
668 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
669 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
670 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
671 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
672 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
673 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
674
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
675 @VOID TCT_Build_Signal_Frame(TC_TCB *task)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
676 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
677
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
678 .globl TCT_Build_Signal_Frame
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
679 TCT_Build_Signal_Frame:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
680
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
681 @ Pickup the stack pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
682 @ REG_Stack_Ptr = (BYTE_PTR) task -> tc_stack_pointer;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
683
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
684 LDR r3,[r0,#0x2c] @ Pickup the current stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
685
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
686 @ Reference the Signal shell.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
687 @ REG_Function_Ptr = (VOID *) TCC_Signal_Shell;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
688
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
689 @ Build a signal stack. This signal stack frame facilitates an
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
690 @ solicited return to the TCC_Signal_Shell function, which in turn
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
691 @ invokes the appropriate signal handler. The initial HISR stack frame
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
692 @ has the following format:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
693
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
694 @ (Lower Address) Stack Top -> 0 (Solicited stack type)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
695 @ !!FOR THUMB ONLY!! 0/0x20 Saved state mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
696 @ r4 Saved r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
697 @ r5 Saved r5
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
698 @ r6 Saved r6
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
699 @ r7 Saved r7
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
700 @ r8 Saved r8
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
701 @ r9/sb Saved r9/sl
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
702 @ r10/sl Saved r10/sl
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
703 @ fp Saved fp
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
704 @ r12 Saved r12
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
705 @ (Higher Address) Stack Bottom-> r15 Saved r15
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
706
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
707
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
708 LDR r2,Signal_Shell @ Pickup address of shell entry
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
709 SUB r3,r3,#4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
710 STR r2,[r3], #-4 @ Store entry address on stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
711 ADD r2,r3,#4 @ Compute initial r13
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
712 STR r2,[r3], #-4 @ Store initial r12
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
713 STR r2,[r3], #-4 @ Store initial fp
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
714 LDR r2,[r0,#0x24] @ Pickup the stack starting address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
715 STR r2,[r3], #-4 @ Store initial r10/sl
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
716 MOV r2,#0 @ Clear value for initial registers
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
717 STR r2,[r3], #-4 @ Store initial r9/sb
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
718 STR r2,[r3], #-4 @ Store initial r8
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
719 STR r2,[r3], #-4 @ Store initial r7
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
720 STR r2,[r3], #-4 @ Store initial r6
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
721 STR r2,[r3], #-4 @ Store initial r5
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
722 STR r2,[r3], #-4 @ Store initial r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
723 #if 0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
724 MOV r1,#0x20 @ Get initial state mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
725 STR r1,[r3], #-4 @ Store initial state mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
726 #else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
727 STR r2,[r3], #-4 @ TCC_Signal_Shell is an ARM proc
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
728 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
729
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
730 STR r2,[r3, #0] @ Store solicited stack type on the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
731 @ top of the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
732
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
733 @ Save the new stack pointer into the task's control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
734 @ task -> tc_stack_pointer = (VOID *) (REG_Stack_Ptr - REG_Stack_Size);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
735
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
736 STR r3,[r0, #0x2C] @ Save stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
737
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
738 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
739
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
740 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
741
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
742 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
743 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
744 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
745 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
746 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
747 * TCT_Check_Stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
748 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
749 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
750 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
751 * This function checks the current stack for overflow conditions.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
752 * Additionally, this function keeps track of the minimum amount
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
753 * of stack space for the calling thread and returns the current
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
754 * available stack space.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
755 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
756 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
757 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
758 * TCC_Send_Signals Send signals to a task
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
759 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
760 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
761 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
762 * ERC_System_Error System error handler
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
763 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
764 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
765 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
766 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
767 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
768 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
769 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
770 * available bytes in stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
771 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
772 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
773 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
774 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
775 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
776 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
777 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
778 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
779 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
780 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
781
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
782 @UNSIGNED TCT_Check_Stack(void)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
783 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
784
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
785 .globl TCT_Check_Stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
786 TCT_Check_Stack:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
787
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
788 @TC_TCB *thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
789 @UNSIGNED remaining;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
790
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
791 @ Pickup the current task/HISR pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
792 @ thread = (TC_TCB *) TCD_Current_Thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
793
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
794 LDR r0,Current_Thread @ Pickup address of thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
795 LDR r0,[r0,#0] @ Pickup thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
796
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
797 @ Determine if there is a current thread.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
798 @ if (thread)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
799 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
800
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
801 CMP r0,#0 @ Determine if a thread is active
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
802 MOV r3,#0 @ Default remaining value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
803 BEQ TCT_Skip_Stack_Check @ If NU_NULL, skip stack checking
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
804
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
805 @ Determine if the stack pointers are out of range.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
806 @ if ((thread -> tc_stack_pointer < thread -> tc_stack_start) ||
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
807 @ (thread -> tc_stack_pointer > thread -> tc_stack_end))
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
808
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
809 LDR r2,[r0,#0x24] @ Pickup start of stack area
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
810 CMP r13,r2 @ Compare with current stack ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
811 BLT TCT_Stack_Range_Error @ If less, stack is out of range
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
812 LDR r1,[r0,#0x28] @ Pickup end of stack area
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
813 CMP r13,r1 @ Compare with current stack ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
814 BLE TCT_Stack_Range_Okay @ If less, stack range is okay
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
815
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
816 @ Stack overflow condition exits.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
817 @ ERC_System_Error(NU_STACK_OVERFLOW);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
818
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
819 TCT_Stack_Range_Error:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
820
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
821 STR r14,[r13, #4]! @ Store r14 on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
822 MOV r0,#3 @ Build NU_STACK_OVERFLOW code
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
823 BL ERC_System_Error @ Call system error handler. Note:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
824 @ control is not returned!
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
825 @ Examine stack to find return
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
826 @ address of this routine.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
827
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
828 TCT_Stack_Range_Okay:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
829
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
830 @ Calculate the amount of available space on the stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
831 @ remaining = (BYTE_PTR) thread -> tc_stack_pointer -
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
832 @ (BYTE_PTR) thread -> tc_stack_start;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
833
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
834 SUB r3,r13,r2 @ Calculate remaining stack size
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
835
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
836 @ Determine if there is enough memory on the stack to save all of the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
837 @ registers.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
838 @ if (remaining < 80)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
839
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
840 CMP r3,#80 @ Is there enough room for an
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
841 @ interrupt frame?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
842 BCS TCT_No_Stack_Error @ If so, no stack overflow yet
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
843
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
844 @ Stack overflow condition is about to happen.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
845 @ ERC_System_Error(NU_STACK_OVERFLOW);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
846
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
847 STR r14,[r13, #4]! @ Store r14 on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
848 MOV r0,#3 @ Build NU_STACK_OVERFLOW code
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
849 BL ERC_System_Error @ Call system error handler. Note:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
850 @ control is not returned!
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
851 @ Examine stack to find return
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
852 @ address of this routine.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
853
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
854 TCT_No_Stack_Error:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
855
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
856 @ Determine if this is a new minimum amount of stack space.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
857 @ if (remaining < thread -> tc_stack_minimum)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
858
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
859 LDR r2,[r0,#0x34]
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
860 CMP r3,r2
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
861 STRCC r3,[r0,#0x34]
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
862
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
863 @ Save the new stack minimum.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
864 @ thread -> tc_stack_minimum = remaining;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
865 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
866 @ else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
867
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
868 @ Set the remaining bytes to 0.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
869 @ remaining = 0;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
870
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
871 @ Return the remaining number of bytes on the stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
872 @ return(remaining);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
873
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
874 TCT_Skip_Stack_Check:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
875 MOV r0,r3 @ Return remaining bytes
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
876
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
877 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
878
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
879 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
880
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
881 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
882 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
883 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
884 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
885 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
886 * TCT_Schedule
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
887 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
888 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
889 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
890 * This function waits for a thread to become ready. Once a thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
891 * is ready, this function initiates a transfer of control to that
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
892 * thread.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
893 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
894 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
895 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
896 * INC_Initialize Main initialization routine
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
897 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
898 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
899 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
900 * TCT_Control_To_Thread Transfer control to a thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
901 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
902 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
903 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
904 * TCD_Execute_Task Pointer to task to execute
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
905 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
906 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
907 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
908 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
909 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
910 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
911 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
912 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
913 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
914 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
915 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
916 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
917 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
918 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
919
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
920 @VOID TCT_Schedule(void)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
921 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
922
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
923 .globl TCT_Schedule
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
924 TCT_Schedule:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
925
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
926 @ Restore interrupts according to the value contained in
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
927 @ TCD_Interrupt_Level.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
928
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
929 LDR r1,Int_Level @ Build address of interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
930 MRS r0,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
931 LDR r2,[r1, #0] @ Pickup current interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
932 BIC r0,r0,#LOCK_MSK @ Clear the interrupt lockout bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
933 ORR r0,r0,r2 @ Build new interrupt lockout CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
934 MSR CPSR,r0 @ Setup new CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
935 LDR r2,Execute_HISR @ Pickup TCD_Execute_HISR address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
936 LDR r3,Execute_Task @ Pickup TCD_Execute_Task address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
937
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
938 #ifdef INCLUDE_PROVIEW
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
939 @ Nucleus ProView Hook
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
940 @ We check if upon entering TCT_Schedule we already have a task to excute.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
941 @ if not, we start IDLE.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
942 LDR r0,[r2, #0] @ Pickup highest priority HISR ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
943 CMP r0,#0 @ Is there a HISR active?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
944 BNE TCT_Schedule_Thread @ Found an HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
945 LDR r0,[r3, #0] @ Pickup highest priority Task ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
946 CMP r0,#0 @ Is there a task active?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
947 BNE TCT_Schedule_Thread @ If not, start IDLE.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
948 STR r2,[r13, #-4]! @ Save r2 on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
949 STR r3,[r13, #-4]! @ Save r3 on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
950 BL _NU_Idle_Hook
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
951 LDR r3,[r13], #4 @ Recover r2
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
952 LDR r2,[r13], #4 @ Recover r3
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
953 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
954
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
955
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
956 @ Wait until a thread (task or HISR) is available to execute.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
957 @ do
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
958 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
959 .globl TCT_Schedule_Loop
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
960 TCT_Schedule_Loop:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
961
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
962 @ } while ((!TCD_Execute_HISR) && (!TCD_Execute_Task));
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
963
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
964 LDR r0,[r2, #0] @ Pickup highest priority HISR ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
965 CMP r0,#0 @ Is there a HISR active?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
966 BNE TCT_Schedule_Thread @ Found an HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
967 LDR r0,[r3, #0] @ Pickup highest priority Task ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
968 CMP r0,#0 @ Is there a task active?
75
6738273be0b3 Nucleus gcc assembly modules compile
Mychaela Falconia <falcon@freecalypso.org>
parents: 74
diff changeset
969 #if 1 /* was CONFIG_INCLUDE_L1 in Citrine */
74
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
970 BEQ _GSM_Small_Sleep
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
971 #else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
972 BEQ TCT_Schedule_Loop @ If not, continue the search
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
973 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
974
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
975 @ Yes, either a task or an HISR is ready to execute. Lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
976 @ interrupts while the thread is transferred to.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
977
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
978 TCT_Schedule_Thread:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
979 MRS r1,CPSR @ Pickup CPSR again
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
980 ORR r1,r1,#LOCKOUT @ Build interrupt lockout value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
981 MSR CPSR,r1 @ Lockout interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
982
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
983 @ Transfer control to the thread by falling through to the following
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
984 @ routine.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
985 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
986
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
987 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
988 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
989 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
990 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
991 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
992 * TCT_Control_To_Thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
993 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
994 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
995 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
996 * This function transfers control to the specified thread. Each
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
997 * time control is transferred to a thread, its scheduled counter
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
998 * is incremented. Additionally, time-slicing for task threads is
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
999 * enabled in this routine. The TCD_Current_Thread pointer is
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1000 * setup by this function.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1001 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1002 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1003 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1004 * TCT_Schedule Indirectly called
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1005 * TCT_Protect Protection task switch
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1006 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1007 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1008 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1009 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1010 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1011 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1012 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1013 * thread Thread control block pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1014 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1015 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1016 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1017 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1018 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1019 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1020 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1021 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1022 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1023 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1024 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1025 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1026 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1027 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1028
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1029 @VOID TCT_Control_To_Thread(TC_TCB *thread)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1030 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1031 TCT_Control_To_Thread:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1032
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1033 @ Setup the current thread pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1034 @ TCD_Current_Thread = (VOID *) thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1035
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1036 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1037 LDR r2,[r0, #0x1c] @ Pickup scheduled count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1038 STR r0,[r1, #0] @ Setup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1039
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1040 @ Increment the thread scheduled counter.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1041 @ thread -> tc_scheduled++;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1042
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1043 LDR r3,[r0, #0x20] @ Pickup time slice value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1044 ADD r2,r2,#1 @ Increment the scheduled count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1045 STR r2,[r0, #0x1c] @ Store new scheduled count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1046
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1047 @ Check for time slice option.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1048 @ if (thread -> tc_cur_time_slice)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1049 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1050 CMP r3,#0 @ Is there a time slice?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1051 BEQ TCT_No_Start_TS_1 @ If 0, there is no time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1052
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1053 @ Start a time slice.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1054 @ TMD_Time_Slice = thread -> tc_cur_time_slice;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1055 @ TMD_Time_Slice_State = 0;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1056
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1057 LDR r2,Time_Slice @ Pickup address of TMD_Time_Slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1058 LDR r1,Slice_State @ Pickup address of
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1059 @ TMD_Time_Slice_State
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1060 STR r3,[r2, #0] @ Setup the time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1061 MOV r2,#0 @ Build active state flag
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1062 STR r2,[r1,#0] @ Set the active flag
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1063 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1064 TCT_No_Start_TS_1:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1065 #ifdef INCLUDE_PROVIEW
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1066 @ Nucleus ProView Hook
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1067
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1068 STR r0,[r13, #-4]! @ Save r0 on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1069 BL _NU_Schedule_Task_Hook @ Branch to RTView
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1070 LDR r0,[r13], #4 @ Recover return address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1071 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1072
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1073
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1074 @ Pickup the stack pointer and resume the thread.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1075 @ REG_Stack_Ptr = thread -> tc_stack_pointer;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1076
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1077 LDR r13,[r0, #0x2c] @ Switch to thread's stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1078
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1079 @ Pop off the saved information associated with the thread. After we
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1080 @ determine which type of stack is present. A 1 on the top of the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1081 @ stack indicates an interrupt stack, while a 0 on the top of the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1082 @ stack indicates a solicited type of stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1083
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1084 @ Remember that the interrupt level that is restored must represent
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1085 @ the interrupt level in TCD_Interrupt_Level.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1086
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1087 LDR r1,[r13], #4 @ Pop off the stack type
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1088 CMP r1,#1 @ See if it is an interrupt stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1089 BEQ TCT_Interrupt_Resume @ If so, an interrupt resume of
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1090 @ thread is required
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1091 LDR r1, Int_Level @ Pickup address of interrupt
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1092 @ lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1093 MRS r0,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1094 BIC r0,r0,#LOCK_MSK @ Clear lockout mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1095
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1096 BIC r0,r0,#0x80000000
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1097
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1098
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1099 LDR r2,[r1, #0] @ Pickup interrupt lockout mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1100 ORR r0,r0,r2 @ Build new interrupt lockout mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1101 #if 1 /* was .if THUMB */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1102 LDR r2,[r13], #4 @ Pop off the state mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1103 ORR r0,r0,r2 @ Set appropriate state
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1104 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1105 MSR SPSR,r0 @ Place it into the SPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1106 LDMIA r13!,{r4-r12,r15}^ @ A solicited return is required.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1107 @ This type of return only
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1108 @ recovers r4-r13 & r15
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1109 TCT_Interrupt_Resume:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1110 LDR r0,[r13], #4 @ Pop off the CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1111 LDR r1,Int_Level @ Pickup address of interrupt
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1112 @ lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1113 BIC r0,r0,#LOCK_MSK @ Clear lockout mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1114 LDR r2,[r1, #0] @ Pickup interrupt lockout mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1115 ORR r0,r0,r2 @ Build new interrupt lockout mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1116 MSR SPSR,r0 @ Place it into the SPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1117 LDMIA r13,{r0-r15}^ @ Recover all registers and resume
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1118 @ at point of interrupt
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1119 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1120
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1121 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1122 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1123 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1124 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1125 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1126 * TCT_Control_To_System
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1127 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1128 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1129 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1130 * This function returns control from a thread to the system. Note
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1131 * that this service is called in a solicited manner, i.e. it is
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1132 * not called from an interrupt thread. Registers required by the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1133 * compiler to be preserved across function boundaries are saved by
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1134 * this routine. Note that this is usually a sub-set of the total
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1135 * number of available registers.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1136 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1137 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1138 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1139 * Other Components
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1140 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1141 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1142 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1143 * TCT_Schedule Schedule the next thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1144 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1145 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1146 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1147 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1148 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1149 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1150 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1151 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1152 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1153 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1154 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1155 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1156 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1157 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1158 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1159 * C. Meredith 03-01-1994 Corrected problem in time-slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1160 * reset logic, resulting in
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1161 * version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1162 * D. Lamie 03-18-1994 Verified version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1163 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1164 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1165 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1166
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1167 @VOID TCT_Control_To_System(void)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1168 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1169
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1170 .globl TCT_Control_To_System
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1171 TCT_Control_To_System:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1172
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1173 @ Lockout interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1174
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1175 MRS r0,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1176 ORR r0,r0,#LOCKOUT @ Build interrupt lockout value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1177 MSR CPSR,r0 @ Lockout interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1178
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1179 @ Save a minimal context of the thread.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1180
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1181 STMDB r13!,{r4-r12,r14} @ Save minimal context of thread on
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1182 @ the current stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1183 #if 1 /* was .if THUMB */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1184 MOV r2,r14 @ Determine what state the caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1185 MOV r2,r2,LSL #31 @ was in and build an
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1186 MOV r2,r2,LSR #26 @ appropriate state mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1187 STR r2,[r13, #-4]! @ Place it on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1188 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1189
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1190 MOV r2,#0 @ Build solicited stack type value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1191 @ and NU_NULL value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1192 STR r2,[r13, #-4]! @ Place it on the top of the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1193
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1194 @ Setup a pointer to the thread control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1195 @ REG_Thread_Ptr = (TC_TCB *) TCD_Current_Thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1196
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1197 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1198 LDR r0,[r1, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1199
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1200 @ Clear the current thread control block pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1201 @ TCD_Current_Thread = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1202
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1203 LDR r3,Slice_State @ Pickup time slice state address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1204 STR r2,[r1, #0] @ Set current thread pointer to
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1205 @ NU_NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1206
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1207 @ Check to see if a time slice is active. If so, copy the original time
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1208 @ slice into the current time slice field of the task's control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1209 @ if (TMD_Time_Slice_State == 0)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1210 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1211 LDR r1,[r3, #0] @ Pickup time slice state flag
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1212 CMP r1,#0 @ Compare with active value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1213 BNE TCT_No_Stop_TS_1 @ If non-active, don't disable
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1214
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1215
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1216 @ Insure that the next time the task runs it gets a fresh time
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1217 @ slice.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1218 @ REG_Thread_Ptr -> tc_cur_time_slice = REG_Thread_Ptr -> tc_time_slice;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1219
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1220 LDR r1,[r0, #0x40] @ Pickup original time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1221
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1222 @ Clear any active time slice by setting the state to NOT_ACTIVE.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1223 @ TMD_Time_Slice_State = 1;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1224
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1225 MOV r2,#1 @ Build disable value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1226 STR r2,[r3, #0] @ Disable time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1227 STR r1,[r0, #0x20] @ Reset current time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1228 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1229 TCT_No_Stop_TS_1:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1230
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1231 @ Save off the current stack pointer in the control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1232 @ REG_Thread_Ptr -> tc_stack_pointer = (VOID *) REG_Stack_Ptr;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1233
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1234 STR r13,[r0, #0x2c] @ Save the thread's stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1235
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1236 @ Clear the task's current protection.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1237 @ (REG_Thread_Ptr -> tc_current_protect) -> tc_tcb_pointer = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1238 @ REG_Thread_Ptr -> tc_current_protect = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1239
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1240 LDR r1,[r0, #0x38] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1241 MOV r2,#0 @ Build NU_NULL value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1242 STR r2,[r0, #0x38] @ Clear the protect pointer field
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1243 STR r2,[r1, #0] @ Release the actual protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1244
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1245 @ Switch to the system stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1246 @ REG_Stack_Ptr = TCD_System_Stack;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1247
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1248 LDR r1, System_Stack @ Pickup address of stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1249 LDR r2, System_Limit @ Pickup address of stack limit ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1250 LDR r13,[r1, #0] @ Switch to system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1251 LDR r10,[r2, #0] @ Setup system stack limit
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1252
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1253 @ Finished, return to the scheduling loop.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1254
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1255 B TCT_Schedule @ Return to scheduling loop
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1256 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1257
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1258 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1259 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1260 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1261 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1262 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1263 * TCT_Signal_Exit
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1264 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1265 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1266 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1267 * This function exits from a signal handler. The primary purpose
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1268 * of this function is to clear the scheduler protection and switch
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1269 * the stack pointer back to the normal task's stack pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1270 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1271 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1272 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1273 * TCC_Signal_Shell Signal handling shell func
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1274 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1275 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1276 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1277 * TCT_Schedule Scheduler
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1278 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1279 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1280 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1281 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1282 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1283 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1284 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1285 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1286 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1287 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1288 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1289 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1290 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1291 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1292 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1293 * C. Meredith 03-01-1994 Corrected problem in time-slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1294 * reset logic, resulting in
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1295 * version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1296 * D. Lamie 03-18-1994 Verified version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1297 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1298 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1299 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1300
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1301 @VOID TCT_Signal_Exit(void)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1302 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1303
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1304 .globl TCT_Signal_Exit
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1305 TCT_Signal_Exit:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1306
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1307 @ Lockout interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1308
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1309 MRS r3,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1310 ORR r3,r3,#LOCKOUT @ Build lockout value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1311 MSR CPSR,r3 @ Lockout interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1312
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1313 @ Setup a pointer to the thread control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1314 @ REG_Thread_Ptr = (TC_TCB *) TCD_Current_Thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1315
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1316 LDR r1,Current_Thread @ Pickup address of thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1317 MOV r2,#0 @ Build NU_NULL value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1318 LDR r0,[r1,#0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1319
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1320 @ Clear the current thread control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1321 @ TCD_Current_Thread = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1322
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1323 LDR r3,Slice_State @ Pickup time slice state address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1324 STR r2,[r1, #0] @ Clear current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1325
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1326 @ Check to see if a time slice is active. If so, copy the original time
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1327 @ slice into the current time slice field of the task's control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1328 @ if (TMD_Time_Slice_State == 0)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1329 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1330
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1331 LDR r1,[r3, #0] @ Pickup time slice state flag
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1332 CMP r1,#0 @ Compare with active value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1333 BNE TCT_No_Stop_TS_2 @ If non-active, don't disable
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1334
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1335 @ Insure that the next time the task runs it gets a fresh time
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1336 @ slice.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1337 @ REG_Thread_Ptr -> tc_cur_time_slice = REG_Thread_Ptr -> tc_time_slice;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1338
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1339 LDR r1,[r0, #0x40] @ Pickup original time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1340
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1341 @ Clear any active time slice by setting the state to NOT_ACTIVE.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1342 @ TMD_Time_Slice_State = 1;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1343
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1344 MOV r2,#1 @ Build disable value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1345 STR r2,[r3, #0] @ Disable time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1346 STR r1,[r0, #0x20] @ Reset current time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1347 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1348 TCT_No_Stop_TS_2:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1349
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1350 @ Switch back to the saved stack. The saved stack pointer was saved
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1351 @ before the signal frame was built.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1352 @ REG_Thread_Ptr -> tc_stack_pointer =
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1353 @ REG_Thread_Ptr -> tc_saved_stack_ptr;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1354
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1355 LDR r1,[r0, #0x3c] @ Pickup saved stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1356 STR r1,[r0, #0x2c] @ Place in current stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1357
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1358 @ Clear the task's current protection.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1359 @ (REG_Thread_Ptr -> tc_current_protect) -> tc_tcb_pointer = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1360 @ REG_Thread_Ptr -> tc_current_protect = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1361
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1362 LDR r1,[r0, #0x38] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1363 MOV r2,#0 @ Build NU_NULL value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1364 STR r2,[r0, #0x38] @ Clear the protect pointer field
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1365 STR r2,[r1, #0] @ Release the actual protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1366
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1367 @ Switch to the system stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1368 @ REG_Stack_Ptr = (BYTE_PTR) TCD_System_Stack;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1369
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1370 LDR r1, System_Stack @ Pickup address of stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1371 LDR r2, System_Limit @ Pickup address of stack limit ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1372 LDR r13,[r1, #0] @ Switch to system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1373 LDR r10,[r2, #0] @ Setup system stack limit
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1374
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1375 @ Finished, return to the scheduling loop.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1376
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1377 B TCT_Schedule @ Return to scheduling loop
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1378 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1379
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1380 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1381 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1382 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1383 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1384 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1385 * TCT_Current_Thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1386 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1387 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1388 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1389 * This function returns the current thread pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1390 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1391 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1392 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1393 * Application
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1394 * System Components
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1395 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1396 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1397 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1398 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1399 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1400 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1401 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1402 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1403 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1404 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1405 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1406 * Pointer to current thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1407 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1408 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1409 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1410 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1411 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1412 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1413 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1414 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1415 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1416 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1417
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1418 @VOID *TCT_Current_Thread(void)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1419 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1420
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1421 .globl TCT_Current_Thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1422 TCT_Current_Thread:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1423
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1424 @ Return the current thread pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1425 @ return(TCD_Current_Thread);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1426
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1427 LDR r0, Current_Thread @ Pickup address of thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1428 LDR r0,[r0, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1429
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1430 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1431
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1432 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1433
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1434 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1435 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1436 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1437 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1438 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1439 * TCT_Set_Execute_Task
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1440 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1441 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1442 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1443 * This function sets the current task to execute variable under
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1444 * protection against interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1445 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1446 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1447 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1448 * TCC Scheduling Routines
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1449 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1450 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1451 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1452 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1453 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1454 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1455 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1456 * task Pointer to task control block
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1457 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1458 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1459 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1460 * TCD_Execute_Task Modified variable
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1461 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1462 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1463 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1464 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1465 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1466 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1467 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1468 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1469 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1470 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1471
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1472 @VOID TCT_Set_Execute_Task(TC_TCB *task)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1473 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1474
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1475 .globl TCT_Set_Execute_Task
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1476 TCT_Set_Execute_Task:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1477
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1478 @ Now setup the TCD_Execute_Task pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1479 @ TCD_Execute_Task = task;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1480
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1481 LDR r1, Execute_Task @ Pickup execute task ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1482 STR r0,[r1,#0] @ Setup new task to execute
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1483
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1484 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1485
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1486 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1487
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1488 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1489 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1490 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1491 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1492 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1493 * TCT_Protect
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1494 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1495 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1496 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1497 * This function protects against multiple thread access.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1498 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1499 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1500 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1501 * Application
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1502 * System Components
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1503 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1504 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1505 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1506 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1507 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1508 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1509 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1510 * protect Pointer to protection block
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1511 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1512 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1513 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1514 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1515 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1516 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1517 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1518 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1519 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1520 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1521 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1522 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1523 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1524 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1525
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1526 @VOID TCT_Protect(TC_PROTECT *protect)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1527 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1528
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1529 .globl TCT_Protect
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1530 TCT_Protect:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1531
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1532 @ Determine if the caller is in a task or HISR thread.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1533 @ if (TCD_Current_Thread)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1534 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1535
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1536 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1537 LDR r3,[r1, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1538 CMP r3,#0 @ Check to see if it is non-NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1539 BEQ TCT_Skip_Protect @ If NULL, skip protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1540
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1541 @ Lockout interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1542
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1543 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1544 ORR r1,r1,#LOCKOUT @ Place lockout value in
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1545 MSR CPSR,r1 @ Lockout interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1546
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1547 @ Wait until the protect structure is available.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1548 @ while (protect -> tc_tcb_pointer != NU_NULL)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1549 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1550
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1551 TCT_Protect_Loop:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1552 LDR r1,[r0, #0] @ Pickup protection owner field
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1553 CMP r1,#0 @ Is there any protection?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1554 BEQ TCT_Protect_Available @ If NU_NULL, no current protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1555
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1556 @ Protection structure is not available.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1557
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1558 @ Indicate that another thread is waiting.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1559 @ protect -> tc_thread_waiting = 1;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1560
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1561 MOV r2,#1 @ Build thread waiting flag
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1562 STR r2,[r0, #4] @ Set waiting field
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1563
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1564 @ Directly schedule the thread waiting.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1565 @ TCT_Schedule_Protected(protect -> tc_tcb_pointer);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1566
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1567 STR r0,[r13, #-4]! @ Save r0 on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1568 STR r14,[r13, #-4]! @ Save r14 on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1569 MOV r0,r3 @ Place current thread into r0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1570 BL TCT_Schedule_Protected @ Call routine to schedule the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1571 @ owner of the thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1572
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1573 LDR r14,[r13], #4 @ Recover saved r14
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1574 LDR r0,[r13], #4 @ Recover saved r0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1575
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1576 @ Lockout interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1577
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1578 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1579 LDR r3,[r1, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1580 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1581 ORR r1,r1,#LOCKOUT @ Place lockout value in
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1582 MSR CPSR,r1 @ Lockout interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1583 B TCT_Protect_Loop @ Examine protect flags again
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1584 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1585 TCT_Protect_Available:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1586
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1587 @ Protection structure is available.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1588
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1589 @ Indicate that this thread owns the protection.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1590 @ protect -> tc_tcb_pointer = TCD_Current_Thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1591
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1592 STR r3,[r0, #0] @ Indicate calling thread owns this
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1593 @ protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1594
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1595 @ Clear the thread waiting flag.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1596 @ protect -> tc_thread_waiting = 0;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1597
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1598 MOV r2,#0 @ Clear value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1599 STR r2,[r0, #4] @ Clear the thread waiting flag
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1600
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1601 @ Save the protection pointer in the thread's control block. Note
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1602 @ that both task and HISR threads share the same control block
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1603 @ format.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1604 @ REG_Thread_Ptr = (TC_TCB *) TCD_Current_Thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1605 @ REG_Thread_Ptr -> tc_current_protect = protect;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1606
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1607 STR r0,[r3, #0x38] @ Setup current protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1608
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1609 @ Restore interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1610
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1611 LDR r2,Int_Level @ Pickup address of interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1612 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1613 LDR r3,[r2, #0] @ Pickup interrupt lockout level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1614 BIC r1,r1,#LOCK_MSK @ Clear lockout bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1615 ORR r1,r1,r3 @ Build new interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1616 MSR CPSR,r1 @ Setup CPSR appropriately
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1617 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1618
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1619 TCT_Skip_Protect:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1620
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1621 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1622
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1623 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1624
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1625 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1626 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1627 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1628 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1629 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1630 * TCT_Unprotect
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1631 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1632 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1633 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1634 * This function releases protection of the currently active
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1635 * thread. If the caller is not an active thread, then this
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1636 * request is ignored.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1637 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1638 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1639 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1640 * Application
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1641 * System Components
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1642 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1643 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1644 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1645 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1646 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1647 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1648 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1649 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1650 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1651 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1652 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1653 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1654 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1655 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1656 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1657 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1658 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1659 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1660 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1661 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1662 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1663 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1664
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1665 @VOID TCT_Unprotect(void)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1666 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1667
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1668 .globl TCT_Unprotect
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1669 TCT_Unprotect:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1670
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1671
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1672 @ Determine if the caller is in a task or HISR thread.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1673 @ if (TCD_Current_Thread)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1674 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1675
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1676 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1677 LDR r3,[r1, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1678 CMP r3,#0 @ Check to see if it is non-NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1679 BEQ TCT_Skip_Unprotect @ If NULL, skip unprotection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1680
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1681 @ Setup a thread control block pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1682 @ REG_Thread_Ptr = (TC_TCB *) TCD_Current_Thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1683
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1684 @ Determine if there is a currently active protection.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1685 @ if (REG_Thread_Ptr -> tc_current_protect)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1686 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1687
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1688 LDR r0,[r3, #0x38] @ Pickup current protect field
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1689 CMP r0,#0 @ Is there a protection in force?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1690 BEQ TCT_Skip_Unprotect @ If not, nothing is protected
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1691
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1692 @ Lockout interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1693
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1694 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1695 ORR r1,r1,#LOCKOUT @ Place lockout value in
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1696 MSR CPSR,r1 @ Lockout interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1697
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1698 @ Yes, this thread still has this protection structure.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1699 @ REG_Protect_Ptr = REG_Thread_Ptr -> tc_current_protect;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1700
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1701 @ Is there a higher priority thread waiting for the protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1702 @ structure?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1703 @ if (REG_Protect_Ptr -> tc_thread_waiting)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1704
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1705 LDR r2,[r0, #4] @ Pickup thread waiting flag
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1706 CMP r2,#0 @ Are there any threads waiting?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1707 BEQ TCT_Not_Waiting_Unpr @ If not, just release protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1708
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1709 @ Transfer control to the system. Note that this
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1710 @ automatically clears the current protection and it returns
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1711 @ to the caller of this routine instead of this routine.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1712 @ TCT_Control_To_System();
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1713
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1714 B TCT_Control_To_System @ Return control to the system
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1715
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1716 @ else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1717 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1718 TCT_Not_Waiting_Unpr:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1719
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1720 @ Clear the protection.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1721 @ REG_Thread_Ptr -> tc_current_protect = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1722 @ REG_Protect_Ptr -> tc_tcb_pointer = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1723
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1724 MOV r2,#0 @ Build NU_NULL value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1725 STR r2,[r0, #0] @ Release the protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1726 STR r2,[r3, #0x38] @ Clear protection pointer in the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1727 @ control block
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1728
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1729 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1730
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1731 TCT_Not_Protected:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1732 @ Restore interrupts again.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1733
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1734 LDR r2,Int_Level @ Pickup address of interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1735 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1736 LDR r3,[r2, #0] @ Pickup interrupt lockout level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1737 BIC r1,r1,#LOCK_MSK @ Clear lockout bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1738 ORR r1,r1,r3 @ Build new interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1739 MSR CPSR,r1 @ Setup CPSR appropriately
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1740
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1741 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1742 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1743 TCT_Skip_Unprotect:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1744
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1745 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1746
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1747 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1748
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1749 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1750 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1751 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1752 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1753 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1754 * TCT_Unprotect_Specific
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1755 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1756 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1757 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1758 * This function releases a specific protection structure.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1759 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1760 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1761 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1762 * Application
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1763 * System Components
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1764 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1765 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1766 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1767 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1768 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1769 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1770 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1771 * protect Pointer to protection block
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1772 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1773 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1774 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1775 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1776 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1777 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1778 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1779 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1780 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1781 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1782 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1783 * C. Meredith 03-01-1994 Corrected problem in time-slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1784 * reset logic, corrected bug
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1785 * using protect ptr, resulting
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1786 * in version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1787 * D. Lamie 03-18-1994 Verified version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1788 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1789 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1790 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1791
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1792 @VOID Specific(TC_PROTECT *protect)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1793 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1794
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1795 .globl TCT_Unprotect_Specific
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1796 TCT_Unprotect_Specific:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1797
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1798 @ Determine if the caller is in a task or HISR thread.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1799 @ if (TCD_Current_Thread)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1800 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1801
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1802 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1803 LDR r3,[r1, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1804 CMP r3,#0 @ Check to see if it is non-NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1805 BEQ TCT_Skip_Unprot_Spec @ If NULL, skip unprotect specific
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1806
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1807 @ Lockout interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1808
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1809 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1810 ORR r1,r1,#LOCKOUT @ Place lockout value in
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1811 MSR CPSR,r1 @ Lockout interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1812
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1813 @ Clear the protection pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1814 @ protect -> tc_tcb_pointer = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1815
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1816 MOV r2,#0 @ Build NU_NULL value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1817 STR r2,[r0, #0] @ Clear protection ownership
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1818
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1819 @ Determine if a thread is waiting.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1820 @ if (protect -> tc_thread_waiting)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1821 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1822
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1823 LDR r1,[r0, #4] @ Pickup the waiting field
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1824 CMP r1,#0 @ Is there another thread waiting?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1825 BEQ TCT_Not_Waiting_Unspec @ No, restore interrupts and return
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1826
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1827 @ A higher-priority thread is waiting.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1828
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1829 @ Save a minimal context of the thread.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1830
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1831 STMDB r13!,{r4-r12,r14} @ Save minimal context of thread on
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1832 @ the current stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1833
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1834 #if 1 /* was .if THUMB */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1835 MOV r2,r14 @ Determine what state the caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1836 MOV r2,r2,LSL #31 @ was in and build an
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1837 MOV r2,r2,LSR #26 @ appropriate state mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1838 STR r2,[r13, #-4]! @ Place it on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1839 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1840
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1841 MOV r2,#0 @ Build solicited stack type value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1842 @ and NU_NULL value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1843 STR r2,[r13, #-4]! @ Place it on the top of the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1844
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1845 @ Setup a pointer to the thread control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1846 @ REG_Thread_Ptr = (TC_TCB *) TCD_Current_Thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1847
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1848 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1849 LDR r0,[r1, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1850
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1851 @ Clear the current thread control block pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1852 @ TCD_Current_Thread = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1853
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1854 LDR r3,Slice_State @ Pickup time slice state address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1855 STR r2,[r1, #0] @ Set current thread pointer to
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1856 @ NU_NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1857
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1858 @ Check to see if a time slice is active. If so, copy the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1859 @ original time slice into the current time slice field of the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1860 @ thread's control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1861 @ if (TMD_Time_Slice_State == 0)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1862 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1863
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1864 LDR r1,[r3, #0] @ Pickup time slice state flag
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1865 CMP r1,#0 @ Compare with active value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1866 BNE TCT_No_Stop_TS_3 @ If non-active, don't disable
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1867
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1868 @ Insure that the next time the task runs it gets a fresh time
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1869 @ slice.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1870 @ REG_Thread_Ptr -> tc_cur_time_slice =
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1871 @ REG_Thread_Ptr -> tc_time_slice;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1872
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1873 LDR r1,[r0, #0x40] @ Pickup original time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1874
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1875 @ Clear any active time slice by setting the state to
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1876 @ NOT_ACTIVE.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1877 @ TMD_Time_Slice_State = 1;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1878
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1879 MOV r2,#1 @ Build disable value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1880 STR r2,[r3, #0] @ Disable time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1881 STR r1,[r0, #0x20] @ Reset current time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1882 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1883
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1884 TCT_No_Stop_TS_3:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1885
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1886 @ Save off the current stack pointer in the control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1887 @ REG_Thread_Ptr -> tc_stack_pointer = (VOID *) REG_Stack_Ptr;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1888
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1889 STR r13,[r0, #0x2c] @ Save the thread's stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1890
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1891 @ Switch to the system stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1892 @ REG_Stack_Ptr = TCD_System_Stack;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1893
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1894 LDR r1,System_Stack @ Pickup address of stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1895 LDR r2,System_Limit @ Pickup address of stack limit ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1896 LDR r13,[r1, #0] @ Switch to system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1897 LDR r10,[r2, #0] @ Setup system stack limit
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1898
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1899 @ Finished, return to the scheduling loop.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1900
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1901 B TCT_Schedule @ Return to scheduling loop
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1902
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1903 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1904 @ else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1905 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1906 TCT_Not_Waiting_Unspec:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1907
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1908 @ No higher-priority thread is waiting.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1909
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1910 @ Restore interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1911
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1912 LDR r2,Int_Level @ Pickup address of interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1913 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1914 LDR r3,[r2, #0] @ Pickup interrupt lockout level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1915 BIC r1,r1,#LOCK_MSK @ Clear lockout bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1916 ORR r1,r1,r3 @ Build new interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1917 MSR CPSR,r1 @ Setup CPSR appropriately
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1918
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1919 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1920 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1921
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1922 TCT_Skip_Unprot_Spec:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1923
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1924 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1925
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1926 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1927
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1928 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1929 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1930 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1931 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1932 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1933 * TCT_Set_Current_Protect
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1934 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1935 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1936 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1937 * This function sets the current protection field of the current
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1938 * thread's control block to the specified protection pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1939 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1940 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1941 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1942 * TCC_Resume_Task Resume task function
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1943 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1944 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1945 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1946 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1947 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1948 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1949 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1950 * protect Pointer to protection block
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1951 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1952 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1953 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1954 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1955 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1956 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1957 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1958 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1959 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1960 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1961 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1962 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1963 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1964 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1965
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1966 @VOID TCT_Set_Current_Protect(TC_PROTECT *protect)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1967 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1968
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1969 .globl TCT_Set_Current_Protect
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1970 TCT_Set_Current_Protect:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1971
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1972 @ Determine if the caller is in a task or HISR thread.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1973 @ if (TCD_Current_Thread)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1974 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1975
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1976 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1977 LDR r3,[r1, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1978 CMP r3,#0 @ Check to see if a thread is
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1979 @ active
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1980
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1981 @ Point at the current thread control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1982 @ REG_Thread_Ptr = (TC_TCB *) TCD_Current_Thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1983
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1984 @ Modify the current protection.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1985 @ REG_Thread_Ptr -> tc_current_protect = protect;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1986
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1987 STRNE r0,[r3, #0x38] @ Setup new protection
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1988 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1989
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1990
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1991 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1992
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1993 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1994
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1995 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1996 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1997 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1998 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1999 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2000 * TCT_Protect_Switch
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2001 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2002 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2003 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2004 * This function waits until a specific task no longer has any
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2005 * protection associated with it. This is necessary since task's
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2006 * cannot be suspended or terminated unless they have released all
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2007 * of their protection.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2008 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2009 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2010 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2011 * System Components
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2012 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2013 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2014 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2015 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2016 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2017 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2018 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2019 * thread Pointer to thread control blk
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2020 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2021 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2022 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2023 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2024 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2025 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2026 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2027 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2028 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2029 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2030 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2031 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2032 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2033 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2034
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2035 @VOID TCT_Protect_Switch(VOID *thread)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2036 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2037
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2038 .globl TCT_Protect_Switch
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2039 TCT_Protect_Switch:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2040
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2041 @ Lockout interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2042
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2043 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2044 ORR r1,r1,#LOCKOUT @ Place lockout value in
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2045 MSR CPSR,r1 @ Lockout interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2046
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2047 @ REG_Thread_Ptr = (TC_TCB *) thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2048
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2049 @ Wait until the specified task has no protection associated with it.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2050 @ while (REG_Thread_Ptr -> tc_current_protect)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2051 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2052
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2053 LDR r1,[r0, #0x38] @ Pickup protection of specified
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2054 @ thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2055 CMP r1,#0 @ Does the specified thread have
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2056 @ an active protection?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2057 BEQ TCT_Switch_Done @ If not, protect switch is done
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2058
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2059 @ Let the task run again in an attempt to clear its protection.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2060
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2061 @ Indicate that a higher priority thread is waiting.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2062 @ (REG_Thread_Ptr -> tc_current_protect) -> tc_thread_waiting = 1;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2063
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2064 MOV r2,#1 @ Build waiting flag value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2065 STR r2,[r1, #4] @ Set waiting flag of the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2066 @ protection owned by the other
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2067 @ thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2068
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2069 @ Directly schedule the thread waiting.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2070 @ TCT_Schedule_Protected((REG_Thread_Ptr -> tc_current_protect)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2071 @ -> tc_tcb_pointer);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2072
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2073 LDR r2,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2074 STR r0,[r13, #-4]! @ Save r0 on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2075 STR r14,[r13, #-4]! @ Save r14 on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2076 MOV r1,r0 @ Move new thread into r1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2077 LDR r0,[r2, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2078 BL TCT_Schedule_Protected @ Call routine to schedule the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2079 @ owner of the thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2080
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2081 LDR r14,[r13], #4 @ Recover saved r14
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2082 LDR r0,[r13], #4 @ Recover saved r0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2083
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2084 @ Lockout interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2085
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2086 B TCT_Protect_Switch @ Branch to top of routine and
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2087 @ start over
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2088 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2089 TCT_Switch_Done:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2090
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2091 @ Restore interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2092
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2093 LDR r2,Int_Level @ Pickup address of interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2094 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2095 LDR r3,[r2, #0] @ Pickup interrupt lockout level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2096 BIC r1,r1,#LOCK_MSK @ Clear lockout bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2097 ORR r1,r1,r3 @ Build new interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2098 MSR CPSR,r1 @ Setup CPSR appropriately
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2099
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2100
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2101 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2102
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2103 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2104
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2105 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2106 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2107 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2108 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2109 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2110 * TCT_Schedule_Protected
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2111 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2112 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2113 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2114 * This function saves the minimal context of the thread and then
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2115 * directly schedules the thread that has protection over the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2116 * the thread that called this routine.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2117 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2118 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2119 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2120 * TCT_Protect
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2121 * TCT_Protect_Switch
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2122 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2123 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2124 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2125 * TCT_Control_To_Thread Transfer control to protected
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2126 * thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2127 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2128 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2129 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2130 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2131 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2132 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2133 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2134 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2135 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2136 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2137 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2138 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2139 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2140 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2141 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2142 * C. Meredith 03-01-1994 Corrected problem in time-slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2143 * reset logic, resulting in
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2144 * version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2145 * D. Lamie 03-18-1994 Verified version 1.1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2146 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2147 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2148 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2149
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2150 @VOID TCT_Schedule_Protected(VOID *thread)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2151 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2152
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2153 .globl TCT_Schedule_Protected
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2154 TCT_Schedule_Protected:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2155
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2156 @ Interrupts are already locked out by the caller.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2157
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2158 @ Save minimal context required by the system.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2159
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2160 STMDB r13!,{r4-r12,r14} @ Save minimal context of thread on
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2161 @ the current stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2162
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2163 #if 1 /* was .if THUMB */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2164 MOV r2,r14 @ Determine what state the caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2165 MOV r2,r2,LSL #31 @ was in and build an
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2166 MOV r2,r2,LSR #26 @ appropriate state mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2167 STR r2,[r13, #-4]! @ Place it on the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2168 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2169
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2170 MOV r2,#0 @ Build solicited stack type value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2171 @ and NU_NULL value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2172 STR r2,[r13, #-4]! @ Place it on the top of the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2173 MOV r4,r1 @ Save thread to schedule
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2174
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2175 @ Setup a pointer to the thread control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2176 @ REG_Thread_Ptr = (TC_TCB *) TCD_Current_Thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2177
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2178 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2179
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2180 @ Clear the current thread control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2181 @ TCD_Current_Thread = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2182
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2183 LDR r3,Slice_State @ Pickup time slice state address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2184 STR r2,[r1, #0] @ Set current thread pointer to
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2185 @ NU_NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2186
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2187 @ Check to see if a time slice is active. If so, copy the original time
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2188 @ slice into the current time slice field of the task's control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2189 @ if (TMD_Time_Slice_State == 0)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2190 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2191
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2192 LDR r1,[r3, #0] @ Pickup time slice state flag
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2193 CMP r1,#0 @ Compare with active value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2194 BNE TCT_No_Stop_TS_4 @ If non-active, don't disable
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2195
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2196 @ Insure that the next time the task runs it gets a fresh time
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2197 @ slice.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2198 @ REG_Thread_Ptr -> tc_cur_time_slice = REG_Thread_Ptr -> tc_time_slice;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2199
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2200 LDR r1,[r0, #0x40] @ Pickup original time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2201
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2202 @ Clear any active time slice by setting the state to NOT_ACTIVE.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2203 @ TMD_Time_Slice_State = 1;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2204
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2205 MOV r2,#1 @ Build disable value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2206 STR r2,[r3, #0] @ Disable time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2207 STR r1,[r0, #0x20] @ Reset current time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2208
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2209 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2210 TCT_No_Stop_TS_4:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2211
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2212 @ Save off the current stack pointer in the control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2213 @ REG_Thread_Ptr -> tc_stack_pointer = (VOID *) REG_Stack_Ptr;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2214
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2215 STR r13,[r0, #0x2c] @ Save the thread's stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2216
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2217 @ Switch to the system stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2218 @ TCD_System_Stack = (VOID *) REG_Stack_Ptr;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2219
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2220 LDR r1,System_Stack @ Pickup address of stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2221 LDR r2,System_Limit @ Pickup address of stack limit ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2222 LDR r13,[r1, #0] @ Switch to system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2223 LDR r10,[r2, #0] @ Setup system stack limit
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2224
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2225 @ Transfer control to the specified thread directly.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2226 @ TCT_Control_To_Thread(thread);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2227
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2228 LDR r2,Int_Level @ Pickup address of interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2229 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2230 LDR r3,[r2, #0] @ Pickup interrupt lockout level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2231 BIC r1,r1,#LOCK_MSK @ Clear lockout bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2232 ORR r1,r1,r3 @ Build new interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2233 MOV r0,r4 @ Indicate thread to schedule
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2234 MSR CPSR,r1 @ Setup CPSR appropriately
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2235 ORR r1,r1,#LOCKOUT @ Build lockout value again
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2236 MSR CPSR,r1 @ Lockout interrupts again
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2237 B TCT_Control_To_Thread @ Schedule the thread indirectly
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2238 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2239
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2240 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2241 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2242 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2243 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2244 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2245 * TCT_Interrupt_Context_Save
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2246 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2247 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2248 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2249 * This function saves the interrupted thread's context. Nested
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2250 * interrupts are also supported. If a task or HISR thread was
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2251 * interrupted, the stack pointer is switched to the system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2252 * after the context is saved.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2253 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2254 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2255 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2256 * Application ISRs Assembly language ISRs
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2257 * INT_Interrupt_Shell Interrupt handler shell
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2258 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2259 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2260 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2261 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2262 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2263 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2264 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2265 * vector Interrupt's vector number
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2266 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2267 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2268 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2269 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2270 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2271 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2272 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2273 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2274 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2275 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2276 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2277 * D. Driscoll 01-04-2002 Released version 1.13.3.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2278 * Updated to handle nested /
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2279 * prioritized IRQs
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2280 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2281 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2282
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2283 @VOID TCT_Interrupt_Context_Save(INT vector)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2284 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2285
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2286 .globl TCT_Interrupt_Context_Save
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2287 TCT_Interrupt_Context_Save:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2288 @ Determine if this is a nested interrupt.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2289 LDR r1,Int_Count @ Pickup address of interrupt count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2290 LDR r2,[r1, #0] @ Pickup interrupt counter
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2291 ADD r2,r2,#1 @ Add 1 to interrupt counter
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2292 STR r2,[r1, #0] @ Store new interrupt counter value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2293 CMP r2,#1 @ Is it nested?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2294 BEQ TCT_Not_Nested_Save @ No
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2295
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2296 @ Nested interrupt. Save complete context on the current stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2297 TCT_Nested_Save:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2298
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2299 /* No longer needed in the FreeCalypso version, as we can use r0 instead. */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2300 #if 0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2301 @ 1. Save another register on the exception stack so we have enough to work with
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2302 STMDB r13!,{r5}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2303 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2304
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2305 @ 2. Save the necessary exception registers into r1-r3
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2306 MOV r1,r13 @ Put the exception r13 into r1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2307 MOV r2,r14 @ Move the return address for the caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2308 @ of this function into r2
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2309 MRS r3,spsr @ Put the exception spsr into r3
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2310
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2311 @ 3. Adjust the exception stack pointer for future exceptions
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2312 ADD r13,r13,#20 @ r13 reset to pre-interrupt value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2313
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2314 @ 4. Switch CPU modes to save context on system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2315 MRS r0,CPSR @ Pickup the current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2316 BIC r0,r0,#MODE_MASK @ Clear the mode bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2317
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2318 ORR r0,r0,#SUP_MODE @ Change to supervisor mode (SVD)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2319
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2320 MSR CPSR,r0 @ Switch modes (IRQ->SVC)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2321
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2322 @ 5. Store the SVC r13 into r5 so the r13 can be saved as is.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2323 @ FreeCalyspo: using r0 instead
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2324 MOV r0,r13
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2325
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2326 @ 6. Save the exception return address on the stack (r15).
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2327 STMDB r0!,{r4}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2328
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2329 @ 7. Save r5-r14 on stack (used to be r6-r14)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2330 STMDB r0!,{r5-r14}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2331
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2332 @ 8. Switch back to using r13 now that the original r13 has been saved.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2333 MOV r13,r0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2334
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2335 /* no longer relevant */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2336 #if 0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2337 @ 9. Get r5 and exception enable registers off of exception stack and
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2338 @ save r5 (stored in r4) back to the system stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2339 LDMIA r1!,{r4-r5}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2340 STMDB r13!,{r4}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2341 MOV r4,r5 @ Put exception enable value into r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2342 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2343
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2344 @ 10. Get the rest of the registers off the exception stack and
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2345 @ save them onto the system stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2346 LDMIA r1!,{r5-r8,r11} @ Get r0-r4 off exception stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2347 STMDB r13!,{r5-r8,r11} @ Put r0-r4 on system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2348
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2349 /* no longer relevant */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2350 #if 0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2351 @ 11. Store the exception enable value back on the exception stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2352 STMDB r1,{r4}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2353 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2354
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2355 @ 12. Save the SPSR on the system stack (CPSR)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2356 STMDB r13!,{r3}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2357
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2358 /* TI's approach to interrupt handling does not support re-enabling here */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2359 #if 0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2360 @ 13. Re-enable interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2361 MRS r1,CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2362 BIC r1,r1,#(IRQ_BIT_OR_FIQ_BIT)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2363 MSR CPSR,r1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2364 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2365
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2366 BX r2 @ Return to calling ISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2367 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2368 @ else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2369 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2370 TCT_Not_Nested_Save:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2371
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2372 @ Determine if a thread was interrupted.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2373 @ if (TCD_Current_Thread)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2374 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2375
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2376 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2377 LDR r1,[r1, #0] @ Pickup the current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2378 CMP r1,#0 @ Is it NU_NULL?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2379 BEQ TCT_Idle_Context_Save @ If no, no real save is necessary
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2380
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2381
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2382 @ Yes, a thread was interrupted. Save complete context on the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2383 @ thread's stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2384
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2385 /* No longer needed in the FreeCalypso version, as we can use r0 instead. */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2386 #if 0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2387 @ 1. Save another register on the exception stack so we have enough to work with
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2388 STMDB r13!,{r5}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2389 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2390
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2391 @ 2. Save the necessary exception registers into r1-r3
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2392 MOV r1,r13 @ Put the exception r13 into r1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2393 MOV r2,r14 @ Move the return address for the caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2394 @ of this function into r2
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2395 MRS r3,spsr @ Put the exception spsr into r3
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2396
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2397 @ 3. Adjust the exception stack pointer for future exceptions
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2398 ADD r13,r13,#20 @ r13 reset to pre-interrupt value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2399
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2400 @ 4. Switch CPU modes to save context on system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2401 MRS r0,CPSR @ Pickup the current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2402 BIC r0,r0,#MODE_MASK @ Clear the mode bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2403
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2404 ORR r0,r0,#SUP_MODE @ Change to supervisor mode (SVD)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2405
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2406 MSR CPSR,r0 @ Switch modes (IRQ->SVC)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2407
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2408 @ 5. Store the SVC r13 into r5 so the r13 can be saved as is.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2409 @ FreeCalyspo: using r0 instead
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2410 MOV r0,r13
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2411
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2412 @ 6. Save the exception return address on the stack (r15).
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2413 STMDB r0!,{r4}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2414
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2415 @ 7. Save r5-r14 on stack (used to be r6-r14)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2416 STMDB r0!,{r5-r14}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2417
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2418 @ 8. Switch back to using r13 now that the original r13 has been saved.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2419 MOV r13,r0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2420
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2421 /* no longer relevant */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2422 #if 0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2423 @ 9. Get r5 and exception enable registers off of exception stack and
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2424 @ save r5 (stored in r4) back to the system stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2425 LDMIA r1!,{r4-r5}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2426 STMDB r13!,{r4}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2427 MOV r4,r5 @ Put exception enable value into r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2428 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2429
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2430 @ 10. Get the rest of the registers off the exception stack and
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2431 @ save them onto the system stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2432 LDMIA r1!,{r5-r8,r11} @ Get r0-r4 off exception stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2433 STMDB r13!,{r5-r8,r11} @ Put r0-r4 on system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2434
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2435 /* no longer relevant */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2436 #if 0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2437 @ 11. Store the exception enable value back on the exception stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2438 STMDB r1,{r4}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2439 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2440
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2441 @ 12. Save the SPSR on the system stack (CPSR)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2442 STMDB r13!,{r3}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2443
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2444 @ 13. Save stack type to the task stack (1=interrupt stack)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2445 MOV r1,#1 @ Interrupt stack type
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2446 STMDB r13!,{r1}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2447
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2448 @ Save the thread's stack pointer in the control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2449 @ REG_Thread_Ptr = (TC_TCB *) TCD_Current_Thread
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2450 @ REG_Thread_Ptr -> tc_stack_pointer = (VOID *) REG_Stack_Ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2451
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2452 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2453 LDR r3,[r1, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2454 STR r13,[r3, #TC_STACK_POINTER] @ Save stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2455
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2456 @ Switch to the system stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2457 @ REG_Stack_Ptr = TCD_System_Stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2458
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2459 LDR r1,System_Stack @ Pickup address of stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2460 LDR r3,System_Limit @ Pickup address of stack limit ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2461 LDR r13,[r1, #0] @ Switch to system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2462 LDR r10,[r3, #0] @ Setup system stack limit
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2463
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2464 /* TI's approach to interrupt handling does not support re-enabling here */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2465 #if 0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2466 @ Re-enable interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2467 MRS r1,CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2468 BIC r1,r1,#(IRQ_BIT_OR_FIQ_BIT)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2469 MSR CPSR,r1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2470 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2471
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2472 @ Return to caller ISR.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2473
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2474 BX r2 @ Return to caller ISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2475
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2476 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2477
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2478 TCT_Idle_Context_Save:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2479
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2480 MOV r2,r14 @ Save r14 in r2
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2481 @ LDR r3,[r13] @ Get exception enable value from stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2482 ADD r13,r13,#20 @ Adjust exception r13 for future interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2483 @ STR r3,[r13] @ Put exception enable value back on stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2484
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2485 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2486 BIC r1,r1,#MODE_MASK @ Clear the current mode
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2487 @ BIC r1,r1,#(IRQ_BIT_OR_FIQ_BIT) @ Re-enable interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2488
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2489 ORR r1,r1,#SUP_MODE @ Prepare to switch to supervisor
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2490 @ mode (SVC)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2491 MSR CPSR,r1 @ Switch to supervisor mode (SVC)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2492
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2493 BX r2 @ Return to caller ISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2494
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2495 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2496 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2497
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2498 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2499 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2500 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2501 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2502 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2503 * TCT_Interrupt_Context_Restore
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2504 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2505 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2506 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2507 * This function restores the interrupt context if a nested
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2508 * interrupt condition is present. Otherwise, this routine
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2509 * transfers control to the scheduling function.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2510 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2511 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2512 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2513 * Application ISRs Assembly language ISRs
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2514 * INT_Interrupt_Shell Interrupt handler shell
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2515 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2516 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2517 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2518 * TCT_Schedule Thread scheduling function
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2519 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2520 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2521 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2522 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2523 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2524 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2525 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2526 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2527 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2528 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2529 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2530 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2531 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2532 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2533 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2534 * D. Driscoll 01-04-2002 Released version 1.13.3.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2535 * Updated to handle nested /
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2536 * prioritized IRQs
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2537 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2538 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2539 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2540
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2541 @VOID TCT_Interrupt_Context_Restore(void)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2542 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2543
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2544 .globl TCT_Interrupt_Context_Restore
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2545 TCT_Interrupt_Context_Restore:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2546 @ It is assumed that anything pushed on the stack by ISRs has been
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2547 @ removed upon entry into this routine.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2548
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2549 @ Decrement and check for nested interrupt conditions.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2550 @ if (--TCD_Interrupt_Count)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2551 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2552
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2553 LDR r1,Int_Count @ Pickup address of interrupt count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2554 LDR r2,[r1, #0] @ Pickup interrupt counter
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2555 SUB r2,r2,#1 @ Decrement interrupt counter
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2556 STR r2,[r1, #0] @ Store interrupt counter
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2557 CMP r2,#0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2558 BEQ TCT_Not_Nested_Restore
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2559
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2560 @ Restore previous context.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2561
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2562 LDR r1,[r13], #4 @ Pickup the saved CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2563
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2564 MSR SPSR,r1 @ Place into saved SPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2565 LDMIA r13,{r0-r15}^ @ Return to the point of interrupt
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2566
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2567 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2568 @ else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2569 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2570
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2571 TCT_Not_Nested_Restore:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2572
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2573 @ Determine if a thread is active.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2574 @ if (TCD_Current_Thread)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2575 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2576
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2577 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2578 LDR r0,[r1, #0] @ Pickup current thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2579 CMP r0,#0 @ Determine if a thread is active
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2580 BEQ TCT_Idle_Context_Restore @ If not, idle system restore
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2581
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2582 @ Clear the current thread pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2583 @ TCD_Current_Thread = NU_NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2584
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2585 MOV r2,#0 @ Build NU_NULL value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2586 STR r2,[r1, #0] @ Set current thread ptr to NU_NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2587
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2588 @ Determine if a time slice is active. If so, the remaining
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2589 @ time left on the time slice must be saved in the task's
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2590 @ control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2591 @ if (TMD_Time_Slice_State == 0)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2592 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2593
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2594 LDR r3,Slice_State @ Pickup time slice state address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2595 LDR r1,[r3, #0] @ Pickup time slice state
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2596 CMP r1,#0 @ Determine if time slice active
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2597 BNE TCT_Idle_Context_Restore @ If not, skip time slice reset
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2598
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2599 @ Pickup the remaining portion of the time slice and save it
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2600 @ in the task's control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2601 @ REG_Thread_Ptr -> tc_cur_time_slice = TMD_Time_Slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2602 @ TMD_Time_Slice_State = 1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2603
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2604 LDR r2,Time_Slice @ Pickup address of time slice left
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2605 MOV r1,#1 @ Build disable time slice value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2606 LDR r2,[r2, #0] @ Pickup remaining time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2607 STR r1,[r3, #0] @ Disable time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2608 STR r2,[r0, #TC_CUR_TIME_SLICE] @ Store remaining time slice
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2609
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2610 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2611 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2612 TCT_Idle_Context_Restore:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2613
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2614 @ Reset the system stack pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2615 LDR r1,System_Stack @ Pickup address of stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2616 LDR r2,System_Limit @ Pickup address of stack limit ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2617 LDR r13,[r1, #0] @ Switch to system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2618 LDR r10,[r2, #0] @ Setup system stack limit
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2619
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2620 @ Return to scheduler.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2621
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2622 B TCT_Schedule @ Return to scheduling loop
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2623
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2624 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2625 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2626
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2627 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2628 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2629 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2630 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2631 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2632 * TCT_Activate_HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2633 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2634 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2635 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2636 * This function activates the specified HISR. If the HISR is
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2637 * already activated, the HISR's activation count is simply
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2638 * incremented. Otherwise, the HISR is placed on the appropriate
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2639 * HISR priority list in preparation for execution.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2640 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2641 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2642 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2643 * Application LISRs
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2644 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2645 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2646 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2647 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2648 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2649 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2650 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2651 * hisr Pointer to HISR to activate
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2652 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2653 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2654 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2655 * NU_SUCCESS Successful completion
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2656 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2657 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2658 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2659 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2660 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2661 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2662 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2663 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2664 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2665 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2666
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2667 @STATUS TCT_Activate_HISR(TC_HCB *hisr)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2668 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2669
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2670 .globl TCT_Activate_HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2671 TCT_Activate_HISR:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2672
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2673 @INT priority;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2674
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2675
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2676 @ Lockout interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2677
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2678 STR r4,[r13, #-4]! @ Save r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2679 MRS r4,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2680 ORR r1,r4,#LOCKOUT @ Build interrupt lockout value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2681 MSR CPSR,r1 @ Lockout interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2682
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2683 @ Determine if the HISR is already active.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2684 @ if (hisr -> tc_activation_count)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2685 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2686
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2687 LDR r1,[r0,#0x40] @ Pickup current activation count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2688 CMP r1,#0 @ Is it the first activation?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2689 BEQ TCT_First_Activate @ Yes, place it on the correct list
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2690
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2691 @ Increment the activation count. Make sure that it does not go
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2692 @ to zero.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2693 @ hisr -> tc_activation_count++;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2694
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2695 ADDS r1,r1,#1 @ Increment the activation count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2696 STR r1,[r0,#0x40] @ Store new activation count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2697
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2698 @ if (hisr -> tc_activation_count == 0)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2699
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2700 @ hisr -> tc_activation_count = 0xFFFFFFFFUL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2701
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2702 MVNEQ r1,#0 @ If counter rolled-over reset
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2703 STREQ r1,[r0,#0x40] @ Store all ones count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2704 B TCT_Activate_Done @ Finished with activation
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2705 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2706 @ else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2707 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2708 TCT_First_Activate:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2709
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2710
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2711 @ Set the activation count to 1.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2712 @ hisr -> tc_activation_count = 1;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2713
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2714 MOV r1,#1 @ Initial activation count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2715 STR r1,[r0,#0x40] @ Store initial activation count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2716
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2717 @ Pickup the HISR's priority.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2718 @ priority = hisr -> tc_priority;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2719
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2720 @ Determine if there is something in the given priority list.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2721 @ if (TCD_Active_HISR_Tails[priority])
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2722 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2723
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2724 LDRB r1,[r0,#0x1a] @ Pickup priority of HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2725 LDR r2,HISR_Tails @ Pickup tail pointer base
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2726 LDR r3,[r2,r1,LSL #2] @ Pickup tail pointer for priority
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2727 CMP r3,#0 @ Is this first HISR at priority?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2728 BEQ TCT_First_HISR @ No, append to end of HISR list
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2729
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2730 @ Something is already on this list. Add after the tail.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2731 @ (TCD_Active_HISR_Tails[priority]) -> tc_active_next = hisr;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2732 @ TCD_Active_HISR_Tails[priority] = hisr;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2733
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2734 STR r0,[r3,#0x3c] @ Setup the active next pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2735 STR r0,[r2,r1,LSL #2] @ Setup the tail pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2736 B TCT_Activate_Done @ Finished with activate processing
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2737 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2738 @ else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2739 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2740 TCT_First_HISR:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2741
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2742 @ Nothing is on this list.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2743 @ TCD_Active_HISR_Heads[priority] = hisr;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2744 @ TCD_Active_HISR_Tails[priority] = hisr;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2745
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2746 LDR r3,HISR_Heads @ Pickup address of head pointers
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2747 STR r0,[r2,r1,LSL #2] @ Set tail pointer to this HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2748 STR r0,[r3,r1,LSL #2] @ Set head pointer to this HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2749
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2750 @ Determine the highest priority HISR.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2751 @ if (TCD_Active_HISR_Heads[0])
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2752 @ TCD_Execute_HISR = TCD_Active_HISR_Heads[0];
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2753 @ else if (TCD_Active_HISR_Heads[1])
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2754 @ TCD_Execute_HISR = TCD_Active_HISR_Heads[1];
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2755 @ else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2756 @ TCD_Execute_HISR = TCD_Active_HISR_Heads[2];
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2757
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2758 LDR r1,[r3,#0] @ Pickup priority 0 head pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2759 LDR r0,Execute_HISR @ Build address to execute HISR ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2760 CMP r1,#0 @ Is priority 0 active?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2761 LDREQ r1,[r3,#4] @ If not, pickup priority 1 head
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2762 CMPEQ r1,#0 @ Is priority 1 active?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2763 LDREQ r1,[r3,#8] @ Else, must be priority 2 active
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2764 STR r1,[r0,#0] @ Store which ever priority is the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2765 @ active one
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2766 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2767 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2768 TCT_Activate_Done:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2769
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2770 MSR CPSR,r4 @ Restore interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2771 LDR r4,[r13], #4 @ Restore corrupted r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2772
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2773 @ return(NU_SUCCESS);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2774
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2775 MOV r0,#0 @ Always return NU_SUCCESS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2776
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2777 BX r14 @ Return to caller
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2778
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2779 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2780
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2781 /*
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2782 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2783 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2784 * FUNCTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2785 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2786 * TCT_HISR_Shell
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2787 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2788 * DESCRIPTION
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2789 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2790 * This function is the execution shell of each and every HISR. If
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2791 * the HISR has completed its processing, this shell routine exits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2792 * back to the system. Otherwise, it sequentially calls the HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2793 * routine until the activation count goes to zero.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2794 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2795 * CALLED BY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2796 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2797 * HISR Scheduling
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2798 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2799 * CALLS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2800 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2801 * hisr -> tc_entry Actual entry function of HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2802 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2803 * INPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2804 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2805 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2806 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2807 * OUTPUTS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2808 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2809 * None
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2810 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2811 * HISTORY
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2812 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2813 * NAME DATE REMARKS
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2814 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2815 * W. Lamie 02-15-1994 Created initial version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2816 * D. Lamie 02-15-1994 Verified version 1.0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2817 *
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2818 ************************************************************************
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2819 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2820
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2821 @VOID TCT_HISR_Shell(void)
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2822 @{
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2823 .globl TCT_HISR_Shell
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2824 TCT_HISR_Shell:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2825
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2826 @ Point at the HISR.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2827 @ REG_HISR_Ptr = (TC_HCB *) TCD_Current_Thread;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2828
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2829 LDR r0,Current_Thread @ Build address of thread pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2830 LDR r5,[r0, #0] @ Pickup control block pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2831
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2832 @ do
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2833 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2834 TCT_HISR_Loop:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2835
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2836 @ Call the HISR's entry routine.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2837 @ (*(REG_HISR_Ptr -> tc_entry)) ();
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2838
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2839 /* old TMS470 code:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2840
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2841 .if THUMB = 0
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2842
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2843 MOV r14,r15 ; Setup return value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2844 LDR r15,[r5,#44h] ; Call HISR entry function
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2845 .else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2846 LDR r4,[r5,#44h] ; Get HISR entry function
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2847 TST r4,#1 ; See if calling Thumb or ARM
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2848 BNE Thumbsec
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2849 MOV r14,r15 ; Setup return value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2850 BX r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2851 B ARMCODE
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2852 Thumbsec:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2853 ADD r14, r15, #1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2854 BX r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2855 .state16
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2856 ThumbAfterHisr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2857 MOV r1, r15
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2858 BX r1
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2859 .state32
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2860 .endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2861 */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2862
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2863 /* new code for the GNU style of ARM/Thumb interworking */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2864 ldr r4, [r5, #TC_HISR_ENTRY]
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2865 mov lr, pc
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2866 bx r4
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2867
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2868 @ Lockout interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2869
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2870 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2871 ORR r1,r1,#LOCKOUT @ Build interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2872 MSR CPSR,r1 @ Lockout interrupts
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2873
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2874 @ On return, decrement the activation count and check to see if
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2875 @ it is 0. Once it reaches 0, the HISR should be made inactive.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2876 @ REG_HISR_Ptr -> tc_activation_count--;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2877
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2878
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2879 LDR r0,[r5, #0x40] @ Pickup current activation count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2880 SUBS r0,r0,#1 @ Subtract and set condition codes
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2881 STR r0,[r5, #0x40] @ Store new activation count
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2882 BEQ TCT_HISR_Finished @ Finished processing HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2883
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2884 @ Restore interrupts.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2885
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2886 LDR r2,Int_Level @ Pickup address of interrupt level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2887 MRS r1,CPSR @ Pickup current CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2888 LDR r3,[r2, #0] @ Pickup interrupt lockout level
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2889 BIC r1,r1,#LOCK_MSK @ Clear lockout bits
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2890 ORR r1,r1,r3 @ Build new interrupt lockout
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2891 MSR CPSR,r1 @ Setup CPSR appropriately
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2892 B TCT_HISR_Loop @ Return to HISR loop
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2893 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2894 @ while (REG_HISR_Ptr -> tc_activation_count);
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2895
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2896 TCT_HISR_Finished:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2897
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2898 @ At this point, the HISR needs to be made inactive.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2899
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2900 @ Determine if this is the only HISR on the given priority list.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2901 @ if (REG_HISR_Ptr == TCD_Active_HISR_Tails[REG_HISR_Ptr -> tc_priority])
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2902 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2903
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2904 LDR r14,HISR_Tails @ Pickup tail pointers address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2905 LDRB r3,[r5,#0x1a] @ Pickup priority
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2906 LDR r6,[r14,r3,LSL #2] @ Pickup this priority tail pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2907 LDR r2,Execute_HISR @ Build address to execute HISR ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2908 MOV r12,#0 @ Clear r12
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2909 LDR r1,HISR_Heads @ Pickup head pointers address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2910 CMP r6,r5 @ Is this priority tail the same as
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2911 @ the current HISR?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2912 BNE TCT_More_HISRs @ If not, more HISRs at this
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2913 @ priority
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2914
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2915 @ The only HISR on the list. Clean up the list and check for the
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2916 @ highest priority HISR.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2917 @ TCD_Active_HISR_Heads[REG_HISR_Ptr -> tc_priority] = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2918 @ TCD_Active_HISR_Tails[REG_HISR_Ptr -> tc_priority] = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2919
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2920 STR r12,[r1,r3,LSL #2] @ Set head pointer to NU_NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2921 STR r12,[r14,r3,LSL #2] @ Set tail pointer to NU_NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2922
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2923 @ Determine the highest priority HISR.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2924 @ if (TCD_Active_HISR_Heads[0])
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2925 @ TCD_Execute_HISR = TCD_Active_HISR_Heads[0];
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2926 @ else if (TCD_Active_HISR_Heads[1])
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2927 @ TCD_Execute_HISR = TCD_Active_HISR_Heads[1];
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2928 @ else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2929 @ TCD_Execute_HISR = TCD_Active_HISR_Heads[2];
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2930
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2931 LDR r3,[r1,#0] @ Pickup priority 0 head pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2932 CMP r3,#0 @ Is there an HISR active?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2933 LDREQ r3,[r1,#4] @ If not, pickup priority 1 pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2934 CMPEQ r3,#0 @ Is there an HISR active?
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2935 LDREQ r3,[r1,#8] @ If not, pickup priority 2 pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2936 STR r3,[r2,#0] @ Setup execute HISR pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2937 B TCT_HISR_Exit @ Exit HISR processing
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2938 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2939 @ else
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2940 @ {
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2941
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2942 TCT_More_HISRs:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2943
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2944 @ Move the head pointer to the next HISR in the list.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2945 @ TCD_Active_HISR_Heads[REG_HISR_Ptr -> tc_priority] =
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2946 @ REG_HISR_Ptr -> tc_active_next;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2947
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2948 @ Also set the TCD_Execute_HISR pointer.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2949 @ TCD_Execute_HISR = REG_HISR_Ptr -> tc_active_next;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2950
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2951 LDR r14,[r5,#0x3c] @ Pickup next HISR to activate
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2952 STR r14,[r1,r3,LSL #2] @ Setup new head pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2953 STR r14,[r2, #0] @ Setup execute HISR pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2954 @ }
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2955
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2956 TCT_HISR_Exit:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2957
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2958 @ Build fake return to the top of this loop. The next time the HISR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2959 @ is activated, it will return to the top of this function.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2960
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2961 LDR r14,HISR_Shell @ Pickup address of shell entry
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2962 STMDB r13!,{r4-r12,r14} @ Save minimal context of thread on
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2963 @ the current stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2964 MOV r2,#0 @ Build solicited stack type value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2965 @ and NU_NULL value
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2966 #if 1 /* was .if THUMB */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2967 STR r2,[r13, #-4]! @ Save state mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2968 #endif
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2969 STR r2,[r13, #-4]! @ Place it on the top of the stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2970
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2971 @ Clear the current thread control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2972 @ TCD_Current_Thread = NU_NULL;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2973
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2974 LDR r1,Current_Thread @ Pickup current thread ptr address
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2975 STR r2,[r1, #0] @ Set current thread pointer to
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2976 @ NU_NULL
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2977
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2978 @ Save off the current stack pointer in the control block.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2979 @ REG_HISR_Ptr -> tc_stack_pointer = (VOID *) REG_Stack_Ptr;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2980
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2981
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2982 STR r13,[r5, #0x2c] @ Save the thread's stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2983
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2984
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2985 @ Switch to the system stack.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2986 @ REG_Stack_Ptr = (BYTE_PTR) TCD_System_Stack;
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2987
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2988 LDR r1,System_Stack @ Pickup address of stack pointer
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2989 LDR r2,System_Limit @ Pickup address of stack limit ptr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2990 LDR r13,[r1, #0] @ Switch to system stack
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2991 LDR r10,[r2, #0] @ Setup system stack limit
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2992
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2993 @ Transfer control to the main scheduling loop.
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2994
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2995 B TCT_Schedule @ Return to main scheduling loop
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2996 @}
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2997
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2998 /* FreeCalypso addition, used by riviera/rvf/rvf_task.c: */
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2999 .globl INT_Check_IRQ_Mask
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3000 INT_Check_IRQ_Mask:
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3001 MRS r0,CPSR
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3002 BX lr
d076885a0669 src/nucleus/gcc: initial import from Citrine
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3003