📄 os_mem.lst
字号:
93 pmem->OSMemNFree = nblks; /* Store number of free blocks in MCB */
\ 0000007C 3C61 STR R4,[R7, #+16]
94 pmem->OSMemNBlks = nblks;
\ 0000007E FC60 STR R4,[R7, #+12]
95 pmem->OSMemBlkSize = blksize; /* Store block size of each memory blocks */
\ 00000080 BD60 STR R5,[R7, #+8]
96 *err = OS_NO_ERR;
\ 00000082 0020 MOVS R0,#+0
\ 00000084 3070 STRB R0,[R6, #+0]
97 return (pmem);
\ 00000086 3800 MOVS R0,R7
\ ??OSMemCreate_1:
\ 00000088 01B0 ADD SP,SP,#+4
\ 0000008A F0BC POP {R4-R7}
\ 0000008C 02BC POP {R1}
\ 0000008E 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 03D1 BNE ??OSMemGet_0
130 *err = OS_MEM_INVALID_PMEM;
\ 0000000A 7420 MOVS R0,#+116
\ 0000000C 2070 STRB R0,[R4, #+0]
131 return ((OS_MEM *)0);
\ 0000000E 0020 MOVS R0,#+0
\ 00000010 15E0 B ??OSMemGet_1
132 }
133 #endif
134 OS_ENTER_CRITICAL();
\ ??OSMemGet_0:
\ 00000012 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
135 if (pmem->OSMemNFree > 0) { /* See if there are any free memory blocks */
\ 00000016 2969 LDR R1,[R5, #+16]
\ 00000018 0029 CMP R1,#+0
\ 0000001A 0BD0 BEQ ??OSMemGet_2
136 pblk = pmem->OSMemFreeList; /* Yes, point to next free memory block */
\ 0000001C 6E68 LDR R6,[R5, #+4]
137 pmem->OSMemFreeList = *(void **)pblk; /* Adjust pointer to new free list */
\ 0000001E 3168 LDR R1,[R6, #+0]
\ 00000020 6960 STR R1,[R5, #+4]
138 pmem->OSMemNFree--; /* One less memory block in this partition */
\ 00000022 2969 LDR R1,[R5, #+16]
\ 00000024 491E SUBS R1,R1,#+1
\ 00000026 2961 STR R1,[R5, #+16]
139 OS_EXIT_CRITICAL();
\ 00000028 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
140 *err = OS_NO_ERR; /* No error */
\ 0000002C 0020 MOVS R0,#+0
\ 0000002E 2070 STRB R0,[R4, #+0]
141 return (pblk); /* Return memory block to caller */
\ 00000030 3000 MOVS R0,R6
\ 00000032 04E0 B ??OSMemGet_1
142 }
143 OS_EXIT_CRITICAL();
\ ??OSMemGet_2:
\ 00000034 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
144 *err = OS_MEM_NO_FREE_BLKS; /* No, Notify caller of empty memory partition */
\ 00000038 7120 MOVS R0,#+113
\ 0000003A 2070 STRB R0,[R4, #+0]
145 return ((void *)0); /* Return NULL pointer to caller */
\ 0000003C 0020 MOVS R0,#+0
\ ??OSMemGet_1:
\ 0000003E 70BC POP {R4-R6}
\ 00000040 02BC POP {R1}
\ 00000042 0847 BX R1 ;; return
146 }
147
148 /*
149 *********************************************************************************************************
150 * GET THE NAME OF A MEMORY PARTITION
151 *
152 * Description: This function is used to obtain the name assigned to a memory partition.
153 *
154 * Arguments : pmem is a pointer to the memory partition
155 *
156 * pname is a pointer to an ASCII string that will receive the name of the memory partition.
157 *
158 * err is a pointer to an error code that can contain one of the following values:
159 *
160 * OS_NO_ERR if the name was copied to 'pname'
161 * OS_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
162 * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
163 *
164 * Returns : The length of the string or 0 if 'pmem' is a NULL pointer.
165 *********************************************************************************************************
166 */
167
168 #if OS_MEM_NAME_SIZE > 1
\ In segment CODE, align 4, keep-with-next
169 INT8U OSMemNameGet (OS_MEM *pmem, char *pname, INT8U *err)
170 {
\ OSMemNameGet:
\ 00000000 F0B5 PUSH {R4-R7,LR}
\ 00000002 0600 MOVS R6,R0
\ 00000004 0F00 MOVS R7,R1
\ 00000006 1400 MOVS R4,R2
171 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
172 OS_CPU_SR cpu_sr;
173 #endif
174 INT8U len;
175
176
177 OS_ENTER_CRITICAL();
\ 00000008 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 0000000C 0500 MOVS R5,R0
178 #if OS_ARG_CHK_EN > 0
179 if (pmem == (OS_MEM *)0) { /* Is 'pmem' a NULL pointer? */
\ 0000000E 002E CMP R6,#+0
\ 00000010 06D1 BNE ??OSMemNameGet_0
180 OS_EXIT_CRITICAL(); /* Yes */
\ 00000012 2800 MOVS R0,R5
\ 00000014 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
181 *err = OS_MEM_INVALID_PMEM;
\ 00000018 7420 MOVS R0,#+116
\ 0000001A 2070 STRB R0,[R4, #+0]
182 return (0);
\ 0000001C 0020 MOVS R0,#+0
\ 0000001E 14E0 B ??OSMemNameGet_1
183 }
184 if (pname == (char *)0) { /* Is 'pname' a NULL pointer? */
\ ??OSMemNameGet_0:
\ 00000020 002F CMP R7,#+0
\ 00000022 06D1 BNE ??OSMemNameGet_2
185 OS_EXIT_CRITICAL(); /* Yes */
\ 00000024 2800 MOVS R0,R5
\ 00000026 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
186 *err = OS_ERR_PNAME_NULL;
\ 0000002A 0F20 MOVS R0,#+15
\ 0000002C 2070 STRB R0,[R4, #+0]
187 return (0);
\ 0000002E 0020 MOVS R0,#+0
\ 00000030 0BE0 B ??OSMemNameGet_1
188 }
189 #endif
190 len = OS_StrCopy(pname, pmem->OSMemName); /* Copy name from OS_MEM */
\ ??OSMemNameGet_2:
\ 00000032 1436 ADDS R6,R6,#+20
\ 00000034 3100 MOVS R1,R6
\ 00000036 3800 MOVS R0,R7
\ 00000038 ........ _BLF OS_StrCopy,??OS_StrCopy??rT
\ 0000003C 0600 MOVS R6,R0
191 OS_EXIT_CRITICAL();
\ 0000003E 2800 MOVS R0,R5
\ 00000040 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
192 *err = OS_NO_ERR;
\ 00000044 0020 MOVS R0,#+0
\ 00000046 2070 STRB R0,[R4, #+0]
193 return (len);
\ 00000048 3000 MOVS R0,R6
\ ??OSMemNameGet_1:
\ 0000004A F0BC POP {R4-R7}
\ 0000004C 02BC POP {R1}
\ 0000004E 0847 BX R1 ;; return
194 }
195 #endif
196
197
198 /*
199 *********************************************************************************************************
200 * ASSIGN A NAME TO A MEMORY PARTITION
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -