• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /**
17  * @file picoextapi.c
18  *
19  * API extension for development use
20  *
21  * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland
22  * All rights reserved.
23  *
24  * History:
25  * - 2009-04-20 -- initial version
26  *
27  */
28 #include "picodefs.h"
29 #include "picoos.h"
30 #include "picoctrl.h"
31 #include "picodbg.h"
32 #include "picoapi.h"
33 #include "picoextapi.h"
34 #include "picoapid.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 #if 0
40 }
41 #endif
42 
43 /* this is not used anymore. For the picosh banner, set
44  * progv.progVers in picosh.c instead. */
45 #define PICO_VERSION_INFO  (picoos_char *)"invalid"
46 
47 
48 extern pico_Status pico_initialize_priv(
49         void *memory,
50         const pico_Uint32 size,
51         pico_Int16 enableMemProt,
52         pico_System *system);
53 
54 
55 /* System initialization and termination functions ****************************/
56 
57 
picoext_initialize(void * memory,const pico_Uint32 size,pico_Int16 enableMemProt,pico_System * outSystem)58 PICO_FUNC picoext_initialize(
59         void *memory,
60         const pico_Uint32 size,
61         pico_Int16 enableMemProt,
62         pico_System *outSystem
63         )
64 {
65     return pico_initialize_priv(memory, size, enableMemProt, outSystem);
66 }
67 
68 
69 /* System and lingware inspection functions ***********************************/
70 
71 /* @todo : not supported yet */
picoext_getVersionInfo(pico_Retstring outInfo,const pico_Int16 outInfoMaxLen)72 PICO_FUNC picoext_getVersionInfo(
73         pico_Retstring outInfo,
74         const pico_Int16 outInfoMaxLen
75         )
76 {
77     if (outInfo == NULL) {
78         return PICO_ERR_NULLPTR_ACCESS;
79     }
80     picoos_strlcpy((picoos_char *) outInfo, PICO_VERSION_INFO, outInfoMaxLen);
81     return PICO_OK;
82 }
83 
84 
85 /* Debugging/testing support functions *****************************************/
86 
87 
picoext_setTraceLevel(pico_System system,pico_Int32 level)88 PICO_FUNC picoext_setTraceLevel(
89         pico_System system,
90         pico_Int32 level
91         )
92 {
93     if (NULL == system) {
94         return PICO_ERR_NULLPTR_ACCESS;
95     }
96     if (level < 0) {
97         level = 0;
98     }
99     if (level > PICODBG_LOG_LEVEL_TRACE) {
100         level = PICODBG_LOG_LEVEL_TRACE;
101     }
102     PICODBG_SET_LOG_LEVEL(level);
103     return PICO_OK;
104 }
105 
106 
picoext_setTraceFilterFN(pico_System system,const pico_Char * name)107 PICO_FUNC picoext_setTraceFilterFN(
108         pico_System system,
109         const pico_Char *name
110         )
111 {
112 
113     if (NULL == system) {
114         return PICO_ERR_NULLPTR_ACCESS;
115     }
116     name = name;        /*PP 13.10.08 : fix warning "var not used in this function"*/
117     PICODBG_SET_LOG_FILTERFN((const char *)name);
118     return PICO_OK;
119 }
120 
121 
picoext_setLogFile(pico_System system,const pico_Char * name)122 PICO_FUNC picoext_setLogFile(
123         pico_System system,
124         const pico_Char *name
125         )
126 {
127     if (NULL == system) {
128         return PICO_ERR_NULLPTR_ACCESS;
129     }
130     name = name;        /*PP 13.10.08 : fix warning "var not used in this function"*/
131     PICODBG_SET_LOG_FILE((const char *) name);
132     return PICO_OK;
133 }
134 
135 
136 /* Memory usage ***************************************************************/
137 
138 
getMemUsage(picoos_Common common,picoos_bool resetIncremental,picoos_int32 * usedBytes,picoos_int32 * incrUsedBytes,picoos_int32 * maxUsedBytes)139 pico_Status getMemUsage(
140         picoos_Common common,
141         picoos_bool resetIncremental,
142         picoos_int32 *usedBytes,
143         picoos_int32 *incrUsedBytes,
144         picoos_int32 *maxUsedBytes
145         )
146 {
147     pico_Status status = PICO_OK;
148 
149     if (common == NULL) {
150         status =  PICO_ERR_NULLPTR_ACCESS;
151     } else {
152         picoos_emReset(common->em);
153         picoos_getMemUsage(common->mm, resetIncremental, usedBytes, incrUsedBytes, maxUsedBytes);
154         status = picoos_emGetExceptionCode(common->em);
155     }
156 
157     return status;
158 }
159 
160 
picoext_getSystemMemUsage(pico_System system,pico_Int16 resetIncremental,pico_Int32 * outUsedBytes,pico_Int32 * outIncrUsedBytes,pico_Int32 * outMaxUsedBytes)161 PICO_FUNC picoext_getSystemMemUsage(
162         pico_System system,
163         pico_Int16 resetIncremental,
164         pico_Int32 *outUsedBytes,
165         pico_Int32 *outIncrUsedBytes,
166         pico_Int32 *outMaxUsedBytes
167         )
168 {
169     pico_Status status = PICO_OK;
170 
171     if (!is_valid_system_handle(system)) {
172         status = PICO_ERR_INVALID_HANDLE;
173     } else if ((outUsedBytes == NULL) || (outIncrUsedBytes == NULL) || (outMaxUsedBytes == NULL)) {
174         status = PICO_ERR_NULLPTR_ACCESS;
175     } else {
176         picoos_Common common = pico_sysGetCommon(system);
177         status = getMemUsage(common, resetIncremental != 0, outUsedBytes, outIncrUsedBytes, outMaxUsedBytes);
178     }
179 
180     return status;
181 }
182 
183 
picoext_getEngineMemUsage(pico_Engine engine,pico_Int16 resetIncremental,pico_Int32 * outUsedBytes,pico_Int32 * outIncrUsedBytes,pico_Int32 * outMaxUsedBytes)184 PICO_FUNC picoext_getEngineMemUsage(
185         pico_Engine engine,
186         pico_Int16 resetIncremental,
187         pico_Int32 *outUsedBytes,
188         pico_Int32 *outIncrUsedBytes,
189         pico_Int32 *outMaxUsedBytes
190         )
191 {
192     pico_Status status = PICO_OK;
193 
194     if (!picoctrl_isValidEngineHandle((picoctrl_Engine) engine)) {
195         status = PICO_ERR_INVALID_HANDLE;
196     } else if ((outUsedBytes == NULL) || (outIncrUsedBytes == NULL) || (outMaxUsedBytes == NULL)) {
197         status = PICO_ERR_NULLPTR_ACCESS;
198     } else {
199         picoos_Common common = picoctrl_engGetCommon((picoctrl_Engine) engine);
200         status = getMemUsage(common, resetIncremental != 0, outUsedBytes, outIncrUsedBytes, outMaxUsedBytes);
201     }
202 
203     return status;
204 }
205 
picoext_getLastScheduledPU(pico_Engine engine)206 PICO_FUNC picoext_getLastScheduledPU(
207         pico_Engine engine
208         )
209 {
210     pico_Status status = PICO_OK;
211     status = picoctrl_getLastScheduledPU((picoctrl_Engine) engine);
212     return status;
213 }
214 
picoext_getLastProducedItemType(pico_Engine engine)215 PICO_FUNC picoext_getLastProducedItemType(
216         pico_Engine engine
217         )
218 {
219     pico_Status status = PICO_OK;
220     status = picoctrl_getLastProducedItemType((picoctrl_Engine) engine);
221     return status;
222 }
223 
224 #ifdef __cplusplus
225 }
226 #endif
227 
228 /* end */
229