📄 bug_fixes.htm
字号:
<param name="bgcolor" value="#FFFFFF">
<param name="effect" value="glow">
<param name="text" value="Y2K Statement">
<param name="font" value="Helvetica">
<param name="fontstyle" value="bold">
<param name="fontsize" value="14">
<param name="url" valuetype="ref" value="y2k.htm">
</applet>
</p>
<p align="center">
</p>
<p align="center">
<applet codebase="index.htm" tppabs="http://www.ucos-ii.com/" code="fphover.class" tppabs="http://www.ucos-ii.com/fphover.class" width="200" height="24">
<param name="color" value="#000080">
<param name="hovercolor" value="#0000FF">
<param name="textcolor" value="#FFFFFF">
<param name="effect" value="glow">
<param name="fontstyle" value="bold">
<param name="fontsize" value="14">
<param name="font" value="Helvetica">
<param name="bgcolor" value="#FFFFFF">
<param name="text" value="Picture Gallery">
<param name="url" valuetype="ref" value="gallery.htm">
</applet>
</p>
</td><td valign="top" width="24"></td><!--msnavigation--><td valign="top"><p align="center"><font size="6" color="#000000"><strong><br>
Bug Fixes / Improvements</strong></font></p>
<p align="left">Below is a list of known bugs in the latest version of 礐/OS-II
(V2.51) as well as the correction(s) <b>or</b>, improvements that can be made to
<b>V2.51</b>.</p>
<table border="1" width="100%">
<tr>
<td width="200%" bgcolor="#C0C0C0"><p align="left"><img border="0" src="bugmove.gif" tppabs="http://www.ucos-ii.com/images/bugmove.gif" width="60" height="47"><strong><font size="5">uCOS_II.H
(V2.51-001):</font></strong></td>
</tr>
</table>
<p>The function prototype for <font face="Courier New" size="2">OSSchedLock()</font>
was changed by mistake to <font face="Courier New" size="2">OS_SchedLock()</font>.
Simply REMOVE the underscore since the <b>CORRECT</b> name is <font face="Courier New" size="2">OSSchedLock()</font>.</p>
<p> </p>
<table border="1" width="100%">
<tr>
<td width="200%" bgcolor="#C0C0C0"><p align="left"><img border="0" src="bugmove.gif" tppabs="http://www.ucos-ii.com/images/bugmove.gif" width="60" height="47"><strong><font size="5">OS_CPU_A.ASM
(V2.05-001):<br>
</font><font size="5">
</font><font size="3">(For both Ix86L and Ix86L-FP)</font></strong></td>
</tr>
</table>
<p>The <i>NEW</i> ISRs MUST check to see <font face="Courier New" size="2">if
OSIntNesting == 1</font> <i>BEFORE</i> you save the <font face="Courier New" size="2">SP</font>
in the current task's <font face="Courier New" size="2">OS_TCB</font>. The
incorrect 'pseudo' code is:</p>
<p><font face="Courier New" size="2"> OSTCBCur->OSTCBStkPtr =
SP /* Save SP onto current
task's stack */<br>
</font><br>
<font color="#FF0000"><b>and should be:</b></font></p>
<p><font face="Courier New" size="2"> if (OSIntNesting == 1) {<br>
</font> <font face="Courier New" size="2">OSTCBCur->OSTCBStkPtr
= SP /* Save SP onto current task's stack */<br>
}</font>
</p>
<p>The reason we need this change is that we don't want to save the current
value of <font face="Courier New" size="2">SP</font> if the ISR is for a nested
ISR!</p>
<p align="left"><b>IMPORTANT</b>: If you have the release notes version <b>V2.05a</b>
then you have the CORRECT code.</p>
<hr>
<p align="left"><br>
Below is a list of known bugs in the latest version of 礐/OS-II
(V2.04) as well as the correction(s) <b>or</b>, improvements that can be made to
<b>V2.04</b>.</p>
<table border="1" width="100%">
<tr>
<td width="200%" bgcolor="#C0C0C0"><p align="left"><img border="0" src="bugmove.gif" tppabs="http://www.ucos-ii.com/images/bugmove.gif" width="60" height="47"><font size="5"><strong>OS_CORE.C
(V2.04-001):</strong></font></td>
</tr>
</table>
<p>The wrong argument is being passed to the call to <font face="Courier New" size="2">OSTaskCreateHook()</font>
in <font face="Courier New" size="2">OSTCBInit()</font>. The BAD code is:</p>
<p><font face="Courier New" size="2">OSTaskCreateHook(<b>OSTCBPrioTbl[prio]</b>); /* Call user defined hook */<br>
</font><br>
<font color="#FF0000"><b>and should be:</b></font></p>
<p><font face="Courier New" size="2">OSTaskCreateHook(<b>ptcb</b>);
/* Call user defined hook */</font><br>
</p>
<table border="1" width="100%">
<tr>
<td width="200%" bgcolor="#C0C0C0"><p align="left"><img border="0" src="bugmove.gif" tppabs="http://www.ucos-ii.com/images/bugmove.gif" width="64" height="50"><strong><font size="5">OS_MUTEX.C
(V2.04-002):</font></strong></td>
</tr>
</table>
<p>The test in <font face="Courier New" size="2">OSMutexPost()</font> to see if
the posting task owns the MUTEX is incorrect. The correct test needs to
have <b><font face="Courier New" color="#FF0000" size="4">&&</font></b>
instead of <b><font face="Courier New" color="#FF0000" size="4">||</font></b> as
follows:</p>
<p><font face="Courier New" size="2"> if (OSTCBCur->OSTCBPrio != pip </font><b><font face="Courier New" size="4" color="#FF0000"> &&</font></b><font face="Courier New" size="2"><br>
OSTCBCur->OSTCBPrio != prio) { /* See if posting task owns the MUTEX */<br>
OS_EXIT_CRITICAL();<br>
return (OS_ERR_NOT_MUTEX_OWNER);<br>
}</font><br>
</p>
<table border="1" width="100%">
<tr>
<td width="200%" bgcolor="#C0C0C0"><p align="left"><img border="0" src="bugmove.gif" tppabs="http://www.ucos-ii.com/images/bugmove.gif" width="64" height="50"><strong><font size="5">OS_MUTEX.C
(V2.04-003):</font></strong></td>
</tr>
</table>
<p>The function <font face="Courier New" size="2">OSMutexDel()</font> needs to
release the priority of the PIP. The correct code for <font face="Courier New" size="2">OSMutexDel()</font>
can be downloaded from: <a href="os_mutex_del.c" tppabs="http://www.ucos-ii.com/files/os_mutex_del.c"><b>Download new <font face="Courier New">OSMutexDel()</font></b></a>.</p>
<p>
</p>
<table border="1" width="100%">
<tr>
<td width="200%" bgcolor="#C0C0C0"><p align="left"><img border="0" src="bugmove.gif" tppabs="http://www.ucos-ii.com/images/bugmove.gif" width="64" height="50"><strong><font size="5">uCOS_II.H
(V2.04-004):</font></strong></td>
</tr>
</table>
<p>The function <font face="Courier New" size="2">OSMutexDel()</font> needs to
be added in the prototype list for MUTEXes as follows:</p>
<p><font face="Courier New" size="2">#if OS_MUTEX_EN<br>
INT8U OSMutexAccept(OS_EVENT *pevent, INT8U *err);<br>
OS_EVENT *OSMutexCreate(INT8U prio, INT8U *err);<br>
<font color="#FF0000"><b>OS_EVENT *OSMutexDel (OS_EVENT *pevent, INT8U opt, INT8U *err);<br>
</b></font>void OSMutexPend(OS_EVENT *pevent, INT16U timeout, INT8U *err);<br>
INT8U OSMutexPost(OS_EVENT *pevent);<br>
INT8U OSMutexQuery(OS_EVENT *pevent, OS_MUTEX_DATA *pdata);<br>
#endif<br>
</font></p>
<table border="1" width="100%">
<tr>
<td width="100%" bgcolor="#C0C0C0"><p align="left"><strong><font size="5">OS_CPU_A.ASM
and ISRs:</font></strong></td>
</tr>
</table>
<p>As you probably know, 礐/OS-II has a function
that is dependent on compiler options (<font face="Courier New" size="2">OSIntCtxSw()</font>)
and, the port designer <font color="#FF0000"><b> HAS</b></font> to adjust the Stack Pointer based on the code
generation of the compiler.</p>
<p>On certain processors (e.g. 80x86) you can simply
write ISRs so that you <b>save</b> the Stack Pointer (<font face="Courier New" size="2">SS:SP</font>
for the 80x86) into the current task's <font face="Courier New" size="2">OS_TCB</font>
<b>
after</b> incrementing <font face="Courier New" size="2">OSIntNesting</font>. This way,
we save the proper pointer to the ISR stack frame in case we don't actually
return to the interrupted task. If we DO return to the interrupted task
then, there is no harm and all we did was waste a little bit of CPU time!
Of course, we <b> eliminate</b> the code at the beginning of <font face="Courier New" size="2">OSIntCtxSw()</font>
to adjust the Stack Pointer (<font face="Courier New" size="2">SP</font> for the 80x86)
and the code to save the Stack Pointer into the <font face="Courier New" size="2">OS_TCB</font>!</p>
<p>The new pseudo code for an ISR and <font face="Courier New" size="2">OSIntCtxSw()</font>
is now:</p>
<p><font face="Courier New" size="2">MyISR:<br>
Save ALL registers;<br>
OSIntNesting++;<br>
</font><font face="Courier New"> <font SIZE="2">OSTCBCur->OSTCBStkPtr
= SP; /* <<<< NEW
*/<br>
</font> </font><font face="Courier New" size="2"> /* Handle ISR
*/<br>
OSIntExit();<br>
Restore ALL registers;<br>
Return from Interrupt;</font></p>
<p><font face="Courier New" size="2">OSIntCtxSw:<br>
OSTaskSwHook();<br>
OSTCBCur = OSTCBHighRdy;<br>
SP = OSTCBHighRdy->OSTCBStkPtr;<br>
Restore ALL registers;<br>
Return from Interrupt;</font></p>
<p>In assembly language for the 80x86 (Large model),
this becomes:</p>
<font SIZE="2">
<p><font face="Courier New">_MyISR PROC FAR<br>
;<br>
PUSHA
; Save interrupted task's context<br>
PUSH ES<br>
PUSH DS<br>
;<br>
MOV AX, SEG(_OSIntNesting) ; Reload
DS<br>
MOV DS, AX<br>
INC BYTE PTR _OSIntNesting ; Notify
uC/OS-II of ISR<br>
;<br>
LES BX, DWORD PTR DS:_OSTCBCur ; OSTCBCur->OSTCBStkPtr =
SS:SP<br>
MOV ES:[BX+2], SS<br>
MOV ES:[BX+0], SP<br>
CALL FAR PTR _MyISRHandler ; Process
the Interrupt<br>
;<br>
CALL FAR PTR _OSIntExit
; Notify uC/OS-II of end of ISR<br>
;<br>
POP
DS
; Restore interrupted task's context<br>
POP ES<br>
POPA<br>
;<br>
IRET
; Return to interrupted task<br>
;<br>
_MyISR ENDP</font></p>
<p> </p>
<p><font face="Courier New" size="2">_OSIntCtxSw PROC FAR<br>
;<br>
CALL FAR PTR _OSTaskSwHook ;
Call user defined task switch hook<br>
;<br>
MOV AX, WORD PTR DS:_OSTCBHighRdy+2 ; OSTCBCur = OSTCBHighRdy<br>
MOV DX, WORD PTR DS:_OSTCBHighRdy <br>
MOV WORD PTR DS:_OSTCBCur+2, AX<br>
MOV WORD PTR DS:_OSTCBCur, DX <br>
;<br>
MOV AL, BYTE PTR DS:_OSPrioHighRdy ; OSPrioCur =
OSPrioHighRdy<br>
MOV BYTE PTR DS:_OSPrioCur, AL<br>
;<br>
LES BX, DWORD PTR DS:_OSTCBHighRdy ; SS:SP = OSTCBHighRdy->OSTCBStkPtr<br>
MOV SS, ES:[BX+2]<br>
MOV SP, ES:[BX]<br>
;<br>
POP
DS ;
Load new task's context<br>
POP ES<br>
POPA<br>
;<br>
IRET
; Return to new task<br>
;<br>
_OSIntCtxSw ENDP</font></p>
</font>
<p align="left">
<p> </p>
<!--msnavigation--></td></tr><!--msnavigation--></table></body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -