os_core.lis

来自「将本站的UCOSFORAVR128V276版本升级到了280版」· LIS 代码 · 共 1,342 行 · 第 1/5 页

LIS
1,342
字号
 0000           ;     *err = OS_NO_ERR;
 0000           ;     return (len);
 0000           ; }
 0000           ; #endif
 0000           ; 
 0000           ; /*$PAGE*/
 0000           ; /*
 0000           ; *********************************************************************************************************
 0000           ; *                         ASSIGN A NAME TO A SEMAPHORE, MUTEX, MAILBOX or QUEUE
 0000           ; *
 0000           ; * Description: This function assigns a name to a semaphore, mutex, mailbox or queue.
 0000           ; *
 0000           ; * Arguments  : pevent    is a pointer to the event group.  'pevent' can point either to a semaphore,
 0000           ; *                        a mutex, a mailbox or a queue.  Where this function is concerned, it doesn't
 0000           ; *                        matter the actual type.
 0000           ; *
 0000           ; *              pname     is a pointer to an ASCII string that will be used as the name of the semaphore,
 0000           ; *                        mutex, mailbox or queue.  The string must be able to hold at least
 0000           ; *                        OS_EVENT_NAME_SIZE characters.
 0000           ; *
 0000           ; *              err       is a pointer to an error code that can contain one of the following values:
 0000           ; *
 0000           ; *                        OS_NO_ERR                  if the requested task is resumed
 0000           ; *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to the proper event
 0000           ; *                                                   control block type.
 0000           ; *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
 0000           ; *                        OS_ERR_PEVENT_NULL         if you passed a NULL pointer for 'pevent'
 0000           ; *
 0000           ; * Returns    : None
 0000           ; *********************************************************************************************************
 0000           ; */
 0000           ; 
 0000           ; #if OS_EVENT_EN && (OS_EVENT_NAME_SIZE > 1)
 0000           ; void  OSEventNameSet (OS_EVENT *pevent, INT8U *pname, INT8U *err)
 0000           ; {
 0000           ;     INT8U      len;
 0000           ; #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 0000           ;     OS_CPU_SR  cpu_sr = 0;
 0000           ; #endif
 0000           ; 
 0000           ; 
 0000           ; 
 0000           ; #if OS_ARG_CHK_EN > 0
 0000           ;     if (err == (INT8U *)0) {                     /* Validate 'err'                                     */
 0000           ;         return;
 0000           ;     }
 0000           ;     if (pevent == (OS_EVENT *)0) {               /* Is 'pevent' a NULL pointer?                        */
 0000           ;         *err = OS_ERR_PEVENT_NULL;
 0000           ;         return;
 0000           ;     }
 0000           ;     if (pname == (INT8U *)0) {                    /* Is 'pname' a NULL pointer?                         */
 0000           ;         *err = OS_ERR_PNAME_NULL;
 0000           ;         return;
 0000           ;     }
 0000           ; #endif
 0000           ;     switch (pevent->OSEventType) {
 0000           ;         case OS_EVENT_TYPE_SEM:
 0000           ;         case OS_EVENT_TYPE_MUTEX:
 0000           ;         case OS_EVENT_TYPE_MBOX:
 0000           ;         case OS_EVENT_TYPE_Q:
 0000           ;              break;
 0000           ; 
 0000           ;         default:
 0000           ;              *err = OS_ERR_EVENT_TYPE;
 0000           ;              return;
 0000           ;     }
 0000           ;     OS_ENTER_CRITICAL();
 0000           ;     len = OS_StrLen(pname);                           /* Can we fit the string in the storage area?    */
 0000           ;     if (len > (OS_EVENT_NAME_SIZE - 1)) {             /* No                                            */
 0000           ;         OS_EXIT_CRITICAL();
 0000           ;         *err = OS_ERR_EVENT_NAME_TOO_LONG;
 0000           ;         return;
 0000           ;     }
 0000           ;     (void)OS_StrCopy(pevent->OSEventName, pname);     /* Yes, copy name to the event control block     */
 0000           ;     OS_EXIT_CRITICAL();
 0000           ;     *err = OS_NO_ERR;
 0000           ; }
 0000           ; #endif
 0000           ; 
 0000           ; /*$PAGE*/
 0000           ; /*
 0000           ; *********************************************************************************************************
 0000           ; *                                             INITIALIZATION
 0000           ; *
 0000           ; * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
 0000           ; *              creating any uC/OS-II object and, prior to calling OSStart().
 0000           ; *
 0000           ; * Arguments  : none
 0000           ; *
 0000           ; * Returns    : none
 0000           ; *********************************************************************************************************
 0000           ; */
 0000           ; 
 0000           ; void  OSInit (void)
 0000           ; {
 0000                   .dbline 226
 0000           ; #if OS_VERSION >= 204
 0000           ;     OSInitHookBegin();                                           /* Call port specific initialization code   */
 0000 0E940000          xcall _OSInitHookBegin
 0004                   .dbline 229
 0004           ; #endif
 0004           ; 
 0004           ;     OS_InitMisc();                                               /* Initialize miscellaneous variables       */
 0004 92D2              xcall _OS_InitMisc
 0006                   .dbline 231
 0006           ; 
 0006           ;     OS_InitRdyList();                                            /* Initialize the Ready List                */
 0006 B7D2              xcall _OS_InitRdyList
 0008                   .dbline 233
 0008           ; 
 0008           ;     OS_InitTCBList();                                            /* Initialize the free list of OS_TCBs      */
 0008 E2D2              xcall _OS_InitTCBList
 000A                   .dbline 235
 000A           ; 
 000A           ;     OS_InitEventList();                                          /* Initialize the free list of OS_EVENTs    */
 000A 61D2              xcall _OS_InitEventList
 000C                   .dbline 249
 000C           ; 
 000C           ; #if (OS_VERSION >= 251) && (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
 000C           ;     OS_FlagInit();                                               /* Initialize the event flag structures     */
 000C           ; #endif
 000C           ; 
 000C           ; #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
 000C           ;     OS_MemInit();                                                /* Initialize the memory manager            */
 000C           ; #endif
 000C           ; 
 000C           ; #if (OS_Q_EN > 0) && (OS_MAX_QS > 0)
 000C           ;     OS_QInit();                                                  /* Initialize the message queue structures  */
 000C           ; #endif
 000C           ; 
 000C           ;     OS_InitTaskIdle();                                           /* Create the Idle Task                     */
 000C D1D2              xcall _OS_InitTaskIdle
 000E                   .dbline 255
 000E           ; #if OS_TASK_STAT_EN > 0
 000E           ;     OS_InitTaskStat();                                           /* Create the Statistic Task                */
 000E           ; #endif
 000E           ; 
 000E           ; #if OS_VERSION >= 204
 000E           ;     OSInitHookEnd();                                             /* Call port specific init. code            */
 000E 0E940000          xcall _OSInitHookEnd
 0012                   .dbline 259
 0012           ; #endif
 0012           ; 
 0012           ; #if OS_VERSION >= 270 && OS_DEBUG_EN > 0
 0012           ;     OSDebugInit();
 0012 0E940000          xcall _OSDebugInit
 0016                   .dbline -2
 0016           L1:
 0016                   .dbline 0 ; func end
 0016 0895              ret
 0018                   .dbend
 0018                   .dbfunc e OSIntEnter _OSIntEnter fV
                        .even
 0018           _OSIntEnter::
 0018                   .dbline -1
 0018                   .dbline 289
 0018           ; #endif
 0018           ; }
 0018           ; /*$PAGE*/
 0018           ; /*
 0018           ; *********************************************************************************************************
 0018           ; *                                              ENTER ISR
 0018           ; *
 0018           ; * Description: This function is used to notify uC/OS-II that you are about to service an interrupt
 0018           ; *              service routine (ISR).  This allows uC/OS-II to keep track of interrupt nesting and thus
 0018           ; *              only perform rescheduling at the last nested ISR.
 0018           ; *
 0018           ; * Arguments  : none
 0018           ; *
 0018           ; * Returns    : none
 0018           ; *
 0018           ; * Notes      : 1) This function should be called ith interrupts already disabled
 0018           ; *              2) Your ISR can directly increment OSIntNesting without calling this function because
 0018           ; *                 OSIntNesting has been declared 'global'.
 0018           ; *              3) You MUST still call OSIntExit() even though you increment OSIntNesting directly.
 0018           ; *              4) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
 0018           ; *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
 0018           ; *                 end of the ISR.
 0018           ; *              5) You are allowed to nest interrupts up to 255 levels deep.
 0018           ; *              6) I removed the OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() around the increment because
 0018           ; *                 OSIntEnter() is always called with interrupts disabled.
 0018           ; *********************************************************************************************************
 0018           ; */
 0018           ; 
 0018           ; void  OSIntEnter (void)
 0018           ; {
 0018                   .dbline 290
 0018           ;     if (OSRunning == TRUE) {
 0018 80919E01          lds R24,_OSRunning
 001C 8130              cpi R24,1
 001E 39F4              brne L3
 0020                   .dbline 290
 0020                   .dbline 291
 0020           ;         if (OSIntNesting < 255u) {
 0020 8091A501          lds R24,_OSIntNesting
 0024 8F3F              cpi R24,255
 0026 18F4              brsh L5
 0028                   .dbline 291
 0028                   .dbline 292
 0028           ;             OSIntNesting++;                      /* Increment ISR nesting level                        */
 0028 8F5F              subi R24,255    ; addi 1
 002A 8093A501          sts _OSIntNesting,R24
 002E                   .dbline 293
 002E           ;         }
 002E           L5:
 002E                   .dbline 294
 002E           L3:
 002E                   .dbline -2
 002E           L2:
 002E                   .dbline 0 ; func end
 002E 0895              ret
 0030                   .dbend
 0030                   .dbfunc e OSIntExit _OSIntExit fV
 0030           ;         cpu_sr -> R10
                        .even
 0030           _OSIntExit::
 0030 0E940000          xcall push_gset3
 0034                   .dbline -1
 0034                   .dbline 317
 0034           ;     }
 0034           ; }
 0034           ; /*$PAGE*/
 0034           ; /*
 0034           ; *********************************************************************************************************
 0034           ; *                                               EXIT ISR
 0034           ; *
 0034           ; * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR.  When
 0034           ; *              the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
 0034           ; *              a new, high-priority task, is ready to run.
 0034           ; *
 0034           ; * Arguments  : none
 0034           ; *
 0034           ; * Returns    : none
 0034           ; *
 0034           ; * Notes      : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
 0034           ; *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
 0034           ; *                 end of the ISR.
 0034           ; *              2) Rescheduling is prevented when the scheduler is locked (see OS_SchedLock())
 0034           ; *********************************************************************************************************
 0034           ; */
 0034           ; 
 0034           ; void  OSIntExit (void)
 0034           ; {
 0034                   .dbline 319
 0034           ; #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register */
 0034           ;     OS_CPU_SR  cpu_sr = 0;
 0034 AA24              clr R10
 0036                   .dbline 324
 0036           ; #endif
 0036           ; 
 0036           ; 
 0036           ; 
 0036           ;     if (OSRunning == TRUE) {
 0036 80919E01          lds R24,_OSRunning
 003A 8130              cpi R24,1
 003C 09F0              breq X0
 003E 46C0              xjmp L8
 0040           X0:
 0040                   .dbline 324
 0040                   .dbline 325
 0040           ;         OS_ENTER_CRITICAL();
 0040 0E940000          xcall _OS_CPU_SR_Save
 0044 A02E              mov R10,R16
 0046                   .dbline 326
 0046           ;         if (OSIntNesting > 0) {                            /* Prevent OSIntNesting from wrapping       */
 0046 2224              clr R2
 0048 3090A501          lds R3,_OSIntNesting
 004C 2314              cp R2,R3
 004E 20F4              brsh L10

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?