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 picoapi.c 18b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * 19b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * Copyright (C) 2008-2009 SVOX AG, Baslerstr. 30, 8048 Zuerich, Switzerland 20b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * All rights reserved. 21b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * 22b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * History: 23b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * - 2009-04-20 -- initial version 24b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen */ 25b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#include "picodefs.h" 26b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#include "picoos.h" 27b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#include "picodbg.h" 28b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#include "picorsrc.h" 29b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#include "picoctrl.h" 30b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#include "picoapi.h" 31b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#include "picoapid.h" 32b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 33b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#ifdef __cplusplus 34b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chenextern "C" { 35b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#endif 36b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 37b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* ****************************************************************************/ 38b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* System-level API functions */ 39b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* ****************************************************************************/ 40b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 41b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#define MAGIC_MASK 0x5069636F /* Pico */ 42b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 43b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#define SET_MAGIC_NUMBER(sys) \ 44d12fa9eb428db88f399a89566772eaed99b2fe58Marcus Oakland (sys)->magic = ((picoos_uint32) (uintptr_t) (sys)) ^ MAGIC_MASK 45b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 46b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#define CHECK_MAGIC_NUMBER(sys) \ 47d12fa9eb428db88f399a89566772eaed99b2fe58Marcus Oakland ((sys)->magic == (((picoos_uint32) (uintptr_t) (sys)) ^ MAGIC_MASK)) 48b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 49b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 50b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 51b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* *** Auxiliary routines (may also be called from picoextapi.c) **************/ 52b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 53b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 54b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chenint is_valid_system_handle(pico_System system) 55b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 56b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return (system != NULL) && CHECK_MAGIC_NUMBER(system); 57b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 58b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 59b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 60b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chenpicoos_Common pico_sysGetCommon(pico_System this) 61b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 62b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (this != NULL) { 63b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return this->common; 64b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 65b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return NULL; 66b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 67b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 68b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 69b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 70b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 71b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* *** System initialization and termination functions ************************/ 72b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chenpico_Status pico_initialize_priv( 73b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen void *memory, 74b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Uint32 size, 75b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Int16 enableMemProt, 76b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System *system 77b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 78b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 79b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 80b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 81b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen PICODBG_INITIALIZE(PICODBG_LOG_LEVEL_INFO); 82b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen PICODBG_ENABLE_COLORS(0); 83b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen /*PICODBG_SET_OUTPUT_FORMAT((PICODBG_SHOW_LEVEL | PICODBG_SHOW_SRCNAME));*/ 84b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 85b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (memory == NULL) { 86b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 87b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (size == 0) { 88b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_ARGUMENT; 89b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (system == NULL) { 90b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 91b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 92b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen byte_ptr_t rest_mem; 93d12fa9eb428db88f399a89566772eaed99b2fe58Marcus Oakland picoos_objsize_t rest_mem_size; 94b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System sys; 95b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_MemoryManager sysMM; 96b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_ExceptionManager sysEM; 97b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 98b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen sys = (pico_System) picoos_raw_malloc(memory, size, sizeof(pico_system_t), 99b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen &rest_mem, &rest_mem_size); 100b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (sys != NULL) { 101b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen sysMM = picoos_newMemoryManager(rest_mem, rest_mem_size, enableMemProt ? TRUE : FALSE); 102b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (sysMM != NULL) { 103b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen sysEM = picoos_newExceptionManager(sysMM); 104b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen sys->common = picoos_newCommon(sysMM); 105b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen sys->rm = picorsrc_newResourceManager(sysMM, sys->common); 106b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if ((sysEM != NULL) && (sys->common != NULL) && (sys->rm != NULL)) { 107b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen sys->common->em = sysEM; 108b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen sys->common->mm = sysMM; 109b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen sys->engine = NULL; 110b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 111b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picorsrc_createDefaultResource(sys->rm /*,&defaultResource */); 112b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 113b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen SET_MAGIC_NUMBER(sys); 114b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_OK; 115b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 116b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_EXC_OUT_OF_MEM; 117b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 118b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 119b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_EXC_OUT_OF_MEM; 120b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 121b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 122b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_EXC_OUT_OF_MEM; 123b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 124b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *system = sys; 125b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 126b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 127b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (status != PICO_OK) { 128b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (system != NULL) { 129b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *system = NULL; 130b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 131b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen PICODBG_TERMINATE(); 132b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 133b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 134b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 135b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 136b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 137b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_initialize : initializes the pico system private memory 138b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param memory : pointer to a free and already allocated memory area 139b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param size : size of the memory area 140b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 141b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful init, !PICO_OK : error on allocating private memory 142b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 143b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 144b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 145b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_initialize( 146b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen void *memory, 147b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Uint32 size, 148b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System *system 149b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 150b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 151b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return pico_initialize_priv(memory, size, /*enableMemProt*/ FALSE, system); 152b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 153b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 154b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 155b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_terminate : deallocates the pico system private memory 156b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 157b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful de-init, !PICO_OK : error on de-allocating private memory 158b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 159b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 160b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 161b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_terminate( 162b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System *system 163b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 164b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 165b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 166b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 167b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if ((system == NULL) || !is_valid_system_handle(*system)) { 168b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 169b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 170b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System sys = *system; 171b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 172b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen /* close engine(s) */ 173b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoctrl_disposeEngine(sys->common->mm, sys->rm, &sys->engine); 174b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 175b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen /* close all resources */ 176b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picorsrc_disposeResourceManager(sys->common->mm, &sys->rm); 177b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 178b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen sys->magic ^= 0xFFFEFDFC; 179b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *system = NULL; 180b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 181b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 182b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen PICODBG_TERMINATE(); 183b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 184b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 185b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 186b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 187b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 188b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 189b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* *** System status and error/warning message retrieval function *************/ 190b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 191b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 192b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_getSystemStatusMessage : Returns a description of the system status or errors 193b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 194b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param errCode : pico_System error code 195b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param outMessage : memory area where to return a string 196b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 197b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 198b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 199b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 200b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 201b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_getSystemStatusMessage( 202b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 203b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status errCode, 204b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Retstring outMessage 205b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 206b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 207b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 208b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 209b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 210b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 211b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (outMessage != NULL) { 212b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_strlcpy((picoos_char *) outMessage, (picoos_char *) "'system' not initialized", PICO_RETSTRINGSIZE); 213b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 214b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (outMessage == NULL) { 215b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 216b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 217b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (picoos_emGetExceptionCode(system->common->em) == PICO_OK) { 218b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (errCode == PICO_OK) { 219b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_strlcpy((picoos_char *) outMessage, (picoos_char *) "system ok", PICO_RETSTRINGSIZE); 220b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 221b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen /* exceptionManager was not informed yet; produce default message */ 222b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_setErrorMsg((picoos_char *) outMessage, PICO_RETSTRINGSIZE, errCode, NULL, NULL, NULL); 223b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 224b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 225b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emGetExceptionMessage(system->common->em, (picoos_char *) outMessage, PICO_RETSTRINGSIZE); 226b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 227b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 228b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 229b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 230b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 231b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 232b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 233b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_getSystemStatusMessage : Returns the number of warnings 234b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 235b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *outNrOfWarnings : pointer to location to receive number of warnings 236b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 237b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 238b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 239b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 240b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 241b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_getNrSystemWarnings( 242b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 243b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Int32 *outNrOfWarnings 244b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 245b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 246b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 247b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 248b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 249b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 250b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (outNrOfWarnings != NULL) { 251b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *outNrOfWarnings = 0; 252b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 253b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (outNrOfWarnings == NULL) { 254b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 255b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 256b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *outNrOfWarnings = picoos_emGetNumOfWarnings(system->common->em); 257b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 258b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 259b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 260b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 261b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 262b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 263b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_getSystemWarning : Returns a description of a warning 264b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 265b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param warningIndex : warning index 266b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *outCode : pointer to receive the warning code 267b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param outMessage : pointer to receive the output message 268b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 269b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 270b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 271b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 272b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 273b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_getSystemWarning( 274b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 275b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Int32 warningIndex, 276b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status *outCode, 277b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Retstring outMessage 278b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 279b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 280b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 281b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 282b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 283b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 284b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (outMessage != NULL) { 285b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_strlcpy((picoos_char *) outMessage, (picoos_char *) "'system' not initialized", PICO_RETSTRINGSIZE); 286b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 287b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (warningIndex < 0) { 288b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INDEX_OUT_OF_RANGE; 289b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if ((outCode == NULL) || (outMessage == NULL)) { 290b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 291b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 292b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *outCode = picoos_emGetWarningCode(system->common->em, warningIndex); 293b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emGetWarningMessage(system->common->em, warningIndex, (picoos_char *) outMessage, (picoos_uint16) PICO_RETSTRINGSIZE); 294b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 295b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 296b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 297b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 298b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 299b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 300b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 301b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* *** Resource loading and unloading functions *******************************/ 302b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 303b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 304b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_loadResource : Loads a resource file into the Pico system 305b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 306b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *lingwareFileName : lingware resource file name 307b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *outLingware : pointer to receive the loaded lingware resource memory area address 308b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 309b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 310b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 311b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 312b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 313b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_loadResource( 314b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 315b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Char *lingwareFileName, 316b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Resource *outLingware 317b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 318b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 319b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 320b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 321b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 322b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 323b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if ((lingwareFileName == NULL) || (outLingware == NULL)) { 324b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 325b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 326b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen PICODBG_DEBUG(("memory usage before resource loading")); 327b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_showMemUsage(system->common->mm, FALSE, TRUE); 328b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emReset(system->common->em); 329b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = picorsrc_loadResource(system->rm, (picoos_char *) lingwareFileName, (picorsrc_Resource *) outLingware); 330b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen PICODBG_DEBUG(("memory used to load resource %s", lingwareFileName)); 331b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_showMemUsage(system->common->mm, TRUE, FALSE); 332b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 333b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 334b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 335b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 336b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 337b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 338b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_unloadResource : unLoads a resource file from the Pico system 339b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 340b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *inoutLingware : pointer to the loaded lingware resource memory area address 341b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 342b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 343b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 344b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 345b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 346b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_unloadResource( 347b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 348b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Resource *inoutLingware 349b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 350b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 351b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 352b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 353b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 354b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 355b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (inoutLingware == NULL) { 356b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 357b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (!picoctrl_isValidResourceHandle(*((picorsrc_Resource *) inoutLingware))) { 358b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 359b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 360b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen PICODBG_DEBUG(("memory usage before resource unloading")); 361b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_showMemUsage(system->common->mm, FALSE, TRUE); 362b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emReset(system->common->em); 363b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = picorsrc_unloadResource(system->rm, (picorsrc_Resource *) inoutLingware); 364b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen PICODBG_DEBUG(("memory released by resource unloading")); 365b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_showMemUsage(system->common->mm, TRUE, FALSE); 366b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 367b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 368b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 369b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 370b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 371b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* *** Resource inspection functions *******************************/ 372b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 373b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_getResourceName : Gets a resource name 374b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 375b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param resource : pointer to the loaded resource memory area address 376b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param outName : pointer to the area to receuive the resource name 377b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 378b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 379b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 380b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 381b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 382b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_getResourceName( 383b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 384b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Resource resource, 385b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Retstring outName) { 386b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 387b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 388b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return PICO_ERR_INVALID_HANDLE; 389b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (NULL == outName) { 390b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return PICO_ERR_NULLPTR_ACCESS; 391b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 392b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return picorsrc_rsrcGetName((picorsrc_Resource)resource, (picoos_char *) outName, PICO_RETSTRINGSIZE); 393b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 394b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 395b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 396b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* *** Voice definition functions *********************************************/ 397b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 398b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 399b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_createVoiceDefinition : Creates a voice definition 400b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 401b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *voiceName : pointer to the area to receive the voice definition 402b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 403b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 404b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 405b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 406b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 407b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_createVoiceDefinition( 408b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 409b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Char *voiceName 410b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 411b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 412b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 413b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 414b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 415b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 416b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (voiceName == NULL) { 417b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 418b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (picoos_strlen((picoos_char *) voiceName) == 0) { 419b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_ARGUMENT; 420b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 421b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emReset(system->common->em); 422b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = picorsrc_createVoiceDefinition(system->rm, (picoos_char *) voiceName); 423b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 424b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 425b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 426b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 427b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 428b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 429b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_addResourceToVoiceDefinition : Adds a mapping pair to a voice definition 430b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 431b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *voiceName : pointer to the area containing the voice definition 432b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *resourceName : pointer to the area containing the resource name 433b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 434b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 435b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 436b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 437b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 438b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_addResourceToVoiceDefinition( 439b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 440b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Char *voiceName, 441b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Char *resourceName 442b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 443b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 444b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 445b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 446b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 447b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 448b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (voiceName == NULL) { 449b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 450b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (picoos_strlen((picoos_char *) voiceName) == 0) { 451b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_ARGUMENT; 452b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (resourceName == NULL) { 453b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 454b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (picoos_strlen((picoos_char *) resourceName) == 0) { 455b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_ARGUMENT; 456b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 457b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emReset(system->common->em); 458b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = picorsrc_addResourceToVoiceDefinition(system->rm, (picoos_char *) voiceName, (picoos_char *) resourceName); 459b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 460b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 461b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 462b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 463b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 464b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 465b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_releaseVoiceDefinition : Releases a voice definition 466b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 467b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *voiceName : pointer to the area containing the voice definition 468b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 469b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 470b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 471b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 472b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 473b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_releaseVoiceDefinition( 474b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 475b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Char *voiceName 476b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 477b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 478b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 479b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 480b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 481b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 482b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (voiceName == NULL) { 483b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 484b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (picoos_strlen((picoos_char *) voiceName) == 0) { 485b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_ARGUMENT; 486b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 487b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emReset(system->common->em); 488b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = picorsrc_releaseVoiceDefinition(system->rm, (picoos_char *) voiceName); 489b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 490b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 491b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 492b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 493b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 494b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 495b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 496b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* *** Engine creation and deletion functions *********************************/ 497b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 498b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 499b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_newEngine : Creates and initializes a new Pico engine 500b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 501b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *voiceName : pointer to the area containing the voice definition 502b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *outEngine : pointer to the Pico engine handle 503b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 504b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 505b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 506b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 507b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 508b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_newEngine( 509b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 510b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Char *voiceName, 511b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Engine *outEngine 512b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 513b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 514b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 515b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 516b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen PICODBG_DEBUG(("creating engine for voice '%s'", (picoos_char *) voiceName)); 517b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 518b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 519b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 520b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (voiceName == NULL) { 521b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 522b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (picoos_strlen((picoos_char *) voiceName) == 0) { 523b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_ARGUMENT; 524b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (outEngine == NULL) { 525b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 526b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 527b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emReset(system->common->em); 528b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (system->engine == NULL) { 529b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *outEngine = (pico_Engine) picoctrl_newEngine(system->common->mm, system->rm, voiceName); 530b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (*outEngine != NULL) { 531b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen system->engine = (picoctrl_Engine) *outEngine; 532b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 533b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = picoos_emRaiseException(system->common->em, PICO_EXC_OUT_OF_MEM, 534b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen (picoos_char *) "out of memory creating new engine", NULL); 535b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 536b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 537b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = picoos_emRaiseException(system->common->em, PICO_EXC_MAX_NUM_EXCEED, 538b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen NULL, (picoos_char *) "no more than %i engines", 1); 539b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 540b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 541b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 542b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 543b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 544b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 545b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 546b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_disposeEngine : Disposes a Pico engine 547b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param system : pointer to a pico_System struct 548b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *inoutEngine : pointer to the Pico engine handle 549b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 550b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 551b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 552b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 553b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 554b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_disposeEngine( 555b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_System system, 556b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Engine *inoutEngine 557b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 558b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 559b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 560b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 561b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!is_valid_system_handle(system)) { 562b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 563b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (inoutEngine == NULL) { 564b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 565b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (!picoctrl_isValidEngineHandle(*((picoctrl_Engine *) inoutEngine))) { 566b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 567b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 568b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emReset(system->common->em); 569b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoctrl_disposeEngine(system->common->mm, system->rm, (picoctrl_Engine *) inoutEngine); 570b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen system->engine = NULL; 571b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = picoos_emGetExceptionCode(system->common->em); 572b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 573b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 574b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 575b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 576b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 577b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 578b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 579b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* ****************************************************************************/ 580b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* Engine-level API functions */ 581b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* ****************************************************************************/ 582b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 583b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 584b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_putTextUtf8 : Puts UTF8 text into Pico text input buffer 585b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param engine : pointer to a Pico engine handle 586b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *text : pointer to the text buffer 587b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param textSize : text buffer size 588b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *bytesPut : pointer to variable to receive the number of bytes put 589b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 590b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 591b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 592b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 593b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen */ 594b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_putTextUtf8( 595b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Engine engine, 596b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Char *text, 597b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Int16 textSize, 598b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Int16 *bytesPut) 599b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 600b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 601b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 602b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!picoctrl_isValidEngineHandle((picoctrl_Engine) engine)) { 603b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 604b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (text == NULL) { 605b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 606b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (textSize < 0) { 607b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_ARGUMENT; 608b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (bytesPut == NULL) { 609b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 610b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 611b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoctrl_engResetExceptionManager((picoctrl_Engine) engine); 612b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = picoctrl_engFeedText((picoctrl_Engine) engine, (picoos_char *)text, textSize, bytesPut); 613b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 614b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 615b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 616b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 617b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 618b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 619b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_getData : Gets speech data from the engine. 620b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param engine : pointer to a Pico engine handle 621b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *buffer : pointer to output buffer 622b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param bufferSize : out buffer size 623b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *bytesReceived : pointer to a variable to receive the number of bytes received 624b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *outDataType : pointer to a variable to receive the type of buffer received 625b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 626b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 627b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 628b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 629b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 630b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_getData( 631b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Engine engine, 632b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen void *buffer, 633b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Int16 bufferSize, 634b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Int16 *bytesReceived, 635b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Int16 *outDataType 636b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 637b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 638b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 639b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 640b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!picoctrl_isValidEngineHandle((picoctrl_Engine) engine)) { 641b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_STEP_ERROR; 642b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (buffer == NULL) { 643b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_STEP_ERROR; 644b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (bufferSize < 0) { 645b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_STEP_ERROR; 646b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (bytesReceived == NULL) { 647b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_STEP_ERROR; 648b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 649b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoctrl_engResetExceptionManager((picoctrl_Engine) engine); 650b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = picoctrl_engFetchOutputItemBytes((picoctrl_Engine) engine, (picoos_char *)buffer, bufferSize, bytesReceived); 651b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if ((status != PICO_STEP_IDLE) && (status != PICO_STEP_BUSY)) { 652b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_STEP_ERROR; 653b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 654b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 655b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 656b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *outDataType = PICO_DATA_PCM_16BIT; 657b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 658b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 659b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 660b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 661b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_resetEngine : Resets the engine 662b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param engine : pointer to a Pico engine handle 663e9f72c8954f29f10cb4feb16d328a1b5c1fd7169Jean-Michel Trivi * @param resetMode : reset mode; one of PICO_RESET_FULL or PICO_RESET_SOFT 664b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 665b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 666b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 667b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 668b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 669b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_resetEngine( 6707bc39b0d41efe0d8733490d54e14bc392d9f0b6dJean-Michel Trivi pico_Engine engine, 671e9f72c8954f29f10cb4feb16d328a1b5c1fd7169Jean-Michel Trivi pico_Int32 resetMode) 672b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 673b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 674b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 675b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!picoctrl_isValidEngineHandle((picoctrl_Engine) engine)) { 676b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 677b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 678b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoctrl_engResetExceptionManager((picoctrl_Engine) engine); 6797bc39b0d41efe0d8733490d54e14bc392d9f0b6dJean-Michel Trivi 680e9f72c8954f29f10cb4feb16d328a1b5c1fd7169Jean-Michel Trivi resetMode = (PICO_RESET_SOFT == resetMode) ? PICO_RESET_SOFT : PICO_RESET_FULL; 6817bc39b0d41efe0d8733490d54e14bc392d9f0b6dJean-Michel Trivi 682e9f72c8954f29f10cb4feb16d328a1b5c1fd7169Jean-Michel Trivi status = picoctrl_engReset((picoctrl_Engine) engine, (picoos_int32)resetMode); 683b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 684b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 685b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 686b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 687b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 688b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 689b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_getEngineStatusMessage : Returns the engine status or error description 690b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param engine : pointer to a Pico engine handle 691b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param errCode : error code 692b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param outMessage : pointer to a memory area to receive the output message 693b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 694b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 695b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 696b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 697b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 698b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_getEngineStatusMessage( 699b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Engine engine, 700b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status errCode, 701b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Retstring outMessage 702b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 703b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 704b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 705b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 706b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen PICODBG_DEBUG(("got error code %i", errCode)); 707b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 708b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!picoctrl_isValidEngineHandle((picoctrl_Engine) engine)) { 709b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 710b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (outMessage != NULL) { 711b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_strlcpy((picoos_char *) outMessage, (picoos_char *) "'engine' not initialized", PICO_RETSTRINGSIZE); 712b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 713b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (outMessage == NULL) { 714b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 715b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 716b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_Common common = picoctrl_engGetCommon((picoctrl_Engine) engine); 717b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (picoos_emGetExceptionCode(common->em) == PICO_OK) { 718b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (errCode == PICO_OK) { 719b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_strlcpy((picoos_char *) outMessage, (picoos_char *) "engine ok", PICO_RETSTRINGSIZE); 720b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 721b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen /* exceptionManager was not informed yet; produce default message */ 722b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_setErrorMsg((picoos_char *) outMessage, PICO_RETSTRINGSIZE, errCode, NULL, NULL, NULL); 723b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 724b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 725b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emGetExceptionMessage(common->em, (picoos_char *) outMessage, PICO_RETSTRINGSIZE); 726b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 727b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 728b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 729b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 730b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 731b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 732b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 733b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_getNrEngineWarnings : Returns the number of warnings 734b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param engine : pointer to a Pico engine handle 735b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *outNrOfWarnings: pointer to a variable to receive the number of warnings 736b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 737b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 738b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 739b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 740b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 741b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_getNrEngineWarnings( 742b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Engine engine, 743b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Int32 *outNrOfWarnings 744b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 745b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 746b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 747b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 748b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!picoctrl_isValidEngineHandle((picoctrl_Engine) engine)) { 749b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 750b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (outNrOfWarnings != NULL) { 751b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *outNrOfWarnings = 0; 752b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 753b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (outNrOfWarnings == NULL) { 754b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 755b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 756b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_Common common = picoctrl_engGetCommon((picoctrl_Engine) engine); 757b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *outNrOfWarnings = picoos_emGetNumOfWarnings(common->em); 758b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 759b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 760b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 761b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 762b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 763b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/** 764b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * pico_getEngineWarning : Returns a description of a warning 765b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param engine : pointer to a Pico engine handle 766b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param warningIndex : warning index 767b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param *outCode: pointer to a variable to receive the warning code 768b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @param outMessage: pointer to a memory area to receive the warning description 769b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_OK : successful 770b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @return PICO_ERR_INVALID_HANDLE, PICO_ERR_NULLPTR_ACCESS : errors 771b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callgraph 772b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen * @callergraph 773b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen*/ 774b190149a69b110e6719ce0a41877a683f8db7ae7Charles ChenPICO_FUNC pico_getEngineWarning( 775b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Engine engine, 776b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen const pico_Int32 warningIndex, 777b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status *outCode, 778b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Retstring outMessage 779b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen ) 780b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen{ 781b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen pico_Status status = PICO_OK; 782b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 783b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (!picoctrl_isValidEngineHandle((picoctrl_Engine) engine)) { 784b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INVALID_HANDLE; 785b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen if (outMessage != NULL) { 786b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_strlcpy((picoos_char *) outMessage, (picoos_char *) "'engine' not initialized", PICO_RETSTRINGSIZE); 787b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 788b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if (warningIndex < 0) { 789b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_INDEX_OUT_OF_RANGE; 790b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else if ((outCode == NULL) || (outMessage == NULL)) { 791b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen status = PICO_ERR_NULLPTR_ACCESS; 792b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } else { 793b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_Common common = picoctrl_engGetCommon((picoctrl_Engine) engine); 794b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen *outCode = picoos_emGetWarningCode(common->em, warningIndex); 795b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen picoos_emGetWarningMessage(common->em, warningIndex, (picoos_char *) outMessage, (picoos_uint16) PICO_RETSTRINGSIZE); 796b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen } 797b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 798b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen return status; 799b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 800b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 801b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#ifdef __cplusplus 802b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen} 803b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen#endif 804b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 805b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen 806b190149a69b110e6719ce0a41877a683f8db7ae7Charles Chen/* end */ 807