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

📄 os_mem.lst

📁 IARSOURCECODE是基于LPC2478嵌入式软件IAR EWARM V4.42的应用实例代码
💻 LST
📖 第 1 页 / 共 4 页
字号:
    101              OS_EXIT_CRITICAL();
   \                     ??OSMemCreate_7:
   \   000000D4   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    102              if (pmem == (OS_MEM *)0) {                        /* See if we have a memory partition             */
   \   000000D8   000058E3           CMP      R8,#+0
   \   000000DC   0300001A           BNE      ??OSMemCreate_8
    103                  *err = OS_ERR_MEM_INVALID_PART;
   \   000000E0   5A00A0E3           MOV      R0,#+90
   \   000000E4   0000C4E5           STRB     R0,[R4, #+0]
    104                  return ((OS_MEM *)0);
   \   000000E8   0000A0E3           MOV      R0,#+0
   \   000000EC   140000EA           B        ??OSMemCreate_1
    105              }
    106              plink = (void **)addr;                            /* Create linked list of free memory blocks      */
   \                     ??OSMemCreate_8:
   \   000000F0   0510B0E1           MOVS     R1,R5
    107              pblk  = (INT8U *)((INT32U)addr + blksize);
   \   000000F4   050097E0           ADDS     R0,R7,R5
    108              for (i = 0; i < (nblks - 1); i++) {
   \   000000F8   0020A0E3           MOV      R2,#+0
   \   000000FC   030000EA           B        ??OSMemCreate_9
    109                 *plink = (void *)pblk;                         /* Save pointer to NEXT block in CURRENT block   */
   \                     ??OSMemCreate_10:
   \   00000100   000081E5           STR      R0,[R1, #+0]
    110                  plink = (void **)pblk;                        /* Position to  NEXT      block                  */
   \   00000104   0010B0E1           MOVS     R1,R0
    111                  pblk  = (INT8U *)((INT32U)pblk + blksize);    /* Point to the FOLLOWING block                  */
   \   00000108   000097E0           ADDS     R0,R7,R0
    112              }
   \   0000010C   012092E2           ADDS     R2,R2,#+1
   \                     ??OSMemCreate_9:
   \   00000110   013056E2           SUBS     R3,R6,#+1
   \   00000114   030052E1           CMP      R2,R3
   \   00000118   F8FFFF3A           BCC      ??OSMemCreate_10
    113              *plink              = (void *)0;                  /* Last memory block points to NULL              */
   \   0000011C   0000A0E3           MOV      R0,#+0
   \   00000120   000081E5           STR      R0,[R1, #+0]
    114              pmem->OSMemAddr     = addr;                       /* Store start address of memory partition       */
   \   00000124   005088E5           STR      R5,[R8, #+0]
    115              pmem->OSMemFreeList = addr;                       /* Initialize pointer to pool of free blocks     */
   \   00000128   045088E5           STR      R5,[R8, #+4]
    116              pmem->OSMemNFree    = nblks;                      /* Store number of free blocks in MCB            */
   \   0000012C   106088E5           STR      R6,[R8, #+16]
    117              pmem->OSMemNBlks    = nblks;
   \   00000130   0C6088E5           STR      R6,[R8, #+12]
    118              pmem->OSMemBlkSize  = blksize;                    /* Store block size of each memory blocks        */
   \   00000134   087088E5           STR      R7,[R8, #+8]
    119              *err                = OS_ERR_NONE;
   \   00000138   0000A0E3           MOV      R0,#+0
   \   0000013C   0000C4E5           STRB     R0,[R4, #+0]
    120              return (pmem);
   \   00000140   0800B0E1           MOVS     R0,R8
   \                     ??OSMemCreate_1:
   \   00000144   F081BDE8           POP      {R4-R8,PC}       ;; return
    121          }
    122          /*$PAGE*/
    123          /*
    124          *********************************************************************************************************
    125          *                                          GET A MEMORY BLOCK
    126          *
    127          * Description : Get a memory block from a partition
    128          *
    129          * Arguments   : pmem    is a pointer to the memory partition control block
    130          *
    131          *               err     is a pointer to a variable containing an error message which will be set by this
    132          *                       function to either:
    133          *
    134          *                       OS_ERR_NONE             if the memory partition has been created correctly.
    135          *                       OS_ERR_MEM_NO_FREE_BLKS if there are no more free memory blocks to allocate to caller
    136          *                       OS_ERR_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
    137          *
    138          * Returns     : A pointer to a memory block if no error is detected
    139          *               A pointer to NULL if an error is detected
    140          *********************************************************************************************************
    141          */
    142          

   \                                 In segment CODE, align 4, keep-with-next
    143          void  *OSMemGet (OS_MEM *pmem, INT8U *err)
    144          {
   \                     OSMemGet:
   \   00000000   70402DE9           PUSH     {R4-R6,LR}
   \   00000004   0050B0E1           MOVS     R5,R0
   \   00000008   0140B0E1           MOVS     R4,R1
    145              void      *pblk;
    146          #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    147              OS_CPU_SR  cpu_sr = 0;
   \   0000000C   0000A0E3           MOV      R0,#+0
    148          #endif
    149          
    150          
    151          
    152          #if OS_ARG_CHK_EN > 0
    153              if (err == (INT8U *)0) {                          /* Validate 'err'                                */
   \   00000010   000054E3           CMP      R4,#+0
   \   00000014   0100001A           BNE      ??OSMemGet_0
    154                  return ((void *)0);
   \   00000018   0000A0E3           MOV      R0,#+0
   \   0000001C   180000EA           B        ??OSMemGet_1
    155              }
    156              if (pmem == (OS_MEM *)0) {                        /* Must point to a valid memory partition        */
   \                     ??OSMemGet_0:
   \   00000020   000055E3           CMP      R5,#+0
   \   00000024   0300001A           BNE      ??OSMemGet_2
    157                  *err = OS_ERR_MEM_INVALID_PMEM;
   \   00000028   6000A0E3           MOV      R0,#+96
   \   0000002C   0000C4E5           STRB     R0,[R4, #+0]
    158                  return ((void *)0);
   \   00000030   0000A0E3           MOV      R0,#+0
   \   00000034   120000EA           B        ??OSMemGet_1
    159              }
    160          #endif
    161              OS_ENTER_CRITICAL();
   \                     ??OSMemGet_2:
   \   00000038   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
    162              if (pmem->OSMemNFree > 0) {                       /* See if there are any free memory blocks       */
   \   0000003C   101095E5           LDR      R1,[R5, #+16]
   \   00000040   000051E3           CMP      R1,#+0
   \   00000044   0A00000A           BEQ      ??OSMemGet_3
    163                  pblk                = pmem->OSMemFreeList;    /* Yes, point to next free memory block          */
   \   00000048   046095E5           LDR      R6,[R5, #+4]
    164                  pmem->OSMemFreeList = *(void **)pblk;         /*      Adjust pointer to new free list          */
   \   0000004C   001096E5           LDR      R1,[R6, #+0]
   \   00000050   041085E5           STR      R1,[R5, #+4]
    165                  pmem->OSMemNFree--;                           /*      One less memory block in this partition  */
   \   00000054   101095E5           LDR      R1,[R5, #+16]
   \   00000058   011051E2           SUBS     R1,R1,#+1
   \   0000005C   101085E5           STR      R1,[R5, #+16]
    166                  OS_EXIT_CRITICAL();
   \   00000060   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    167                  *err = OS_ERR_NONE;                           /*      No error                                 */
   \   00000064   0000A0E3           MOV      R0,#+0
   \   00000068   0000C4E5           STRB     R0,[R4, #+0]
    168                  return (pblk);                                /*      Return memory block to caller            */
   \   0000006C   0600B0E1           MOVS     R0,R6
   \   00000070   030000EA           B        ??OSMemGet_1
    169              }
    170              OS_EXIT_CRITICAL();
   \                     ??OSMemGet_3:
   \   00000074   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    171              *err = OS_ERR_MEM_NO_FREE_BLKS;                   /* No,  Notify caller of empty memory partition  */
   \   00000078   5D00A0E3           MOV      R0,#+93
   \   0000007C   0000C4E5           STRB     R0,[R4, #+0]
    172              return ((void *)0);                               /*      Return NULL pointer to caller            */
   \   00000080   0000A0E3           MOV      R0,#+0
   \                     ??OSMemGet_1:
   \   00000084   7080BDE8           POP      {R4-R6,PC}       ;; return
    173          }
    174          /*$PAGE*/
    175          /*
    176          *********************************************************************************************************
    177          *                                   GET THE NAME OF A MEMORY PARTITION
    178          *
    179          * Description: This function is used to obtain the name assigned to a memory partition.
    180          *
    181          * Arguments  : pmem      is a pointer to the memory partition
    182          *
    183          *              pname     is a pointer to an ASCII string that will receive the name of the memory partition.
    184          *
    185          *              err       is a pointer to an error code that can contain one of the following values:
    186          *
    187          *                        OS_ERR_NONE                if the name was copied to 'pname'
    188          *                        OS_ERR_MEM_INVALID_PMEM    if you passed a NULL pointer for 'pmem'
    189          *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
    190          *
    191          * Returns    : The length of the string or 0 if 'pmem' is a NULL pointer.
    192          *********************************************************************************************************
    193          */
    194          
    195          #if OS_MEM_NAME_SIZE > 1

   \                                 In segment CODE, align 4, keep-with-next
    196          INT8U  OSMemNameGet (OS_MEM *pmem, INT8U *pname, INT8U *err)
    197          {
   \                     OSMemNameGet:
   \   00000000   F0402DE9           PUSH     {R4-R7,LR}
   \   00000004   0040B0E1           MOVS     R4,R0
   \   00000008   0150B0E1           MOVS     R5,R1
   \   0000000C   0260B0E1           MOVS     R6,R2
    198              INT8U      len;
    199          #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    200              OS_CPU_SR  cpu_sr = 0;
   \   00000010   0070A0E3           MOV      R7,#+0
    201          #endif
    202          
    203          
    204          
    205              OS_ENTER_CRITICAL();
   \   00000014   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
   \   00000018   0070B0E1           MOVS     R7,R0
    206          #if OS_ARG_CHK_EN > 0
    207              if (err == (INT8U *)0) {                     /* Validate 'err'                                     */
   \   0000001C   000056E3           CMP      R6,#+0
   \   00000020   0300001A           BNE      ??OSMemNameGet_0
    208                  OS_EXIT_CRITICAL();
   \   00000024   0700B0E1           MOVS     R0,R7
   \   00000028   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    209                  return (0);
   \   0000002C   0000A0E3           MOV      R0,#+0
   \   00000030   180000EA           B        ??OSMemNameGet_1
    210              }
    211              if (pmem == (OS_MEM *)0) {                   /* Is 'pmem' a NULL pointer?                          */
   \                     ??OSMemNameGet_0:
   \   00000034   000054E3           CMP      R4,#+0
   \   00000038   0500001A           BNE      ??OSMemNameGet_2
    212                  OS_EXIT_CRITICAL();                      /* Yes                                                */
   \   0000003C   0700B0E1           MOVS     R0,R7
   \   00000040   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
    213                  *err = OS_ERR_MEM_INVALID_PMEM;
   \   00000044   6000A0E3           MOV      R0,#+96
   \   00000048   0000C6E5           STRB     R0,[R6, #+0]
    214                  return (0);
   \   0000004C   0000A0E3           MOV      R0,#+0
   \   00000050   100000EA           B        ??OSMemNameGet_1
    215              }
    216              if (pname == (INT8U *)0) {                   /* Is 'pname' a NULL pointer?                         */
   \                     ??OSMemNameGet_2:
   \   00000054   000055E3           CMP      R5,#+0
   \   00000058   0500001A           BNE      ??OSMemNameGet_3
    217                  OS_EXIT_CRITICAL();                      /* Yes                                                */

⌨️ 快捷键说明

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