FreeCalypso > hg > freecalypso-sw
annotate nuc-fw/riviera/rvf/rvf_buffer.c @ 132:2c5160a9d652
nuc-fw: switched from nucdemo to Riviera, got some serial output
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 02 Nov 2013 01:48:11 +0000 |
parents | dd56546ad9e0 |
children |
rev | line source |
---|---|
118
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /****************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 /* */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 /* Name rvf_buffer.c */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 /* */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 /* Function this file contains rvf buffer handling functions */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 /* */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 /* Version 0.1 */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 /* */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 /* Date Modification */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 /* ------------------------------------ */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 /* 3/12/99 Create */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 /* 10/27/1999 remove all non-nucleus sections (#ifdef) */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 /* 30/11/1999 compliant to RV coding guidelines */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 /* 12/23/1999 change buffer management, add memory bank handling and */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 /* remove useless functions */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 /* 07/12/2000 implement dynamic memory allocation. */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 /* */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 /* Author David Lamy-Charrier (dlamy@tif.ti.com) */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 /* */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 /* (C) Copyright 1999 by Texas Instruments Incorporated, All Rights Reserved*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 /****************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 |
119
dd56546ad9e0
starting to compile RVF
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
23 #include "../../include/config.h" |
118
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 |
119
dd56546ad9e0
starting to compile RVF
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
25 #include "../rvm/rvm_use_id_list.h" |
dd56546ad9e0
starting to compile RVF
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
26 #include "rvf_api.h" |
dd56546ad9e0
starting to compile RVF
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
27 #include "rvf_i.h" |
dd56546ad9e0
starting to compile RVF
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
28 #include "../support/exception.h" |
dd56546ad9e0
starting to compile RVF
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
29 #include "rvf_pool_size.h" |
dd56546ad9e0
starting to compile RVF
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
30 |
dd56546ad9e0
starting to compile RVF
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
31 #include "../../nucleus/nucleus.h" |
118
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 #include <string.h> |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 #include <stdio.h> |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 #if RVF_ENABLE_STATS /* conditional inclusion of stdio.h for sprintf() function */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 #ifdef _WINDOWS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 #include <stdio.h> |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 |
119
dd56546ad9e0
starting to compile RVF
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
118
diff
changeset
|
43 #include "../rv/rv_defined_swe.h" |
118
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 #ifdef RVM_DAR_SWE |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 #include "dar/dar_api.h" |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 #define RVF_INVALID_MD_ID_ERRROR ("RVF: Invalid MB ID") |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 #define INC_END_INITIALIZE 2 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 #define RVF_INVALID_INDEX 0xFFFF |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 /************* TASK MAILBOXES *******************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 /* chained lists for task mailboxes */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 T_RVF_INTERNAL_BUF *OSTaskQFirst[1][1]; //[MAX_RVF_TASKS][RVF_NUM_TASK_MBOX]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 T_RVF_INTERNAL_BUF *OSTaskQLast [1][1]; //[MAX_RVF_TASKS][RVF_NUM_TASK_MBOX]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 extern INC_Initialize_State; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 T_RVF_RT_ADDR_ID_DATA* pRtAddrIdTable[MAX_RVF_G_ADDR_ID]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 /******** MEMORY POOLS ******************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 /* Define the buffer pools */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 extern T_RVF_POOL _rvf_pools[]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 /*********** MEMORY BANKS ***********/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 /* array of memory bank */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 static T_RVF_MB rvf_banks[RVF_MAX_REAL_MB]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 /* array of waiting buffers */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 static T_RVF_BUFFER * waiting_buffers[RVF_MAX_WAITING_BUF]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 static UINT16 next_buffer[RVF_MAX_WAITING_BUF]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 static UINT16 first_free_element; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 /* array of memory bank name and id*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 static T_RVF_MB_NAME_ID rvf_name_id[RVF_MAX_TOTAL_MB] = RVF_MB_MAPPING; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 /* variable for statistics */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 #if RVF_ENABLE_STATS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 static UINT32 required_size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 static UINT32 obtained_size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 static UINT32 used_size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 static UINT32 mem_in_use = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 /* lists of free buffers */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 static T_RVF_INTERNAL_BUF * lists[RVF_NB_FREE_LISTS]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 /* last split-off buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 T_RVF_INTERNAL_BUF * last_remainder = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 /* allocated static buffer pools */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 extern UINT8 Buf0[]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 extern UINT8 Buf1[]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 /********Internal windows function used to display memory status *******/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 #ifdef _WINDOWS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 extern void AddNewState(void *s,char *name, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 unsigned long current,unsigned long peak, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 unsigned long water,unsigned long bank); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 ** Function _rvf_init_free_queue |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 ** Description Function called at startup to initialize a free |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 ** pool (statically or dynamically allocated). |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 ** It is called once for each free pool. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 ** Returns void |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 void _rvf_init_free_queue (UINT8 id, UINT32 size, void *p_mem) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 T_RVF_INTERNAL_BUF *hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 UINT8 list_idx; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 /* round to up size to a multiple of 4 */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 size = (size + 3) & ~0x0003; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 /* store pool start address and size */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 _rvf_pools[id].start_address = p_mem; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 _rvf_pools[id].pool_size = size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 /* Initialize the pool as a big free buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 hdr = (T_RVF_INTERNAL_BUF *) p_mem; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 hdr->buf_size = size - sizeof(T_RVF_INTERNAL_BUF) - sizeof(UINT32); /* last 4 bytes of the pool losts*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 hdr->header.p_prev = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 RVF_SET_PREV_IN_USE(hdr); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 NEXTCHUNK(hdr)->buf_size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 ENDSIZE(hdr) = hdr->buf_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 /* get the corresponding list and insert the buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 list_idx = RVF_BUF_LIST_INDEX( hdr->buf_size); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 hdr->p_next = lists[list_idx]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 lists[list_idx] = hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 last_remainder = hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 void rvf_mbox_buffer_init(T_RVF_RT_ADDR_ID_DATA* pRtAddrIdElement) { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 UINT8 task_num, mbox_num; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 /* Initialize all mailboxes queues of all tasks*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 for (task_num = 0; task_num < MAX_RVF_TASKS; task_num++) { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 for (mbox_num = 0; mbox_num < RVF_NUM_TASK_MBOX; mbox_num++) { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 pRtAddrIdElement->OSTaskQFirst[mbox_num] = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 pRtAddrIdElement->OSTaskQLast[mbox_num] = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 ** Function _rvf_buffer_init |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 ** Description Called once internally by rvf at startup to initialize all |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 ** buffers and free buffer pools. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 ** Returns void |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
170 void _rvf_buffer_init(void) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 UINT8 list_num; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 UINT16 memory_bank_num; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 /* Initialize all mailboxes queues of all tasks*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 /* for (task_num = 0; task_num < MAX_RVF_TASKS; task_num++) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 for (mbox_num = 0; mbox_num < RVF_NUM_TASK_MBOX; mbox_num++) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 OSTaskQFirst[task_num][mbox_num] = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 OSTaskQLast [task_num][mbox_num] = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 //pRtAddrIdTable[task_num]->OSTaskQFirst[mbox_num] = NULL; // only if static |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
183 //pRtAddrIdTable[task_num]->OSTaskQLast[mbox_num] = NULL; // only if static |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 } */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 /* initialize free lists */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 for (list_num = 0; list_num < RVF_NB_FREE_LISTS; list_num++) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 lists[list_num] = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
191 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
192 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
193 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
194 /* initialize buffer pools */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
195 _rvf_init_mem_pool(); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
196 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
197 /* Initialize real memory banks */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
198 for (memory_bank_num = 0; memory_bank_num < RVF_MAX_REAL_MB; memory_bank_num++) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
199 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
200 rvf_banks[memory_bank_num].cur_memory_used = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
201 rvf_banks[memory_bank_num].watermark = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
202 rvf_banks[memory_bank_num].max = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
203 rvf_banks[memory_bank_num].first_buffer_index = RVF_INVALID_INDEX; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
204 rvf_banks[memory_bank_num].last_buffer_index = RVF_INVALID_INDEX; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
205 rvf_banks[memory_bank_num].func = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
206 rvf_banks[memory_bank_num].returned_red = FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
207 #if RVF_ENABLE_STATS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
208 rvf_banks[memory_bank_num].max_reached = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
209 rvf_banks[memory_bank_num].required_size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
210 rvf_banks[memory_bank_num].num_buf = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
211 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
212 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
213 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
214 /* Initialize total memory banks */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
215 for (memory_bank_num = 0; memory_bank_num < RVF_MAX_TOTAL_MB; memory_bank_num++) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
217 rvf_name_id[memory_bank_num].mb_params.size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
218 rvf_name_id[memory_bank_num].mb_params.watermark = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
220 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
221 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
222 /* initialize array of waiting buffers */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
223 first_free_element = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
224 for( memory_bank_num = 0; memory_bank_num < RVF_MAX_WAITING_BUF; memory_bank_num++) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
225 { waiting_buffers[memory_bank_num] = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
226 next_buffer[memory_bank_num] = memory_bank_num + 1; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
227 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
228 next_buffer[RVF_MAX_WAITING_BUF-1] = RVF_INVALID_INDEX; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
229 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
230 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
231 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
232 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
233 ** Function _rvf_send_msg_to_mbox |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
234 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
235 ** Description Called by applications to send a buffer to a SWE. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
236 ** (Temporary internal use - DO NOT USE IT !) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
237 ** (Presently, only for Christophe ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
238 ** Returns RVF_OK if successful, else an error code. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
239 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
240 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
241 T_RVF_RET _rvf_send_msg_to_mbox (T_RVF_G_ADDR_ID addr_id, UINT8 mbox,void *msg){ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
242 return rvf_adapt_send_msg(addr_id, msg, mbox); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
243 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
244 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
245 /*T_RVF_RET _rvf_send_msg_to_mbox (T_RVF_ADDR_ID addr_id, UINT8 mbox,void *msg) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
246 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
247 T_RVF_INTERNAL_BUF *p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
248 UINT8 task_id = (UINT8)addr_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
249 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
250 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
251 if ((task_id >= MAX_RVF_TASKS) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
252 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
253 rvf_send_trace( "RVF: rvf_send_msg(): invalid taskid", 35, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
254 rvf_free_buf (msg); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
255 return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
256 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
257 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
258 #if RVF_ENABLE_BUF_CORRUPTION_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
259 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
260 if (_rvf_chk_buf_damage(msg) == TRUE) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
261 { rvf_send_trace( "RVF: rvf_send_msg(): buffer corrupted", 37, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
262 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
263 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
264 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
265 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
266 ((T_RV_HDR *)msg)->dest_addr_id = addr_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
267 p_hdr = USER2MEM(msg); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
268 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
269 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
270 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
271 if ( RVF_BUF_IS_LINKED( p_hdr) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
272 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
273 rvf_send_trace( "RVF: rvf_send_msg(): buffer already enqueued", 44, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
274 return RVF_MEMORY_ERR; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
275 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
276 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
277 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
278 rvf_disable(8); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
279 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
280 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
281 if (OSTaskQFirst[task_id][mbox]) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
282 { OSTaskQLast[task_id][mbox]->p_next = p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
283 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
284 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
285 { OSTaskQFirst[task_id][mbox] = p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
286 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
287 OSTaskQLast[task_id][mbox] = p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
288 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
289 p_hdr->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
290 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
291 if (pRtAddrIdTable[task_id]->OSTaskQFirst[mbox]) { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
292 pRtAddrIdTable[task_id]->OSTaskQLast[mbox]->p_next = p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
293 } else { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
294 pRtAddrIdTable[task_id]->OSTaskQFirst[mbox] = p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
295 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
296 pRtAddrIdTable[task_id]->OSTaskQLast[mbox] = p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
297 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
298 p_hdr->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
299 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
300 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
301 RVF_SET_BUF_LINKED(p_hdr); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
302 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
303 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
304 rvf_enable(); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
305 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
306 rvf_send_event(task_id, (UINT16) (EVENT_MASK(mbox)) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
307 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
308 }*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
309 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
310 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
311 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
312 ** Function rvf_read_mbox |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
313 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
314 ** Description Called by applications to read a buffer from one of |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
315 ** the task mailboxes. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
316 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
317 ** Returns NULL if the mailbox was empty, else the address of a buffer |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
318 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
319 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
320 void * rvf_read_mbox (UINT8 mbox) { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
321 T_RVF_G_ADDR_ID task_id = rvf_get_taskid(); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
322 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
323 return rvf_read_addr_mbox (task_id, mbox) ; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
324 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
325 void * rvf_read_addr_mbox (T_RVF_G_ADDR_ID task_id, UINT8 mbox) { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
326 void * p_buf = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
327 T_RVF_INTERNAL_BUF * p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
328 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
329 mbox=resolveHostAddrId(mbox); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
330 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
331 if ((task_id >= MAX_RVF_TASKS) || (mbox >= RVF_NUM_TASK_MBOX)) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
332 { rvf_send_trace( "RVF: rvf_read_mbox(): invalid taskid or mbox", 44, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
333 return NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
334 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
335 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
336 rvf_disable(9); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
337 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
338 /* if the chained list is not empty */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
339 /*if ( OSTaskQFirst[task_id][mbox] ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
340 { p_hdr = OSTaskQFirst[task_id][mbox]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
341 OSTaskQFirst[task_id][mbox] = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
342 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
343 p_hdr->p_next = NULL;*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
344 if ( pRtAddrIdTable[task_id]->OSTaskQFirst[mbox] ) { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
345 p_hdr = pRtAddrIdTable[task_id]->OSTaskQFirst[mbox]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
346 pRtAddrIdTable[task_id]->OSTaskQFirst[mbox] = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
347 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
348 p_hdr->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
349 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
350 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
351 RVF_SET_BUF_UNLINKED(p_hdr); /* change buffer status */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
352 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
353 p_buf = (UINT8 *)p_hdr + sizeof(T_RVF_INTERNAL_BUF); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
354 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
355 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
356 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
357 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
358 return (p_buf); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
359 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
360 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
361 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
362 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
363 ** Function rvf_enqueue |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
364 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
365 ** Description Enqueue a buffer at the tail of the queue |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
366 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
367 ** Returns RVF_OK if successful, else an error code. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
368 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
369 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
370 T_RVF_RET rvf_enqueue (T_RVF_BUFFER_Q *p_q, void *p_buf) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
371 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
372 T_RVF_INTERNAL_BUF *p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
373 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
374 #if RVF_ENABLE_BUF_CORRUPTION_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
375 if ( _rvf_chk_buf_damage(p_buf) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
376 { rvf_send_trace( "RVF: rvf_enqueue(): buffer corrupted", 36, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
377 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
378 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
379 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
380 /* check if the buffer has been already enqueued */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
381 p_hdr = USER2MEM(p_buf); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
382 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
383 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
384 if( RVF_BUF_IS_LINKED(p_hdr) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
385 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
386 rvf_send_trace( "RVF: rvf_enqueue(): buffer already enqueued", 43, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
387 return RVF_MEMORY_ERR; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
388 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
389 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
390 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
391 rvf_disable(10); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
392 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
393 /* Since the queue is exposed (C vs C++), keep the pointers in exposed format */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
394 /* p_q->p_last and p_q->p_first point to the user buffer, since p_hdr->p_next points to the T_RVF_INTERNAL_BUF */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
395 if (p_q->p_first) /* if the queue is not empty */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
396 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
397 T_RVF_INTERNAL_BUF * p_last_hdr = (T_RVF_INTERNAL_BUF *) ((UINT8 *)p_q->p_last - sizeof(T_RVF_INTERNAL_BUF) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
398 p_last_hdr->p_next = p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
399 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
400 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
401 p_q->p_first = p_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
402 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
403 p_q->p_last = p_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
404 p_q->count++; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
405 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
406 p_hdr->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
407 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
408 RVF_SET_BUF_LINKED(p_hdr); /* change buffer status */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
409 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
410 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
411 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
412 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
413 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
414 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
415 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
416 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
417 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
418 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
419 ** Function rvf_dequeue |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
420 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
421 ** Description Dequeue a buffer from the head of a queue |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
422 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
423 ** Returns NULL if queue is empty, else buffer |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
424 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
425 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
426 void * rvf_dequeue (T_RVF_BUFFER_Q *p_q) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
427 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
428 T_RVF_INTERNAL_BUF *p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
429 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
430 if (!p_q->count) /* if the queue is empty */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
431 return (NULL); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
432 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
433 rvf_disable(12); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
434 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
435 p_hdr = USER2MEM(p_q->p_first ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
436 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
437 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
438 /* Keep buffers such that RVF header is invisible */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
439 if (p_hdr->p_next) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
440 p_q->p_first = ((UINT8 *)p_hdr->p_next + sizeof(T_RVF_INTERNAL_BUF)); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
441 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
442 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
443 p_q->p_first = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
444 p_q->p_last = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
445 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
446 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
447 p_q->count--; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
448 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
449 p_hdr->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
450 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
451 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
452 RVF_SET_BUF_UNLINKED(p_hdr); /* change buffer status */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
453 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
454 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
455 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
456 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
457 return (MEM2USER(p_hdr) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
458 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
459 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
460 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
461 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
462 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
463 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
464 ** Function rvf_enqueue_head |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
465 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
466 ** Description Enqueue a buffer at the head of the queue |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
467 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
468 ** Returns RVF_OK if successful, else an error code. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
469 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
470 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
471 T_RVF_RET rvf_enqueue_head (T_RVF_BUFFER_Q *p_q, void *p_buf) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
472 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
473 T_RVF_INTERNAL_BUF *p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
474 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
475 #if RVF_ENABLE_BUF_CORRUPTION_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
476 if ( _rvf_chk_buf_damage(p_buf) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
477 { rvf_send_trace( "RVF: rvf_enqueue_head(): buffer corrupted", 41, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
478 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
479 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
480 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
481 p_hdr = USER2MEM(p_buf); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
482 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
483 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
484 if( RVF_BUF_IS_LINKED(p_hdr) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
485 { rvf_send_trace( "RVF: rvf_enqueue_head(): buffer already enqueued", 48, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
486 return RVF_MEMORY_ERR; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
487 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
488 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
489 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
490 rvf_disable(11); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
491 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
492 if (p_q->p_first) /* if the queue is not empty */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
493 { p_hdr->p_next = (T_RVF_INTERNAL_BUF *)((UINT8 *)p_q->p_first - sizeof(T_RVF_INTERNAL_BUF) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
494 p_q->p_first = p_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
495 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
496 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
497 { p_q->p_first = p_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
498 p_q->p_last = p_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
499 p_hdr->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
500 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
501 p_q->count++; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
502 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
503 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
504 RVF_SET_BUF_LINKED(p_hdr); /* change buffer status */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
505 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
506 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
507 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
508 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
509 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
510 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
511 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
512 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
513 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
514 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
515 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
516 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
517 ** Function rvf_get_buf_size |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
518 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
519 ** Description Called by an application to get the size of a buffer. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
520 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
521 ** Returns the size of the buffer or 0 if the address is invalid. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
522 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
523 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
524 INLINE UINT32 rvf_get_buf_size (void *bptr) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
525 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
526 T_RVF_INTERNAL_BUF *p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
527 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
528 p_hdr = (T_RVF_INTERNAL_BUF *)((UINT8 *) bptr - sizeof(T_RVF_INTERNAL_BUF) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
529 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
530 if ((UINT32)p_hdr & 1) return 0; /* invalid pointer: odd address*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
531 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
532 return (GETSIZE(p_hdr) - RVF_CORRUPT_OVERHEAD) ; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
533 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
534 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
535 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
536 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
537 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
538 ** Function _rvf_chk_buf_damage |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
539 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
540 ** Description Called internally by rvf to check for buffer corruption. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
541 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
542 ** Returns TRUE if there is a problem, else FALSE |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
543 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
544 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
545 #if RVF_ENABLE_BUF_CORRUPTION_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
546 BOOLEAN _rvf_chk_buf_damage(void *bptr) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
547 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
548 UINT32 *lg; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
549 T_RVF_INTERNAL_BUF * p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
550 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
551 if((UINT32)bptr & 1) /* odd address */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
552 { return TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
553 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
554 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
555 p_hdr = USER2MEM(bptr); /* get the internal header */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
556 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
557 lg = (UINT32*)( (UINT8*)bptr + GETSIZE(p_hdr) - sizeof(UINT32) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
558 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
559 if (lg == 0) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
560 return TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
561 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
562 if(*lg == GETSIZE(p_hdr) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
563 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
564 return FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
565 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
566 return TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
567 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
568 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
569 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
570 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
571 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
572 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
573 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
574 ** Function _find_buf |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
575 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
576 ** Description Internal function which is in charge of finding a free buffer |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
577 ** of the requested size in one of the lists. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
578 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
579 ** Returns A pointer to the buffer header, or NULL if none available |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
580 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
581 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
582 INLINE void * _find_buf (UINT32 size) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
583 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
584 T_RVF_INTERNAL_BUF * p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
585 UINT8 idx; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
586 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
587 if (size == 0) /* if user requires a 0 byte buffer !! */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
588 { return (NULL); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
589 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
590 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
591 /* add the overhead for buffer corruption check */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
592 size = REQ2SIZE(size); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
593 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
594 /* find the corresponding list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
595 idx = RVF_BUF_LIST_INDEX(size); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
596 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
597 /* 1. try in the bin corresponding to the requested size. */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
598 /* 2. try to use the last_remainder chunk. */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
599 /* 3. try in the others bins of greater size. */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
600 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
601 if( (lists[idx] == NULL) || ( GETSIZE(lists[idx]) < size) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
602 /* if the first buffer in the appropriate bin is not big enough. */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
603 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
604 rvf_disable(4); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
605 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
606 if( last_remainder != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
607 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
608 p_hdr = last_remainder; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
609 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
610 /* if the last remainder is big enough */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
611 if( GETSIZE(p_hdr) >= size ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
612 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
613 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
614 if( GETSIZE(p_hdr) >= (size + RVF_MIN_USABLE_SIZE ) ) /* if the free part may be used */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
615 { /* create a new free buffer and link it in the appropriate list*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
616 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
617 T_RVF_INTERNAL_BUF * new_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
618 UINT8 new_idx; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
619 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
620 new_buf = (T_RVF_INTERNAL_BUF *) ((UINT8*)p_hdr + size + sizeof(T_RVF_INTERNAL_BUF)); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
621 new_buf->buf_size = GETSIZE(p_hdr) - size - sizeof(T_RVF_INTERNAL_BUF); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
622 ENDSIZE(new_buf) = new_buf->buf_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
623 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
624 /* remove the used buffer from the list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
625 if( p_hdr->header.p_prev != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
626 { (p_hdr->header.p_prev)->p_next = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
627 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
628 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
629 { lists[ RVF_BUF_LIST_INDEX( GETSIZE(p_hdr) )] = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
630 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
631 if( p_hdr->p_next != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
632 { (p_hdr->p_next)->header.p_prev = p_hdr->header.p_prev; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
633 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
634 p_hdr->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
635 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
636 SETSIZE(p_hdr, size); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
637 ENDSIZE(p_hdr) = size; /* to CHANGE */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
638 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
639 /* insert the new buffer in the appropriate list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
640 new_idx = RVF_BUF_LIST_INDEX(new_buf->buf_size); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
641 new_buf->p_next = lists[new_idx]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
642 lists[new_idx] = new_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
643 new_buf->header.p_prev = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
644 if( new_buf->p_next != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
645 { (new_buf->p_next)->header.p_prev = new_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
646 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
647 RVF_SET_PREV_IN_USE(new_buf); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
648 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
649 last_remainder = new_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
650 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
651 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
652 return p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
653 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
654 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
655 else /* return the entire buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
656 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
657 /* remove the used buffer from the list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
658 if( p_hdr->header.p_prev != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
659 { (p_hdr->header.p_prev)->p_next = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
660 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
661 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
662 { lists[ RVF_BUF_LIST_INDEX( GETSIZE(p_hdr) )] = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
663 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
664 if( p_hdr->p_next != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
665 { (p_hdr->p_next)->header.p_prev = p_hdr->header.p_prev; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
666 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
667 p_hdr->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
668 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
669 RVF_SET_PREV_IN_USE( NEXTCHUNK(p_hdr) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
670 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
671 last_remainder = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
672 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
673 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
674 return p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
675 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
676 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
677 else /* the last remainder is too small */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
678 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
679 /* clear the last remainder */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
680 last_remainder = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
681 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
682 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
683 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
684 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
685 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
686 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
687 while( idx < RVF_NB_FREE_LISTS ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
688 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
689 rvf_disable(4); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
690 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
691 if( lists[idx] != NULL ) /*if the list is not empty */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
692 { /* remove the first buffer from the list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
693 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
694 p_hdr = lists[idx]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
695 if( GETSIZE(p_hdr) >= size) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
696 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
697 if( GETSIZE(p_hdr) >= (size + RVF_MIN_USABLE_SIZE ) ) /* if the free part may be used */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
698 { /* create a new free buffer and link it in the appropriate list*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
699 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
700 T_RVF_INTERNAL_BUF * new_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
701 UINT8 new_idx; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
702 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
703 new_buf = (T_RVF_INTERNAL_BUF *) ((UINT8*)p_hdr + size + sizeof(T_RVF_INTERNAL_BUF)); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
704 new_buf->buf_size = GETSIZE( p_hdr) - size - sizeof(T_RVF_INTERNAL_BUF); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
705 ENDSIZE(new_buf) = new_buf->buf_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
706 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
707 /* remove the used buffer from the list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
708 lists[idx] = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
709 if( p_hdr->p_next != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
710 { (p_hdr->p_next)->header.p_prev = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
711 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
712 p_hdr->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
713 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
714 SETSIZE(p_hdr, size); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
715 ENDSIZE(p_hdr) = size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
716 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
717 /* insert the new buffer in the appropriate list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
718 new_idx = RVF_BUF_LIST_INDEX(new_buf->buf_size); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
719 new_buf->p_next = lists[new_idx]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
720 lists[new_idx] = new_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
721 new_buf->header.p_prev = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
722 if( new_buf->p_next != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
723 { (new_buf->p_next)->header.p_prev = new_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
724 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
725 RVF_SET_PREV_IN_USE(new_buf); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
726 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
727 last_remainder = new_buf; /* set this new buffer as the last remainder */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
728 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
729 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
730 return p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
731 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
732 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
733 else /* return the entire buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
734 { lists[idx] = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
735 if( p_hdr->p_next != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
736 { (p_hdr->p_next)->header.p_prev = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
737 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
738 p_hdr->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
739 RVF_SET_PREV_IN_USE( NEXTCHUNK(p_hdr) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
740 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
741 if( last_remainder == p_hdr) /* if it was the last_remainder, clear it. */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
742 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
743 last_remainder = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
744 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
745 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
746 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
747 return p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
748 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
749 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
750 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
751 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
752 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
753 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
754 idx++; /* search in the next list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
755 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
756 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
757 return NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
758 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
759 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
760 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
761 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
762 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
763 ** Function _release_buf |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
764 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
765 ** Description Internal function called to release a buffer after use. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
766 ** The parameter points to the beginning of the header. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
767 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
768 ** Returns BOOLEAN: TRUE if successful, else FALSE |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
769 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
770 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
771 INLINE BOOLEAN _release_buf (T_RVF_INTERNAL_BUF *p_hdr) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
772 { UINT8 idx; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
773 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
774 #if RVF_ENABLE_BUF_CORRUPTION_CHECK /* check for buffer corruption:i.e. if user wrote data after the end of the buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
775 if ( _rvf_chk_buf_damage( MEM2USER(p_hdr) ) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
776 { rvf_send_trace( "RVF: _release_buf(): buffer corrupted", 37, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
777 return FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
778 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
779 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
780 /* check if the buffer has been already freed */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
781 if ( RVF_IS_PREV_FREE( NEXTCHUNK(p_hdr) ) ) /* check buffer status */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
782 { rvf_send_trace( "RVF: _release_buf(): buffer already freed", 41, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
783 return FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
784 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
785 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
786 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
787 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
788 #if RVF_ENABLE_BUF_LINKAGE_CHECK /* check for buffer linkage */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
789 if ( RVF_BUF_IS_LINKED(p_hdr) ) /* check buffer status */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
790 { rvf_send_trace( "RVF: _release_buf(): free buf buffer linked", 43, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
791 return FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
792 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
793 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
794 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
795 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
796 rvf_disable(6); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
797 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
798 /* try to coalesce the buffer with its neighbors (left and right) */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
799 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
800 if( RVF_IS_PREV_FREE(p_hdr) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
801 { /* merge the buffer with its left neighbor */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
802 UINT32 left_buf_size = *((UINT32*)((UINT8*)p_hdr - sizeof(UINT32) ) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
803 T_RVF_INTERNAL_BUF * left_buf = (T_RVF_INTERNAL_BUF *) ((UINT8 *)p_hdr - left_buf_size - sizeof(T_RVF_INTERNAL_BUF) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
804 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
805 /* remove the left buffer from its list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
806 if( left_buf->header.p_prev == NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
807 { lists[ RVF_BUF_LIST_INDEX(left_buf_size)] = left_buf->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
808 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
809 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
810 { (left_buf->header.p_prev)->p_next = left_buf->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
811 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
812 if( left_buf->p_next != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
813 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
814 (left_buf->p_next)->header.p_prev = left_buf->header.p_prev; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
815 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
816 /* set the size of the newly created buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
817 SETSIZE(left_buf, (left_buf_size + GETSIZE(p_hdr) + sizeof(T_RVF_INTERNAL_BUF) ) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
818 /* set the current buffer as free to allow check for double free */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
819 RVF_SET_PREV_FREE( NEXTCHUNK(p_hdr) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
820 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
821 p_hdr = left_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
822 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
823 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
824 /* check for pool limits */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
825 if( GETSIZE( NEXTCHUNK(p_hdr) ) != 0) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
826 { T_RVF_INTERNAL_BUF * right_buf = NEXTCHUNK(p_hdr); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
827 /* merge the buffer with its right neighbor */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
828 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
829 if( RVF_IS_PREV_FREE( NEXTCHUNK(right_buf) ) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
830 { /* remove the right buffer from its list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
831 UINT32 right_buf_size = GETSIZE( right_buf); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
832 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
833 if( right_buf->header.p_prev == NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
834 { lists[ RVF_BUF_LIST_INDEX(right_buf_size)] = right_buf->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
835 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
836 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
837 { (right_buf->header.p_prev)->p_next = right_buf->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
838 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
839 if( right_buf->p_next != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
840 { (right_buf->p_next)->header.p_prev = right_buf->header.p_prev; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
841 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
842 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
843 right_buf_size += GETSIZE(p_hdr); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
844 SETSIZE(p_hdr, (right_buf_size + sizeof(T_RVF_INTERNAL_BUF) ) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
845 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
846 if( last_remainder == right_buf) /* keep as last_remainder */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
847 { last_remainder = p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
848 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
849 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
850 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
851 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
852 /* enqueue the free buffer in the appropriate list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
853 idx = RVF_BUF_LIST_INDEX( GETSIZE(p_hdr) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
854 p_hdr->header.p_prev = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
855 p_hdr->p_next = lists[idx]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
856 lists[idx] = p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
857 if( p_hdr->p_next != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
858 { (p_hdr->p_next)->header.p_prev = p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
859 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
860 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
861 ENDSIZE(p_hdr) = GETSIZE(p_hdr); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
862 RVF_SET_PREV_FREE( NEXTCHUNK(p_hdr) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
863 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
864 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
865 return TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
866 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
867 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
868 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
869 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
870 ** Function _str_cmp |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
871 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
872 ** Description Internal function which compares two null-terminated string. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
873 ** Returns TRUE if they are equal, else FALSE. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
874 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
875 BOOLEAN _str_cmp( char *str1, char * str2) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
876 { UINT8 i; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
877 for ( i = 0; (str1[i] == str2[i]) && (str1[i] != 0) && (str2[i] != 0) && (i < RVF_MAX_MB_LEN); i++ ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
878 if ( i == RVF_MAX_MB_LEN) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
879 { return TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
880 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
881 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
882 if ( (str1[i] == 0) && (str2[i] == 0) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
883 { return TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
884 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
885 return FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
886 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
887 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
888 /****************************************************************************** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
889 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
890 ** MEMORY BANK RELATED FUNCTIONS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
891 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
892 ******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
893 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
894 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
895 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
896 ** Function _remove_from_list |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
897 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
898 ** Description Internal function called to remove a buffer from the list of |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
899 ** buffer waiting to be counted on the memory bank. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
900 ** The parameter points to the beginning of the header. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
901 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
902 ** Returns BOOLEAN: TRUE if successful, else FALSE |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
903 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
904 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
905 BOOLEAN _remove_from_list (void *bptr, T_RVF_MB * mb) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
906 { UINT16 * index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
907 UINT16 free_elem, prec; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
908 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
909 /* check all elements of the list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
910 index = &(mb->first_buffer_index); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
911 prec = RVF_INVALID_INDEX; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
912 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
913 while ( (*index != RVF_INVALID_INDEX) && (waiting_buffers[*index]!=bptr) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
914 { prec = *index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
915 index = &(next_buffer[*index]); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
916 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
917 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
918 if (waiting_buffers[*index] == bptr) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
919 { free_elem = *index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
920 *index = next_buffer[free_elem]; /* link preceding element to the next one */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
921 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
922 if (next_buffer[free_elem] == RVF_INVALID_INDEX ) /* last element in the list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
923 { mb->last_buffer_index = prec; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
924 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
925 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
926 waiting_buffers[free_elem] = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
927 next_buffer[free_elem] = first_free_element; /* link free elements */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
928 first_free_element = free_elem; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
929 return TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
930 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
931 return FALSE; /* buffer not found */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
932 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
933 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
934 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
935 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
936 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
937 ** Function _add_to_list |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
938 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
939 ** Description Internal function called to add a buffer to the list of |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
940 ** buffer waiting to be counted on the memory bank. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
941 ** The parameter points to the beginning of the header. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
942 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
943 ** Returns BOOLEAN: TRUE if successful, else FALSE |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
944 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
945 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
946 BOOLEAN _add_to_list (void *bptr, T_RVF_MB * mb) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
947 { UINT16 index = first_free_element; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
948 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
949 first_free_element = next_buffer[index]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
950 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
951 waiting_buffers[index] = bptr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
952 next_buffer[index] = RVF_INVALID_INDEX; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
953 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
954 if ( mb->last_buffer_index == RVF_INVALID_INDEX) /* empty list */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
955 { mb->first_buffer_index = index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
956 mb->last_buffer_index = index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
957 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
958 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
959 { next_buffer[mb->last_buffer_index] = index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
960 mb->last_buffer_index = index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
961 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
962 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
963 return TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
964 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
965 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
966 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
967 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
968 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
969 ** Function rvf_create_mb |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
970 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
971 ** Description Called by an application to create a memory bank |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
972 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
973 ** Parameters: memory bank name, memory bank param |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
974 ** (return) memory bank id |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
975 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
976 ** Returns T_RVF_RET: RVF_OK if success |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
977 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
978 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
979 T_RVF_RET rvf_create_mb(T_RVF_MB_NAME mb_name, T_RVF_MB_PARAM mb_param, T_RVF_MB_ID *mb_id) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
980 { UINT8 num_mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
981 T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
982 UINT32 available_mem = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
983 UINT32 required_mem = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
984 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
985 /* find the mb name in the array */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
986 for ( num_mb = 0; (num_mb < RVF_MAX_TOTAL_MB) && (!_str_cmp(mb_name, rvf_name_id[num_mb].mb_name) ); num_mb++); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
987 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
988 if ( num_mb == RVF_MAX_TOTAL_MB ) /* mb name not found */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
989 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
990 /* DLC added for dynamic memory bank creation*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
991 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
992 /* search the first available place in the array */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
993 T_RVF_MB_ID first_available_mb_id = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
994 BOOLEAN mb_id_found = FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
995 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
996 for ( num_mb = 0; (num_mb < RVF_MAX_TOTAL_MB) && (rvf_name_id[num_mb].mb_name[0] != 0) ; num_mb++) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
997 { if( rvf_name_id[num_mb].mb_id == first_available_mb_id) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
998 { first_available_mb_id ++; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
999 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1000 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1001 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1002 while( (first_available_mb_id < RVF_MAX_REAL_MB) && (mb_id_found == FALSE) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1003 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1004 for ( num_mb = 0; (num_mb < RVF_MAX_TOTAL_MB) && (rvf_name_id[num_mb].mb_name[0] != 0) && (rvf_name_id[num_mb].mb_id != first_available_mb_id) ; num_mb++); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1005 if ( rvf_name_id[num_mb].mb_id != first_available_mb_id) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1006 { /* available mb id found */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1007 mb_id_found = TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1008 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1009 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1010 { /* try the next one */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1011 first_available_mb_id++; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1012 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1013 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1014 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1015 if ( (num_mb == RVF_MAX_TOTAL_MB) || (first_available_mb_id + 1 >= RVF_MAX_REAL_MB ) ) /* no available space in the array */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1016 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1017 { *mb_id = RVF_INVALID_MB_ID; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1018 return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1019 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1020 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1021 if(INC_Initialize_State==INC_END_INITIALIZE) rvf_disable(20); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1022 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1023 /* create the new mb name and id */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1024 strcpy( rvf_name_id[num_mb].mb_name, mb_name); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1025 rvf_name_id[num_mb].mb_id = first_available_mb_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1026 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1027 /* initialize the next one */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1028 rvf_name_id[num_mb+1].mb_name[0] = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1029 rvf_name_id[num_mb+1].mb_id = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1030 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1031 if(INC_Initialize_State==INC_END_INITIALIZE) rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1032 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1033 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1034 /* check if the memory bank has been already created */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1035 if ( rvf_name_id[ num_mb].mb_params.size != 0) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1036 { *mb_id = RVF_INVALID_MB_ID; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1037 return RVF_INTERNAL_ERR; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1038 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1039 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1040 rvf_get_available_mem( &available_mem, &required_mem); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1041 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1042 if ( ( (required_mem + mb_param.size)*100) > ( available_mem * _rvf_get_mem_usage_ratio()) ) /* if there is not enough available memory to create this mb */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1043 { *mb_id = RVF_INVALID_MB_ID; /* In a next version: try to create a dynamic pool */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1044 return RVF_MEMORY_ERR; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1045 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1046 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1047 rvf_disable(20); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1048 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1049 /* save the mb parameters for deletion */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1050 rvf_name_id[num_mb].mb_params.size = mb_param.size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1051 rvf_name_id[num_mb].mb_params.watermark = mb_param.watermark; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1052 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1053 * mb_id = rvf_name_id[num_mb].mb_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1054 mb = &rvf_banks[ *mb_id ]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1055 /* initialize the memory bank structure */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1056 mb->watermark += mb_param.watermark; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1057 mb->max += mb_param.size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1058 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1059 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1060 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1061 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1062 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1063 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1064 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1065 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1066 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1067 ** Function rvf_get_mb_id |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1068 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1069 ** Description Called by an application to get the memory bank id from its name |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1070 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1071 ** Parameters: memory bank name |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1072 ** (return) memory bank id |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1073 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1074 ** Returns T_RVF_RET: RVF_OK if success |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1075 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1076 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1077 T_RVF_RET rvf_get_mb_id(T_RVF_MB_NAME mb_name, T_RVF_MB_ID *mb_id) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1078 { UINT8 num_mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1079 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1080 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1081 /* find the mb name in the array */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1082 for ( num_mb = 0; (num_mb < RVF_MAX_TOTAL_MB) && (!_str_cmp(mb_name, rvf_name_id[num_mb].mb_name) ); num_mb++); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1083 if ( num_mb == RVF_MAX_TOTAL_MB ) /* mb name not found */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1084 { *mb_id = RVF_INVALID_MB_ID; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1085 return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1086 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1087 if ( rvf_banks[ rvf_name_id[num_mb].mb_id ].max == 0 ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1088 { /* the memory bank has not been created */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1089 *mb_id = RVF_INVALID_MB_ID; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1090 return RVF_NOT_READY; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1091 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1092 *mb_id = rvf_name_id[num_mb].mb_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1093 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1094 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1095 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1096 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1097 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1098 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1099 ** Function rvf_delete_mb |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1100 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1101 ** Description Called by an application to delete a memory bank |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1102 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1103 ** Parameters: memory bank name |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1104 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1105 ** Returns T_RVF_RET: RVF_OK if success |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1106 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1107 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1108 T_RVF_RET rvf_delete_mb(T_RVF_MB_NAME mb_name) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1109 { UINT8 num_mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1110 T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1111 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1112 /* find the mb name in the array */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1113 for ( num_mb = 0; (num_mb < RVF_MAX_TOTAL_MB) && (!_str_cmp(mb_name, rvf_name_id[num_mb].mb_name) ); num_mb++); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1114 if ( num_mb == RVF_MAX_TOTAL_MB ) /* mb name not found */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1115 { return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1116 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1117 mb = &rvf_banks[ rvf_name_id[num_mb].mb_id ]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1118 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1119 /* check if the mb is used more than once or not */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1120 if ( mb->max == rvf_name_id[num_mb].mb_params.size ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1121 { /* mb is used only once, check if cur_memory_used > 0 */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1122 if ( mb->cur_memory_used > 0) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1123 { rvf_send_trace( "RVF: rvf_delete_mb(): not all buffers have been freed", 53, NULL_PARAM, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1124 return RVF_MEMORY_ERR; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1125 /* free all buffers ????? -> NOT POSSIBLE */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1126 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1127 /* initialize mb params */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1128 mb->max = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1129 mb->first_buffer_index = RVF_INVALID_INDEX; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1130 mb->last_buffer_index = RVF_INVALID_INDEX; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1131 mb->watermark = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1132 mb->returned_red = FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1133 mb->func = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1134 #if RVF_ENABLE_STATS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1135 mb->max_reached = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1136 mb->required_size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1137 mb->num_buf = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1138 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1139 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1140 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1141 else /* mb is still used by another entity */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1142 { /* change mb params */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1143 mb->max -= rvf_name_id[num_mb].mb_params.size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1144 mb->watermark -= rvf_name_id[num_mb].mb_params.watermark; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1145 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1146 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1147 rvf_name_id[num_mb].mb_params.size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1148 rvf_name_id[num_mb].mb_params.watermark = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1149 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1150 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1151 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1152 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1153 T_RVF_RET rvf_mb_is_used(T_RVF_MB_NAME mb_name, UINT8* isUsed) { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1154 UINT8 num_mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1155 T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1156 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1157 *isUsed=0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1158 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1159 /* find the mb name in the array */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1160 for ( num_mb = 0; (num_mb < RVF_MAX_TOTAL_MB) && (!_str_cmp(mb_name, rvf_name_id[num_mb].mb_name) ); num_mb++); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1161 if ( num_mb == RVF_MAX_TOTAL_MB ) {/* mb name not found */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1162 return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1163 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1164 mb = &rvf_banks[ rvf_name_id[num_mb].mb_id ]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1165 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1166 /* check if the mb is used more than once or not */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1167 if ( mb->max == rvf_name_id[num_mb].mb_params.size ) { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1168 /* mb is used only once, check if cur_memory_used > 0 */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1169 if ( mb->cur_memory_used > 0) *isUsed=1; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1170 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1171 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1172 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1173 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1174 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1175 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1176 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1177 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1178 ** Function rvf_get_mb_status |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1179 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1180 ** Description Called by an application to get the status of a memory bank |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1181 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1182 ** Parameters: memory bank id |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1183 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1184 ** Returns T_RVF_MB_STATUS: RVF_GREEN if everything is ok, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1185 ** RVF_YELLOW if watermark limit has been reached, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1186 ** RVF_RED if max size has been reached |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1187 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1188 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1189 T_RVF_MB_STATUS rvf_get_mb_status(T_RVF_MB_ID mb_id) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1190 { T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1191 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1192 /* checking for invalid memory bank IDs */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1193 if (mb_id >= RVF_MAX_REAL_MB) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1194 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1195 #ifdef RVM_DAR_SWE |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1196 dar_diagnose_generate_emergency (RVF_INVALID_MD_ID_ERRROR, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1197 DAR_ASCII_FORMAT, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1198 RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1199 #else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1200 rvf_send_trace (RVF_INVALID_MD_ID_ERRROR, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1201 sizeof (RVF_INVALID_MD_ID_ERRROR) - 1, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1202 NULL_PARAM, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1203 RV_TRACE_LEVEL_ERROR, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1204 RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1205 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1206 return RVF_RED; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1207 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1208 mb = &rvf_banks[mb_id]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1209 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1210 if ( mb->returned_red == TRUE) /* if a previous count buf or get buf has failed */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1211 { return RVF_RED; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1212 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1213 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1214 if ( mb->cur_memory_used < mb->watermark ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1215 { return RVF_GREEN; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1216 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1217 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1218 { if ( mb->cur_memory_used < mb->max ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1219 { return RVF_YELLOW; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1220 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1221 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1222 { return RVF_RED; /* since max and cur_memory_used are set to 0 for not-created mb, it will return RED*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1223 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1224 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1225 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1226 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1227 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1228 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1229 ** Function rvf_get_mb_unused_mem |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1230 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1231 ** Description Called by an application to get the number of bytes available |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1232 ** until the memory bank size. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1233 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1234 ** Parameters: memory bank id |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1235 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1236 ** Returns UINT32: number of bytes available |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1237 ** returns 0 if the memory bank has not been created. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1238 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1239 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1240 UINT32 rvf_get_mb_unused_mem(T_RVF_MB_ID mb_id) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1241 { T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1242 mb = &rvf_banks[mb_id]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1243 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1244 if ( mb->returned_red == TRUE) /* if a previous count buf or get buf has failed */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1245 { return 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1246 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1247 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1248 return( mb->max - mb->cur_memory_used); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1249 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1250 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1251 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1252 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1253 ** Function rvf_get_mb_unused_green_mem |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1254 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1255 ** Description Called by an application to get the number of bytes available |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1256 ** until the memory bank watermark. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1257 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1258 ** Parameters: memory bank id |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1259 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1260 ** Returns UINT32: number of bytes available |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1261 ** returns 0 if the memory bank has not been created. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1262 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1263 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1264 UINT32 rvf_get_mb_unused_green_mem(T_RVF_MB_ID mb_id) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1265 { T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1266 mb = &rvf_banks[mb_id]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1267 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1268 if ( mb->returned_red == TRUE) /* if a previous count buf or get buf has failed */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1269 { return 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1270 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1271 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1272 if( mb->cur_memory_used > mb->watermark) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1273 { return 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1274 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1275 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1276 return( mb->watermark - mb->cur_memory_used); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1277 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1278 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1279 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1280 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1281 ** Function rvf_get_buf |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1282 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1283 ** Description Called by an application to get a buffer from a memory bank |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1284 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1285 ** Parameters: memory bank id, buffer size |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1286 ** (return) buffer pointer to the allocated buffer or null if |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1287 ** mb status is RVF_RED |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1288 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1289 ** Returns T_RVF_MB_STATUS: RVF_GREEN if everything is ok, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1290 ** RVF_YELLOW if watermark limit has been reached, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1291 ** RVF_RED if max size has been reached (does not return a buffer) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1292 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1293 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1294 T_RVF_MB_STATUS rvf_get_buf(T_RVF_MB_ID mb_id, UINT32 buffer_size, T_RVF_BUFFER** p_buffer) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1295 { T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1296 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1297 /* checking for invalid memory bank IDs */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1298 if (mb_id >= RVF_MAX_REAL_MB) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1299 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1300 #ifdef RVM_DAR_SWE |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1301 dar_diagnose_generate_emergency (RVF_INVALID_MD_ID_ERRROR, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1302 DAR_ASCII_FORMAT, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1303 RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1304 #else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1305 rvf_send_trace (RVF_INVALID_MD_ID_ERRROR, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1306 sizeof (RVF_INVALID_MD_ID_ERRROR) - 1, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1307 NULL_PARAM, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1308 RV_TRACE_LEVEL_ERROR, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1309 RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1310 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1311 return RVF_RED; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1312 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1313 mb = &rvf_banks[ mb_id ]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1314 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1315 /* check memory usage */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1316 if ( ( mb->cur_memory_used + buffer_size) > mb->max ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1317 { /* over the limits, return RED and do not allocate a buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1318 mb->returned_red = TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1319 *p_buffer = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1320 return RVF_RED; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1321 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1322 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1323 /* find a buffer of the requested size */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1324 *p_buffer = _find_buf( buffer_size ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1325 if ( *p_buffer == NULL ) /* error during allocation, not enough memory */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1326 { //rvf_send_trace( "RVF: rvf_get_buf(): not enough available physical memory", 56, NULL_PARAM, RV_TRACE_LEVEL_ERROR, TRACE_RVF_BUFFER ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1327 mb->returned_red = TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1328 return RVF_RED; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1329 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1330 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1331 #if RVF_ENABLE_STATS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1332 required_size += buffer_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1333 obtained_size += rvf_get_buf_size((UINT8*)(*p_buffer) + sizeof(T_RVF_INTERNAL_BUF)); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1334 used_size += rvf_get_buf_size((UINT8*)(*p_buffer) + sizeof(T_RVF_INTERNAL_BUF)) + sizeof(T_RVF_INTERNAL_BUF) + RVF_CORRUPT_OVERHEAD; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1335 mem_in_use += rvf_get_buf_size((UINT8*)(*p_buffer) + sizeof(T_RVF_INTERNAL_BUF)) + sizeof(T_RVF_INTERNAL_BUF) + RVF_CORRUPT_OVERHEAD; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1336 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1337 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1338 if(INC_Initialize_State==INC_END_INITIALIZE) rvf_disable(20); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1339 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1340 /* set as unlinked */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1341 RVF_SET_BUF_UNLINKED((T_RVF_INTERNAL_BUF*)(*p_buffer)); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1342 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1343 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1344 /* increase memory use counter */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1345 mb->cur_memory_used += rvf_get_buf_size( (UINT8*)(*p_buffer) + sizeof(T_RVF_INTERNAL_BUF) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1346 ( (T_RVF_INTERNAL_BUF *) (*p_buffer))->header.external.mb_id = mb_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1347 ( (T_RVF_INTERNAL_BUF *) (*p_buffer))->header.external.mb_expected = RVF_INVALID_MB_ID; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1348 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1349 *p_buffer = (UINT8*)(*p_buffer) + sizeof(T_RVF_INTERNAL_BUF); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1350 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1351 #if RVF_ENABLE_STATS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1352 if ( mb->cur_memory_used > mb->max_reached ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1353 { mb->max_reached = mb->cur_memory_used; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1354 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1355 mb->required_size += buffer_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1356 mb->num_buf++; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1357 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1358 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1359 if(INC_Initialize_State==INC_END_INITIALIZE) rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1360 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1361 /* return the correct flag */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1362 if ( mb->cur_memory_used > mb->watermark ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1363 { return RVF_YELLOW; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1364 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1365 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1366 { return RVF_GREEN; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1367 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1368 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1369 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1370 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1371 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1372 ** Function rvf_count_buf |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1373 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1374 ** Description Called by an application to change the memory bank on which a buffer is counted |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1375 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1376 ** Parameters: new memory bank id, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1377 ** pointer to the buffer. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1378 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1379 ** Returns T_RVF_MB_STATUS: RVF_GREEN if everything is ok, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1380 ** RVF_YELLOW if watermark limit has been reached, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1381 ** RVF_RED if max size has been reached |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1382 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1383 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1384 T_RVF_MB_STATUS rvf_count_buf(T_RVF_MB_ID mb_id, T_RVF_BUFFER * p_buffer) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1385 { T_RVF_INTERNAL_BUF * buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1386 UINT32 buf_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1387 T_RVF_MB * new_mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1388 T_RVF_MB * old_mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1389 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1390 /* checking for invalid memory bank IDs */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1391 if (mb_id >= RVF_MAX_REAL_MB) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1392 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1393 #ifdef RVM_DAR_SWE |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1394 dar_diagnose_generate_emergency (RVF_INVALID_MD_ID_ERRROR, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1395 DAR_ASCII_FORMAT, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1396 RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1397 #else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1398 rvf_send_trace (RVF_INVALID_MD_ID_ERRROR, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1399 sizeof (RVF_INVALID_MD_ID_ERRROR) - 1, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1400 NULL_PARAM, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1401 RV_TRACE_LEVEL_ERROR, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1402 RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1403 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1404 return RVF_RED; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1405 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1406 buf = (T_RVF_INTERNAL_BUF *) ( (UINT8 *) p_buffer - sizeof(T_RVF_INTERNAL_BUF) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1407 new_mb = &rvf_banks[mb_id]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1408 old_mb = &rvf_banks[buf->header.external.mb_id]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1409 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1410 /* get the size of the buffer and try to count it on the new mb */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1411 buf_size = rvf_get_buf_size( p_buffer ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1412 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1413 if ( ( new_mb->cur_memory_used + buf_size ) < new_mb->max ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1414 { /* there is enough memory in the new mb */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1415 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1416 if ( buf->header.external.mb_expected != RVF_INVALID_MB_ID ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1417 { /* remove the buffer from the list of waiting buffers in mb expected */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1418 _remove_from_list( buf, &rvf_banks[buf->header.external.mb_expected] ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1419 buf->header.external.mb_expected = RVF_INVALID_MB_ID; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1420 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1421 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1422 rvf_disable(20); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1423 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1424 /* decrease the memory used in the old mb */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1425 old_mb->cur_memory_used -= buf_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1426 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1427 /* increase memory used in the new mb */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1428 new_mb->cur_memory_used += buf_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1429 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1430 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1431 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1432 /* call the callback function if state of the old mb switches to RVF_GREEN and there is no buffer waiting */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1433 if ( (old_mb->cur_memory_used < old_mb->watermark) && (old_mb->first_buffer_index == RVF_INVALID_INDEX) && (old_mb->returned_red == TRUE) && ( old_mb->func != NULL) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1434 { old_mb->returned_red = FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1435 old_mb->func( buf->header.external.mb_id); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1436 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1437 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1438 { /* count as many waiting buffers as possible on the old mb */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1439 while( (old_mb->first_buffer_index != RVF_INVALID_INDEX) && (rvf_count_buf( buf->header.external.mb_id, (UINT8 *) (waiting_buffers[old_mb->first_buffer_index]) + sizeof(T_RVF_INTERNAL_BUF)) != RVF_RED) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1440 if ( (old_mb->cur_memory_used < old_mb->watermark) && (old_mb->first_buffer_index == RVF_INVALID_INDEX) && (old_mb->returned_red == TRUE) && ( old_mb->func != NULL) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1441 { old_mb->returned_red = FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1442 old_mb->func( buf->header.external.mb_id); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1443 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1444 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1445 /* change mb_id of the buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1446 buf->header.external.mb_id = mb_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1447 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1448 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1449 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1450 #if RVF_ENABLE_STATS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1451 if ( new_mb->cur_memory_used > new_mb->max_reached ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1452 { new_mb->max_reached = new_mb->cur_memory_used; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1453 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1454 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1455 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1456 if ( new_mb->cur_memory_used > new_mb->watermark ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1457 { return RVF_YELLOW; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1458 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1459 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1460 { return RVF_GREEN; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1461 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1462 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1463 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1464 { /* there is not enough memory in the new mb_id */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1465 if ( buf->header.external.mb_expected != RVF_INVALID_MB_ID) /* remove the buffer from old expected mb */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1466 { _remove_from_list( buf, &rvf_banks[ buf->header.external.mb_expected] ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1467 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1468 /* enqueue the buffer in the list of waiting buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1469 buf->header.external.mb_expected = mb_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1470 _add_to_list( buf, new_mb ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1471 new_mb->returned_red = TRUE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1472 return RVF_RED; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1473 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1474 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1475 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1476 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1477 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1478 ** Function rvf_free_buf |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1479 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1480 ** Description Called by an application to free a buffer |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1481 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1482 ** Parameters: buffer pointer |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1483 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1484 ** Returns T_RVF_RET: T_RVF_OK if succesful, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1485 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1486 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1487 T_RVF_RET rvf_free_buf( T_RVF_BUFFER * p_buffer) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1488 { T_RVF_INTERNAL_BUF * buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1489 T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1490 T_RVF_MB_ID mb_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1491 UINT32 buf_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1492 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1493 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1494 buf = USER2MEM(p_buffer); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1495 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1496 mb_id = buf->header.external.mb_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1497 mb = &rvf_banks[mb_id]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1498 buf_size = rvf_get_buf_size(p_buffer); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1499 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1500 /* do not need to change the mb id of the buffer, since it will be overwritten by p_prev */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1501 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1502 /* free the buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1503 if ( !_release_buf(buf) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1504 { return RVF_MEMORY_ERR; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1505 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1506 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1507 #if RVF_ENABLE_STATS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1508 mem_in_use -= buf_size + sizeof(T_RVF_INTERNAL_BUF) + RVF_CORRUPT_OVERHEAD; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1509 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1510 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1511 rvf_disable(20); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1512 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1513 /* decrease mb memory use */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1514 mb->cur_memory_used -= buf_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1515 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1516 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1517 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1518 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1519 /* call the callback function if state of the mb switches to RVF_GREEN and there is no buffer waiting */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1520 if ( (mb->returned_red == TRUE) && (mb->cur_memory_used < mb->watermark) && ( mb->first_buffer_index == RVF_INVALID_INDEX) && ( mb->func != NULL) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1521 { mb->returned_red = FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1522 mb->func( mb_id); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1523 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1524 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1525 { /* count as many waiting buffers as possible on the mb */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1526 while( (mb->first_buffer_index != RVF_INVALID_INDEX) && (rvf_count_buf( mb_id, (UINT8 *) (waiting_buffers[mb->first_buffer_index]) + sizeof(T_RVF_INTERNAL_BUF)) != RVF_RED) ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1527 if ( (mb->cur_memory_used < mb->watermark) && ( mb->first_buffer_index == RVF_INVALID_INDEX) && (mb->returned_red == TRUE) && ( mb->func != NULL) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1528 { mb->returned_red = FALSE; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1529 mb->func( mb_id); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1530 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1531 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1532 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1533 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1534 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1535 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1536 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1537 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1538 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1539 ** Function rvf_set_callback_func |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1540 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1541 ** Description Called the first time an application wants to set the callback |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1542 ** function associated to a memory bank. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1543 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1544 ** Parameters: memory bank id, pointer to the callback function. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1545 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1546 ** Returns T_RVF_RET: T_RVF_OK if succesful, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1547 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1548 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1549 T_RVF_RET rvf_set_callback_func(T_RVF_MB_ID mb_id, MB_CALLBACK_FUNC func) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1550 { T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1551 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1552 /* checking for invalid memory bank IDs */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1553 if (mb_id >= RVF_MAX_REAL_MB) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1554 return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1555 mb = &rvf_banks[mb_id]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1556 if ( (mb->max != 0) && (mb->func == NULL) ) /* if the mb has been created and the callback func has never been set */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1557 { mb->func = func; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1558 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1559 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1560 return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1561 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1562 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1563 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1564 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1565 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1566 ** Function rvf_change_callback_func |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1567 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1568 ** Description Called by an application to change the callback |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1569 ** function associated to a memory bank. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1570 ** It means the callback function has to be set before. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1571 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1572 ** Parameters: memory bank id, pointer to the callback function. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1573 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1574 ** Returns T_RVF_RET: T_RVF_OK if succesful, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1575 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1576 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1577 T_RVF_RET rvf_change_callback_func(T_RVF_MB_ID mb_id, MB_CALLBACK_FUNC func) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1578 { T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1579 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1580 /* checking for invalid memory bank IDs */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1581 if (mb_id >= RVF_MAX_REAL_MB) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1582 return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1583 mb = &rvf_banks[mb_id]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1584 if ( (mb->max != 0) && (mb->func != NULL) ) /* if the mb has been created and the callback func has already been set */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1585 { mb->func = func; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1586 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1587 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1588 return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1589 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1590 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1591 #ifdef _WINDOWS_ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1592 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1593 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1594 ** Function _rvf_window_dump_mem |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1595 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1596 ** Description Called by a C++ object to update the graphical display of |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1597 ** memory |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1598 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1599 ** Parameters: Opaque pointer to C++ object |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1600 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1601 ** Returns void |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1602 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1603 ** WARNING DON'T CHANGE THE SYNTAX OF DISPLAYED DATAS SINCE |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1604 ** THEY ARE PARSED TO DISPLAY GRAPHICALLY THE MEMORY |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1605 ** STATUS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1606 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1607 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1608 void _rvf_window_dump_mem(void *m) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1609 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1610 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1611 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1612 #if RVF_ENABLE_STATS /* conditional compilation if stats are enabled */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1613 char mb_info[100]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1614 UINT16 num_mb, num_buf, index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1615 UINT32 total_mem_size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1616 UINT32 total_max_used = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1617 UINT32 total_cur_used = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1618 T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1619 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1620 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1621 for ( num_mb = 0; num_mb < RVF_MAX_TOTAL_MB; num_mb++ ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1622 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1623 /* trace the mb if it has been created*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1624 if ( rvf_name_id[num_mb].mb_params.size > 0 ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1625 { mb = &rvf_banks[ rvf_name_id[num_mb].mb_id ]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1626 num_buf = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1627 index = mb->first_buffer_index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1628 while ( index != RVF_INVALID_INDEX) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1629 { num_buf++; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1630 index = next_buffer[index]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1631 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1632 strcpy(mb_info,rvf_name_id[num_mb].mb_name); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1633 mb_info[10]='\0'; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1634 AddNewState(m,mb_info, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1635 mb->cur_memory_used,mb->max_reached,mb->watermark,mb->max); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1636 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1637 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1638 total_mem_size += mb->max; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1639 total_max_used += mb->max_reached; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1640 total_cur_used += mb->cur_memory_used; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1641 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1642 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1643 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1644 #endif /* RVF_ENABLE_STATS */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1645 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1646 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1647 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1648 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1649 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1650 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1651 ** Function rvf_dump_mem |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1652 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1653 ** Description Called by an application to dump mb state and display statistics |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1654 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1655 ** Parameters: None |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1656 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1657 ** Returns void |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1658 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1659 ** WARNING DON'T CHANGE THE SYNTAX OF DISPLAYED DATAS SINCE |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1660 ** THEY ARE PARSED TO DISPLAY GRAPHICALLY THE MEMORY |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1661 ** STATUS |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1662 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1663 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1664 void rvf_dump_mem() |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1665 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1666 #if RVF_ENABLE_STATS /* conditional compilation if stats are enabled */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1667 char mb_info[100]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1668 UINT16 num_mb, num_buf, index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1669 UINT32 total_mem_size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1670 UINT32 total_max_used = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1671 UINT32 total_cur_used = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1672 T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1673 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1674 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1675 /* display memory required, obtained and ratio */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1676 rvf_send_trace("MEM STAT: Total memory required", 31, required_size, RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1677 rvf_send_trace("MEM STAT: Total memory obtained", 31, obtained_size, RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1678 rvf_send_trace("MEM STAT: Total memory used ", 31, used_size, RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1679 sprintf( mb_info,"MEM STAT: Mem usage ratio : %010f%%", ( (double)(required_size) / (double)(obtained_size) ) *100 ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1680 rvf_send_trace(mb_info, 44, NULL_PARAM , RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1681 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1682 rvf_send_trace("*** START DUMPING MEMORY BANK ***", 33, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1683 /* for each mb, display its name, its id, its cur_size, its watermark, its limit, its max reached, the number of callback functions enqueued, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1684 (the requested size, the number of allocated buffer), the average buffer size for this mb */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1685 rvf_send_trace("**MB_NAME* Id Used_mem Watermark Limit Peak Nb_buff Avg_buf_size", 67, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1686 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1687 for ( num_mb = 0; num_mb < RVF_MAX_TOTAL_MB; num_mb++ ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1688 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1689 /* trace the mb if it has been created*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1690 if ( rvf_name_id[num_mb].mb_params.size > 0 ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1691 { mb = &rvf_banks[ rvf_name_id[num_mb].mb_id ]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1692 num_buf = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1693 index = mb->first_buffer_index; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1694 while ( index != RVF_INVALID_INDEX) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1695 { num_buf++; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1696 index = next_buffer[index]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1697 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1698 sprintf( mb_info, "%10.10s %2d %6d %6d %6d %6d %2d %6d", |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1699 rvf_name_id[num_mb].mb_name, rvf_name_id[num_mb].mb_id, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1700 mb->cur_memory_used, mb->watermark, mb->max, mb->max_reached, num_buf, |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1701 mb->num_buf == 0? 0:mb->required_size / mb->num_buf); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1702 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1703 rvf_send_trace( mb_info, 67, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1704 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1705 total_mem_size += mb->max; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1706 total_max_used += mb->max_reached; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1707 total_cur_used += mb->cur_memory_used; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1708 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1709 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1710 sprintf( mb_info, "TOTAL: ******** %6d********** %6d %6d", |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1711 total_cur_used, total_mem_size, total_max_used ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1712 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1713 rvf_send_trace( mb_info, 46, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1714 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1715 #endif /* RVF_ENABLE_STATS */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1716 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1717 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1718 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1719 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1720 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1721 ** Function rvf_get_available_mem |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1722 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1723 ** Description Called to get the total size of the memory and the used size. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1724 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1725 ** Parameters: (return) UINT32 * total_size: contains the number of bytes in the memory. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1726 ** (return) UINT32 * used_size: contains the number of used bytes in the memory. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1727 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1728 ** Returns T_RVF_RET: RVF_OK if successful, else a negative value. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1729 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1730 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1731 T_RVF_RET rvf_get_available_mem( UINT32 * total_size, UINT32 * used_size ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1732 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1733 UINT16 count; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1734 *total_size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1735 *used_size = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1736 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1737 /* check if there is enough available physical memory (static or dynamic): if Sum(mb size) <= Sum(pool size)*/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1738 for ( count = 0; count < _rvf_get_number_of_pool(); count ++ ) /* sum the memory in pools */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1739 { *total_size += _rvf_pools[count].pool_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1740 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1741 /* sum the memory required by existing mb */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1742 for ( count = 0; count < RVF_MAX_REAL_MB; count ++ ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1743 { *used_size += rvf_banks[count].max; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1744 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1745 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1746 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1747 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1748 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1749 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1750 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1751 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1752 ** Function rvf_get_mb_param |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1753 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1754 ** Description return the parameters of a specific memory bank |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1755 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1756 ** Parameters: T_RVF_MB_NAME: name of the memory bank |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1757 ** (return) T_RVF_MB_PARAM*: parameter of the memory bank. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1758 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1759 ** Returns T_RVF_RET: RVF_OK if successful, else a negative value. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1760 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1761 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1762 T_RVF_RET rvf_get_mb_param( T_RVF_MB_NAME mb_name, T_RVF_MB_PARAM * param) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1763 { UINT8 num_mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1764 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1765 /* find the mb name in the array */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1766 for ( num_mb = 0; (num_mb < RVF_MAX_TOTAL_MB) && (!_str_cmp(mb_name, rvf_name_id[num_mb].mb_name) ); num_mb++); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1767 if ( num_mb == RVF_MAX_TOTAL_MB ) /* mb name not found */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1768 { return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1769 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1770 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1771 /* copy the parameters of the memory bank */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1772 *param = rvf_name_id[num_mb].mb_params; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1773 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1774 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1775 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1776 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1777 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1778 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1779 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1780 ** Function rvf_set_mb_param |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1781 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1782 ** Description change the parameters of a specific memory bank |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1783 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1784 ** Parameters: T_RVF_MB_NAME: name of the memory bank |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1785 ** T_RVF_MB_PARAM*: parameter of the memory bank. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1786 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1787 ** Returns T_RVF_RET: RVF_OK if successful, else a negative value. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1788 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1789 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1790 T_RVF_RET rvf_set_mb_param( T_RVF_MB_NAME mb_name, T_RVF_MB_PARAM * param) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1791 { UINT8 num_mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1792 T_RVF_MB_ID mb_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1793 T_RVF_MB * mb; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1794 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1795 /* find the mb name in the array */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1796 for ( num_mb = 0; (num_mb < RVF_MAX_TOTAL_MB) && (!_str_cmp(mb_name, rvf_name_id[num_mb].mb_name) ); num_mb++); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1797 if ( num_mb == RVF_MAX_TOTAL_MB ) /* mb name not found */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1798 { return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1799 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1800 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1801 mb_id = rvf_name_id[num_mb].mb_id; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1802 mb = &rvf_banks[ mb_id ]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1803 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1804 rvf_disable(20); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1805 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1806 /* decrease the mb param by the old parameters */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1807 mb->watermark -= rvf_name_id[num_mb].mb_params.watermark; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1808 mb->max -= rvf_name_id[num_mb].mb_params.size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1809 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1810 /* save the mb parameters */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1811 rvf_name_id[num_mb].mb_params.size = param->size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1812 rvf_name_id[num_mb].mb_params.watermark = param->watermark; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1813 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1814 /* increase the mb param by the new parameters */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1815 mb->watermark += param->watermark; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1816 mb->max += param->size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1817 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1818 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1819 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1820 /* dequeue callback functions if state switches to RVF_GREEN */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1821 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1822 return RVF_OK; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1823 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1824 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1825 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1826 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1827 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1828 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1829 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1830 ** Function rvf_empty_mailboxes |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1831 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1832 ** Description Called by rvf_exit_task to empty a task's mailboxes before |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1833 ** killing it |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1834 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1835 ** Parameters: task_id: task of wich the mailboxes have to be emptied |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1836 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1837 ** Returns RV_OK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1838 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1839 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1840 T_RV_RET _rvf_empty_mailboxes (T_RVF_G_ADDR_ID task_id) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1841 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1842 void * p_buf = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1843 T_RVF_INTERNAL_BUF * p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1844 UINT8 mbox_id = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1845 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1846 if (task_id >= MAX_RVF_TASKS) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1847 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1848 rvf_send_trace( "RVF: rvf_empty_mbox(): invalid taskid: ", 39, task_id, RV_TRACE_LEVEL_ERROR, RVM_USE_ID ); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1849 return RVF_INVALID_PARAMETER; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1850 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1851 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1852 for (mbox_id = 0; mbox_id< RVF_NUM_TASK_MBOX; mbox_id++) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1853 { /* while the chained list is not empty */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1854 /*while ( OSTaskQFirst[task_id][mbox_id] ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1855 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1856 rvf_disable(9); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1857 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1858 p_hdr = OSTaskQFirst[task_id][mbox_id]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1859 OSTaskQFirst[task_id][mbox_id] = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1860 */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1861 while ( pRtAddrIdTable[task_id]->OSTaskQFirst[mbox_id] ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1862 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1863 rvf_disable(9); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1864 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1865 p_hdr = pRtAddrIdTable[task_id]->OSTaskQFirst[mbox_id]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1866 pRtAddrIdTable[task_id]->OSTaskQFirst[mbox_id] = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1867 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1868 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1869 /* set as unlinked */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1870 RVF_SET_BUF_UNLINKED(p_hdr); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1871 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1872 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1873 p_buf = (UINT8 *)p_hdr + sizeof(T_RVF_INTERNAL_BUF); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1874 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1875 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1876 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1877 rvf_free_buf(p_buf); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1878 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1879 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1880 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1881 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1882 return (RV_OK); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1883 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1884 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1885 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1886 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1887 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1888 ** Function rvf_scan_next |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1889 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1890 ** Description return the next item in the queue if any. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1891 ** If the end of the queue is reached, returns NULL. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1892 ** If current item is NULL, returns the first item in the queue. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1893 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1894 ** Returns NULL if the end of the queue is reached, else a pointer to the buffer. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1895 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1896 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1897 T_RVF_BUFFER * rvf_scan_next (T_RVF_BUFFER_Q * p_q, T_RVF_BUFFER * p_buf) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1898 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1899 T_RVF_INTERNAL_BUF *p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1900 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1901 if (!p_q->count) /* if the queue is empty */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1902 return (NULL); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1903 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1904 if (p_buf == NULL) /* if current item == NULL, returns the first one */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1905 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1906 return (T_RVF_BUFFER*)p_q->p_first; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1907 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1908 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1909 rvf_disable(12); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1910 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1911 p_hdr = (T_RVF_INTERNAL_BUF *)((UINT8 *)p_buf - sizeof(T_RVF_INTERNAL_BUF)); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1912 p_hdr = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1913 if (p_hdr != NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1914 { p_hdr = (T_RVF_INTERNAL_BUF*) ((UINT8 *)p_hdr + sizeof(T_RVF_INTERNAL_BUF)); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1915 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1916 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1917 rvf_enable(); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1918 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1919 return (T_RVF_BUFFER*)p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1920 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1921 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1922 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1923 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1924 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1925 ** Function rvf_remove_from_queue |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1926 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1927 ** Description remove a specific item from a queue |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1928 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1929 ** Returns RVF_OK if the item is removed, RVF_INTERNAL_ERR else. |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1930 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1931 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1932 T_RVF_RET rvf_remove_from_queue (T_RVF_BUFFER_Q * p_q, T_RVF_BUFFER * p_buf) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1933 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1934 T_RVF_INTERNAL_BUF *p_hdr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1935 T_RVF_INTERNAL_BUF *p_target; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1936 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1937 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1938 if (!p_q->count) /* if the queue is empty */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1939 return (RVF_INTERNAL_ERR); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1940 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1941 rvf_disable(12); /* enter critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1942 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1943 /* find the specific item in the queue */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1944 p_target = USER2MEM((UINT8*)p_buf); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1945 p_hdr = USER2MEM( (UINT8 *)p_q->p_first); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1946 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1947 if( p_hdr == p_target ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1948 { /* the specific item is the first one */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1949 rvf_dequeue( p_q); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1950 rvf_enable(); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1951 return (RVF_OK); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1952 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1953 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1954 while( (p_hdr->p_next != p_target) && (p_hdr->p_next != NULL) ) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1955 { p_hdr = p_hdr->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1956 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1957 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1958 if( p_hdr->p_next == NULL) /* item not found */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1959 { rvf_enable(); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1960 return (RVF_INTERNAL_ERR); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1961 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1962 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1963 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1964 p_hdr->p_next = p_target->p_next; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1965 p_q->count--; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1966 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1967 /* if we removed the last buffer */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1968 if (p_q->p_last == p_buf) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1969 { p_q->p_last = p_hdr + sizeof(T_RVF_INTERNAL_BUF); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1970 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1971 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1972 p_target->p_next = NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1973 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1974 #if RVF_ENABLE_BUF_LINKAGE_CHECK |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1975 /* set as unlinked */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1976 RVF_SET_BUF_UNLINKED(p_target); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1977 #endif |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1978 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1979 rvf_enable(); /* exit critical section */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1980 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1981 return (RVF_OK); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1982 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1983 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1984 /******************************************************************************* |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1985 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1986 ** Function rvf_dump_pool |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1987 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1988 ** Description Called by an application to dump memory pool usage |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1989 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1990 ** Parameters: None |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1991 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1992 ** Returns void |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1993 ** |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1994 *******************************************************************************/ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1995 void rvf_dump_pool() |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1996 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1997 #if RVF_ENABLE_STATS /* conditional compilation if stats are enabled */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1998 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1999 UINT16 num_pool; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2000 UINT32 total_mem = 0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2001 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2002 /* display memory stats */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2003 rvf_send_trace("*** START DUMPING MEMORY ***", 28, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2004 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2005 /* display the total amount of memory available in the system */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2006 /* and the total amount of memory currently in use */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2007 for( num_pool = 0; num_pool < _rvf_get_number_of_pool(); num_pool++) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2008 { total_mem += _rvf_pools[num_pool].pool_size; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2009 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2010 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2011 rvf_send_trace( "Total memory available ", 23, total_mem, RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2012 rvf_send_trace( "Memory currently in use", 23, mem_in_use, RV_TRACE_LEVEL_DEBUG_HIGH, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2013 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2014 #endif /* RVF_ENABLE_STATS */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2015 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2016 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2017 static void rvf_free_protected_buf(void *buf) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2018 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2019 rvf_free_buf(buf); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2020 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2021 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2022 void rvf_get_protected_buf(T_RVF_MB_ID mb_id, UINT32 buffer_size, T_RVF_BUFFER** p_buffer) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2023 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2024 T_RVF_MB_STATUS err; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2025 err=rvf_get_buf(mb_id,buffer_size,p_buffer); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2026 if (err==RVF_GREEN) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2027 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2028 struct _protectedPtr_ *ptr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2029 struct _exceptionContext_ *context; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2030 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2031 context=_currentExceptionContext_[rvf_get_taskid()]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2032 err=rvf_get_buf(mb_id,sizeof(struct _protectedPtr_),(void*)&ptr); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2033 ptr->next=NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2034 ptr->previous=NULL; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2035 ptr->ptr=*p_buffer; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2036 ptr->func=rvf_free_protected_buf; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2037 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2038 if (err==RVF_GREEN) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2039 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2040 if (context->stack==NULL) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2041 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2042 context->stack=ptr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2043 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2044 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2045 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2046 ptr->previous=context->stack; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2047 context->stack->next=ptr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2048 context->stack=ptr; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2049 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2050 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2051 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2052 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2053 rvf_free_buf(*p_buffer); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2054 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2055 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2056 if (err!=RVF_GREEN) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2057 throw(E_not_enough_memory); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2058 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2059 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2060 //TISHMMS Project |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2061 /* add by xmzhou_trace_string to trace debug trace message */ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2062 void xmzhou_trace_string(char * string2trace) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2063 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2064 rvf_send_trace(string2trace,strlen(string2trace),NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2065 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2066 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2067 void xmzhou_trace_string_value(char * string2trace,UINT32 value) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2068 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2069 rvf_send_trace(string2trace,strlen(string2trace),value, RV_TRACE_LEVEL_DEBUG_LOW, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2070 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2071 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2072 static void mychar2hex(char ch, char *str) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2073 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2074 unsigned char h_nibble = (ch >> 4) & 0x0F; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2075 unsigned char l_nibble = ch & 0x0F; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2076 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2077 if (h_nibble < 10) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2078 str[0] = 48 + h_nibble; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2079 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2080 str[0] = 55 + h_nibble; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2081 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2082 if (l_nibble < 10) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2083 str[1] = 48 + l_nibble; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2084 else |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2085 str[1] = 55 + l_nibble; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2086 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2087 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2088 void xmzhou_trace_n_bytes(char * buffer0, UINT32 len) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2089 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2090 int i; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2091 int traced_len=0; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2092 char mybuffer[40]; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2093 char *tracebuffer; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2094 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2095 if(buffer0==NULL) return; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2096 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2097 xmzhou_trace_string_value("xmzhou dumping data length=",len); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2098 xmzhou_trace_string("-------"); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2099 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2100 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2101 while(traced_len<len){ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2102 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2103 if((len-traced_len)>=16){ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2104 tracebuffer=mybuffer; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2105 for (i = 0; i < 16; i++) { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2106 mychar2hex (buffer0[traced_len+i], tracebuffer); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2107 tracebuffer += 2; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2108 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2109 traced_len+=16; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2110 *tracebuffer = '\0'; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2111 rvf_send_trace(mybuffer,strlen(mybuffer),NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2112 rvf_delay(20); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2113 }else{ |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2114 tracebuffer=mybuffer; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2115 for(i=0;i<(len-traced_len);i++) |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2116 { |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2117 mychar2hex (buffer0[traced_len+i], tracebuffer); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2118 tracebuffer += 2; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2119 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2120 *tracebuffer = '\0'; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2121 rvf_send_trace(mybuffer,strlen(mybuffer),NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, RVM_USE_ID); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2122 rvf_delay(20); |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2123 break; |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2124 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2125 |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2126 } |
21de8d8e6ea7
checking in Riviera code from the Sotomodem version
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2127 } |