📄 os_sem.lst
字号:
##############################################################################
# #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32 KICKSTART 13/Mar/2009 16:01:03 #
# 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_sem.c #
# Command line = E:\UC_OS\Micrium\Software\uCOS-II\Source\os_sem.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_sem.lst #
# Object file = E:\UC_OS\Micrium\Software\EvalBoards\ST\STM3210B-EVA #
# L\IAR\OS-Probe\Flash\Obj\os_sem.r79 #
# #
# #
##############################################################################
E:\UC_OS\Micrium\Software\uCOS-II\Source\os_sem.c
1 /*
2 *********************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 * SEMAPHORE MANAGEMENT
6 *
7 * (c) Copyright 1992-2007, Jean J. Labrosse, Weston, FL
8 * All Rights Reserved
9 *
10 * File : OS_SEM.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 #if OS_SEM_EN > 0
29 /*$PAGE*/
30 /*
31 *********************************************************************************************************
32 * ACCEPT SEMAPHORE
33 *
34 * Description: This function checks the semaphore to see if a resource is available or, if an event
35 * occurred. Unlike OSSemPend(), OSSemAccept() does not suspend the calling task if the
36 * resource is not available or the event did not occur.
37 *
38 * Arguments : pevent is a pointer to the event control block
39 *
40 * Returns : > 0 if the resource is available or the event did not occur the semaphore is
41 * decremented to obtain the resource.
42 * == 0 if the resource is not available or the event did not occur or,
43 * if 'pevent' is a NULL pointer or,
44 * if you didn't pass a pointer to a semaphore
45 *********************************************************************************************************
46 */
47
48 #if OS_SEM_ACCEPT_EN > 0
\ In segment CODE, align 4, keep-with-next
49 INT16U OSSemAccept (OS_EVENT *pevent)
50 {
\ OSSemAccept:
\ 00000000 30B5 PUSH {R4,R5,LR}
\ 00000002 0400 MOVS R4,R0
51 INT16U cnt;
52 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
53 OS_CPU_SR cpu_sr = 0;
54 #endif
55
56
57
58 #if OS_ARG_CHK_EN > 0
59 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 00000004 01D1 BNE.N ??OSSemAccept_0
60 return (0);
\ ??OSSemAccept_1:
\ 00000006 0020 MOVS R0,#+0
\ 00000008 30BD POP {R4,R5,PC}
61 }
62 #endif
63 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
\ ??OSSemAccept_0:
\ 0000000A 2078 LDRB R0,[R4, #+0]
\ 0000000C 0328 CMP R0,#+3
\ 0000000E FAD1 BNE.N ??OSSemAccept_1
64 return (0);
65 }
66 OS_ENTER_CRITICAL();
\ 00000010 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
67 cnt = pevent->OSEventCnt;
\ 00000014 2589 LDRH R5,[R4, #+8]
68 if (cnt > 0) { /* See if resource is available */
\ 00000016 2900 MOVS R1,R5
\ 00000018 01D0 BEQ.N ??OSSemAccept_2
69 pevent->OSEventCnt--; /* Yes, decrement semaphore and notify caller */
\ 0000001A 491E SUBS R1,R1,#+1
\ 0000001C 2181 STRH R1,[R4, #+8]
70 }
71 OS_EXIT_CRITICAL();
\ ??OSSemAccept_2:
\ 0000001E ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
72 return (cnt); /* Return semaphore count */
\ 00000022 2800 MOVS R0,R5
\ 00000024 30BD POP {R4,R5,PC} ;; return
73 }
74 #endif
75
76 /*$PAGE*/
77 /*
78 *********************************************************************************************************
79 * CREATE A SEMAPHORE
80 *
81 * Description: This function creates a semaphore.
82 *
83 * Arguments : cnt is the initial value for the semaphore. If the value is 0, no resource is
84 * available (or no event has occurred). You initialize the semaphore to a
85 * non-zero value to specify how many resources are available (e.g. if you have
86 * 10 resources, you would initialize the semaphore to 10).
87 *
88 * Returns : != (void *)0 is a pointer to the event control block (OS_EVENT) associated with the
89 * created semaphore
90 * == (void *)0 if no event control blocks were available
91 *********************************************************************************************************
92 */
93
\ In segment CODE, align 4, keep-with-next
94 OS_EVENT *OSSemCreate (INT16U cnt)
95 {
\ OSSemCreate:
\ 00000000 30B5 PUSH {R4,R5,LR}
\ 00000002 0500 MOVS R5,R0
96 OS_EVENT *pevent;
97 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
98 OS_CPU_SR cpu_sr = 0;
99 #endif
100
101
102
103 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ 00000004 .... LDR.N R0,??DataTable4 ;; OSIntNesting
\ 00000006 0078 LDRB R0,[R0, #+0]
\ 00000008 0028 CMP R0,#+0
\ 0000000A 01D0 BEQ.N ??OSSemCreate_0
104 return ((OS_EVENT *)0); /* ... can't CREATE from an ISR */
\ 0000000C 0020 MOVS R0,#+0
\ 0000000E 30BD POP {R4,R5,PC}
105 }
106 OS_ENTER_CRITICAL();
\ ??OSSemCreate_0:
\ 00000010 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
107 pevent = OSEventFreeList; /* Get next free event control block */
\ 00000014 .... LDR.N R1,??DataTable3 ;; OSEventFreeList
\ 00000016 0A68 LDR R2,[R1, #+0]
\ 00000018 1400 MOVS R4,R2
108 if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB pool was empty */
\ 0000001A 01D0 BEQ.N ??OSSemCreate_1
109 OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
\ 0000001C 5268 LDR R2,[R2, #+4]
\ 0000001E 0A60 STR R2,[R1, #+0]
110 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -