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