os_mem.ls1
来自「在51单片机上移植成功的UCOS-II操作系统源代码,包括源代码及相关注释」· LS1 代码 · 共 464 行 · 第 1/2 页
LS1
464 行
A51 MACRO ASSEMBLER OS_MEM 09/09/2007 21:12:48 PAGE 1
MACRO ASSEMBLER A51 V7.10
OBJECT MODULE PLACED IN OS_MEM.OBJ
ASSEMBLER INVOKED BY: D:\Keil\C51\BIN\A51.EXE OS_MEM.src PR(.\OS_MEM.ls1) EP DEBUG
LOC OBJ LINE SOURCE
1 ; .\OS_MEM.SRC generated from: OS_MEM.C
2 ; COMPILER INVOKED BY:
3 ; D:\Keil\C51\BIN\C51.EXE OS_MEM.C LARGE BROWSE DEBUG OBJECTEXTEND SRC(.\OS_MEM.SRC)
4
5 $nomod51
6
7 NAME OS_MEM
8
0080 9 P0 DATA 080H
0090 10 P1 DATA 090H
00A0 11 P2 DATA 0A0H
00B0 12 P3 DATA 0B0H
00B4 13 T0 BIT 0B0H.4
00D6 14 AC BIT 0D0H.6
00B5 15 T1 BIT 0B0H.5
00AF 16 EA BIT 0A8H.7
00A8 17 IE DATA 0A8H
00B7 18 RD BIT 0B0H.7
00AC 19 ES BIT 0A8H.4
00B8 20 IP DATA 0B8H
0098 21 RI BIT 098H.0
00B2 22 INT0 BIT 0B0H.2
00D7 23 CY BIT 0D0H.7
0099 24 TI BIT 098H.1
00B3 25 INT1 BIT 0B0H.3
00BC 26 PS BIT 0B8H.4
0081 27 SP DATA 081H
00D2 28 OV BIT 0D0H.2
00B6 29 WR BIT 0B0H.6
0099 30 SBUF DATA 099H
0087 31 PCON DATA 087H
0098 32 SCON DATA 098H
0089 33 TMOD DATA 089H
0088 34 TCON DATA 088H
0089 35 IE0 BIT 088H.1
008B 36 IE1 BIT 088H.3
00F0 37 B DATA 0F0H
00E0 38 ACC DATA 0E0H
00A9 39 ET0 BIT 0A8H.1
00AB 40 ET1 BIT 0A8H.3
008D 41 TF0 BIT 088H.5
008F 42 TF1 BIT 088H.7
009A 43 RB8 BIT 098H.2
008C 44 TH0 DATA 08CH
00A8 45 EX0 BIT 0A8H.0
0088 46 IT0 BIT 088H.0
008D 47 TH1 DATA 08DH
009B 48 TB8 BIT 098H.3
00AA 49 EX1 BIT 0A8H.2
008A 50 IT1 BIT 088H.2
00D0 51 P BIT 0D0H.0
009F 52 SM0 BIT 098H.7
008A 53 TL0 DATA 08AH
009E 54 SM1 BIT 098H.6
008B 55 TL1 DATA 08BH
009D 56 SM2 BIT 098H.5
00B9 57 PT0 BIT 0B8H.1
00BB 58 PT1 BIT 0B8H.3
A51 MACRO ASSEMBLER OS_MEM 09/09/2007 21:12:48 PAGE 2
00D3 59 RS0 BIT 0D0H.3
008C 60 TR0 BIT 088H.4
00D4 61 RS1 BIT 0D0H.4
008E 62 TR1 BIT 088H.6
00B8 63 PX0 BIT 0B8H.0
00BA 64 PX1 BIT 0B8H.2
0083 65 DPH DATA 083H
0082 66 DPL DATA 082H
009C 67 REN BIT 098H.4
00B0 68 RXD BIT 0B0H.0
00B1 69 TXD BIT 0B0H.1
00D5 70 F0 BIT 0D0H.5
00D0 71 PSW DATA 0D0H
72 ; /*
73 ; *****************************************************************************************
****************
74 ; * uC/OS-II
75 ; * The Real-Time Kernel
76 ; * MEMORY MANAGEMENT
77 ; *
78 ; * (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
79 ; * All Rights Reserved
80 ; *
81 ; * V2.00
82 ; *
83 ; * File : OS_MEM.C
84 ; * By : Jean J. Labrosse
85 ; *****************************************************************************************
****************
86 ; */
87 ;
88 ; #ifndef OS_MASTER_FILE
89 ; #include "includes.h"
90 ; #endif
91 ;
92 ; #if OS_MEM_EN && OS_MAX_MEM_PART >= 2
93 ; /*
94 ; *****************************************************************************************
****************
95 ; * LOCAL GLOBAL VARIABLES
96 ; *****************************************************************************************
****************
97 ; */
98 ;
99 ; static OS_MEM *OSMemFreeList; /* Pointer to free list of memory partitio
ns */
100 ; static OS_MEM OSMemTbl[OS_MAX_MEM_PART];/* Storage for memory partition manager
*/
101 ; /*$PAGE*/
102 ; /*
103 ; *****************************************************************************************
****************
104 ; * CREATE A MEMORY PARTITION
105 ; *
106 ; * Description : Create a fixed-sized memory partition that will be managed by uC/OS-II.
107 ; *
108 ; * Arguments : addr is the starting address of the memory partition
109 ; *
110 ; * nblks is the number of memory blocks to create from the partition.
111 ; *
112 ; * blksize is the size (in bytes) of each block in the memory partition.
113 ; *
114 ; * err is a pointer to a variable containing an error message which wil
l be set by
115 ; * this function to either:
116 ; *
A51 MACRO ASSEMBLER OS_MEM 09/09/2007 21:12:48 PAGE 3
117 ; * OS_NO_ERR if the memory partition has been created co
rrectly.
118 ; * OS_MEM_INVALID_PART no free partitions available
119 ; * OS_MEM_INVALID_BLKS user specified an invalid number of blocks
(must be >= 2)
120 ; * OS_MEM_INVALID_SIZE user specified an invalid block size
121 ; * (must be greater than the size of a pointer
)
122 ; * Returns : != (OS_MEM *)0 is the partition was created
123 ; * == (OS_MEM *)0 if the partition was not created because of invalid argume
nts or, no
124 ; * free partition is available.
125 ; *****************************************************************************************
****************
126 ; */
127 ;
128 ; OS_MEM *OSMemCreate (void *addr, INT32U nblks, INT32U blksize, INT8U *err) reentrant
129 ; {
130 ; OS_MEM *pmem;
131 ; INT8U *pblk;
132 ; void **plink;
133 ; INT32U i;
134 ;
135 ;
136 ; if (nblks < 2) { /* Must have at least 2 blocks per
partition */
137 ; *err = OS_MEM_INVALID_BLKS;
138 ; return ((OS_MEM *)0);
139 ; }
140 ; if (blksize < sizeof(void *)) { /* Must contain space for at least
a pointer */
141 ; *err = OS_MEM_INVALID_SIZE;
142 ; return ((OS_MEM *)0);
143 ; }
144 ; OS_ENTER_CRITICAL();
145 ; pmem = OSMemFreeList; /* Get next free memory partition
*/
146 ; if (OSMemFreeList != (OS_MEM *)0) { /* See if pool of free partitions w
as empty */
147 ; OSMemFreeList = (OS_MEM *)OSMemFreeList->OSMemFreeList;
148 ; }
149 ; OS_EXIT_CRITICAL();
150 ; if (pmem == (OS_MEM *)0) { /* See if we have a memory partitio
n */
151 ; *err = OS_MEM_INVALID_PART;
152 ; return ((OS_MEM *)0);
153 ; }
154 ; plink = (void **)addr; /* Create linked list of free memor
y blocks */
155 ; pblk = (INT8U *)addr + blksize;
156 ; for (i = 0; i < (nblks - 1); i++) {
157 ; *plink = (void *)pblk;
158 ; plink = (void **)pblk;
159 ; pblk = pblk + blksize;
160 ; }
161 ; *plink = (void *)0; /* Last memory block points to NULL
*/
162 ; OS_ENTER_CRITICAL();
163 ; pmem->OSMemAddr = addr; /* Store start address of memory pa
rtition */
164 ; pmem->OSMemFreeList = addr; /* Initialize pointer to pool of fr
ee blocks */
165 ; pmem->OSMemNFree = nblks; /* Store number of free blocks in M
CB */
166 ; pmem->OSMemNBlks = nblks;
167 ; pmem->OSMemBlkSize = blksize; /* Store block size of each memory
A51 MACRO ASSEMBLER OS_MEM 09/09/2007 21:12:48 PAGE 4
blocks */
168 ; OS_EXIT_CRITICAL();
169 ; *err = OS_NO_ERR;
170 ; return (pmem);
171 ; }
172 ; /*$PAGE*/
173 ; /*
174 ; *****************************************************************************************
****************
175 ; * GET A MEMORY BLOCK
176 ; *
177 ; * Description : Get a memory block from a partition
178 ; *
179 ; * Arguments : pmem is a pointer to the memory partition control block
180 ; *
181 ; * err is a pointer to a variable containing an error message which will
be set by this
182 ; * function to either:
183 ; *
184 ; * OS_NO_ERR if the memory partition has been created corr
ectly.
185 ; * OS_MEM_NO_FREE_BLKS if there are no more free memory blocks to al
locate to caller
186 ; *
187 ; * Returns : A pointer to a memory block if no error is detected
188 ; * A pointer to NULL if an error is detected
189 ; *****************************************************************************************
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?