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

📄 os_mem.lst

📁 ARM仿真案例
💻 LST
📖 第 1 页 / 共 4 页
字号:
    201          *
    202          * Description: This function assigns a name to a memory partition.
    203          *
    204          * Arguments  : pmem      is a pointer to the memory partition
    205          *
    206          *              pname     is a pointer to an ASCII string that contains the name of the memory partition.
    207          *
    208          *              err       is a pointer to an error code that can contain one of the following values:
    209          *
    210          *                        OS_NO_ERR                  if the name was copied to 'pname'
    211          *                        OS_MEM_INVALID_PMEM        if you passed a NULL pointer for 'pmem'
    212          *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
    213          *						 OS_MEM_NAME_TOO_LONG       if the name doesn't fit in the storage area
    214          *
    215          * Returns    : None
    216          *********************************************************************************************************
    217          */
    218          
    219          #if OS_MEM_NAME_SIZE > 1

   \                                 In segment CODE, align 4, keep-with-next
    220          void  OSMemNameSet (OS_MEM *pmem, char *pname, INT8U *err)
    221          {
   \                     OSMemNameSet:
   \   00000000   F0B5               PUSH     {R4-R7,LR}
   \   00000002   0400               MOVS     R4,R0
   \   00000004   0D00               MOVS     R5,R1
   \   00000006   1600               MOVS     R6,R2
    222          #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    223              OS_CPU_SR  cpu_sr;
    224          #endif
    225              INT8U      len;
    226          
    227          
    228              OS_ENTER_CRITICAL();
   \   00000008   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
   \   0000000C   0700               MOVS     R7,R0
    229          #if OS_ARG_CHK_EN > 0
    230              if (pmem == (OS_MEM *)0) {                   /* Is 'pmem' a NULL pointer?                          */
   \   0000000E   002C               CMP      R4,#+0
   \   00000010   04D1               BNE      ??OSMemNameSet_0
    231                  OS_EXIT_CRITICAL();                      /* Yes                                                */
   \   00000012   3800               MOVS     R0,R7
   \   00000014   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    232                  *err = OS_MEM_INVALID_PMEM;
   \   00000018   7420               MOVS     R0,#+116
   \   0000001A   3070               STRB     R0,[R6, #+0]
    233              }
    234              if (pname == (char *)0) {                    /* Is 'pname' a NULL pointer?                         */
   \                     ??OSMemNameSet_0:
   \   0000001C   002D               CMP      R5,#+0
   \   0000001E   05D1               BNE      ??OSMemNameSet_1
    235                  OS_EXIT_CRITICAL();                      /* Yes                                                */
   \   00000020   3800               MOVS     R0,R7
   \   00000022   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    236                  *err = OS_ERR_PNAME_NULL;
   \   00000026   0F20               MOVS     R0,#+15
   \   00000028   3070               STRB     R0,[R6, #+0]
    237                  return;
   \   0000002A   14E0               B        ??OSMemNameSet_2
    238              }
    239          #endif
    240              len = OS_StrLen(pname);                      /* Can we fit the string in the storage area?         */
   \                     ??OSMemNameSet_1:
   \   0000002C   2800               MOVS     R0,R5
   \   0000002E   ........           _BLF     OS_StrLen,??OS_StrLen??rT
    241              if (len > (OS_MEM_NAME_SIZE - 1)) {          /* No                                                 */
   \   00000032   2028               CMP      R0,#+32
   \   00000034   05D3               BCC      ??OSMemNameSet_3
    242                  OS_EXIT_CRITICAL();
   \   00000036   3800               MOVS     R0,R7
   \   00000038   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    243                  *err = OS_MEM_NAME_TOO_LONG;
   \   0000003C   7720               MOVS     R0,#+119
   \   0000003E   3070               STRB     R0,[R6, #+0]
    244                  return;
   \   00000040   09E0               B        ??OSMemNameSet_2
    245              } 
    246              (void)OS_StrCopy(pmem->OSMemName, pname);    /* Yes, copy name to the memory partition header      */
   \                     ??OSMemNameSet_3:
   \   00000042   2900               MOVS     R1,R5
   \   00000044   1434               ADDS     R4,R4,#+20
   \   00000046   2000               MOVS     R0,R4
   \   00000048   ........           _BLF     OS_StrCopy,??OS_StrCopy??rT
    247              OS_EXIT_CRITICAL();
   \   0000004C   3800               MOVS     R0,R7
   \   0000004E   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    248              *err = OS_NO_ERR;
   \   00000052   0020               MOVS     R0,#+0
   \   00000054   3070               STRB     R0,[R6, #+0]
    249          }
   \                     ??OSMemNameSet_2:
   \   00000056   F0BC               POP      {R4-R7}
   \   00000058   01BC               POP      {R0}
   \   0000005A   0047               BX       R0               ;; return
    250          #endif
    251          
    252          
    253          /*
    254          *********************************************************************************************************
    255          *                                         RELEASE A MEMORY BLOCK
    256          *
    257          * Description : Returns a memory block to a partition
    258          *
    259          * Arguments   : pmem    is a pointer to the memory partition control block
    260          *
    261          *               pblk    is a pointer to the memory block being released.
    262          *
    263          * Returns     : OS_NO_ERR            if the memory block was inserted into the partition
    264          *               OS_MEM_FULL          if you are returning a memory block to an already FULL memory 
    265          *                                    partition (You freed more blocks than you allocated!)
    266          *               OS_MEM_INVALID_PMEM  if you passed a NULL pointer for 'pmem'
    267          *               OS_MEM_INVALID_PBLK  if you passed a NULL pointer for the block to release.
    268          *********************************************************************************************************
    269          */
    270          

   \                                 In segment CODE, align 4, keep-with-next
    271          INT8U  OSMemPut (OS_MEM *pmem, void *pblk)
    272          {
   \                     OSMemPut:
   \   00000000   30B5               PUSH     {R4,R5,LR}
   \   00000002   0400               MOVS     R4,R0
   \   00000004   0D00               MOVS     R5,R1
    273          #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    274              OS_CPU_SR  cpu_sr;
    275          #endif    
    276              
    277              
    278          #if OS_ARG_CHK_EN > 0
    279              if (pmem == (OS_MEM *)0) {                   /* Must point to a valid memory partition             */
   \   00000006   002C               CMP      R4,#+0
   \   00000008   01D1               BNE      ??OSMemPut_0
    280                  return (OS_MEM_INVALID_PMEM);
   \   0000000A   7420               MOVS     R0,#+116
   \   0000000C   16E0               B        ??OSMemPut_1
    281              }
    282              if (pblk == (void *)0) {                     /* Must release a valid block                         */
   \                     ??OSMemPut_0:
   \   0000000E   002D               CMP      R5,#+0
   \   00000010   01D1               BNE      ??OSMemPut_2
    283                  return (OS_MEM_INVALID_PBLK);
   \   00000012   7320               MOVS     R0,#+115
   \   00000014   12E0               B        ??OSMemPut_1
    284              }
    285          #endif
    286              OS_ENTER_CRITICAL();
   \                     ??OSMemPut_2:
   \   00000016   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
    287              if (pmem->OSMemNFree >= pmem->OSMemNBlks) {  /* Make sure all blocks not already returned          */
   \   0000001A   2169               LDR      R1,[R4, #+16]
   \   0000001C   E268               LDR      R2,[R4, #+12]
   \   0000001E   9142               CMP      R1,R2
   \   00000020   03D3               BCC      ??OSMemPut_3
    288                  OS_EXIT_CRITICAL();
   \   00000022   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    289                  return (OS_MEM_FULL);
   \   00000026   7220               MOVS     R0,#+114
   \   00000028   08E0               B        ??OSMemPut_1
    290              }
    291              *(void **)pblk      = pmem->OSMemFreeList;   /* Insert released block into free block list         */
   \                     ??OSMemPut_3:
   \   0000002A   6168               LDR      R1,[R4, #+4]
   \   0000002C   2960               STR      R1,[R5, #+0]
    292              pmem->OSMemFreeList = pblk;
   \   0000002E   6560               STR      R5,[R4, #+4]
    293              pmem->OSMemNFree++;                          /* One more memory block in this partition            */
   \   00000030   2169               LDR      R1,[R4, #+16]
   \   00000032   491C               ADDS     R1,R1,#+1
   \   00000034   2161               STR      R1,[R4, #+16]
    294              OS_EXIT_CRITICAL();
   \   00000036   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
    295              return (OS_NO_ERR);                          /* Notify caller that memory block was released       */
   \   0000003A   0020               MOVS     R0,#+0
   \                     ??OSMemPut_1:
   \   0000003C   30BC               POP      {R4,R5}
   \   0000003E   02BC               POP      {R1}
   \   00000040   0847               BX       R1               ;; return
    296          }
    297          
    298          /*
    299          *********************************************************************************************************
    300          *                                          QUERY MEMORY PARTITION
    301          *
    302          * Description : This function is used to determine the number of free memory blocks and the number of
    303          *               used memory blocks from a memory partition.
    304          *
    305          * Arguments   : pmem        is a pointer to the memory partition control block
    306          *
    307          *               p_mem_data  is a pointer to a structure that will contain information about the memory
    308          *                           partition.
    309          *
    310          * Returns     : OS_NO_ERR            If no errors were found.
    311          *               OS_MEM_INVALID_PMEM  if you passed a NULL pointer for 'pmem'
    312          *               OS_MEM_INVALID_PDATA if you passed a NULL pointer to the data recipient.
    313          *********************************************************************************************************
    314          */

⌨️ 快捷键说明

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