📄 os_cpu_c.lst
字号:
C51 COMPILER V7.06 OS_CPU_C 07/30/2008 11:19:14 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE OS_CPU_C
OBJECT MODULE PLACED IN .\OS_CPU_C.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\uc_51\OS_CPU_C.C BROWSE DEBUG OBJECTEXTEND PRINT(.\OS_CPU_C.lst) OBJECT(
-.\OS_CPU_C.obj)
stmt level source
1 /*
2 *********************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 *
6 * (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
7 * All Rights Reserved
8 *
9 *
10 * KeilC51 Specific code
11 * SMALL MEMORY MODEL
12 *
13 * File : OS_CPU_C.C
14 * By : Jean J. Labrosse
15 * Refer to Code Written By : Yang Yi (http://www.zlgmcu.com/philips/philips-embedsys.asp)
16 * Port to KeilC51 Small Mode By : Li Zhanglin (wzzlin@nankai.edu.cn)
17 *********************************************************************************************************
18 */
19 #define OS_CPU_GLOBALS
20 #define UCOS51_GLOBALS
21 #include "..\uc_os_II\includes.h"
22 #include "..\Ex1_Keil\ucos51_bl.h"
23 /*
24 *********************************************************************************************************
25 * OSTaskStkInit
26 *
27 * Description: Init stack before task running.
28 *
29 * Arguments : task is a pointer to the task code
30 *
31 * pdata is a pointer to a user supplied data area that will be passed to the task
32 * when the task first executes.
33 *
34 * ptos is a pointer to the top of stack. It is assumed that 'ptos' points to
35 * a 'free' entry on the task stack. If OS_STK_GROWTH is set to 1 then
36 * 'ptos' will contain the HIGHEST valid address of the stack. Similarly, if
37 * OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address
38 * of the stack.
39 *
40 * opt specifies options that can be used to alter the behavior of OSTaskStkInit().
41 * (see uCOS_II.H for OS_TASK_OPT_???).
42 *
43 * Returns : Always returns the bottom of stack.
44 *
45 * Note(s) : 1) stack stored as following format
46
47 ; CONTENT START POSITION IN OSTCBStk
48 ; ---------- ----------------------
49 ; AR7
50 ; AR6
51 ; AR5
52 ; AR4
53 ; AR3
54 ; AR2
C51 COMPILER V7.06 OS_CPU_C 07/30/2008 11:19:14 PAGE 2
55 ; AR1
56 ; AR0
57 ; PSW
58 ; DPL
59 ; DPH
60 ; B
61 ; ACC
62 ; HARDWARE STACK CONTENT(NOT INCLUDE REGISTERS) 2+SmltStkSize
63 ; HARDWARE STACK SIZE(INCLUDE REGISTERS) 1+SmltStkSize
64 ; SIMULATED STACK CONTENT 1
65 ; ?C_IBP 0
66
67 *********************************************************************************************************
68 */
69 /*
70 因为uC/OS-II在设计时无法知道当前处理器在进行进程调度时需要保存那些信息.
71 OSTaskStkInit就是初始化堆栈,让Task看起来就好像刚刚进入中断并保存好寄存器的值一样.
72 当OS_Sched调度到该Task时,只需切换到该堆栈中,将寄存器值Pop出来,然后执行一个中断返回指令IRET即可。
73 */
74 void DT_XDATA *OSTaskStkInit (void (DT_CODE *task)(void DT_XDATA *pd), void DT_XDATA *ppdata, void DT_XDAT
-A *ptos, INT16U opt) REENTRANT
75 {
76 1 /*一般是将pdata入栈,flag入栈,task入栈,然后将各寄存器依次入栈。*/
77 1 OS_STK DT_XDATA *stk;
78 1
79 1 ppdata = ppdata;
80 1 opt = opt; /* 保留此句防止警告产生 */
81 1
82 1 /*每个任务传过来一个堆栈栈顶(增长型TOP为最低,减少型TOP为最高).从这个TOP堆栈起分别压入2+13个寄存器的内容.
83 1 当调用这个任务的TCB的就好象刚刚发生中断一样.从TOP起还原2+13个寄存器.使程序从这个任务重新开始*/
84 1 stk = (OS_STK DT_XDATA *)ptos; /* 用户堆栈最低地址 */
85 1 *stk++ = (0xFF + 1); /* C_IBP */
86 1 /* simulated stack size == 0 */
87 1 *stk++ = 2 + 13; /* tow bytes of return address and 13 byte registers */
88 1 *stk++ = (INT16U)task & 0xFF; /* 保存返回的地址--低地址 */
89 1 *stk++ = (INT16U)task >> 8; /* 保存返回的地址--高地址 */
90 1 *stk++ = 0x0A; /* ACC */
91 1 *stk++ = 0x0B; /* B */
92 1 *stk++ = 0xD1; /* DPH */
93 1 *stk++ = 0xD0; /* DPL */
94 1 *stk++ = 0x00; /* PSW */
95 1 *stk++ = 0x00; /* R0 */
96 1 *stk++ = 0x01; /* R1 */
97 1 *stk++ = 0x02; /* R2 */
98 1 *stk++ = 0x03; /* R3 */
99 1 *stk++ = 0x04; /* R4 */
100 1 *stk++ = 0x05; /* R5 */
101 1 *stk++ = 0x06; /* R6 */
102 1 *stk++ = 0x07; /* R7 */
103 1
104 1 return ((void DT_XDATA *)ptos); /* note return ptos, not stk */
105 1 }
106
107 /*
108 *********************************************************************************************************
109 * OS Time ISR
110 *
111 * Description: use T0.
112 *
113 * Arguments :
114 *
115 * Note(s) : in default, OSTickISR using register bank 0. Register pushing code will added by keilC.
C51 COMPILER V7.06 OS_CPU_C 07/30/2008 11:19:14 PAGE 3
116 *********************************************************************************************************
117 */
118 //2ms
119 void OSTickISR() interrupt 1
120 {
121 1 TH0 = TIMER_24M_25MS_H;
122 1 TL0 = TIMER_24M_25MS_L;
123 1
124 1 OSIntEnter();
125 1
126 1 OSMboxPost (LEDSM,(void*)1);
*** WARNING C259 IN LINE 126 OF ..\UC_51\OS_CPU_C.C: 'parameter': pointer: different mspace
127 1
128 1 if(++time0>=5) //10MS
129 1 {
130 2 time0=0;
131 2 OSTimeTick();
132 2 }
133 1
134 1 OSIntExit();
135 1 }
136
137
138 /*$PAGE*/
139 #if OS_CPU_HOOKS_EN
140 /*
141 *********************************************************************************************************
142 * TASK CREATION HOOK
143 *
144 * Description: This function is called when a task is created.
145 *
146 * Arguments : ptcb is a pointer to the task control block of the task being created.
147 *
148 * Note(s) : 1) Interrupts are disabled during this call.
149 *********************************************************************************************************
150 */
151 void OSTaskCreateHook (OS_TCB DT_XDATA *ptcb) REENTRANT
152 {
153 1 ptcb = ptcb; /* Prevent compiler warning */
154 1 }
155
156
157 /*
158 *********************************************************************************************************
159 * TASK DELETION HOOK
160 *
161 * Description: This function is called when a task is deleted.
162 *
163 * Arguments : ptcb is a pointer to the task control block of the task being deleted.
164 *
165 * Note(s) : 1) Interrupts are disabled during this call.
166 *********************************************************************************************************
167 */
168 void OSTaskDelHook (OS_TCB DT_XDATA *ptcb) REENTRANT
169 {
170 1 ptcb = ptcb; /* Prevent compiler warning */
171 1 }
172
173 /*
174 *********************************************************************************************************
175 * TASK SWITCH HOOK
176 *
C51 COMPILER V7.06 OS_CPU_C 07/30/2008 11:19:14 PAGE 4
177 * Description: This function is called when a task switch is performed. This allows you to perform other
178 * operations during a context switch.
179 *
180 * Arguments : none
181 *
182 * Note(s) : 1) Interrupts are disabled during this call.
183 * 2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
184 * will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
185 * task being switched out (i.e. the preempted task).
186 *********************************************************************************************************
187 */
188 void OSTaskSwHook (void) REENTRANT
189 {
190 1 }
191
192 /*
193 *********************************************************************************************************
194 * STATISTIC TASK HOOK
195 *
196 * Description: This function is called every second by uC/OS-II's statistics task. This allows your
197 * application to add functionality to the statistics task.
198 *
199 * Arguments : none
200 *********************************************************************************************************
201 */
202 void OSTaskStatHook (void) REENTRANT
203 {
204 1 }
205
206 /*
207 *********************************************************************************************************
208 * TICK HOOK
209 *
210 * Description: This function is called every tick.
211 *
212 * Arguments : none
213 *
214 * Note(s) : 1) Interrupts may or may not be ENABLED during this call.
215 *********************************************************************************************************
216 */
217 void OSTimeTickHook (void) REENTRANT
218 {
219 1 }
220 #endif
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 595 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 28 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -