comparison src/gpf3/frame/vsi_ppm.c @ 2:c41a534f33c6

src/gpf3: preened GPF goo from TCS3.2
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 23:52:50 +0000
parents
children
comparison
equal deleted inserted replaced
1:864b8cc0cf63 2:c41a534f33c6
1 /*
2 +------------------------------------------------------------------------------
3 | File: vsi_ppm.c
4 +------------------------------------------------------------------------------
5 | Copyright 2002 Texas Instruments Berlin, AG
6 | All rights reserved.
7 |
8 | This file is confidential and a trade secret of Texas
9 | Instruments Berlin, AG
10 | The receipt of or possession of this file does not convey
11 | any rights to reproduce or disclose its contents or to
12 | manufacture, use, or sell anything it may describe, in
13 | whole, or in part, without the specific written consent of
14 | Texas Instruments Berlin, AG.
15 +-----------------------------------------------------------------------------
16 | Purpose : This Module defines the virtual system interface part
17 | for the primitive partition pool supervision.
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef __VSI_PPM_C__
22 #define __VSI_PPM_C__
23 #endif
24
25 #ifdef MEMORY_SUPERVISION
26
27 /*==== INCLUDES ===================================================*/
28
29 #include "string.h"
30 #include "typedefs.h"
31 #include "os.h"
32 #include "vsi.h"
33 #include "tools.h"
34 #include "frm_defs.h"
35 #include "frm_types.h"
36 #include "frm_glob.h"
37
38 /*==== TYPES ======================================================*/
39
40 typedef struct
41 {
42 USHORT pool_nr;
43 USHORT group_nr;
44 } T_POOL_GROUP;
45
46 typedef struct
47 {
48 SHORT state_id;
49 char const * state_name;
50 } T_PARTITION_STATE;
51 /*
52 * indices to read the stored counters
53 */
54 typedef enum { TOTAL,CURRENT_BYTE,CURRENT_PART,MAX_RANGES,MAX_BYTE_MEM,MAX_PART_MEM } T_COUNTER_READ;
55
56 /*
57 * indices to update the counters
58 */
59 typedef enum { DECREMENT, INCREMENT, STORE_MAX_BYTE, STORE_MAX_PART } T_COUNTER_UPDATE;
60
61 /*==== CONSTANTS ==================================================*/
62
63 #define OWNER_IS_COM_HANDLE 0x8000
64 /*
65 * Partition States
66 */
67 #define PARTITION_FREED 0x0001
68 #define PARTITION_ALLOCATED 0x0002
69 #define PARTITION_RECEIVED 0x0004
70 #define PARTITION_SENT 0x0008
71 #define PARTITION_REUSED 0x0010
72 #define PARTITION_ACCESSED 0x0020
73 #define PARTITION_STORED 0x0040
74 #define MAX_PARTITION_STATE 7
75
76 #define ALLOWED_ALLOCATE_STATES (PARTITION_FREED)
77 #define ALLOWED_RECEIVE_STATES (PARTITION_SENT|PARTITION_RECEIVED)
78 #define ALLOWED_SEND_STATES (PARTITION_ALLOCATED|PARTITION_REUSED|\
79 PARTITION_RECEIVED|PARTITION_ACCESSED|\
80 PARTITION_STORED)
81 #define ALLOWED_REUSE_STATES (PARTITION_ALLOCATED|PARTITION_RECEIVED|\
82 PARTITION_STORED|PARTITION_REUSED)
83 #define ALLOWED_DEALLOCATE_STATES (PARTITION_RECEIVED|PARTITION_ALLOCATED|\
84 PARTITION_SENT|PARTITION_REUSED|\
85 PARTITION_ACCESSED|PARTITION_STORED)
86 #define ALLOWED_ACCESS_STATES (PARTITION_ALLOCATED|PARTITION_RECEIVED|\
87 PARTITION_REUSED|PARTITION_ACCESSED|\
88 PARTITION_STORED)
89 #define ALLOWED_STORE_STATES (PARTITION_ALLOCATED|PARTITION_RECEIVED|\
90 PARTITION_REUSED|PARTITION_ACCESSED|\
91 PARTITION_SENT)
92
93 #define FORBIDDEN_ALLOCATE_STATES (0xffff&~ALLOWED_ALLOCATE_STATES)
94 #define FORBIDDEN_RECEIVE_STATES (0xffff&~ALLOWED_RECEIVE_STATES)
95 #define FORBIDDEN_SEND_STATES (0xffff&~ALLOWED_SEND_STATES)
96 #define FORBIDDEN_REUSE_STATES (0xffff&~ALLOWED_REUSE_STATES)
97 #define FORBIDDEN_DEALLOCATE_STATES (0xffff&~ALLOWED_DEALLOCATE_STATES)
98 #define FORBIDDEN_ACCESS_STATES (0xffff&~ALLOWED_ACCESS_STATES)
99 #define FORBIDDEN_STORE_STATES (0xffff&~ALLOWED_STORE_STATES)
100
101 #define PPM_END_MARKER ((char)0xff)
102
103 #define PARTITION_SIZE(g,p) (partition_grp_config[g].grp_config[p].part_size)
104
105 #ifndef RUN_INT_RAM
106 const T_PARTITION_STATE partition_state[MAX_PARTITION_STATE+1] =
107 {
108 { PARTITION_FREED, "FREED" },
109 { PARTITION_ALLOCATED, "ALLOCATED" },
110 { PARTITION_RECEIVED, "RECEIVED" },
111 { PARTITION_SENT, "SENT" },
112 { PARTITION_REUSED, "REUSED" },
113 { PARTITION_ACCESSED, "ACCESSED" },
114 { PARTITION_STORED, "STORED" },
115 { 0, NULL }
116 };
117 #endif
118
119 /*==== EXTERNALS ==================================================*/
120
121 /* -------------- S H A R E D - BEGIN ---------------- */
122 #ifdef _TOOLS_
123 #pragma data_seg("FRAME_SHARED")
124 #endif
125
126 extern T_HANDLE TST_Handle;
127 extern const T_FRM_PARTITION_GROUP_CONFIG partition_grp_config[];
128 extern T_HANDLE * PoolGroupHandle [];
129 extern OS_HANDLE ext_data_pool_handle;
130 extern USHORT MaxPoolGroups;
131
132 /*==== VARIABLES ==================================================*/
133
134 #ifndef RUN_INT_RAM
135
136 USHORT NumberOfPPMPartitions = 0;
137 USHORT NumOfPPMPools = 0;
138 USHORT NumOfPPMGroups;
139 USHORT NumOfPrimPools;
140 USHORT NumOfDmemPools;
141 T_PARTITION_POOL_STATUS PoolStatus;
142 T_PARTITION_STATUS *PartitionStatus;
143 T_OVERSIZE_STATUS *PartitionOversize;
144 T_COUNTER *PartitionCounter;
145 T_POOL_GROUP *PoolGroup;
146 #ifdef OPTIMIZE_POOL
147 T_COUNTER *ByteCounter;
148 T_COUNTER *RangeCounter;
149 int *GroupStartRange;
150 int *GroupStartCnt;
151 #endif /* OPTIMIZE_POOL */
152 int ppm_check_partition_owner;
153
154 #else /* RUN_INT_RAM */
155
156 extern int ppm_check_partition_owner;
157 extern T_PARTITION_POOL_STATUS PoolStatus;
158 extern T_POOL_GROUP * PoolGroup;
159 extern USHORT NumOfPrimPools;
160 extern USHORT NumOfDmemPools;
161 extern int *GroupStartRange;
162
163 #endif /* RUN_INT_RAM */
164
165 #ifdef _TOOLS_
166 #pragma data_seg()
167 #endif
168 /* -------------- S H A R E D - END ---------------- */
169
170 /*==== FUNCTIONS ==================================================*/
171
172 GLOBAL void SetPartitionStatus ( T_PARTITION_STATUS *pPoolStatus, const char *file, int line,
173 ULONG opc, USHORT Status, T_HANDLE owner );
174
175 USHORT update_dyn_state ( T_HANDLE Caller, T_PRIM_HEADER *prim, T_HANDLE owner, USHORT state, const char* file, int line );
176 BOOL UpdatePoolCounter ( T_COUNTER *pCounter, T_COUNTER_UPDATE Status, ULONG Value );
177 void StoreRangeCounters ( T_PRIM_HEADER *prim, T_COUNTER_UPDATE Status );
178 int GetPartitionRange ( ULONG size, USHORT group_nr, USHORT pool_nr );
179 LONG get_partition_group ( T_PRIM_HEADER *prim, USHORT *group_nr, USHORT *pool_nr );
180 char const *get_partition_state_name ( USHORT partition_state );
181
182
183 #ifndef RUN_FLASH
184 USHORT update_dyn_state ( T_HANDLE Caller, T_PRIM_HEADER *prim, T_HANDLE owner, USHORT state, const char* file, int line )
185 {
186 T_desc *desc;
187 T_desc3 *desc3;
188 T_M_HEADER *mem;
189 T_DP_HEADER *dp_hdr;
190 USHORT ret = TRUE;
191
192 if ( prim->dph_offset != 0 )
193 {
194 dp_hdr = (T_DP_HEADER*)((ULONG*)prim + prim->dph_offset);
195 if ( *((ULONG*)dp_hdr) == GUARD_PATTERN )
196 {
197 dp_hdr = (T_DP_HEADER*)dp_hdr->next;
198 while (dp_hdr != NULL)
199 {
200 SetPartitionStatus ( &PoolStatus.PartitionStatus [ P_PNR(dp_hdr) ], file, line, P_OPC(prim), state, owner );
201 dp_hdr = (T_DP_HEADER*)dp_hdr->next;
202 }
203 }
204 else
205 {
206 if ( Caller != TST_Handle )
207 {
208 /* do not check and update the states of the primitives in descriptor lists when called by TST, because
209 descriptor lists are not routed to TST and will result in the warning generated below */
210 desc = (T_desc*)(((T_desc_list*)dp_hdr)->first);
211 while (desc != NULL)
212 {
213 #ifdef _NUCLEUS_
214 if ( *(((ULONG*)desc)-4) == 0 )
215 #endif
216 {
217 mem = ((T_M_HEADER*)desc)-1;
218 SetPartitionStatus ( &PoolStatus.PartitionStatus [P_PNR(mem)], file, line, P_OPC(prim), state, owner );
219 if ( mem->desc_type == (VSI_DESC_TYPE3 >> 16) )
220 {
221 desc3 = (T_desc3*)desc;
222 mem = ((T_M_HEADER*)desc3->buffer)-1;
223 SetPartitionStatus ( &PoolStatus.PartitionStatus [P_PNR(mem)], file, line, P_OPC(prim), state, owner );
224 }
225 }
226 #ifdef _NUCLEUS_
227 else
228 vsi_o_ttrace (Caller, TC_SYSTEM,"[PPM]: FREED PARTITION 0x%lx IN DESCLIST, %s(%d)", prim,rm_path(file),line );
229 #endif
230 desc = (T_desc *)desc->next;
231 }
232 }
233 }
234 }
235 else
236 ret = FALSE;
237 return ret;
238 }
239 #endif
240
241 #ifndef RUN_INT_RAM
242 /*
243 +------------------------------------------------------------------------+
244 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
245 | STATE : code ROUTINE : get_partition_state_name|
246 +------------------------------------------------------------------------+
247
248 PURPOSE : update counter.
249
250 */
251 char const *get_partition_state_name ( USHORT state )
252 {
253 USHORT i = 0;
254
255 while ( partition_state[i].state_id )
256 {
257 if ( partition_state[i].state_id == state )
258 return partition_state[i].state_name;
259 i++;
260 }
261 return NULL;
262 }
263 #endif
264
265 #ifndef RUN_FLASH
266 /*
267 +----------------------------------------------------------------------+
268 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
269 | STATE : code ROUTINE : check_partition_group |
270 +----------------------------------------------------------------------+
271
272 PURPOSE : update counter.
273
274 */
275 LONG get_partition_group ( T_PRIM_HEADER *prim, USHORT *group_nr, USHORT *pool_nr )
276 {
277 SHORT invalid_pool = 0;
278 T_HANDLE Caller;
279
280 *pool_nr = PoolGroup [ (USHORT)(P_PGR(prim)) ].pool_nr;
281 *group_nr = PoolGroup [ (USHORT)(P_PGR(prim)) ].group_nr;
282
283 if ( *group_nr > MaxPoolGroups )
284 invalid_pool = 1;
285
286 if ( *group_nr == PrimGroupHandle )
287 {
288 if ( *pool_nr > NumOfPrimPools )
289 invalid_pool = 1;
290 }
291 else if ( *group_nr == DmemGroupHandle )
292 {
293 if ( *pool_nr > NumOfDmemPools )
294 invalid_pool = 1;
295 }
296
297 if ( invalid_pool == 1 )
298 {
299 Caller = e_running[os_MyHandle()];
300 vsi_o_ttrace (Caller, TC_SYSTEM,
301 "[PPM]: Invalid Partition Pool, group: %d, pool: %d", *group_nr, *pool_nr );
302 return VSI_ERROR;
303 }
304
305 return VSI_OK;
306 }
307 #endif
308
309 #ifndef RUN_FLASH
310 /*
311 +--------------------------------------------------------------------+
312 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
313 | STATE : code ROUTINE : GetPartitionRange |
314 +--------------------------------------------------------------------+
315
316 PURPOSE : update counter.
317
318 */
319 int GetPartitionRange ( ULONG size, USHORT group_nr, USHORT pool_nr )
320 {
321 int partition_range;
322 int size_offset;
323 int range;
324
325 if ( pool_nr != 0 )
326 {
327 partition_range = (int)(PARTITION_SIZE(group_nr,pool_nr) - PARTITION_SIZE(group_nr,pool_nr-1));
328
329 size_offset = (int)(size - (USHORT)(PARTITION_SIZE(group_nr,pool_nr-1)) - 1);
330 if ( size_offset < 0 )
331 size_offset = 0;
332 }
333 else
334 {
335 partition_range = (USHORT)(PARTITION_SIZE(group_nr,pool_nr));
336 if ( size == 0 )
337 size_offset = 0;
338 else
339 size_offset = (int)(size - 1);
340 }
341
342 range = (USHORT)((size_offset * RANGES_PER_POOL)/partition_range + pool_nr * RANGES_PER_POOL + GroupStartRange[group_nr]);
343
344 return range;
345 }
346 #endif
347
348 #ifndef RUN_FLASH
349 /*
350 +--------------------------------------------------------------------+
351 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
352 | STATE : code ROUTINE : UpdatePoolCounter |
353 +--------------------------------------------------------------------+
354
355 PURPOSE : update counter.
356
357 */
358 BOOL UpdatePoolCounter ( T_COUNTER *pCounter, T_COUNTER_UPDATE Status, ULONG Value )
359 {
360
361 switch ( Status )
362 {
363 case INCREMENT:
364 pCounter->Total += Value; /* total number */
365 pCounter->Current += Value; /* current number */
366 if ( pCounter->Current > pCounter->Maximum ) /* current > maximum ? */
367 {
368 pCounter->Maximum = pCounter->Current; /* Maximum = Current */
369 return TRUE ;
370 }
371 break;
372 case DECREMENT:
373 pCounter->Current -= Value; /* current number */
374 break;
375 case STORE_MAX_BYTE:
376 pCounter->MaxByteMemory = pCounter->Current; /* store current number */
377 break;
378 case STORE_MAX_PART:
379 pCounter->MaxPartMemory = pCounter->Current; /* store current number */
380 break;
381 }
382 return FALSE;
383 }
384 #endif
385
386 #ifndef RUN_FLASH
387 /*
388 +--------------------------------------------------------------------+
389 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
390 | STATE : code ROUTINE : SetPartitionStatus |
391 +--------------------------------------------------------------------+
392
393 PURPOSE : update the status of the partition.
394
395 */
396 GLOBAL void SetPartitionStatus ( T_PARTITION_STATUS *pPoolStatus, const char *file, int line, ULONG opc, USHORT Status, T_HANDLE owner )
397 {
398
399 pPoolStatus->Status = Status;
400 pPoolStatus->PrimOPC = opc;
401 pPoolStatus->owner = owner;
402 if ( Status NEQ PARTITION_FREED )
403 {
404 os_GetTime (0,&pPoolStatus->time);
405 pPoolStatus->Userfile = file;
406 pPoolStatus->Line = line;
407 }
408 }
409 #endif
410
411 #ifdef OPTIMIZE_POOL
412 #ifndef RUN_FLASH
413 /*
414 +--------------------------------------------------------------------+
415 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
416 | STATE : code ROUTINE : StoreRangeCounters |
417 +--------------------------------------------------------------------+
418
419 PURPOSE : stores the range counters for a specified partition.
420
421 */
422 void StoreRangeCounters ( T_PRIM_HEADER *prim, T_COUNTER_UPDATE Status )
423 {
424 USHORT i;
425
426 for ( i=0; i<5; i++ )
427 UpdatePoolCounter ( &PoolStatus.RangeCounter [ P_PGR(prim)*5+i ], Status,0 );
428 }
429 #endif
430
431 #ifndef RUN_INT_RAM
432 /*
433 +--------------------------------------------------------------------+
434 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
435 | STATE : code ROUTINE : TracePoolStatistic |
436 +--------------------------------------------------------------------+
437
438 PURPOSE : send the statistic information specified by the parameters
439 to the tst interface.
440
441 */
442 LOCAL void TracePoolStatistic ( T_HANDLE Caller, USHORT group_nr, USHORT pool_nr, char const *Src,
443 T_COUNTER_READ Status )
444 {
445 #define RNG_COUNT_IDX(g,p,i) (GroupStartRange[g]+p*RANGES_PER_POOL+i)
446 #define COUNT_IDX(g,p) (GroupStartCnt[g]+p)
447 T_FRM_PARTITION_POOL_CONFIG * pool_config;
448 ULONG Value1;
449 ULONG Value2;
450 char const *Resource;
451 BOOL TraceRange = FALSE;
452 BOOL TraceValue = FALSE;
453 ULONG Value[5];
454 int i;
455
456 pool_config = (T_FRM_PARTITION_POOL_CONFIG*)partition_grp_config[group_nr].grp_config + pool_nr;
457
458 switch ( Status )
459 {
460 case TOTAL:
461 TraceRange = TRUE;
462 for ( i = 0; i < RANGES_PER_POOL; i++ )
463 Value[i] = PoolStatus.RangeCounter [ RNG_COUNT_IDX(group_nr,pool_nr,i) ].Total;
464 break;
465 case CURRENT_BYTE:
466 TraceValue = TRUE;
467 Resource = "max bytes ";
468 Value1 = PoolStatus.ByteCounter [ COUNT_IDX(group_nr,pool_nr) ].Current;
469 Value2 = PoolStatus.PartitionCounter [COUNT_IDX(group_nr,pool_nr)].Current * pool_config->part_size;
470 break;
471 case CURRENT_PART:
472 TraceValue = TRUE;
473 Resource = "part";
474 Value1 = PoolStatus.PartitionCounter [COUNT_IDX(group_nr,pool_nr)].Current;
475 Value2 = pool_config->part_num;
476
477 break;
478 case MAX_RANGES:
479 TraceRange = TRUE;
480 for ( i = 0; i < RANGES_PER_POOL; i++ )
481 Value[i] = PoolStatus.RangeCounter [ RNG_COUNT_IDX(group_nr,pool_nr,i) ].Maximum;
482 break;
483 case MAX_BYTE_MEM:
484 TraceRange = TRUE;
485 TraceValue = TRUE;
486 Resource = "bytes ";
487 Value1 = PoolStatus.ByteCounter [COUNT_IDX(group_nr,pool_nr)].Maximum;
488 Value2 = PoolStatus.PartitionCounter [COUNT_IDX(group_nr,pool_nr)].MaxByteMemory * pool_config->part_size;
489 for ( i = 0; i < RANGES_PER_POOL; i++ )
490 Value[i] = PoolStatus.RangeCounter [ RNG_COUNT_IDX(group_nr,pool_nr,i) ].MaxByteMemory;
491 break;
492 case MAX_PART_MEM:
493 TraceRange = TRUE;
494 TraceValue = TRUE;
495 Resource = "partitions";
496 Value1 = PoolStatus.PartitionCounter [COUNT_IDX(group_nr,pool_nr)].Maximum;
497 Value2 = pool_config->part_num;
498 for ( i = 0; i < RANGES_PER_POOL; i++ )
499 Value[i] = PoolStatus.RangeCounter [ RNG_COUNT_IDX(group_nr,pool_nr,i) ].MaxPartMemory;
500 break;
501 default:
502 break;
503 }
504
505 /*lint -e644, suppress Warning -- Variable may not have been initialized */
506 if ( TraceValue )
507 vsi_o_ttrace (Caller, TC_SYSTEM,"[PPM]: %s pool %d:%5d %s =>%3d%%",
508 Src, pool_nr, Value1, Resource, (Value1*100)/(Value2==0?1:Value2) );
509
510 if ( TraceRange )
511 vsi_o_ttrace (Caller, TC_SYSTEM,"[PPM]: %s partitions pool %d: %3d, %3d, %3d, %3d, %3d",Src, pool_nr,
512 Value[0],Value[1],Value[2],Value[3],Value[4]);
513 /*lint +e644 */
514
515 }
516 #endif
517 #endif /* OPTIMIZE_POOL */
518
519 #ifndef RUN_INT_RAM
520 /*
521 +--------------------------------------------------------------------+
522 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
523 | STATE : code ROUTINE : TracePoolStatus |
524 +--------------------------------------------------------------------+
525
526 PURPOSE : send the statistic information to the test interface.
527
528 */
529 GLOBAL void TracePoolstatus ( T_HANDLE Caller )
530 {
531 T_PARTITION_STATUS *pPoolStatus;
532 T_FRM_PARTITION_POOL_CONFIG * pool_config;
533 USHORT i, m;
534 USHORT group_nr, pool_nr;
535 USHORT PartitionError = FALSE, OversizeError = FALSE;
536 T_OVERSIZE_STATUS *pOversizeStatus;
537 T_HANDLE owner;
538 char *opc;
539
540 pOversizeStatus = &PoolStatus.PartitionOversize[0];
541 pPoolStatus = &PoolStatus.PartitionStatus [0];
542 for ( i = 0; i < NumberOfPPMPartitions; i++ )
543 {
544 if ( pPoolStatus->Status > 0 && pPoolStatus->Status NEQ PARTITION_FREED )
545 {
546 if ( pPoolStatus->owner & OWNER_IS_COM_HANDLE )
547 owner = pPoolStatus->owner&~OWNER_IS_COM_HANDLE;
548 else
549 owner = pPoolStatus->owner;
550
551 if ( pPoolStatus->PrimOPC && ( ((T_PRIM_HEADER*)pPoolStatus->ptr)->opc != pPoolStatus->PrimOPC ) )
552 opc = "in desclist of OPC";
553 else
554 opc = "OPC";
555 get_partition_group ( pPoolStatus->ptr, &group_nr, &pool_nr );
556
557 pool_config = (T_FRM_PARTITION_POOL_CONFIG*)partition_grp_config[group_nr].grp_config + pool_nr;
558
559 vsi_o_ttrace ( Caller, TC_SYSTEM, "POOL%d%d(%s), PARTITION 0x%lx(%d), %s 0x%lx, \
560 %s, %s, TIME %d, %s(%d)", group_nr,pool_nr,partition_grp_config[group_nr].name, pPoolStatus->ptr,pool_config->part_size,
561 opc, pPoolStatus->PrimOPC, get_partition_state_name(pPoolStatus->Status), pf_TaskTable[owner].Name, pPoolStatus->time,
562 rm_path(pPoolStatus->Userfile), pPoolStatus->Line);
563 PartitionError = TRUE;
564 }
565 pPoolStatus++;
566 }
567
568 for (m = 0; partition_grp_config[m].grp_config != NULL; m++ )
569 {
570 if ( strcmp ("TEST", partition_grp_config[m].name ) )
571 {
572 vsi_o_ttrace ( Caller, TC_SYSTEM, "---------------------------------------------------------" );
573 vsi_o_ttrace ( Caller, TC_SYSTEM, "[PPM]: POOL NAME: %s", partition_grp_config[m].name );
574 pool_config = (T_FRM_PARTITION_POOL_CONFIG*)partition_grp_config[m].grp_config;
575 for ( i = 0; pool_config != NULL; i++)
576 {
577 if ( pool_config->part_size )
578 {
579 #ifdef OPTIMIZE_POOL
580 vsi_o_ttrace ( Caller, TC_SYSTEM, "---------------------------------------------------------" );
581 vsi_o_ttrace ( Caller, TC_SYSTEM, "[PPM]: POOL %d (size %d) ",i, pool_config->part_size );
582 TracePoolStatistic ( Caller, m, i, "MAXBYTE ", MAX_BYTE_MEM );
583 TracePoolStatistic ( Caller, m, i, "MAXPART ", MAX_PART_MEM );
584 TracePoolStatistic ( Caller, m, i, "MAXRANGE", MAX_RANGES );
585 TracePoolStatistic ( Caller, m, i, "TOTAL ", TOTAL );
586 #endif /* OPTIMIZE_POOL */
587 if ( pOversizeStatus->PrimOPC )
588 {
589 vsi_o_ttrace ( Caller, TC_SYSTEM, "PPM: PARTITION OF SIZE %d USED BY OVERSIZED \
590 PRIMITIVE %lx AT %s(%d)", pool_config->part_size,
591 pOversizeStatus->PrimOPC, rm_path(pOversizeStatus->Userfile), pPoolStatus->Line);
592 OversizeError = TRUE;
593 }
594 pOversizeStatus++;
595 }
596 else
597 {
598 break;
599 }
600 pool_config++;
601 }
602 if ( !PartitionError )
603 vsi_o_ttrace ( Caller, TC_SYSTEM, "[PPM]: ALL PARTITIONS FREED" );
604 if ( !OversizeError )
605 vsi_o_ttrace ( Caller, TC_SYSTEM, "[PPM]: NO OVERSIZE ERRORS OCCURED" );
606 }
607 }
608
609 }
610 #endif
611
612 #ifndef RUN_INT_RAM
613 /*
614 +--------------------------------------------------------------------+
615 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
616 | STATE : code ROUTINE : InitializePPM |
617 +--------------------------------------------------------------------+
618
619 PURPOSE : initialize supervision, write index to each partition.
620
621 */
622 void InitializePPM ( void )
623 {
624 T_FRM_PARTITION_POOL_CONFIG * pool_config;
625 ULONG *Prims;
626 USHORT i,j,k,m,n;
627 int status;
628 static int last_range = 0;
629 static int last_cnt = 0;
630
631 status = os_AllocateMemory (NO_TASK, (T_VOID_STRUCT**)&Prims, sizeof(int)*NumberOfPPMPartitions, OS_NO_SUSPEND, ext_data_pool_handle );
632 status |= os_AllocateMemory (NO_TASK, (T_VOID_STRUCT**)&PoolGroup, sizeof(T_POOL_GROUP)*NumOfPPMPools, OS_NO_SUSPEND, ext_data_pool_handle );
633 status |= os_AllocateMemory (NO_TASK, (T_VOID_STRUCT**)&PartitionStatus, sizeof(T_PARTITION_STATUS)*NumberOfPPMPartitions, OS_NO_SUSPEND, ext_data_pool_handle );
634 status |= os_AllocateMemory (NO_TASK, (T_VOID_STRUCT**)&PartitionOversize, sizeof(T_OVERSIZE_STATUS)*NumOfPPMPools, OS_NO_SUSPEND, ext_data_pool_handle );
635 status |= os_AllocateMemory (NO_TASK, (T_VOID_STRUCT**)&PartitionCounter, sizeof(T_COUNTER)*NumOfPPMPools, OS_NO_SUSPEND, ext_data_pool_handle );
636 #ifdef OPTIMIZE_POOL
637 status |= os_AllocateMemory (NO_TASK, (T_VOID_STRUCT**)&ByteCounter, sizeof(T_COUNTER)*NumOfPPMPools, OS_NO_SUSPEND, ext_data_pool_handle );
638 status |= os_AllocateMemory (NO_TASK, (T_VOID_STRUCT**)&RangeCounter, sizeof(T_COUNTER)*NumberOfPPMPartitions, OS_NO_SUSPEND, ext_data_pool_handle );
639 status |= os_AllocateMemory (NO_TASK, (T_VOID_STRUCT**)&GroupStartRange, sizeof(int)*NumOfPPMGroups, OS_NO_SUSPEND, ext_data_pool_handle );
640 status |= os_AllocateMemory (NO_TASK, (T_VOID_STRUCT**)&GroupStartCnt, sizeof(int)*NumOfPPMGroups, OS_NO_SUSPEND, ext_data_pool_handle );
641 #endif
642 if ( status > 0 )
643 {
644 vsi_o_assert ( 0, OS_SYST_ERR, __FILE__, __LINE__, "Memory allocation for partition supervision failed" );
645 }
646 ppm_check_partition_owner = 0;
647 PoolStatus.PartitionStatus = PartitionStatus;
648 PoolStatus.PartitionOversize = PartitionOversize;
649 PoolStatus.PartitionCounter = PartitionCounter;
650 #ifdef OPTIMIZE_POOL
651 PoolStatus.ByteCounter = ByteCounter;
652 PoolStatus.RangeCounter = RangeCounter;
653 #endif
654
655 for ( j = 0; j<NumberOfPPMPartitions; j++)
656 Prims[j] = 0;
657
658 for (m = 0, j = 0, i = 0; partition_grp_config[m].grp_config != NULL; m++ )
659 {
660 if ( strcmp ("TEST", partition_grp_config[m].name ) )
661 {
662 pool_config = (T_FRM_PARTITION_POOL_CONFIG*)partition_grp_config[m].grp_config;
663
664 for (n = 0; pool_config != NULL; i++, n++)
665 {
666 if ( pool_config->part_size )
667 {
668 PoolGroup[i].group_nr = m;
669 PoolGroup[i].pool_nr = n;
670 for (k = 0; k < pool_config->part_num; k++ , j++)
671 {
672 if ( os_AllocatePartition ( NO_TASK, (T_VOID_STRUCT**)&Prims[j], pool_config->part_size,
673 OS_NO_SUSPEND, *PoolGroupHandle[m] ) == OS_OK )
674 {
675 P_IDX((T_PRIM_HEADER*)(Prims[j]+PPM_IDX_OFFSET)) = ( ((USHORT)i<<16) | j );
676 }
677 else
678 {
679 P_IDX((T_PRIM_HEADER*)(Prims[j]+PPM_IDX_OFFSET)) = 0;
680 }
681 }
682 }
683 else
684 {
685 break;
686 }
687 pool_config++;
688 }
689 if ( m == 0 )
690 {
691 GroupStartCnt[m] = 0;
692 GroupStartRange[m] = 0;
693 last_cnt = n;
694 last_range = RANGES_PER_POOL * n;
695 }
696 else
697 {
698 GroupStartCnt[m] = last_cnt;
699 GroupStartRange[m] = last_range;
700 last_cnt = GroupStartCnt[m] + n;
701 last_range = GroupStartRange[m] + RANGES_PER_POOL * n;
702 }
703
704 }
705 }
706 for ( j = 0; j<NumberOfPPMPartitions; j++)
707 {
708 if ( Prims[j] )
709 {
710 os_DeallocatePartition ( NO_TASK, (T_VOID_STRUCT*)Prims[j] );
711 PoolStatus.PartitionStatus [ P_PNR(Prims[j]+4) ].Status = PARTITION_FREED;
712 }
713 }
714 }
715 #endif
716
717 #ifndef RUN_FLASH
718 /*
719 +--------------------------------------------------------------------+
720 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
721 | STATE : code ROUTINE : vsi_ppm_new |
722 +--------------------------------------------------------------------+
723
724 PURPOSE : supervision of allocating a partition.
725
726 */
727 GLOBAL void vsi_ppm_new ( T_HANDLE Caller, ULONG Size, T_PRIM_HEADER *prim, const char* file, int line )
728 {
729 T_PARTITION_STATUS *pPoolStatus;
730 USHORT group_nr, pool_nr;
731
732 if ( prim != NULL )
733 {
734 if ( get_partition_group ( prim, &group_nr, &pool_nr ) == VSI_OK )
735 {
736 vsi_ppm_setend(prim, Size);
737 /*
738 * set pointer to status entry of the currently used partition
739 */
740 pPoolStatus = &PoolStatus.PartitionStatus [ P_PNR(prim) ];
741
742 pPoolStatus->ptr = prim;
743 /*
744 * send error message in case of an illegal state transition
745 */
746 if ( pPoolStatus->Status & FORBIDDEN_ALLOCATE_STATES )
747 vsi_o_ttrace (Caller, TC_SYSTEM,
748 "[PPM]: %s->%s: %s(%d)", get_partition_state_name(pPoolStatus->Status),
749 get_partition_state_name(PARTITION_ALLOCATED),rm_path(file),line );
750
751 /*
752 * update partition status
753 */
754 SetPartitionStatus ( pPoolStatus, file, line, P_OPC(prim), PARTITION_ALLOCATED, Caller );
755
756 #ifdef OPTIMIZE_POOL
757 /*
758 * get primitive size and update range counter
759 */
760 pPoolStatus->UsedSize = Size;
761 UpdatePoolCounter ( &PoolStatus.RangeCounter [GetPartitionRange(pPoolStatus->UsedSize,group_nr,pool_nr)], INCREMENT,1 );
762 #endif /* OPTIMIZE_POOL */
763
764 /*
765 * update partition counter, if new maximum and OPTIMIZE_POOL, then
766 * - store the counters of the ranges within this partition
767 * - send a message that a new maximum has occurred
768 */
769 if ( UpdatePoolCounter ( &PoolStatus.PartitionCounter [P_PGR(prim)],INCREMENT,1 ) )
770 #ifndef OPTIMIZE_POOL
771 ;
772 #else
773 {
774 StoreRangeCounters ( prim, STORE_MAX_PART );
775 }
776
777 /*
778 * update byte counter, if new maximum, then
779 * - store the counters of the ranges within this partition
780 * - store the number of currently allocated partitions
781 */
782 if ( UpdatePoolCounter ( &PoolStatus.ByteCounter [P_PGR(prim)],INCREMENT,pPoolStatus->UsedSize ) )
783 {
784 StoreRangeCounters ( prim, STORE_MAX_BYTE );
785 UpdatePoolCounter ( &PoolStatus.PartitionCounter [ P_PGR(prim) ], STORE_MAX_BYTE,0 );
786 }
787 #endif /* OPTIMIZE_POOL */
788 }
789 else
790 vsi_o_ttrace (Caller, TC_SYSTEM,"[PPM]: Invalid Partition Pool, group: %d, pool: %d", group_nr, pool_nr );
791 }
792 }
793 #endif
794
795 #ifndef RUN_FLASH
796 /*
797 +--------------------------------------------------------------------+
798 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
799 | STATE : code ROUTINE : vsi_ppm_rec |
800 +--------------------------------------------------------------------+
801
802 PURPOSE : supervision of receiving a partition.
803
804 */
805 GLOBAL void vsi_ppm_rec ( T_HANDLE Caller, T_PRIM_HEADER *prim, const char *file, int line )
806 {
807 T_PARTITION_STATUS *pPoolStatus;
808 USHORT group_nr, pool_nr;
809
810 if ( prim != NULL )
811 {
812 if ( get_partition_group ( prim, &group_nr, &pool_nr ) == VSI_OK )
813 {
814 Caller = e_running[os_MyHandle()];
815 /*
816 * set pointer to status entry of the currently used partition
817 */
818 pPoolStatus = &PoolStatus.PartitionStatus [ P_PNR(prim) ];
819
820 /*
821 * send error message in case of an illegal state transition
822 */
823 if ( pPoolStatus->Status & FORBIDDEN_RECEIVE_STATES )
824 vsi_o_ttrace (Caller, TC_SYSTEM,
825 "[PPM]: %s->%s: %s(%d)", get_partition_state_name(pPoolStatus->Status),
826 get_partition_state_name(PARTITION_RECEIVED),rm_path(file),line );
827
828 /*
829 * update partition status
830 */
831 SetPartitionStatus ( pPoolStatus, file, line, P_OPC(prim), PARTITION_RECEIVED, Caller );
832 update_dyn_state ( Caller, prim, Caller, PARTITION_RECEIVED, file, line );
833 }
834 else
835 vsi_o_ttrace (Caller, TC_SYSTEM,"[PPM]: Invalid Partition Pool, group: %d, pool: %d", group_nr, pool_nr );
836 }
837 }
838 #endif
839
840 #ifndef RUN_INT_RAM
841 /*
842 +--------------------------------------------------------------------+
843 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
844 | STATE : code ROUTINE : vsi_ppm_access |
845 +--------------------------------------------------------------------+
846
847 PURPOSE : supervision of receiving a partition.
848
849 */
850 GLOBAL void vsi_ppm_access ( T_HANDLE Caller, T_PRIM_HEADER *prim, const char *file, int line )
851 {
852 T_PARTITION_STATUS *pPoolStatus;
853 USHORT group_nr, pool_nr;
854
855 if ( prim != NULL )
856 {
857 if ( get_partition_group ( prim, &group_nr, &pool_nr ) == VSI_OK )
858 {
859 Caller = e_running[os_MyHandle()];
860 /*
861 * set pointer to status entry of the currently used partition
862 */
863 pPoolStatus = &PoolStatus.PartitionStatus [ P_PNR(prim) ];
864
865 /*
866 * send error message in case of an illegal state transition
867 */
868 if ( pPoolStatus->Status & FORBIDDEN_ACCESS_STATES )
869 vsi_o_ttrace (Caller, TC_SYSTEM,
870 "[PPM]: %s->%s: %s(%d)", get_partition_state_name(pPoolStatus->Status),
871 get_partition_state_name(PARTITION_ACCESSED),rm_path(file),line );
872
873 /*
874 * update partition status
875 */
876 SetPartitionStatus ( pPoolStatus, file, line, P_OPC(prim), pPoolStatus->Status, Caller );
877 update_dyn_state ( Caller, prim, Caller, PARTITION_ACCESSED, file, line );
878 }
879 else
880 vsi_o_ttrace (Caller, TC_SYSTEM,"[PPM]: Invalid Partition Pool, group: %d, pool: %d", group_nr, pool_nr );
881 }
882 }
883 #endif
884
885 #ifndef RUN_FLASH
886 /*
887 +--------------------------------------------------------------------+
888 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
889 | STATE : code ROUTINE : vsi_ppm_send |
890 +--------------------------------------------------------------------+
891
892 PURPOSE : supervision of receiving a partition.
893
894 */
895 GLOBAL void vsi_ppm_send ( T_HANDLE Caller, T_HANDLE rcv, T_PRIM_HEADER *prim, const char *file, int line )
896 {
897 T_PARTITION_STATUS *pPoolStatus;
898 USHORT NewStatus = PARTITION_SENT;
899 USHORT group_nr, pool_nr;
900
901 if ( prim != NULL )
902 {
903 if ( get_partition_group ( prim, &group_nr, &pool_nr ) == VSI_OK )
904 {
905 Caller = e_running[os_MyHandle()];
906 /*
907 * set pointer to status entry of the currently used partition
908 */
909 pPoolStatus = &PoolStatus.PartitionStatus [ P_PNR(prim) ];
910
911
912 /*
913 * send error message in case of an illegal state transition
914 */
915 if ( pPoolStatus->Status & FORBIDDEN_SEND_STATES )
916 vsi_o_ttrace (Caller, TC_SYSTEM,
917 "[PPM]: %s->%s: %s(%d)", get_partition_state_name(pPoolStatus->Status),
918 get_partition_state_name(PARTITION_SENT),rm_path(file),line );
919
920 /*
921 * check if more bytes written than requested during allocation
922 */
923 if ( *((char*)prim + pPoolStatus->RequestedSize - 1) != PPM_END_MARKER )
924 {
925 if ( prim->dph_offset == 0 )
926 vsi_o_ttrace ( NO_TASK, TC_SYSTEM, "SYSTEM WARNING: Bytes written > requested partition size, %s(%d)", rm_path(file), line );
927 }
928 /*
929 * update partition status
930 */
931 SetPartitionStatus ( pPoolStatus, file, line, P_OPC(prim), NewStatus, (T_HANDLE)(OWNER_IS_COM_HANDLE|rcv) );
932 update_dyn_state ( Caller, prim, rcv, PARTITION_SENT, file, line );
933 }
934 else
935 vsi_o_ttrace (Caller, TC_SYSTEM,"[PPM]: Invalid Partition Pool, group: %d, pool: %d", group_nr, pool_nr );
936 }
937 }
938 #endif
939
940 #ifndef RUN_INT_RAM
941 /*
942 +--------------------------------------------------------------------+
943 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
944 | STATE : code ROUTINE : vsi_ppm_store |
945 +--------------------------------------------------------------------+
946
947 PURPOSE : supervision of storing a partition.
948
949 */
950 GLOBAL void vsi_ppm_store ( T_HANDLE Caller, T_PRIM_HEADER *prim, const char *file, int line )
951 {
952 T_PARTITION_STATUS *pPoolStatus;
953 USHORT group_nr, pool_nr;
954
955 if ( prim != NULL )
956 {
957 if ( get_partition_group ( prim, &group_nr, &pool_nr ) == VSI_OK )
958 {
959 Caller = e_running[os_MyHandle()];
960 /*
961 * set pointer to status entry of the currently used partition
962 */
963 pPoolStatus = &PoolStatus.PartitionStatus [ P_PNR(prim) ];
964
965 /*
966 * send error message in case of an illegal state transition
967 */
968 if ( pPoolStatus->Status & FORBIDDEN_STORE_STATES )
969 vsi_o_ttrace (Caller, TC_SYSTEM,
970 "[PPM]: %s->%s: %s(%d)", get_partition_state_name(pPoolStatus->Status),
971 get_partition_state_name(PARTITION_STORED),rm_path(file),line );
972
973 /*
974 * update partition status
975 */
976 SetPartitionStatus ( pPoolStatus, file, line, P_OPC(prim), pPoolStatus->Status, Caller );
977 }
978 else
979 vsi_o_ttrace (Caller, TC_SYSTEM,"[PPM]: Invalid Partition Pool, group: %d, pool: %d", group_nr, pool_nr );
980 }
981 }
982 #endif
983
984 #ifndef RUN_INT_RAM
985 /*
986 +--------------------------------------------------------------------+
987 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
988 | STATE : code ROUTINE : vsi_ppm_reuse |
989 +--------------------------------------------------------------------+
990
991 PURPOSE : supervision of reusing a partition.
992
993 */
994 GLOBAL void vsi_ppm_reuse ( T_HANDLE Caller, T_PRIM_HEADER *prim, const char *file, int line )
995 {
996 T_PARTITION_STATUS *pPoolStatus;
997 ULONG OldSize, NewSize;
998 USHORT group_nr, pool_nr;
999
1000 if ( prim != NULL )
1001 {
1002 if ( get_partition_group ( prim, &group_nr, &pool_nr ) == VSI_OK )
1003 {
1004 Caller = e_running[os_MyHandle()];
1005 /*
1006 * set pointer to status entry of the currently used partition
1007 */
1008 pPoolStatus = &PoolStatus.PartitionStatus [ P_PNR(prim) ];
1009
1010 /*
1011 * send error message in case of an illegal state transition
1012 */
1013 if ( pPoolStatus->Status & FORBIDDEN_REUSE_STATES )
1014 vsi_o_ttrace (Caller, TC_SYSTEM,
1015 "[PPM]: %s->%s: %s(%d)", get_partition_state_name(pPoolStatus->Status),
1016 get_partition_state_name(PARTITION_REUSED),rm_path(file),line );
1017
1018 /*
1019 * update partition status
1020 */
1021 SetPartitionStatus ( pPoolStatus, file, line, P_OPC(prim), PARTITION_REUSED, Caller );
1022 update_dyn_state ( Caller, prim, Caller, PARTITION_REUSED, file, line );
1023 /*
1024 * if the new primitive exceeds the size of the partition, then
1025 * - store file, line and primitive opc
1026 * - send an error message
1027 */
1028 #if 0
1029 if ( (ULONG)(P_LEN(prim)) > PoolGroupConfig[PrimGroupHandle]->PoolConfig[P_PGR(prim)].PartitionSize )
1030 {
1031 PoolStatus.PartitionOversize [P_PGR(prim)].Userfile = file;
1032 PoolStatus.PartitionOversize [P_PGR(prim)].Line = line;
1033 PoolStatus.PartitionOversize [P_PGR(prim)].PrimOPC = P_OPC(prim);
1034 vsi_o_assert (NO_TASK, OS_SYST_ERR_OVERSIZE, file, line, "PREUSE - oversize error in %s",
1035 pf_TaskTable[Caller].Name );
1036 }
1037 #endif
1038 #ifdef OPTIMIZE_POOL
1039 /*
1040 * if the old and new primitve have different sizes, then
1041 * - decrement byte counter by old size
1042 * - decrement old range counter
1043 * - increment new range counter
1044 * - increment byte counter by new size
1045 */
1046 if ( (OldSize=pPoolStatus->UsedSize) NEQ (NewSize=P_LEN(prim)) )
1047 {
1048 UpdatePoolCounter ( &PoolStatus.ByteCounter [P_PGR(prim)],DECREMENT,OldSize );
1049 UpdatePoolCounter ( &PoolStatus.RangeCounter [ GetPartitionRange(OldSize,group_nr,pool_nr) ], DECREMENT, 1 );
1050 UpdatePoolCounter ( &PoolStatus.RangeCounter [ GetPartitionRange(NewSize,group_nr,pool_nr) ], INCREMENT, 1 );
1051 pPoolStatus->UsedSize = NewSize;
1052 if ( UpdatePoolCounter ( &PoolStatus.ByteCounter [P_PGR(prim)],INCREMENT,NewSize ) )
1053 {
1054 StoreRangeCounters ( prim, STORE_MAX_BYTE );
1055 UpdatePoolCounter ( &PoolStatus.PartitionCounter [ P_PGR(prim) ], STORE_MAX_BYTE,0 );
1056 }
1057 }
1058 #endif /* OPTIMIZE_POOL */
1059 }
1060 else
1061 vsi_o_ttrace (Caller, TC_SYSTEM,"[PPM]: Invalid Partition Pool, group: %d, pool: %d", group_nr, pool_nr );
1062 }
1063 }
1064 #endif
1065
1066 #ifndef RUN_FLASH
1067 /*
1068 +--------------------------------------------------------------------+
1069 | PROJECT : GSM-Frame (8415) MODULE : VSI_PPM |
1070 | STATE : code ROUTINE : vsi_ppm_free |
1071 +--------------------------------------------------------------------+
1072
1073 PURPOSE : supervision of deallocating a partition.
1074
1075 */
1076 GLOBAL void vsi_ppm_free ( T_HANDLE Caller, T_PRIM_HEADER *prim, const char *file, int line )
1077 {
1078 T_PARTITION_STATUS *pPoolStatus;
1079 USHORT group_nr, pool_nr;
1080 T_HANDLE owner;
1081
1082 if ( prim != NULL )
1083 {
1084 if ( get_partition_group ( prim, &group_nr, &pool_nr ) == VSI_OK )
1085 {
1086 Caller = e_running[os_MyHandle()];
1087 prim->opc = 0;
1088 /*
1089 * set pointer to status entry of the currently used partition
1090 */
1091 pPoolStatus = &PoolStatus.PartitionStatus [ P_PNR(prim) ];
1092
1093 /*
1094 * send error message in case of an illegal state transition
1095 */
1096 if ( pPoolStatus->Status & FORBIDDEN_DEALLOCATE_STATES )
1097 vsi_o_ttrace (Caller, TC_SYSTEM,
1098 "[PPM]: %s->%s: %s(%d)", get_partition_state_name(pPoolStatus->Status),
1099 get_partition_state_name(PARTITION_FREED),file,line );
1100
1101
1102 /* CURRENTLY DISABLED FOR UMTS RELEASE */
1103 if ( pPoolStatus->owner & OWNER_IS_COM_HANDLE )
1104 {
1105 owner = pPoolStatus->owner&~OWNER_IS_COM_HANDLE;
1106 vsi_o_ttrace (NO_TASK, TC_SYSTEM,
1107 "SYSTEM WARNING: %s freed partition stored in %s queue, %s(%d)",
1108 pf_TaskTable[Caller].Name,pf_TaskTable[owner].Name,rm_path(file),line );
1109 }
1110 if ( ppm_check_partition_owner == 1 )
1111 {
1112 if ( (pPoolStatus->owner & ~OWNER_IS_COM_HANDLE) != Caller )
1113 {
1114 owner = pPoolStatus->owner&~OWNER_IS_COM_HANDLE;
1115 vsi_o_ttrace (NO_TASK, TC_SYSTEM,
1116 "SYSTEM WARNING: %s freed partition belonging to %s, %s(%d)",
1117 pf_TaskTable[Caller].Name,pf_TaskTable[owner].Name,rm_path(file),line );
1118 }
1119 }
1120
1121 if ( !(pPoolStatus->Status & PARTITION_FREED) )
1122 {
1123 #ifdef OPTIMIZE_POOL
1124 /*
1125 * decrement byte counter by primitive size
1126 * decrement range counter
1127 * decrement partition counter
1128 */
1129 UpdatePoolCounter ( &PoolStatus.ByteCounter [ P_PGR(prim) ], DECREMENT, pPoolStatus->UsedSize );
1130 UpdatePoolCounter ( &PoolStatus.RangeCounter [GetPartitionRange(pPoolStatus->UsedSize,group_nr,pool_nr)], DECREMENT, 1 ) ;
1131 #endif /* OPTIMIZE_POOL */
1132 UpdatePoolCounter ( &PoolStatus.PartitionCounter [ P_PGR(prim) ], DECREMENT, 1 );
1133 }
1134
1135 /*
1136 * update partition status
1137 */
1138 SetPartitionStatus ( pPoolStatus, file, line, 0, PARTITION_FREED, 0 );
1139 }
1140 else
1141 vsi_o_ttrace (Caller, TC_SYSTEM,"[PPM]: Invalid Partition Pool, group: %d, pool: %d", group_nr, pool_nr );
1142 }
1143 }
1144 #endif
1145
1146 #ifndef RUN_FLASH
1147 GLOBAL void vsi_ppm_setend ( T_PRIM_HEADER *prim, ULONG size )
1148 {
1149 *((char*)prim + size ) = PPM_END_MARKER;
1150 PoolStatus.PartitionStatus[P_PNR(prim)].RequestedSize = size+1;
1151 }
1152 #endif
1153 #endif /* MEMORY_SUPERVISION */