📄 os_mem.lst
字号:
\ 00000110 0000A0E3 MOV R0,#+0
\ 00000114 00B0B0E1 MOVS R11,R0
\ ??OSMemCreate_9:
\ 00000118 010055E2 SUBS R0,R5,#+1
\ 0000011C 00005BE1 CMP R11,R0
\ 00000120 0400002A BCS ??OSMemCreate_10
109 *plink = (void *)pblk; /* Save pointer to NEXT block in CURRENT block */
\ 00000124 00908AE5 STR R9,[R10, #+0]
110 plink = (void **)pblk; /* Position to NEXT block */
\ 00000128 09A0B0E1 MOVS R10,R9
111 pblk = (INT8U *)((INT32U)pblk + blksize); /* Point to the FOLLOWING block */
\ 0000012C 099096E0 ADDS R9,R6,R9
112 }
\ 00000130 01B09BE2 ADDS R11,R11,#+1
\ 00000134 F7FFFFEA B ??OSMemCreate_9
113 *plink = (void *)0; /* Last memory block points to NULL */
\ ??OSMemCreate_10:
\ 00000138 0000A0E3 MOV R0,#+0
\ 0000013C 00008AE5 STR R0,[R10, #+0]
114 pmem->OSMemAddr = addr; /* Store start address of memory partition */
\ 00000140 004088E5 STR R4,[R8, #+0]
115 pmem->OSMemFreeList = addr; /* Initialize pointer to pool of free blocks */
\ 00000144 044088E5 STR R4,[R8, #+4]
116 pmem->OSMemNFree = nblks; /* Store number of free blocks in MCB */
\ 00000148 105088E5 STR R5,[R8, #+16]
117 pmem->OSMemNBlks = nblks;
\ 0000014C 0C5088E5 STR R5,[R8, #+12]
118 pmem->OSMemBlkSize = blksize; /* Store block size of each memory blocks */
\ 00000150 086088E5 STR R6,[R8, #+8]
119 *err = OS_ERR_NONE;
\ 00000154 0000A0E3 MOV R0,#+0
\ 00000158 0000C7E5 STRB R0,[R7, #+0]
120 return (pmem);
\ 0000015C 0800B0E1 MOVS R0,R8
\ ??OSMemCreate_1:
\ 00000160 04D08DE2 ADD SP,SP,#+4 ;; stack cleaning
\ 00000164 F08FBDE8 POP {R4-R11,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 F0402DE9 PUSH {R4-R7,LR}
\ 00000004 0040B0E1 MOVS R4,R0
\ 00000008 0150B0E1 MOVS R5,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
\ 00000010 0070B0E1 MOVS R7,R0
148 #endif
149
150
151
152 #if OS_ARG_CHK_EN > 0
153 if (err == (INT8U *)0) { /* Validate 'err' */
\ 00000014 000055E3 CMP R5,#+0
\ 00000018 0100001A BNE ??OSMemGet_0
154 return ((void *)0);
\ 0000001C 0000A0E3 MOV R0,#+0
\ 00000020 1C0000EA B ??OSMemGet_1
155 }
156 if (pmem == (OS_MEM *)0) { /* Must point to a valid memory partition */
\ ??OSMemGet_0:
\ 00000024 000054E3 CMP R4,#+0
\ 00000028 0300001A BNE ??OSMemGet_2
157 *err = OS_ERR_MEM_INVALID_PMEM;
\ 0000002C 6000A0E3 MOV R0,#+96
\ 00000030 0000C5E5 STRB R0,[R5, #+0]
158 return ((void *)0);
\ 00000034 0000A0E3 MOV R0,#+0
\ 00000038 160000EA B ??OSMemGet_1
159 }
160 #endif
161 OS_ENTER_CRITICAL();
\ ??OSMemGet_2:
\ 0000003C ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 00000040 0070B0E1 MOVS R7,R0
162 if (pmem->OSMemNFree > 0) { /* See if there are any free memory blocks */
\ 00000044 100094E5 LDR R0,[R4, #+16]
\ 00000048 000050E3 CMP R0,#+0
\ 0000004C 0C00000A BEQ ??OSMemGet_3
163 pblk = pmem->OSMemFreeList; /* Yes, point to next free memory block */
\ 00000050 040094E5 LDR R0,[R4, #+4]
\ 00000054 0060B0E1 MOVS R6,R0
164 pmem->OSMemFreeList = *(void **)pblk; /* Adjust pointer to new free list */
\ 00000058 000096E5 LDR R0,[R6, #+0]
\ 0000005C 040084E5 STR R0,[R4, #+4]
165 pmem->OSMemNFree--; /* One less memory block in this partition */
\ 00000060 100094E5 LDR R0,[R4, #+16]
\ 00000064 010050E2 SUBS R0,R0,#+1
\ 00000068 100084E5 STR R0,[R4, #+16]
166 OS_EXIT_CRITICAL();
\ 0000006C 0700B0E1 MOVS R0,R7
\ 00000070 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
167 *err = OS_ERR_NONE; /* No error */
\ 00000074 0000A0E3 MOV R0,#+0
\ 00000078 0000C5E5 STRB R0,[R5, #+0]
168 return (pblk); /* Return memory block to caller */
\ 0000007C 0600B0E1 MOVS R0,R6
\ 00000080 040000EA B ??OSMemGet_1
169 }
170 OS_EXIT_CRITICAL();
\ ??OSMemGet_3:
\ 00000084 0700B0E1 MOVS R0,R7
\ 00000088 ........ _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 */
\ 0000008C 5D00A0E3 MOV R0,#+93
\ 00000090 0000C5E5 STRB R0,[R5, #+0]
172 return ((void *)0); /* Return NULL pointer to caller */
\ 00000094 0000A0E3 MOV R0,#+0
\ ??OSMemGet_1:
\ 00000098 F080BDE8 POP {R4-R7,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 F0412DE9 PUSH {R4-R8,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 0000A0E3 MOV R0,#+0
\ 00000014 0080B0E1 MOVS R8,R0
201 #endif
202
203
204
205 OS_ENTER_CRITICAL();
\ 00000018 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 0000001C 0080B0E1 MOVS R8,R0
206 #if OS_ARG_CHK_EN > 0
207 if (err == (INT8U *)0) { /* Validate 'err' */
\ 00000020 000056E3 CMP R6,#+0
\ 00000024 0300001A BNE ??OSMemNameGet_0
208 OS_EXIT_CRITICAL();
\ 00000028 0800B0E1 MOVS R0,R8
\ 0000002C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
209 return (0);
\ 00000030 0000A0E3 MOV R0,#+0
\ 00000034 180000EA B ??OSMemNameGet_1
210 }
211 if (pmem == (OS_MEM *)0) { /* Is 'pmem' a NULL pointer? */
\ ??OSMemNameGet_0:
\ 00000038 000054E3 CMP R4,#+0
\ 0000003C 0500001A BNE ??OSMemNameGet_2
212 OS_EXIT_CRITICAL(); /* Yes */
\ 00000040 0800B0E1 MOVS R0,R8
\ 00000044 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
213 *err = OS_ERR_MEM_INVALID_PMEM;
\ 00000048 6000A0E3 MOV R0,#+96
\ 0000004C 0000C6E5 STRB R0,[R6, #+0]
214 return (0);
\ 00000050 0000A0E3 MOV R0,#+0
\ 00000054 100000EA B ??OSMemNameGet_1
215 }
216 if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer? */
\ ??OSMemNameGet_2:
\ 00000058 000055E3 CMP R5,#+0
\ 0000005C 0500001A BNE ??OSMemNameGet_3
217 OS_EXIT_CRITICAL(); /* Yes */
\ 00000060 0800B0E1 MOVS R0,R8
\ 00000064 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
218 *err = OS_ERR_PNAME_NULL;
\ 00000068 0C00A0E3 MOV R0,#+12
\ 0000006C 0000C6E5 STRB R0,[R6, #+0]
219 return (0);
\ 00000070 0000A0E3 MOV R0,#+0
\ 00000074 080000EA B ??OSMemNameGet_1
220 }
221 #endif
222 len = OS_StrCopy(pname, pmem->OSMemName); /* Copy name from OS_MEM */
\ ??OSMemNameGet_3:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -