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

📄 os_mem.lst

📁 编译环境是 iar EWARM ,STM32 下的UCOSII
💻 LST
📖 第 1 页 / 共 3 页
字号:
##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.42A/W32 KICKSTART     26/Dec/2008  18:22:03 #
# Copyright 1999-2005 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  thumb                                                #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  F:\PROJECT\STM32_UCOSII\uCOS-II\Source\os_mem.c      #
#    Command line    =  F:\PROJECT\STM32_UCOSII\uCOS-II\Source\os_mem.c      #
#                       -lCN F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E- #
#                       EVAL\IAR\OS-Probe\Flash\List\ -o                     #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\Flash\Obj\ -z6 --no_unroll --no_inline  #
#                       --no_tbaa --no_scheduling --debug --cpu_mode thumb   #
#                       --endian little --cpu cortex-M3 --stack_align 4 -e   #
#                       --fpu None --dlib_config "E:\Program Files\IAR       #
#                       Systems\Embedded Workbench 4.0                       #
#                       Kickstart\arm\LIB\dl7mptnnl8n.h" -I                  #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\ -I F:\PROJECT\STM32_UCOSII\EvalBoards\ #
#                       ST\STM3210E-EVAL\IAR\OS-Probe\..\BSP\ -I             #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\CPU\ST\STM32\inc\ -I     #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-CPU\ -I               #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-CPU\ARM-Cortex-M3\IAR #
#                       \ -I F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E- #
#                       EVAL\IAR\OS-Probe\..\..\..\..\..\uC-LCD\Source\ -I   #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-LIB\ -I               #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uCOS-II\Ports\ARM-Cortex #
#                       -M3\Generic\IAR\ -I F:\PROJECT\STM32_UCOSII\EvalBoar #
#                       ds\ST\STM3210E-EVAL\IAR\OS-Probe\..\..\..\..\..\uCOS #
#                       -II\Source\ -I F:\PROJECT\STM32_UCOSII\EvalBoards\ST #
#                       \STM3210E-EVAL\IAR\OS-Probe\..\..\..\..\..\uC-Probe\ #
#                       Target\Communication\Generic\RS-232\Source\ -I       #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-Probe\Target\Communic #
#                       ation\Generic\RS-232\Ports\ST\STM32\ -I              #
#                       F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\..\..\..\..\..\uC-Probe\Target\Communic #
#                       ation\Generic\Source\ -I F:\PROJECT\STM32_UCOSII\Eva #
#                       lBoards\ST\STM3210E-EVAL\IAR\OS-Probe\..\..\..\..\.. #
#                       \uC-Probe\Target\Plugins\uCOS-II\ -I "E:\Program     #
#                       Files\IAR Systems\Embedded Workbench 4.0             #
#                       Kickstart\arm\INC\"                                  #
#    List file       =  F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\Flash\List\os_mem.lst                   #
#    Object file     =  F:\PROJECT\STM32_UCOSII\EvalBoards\ST\STM3210E-EVAL\ #
#                       IAR\OS-Probe\Flash\Obj\os_mem.r79                    #
#                                                                            #
#                                                                            #
##############################################################################

F:\PROJECT\STM32_UCOSII\uCOS-II\Source\os_mem.c
      1          /*
      2          *********************************************************************************************************
      3          *                                                uC/OS-II
      4          *                                          The Real-Time Kernel
      5          *                                            MEMORY MANAGEMENT
      6          *
      7          *                              (c) Copyright 1992-2007, Micrium, Weston, FL
      8          *                                           All Rights Reserved
      9          *
     10          * File    : OS_MEM.C
     11          * By      : Jean J. Labrosse
     12          * Version : V2.86
     13          *
     14          * LICENSING TERMS:
     15          * ---------------
     16          *   uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research.  
     17          * If you plan on using  uC/OS-II  in a commercial product you need to contact Micri祄 to properly license 
     18          * its use in your product. We provide ALL the source code for your convenience and to help you experience 
     19          * uC/OS-II.   The fact that the  source is provided does  NOT  mean that you can use it without  paying a 
     20          * licensing fee.
     21          *********************************************************************************************************
     22          */
     23          
     24          #ifndef  OS_MASTER_FILE
     25          #include <ucos_ii.h>
     26          #endif
     27          
     28          #if (OS_MEM_EN > 0) && (OS_MAX_MEM_PART > 0)
     29          /*
     30          *********************************************************************************************************
     31          *                                        CREATE A MEMORY PARTITION
     32          *
     33          * Description : Create a fixed-sized memory partition that will be managed by uC/OS-II.
     34          *
     35          * Arguments   : addr     is the starting address of the memory partition
     36          *
     37          *               nblks    is the number of memory blocks to create from the partition.
     38          *
     39          *               blksize  is the size (in bytes) of each block in the memory partition.
     40          *
     41          *               perr     is a pointer to a variable containing an error message which will be set by
     42          *                        this function to either:
     43          *
     44          *                        OS_ERR_NONE              if the memory partition has been created correctly.
     45          *                        OS_ERR_MEM_INVALID_ADDR  if you are specifying an invalid address for the memory
     46          *                                                 storage of the partition or, the block does not align
     47          *                                                 on a pointer boundary
     48          *                        OS_ERR_MEM_INVALID_PART  no free partitions available
     49          *                        OS_ERR_MEM_INVALID_BLKS  user specified an invalid number of blocks (must be >= 2)
     50          *                        OS_ERR_MEM_INVALID_SIZE  user specified an invalid block size
     51          *                                                   - must be greater than the size of a pointer
     52          *                                                   - must be able to hold an integral number of pointers
     53          * Returns    : != (OS_MEM *)0  is the partition was created
     54          *              == (OS_MEM *)0  if the partition was not created because of invalid arguments or, no
     55          *                              free partition is available.
     56          *********************************************************************************************************
     57          */
     58          
     59          OS_MEM  *OSMemCreate (void *addr, INT32U nblks, INT32U blksize, INT8U *perr)
     60          {
     61              OS_MEM    *pmem;
     62              INT8U     *pblk;
     63              void     **plink;
     64              INT32U     i;
     65          #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register      */
     66              OS_CPU_SR  cpu_sr = 0;
     67          #endif
     68          
     69          
     70          
     71          #if OS_ARG_CHK_EN > 0              
     72              if (perr == (INT8U *)0) {                         /* Validate 'perr'                               */
     73                  return ((OS_MEM *)0);
     74              }
     75              if (addr == (void *)0) {                          /* Must pass a valid address for the memory part.*/
     76                  *perr = OS_ERR_MEM_INVALID_ADDR;
     77                  return ((OS_MEM *)0);
     78              }
     79              if (((INT32U)addr & (sizeof(void *) - 1)) != 0){  /* Must be pointer size aligned                  */
     80                  *perr = OS_ERR_MEM_INVALID_ADDR;
     81                  return ((OS_MEM *)0);
     82              }
     83              if (nblks < 2) {                                  /* Must have at least 2 blocks per partition     */
     84                  *perr = OS_ERR_MEM_INVALID_BLKS;
     85                  return ((OS_MEM *)0);
     86              }
     87              if (blksize < sizeof(void *)) {                   /* Must contain space for at least a pointer     */
     88                  *perr = OS_ERR_MEM_INVALID_SIZE;
     89                  return ((OS_MEM *)0);
     90              }
     91          #endif
     92              OS_ENTER_CRITICAL();
     93              pmem = OSMemFreeList;                             /* Get next free memory partition                */
     94              if (OSMemFreeList != (OS_MEM *)0) {               /* See if pool of free partitions was empty      */
     95                  OSMemFreeList = (OS_MEM *)OSMemFreeList->OSMemFreeList;
     96              }
     97              OS_EXIT_CRITICAL();
     98              if (pmem == (OS_MEM *)0) {                        /* See if we have a memory partition             */
     99                  *perr = OS_ERR_MEM_INVALID_PART;
    100                  return ((OS_MEM *)0);
    101              }
    102              plink = (void **)addr;                            /* Create linked list of free memory blocks      */
    103              pblk  = (INT8U *)((INT32U)addr + blksize);
    104              for (i = 0; i < (nblks - 1); i++) {
    105                 *plink = (void *)pblk;                         /* Save pointer to NEXT block in CURRENT block   */
    106                  plink = (void **)pblk;                        /* Position to  NEXT      block                  */
    107                  pblk  = (INT8U *)((INT32U)pblk + blksize);    /* Point to the FOLLOWING block                  */
    108              }
    109              *plink              = (void *)0;                  /* Last memory block points to NULL              */
    110              pmem->OSMemAddr     = addr;                       /* Store start address of memory partition       */
    111              pmem->OSMemFreeList = addr;                       /* Initialize pointer to pool of free blocks     */

⌨️ 快捷键说明

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