📄 os_sem.lst
字号:
##############################################################################
# #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32 KICKSTART 10/Jan/2008 16:48:30 #
# Copyright 1999-2005 IAR Systems. All rights reserved. #
# #
# Cpu mode = arm #
# Endian = little #
# Stack alignment = 4 #
# Source file = D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \uCOS-II\Source\os_sem.c #
# Command line = D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \uCOS-II\Source\os_sem.c -lCN #
# D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \EvalBoards\NXP\LPC2468-EA\IAR\OS-View\Flash\List\ #
# -o D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Softw #
# are\EvalBoards\NXP\LPC2468-EA\IAR\OS-View\Flash\Obj\ #
# -z3 --no_cse --no_unroll --no_inline #
# --no_code_motion --no_tbaa --no_clustering #
# --no_scheduling --debug --cpu_mode arm --endian #
# little --cpu ARM7TDMI-S --stack_align 4 -e --fpu #
# None --dlib_config "C:\Program Files\IAR #
# Systems\Embedded Workbench 4.0 #
# Kickstart\arm\LIB\dl4tpannl8n.h" -I #
# D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \EvalBoards\NXP\LPC2468-EA\IAR\OS-View\ -I #
# D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \EvalBoards\NXP\LPC2468-EA\IAR\OS-View\..\..\..\..\. #
# .\ucos-ii\ports\arm\generic\iar\ -I #
# D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \EvalBoards\NXP\LPC2468-EA\IAR\OS-View\..\..\..\..\. #
# .\ucos-ii\source\ -I D:\work\资料\嵌入式操作系统\UCO #
# S-II\Micrium\Software\EvalBoards\NXP\LPC2468-EA\IAR\ #
# OS-View\..\..\..\..\..\ucosview\source\ -I #
# D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \EvalBoards\NXP\LPC2468-EA\IAR\OS-View\..\..\..\..\. #
# .\ucosview\ports\arm7\lpc2468\iar\ -I #
# D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \EvalBoards\NXP\LPC2468-EA\IAR\OS-View\..\..\..\..\. #
# .\uc-lib\ -I D:\work\资料\嵌入式操作系统\UCOS-II\Mic #
# rium\Software\EvalBoards\NXP\LPC2468-EA\IAR\OS-View\ #
# ..\..\..\..\..\uc-cpu\ -I #
# D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \EvalBoards\NXP\LPC2468-EA\IAR\OS-View\..\..\..\..\. #
# .\uc-cpu\arm\IAR\ -I D:\work\资料\嵌入式操作系统\UCO #
# S-II\Micrium\Software\EvalBoards\NXP\LPC2468-EA\IAR\ #
# OS-View\..\BSP\ -I "C:\Program Files\IAR #
# Systems\Embedded Workbench 4.0 Kickstart\arm\INC\" #
# List file = D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \EvalBoards\NXP\LPC2468-EA\IAR\OS-View\Flash\List\os #
# _sem.lst #
# Object file = D:\work\资料\嵌入式操作系统\UCOS-II\Micrium\Software #
# \EvalBoards\NXP\LPC2468-EA\IAR\OS-View\Flash\Obj\os_ #
# sem.r79 #
# #
# #
##############################################################################
D:\work\资料\嵌入式操作系统\UCOS-II\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.84
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 30402DE9 PUSH {R4,R5,LR}
\ 00000004 0040B0E1 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;
\ 00000008 0000A0E3 MOV R0,#+0
54 #endif
55
56
57
58 #if OS_ARG_CHK_EN > 0
59 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 0000000C 000054E3 CMP R4,#+0
\ 00000010 0100001A BNE ??OSSemAccept_0
60 return (0);
\ 00000014 0000A0E3 MOV R0,#+0
\ 00000018 0F0000EA B ??OSSemAccept_1
61 }
62 #endif
63 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
\ ??OSSemAccept_0:
\ 0000001C 0000D4E5 LDRB R0,[R4, #+0]
\ 00000020 030050E3 CMP R0,#+3
\ 00000024 0100000A BEQ ??OSSemAccept_2
64 return (0);
\ 00000028 0000A0E3 MOV R0,#+0
\ 0000002C 0A0000EA B ??OSSemAccept_1
65 }
66 OS_ENTER_CRITICAL();
\ ??OSSemAccept_2:
\ 00000030 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
67 cnt = pevent->OSEventCnt;
\ 00000034 B850D4E1 LDRH R5,[R4, #+8]
68 if (cnt > 0) { /* See if resource is available */
\ 00000038 010055E3 CMP R5,#+1
\ 0000003C 0400003A BCC ??OSSemAccept_3
69 pevent->OSEventCnt--; /* Yes, decrement semaphore and notify caller */
\ 00000040 B810D4E1 LDRH R1,[R4, #+8]
\ 00000044 FF20A0E3 MOV R2,#+255
\ 00000048 FF2C82E3 ORR R2,R2,#0xFF00
\ 0000004C 011092E0 ADDS R1,R2,R1
\ 00000050 B810C4E1 STRH R1,[R4, #+8]
70 }
71 OS_EXIT_CRITICAL();
\ ??OSSemAccept_3:
\ 00000054 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
72 return (cnt); /* Return semaphore count */
\ 00000058 0500B0E1 MOVS R0,R5
\ ??OSSemAccept_1:
\ 0000005C 3080BDE8 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 clock (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 30402DE9 PUSH {R4,R5,LR}
\ 00000004 0040B0E1 MOVS R4,R0
96 OS_EVENT *pevent;
97 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
98 OS_CPU_SR cpu_sr = 0;
\ 00000008 0000A0E3 MOV R0,#+0
99 #endif
100
101
102
103 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ 0000000C ........ LDR R1,??DataTable10 ;; OSIntNesting
\ 00000010 0010D1E5 LDRB R1,[R1, #+0]
\ 00000014 010051E3 CMP R1,#+1
\ 00000018 0100003A BCC ??OSSemCreate_0
104 return ((OS_EVENT *)0); /* ... can't CREATE from an ISR */
\ 0000001C 0000A0E3 MOV R0,#+0
\ 00000020 1A0000EA B ??OSSemCreate_1
105 }
106 OS_ENTER_CRITICAL();
\ ??OSSemCreate_0:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -