FreeCalypso > hg > fc-tourmaline
comparison src/nucleus/pmf.c @ 0:4e78acac3d88
src/{condat,cs,gpf,nucleus}: import from Selenite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 16 Oct 2020 06:23:26 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4e78acac3d88 |
---|---|
1 /*************************************************************************/ | |
2 /* */ | |
3 /* Copyright Mentor Graphics Corporation 2002 */ | |
4 /* All Rights Reserved. */ | |
5 /* */ | |
6 /* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS */ | |
7 /* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS */ | |
8 /* SUBJECT TO LICENSE TERMS. */ | |
9 /* */ | |
10 /*************************************************************************/ | |
11 | |
12 /*************************************************************************/ | |
13 /* */ | |
14 /* FILE NAME VERSION */ | |
15 /* */ | |
16 /* pmf.c Nucleus PLUS 1.14 */ | |
17 /* */ | |
18 /* COMPONENT */ | |
19 /* */ | |
20 /* PM - Partition Memory Management */ | |
21 /* */ | |
22 /* DESCRIPTION */ | |
23 /* */ | |
24 /* This file contains routines to obtain facts about the Partition */ | |
25 /* Memory Management component. */ | |
26 /* */ | |
27 /* DATA STRUCTURES */ | |
28 /* */ | |
29 /* None */ | |
30 /* */ | |
31 /* FUNCTIONS */ | |
32 /* */ | |
33 /* PMF_Established_Partition_Pools Number of partition pools */ | |
34 /* PMF_Partition_Pool_Pointers Build partition pool pointer */ | |
35 /* list */ | |
36 /* PMF_Partition_Pool_Information Retrieve partition pool info */ | |
37 /* */ | |
38 /* DEPENDENCIES */ | |
39 /* */ | |
40 /* cs_extr.h Common Service functions */ | |
41 /* tc_extr.h Thread Control functions */ | |
42 /* pm_extr.h Partition functions */ | |
43 /* hi_extr.h History functions */ | |
44 /* */ | |
45 /* HISTORY */ | |
46 /* */ | |
47 /* DATE REMARKS */ | |
48 /* */ | |
49 /* 03-01-1994 Initial version of partition fact */ | |
50 /* service file, version 1.1 */ | |
51 /* */ | |
52 /* 03-18-1994 Verified version 1.1 */ | |
53 /* 04-17-1996 updated to version 1.2 */ | |
54 /* 11-18-1996 Protected Informational service */ | |
55 /* from NULL Control Block pointers */ | |
56 /* creating 1.2a. (SPR220) */ | |
57 /* 03-24-1998 Released version 1.3. */ | |
58 /* 03-26-1999 Released 1.11m (new release */ | |
59 /* numbering scheme) */ | |
60 /* 04-17-2002 Released version 1.13m */ | |
61 /* 11-07-2002 Released version 1.14 */ | |
62 /*************************************************************************/ | |
63 #define NU_SOURCE_FILE | |
64 | |
65 | |
66 #include "cs_extr.h" /* Common service functions */ | |
67 #include "tc_extr.h" /* Thread control functions */ | |
68 #include "pm_extr.h" /* Partition functions */ | |
69 #include "hi_extr.h" /* History functions */ | |
70 | |
71 | |
72 /* Define external inner-component global data references. */ | |
73 | |
74 extern CS_NODE *PMD_Created_Pools_List; | |
75 extern UNSIGNED PMD_Total_Pools; | |
76 extern TC_PROTECT PMD_List_Protect; | |
77 | |
78 | |
79 | |
80 /*************************************************************************/ | |
81 /* */ | |
82 /* FUNCTION */ | |
83 /* */ | |
84 /* PMF_Established_Partition_Pools */ | |
85 /* */ | |
86 /* DESCRIPTION */ | |
87 /* */ | |
88 /* This function returns the current number of established */ | |
89 /* partition pools. Pools previously deleted are no longer */ | |
90 /* considered established. */ | |
91 /* */ | |
92 /* CALLED BY */ | |
93 /* */ | |
94 /* Application */ | |
95 /* */ | |
96 /* CALLS */ | |
97 /* */ | |
98 /* [TCT_Check_Stack] Stack checking function */ | |
99 /* */ | |
100 /* INPUTS */ | |
101 /* */ | |
102 /* None */ | |
103 /* */ | |
104 /* OUTPUTS */ | |
105 /* */ | |
106 /* PMD_Total_Pools Number of established */ | |
107 /* partition pools */ | |
108 /* */ | |
109 /* HISTORY */ | |
110 /* */ | |
111 /* DATE REMARKS */ | |
112 /* */ | |
113 /* 03-01-1993 Created initial version 1.0 */ | |
114 /* 04-19-1993 Verified version 1.0 */ | |
115 /* 03-01-1994 Modified function interface, */ | |
116 /* resulting in version 1.1 */ | |
117 /* */ | |
118 /* 03-18-1994 Verified version 1.1 */ | |
119 /* */ | |
120 /*************************************************************************/ | |
121 UNSIGNED PMF_Established_Partition_Pools(VOID) | |
122 { | |
123 | |
124 | |
125 #ifdef NU_ENABLE_STACK_CHECK | |
126 | |
127 /* Call stack checking function to check for an overflow condition. */ | |
128 TCT_Check_Stack(); | |
129 | |
130 #endif | |
131 | |
132 /* Return the number of established partition pools. */ | |
133 return(PMD_Total_Pools); | |
134 } | |
135 | |
136 | |
137 /*************************************************************************/ | |
138 /* */ | |
139 /* FUNCTION */ | |
140 /* */ | |
141 /* PMF_Partition_Pool_Pointers */ | |
142 /* */ | |
143 /* DESCRIPTION */ | |
144 /* */ | |
145 /* This function builds a list of pool pointers, starting at */ | |
146 /* the specified location. The number of pool pointers */ | |
147 /* placed in the list is equivalent to the total number of */ | |
148 /* pools or the maximum number of pointers specified in the */ | |
149 /* call. */ | |
150 /* */ | |
151 /* CALLED BY */ | |
152 /* */ | |
153 /* Application */ | |
154 /* */ | |
155 /* CALLS */ | |
156 /* */ | |
157 /* [TCT_Check_Stack] Stack checking function */ | |
158 /* TCT_Protect Protect created list */ | |
159 /* TCT_Unprotect Release protection */ | |
160 /* */ | |
161 /* INPUTS */ | |
162 /* */ | |
163 /* pointer_list Pointer to the list area */ | |
164 /* maximum_pointers Maximum number of pointers */ | |
165 /* */ | |
166 /* OUTPUTS */ | |
167 /* */ | |
168 /* pointers Number of partition pools */ | |
169 /* placed in the list */ | |
170 /* HISTORY */ | |
171 /* */ | |
172 /* DATE REMARKS */ | |
173 /* */ | |
174 /* 03-01-1993 Created initial version 1.0 */ | |
175 /* 04-19-1993 Verified version 1.0 */ | |
176 /* 08-09-1993 Corrected pointer retrieval */ | |
177 /* loop, resulting in version 1.0a */ | |
178 /* 08-09-1993 Verified version 1.0a */ | |
179 /* 03-01-1994 Modified function interface, */ | |
180 /* resulting in version 1.1 */ | |
181 /* */ | |
182 /* 03-18-1994 Verified version 1.1 */ | |
183 /* */ | |
184 /*************************************************************************/ | |
185 UNSIGNED PMF_Partition_Pool_Pointers(NU_PARTITION_POOL **pointer_list, | |
186 UNSIGNED maximum_pointers) | |
187 { | |
188 CS_NODE *node_ptr; /* Pointer to each PCB */ | |
189 UNSIGNED pointers; /* Number of pointers in list*/ | |
190 NU_SUPERV_USER_VARIABLES | |
191 | |
192 /* Switch to supervisor mode */ | |
193 NU_SUPERVISOR_MODE(); | |
194 | |
195 #ifdef NU_ENABLE_STACK_CHECK | |
196 | |
197 /* Call stack checking function to check for an overflow condition. */ | |
198 TCT_Check_Stack(); | |
199 | |
200 #endif | |
201 | |
202 /* Initialize the number of pointers returned. */ | |
203 pointers = 0; | |
204 | |
205 /* Protect against access to the list of created partition pools. */ | |
206 TCT_Protect(&PMD_List_Protect); | |
207 | |
208 /* Loop until all pool pointers are in the list or until the maximum | |
209 list size is reached. */ | |
210 node_ptr = PMD_Created_Pools_List; | |
211 while ((node_ptr) && (pointers < maximum_pointers)) | |
212 { | |
213 | |
214 /* Place the node into the destination list. */ | |
215 *pointer_list++ = (NU_PARTITION_POOL *) node_ptr; | |
216 | |
217 /* Increment the pointers variable. */ | |
218 pointers++; | |
219 | |
220 /* Position the node pointer to the next node. */ | |
221 node_ptr = node_ptr -> cs_next; | |
222 | |
223 /* Determine if the pointer is at the head of the list. */ | |
224 if (node_ptr == PMD_Created_Pools_List) | |
225 | |
226 /* The list search is complete. */ | |
227 node_ptr = NU_NULL; | |
228 } | |
229 | |
230 /* Release protection against access to the list of created pools. */ | |
231 TCT_Unprotect(); | |
232 | |
233 /* Return to user mode */ | |
234 NU_USER_MODE(); | |
235 | |
236 /* Return the number of pointers in the list. */ | |
237 return(pointers); | |
238 } | |
239 | |
240 | |
241 /*************************************************************************/ | |
242 /* */ | |
243 /* FUNCTION */ | |
244 /* */ | |
245 /* PMF_Partition_Pool_Information */ | |
246 /* */ | |
247 /* DESCRIPTION */ | |
248 /* */ | |
249 /* This function returns information about the specified partition */ | |
250 /* pool. However, if the supplied partition pool pointer is */ | |
251 /* invalid, the function simply returns an error status. */ | |
252 /* */ | |
253 /* CALLED BY */ | |
254 /* */ | |
255 /* Application */ | |
256 /* */ | |
257 /* CALLS */ | |
258 /* */ | |
259 /* [TCT_Check_Stack] Stack checking function */ | |
260 /* TCT_System_Protect Protect partition pool */ | |
261 /* TCT_Unprotect Release protection */ | |
262 /* */ | |
263 /* INPUTS */ | |
264 /* */ | |
265 /* pool_ptr Pointer to the partition pool*/ | |
266 /* name Destination for the name */ | |
267 /* start_address Destination for the starting */ | |
268 /* memory address of the pool */ | |
269 /* pool_size Destination for the pool's */ | |
270 /* total size */ | |
271 /* partition_size Destination for the size of */ | |
272 /* each partition */ | |
273 /* available Destination for the available*/ | |
274 /* number of partitions */ | |
275 /* allocated Destination for the number */ | |
276 /* of allocated partitions */ | |
277 /* suspend_type Destination for the type of */ | |
278 /* suspension */ | |
279 /* tasks_waiting Destination for the tasks */ | |
280 /* waiting count */ | |
281 /* first_task Destination for the pointer */ | |
282 /* to the first task waiting */ | |
283 /* */ | |
284 /* OUTPUTS */ | |
285 /* */ | |
286 /* NU_SUCCESS If a valid pool pointer */ | |
287 /* is supplied */ | |
288 /* NU_INVALID_POOL If pool pointer invalid */ | |
289 /* */ | |
290 /* HISTORY */ | |
291 /* */ | |
292 /* DATE REMARKS */ | |
293 /* */ | |
294 /* 03-01-1993 Created initial version 1.0 */ | |
295 /* 04-19-1993 Verified version 1.0 */ | |
296 /* 03-01-1994 Modified function interface, */ | |
297 /* resulting in version 1.1 */ | |
298 /* */ | |
299 /* 03-18-1994 Verified version 1.1 */ | |
300 /* 11-18-1996 Corrected SPR220. */ | |
301 /* */ | |
302 /*************************************************************************/ | |
303 STATUS PMF_Partition_Pool_Information(NU_PARTITION_POOL *pool_ptr, CHAR *name, | |
304 VOID **start_address, UNSIGNED *pool_size, | |
305 UNSIGNED *partition_size, UNSIGNED *available, | |
306 UNSIGNED *allocated, OPTION *suspend_type, | |
307 UNSIGNED *tasks_waiting, NU_TASK **first_task) | |
308 { | |
309 | |
310 PM_PCB *pool; /* Pool control block ptr */ | |
311 INT i; /* Working integer variable */ | |
312 STATUS completion; /* Completion status */ | |
313 NU_SUPERV_USER_VARIABLES | |
314 | |
315 /* Switch to superisor mode */ | |
316 NU_SUPERVISOR_MODE(); | |
317 | |
318 /* Move input pool pointer into internal pointer. */ | |
319 pool = (PM_PCB *) pool_ptr; | |
320 | |
321 | |
322 #ifdef NU_ENABLE_STACK_CHECK | |
323 | |
324 /* Call stack checking function to check for an overflow condition. */ | |
325 TCT_Check_Stack(); | |
326 | |
327 #endif | |
328 | |
329 /* Determine if this partition pool id is valid. */ | |
330 if ((pool != NU_NULL) && (pool -> pm_id == PM_PARTITION_ID)) | |
331 { | |
332 | |
333 /* Setup protection of the partition pool. */ | |
334 TCT_System_Protect(); | |
335 | |
336 /* The partition pool pointer is valid. Reflect this in the completion | |
337 status and fill in the actual information. */ | |
338 completion = NU_SUCCESS; | |
339 | |
340 /* Copy the partition pool's name. */ | |
341 for (i = 0; i < NU_MAX_NAME; i++) | |
342 *name++ = pool -> pm_name[i]; | |
343 | |
344 /* Determine the suspension type. */ | |
345 if (pool -> pm_fifo_suspend) | |
346 *suspend_type = NU_FIFO; | |
347 else | |
348 *suspend_type = NU_PRIORITY; | |
349 | |
350 /* Retrieve information directly out of the control structure. */ | |
351 *start_address = pool -> pm_start_address; | |
352 *pool_size = pool -> pm_pool_size; | |
353 *partition_size = pool -> pm_partition_size; | |
354 *available = pool -> pm_available; | |
355 *allocated = pool -> pm_allocated; | |
356 | |
357 /* Retrieve the number of tasks waiting and the pointer to the | |
358 first task waiting. */ | |
359 *tasks_waiting = pool -> pm_tasks_waiting; | |
360 if (pool -> pm_suspension_list) | |
361 | |
362 /* There is a task waiting. */ | |
363 *first_task = (NU_TASK *) | |
364 (pool -> pm_suspension_list) -> pm_suspended_task; | |
365 else | |
366 | |
367 /* There are no tasks waiting. */ | |
368 *first_task = NU_NULL; | |
369 | |
370 /* Release protection of the partition pool. */ | |
371 TCT_Unprotect(); | |
372 } | |
373 else | |
374 | |
375 /* Indicate that the partition pool pointer is invalid. */ | |
376 completion = NU_INVALID_POOL; | |
377 | |
378 /* Return to user mode */ | |
379 NU_USER_MODE(); | |
380 | |
381 /* Return the appropriate completion status. */ | |
382 return(completion); | |
383 } | |
384 | |
385 | |
386 | |
387 |