📄 os_mutex.lst
字号:
##############################################################################
# #
# IAR MSP430 C-Compiler V1.26A/WIN #
# #
# Time limited license: 29 days left #
# #
# Compile time = 30/Sep/2002 18:04:12 #
# Target option = SP430x31x #
# Memory model = small #
# Source file = c:\software\ucos-ii\source\os_mutex.c #
# List file = j:\software\ucos-ii\ti-msp430\iar\source\debug\list\os_mutex.lst#
# Object file = j:\software\ucos-ii\ti-msp430\iar\source\debug\obj\os_mutex.r43#
# ASM file = j:\software\ucos-ii\ti-msp430\iar\source\debug\list\os_mutex.s43#
# Command line = -OJ:\SOFTWARE\UCOS-II\TI-MSP430\IAR\SOURCE\Debug\Obj\ #
# -e -K -gA -s6 -RCODE -r0 #
# -LJ:\SOFTWARE\UCOS-II\TI-MSP430\IAR\SOURCE\Debug\List\ #
# -q -t8 -x #
# -AJ:\SOFTWARE\UCOS-II\TI-MSP430\IAR\SOURCE\Debug\List\ #
# -X -IC:\PROGRA~1\IARSYS~1\ew23\430\inc\ #
# -I\software\ucos-ii\ti-msp430\iar\source\ #
# -I\software\ucos-ii\source\ #
# C:\SOFTWARE\uCOS-II\SOURCE\OS_MUTEX.C #
# #
# Copyright 1996-2002 IAR Systems. All rights reserved. #
##############################################################################
extern INT8U const OSMapTbl[]; /* Priority->Bit Mask lookup table */
-----------------------------------^
"c:\software\ucos-ii\source\ucos_ii.h",481 Warning[27]: Size of "extern" object 'OSMapTbl' is unknown
extern INT8U const OSUnMapTbl[]; /* Priority->Index lookup table */
-------------------------------------^
"c:\software\ucos-ii\source\ucos_ii.h",482 Warning[27]: Size of "extern" object 'OSUnMapTbl' is unknown
\ 0000 NAME os_mutex(16)
\ 0000 RSEG CODE(1)
\ 0000 EXTERN OSEventFreeList
\ 0000 EXTERN OSIntNesting
\ 0000 EXTERN OSMapTbl
\ 0000 PUBLIC OSMutexAccept
\ 0000 PUBLIC OSMutexCreate
\ 0000 PUBLIC OSMutexDel
\ 0000 PUBLIC OSMutexPend
\ 0000 PUBLIC OSMutexPost
\ 0000 PUBLIC OSMutexQuery
\ 0000 EXTERN OSRdyGrp
\ 0000 EXTERN OSRdyTbl
\ 0000 EXTERN OSTCBCur
\ 0000 EXTERN OSTCBPrioTbl
\ 0000 EXTERN OS_EventTO
\ 0000 EXTERN OS_EventTaskRdy
\ 0000 EXTERN OS_EventTaskWait
\ 0000 EXTERN OS_EventWaitListInit
\ 0000 EXTERN OS_Sched
\ 0000 EXTERN ?CL430_1_26_L08
\ 0000 RSEG CODE
\ 0000 OSMutexAccept:
1 /*
2 *********************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 * MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
6 *
7 * (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
8 * All Rights Reserved
9 *
10 * File : OS_MUTEX.C
11 * By : Jean J. Labrosse
12 *********************************************************************************************************
13 */
14
15 #ifndef OS_MASTER_FILE
16 #include "includes.h"
17 #endif
18
19 /*
20 *********************************************************************************************************
21 * LOCAL CONSTANTS
22 *********************************************************************************************************
23 */
24
25 #define OS_MUTEX_KEEP_LOWER_8 0x00FF
26 #define OS_MUTEX_KEEP_UPPER_8 0xFF00
27
28 #define OS_MUTEX_AVAILABLE 0x00FF
29
30
31 #if OS_MUTEX_EN > 0
32 /*
33 *********************************************************************************************************
34 * ACCEPT MUTUAL EXCLUSION SEMAPHORE
35 *
36 * Description: This function checks the mutual exclusion semaphore to see if a resource is available.
37 * Unlike OSMutexPend(), OSMutexAccept() does not suspend the calling task if the resource is
38 * not available or the event did not occur.
39 *
40 * Arguments : pevent is a pointer to the event control block
41 *
42 * err is a pointer to an error code which will be returned to your application:
43 * OS_NO_ERR if the call was successful.
44 * OS_ERR_EVENT_TYPE if 'pevent' is not a pointer to a mutex
45 * OS_ERR_PEVENT_NULL 'pevent' is a NULL pointer
46 * OS_ERR_PEND_ISR if you called this function from an ISR
47 *
48 * Returns : == 1 if the resource is available, the mutual exclusion semaphore is acquired
49 * == 0 a) if the resource is not available
50 * b) you didn't pass a pointer to a mutual exclusion semaphore
51 * c) you called this function from an ISR
52 *
53 * Warning(s) : This function CANNOT be called from an ISR because mutual exclusion semaphores are
54 * intended to be used by tasks only.
55 *********************************************************************************************************
56 */
57
58 #if OS_MUTEX_ACCEPT_EN > 0
59 INT8U OSMutexAccept (OS_EVENT *pevent, INT8U *err)
60 {
61 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
62 OS_CPU_SR cpu_sr;
63 #endif
64
65
66 if (OSIntNesting > 0) { /* Make sure it's not called from an ISR */
\ 0000 C2930000 CMP.B #0,&OSIntNesting
\ 0004 0424 JEQ (?0057)
67 *err = OS_ERR_PEND_ISR;
\ 0006 EE430000 MOV.B #2,0(R14)
68 return (0);
\ 000A 4C43 MOV.B #0,R12
69 }
\ 000C 3041 RET
\ 000E ?0057:
70 #if OS_ARG_CHK_EN > 0
71 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 000E 0C93 CMP #0,R12
\ 0010 0320 JNE (?0059)
72 *err = OS_ERR_PEVENT_NULL;
\ 0012 EE420000 MOV.B #4,0(R14)
73 return (0);
74 }
\ 0016 3041 RET
\ 0018 ?0059:
75 if (pevent->OSEventType != OS_EVENT_TYPE_MUTEX) { /* Validate event block type */
\ 0018 6D42 MOV.B #4,R13
\ 001A 6D9C CMP.B @R12,R13
\ 001C 0424 JEQ (?0061)
76 *err = OS_ERR_EVENT_TYPE;
\ 001E DE430000 MOV.B #1,0(R14)
77 return (0);
\ 0022 4C43 MOV.B #0,R12
78 }
\ 0024 3041 RET
\ 0026 ?0061:
79 #endif
80 OS_ENTER_CRITICAL(); /* Get value (0 or 1) of Mutex */
\ 0026 32C2 DINT
81 if ((pevent->OSEventCnt & OS_MUTEX_KEEP_LOWER_8) == OS_MUTEX_AVAILABLE) {
\ 0028 1D4C0200 MOV 2(R12),R13
\ 002C 3DF0FF00 AND #255,R13
\ 0030 3D90FF00 CMP #255,R13
\ 0034 1120 JNE (?0063)
82 pevent->OSEventCnt &= OS_MUTEX_KEEP_UPPER_8; /* Mask off LSByte (Acquire Mutex) */
\ 0036 BCF000FF AND #65280,2(R12)
\ 003A 0200
83 pevent->OSEventCnt |= OSTCBCur->OSTCBPrio; /* Save current task priority in LSByte */
\ 003C 1D420000 MOV &OSTCBCur,R13
\ 0040 5D4D1D00 MOV.B 29(R13),R13
\ 0044 8CDD0200 BIS R13,2(R12)
84 pevent->OSEventPtr = (void *)OSTCBCur; /* Link TCB of task owning Mutex */
\ 0048 9C420000 MOV &OSTCBCur,4(R12)
\ 004C 0400
85 OS_EXIT_CRITICAL();
\ 004E 32D2 EINT
86 *err = OS_NO_ERR;
\ 0050 CE430000 MOV.B #0,0(R14)
87 return (1);
\ 0054 5C43 MOV.B #1,R12
88 }
\ 0056 3041 RET
\ 0058 ?0063:
89 OS_EXIT_CRITICAL();
\ 0058 32D2 EINT
90 *err = OS_NO_ERR;
\ 005A CE430000 MOV.B #0,0(R14)
91 return (0);
\ 005E 4C43 MOV.B #0,R12
92 }
\ 0060 3041 RET
\ 0062 OSMutexCreate:
93 #endif
94
95 /*$PAGE*/
96 /*
97 *********************************************************************************************************
98 * CREATE A MUTUAL EXCLUSION SEMAPHORE
99 *
100 * Description: This function creates a mutual exclusion semaphore.
101 *
102 * Arguments : prio is the priority to use when accessing the mutual exclusion semaphore. In
103 * other words, when the semaphore is acquired and a higher priority task
104 * attempts to obtain the semaphore then the priority of the task owning the
105 * semaphore is raised to this priority. It is assumed that you will specify
106 * a priority that is LOWER in value than ANY of the tasks competing for the
107 * mutex.
108 *
109 * err is a pointer to an error code which will be returned to your application:
110 * OS_NO_ERR if the call was successful.
111 * OS_ERR_CREATE_ISR if you attempted to create a MUTEX from an ISR
112 * OS_PRIO_EXIST if a task at the priority inheritance priority
113 * already exist.
114 * OS_ERR_PEVENT_NULL No more event control blocks available.
115 * OS_PRIO_INVALID if the priority you specify is higher that the
116 * maximum allowed (i.e. > OS_LOWEST_PRIO)
117 *
118 * Returns : != (void *)0 is a pointer to the event control clock (OS_EVENT) associated with the
119 * created mutex.
120 * == (void *)0 if an error is detected.
121 *
122 * Note(s) : 1) The LEAST significant 8 bits of '.OSEventCnt' are used to hold the priority number
123 * of the task owning the mutex or 0xFF if no task owns the mutex.
124 * 2) The MOST significant 8 bits of '.OSEventCnt' are used to hold the priority number
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -