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

📄 os_mem.lst

📁 ARM仿真案例
💻 LST
📖 第 1 页 / 共 3 页
字号:
##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.40A/W32 EVALUATION    21/Jul/2006  16:27:52 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
# Time limited license: 22 days left                                         #
#                                                                            #
#    Cpu mode        =  interwork                                            #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  E:\Project\ucos-ii\spi\uCOS-II\os_mem.c              #
#    Command line    =  E:\Project\ucos-ii\spi\uCOS-II\os_mem.c -lCN         #
#                       E:\Project\ucos-ii\spi\Debug\List\ -lA               #
#                       E:\Project\ucos-ii\spi\Debug\List\ -o                #
#                       E:\Project\ucos-ii\spi\Debug\Obj\ -s9 --no_cse       #
#                       --no_unroll --no_inline --no_code_motion --no_tbaa   #
#                       --no_clustering --no_scheduling --debug --cpu_mode   #
#                       thumb --endian little --cpu ARM7TDMI-S               #
#                       --stack_align 4 --interwork -e --fpu None            #
#                       --dlib_config "e:\Program Files\IAR                  #
#                       Systems\Embedded Workbench 4.0                       #
#                       Evaluation\ARM\LIB\dl4tptinl8n.h" -I                 #
#                       E:\Project\ucos-ii\spi\ -I                           #
#                       E:\Project\ucos-ii\spi\App\ -I                       #
#                       E:\Project\ucos-ii\spi\ARM\ -I                       #
#                       E:\Project\ucos-ii\spi\BSP\ -I                       #
#                       E:\Project\ucos-ii\spi\uCOS-II\ -I "e:\Program       #
#                       Files\IAR Systems\Embedded Workbench 4.0             #
#                       Evaluation\ARM\INC\"                                 #
#    List file       =  E:\Project\ucos-ii\spi\Debug\List\os_mem.lst         #
#    Object file     =  E:\Project\ucos-ii\spi\Debug\Obj\os_mem.r79          #
#                                                                            #
#                                                                            #
##############################################################################

E:\Project\ucos-ii\spi\uCOS-II\os_mem.c
      1          /*
      2          *********************************************************************************************************
      3          *                                                uC/OS-II
      4          *                                          The Real-Time Kernel
      5          *                                            MEMORY MANAGEMENT
      6          *
      7          *                          (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
      8          *                                           All Rights Reserved
      9          *
     10          * File : OS_MEM.C
     11          * By   : Jean J. Labrosse
     12          *********************************************************************************************************
     13          */
     14          
     15          #ifndef  OS_MASTER_FILE
     16          #include <ucos_ii.h>
     17          #endif
     18          
     19          #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
     20          /*
     21          *********************************************************************************************************
     22          *                                        CREATE A MEMORY PARTITION
     23          *
     24          * Description : Create a fixed-sized memory partition that will be managed by uC/OS-II.
     25          *
     26          * Arguments   : addr     is the starting address of the memory partition
     27          *
     28          *               nblks    is the number of memory blocks to create from the partition.
     29          *
     30          *               blksize  is the size (in bytes) of each block in the memory partition.
     31          *
     32          *               err      is a pointer to a variable containing an error message which will be set by
     33          *                        this function to either:
     34          *
     35          *                        OS_NO_ERR            if the memory partition has been created correctly.
     36          *                        OS_MEM_INVALID_ADDR  you are specifying an invalid address for the memory 
     37          *                                             storage of the partition.
     38          *                        OS_MEM_INVALID_PART  no free partitions available
     39          *                        OS_MEM_INVALID_BLKS  user specified an invalid number of blocks (must be >= 2)
     40          *                        OS_MEM_INVALID_SIZE  user specified an invalid block size
     41          *                                             (must be greater than the size of a pointer)
     42          * Returns    : != (OS_MEM *)0  is the partition was created
     43          *              == (OS_MEM *)0  if the partition was not created because of invalid arguments or, no
     44          *                              free partition is available.
     45          *********************************************************************************************************
     46          */
     47          

   \                                 In segment CODE, align 4, keep-with-next
     48          OS_MEM  *OSMemCreate (void *addr, INT32U nblks, INT32U blksize, INT8U *err)
     49          {
   \                     OSMemCreate:
   \   00000000   F1B5               PUSH     {R0,R4-R7,LR}
   \   00000002   0C00               MOVS     R4,R1
   \   00000004   1500               MOVS     R5,R2
   \   00000006   1E00               MOVS     R6,R3
     50          #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
     51              OS_CPU_SR  cpu_sr;
     52          #endif    
     53              OS_MEM    *pmem;
     54              INT8U     *pblk;
     55              void     **plink;
     56              INT32U     i;
     57          
     58          
     59          #if OS_ARG_CHK_EN > 0
     60              if (addr == (void *)0) {                          /* Must pass a valid address for the memory part. */
   \   00000008   0028               CMP      R0,#+0
   \   0000000A   03D1               BNE      ??OSMemCreate_0
     61                  *err = OS_MEM_INVALID_ADDR;
   \   0000000C   7620               MOVS     R0,#+118
   \                     ??OSMemCreate_1:
   \   0000000E   3070               STRB     R0,[R6, #+0]
     62                  return ((OS_MEM *)0);
   \   00000010   0020               MOVS     R0,#+0
   \   00000012   2BE0               B        ??OSMemCreate_2
     63              }
     64              if (nblks < 2) {                                  /* Must have at least 2 blocks per partition      */
   \                     ??OSMemCreate_0:
   \   00000014   022C               CMP      R4,#+2
   \   00000016   01D2               BCS      ??OSMemCreate_3
     65                  *err = OS_MEM_INVALID_BLKS;
   \   00000018   6F20               MOVS     R0,#+111
   \   0000001A   F8E7               B.N      ??OSMemCreate_1
     66                  return ((OS_MEM *)0);
     67              }
     68              if (blksize < sizeof(void *)) {                   /* Must contain space for at least a pointer      */
   \                     ??OSMemCreate_3:
   \   0000001C   042D               CMP      R5,#+4
   \   0000001E   03D2               BCS      ??OSMemCreate_4
     69                  *err = OS_MEM_INVALID_SIZE;
   \   00000020   7020               MOVS     R0,#+112
   \   00000022   3070               STRB     R0,[R6, #+0]
     70                  return ((OS_MEM *)0);
   \   00000024   0020               MOVS     R0,#+0
   \   00000026   21E0               B        ??OSMemCreate_2
     71              }
     72          #endif
     73              OS_ENTER_CRITICAL();
   \                     ??OSMemCreate_4:
   \   00000028   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
     74              pmem = OSMemFreeList;                             /* Get next free memory partition                */
   \   0000002C   ....               LDR      R1,??DataTable1  ;; OSMemFreeList
   \   0000002E   0F68               LDR      R7,[R1, #+0]
     75              if (OSMemFreeList != (OS_MEM *)0) {               /* See if pool of free partitions was empty      */
   \   00000030   002F               CMP      R7,#+0
   \   00000032   01D0               BEQ      ??OSMemCreate_5
     76                  OSMemFreeList = (OS_MEM *)OSMemFreeList->OSMemFreeList;
   \   00000034   7A68               LDR      R2,[R7, #+4]
   \   00000036   0A60               STR      R2,[R1, #+0]
     77              }
     78              OS_EXIT_CRITICAL();
   \                     ??OSMemCreate_5:
   \   00000038   ........           _BLF     OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
     79              if (pmem == (OS_MEM *)0) {                        /* See if we have a memory partition             */
   \   0000003C   002F               CMP      R7,#+0
   \   0000003E   01D1               BNE      ??OSMemCreate_6
     80                  *err = OS_MEM_INVALID_PART;
   \   00000040   6E20               MOVS     R0,#+110
   \   00000042   E4E7               B.N      ??OSMemCreate_1
     81                  return ((OS_MEM *)0);
     82              }
     83              plink = (void **)addr;                            /* Create linked list of free memory blocks      */
   \                     ??OSMemCreate_6:
   \   00000044   0098               LDR      R0,[SP, #+0]
     84              pblk  = (INT8U *)((INT32U)addr + blksize);
   \   00000046   4119               ADDS     R1,R0,R5
     85              for (i = 0; i < (nblks - 1); i++) {
   \   00000048   621E               SUBS     R2,R4,#+1
   \   0000004A   04D0               BEQ      ??OSMemCreate_7
     86                 *plink = (void *)pblk;
   \                     ??OSMemCreate_8:
   \   0000004C   0160               STR      R1,[R0, #+0]
     87                  plink = *plink;
   \   0000004E   0800               MOVS     R0,R1
     88                  pblk  = (INT8U *)((INT32U)pblk + blksize);
   \   00000050   4919               ADDS     R1,R1,R5
     89              }
   \   00000052   521E               SUBS     R2,R2,#+1
   \   00000054   FAD1               BNE      ??OSMemCreate_8
     90              *plink              = (void *)0;                  /* Last memory block points to NULL              */
   \                     ??OSMemCreate_7:
   \   00000056   0021               MOVS     R1,#+0
   \   00000058   0160               STR      R1,[R0, #+0]
     91              pmem->OSMemAddr     = addr;                       /* Store start address of memory partition       */
   \   0000005A   0098               LDR      R0,[SP, #+0]
   \   0000005C   3860               STR      R0,[R7, #+0]
     92              pmem->OSMemFreeList = addr;                       /* Initialize pointer to pool of free blocks     */
   \   0000005E   0098               LDR      R0,[SP, #+0]
   \   00000060   7860               STR      R0,[R7, #+4]
     93              pmem->OSMemNFree    = nblks;                      /* Store number of free blocks in MCB            */
   \   00000062   3C61               STR      R4,[R7, #+16]
     94              pmem->OSMemNBlks    = nblks;
   \   00000064   FC60               STR      R4,[R7, #+12]
     95              pmem->OSMemBlkSize  = blksize;                    /* Store block size of each memory blocks        */
   \   00000066   BD60               STR      R5,[R7, #+8]
     96              *err                = OS_NO_ERR;
   \   00000068   3170               STRB     R1,[R6, #+0]
     97              return (pmem);
   \   0000006A   3800               MOVS     R0,R7
   \                     ??OSMemCreate_2:
   \   0000006C   01B0               ADD      SP,SP,#+4
   \   0000006E   F0BC               POP      {R4-R7}
   \   00000070   02BC               POP      {R1}
   \   00000072   0847               BX       R1               ;; return
     98          }
     99          
    100          /*
    101          *********************************************************************************************************
    102          *                                          GET A MEMORY BLOCK
    103          *
    104          * Description : Get a memory block from a partition
    105          *
    106          * Arguments   : pmem    is a pointer to the memory partition control block
    107          *
    108          *               err     is a pointer to a variable containing an error message which will be set by this
    109          *                       function to either:
    110          *
    111          *                       OS_NO_ERR           if the memory partition has been created correctly.
    112          *                       OS_MEM_NO_FREE_BLKS if there are no more free memory blocks to allocate to caller
    113          *                       OS_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
    114          *
    115          * Returns     : A pointer to a memory block if no error is detected
    116          *               A pointer to NULL if an error is detected
    117          *********************************************************************************************************
    118          */
    119          

   \                                 In segment CODE, align 4, keep-with-next
    120          void  *OSMemGet (OS_MEM *pmem, INT8U *err)
    121          {
   \                     OSMemGet:
   \   00000000   70B5               PUSH     {R4-R6,LR}
   \   00000002   0500               MOVS     R5,R0
   \   00000004   0C00               MOVS     R4,R1
    122          #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
    123              OS_CPU_SR  cpu_sr;
    124          #endif    
    125              void      *pblk;
    126          
    127          
    128          #if OS_ARG_CHK_EN > 0
    129              if (pmem == (OS_MEM *)0) {                        /* Must point to a valid memory partition         */
   \   00000006   002D               CMP      R5,#+0
   \   00000008   01D1               BNE      ??OSMemGet_0
    130                  *err = OS_MEM_INVALID_PMEM;
   \   0000000A   7420               MOVS     R0,#+116
   \   0000000C   13E0               B.N      ??OSMemGet_1
    131                  return ((OS_MEM *)0);
    132              }
    133          #endif
    134              OS_ENTER_CRITICAL();
   \                     ??OSMemGet_0:
   \   0000000E   ........           _BLF     OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
    135              if (pmem->OSMemNFree > 0) {                       /* See if there are any free memory blocks       */
   \   00000012   2969               LDR      R1,[R5, #+16]
   \   00000014   0029               CMP      R1,#+0
   \   00000016   0BD0               BEQ      ??OSMemGet_2
    136                  pblk                = pmem->OSMemFreeList;    /* Yes, point to next free memory block          */

⌨️ 快捷键说明

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