📄 os_sem.lst
字号:
##############################################################################
# #
# IAR MSP430 C-Compiler V1.26A/WIN #
# #
# Time limited license: 29 days left #
# #
# Compile time = 30/Sep/2002 18:04:13 #
# Target option = SP430x31x #
# Memory model = small #
# Source file = c:\software\ucos-ii\source\os_sem.c #
# List file = j:\software\ucos-ii\ti-msp430\iar\source\debug\list\os_sem.lst#
# Object file = j:\software\ucos-ii\ti-msp430\iar\source\debug\obj\os_sem.r43#
# ASM file = j:\software\ucos-ii\ti-msp430\iar\source\debug\list\os_sem.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_SEM.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_sem(16)
\ 0000 RSEG CODE(1)
\ 0000 EXTERN OSEventFreeList
\ 0000 EXTERN OSIntNesting
\ 0000 PUBLIC OSSemAccept
\ 0000 PUBLIC OSSemCreate
\ 0000 PUBLIC OSSemDel
\ 0000 PUBLIC OSSemPend
\ 0000 PUBLIC OSSemPost
\ 0000 PUBLIC OSSemQuery
\ 0000 EXTERN OSTCBCur
\ 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 OSSemAccept:
1 /*
2 *********************************************************************************************************
3 * uC/OS-II
4 * The Real-Time Kernel
5 * SEMAPHORE MANAGEMENT
6 *
7 * (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
8 * All Rights Reserved
9 *
10 * File : OS_SEM.C
11 * By : Jean J. Labrosse
12 *********************************************************************************************************
13 */
14
15 #ifndef OS_MASTER_FILE
16 #include "includes.h"
17 #endif
18
19 #if OS_SEM_EN > 0
20 /*
21 *********************************************************************************************************
22 * ACCEPT SEMAPHORE
23 *
24 * Description: This function checks the semaphore to see if a resource is available or, if an event
25 * occurred. Unlike OSSemPend(), OSSemAccept() does not suspend the calling task if the
26 * resource is not available or the event did not occur.
27 *
28 * Arguments : pevent is a pointer to the event control block
29 *
30 * Returns : > 0 if the resource is available or the event did not occur the semaphore is
31 * decremented to obtain the resource.
32 * == 0 if the resource is not available or the event did not occur or,
33 * if 'pevent' is a NULL pointer or,
34 * if you didn't pass a pointer to a semaphore
35 *********************************************************************************************************
36 */
37
38 #if OS_SEM_ACCEPT_EN > 0
39 INT16U OSSemAccept (OS_EVENT *pevent)
40 {
41 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
42 OS_CPU_SR cpu_sr;
43 #endif
44 INT16U cnt;
45
46
47 #if OS_ARG_CHK_EN > 0
48 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 0000 0C93 CMP #0,R12
\ 0002 0120 JNE (?0057)
49 return (0);
50 }
\ 0004 3041 RET
\ 0006 ?0057:
51 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
\ 0006 7D400300 MOV.B #3,R13
\ 000A 6D9C CMP.B @R12,R13
\ 000C 0224 JEQ (?0059)
52 return (0);
\ 000E 0C43 MOV #0,R12
53 }
\ 0010 3041 RET
\ 0012 ?0059:
54 #endif
55 OS_ENTER_CRITICAL();
\ 0012 32C2 DINT
56 cnt = pevent->OSEventCnt;
\ 0014 1D4C0200 MOV 2(R12),R13
57 if (cnt > 0) { /* See if resource is available */
\ 0018 0D93 CMP #0,R13
\ 001A 0224 JEQ (?0061)
58 pevent->OSEventCnt--; /* Yes, decrement semaphore and notify caller */
\ 001C BC530200 ADD #-1,2(R12)
\ 0020 ?0061:
59 }
60 OS_EXIT_CRITICAL();
\ 0020 32D2 EINT
61 return (cnt); /* Return semaphore count */
\ 0022 0C4D MOV R13,R12
62 }
\ 0024 3041 RET
\ 0026 OSSemCreate:
63 #endif
64
65 /*$PAGE*/
66 /*
67 *********************************************************************************************************
68 * CREATE A SEMAPHORE
69 *
70 * Description: This function creates a semaphore.
71 *
72 * Arguments : cnt is the initial value for the semaphore. If the value is 0, no resource is
73 * available (or no event has occurred). You initialize the semaphore to a
74 * non-zero value to specify how many resources are available (e.g. if you have
75 * 10 resources, you would initialize the semaphore to 10).
76 *
77 * Returns : != (void *)0 is a pointer to the event control clock (OS_EVENT) associated with the
78 * created semaphore
79 * == (void *)0 if no event control blocks were available
80 *********************************************************************************************************
81 */
82
83 OS_EVENT *OSSemCreate (INT16U cnt)
84 {
\ 0026 0A12 PUSH R10
85 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
86 OS_CPU_SR cpu_sr;
87 #endif
88 OS_EVENT *pevent;
89
90
91 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ 0028 C2930000 CMP.B #0,&OSIntNesting
\ 002C 0224 JEQ (?0064)
92 return ((OS_EVENT *)0); /* ... can't CREATE from an ISR */
\ 002E 0C43 MOV #0,R12
93 }
\ 0030 193C JMP (?0069)
\ 0032 ?0064:
94 OS_ENTER_CRITICAL();
\ 0032 32C2 DINT
95 pevent = OSEventFreeList; /* Get next free event control block */
\ 0034 1A420000 MOV &OSEventFreeList,R10
96 if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB pool was empty */
\ 0038 82930000 CMP #0,&OSEventFreeList
\ 003C 0524 JEQ (?0066)
97 OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
\ 003E 1D420000 MOV &OSEventFreeList,R13
\ 0042 924D0400 MOV 4(R13),&OSEventFreeList
\ 0046 0000
\ 0048 ?0066:
98 }
99 OS_EXIT_CRITICAL();
\ 0048 32D2 EINT
100 if (pevent != (OS_EVENT *)0) { /* Get an event control block */
\ 004A 0A93 CMP #0,R10
\ 004C 0A24 JEQ (?0068)
101 pevent->OSEventType = OS_EVENT_TYPE_SEM;
\ 004E FA400300 MOV.B #3,0(R10)
\ 0052 0000
102 pevent->OSEventCnt = cnt; /* Set semaphore value */
\ 0054 8A4C0200 MOV R12,2(R10)
103 pevent->OSEventPtr = (void *)0; /* Unlink from ECB free list */
\ 0058 8A430400 MOV #0,4(R10)
104 OS_EventWaitListInit(pevent); /* Initialize to 'nobody waiting' on sem. */
\ 005C 0C4A MOV R10,R12
\ 005E B0120000 CALL #OS_EventWaitListInit
\ 0062 ?0068:
105 }
106 return (pevent);
\ 0062 0C4A MOV R10,R12
107 }
\ 0064 ?0069:
\ 0064 3A41 POP R10
\ 0066 3041 RET
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -