📄 os_mutex.lst
字号:
##############################################################################
# #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32 KICKSTART 13/Mar/2009 16:01:01 #
# Copyright 1999-2005 IAR Systems. All rights reserved. #
# #
# Cpu mode = thumb #
# Endian = little #
# Stack alignment = 4 #
# Source file = E:\UC_OS\Micrium\Software\uCOS-II\Source\os_mutex.c #
# Command line = E:\UC_OS\Micrium\Software\uCOS-II\Source\os_mutex.c #
# -lCN E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210 #
# B-EVAL\IAR\OS-Probe\Flash\List\ -o #
# E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\Flash\Obj\ -z6 --no_unroll #
# --no_inline --no_tbaa --no_scheduling --debug #
# --cpu_mode thumb --endian little --cpu cortex-M3 #
# --stack_align 4 -e --fpu None --dlib_config #
# "C:\Program Files\IAR Systems\Embedded Workbench #
# 4.0 Kickstart\arm\LIB\dl7mptnnl8n.h" -I #
# E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\ -I E:\UC_OS\Micrium\Software\EvalBoa #
# rds\ST\STM3210B-EVAL\IAR\OS-Probe\..\..\..\..\..\uco #
# s-ii\ports\arm-cortex-m3\generic\iar\ -I #
# E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\..\..\..\..\..\ucos-ii\source\ -I #
# E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\..\..\..\..\..\uc-lib\ -I #
# E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\..\..\..\..\..\uc-cpu\ -I #
# E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\..\..\..\..\..\uc-cpu\ARM-Cortex-M3\I #
# AR\ -I E:\UC_OS\Micrium\Software\EvalBoards\ST\STM32 #
# 10B-EVAL\IAR\OS-Probe\..\..\..\..\..\cpu\st\stm32\in #
# c\ -I E:\UC_OS\Micrium\Software\EvalBoards\ST\STM321 #
# 0B-EVAL\IAR\OS-Probe\..\BSP\ -I #
# E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\..\..\..\..\..\uC-Probe\Target\Commun #
# ication\Generic\RS-232\Source\ -I #
# E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\..\..\..\..\..\uC-Probe\Target\Commun #
# ication\Generic\RS-232\Ports\ST\STM32\ -I #
# E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\..\..\..\..\..\uC-Probe\Target\Commun #
# ication\Generic\Source\ -I #
# E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\..\..\..\..\..\uC-Probe\Target\Plugin #
# s\uCOS-II\ -I "C:\Program Files\IAR #
# Systems\Embedded Workbench 4.0 Kickstart\arm\INC\" #
# List file = E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\Flash\List\os_mutex.lst #
# Object file = E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\Flash\Obj\os_mutex.r79 #
# #
# #
##############################################################################
E:\UC_OS\Micrium\Software\uCOS-II\Source\os_mutex.c
1 /*
2 *********************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 * MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
6 *
7 * (c) Copyright 1992-2007, Jean J. Labrosse, Weston, FL
8 * All Rights Reserved
9 *
10 * File : OS_MUTEX.C
11 * By : Jean J. Labrosse
12 * Version : V2.85
13 *
14 * LICENSING TERMS:
15 * ---------------
16 * uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.
17 * If you plan on using uC/OS-II in a commercial product you need to contact Micri祄 to properly license
18 * its use in your product. We provide ALL the source code for your convenience and to help you experience
19 * uC/OS-II. The fact that the source is provided does NOT mean that you can use it without paying a
20 * licensing fee.
21 *********************************************************************************************************
22 */
23
24 #ifndef OS_MASTER_FILE
25 #include <ucos_ii.h>
26 #endif
27
28
29 #if OS_MUTEX_EN > 0
30 /*
31 *********************************************************************************************************
32 * LOCAL CONSTANTS
33 *********************************************************************************************************
34 */
35
36 #define OS_MUTEX_KEEP_LOWER_8 (INT16U)0x00FFu
37 #define OS_MUTEX_KEEP_UPPER_8 (INT16U)0xFF00u
38
39 #define OS_MUTEX_AVAILABLE (INT16U)0x00FFu
40
41 /*
42 *********************************************************************************************************
43 * LOCAL CONSTANTS
44 *********************************************************************************************************
45 */
46
47 static void OSMutex_RdyAtPrio(OS_TCB *ptcb, INT8U prio);
48
49 /*$PAGE*/
50 /*
51 *********************************************************************************************************
52 * ACCEPT MUTUAL EXCLUSION SEMAPHORE
53 *
54 * Description: This function checks the mutual exclusion semaphore to see if a resource is available.
55 * Unlike OSMutexPend(), OSMutexAccept() does not suspend the calling task if the resource is
56 * not available or the event did not occur.
57 *
58 * Arguments : pevent is a pointer to the event control block
59 *
60 * perr is a pointer to an error code which will be returned to your application:
61 * OS_ERR_NONE if the call was successful.
62 * OS_ERR_EVENT_TYPE if 'pevent' is not a pointer to a mutex
63 * OS_ERR_PEVENT_NULL 'pevent' is a NULL pointer
64 * OS_ERR_PEND_ISR if you called this function from an ISR
65 * OS_ERR_PIP_LOWER If the priority of the task that owns the Mutex is
66 * HIGHER (i.e. a lower number) than the PIP. This error
67 * indicates that you did not set the PIP higher (lower
68 * number) than ALL the tasks that compete for the Mutex.
69 * Unfortunately, this is something that could not be
70 * detected when the Mutex is created because we don't know
71 * what tasks will be using the Mutex.
72 *
73 * Returns : == OS_TRUE if the resource is available, the mutual exclusion semaphore is acquired
74 * == OS_FALSE a) if the resource is not available
75 * b) you didn't pass a pointer to a mutual exclusion semaphore
76 * c) you called this function from an ISR
77 *
78 * Warning(s) : This function CANNOT be called from an ISR because mutual exclusion semaphores are
79 * intended to be used by tasks only.
80 *********************************************************************************************************
81 */
82
83 #if OS_MUTEX_ACCEPT_EN > 0
\ In segment CODE, align 4, keep-with-next
84 BOOLEAN OSMutexAccept (OS_EVENT *pevent, INT8U *perr)
85 {
\ OSMutexAccept:
\ 00000000 F0B5 PUSH {R4-R7,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 0D00 MOVS R5,R1
86 INT8U pip; /* Priority Inheritance Priority (PIP) */
87 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
88 OS_CPU_SR cpu_sr = 0;
89 #endif
90
91
92
93 #if OS_ARG_CHK_EN > 0
94 if (perr == (INT8U *)0) { /* Validate 'perr' */
\ 00000006 01D1 BNE.N ??OSMutexAccept_0
95 return (OS_FALSE);
\ ??OSMutexAccept_1:
\ 00000008 0020 MOVS R0,#+0
\ 0000000A F0BD POP {R4-R7,PC} ;; return
96 }
97 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ ??OSMutexAccept_0:
\ 0000000C 002C CMP R4,#+0
\ 0000000E 02D1 BNE.N ??OSMutexAccept_2
98 *perr = OS_ERR_PEVENT_NULL;
\ 00000010 0420 MOVS R0,#+4
\ 00000012 2870 STRB R0,[R5, #+0]
\ 00000014 F8E7 B.N ??OSMutexAccept_1
99 return (OS_FALSE);
100 }
101 #endif
102 if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) { /* Validate event block type */
\ ??OSMutexAccept_2:
\ 00000016 2078 LDRB R0,[R4, #+0]
\ 00000018 0428 CMP R0,#+4
\ 0000001A 02D0 BEQ.N ??OSMutexAccept_3
103 *perr = OS_ERR_EVENT_TYPE;
\ 0000001C 0120 MOVS R0,#+1
\ 0000001E 2870 STRB R0,[R5, #+0]
\ 00000020 F2E7 B.N ??OSMutexAccept_1
104 return (OS_FALSE);
105 }
106 if (OSIntNesting > 0) { /* Make sure it's not called from an ISR */
\ ??OSMutexAccept_3:
\ 00000022 .... LDR.N R0,??DataTable5 ;; OSIntNesting
\ 00000024 0078 LDRB R0,[R0, #+0]
\ 00000026 0028 CMP R0,#+0
\ 00000028 02D0 BEQ.N ??OSMutexAccept_4
107 *perr = OS_ERR_PEND_ISR;
\ 0000002A 0220 MOVS R0,#+2
\ 0000002C 2870 STRB R0,[R5, #+0]
\ 0000002E EBE7 B.N ??OSMutexAccept_1
108 return (OS_FALSE);
109 }
110 OS_ENTER_CRITICAL(); /* Get value (0 or 1) of Mutex */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -