@@ -93,88 +93,114 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
93
93
void * pvParameters )
94
94
{
95
95
uint32_t * pulLocal ;
96
-
97
- /* With large code and large data sizeof( StackType_t ) == 2, and
98
- * sizeof( StackType_t * ) == 4. With small code and small data
99
- * sizeof( StackType_t ) == 2 and sizeof( StackType_t * ) == 2. */
100
-
101
- #if __DATA_MODEL__ == __DATA_MODEL_FAR__
96
+ /* With large data sizeof( StackType_t ) == 2, and
97
+ * sizeof( StackType_t * ) == 4. With small data
98
+ * sizeof( StackType_t ) == 2 and sizeof( StackType_t * ) == 2. */
99
+ #if __DATA_MODEL__ == __DATA_MODEL_FAR__
102
100
{
103
101
/* Far pointer parameters are passed using the A:DE registers (24-bit).
104
102
* Although they are stored in memory as a 32-bit value. Hence decrement
105
103
* the stack pointer, so 2 bytes are left for the contents of A, before
106
104
* storing the pvParameters value. */
107
105
pxTopOfStack -- ;
108
106
pulLocal = ( uint32_t * ) pxTopOfStack ;
109
- * pulLocal = ( uint32_t ) pvParameters ;
110
- pxTopOfStack -- ;
111
-
107
+ #if __CALLING_CONVENTION__ == __CC_V2__
108
+ /* V2: parameter via A:DE, do not push pvParameters on stack */
109
+ #else
110
+ /* V1 or unknown: keep stack write */
111
+ * pulLocal = ( uint32_t ) pvParameters ;
112
+ pxTopOfStack -- ;
113
+ #endif
112
114
/* The return address is a 32-bit value. So decrement the stack pointer
113
115
* in order to make extra room needed to store the correct value. See the
114
116
* comments above the prvTaskExitError() prototype at the top of this file. */
115
117
pxTopOfStack -- ;
116
118
pulLocal = ( uint32_t * ) pxTopOfStack ;
117
119
* pulLocal = ( uint32_t ) prvTaskExitError ;
118
120
pxTopOfStack -- ;
119
-
120
121
/* The task function start address combined with the PSW is also stored
121
122
* as a 32-bit value. So leave a space for the second two bytes. */
122
123
pxTopOfStack -- ;
123
124
pulLocal = ( uint32_t * ) pxTopOfStack ;
124
125
* pulLocal = ( ( ( uint32_t ) pxCode ) | ( portPSW << 24UL ) );
125
126
pxTopOfStack -- ;
126
-
127
- /* An initial value for the AX register. */
128
- * pxTopOfStack = ( StackType_t ) 0x1111 ;
127
+ /* Register image on task entry. */
128
+ #if __CALLING_CONVENTION__ == __CC_V2__
129
+ {
130
+ uint32_t p = ( uint32_t ) pvParameters ;
131
+ uint16_t de_init = (uint16_t )( p & 0xFFFFU );
132
+ uint16_t ax_init = (uint16_t )( ((p >> 16 ) & 0xFFU ) << 8 );
133
+ /* AX register image */
134
+ * pxTopOfStack = ( StackType_t ) ax_init ;
135
+ pxTopOfStack -- ;
136
+ /* HL register image (dummy) */
137
+ * pxTopOfStack = ( StackType_t ) 0x2222 ;
138
+ pxTopOfStack -- ;
139
+ /* CS:ES register image */
140
+ * pxTopOfStack = ( StackType_t ) 0x0F00 ;
141
+ pxTopOfStack -- ;
142
+ /* DE register image */
143
+ * pxTopOfStack = ( StackType_t ) de_init ;
144
+ pxTopOfStack -- ;
145
+ }
146
+ #else
147
+ /* An initial value for the AX register. */
148
+ * pxTopOfStack = ( StackType_t ) 0x1111 ;
149
+ pxTopOfStack -- ;
150
+ /* HL register image (dummy) */
151
+ * pxTopOfStack = ( StackType_t ) 0x2222 ;
152
+ pxTopOfStack -- ;
153
+ /* CS:ES register image */
154
+ * pxTopOfStack = ( StackType_t ) 0x0F00 ;
155
+ pxTopOfStack -- ;
156
+ /* DE register image (dummy) */
157
+ * pxTopOfStack = ( StackType_t ) 0xDEDE ;
158
+ pxTopOfStack -- ;
159
+ #endif
160
+ /* BC remains a dummy value (not used for parameter passing). */
161
+ * pxTopOfStack = ( StackType_t ) 0xBCBC ;
129
162
pxTopOfStack -- ;
130
163
}
131
- #else /* if __DATA_MODEL__ == __DATA_MODEL_FAR__ */
164
+ #else /* if __DATA_MODEL__ == __DATA_MODEL_FAR__ */
132
165
{
133
- /* The return address, leaving space for the first two bytes of the
166
+ /* The return address, leaving space for the first two bytes of the
134
167
* 32-bit value. See the comments above the prvTaskExitError() prototype
135
168
* at the top of this file. */
136
169
pxTopOfStack -- ;
137
170
pulLocal = ( uint32_t * ) pxTopOfStack ;
138
171
* pulLocal = ( uint32_t ) prvTaskExitError ;
139
172
pxTopOfStack -- ;
140
-
141
173
/* Task function. Again as it is written as a 32-bit value a space is
142
174
* left on the stack for the second two bytes. */
143
175
pxTopOfStack -- ;
144
-
145
176
/* Task function start address combined with the PSW. */
146
177
pulLocal = ( uint32_t * ) pxTopOfStack ;
147
178
* pulLocal = ( ( ( uint32_t ) pxCode ) | ( portPSW << 24UL ) );
148
179
pxTopOfStack -- ;
149
-
150
180
/* The parameter is passed in AX. */
151
181
* pxTopOfStack = ( StackType_t ) pvParameters ;
152
182
pxTopOfStack -- ;
183
+ /* An initial value for the HL register. */
184
+ * pxTopOfStack = ( StackType_t ) 0x2222 ;
185
+ pxTopOfStack -- ;
186
+ /* CS and ES registers. */
187
+ * pxTopOfStack = ( StackType_t ) 0x0F00 ;
188
+ pxTopOfStack -- ;
189
+ /* The remaining general purpose registers DE and BC */
190
+ * pxTopOfStack = ( StackType_t ) 0xDEDE ;
191
+ pxTopOfStack -- ;
192
+ * pxTopOfStack = ( StackType_t ) 0xBCBC ;
193
+ pxTopOfStack -- ;
153
194
}
154
- #endif /* if __DATA_MODEL__ == __DATA_MODEL_FAR__ */
155
-
156
- /* An initial value for the HL register. */
157
- * pxTopOfStack = ( StackType_t ) 0x2222 ;
158
- pxTopOfStack -- ;
159
-
160
- /* CS and ES registers. */
161
- * pxTopOfStack = ( StackType_t ) 0x0F00 ;
162
- pxTopOfStack -- ;
163
-
164
- /* The remaining general purpose registers DE and BC */
165
- * pxTopOfStack = ( StackType_t ) 0xDEDE ;
166
- pxTopOfStack -- ;
167
- * pxTopOfStack = ( StackType_t ) 0xBCBC ;
168
- pxTopOfStack -- ;
169
-
195
+ #endif /* __DATA_MODEL__ */
170
196
/* Finally the critical section nesting count is set to zero when the task
171
197
* first starts. */
172
198
* pxTopOfStack = ( StackType_t ) portNO_CRITICAL_SECTION_NESTING ;
173
-
174
199
/* Return a pointer to the top of the stack that has been generated so
175
200
* it can be stored in the task control block for the task. */
176
201
return pxTopOfStack ;
177
202
}
203
+
178
204
/*-----------------------------------------------------------*/
179
205
180
206
static void prvTaskExitError ( void )
0 commit comments