📄 os_mem.lst
字号:
104 for (i = 0; i < (nblks - 1); i++) {
\ 0000005C 0022 MOVS R2,#+0
\ 0000005E 1300 MOVS R3,R2
\ 00000060 04E0 B.N ??OSMemCreate_9
105 *plink = (void *)pblk; /* Save pointer to NEXT block in CURRENT block */
\ ??OSMemCreate_10:
\ 00000062 0160 STR R1,[R0, #+0]
106 plink = (void **)pblk; /* Position to NEXT block */
\ 00000064 0800 MOVS R0,R1
107 pblk = (INT8U *)((INT32U)pblk + blksize); /* Point to the FOLLOWING block */
\ 00000066 19EB0101 ADDS R1,R9,R1
108 }
\ 0000006A 5B1C ADDS R3,R3,#+1
\ ??OSMemCreate_9:
\ 0000006C 4746 MOV R7,R8
\ 0000006E 7F1E SUBS R7,R7,#+1
\ 00000070 BB42 CMP R3,R7
\ 00000072 F6D3 BCC.N ??OSMemCreate_10
109 *plink = (void *)0; /* Last memory block points to NULL */
\ 00000074 0260 STR R2,[R0, #+0]
110 pmem->OSMemAddr = addr; /* Store start address of memory partition */
\ 00000076 3460 STR R4,[R6, #+0]
111 pmem->OSMemFreeList = addr; /* Initialize pointer to pool of free blocks */
\ 00000078 7460 STR R4,[R6, #+4]
112 pmem->OSMemNFree = nblks; /* Store number of free blocks in MCB */
\ 0000007A C6F81080 STR R8,[R6, #+16]
113 pmem->OSMemNBlks = nblks;
\ 0000007E C6F80C80 STR R8,[R6, #+12]
114 pmem->OSMemBlkSize = blksize; /* Store block size of each memory blocks */
\ 00000082 C6F80890 STR R9,[R6, #+8]
115 *perr = OS_ERR_NONE;
\ 00000086 2A70 STRB R2,[R5, #+0]
116 return (pmem);
\ 00000088 3000 MOVS R0,R6
\ ??OSMemCreate_2:
\ 0000008A BDE8F083 POP {R4-R9,PC} ;; return
117 }
118 /*$PAGE*/
119 /*
120 *********************************************************************************************************
121 * GET A MEMORY BLOCK
122 *
123 * Description : Get a memory block from a partition
124 *
125 * Arguments : pmem is a pointer to the memory partition control block
126 *
127 * perr is a pointer to a variable containing an error message which will be set by this
128 * function to either:
129 *
130 * OS_ERR_NONE if the memory partition has been created correctly.
131 * OS_ERR_MEM_NO_FREE_BLKS if there are no more free memory blocks to allocate to caller
132 * OS_ERR_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
133 *
134 * Returns : A pointer to a memory block if no error is detected
135 * A pointer to NULL if an error is detected
136 *********************************************************************************************************
137 */
138
\ In segment CODE, align 4, keep-with-next
139 void *OSMemGet (OS_MEM *pmem, INT8U *perr)
140 {
\ OSMemGet:
\ 00000000 70B5 PUSH {R4-R6,LR}
\ 00000002 0500 MOVS R5,R0
\ 00000004 0C00 MOVS R4,R1
141 void *pblk;
142 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
143 OS_CPU_SR cpu_sr = 0;
144 #endif
145
146
147
148 #if OS_ARG_CHK_EN > 0
149 if (perr == (INT8U *)0) { /* Validate 'perr' */
\ 00000006 01D1 BNE.N ??OSMemGet_0
150 return ((void *)0);
\ 00000008 0020 MOVS R0,#+0
\ 0000000A 70BD POP {R4-R6,PC}
151 }
152 if (pmem == (OS_MEM *)0) { /* Must point to a valid memory partition */
\ ??OSMemGet_0:
\ 0000000C 002D CMP R5,#+0
\ 0000000E 03D1 BNE.N ??OSMemGet_1
153 *perr = OS_ERR_MEM_INVALID_PMEM;
\ 00000010 6020 MOVS R0,#+96
\ 00000012 2070 STRB R0,[R4, #+0]
154 return ((void *)0);
\ 00000014 0020 MOVS R0,#+0
\ 00000016 70BD POP {R4-R6,PC}
155 }
156 #endif
157 OS_ENTER_CRITICAL();
\ ??OSMemGet_1:
\ 00000018 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
158 if (pmem->OSMemNFree > 0) { /* See if there are any free memory blocks */
\ 0000001C 2969 LDR R1,[R5, #+16]
\ 0000001E 0029 CMP R1,#+0
\ 00000020 0BD0 BEQ.N ??OSMemGet_2
159 pblk = pmem->OSMemFreeList; /* Yes, point to next free memory block */
\ 00000022 6E68 LDR R6,[R5, #+4]
160 pmem->OSMemFreeList = *(void **)pblk; /* Adjust pointer to new free list */
\ 00000024 3168 LDR R1,[R6, #+0]
\ 00000026 6960 STR R1,[R5, #+4]
161 pmem->OSMemNFree--; /* One less memory block in this partition */
\ 00000028 2969 LDR R1,[R5, #+16]
\ 0000002A 491E SUBS R1,R1,#+1
\ 0000002C 2961 STR R1,[R5, #+16]
162 OS_EXIT_CRITICAL();
\ 0000002E ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
163 *perr = OS_ERR_NONE; /* No error */
\ 00000032 0020 MOVS R0,#+0
\ 00000034 2070 STRB R0,[R4, #+0]
164 return (pblk); /* Return memory block to caller */
\ 00000036 3000 MOVS R0,R6
\ 00000038 70BD POP {R4-R6,PC}
165 }
166 OS_EXIT_CRITICAL();
\ ??OSMemGet_2:
\ 0000003A ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
167 *perr = OS_ERR_MEM_NO_FREE_BLKS; /* No, Notify caller of empty memory partition */
\ 0000003E 5D20 MOVS R0,#+93
\ 00000040 2070 STRB R0,[R4, #+0]
168 return ((void *)0); /* Return NULL pointer to caller */
\ 00000042 0020 MOVS R0,#+0
\ 00000044 70BD POP {R4-R6,PC} ;; return
169 }
170 /*$PAGE*/
171 /*
172 *********************************************************************************************************
173 * GET THE NAME OF A MEMORY PARTITION
174 *
175 * Description: This function is used to obtain the name assigned to a memory partition.
176 *
177 * Arguments : pmem is a pointer to the memory partition
178 *
179 * pname is a pointer to an ASCII string that will receive the name of the memory partition.
180 *
181 * perr is a pointer to an error code that can contain one of the following values:
182 *
183 * OS_ERR_NONE if the name was copied to 'pname'
184 * OS_ERR_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
185 * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
186 * OS_ERR_NAME_GET_ISR You called this function from an ISR
187 *
188 * Returns : The length of the string or 0 if 'pmem' is a NULL pointer.
189 *********************************************************************************************************
190 */
191
192 #if OS_MEM_NAME_SIZE > 1
\ In segment CODE, align 4, keep-with-next
193 INT8U OSMemNameGet (OS_MEM *pmem, INT8U *pname, INT8U *perr)
194 {
\ OSMemNameGet:
\ 00000000 F0B5 PUSH {R4-R7,LR}
\ 00000002 0600 MOVS R6,R0
\ 00000004 0F00 MOVS R7,R1
\ 00000006 1400 MOVS R4,R2
195 INT8U len;
196 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
197 OS_CPU_SR cpu_sr = 0;
198 #endif
199
200
201
202 #if OS_ARG_CHK_EN > 0
203 if (perr == (INT8U *)0) { /* Validate 'perr' */
\ 00000008 01D1 BNE.N ??OSMemNameGet_0
204 return (0);
\ 0000000A 0020 MOVS R0,#+0
\ 0000000C F0BD POP {R4-R7,PC}
205 }
206 if (pmem == (OS_MEM *)0) { /* Is 'pmem' a NULL pointer? */
\ ??OSMemNameGet_0:
\ 0000000E 002E CMP R6,#+0
\ 00000010 03D1 BNE.N ??OSMemNameGet_1
207 *perr = OS_ERR_MEM_INVALID_PMEM;
\ 00000012 6020 MOVS R0,#+96
\ 00000014 2070 STRB R0,[R4, #+0]
208 return (0);
\ 00000016 0020 MOVS R0,#+0
\ 00000018 F0BD POP {R4-R7,PC}
209 }
210 if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer? */
\ ??OSMemNameGet_1:
\ 0000001A 002F CMP R7,#+0
\ 0000001C 03D1 BNE.N ??OSMemNameGet_2
211 *perr = OS_ERR_PNAME_NULL;
\ 0000001E 0C20 MOVS R0,#+12
\ 00000020 2070 STRB R0,[R4, #+0]
212 return (0);
\ 00000022 0020 MOVS R0,#+0
\ 00000024 F0BD POP {R4-R7,PC}
213 }
214 #endif
215 if (OSIntNesting > 0) { /* See if trying to call from an ISR */
\ ??OSMemNameGet_2:
\ 00000026 .... LDR.N R0,??DataTable2 ;; OSIntNesting
\ 00000028 0078 LDRB R0,[R0, #+0]
\ 0000002A 0028 CMP R0,#+0
\ 0000002C 03D0 BEQ.N ??OSMemNameGet_3
216 *perr = OS_ERR_NAME_GET_ISR;
\ 0000002E 1120 MOVS R0,#+17
\ 00000030 2070 STRB R0,[R4, #+0]
217 return (0);
\ 00000032 0020 MOVS R0,#+0
\ 00000034 F0BD POP {R4-R7,PC}
218 }
219 OS_ENTER_CRITICAL();
\ ??OSMemNameGet_3:
\ 00000036 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 0000003A 0500 MOVS R5,R0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -