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

📄 os_mem.lst

📁 ucos2.52在msp430上移植
💻 LST
📖 第 1 页 / 共 4 页
字号:
   \   00CE  844E0800          MOV     R14,8(R4)       
   \   00D2  844F0A00          MOV     R15,10(R4)      
     95              pmem->OSMemBlkSize  = blksize;                    /* Store block size of each memory blocks        */
   \   00D6  84480400          MOV     R8,4(R4)        
   \   00DA  84490600          MOV     R9,6(R4)        
     96              *err                = OS_NO_ERR;
   \   00DE  CB430000          MOV.B   #0,0(R11)       
     97              return (pmem);
   \   00E2  0C44              MOV     R4,R12  
     98          }
   \   00E4            ?0072:
   \   00E4  31500600          ADD     #6,SP   
   \   00E8  3541              POP     R5      
   \   00EA  3441              POP     R4      
   \   00EC  3741              POP     R7      
   \   00EE  3641              POP     R6      
   \   00F0  3941              POP     R9      
   \   00F2  3841              POP     R8      
   \   00F4  3B41              POP     R11     
   \   00F6  3A41              POP     R10     
   \   00F8  3041              RET             
   \   00FA            OSMemGet:
     99          /*$PAGE*/
    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          
    120          void  *OSMemGet (OS_MEM *pmem, INT8U *err)
    121          {
    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         */
   \   00FA  0C93              CMP     #0,R12  
   \   00FC  0420              JNE     (?0074) 
    130                  *err = OS_MEM_INVALID_PMEM;
   \   00FE  FE407400          MOV.B   #116,0(R14)     
   \   0102  0000
    131                  return ((OS_MEM *)0);
    132              }
   \   0104  3041              RET             
   \   0106            ?0074:
    133          #endif
    134              OS_ENTER_CRITICAL();
   \   0106  32C2              DINT            
    135              if (pmem->OSMemNFree > 0) {                       /* See if there are any free memory blocks       */
   \   0108  1D4C0C00          MOV     12(R12),R13     
   \   010C  1DDC0E00          BIS     14(R12),R13     
   \   0110  0D93              CMP     #0,R13  
   \   0112  0D24              JEQ     (?0076) 
    136                  pblk                = pmem->OSMemFreeList;    /* Yes, point to next free memory block          */
   \   0114  1D4C0200          MOV     2(R12),R13      
    137                  pmem->OSMemFreeList = *(void **)pblk;         /*      Adjust pointer to new free list          */
   \   0118  AC4D0200          MOV     @R13,2(R12)     
    138                  pmem->OSMemNFree--;                           /*      One less memory block in this partition  */
   \   011C  BC530C00          ADD     #65535,12(R12)  
   \   0120  BC630E00          ADDC    #-1,14(R12)     
    139                  OS_EXIT_CRITICAL();
   \   0124  32D2              EINT            
    140                  *err = OS_NO_ERR;                             /*      No error                                 */
   \   0126  CE430000          MOV.B   #0,0(R14)       
    141                  return (pblk);                                /*      Return memory block to caller            */
   \   012A  0C4D              MOV     R13,R12 
    142              }
   \   012C  3041              RET             
   \   012E            ?0076:
    143              OS_EXIT_CRITICAL();
   \   012E  32D2              EINT            
    144              *err = OS_MEM_NO_FREE_BLKS;                       /* No,  Notify caller of empty memory partition  */
   \   0130  FE407100          MOV.B   #113,0(R14)     
   \   0134  0000
    145              return ((void *)0);                               /*      Return NULL pointer to caller            */
   \   0136  0C43              MOV     #0,R12  
    146          }
   \   0138  3041              RET             
   \   013A            OSMemPut:
    147          /*$PAGE*/
    148          /*
    149          *********************************************************************************************************
    150          *                                         RELEASE A MEMORY BLOCK
    151          *
    152          * Description : Returns a memory block to a partition
    153          *
    154          * Arguments   : pmem    is a pointer to the memory partition control block
    155          *
    156          *               pblk    is a pointer to the memory block being released.
    157          *
    158          * Returns     : OS_NO_ERR            if the memory block was inserted into the partition
    159          *               OS_MEM_FULL          if you are returning a memory block to an already FULL memory 
    160          *                                    partition (You freed more blocks than you allocated!)
    161          *               OS_MEM_INVALID_PMEM  if you passed a NULL pointer for 'pmem'
    162          *               OS_MEM_INVALID_PBLK  if you passed a NULL pointer for the block to release.
    163          *********************************************************************************************************
    164          */
    165          
    166          INT8U  OSMemPut (OS_MEM  *pmem, void *pblk)
    167          {
   \   013A  0A12              PUSH    R10     
   \   013C  0B12              PUSH    R11     
    168          #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    169              OS_CPU_SR  cpu_sr;
    170          #endif    
    171              
    172              
    173          #if OS_ARG_CHK_EN > 0
    174              if (pmem == (OS_MEM *)0) {                   /* Must point to a valid memory partition             */
   \   013E  0C93              CMP     #0,R12  
   \   0140  0320              JNE     (?0079) 
    175                  return (OS_MEM_INVALID_PMEM);
   \   0142  7C407400          MOV.B   #116,R12        
    176              }
   \   0146  1E3C              JMP     (?0084) 
   \   0148            ?0079:
    177              if (pblk == (void *)0) {                     /* Must release a valid block                         */
   \   0148  0E93              CMP     #0,R14  
   \   014A  0320              JNE     (?0081) 
    178                  return (OS_MEM_INVALID_PBLK);
   \   014C  7C407300          MOV.B   #115,R12        
    179              }
   \   0150  193C              JMP     (?0084) 
   \   0152            ?0081:
    180          #endif
    181              OS_ENTER_CRITICAL();
   \   0152  32C2              DINT            
    182              if (pmem->OSMemNFree >= pmem->OSMemNBlks) {  /* Make sure all blocks not already returned          */
   \   0154  1A4C0C00          MOV     12(R12),R10     
   \   0158  1B4C0E00          MOV     14(R12),R11     
   \   015C  1A8C0800          SUB     8(R12),R10      
   \   0160  1B7C0A00          SUBC    10(R12),R11     
   \   0164  0428              JNC     (?0083) 
    183                  OS_EXIT_CRITICAL();
   \   0166  32D2              EINT            
    184                  return (OS_MEM_FULL);
   \   0168  7C407200          MOV.B   #114,R12        
    185              }
   \   016C  0B3C              JMP     (?0084) 
   \   016E            ?0083:
    186              *(void **)pblk      = pmem->OSMemFreeList;   /* Insert released block into free block list         */
   \   016E  9E4C0200          MOV     2(R12),0(R14)   
   \   0172  0000
    187              pmem->OSMemFreeList = pblk;
   \   0174  8C4E0200          MOV     R14,2(R12)      
    188              pmem->OSMemNFree++;                          /* One more memory block in this partition            */
   \   0178  9C530C00          ADD     #1,12(R12)      
   \   017C  8C630E00          ADDC    #0,14(R12)      
    189              OS_EXIT_CRITICAL();
   \   0180  32D2              EINT            
    190              return (OS_NO_ERR);                          /* Notify caller that memory block was released       */
   \   0182  4C43              MOV.B   #0,R12  
    191          }
   \   0184            ?0084:
   \   0184  3B41              POP     R11     
   \   0186  3A41              POP     R10     
   \   0188  3041              RET             
   \   018A            OSMemQuery:
    192          /*$PAGE*/
    193          /*
    194          *********************************************************************************************************
    195          *                                          QUERY MEMORY PARTITION
    196          *
    197          * Description : This function is used to determine the number of free memory blocks and the number of
    198          *               used memory blocks from a memory partition.
    199          *
    200          * Arguments   : pmem    is a pointer to the memory partition control block
    201          *
    202          *               pdata   is a pointer to a structure that will contain information about the memory
    203          *                       partition.
    204          *
    205          * Returns     : OS_NO_ERR            If no errors were found.
    206          *               OS_MEM_INVALID_PMEM  if you passed a NULL pointer for 'pmem'
    207          *               OS_MEM_INVALID_PDATA if you passed a NULL pointer for the block to release.
    208          *********************************************************************************************************
    209          */
    210          
    211          #if OS_MEM_QUERY_EN > 0
    212          INT8U  OSMemQuery (OS_MEM *pmem, OS_MEM_DATA *pdata)
    213          {
    214          #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    215              OS_CPU_SR  cpu_sr;
    216          #endif    
    217              
    218              
    219          #if OS_ARG_CHK_EN > 0
    220              if (pmem == (OS_MEM *)0) {                   /* Must point to a valid memory partition             */
   \   018A  0C93              CMP     #0,R12  
   \   018C  0320              JNE     (?0086) 
    221                  return (OS_MEM_INVALID_PMEM);
   \   018E  7C407400          MOV.B   #116,R12        
    222              }
   \   0192  3041              RET             
   \   0194            ?0086:
    223              if (pdata == (OS_MEM_DATA *)0) {             /* Must release a valid storage area for the data     */
   \   0194  0E93              CMP     #0,R14  
   \   0196  0320              JNE     (?0088) 
    224                  return (OS_MEM_INVALID_PDATA);
   \   0198  7C407500          MOV.B   #117,R12        
    225              }
   \   019C  3041              RET             
   \   019E            ?0088:
    226          #endif
    227              OS_ENTER_CRITICAL();
   \   019E  32C2              DINT            
    228              pdata->OSAddr     = pmem->OSMemAddr;
   \   01A0  AE4C0000          MOV     @R12,0(R14)     

⌨️ 快捷键说明

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