📄 os_mem.s79
字号:
POP {R4-R7}
POP {R1}
BX R1 ;; return
CFI EndBlock cfiBlock1
// 98 }
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock2 Using cfiCommon0
CFI NoFunction
ARM
??OSMemGet??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock2
REQUIRE OSMemGet
// 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
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock3 Using cfiCommon1
CFI Function OSMemGet
THUMB
// 120 void *OSMemGet (OS_MEM *pmem, INT8U *err)
// 121 {
OSMemGet:
PUSH {R4-R6,LR}
CFI ?RET Frame(CFA, -4)
CFI R6 Frame(CFA, -8)
CFI R5 Frame(CFA, -12)
CFI R4 Frame(CFA, -16)
CFI CFA R13+16
MOVS R5,R0
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 */
CMP R5,#+0
BNE ??OSMemGet_0
// 130 *err = OS_MEM_INVALID_PMEM;
MOVS R0,#+116
B.N ??OSMemGet_1
// 131 return ((OS_MEM *)0);
// 132 }
// 133 #endif
// 134 OS_ENTER_CRITICAL();
??OSMemGet_0:
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
// 135 if (pmem->OSMemNFree > 0) { /* See if there are any free memory blocks */
LDR R1,[R5, #+16]
CMP R1,#+0
BEQ ??OSMemGet_2
// 136 pblk = pmem->OSMemFreeList; /* Yes, point to next free memory block */
LDR R6,[R5, #+4]
// 137 pmem->OSMemFreeList = *(void **)pblk; /* Adjust pointer to new free list */
LDR R1,[R6, #+0]
STR R1,[R5, #+4]
// 138 pmem->OSMemNFree--; /* One less memory block in this partition */
LDR R1,[R5, #+16]
SUBS R1,R1,#+1
STR R1,[R5, #+16]
// 139 OS_EXIT_CRITICAL();
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 140 *err = OS_NO_ERR; /* No error */
MOVS R0,#+0
STRB R0,[R4, #+0]
// 141 return (pblk); /* Return memory block to caller */
MOVS R0,R6
B ??OSMemGet_3
// 142 }
// 143 OS_EXIT_CRITICAL();
??OSMemGet_2:
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 144 *err = OS_MEM_NO_FREE_BLKS; /* No, Notify caller of empty memory partition */
MOVS R0,#+113
??OSMemGet_1:
STRB R0,[R4, #+0]
// 145 return ((void *)0); /* Return NULL pointer to caller */
MOVS R0,#+0
??OSMemGet_3:
POP {R4-R6}
POP {R1}
BX R1 ;; return
CFI EndBlock cfiBlock3
// 146 }
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock4 Using cfiCommon0
CFI NoFunction
ARM
??OSMemNameGet??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock4
REQUIRE OSMemNameGet
// 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
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock5 Using cfiCommon1
CFI Function OSMemNameGet
THUMB
// 169 INT8U OSMemNameGet (OS_MEM *pmem, char *pname, INT8U *err)
// 170 {
OSMemNameGet:
PUSH {R4-R7,LR}
CFI ?RET Frame(CFA, -4)
CFI R7 Frame(CFA, -8)
CFI R6 Frame(CFA, -12)
CFI R5 Frame(CFA, -16)
CFI R4 Frame(CFA, -20)
CFI CFA R13+20
MOVS R6,R0
MOVS R7,R1
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();
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R5,R0
// 178 #if OS_ARG_CHK_EN > 0
// 179 if (pmem == (OS_MEM *)0) { /* Is 'pmem' a NULL pointer? */
CMP R6,#+0
BNE ??OSMemNameGet_0
// 180 OS_EXIT_CRITICAL(); /* Yes */
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 181 *err = OS_MEM_INVALID_PMEM;
MOVS R0,#+116
??OSMemNameGet_1:
STRB R0,[R4, #+0]
// 182 return (0);
MOVS R0,#+0
B ??OSMemNameGet_2
// 183 }
// 184 if (pname == (char *)0) { /* Is 'pname' a NULL pointer? */
??OSMemNameGet_0:
CMP R7,#+0
BNE ??OSMemNameGet_3
// 185 OS_EXIT_CRITICAL(); /* Yes */
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 186 *err = OS_ERR_PNAME_NULL;
MOVS R0,#+15
B.N ??OSMemNameGet_1
// 187 return (0);
// 188 }
// 189 #endif
// 190 len = OS_StrCopy(pname, pmem->OSMemName); /* Copy name from OS_MEM */
??OSMemNameGet_3:
ADDS R6,R6,#+20
MOVS R1,R6
MOVS R0,R7
_BLF OS_StrCopy,??OS_StrCopy??rT
MOVS R6,R0
// 191 OS_EXIT_CRITICAL();
MOVS R0,R5
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 192 *err = OS_NO_ERR;
MOVS R0,#+0
STRB R0,[R4, #+0]
// 193 return (len);
MOVS R0,R6
??OSMemNameGet_2:
POP {R4-R7}
POP {R1}
BX R1 ;; return
CFI EndBlock cfiBlock5
// 194 }
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock6 Using cfiCommon0
CFI NoFunction
ARM
??OSMemNameSet??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock6
REQUIRE OSMemNameSet
// 195 #endif
// 196
// 197
// 198 /*
// 199 *********************************************************************************************************
// 200 * ASSIGN A NAME TO A MEMORY PARTITION
// 201 *
// 202 * Description: This function assigns a name to a memory partition.
// 203 *
// 204 * Arguments : pmem is a pointer to the memory partition
// 205 *
// 206 * pname is a pointer to an ASCII string that contains the name of the memory partition.
// 207 *
// 208 * err is a pointer to an error code that can contain one of the following values:
// 209 *
// 210 * OS_NO_ERR if the name was copied to 'pname'
// 211 * OS_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
// 212 * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
// 213 * OS_MEM_NAME_TOO_LONG if the name doesn't fit in the storage area
// 214 *
// 215 * Returns : None
// 216 *********************************************************************************************************
// 217 */
// 218
// 219 #if OS_MEM_NAME_SIZE > 1
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock7 Using cfiCommon1
CFI Function OSMemNameSet
THUMB
// 220 void OSMemNameSet (OS_MEM *pmem, char *pname, INT8U *err)
// 221 {
OSMemNameSet:
PUSH {R4-R7,LR}
CFI ?RET Frame(CFA, -4)
CFI R7 Frame(CFA, -8)
CFI R6 Frame(CFA, -12)
CFI R5 Frame(CFA, -16)
CFI R4 Frame(CFA, -20)
CFI CFA R13+20
MOVS R4,R0
MOVS R5,R1
MOVS R6,R2
// 222 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
// 223 OS_CPU_SR cpu_sr;
// 224 #endif
// 225 INT8U len;
// 226
// 227
// 228 OS_ENTER_CRITICAL();
_BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
MOVS R7,R0
// 229 #if OS_ARG_CHK_EN > 0
// 230 if (pmem == (OS_MEM *)0) { /* Is 'pmem' a NULL pointer? */
CMP R4,#+0
BNE ??OSMemNameSet_0
// 231 OS_EXIT_CRITICAL(); /* Yes */
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 232 *err = OS_MEM_INVALID_PMEM;
MOVS R0,#+116
STRB R0,[R6, #+0]
// 233 }
// 234 if (pname == (char *)0) { /* Is 'pname' a NULL pointer? */
??OSMemNameSet_0:
CMP R5,#+0
BNE ??OSMemNameSet_1
// 235 OS_EXIT_CRITICAL(); /* Yes */
MOVS R0,R7
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 236 *err = OS_ERR_PNAME_NULL;
MOVS R0,#+15
B.N ??OSMemNameSet_2
// 237 return;
// 238 }
// 239 #endif
// 240 len = OS_StrLen(pname); /* Can we fit the string in the storage area? */
??OSMemNameSet_1:
MOVS R0,R5
_BLF OS_StrLen,??OS_StrLen??rT
// 241 if (len > (OS_MEM_NAME_SIZE - 1)) { /* No */
CMP R0,#+32
BCC ??OSMemNameSet_3
// 242 OS_EXIT_CRITICAL();
MOVS R0,R7
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 243 *err = OS_MEM_NAME_TOO_LONG;
MOVS R0,#+119
B.N ??OSMemNameSet_2
// 244 return;
// 245 }
// 246 (void)OS_StrCopy(pmem->OSMemName, pname); /* Yes, copy name to the memory partition header */
??OSMemNameSet_3:
MOVS R1,R5
ADDS R4,R4,#+20
MOVS R0,R4
_BLF OS_StrCopy,??OS_StrCopy??rT
// 247 OS_EXIT_CRITICAL();
MOVS R0,R7
_BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
// 248 *err = OS_NO_ERR;
MOVS R0,#+0
??OSMemNameSet_2:
STRB R0,[R6, #+0]
// 249 }
POP {R4-R7}
POP {R0}
BX R0 ;; return
CFI EndBlock cfiBlock7
RSEG CODE:CODE:NOROOT(2)
CFI Block cfiBlock8 Using cfiCommon0
CFI NoFunction
ARM
??OSMemPut??rA:
ADD R12,PC,#+1
BX R12
CFI EndBlock cfiBlock8
REQUIRE OSMemPut
// 250 #endif
// 251
// 252
// 253 /*
// 254 *********************************************************************************************************
// 255 * RELEASE A MEMORY BLOCK
// 256 *
// 257 * Description : Returns a memory block to a partition
// 258 *
// 259 * Arguments : pmem is a pointer to the memory partition control block
// 260 *
// 261 * pblk is a pointer to the memory block being released.
// 262 *
// 263 * Returns : OS_NO_ERR if the memory block was inserted into the partition
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -