⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_core.s79

📁 ARM仿真案例
💻 S79
📖 第 1 页 / 共 5 页
字号:
//   33 *                                       PRIORITY RESOLUTION TABLE
//   34 *
//   35 * Note: Index into table is bit pattern to resolve highest priority
//   36 *       Indexed value corresponds to highest priority bit position (i.e. 0..7)
//   37 *********************************************************************************************************
//   38 */
//   39 

        RSEG DATA_C:CONST:SORT:NOROOT(2)
//   40 INT8U  const  OSUnMapTbl[256] = {
OSUnMapTbl:
        DATA
        DC8 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1
        DC8 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0
        DC8 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2
        DC8 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0
        DC8 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1
        DC8 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 7, 0, 1, 0, 2, 0, 1, 0, 3, 0
        DC8 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5
        DC8 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0
        DC8 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1
        DC8 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0
        DC8 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2
        DC8 0, 1, 0

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock0 Using cfiCommon0
        CFI NoFunction
        ARM
??OSEventNameGet??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock0
        REQUIRE OSEventNameGet
//   41     0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x00 to 0x0F                             */
//   42     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x10 to 0x1F                             */
//   43     5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x20 to 0x2F                             */
//   44     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x30 to 0x3F                             */
//   45     6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x40 to 0x4F                             */
//   46     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x50 to 0x5F                             */
//   47     5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x60 to 0x6F                             */
//   48     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x70 to 0x7F                             */
//   49     7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x80 to 0x8F                             */
//   50     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0x90 to 0x9F                             */
//   51     5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0xA0 to 0xAF                             */
//   52     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0xB0 to 0xBF                             */
//   53     6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0xC0 to 0xCF                             */
//   54     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0xD0 to 0xDF                             */
//   55     5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,       /* 0xE0 to 0xEF                             */
//   56     4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0        /* 0xF0 to 0xFF                             */
//   57 };
//   58 
//   59 /*$PAGE*/
//   60 /*
//   61 *********************************************************************************************************
//   62 *                                       FUNCTION PROTOTYPES
//   63 *********************************************************************************************************
//   64 */
//   65 static  void  OS_InitEventList(void);
//   66 static  void  OS_InitMisc(void);
//   67 static  void  OS_InitRdyList(void);
//   68 static  void  OS_InitTaskIdle(void);
//   69 #if OS_TASK_STAT_EN > 0
//   70 static  void  OS_InitTaskStat(void);
//   71 #endif
//   72 static  void  OS_InitTCBList(void);
//   73 
//   74 /*$PAGE*/
//   75 /*
//   76 *********************************************************************************************************
//   77 *                         GET THE NAME OF A SEMAPHORE, MUTEX, MAILBOX or QUEUE
//   78 *
//   79 * Description: This function is used to obtain the name assigned to a semaphore, mutex, mailbox or queue.
//   80 *
//   81 * Arguments  : pevent    is a pointer to the event group.  'pevent' can point either to a semaphore,
//   82 *                        a mutex, a mailbox or a queue.  Where this function is concerned, the actual
//   83 *                        type is irrelevant.
//   84 *
//   85 *              pname     is a pointer to an ASCII string that will receive the name of the semaphore,
//   86 *                        mutex, mailbox or queue.  The string must be able to hold at least 
//   87 *                        OS_EVENT_NAME_SIZE characters.
//   88 *
//   89 *              err       is a pointer to an error code that can contain one of the following values:
//   90 *
//   91 *                        OS_NO_ERR                  if the name was copied to 'pname'
//   92 *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to the proper event 
//   93 *                                                   control block type.
//   94 *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
//   95 *                        OS_ERR_PEVENT_NULL         if you passed a NULL pointer for 'pevent'
//   96 *
//   97 * Returns    : The length of the string or 0 if the 'pevent' is a NULL pointer.
//   98 *********************************************************************************************************
//   99 */
//  100 
//  101 #if OS_EVENT_NAME_SIZE > 1

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock1 Using cfiCommon1
        CFI Function OSEventNameGet
        THUMB
//  102 INT8U  OSEventNameGet (OS_EVENT *pevent, char *pname, INT8U *err)
//  103 {
OSEventNameGet:
        PUSH     {R4-R7,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R7 Frame(CFA, -8)
        CFI R6 Frame(CFA, -12)
        CFI R5 Frame(CFA, -16)
        CFI R4 Frame(CFA, -20)
        CFI CFA R13+20
        MOVS     R6,R0
        MOVS     R7,R1
        MOVS     R4,R2
//  104 #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
//  105     OS_CPU_SR  cpu_sr;
//  106 #endif
//  107     INT8U      len;
//  108 
//  109 
//  110     OS_ENTER_CRITICAL();
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
        MOVS     R5,R0
//  111 #if OS_ARG_CHK_EN > 0
//  112     if (pevent == (OS_EVENT *)0) {               /* Is 'pevent' a NULL pointer?                        */
        CMP      R6,#+0
        BNE      ??OSEventNameGet_0
//  113         OS_EXIT_CRITICAL();                      /* Yes                                                */
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  114         *err = OS_ERR_PEVENT_NULL;
        MOVS     R0,#+4
        B.N      ??OSEventNameGet_1
//  115         return (0);
//  116     }
//  117     if (pname == (char *)0) {                    /* Is 'pname' a NULL pointer?                         */
??OSEventNameGet_0:
        CMP      R7,#+0
        BNE      ??OSEventNameGet_2
//  118         OS_EXIT_CRITICAL();                      /* Yes                                                */
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  119         *err = OS_ERR_PNAME_NULL;
        MOVS     R0,#+15
        B.N      ??OSEventNameGet_1
//  120         return (0);
//  121     }
//  122 #endif
//  123     switch (pevent->OSEventType) {
??OSEventNameGet_2:
        LDRB     R0,[R6, #+0]
        SUBS     R0,R0,#+1
        CMP      R0,#+3
        BHI      ??OSEventNameGet_3
//  124         case OS_EVENT_TYPE_SEM:
//  125         case OS_EVENT_TYPE_MUTEX:
//  126         case OS_EVENT_TYPE_MBOX:
//  127         case OS_EVENT_TYPE_Q:
//  128              break;
//  129 
//  130         default:
//  131              OS_EXIT_CRITICAL();
//  132              *err = OS_ERR_EVENT_TYPE;
//  133              return (0);
//  134     }
//  135     len  = OS_StrCopy(pname, pevent->OSEventName);    /* Copy name from OS_EVENT                       */
        ADDS     R6,R6,#+16
        MOVS     R1,R6
        MOVS     R0,R7
        BL       OS_StrCopy
        MOVS     R6,R0
//  136     OS_EXIT_CRITICAL();
        MOVS     R0,R5
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  137     *err = OS_NO_ERR;
        MOVS     R0,#+0
        STRB     R0,[R4, #+0]
//  138     return (len);
        MOVS     R0,R6
        B        ??OSEventNameGet_4
??OSEventNameGet_3:
        MOVS     R0,R5
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
        MOVS     R0,#+1
??OSEventNameGet_1:
        STRB     R0,[R4, #+0]
        MOVS     R0,#+0
??OSEventNameGet_4:
        POP      {R4-R7}
        POP      {R1}
        BX       R1               ;; return
        CFI EndBlock cfiBlock1
//  139 }

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock2 Using cfiCommon0
        CFI NoFunction
        ARM
??OSEventNameSet??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock2
        REQUIRE OSEventNameSet
//  140 #endif
//  141 
//  142 /*$PAGE*/
//  143 /*
//  144 *********************************************************************************************************
//  145 *                         ASSIGN A NAME TO A SEMAPHORE, MUTEX, MAILBOX or QUEUE
//  146 *
//  147 * Description: This function assigns a name to a semaphore, mutex, mailbox or queue.
//  148 *
//  149 * Arguments  : pevent    is a pointer to the event group.  'pevent' can point either to a semaphore,
//  150 *                        a mutex, a mailbox or a queue.  Where this function is concerned, it doesn't
//  151 *                        matter the actual type.
//  152 *
//  153 *              pname     is a pointer to an ASCII string that will be used as the name of the semaphore,
//  154 *                        mutex, mailbox or queue.  The string must be able to hold at least 
//  155 *                        OS_EVENT_NAME_SIZE characters.
//  156 *
//  157 *              err       is a pointer to an error code that can contain one of the following values:
//  158 *
//  159 *                        OS_NO_ERR                  if the requested task is resumed
//  160 *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to the proper event 
//  161 *                                                   control block type.
//  162 *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
//  163 *                        OS_ERR_PEVENT_NULL         if you passed a NULL pointer for 'pevent'
//  164 *
//  165 * Returns    : None
//  166 *********************************************************************************************************
//  167 */
//  168 
//  169 #if OS_EVENT_NAME_SIZE > 1

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock3 Using cfiCommon1
        CFI Function OSEventNameSet
        THUMB
//  170 void  OSEventNameSet (OS_EVENT *pevent, char *pname, INT8U *err)
//  171 {
OSEventNameSet:
        PUSH     {R4-R7,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R7 Frame(CFA, -8)
        CFI R6 Frame(CFA, -12)
        CFI R5 Frame(CFA, -16)
        CFI R4 Frame(CFA, -20)
        CFI CFA R13+20
        MOVS     R5,R0
        MOVS     R6,R1
        MOVS     R4,R2
//  172 #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
//  173     OS_CPU_SR  cpu_sr;
//  174 #endif
//  175     INT8U      len;
//  176 
//  177 
//  178     OS_ENTER_CRITICAL();
        _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
        MOVS     R7,R0
//  179 #if OS_ARG_CHK_EN > 0
//  180     if (pevent == (OS_EVENT *)0) {               /* Is 'pevent' a NULL pointer?                        */
        CMP      R5,#+0
        BNE      ??OSEventNameSet_0
//  181         OS_EXIT_CRITICAL();                      /* Yes                                                */
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  182         *err = OS_ERR_PEVENT_NULL;
        MOVS     R0,#+4
        B.N      ??OSEventNameSet_1
//  183         return;
//  184     }
//  185     if (pname == (char *)0) {                    /* Is 'pname' a NULL pointer?                         */
??OSEventNameSet_0:
        CMP      R6,#+0
        BNE      ??OSEventNameSet_2
//  186         OS_EXIT_CRITICAL();                      /* Yes                                                */
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  187         *err = OS_ERR_PNAME_NULL;
        MOVS     R0,#+15
        B.N      ??OSEventNameSet_1
//  188         return;
//  189     }
//  190 #endif
//  191     switch (pevent->OSEventType) {
??OSEventNameSet_2:
        LDRB     R0,[R5, #+0]
        SUBS     R0,R0,#+1
        CMP      R0,#+3
        BHI      ??OSEventNameSet_3
//  192         case OS_EVENT_TYPE_SEM:
//  193         case OS_EVENT_TYPE_MUTEX:
//  194         case OS_EVENT_TYPE_MBOX:
//  195         case OS_EVENT_TYPE_Q:
//  196              break;
//  197 
//  198         default:
//  199              OS_EXIT_CRITICAL();
//  200              *err = OS_ERR_EVENT_TYPE;
//  201              return;
//  202     }
//  203     len = OS_StrLen(pname);                           /* Can we fit the string in the storage area?    */
        MOVS     R0,R6
        BL       OS_StrLen
//  204     if (len > (OS_EVENT_NAME_SIZE - 1)) {             /* No                                            */
        CMP      R0,#+32
        BCC      ??OSEventNameSet_4
//  205         OS_EXIT_CRITICAL();
        MOVS     R0,R7
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  206         *err = OS_ERR_EVENT_NAME_TOO_LONG;
        MOVS     R0,#+12
        B.N      ??OSEventNameSet_1
//  207         return;
//  208     } 
??OSEventNameSet_3:
        MOVS     R0,R7
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
        MOVS     R0,#+1
        B.N      ??OSEventNameSet_1
//  209     (void)OS_StrCopy(pevent->OSEventName, pname);     /* Yes, copy name to the event control block     */
??OSEventNameSet_4:
        MOVS     R1,R6
        ADDS     R5,R5,#+16
        MOVS     R0,R5
        BL       OS_StrCopy
//  210     OS_EXIT_CRITICAL();
        MOVS     R0,R7
        _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
//  211     *err = OS_NO_ERR;
        MOVS     R0,#+0
??OSEventNameSet_1:
        STRB     R0,[R4, #+0]
//  212 }
        POP      {R4-R7}
        POP      {R0}
        BX       R0               ;; return
        CFI EndBlock cfiBlock3

        RSEG CODE:CODE:NOROOT(2)
        CFI Block cfiBlock4 Using cfiCommon0
        CFI NoFunction
        ARM
??OSInit??rA:
        ADD      R12,PC,#+1
        BX       R12
        CFI EndBlock cfiBlock4
        REQUIRE OSInit
//  213 #endif
//  214 
//  215 /*$PAGE*/
//  216 /*

⌨️ 快捷键说明

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