1425bb815Sopenharmony_ci/* 2425bb815Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3425bb815Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4425bb815Sopenharmony_ci * you may not use this file except in compliance with the License. 5425bb815Sopenharmony_ci * You may obtain a copy of the License at 6425bb815Sopenharmony_ci * 7425bb815Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8425bb815Sopenharmony_ci * 9425bb815Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10425bb815Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS 11425bb815Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12425bb815Sopenharmony_ci * See the License for the specific language governing permissions and 13425bb815Sopenharmony_ci * limitations under the License. 14425bb815Sopenharmony_ci */ 15425bb815Sopenharmony_ci 16425bb815Sopenharmony_ci#ifdef JERRY_IAR_JUPITER 17425bb815Sopenharmony_ci 18425bb815Sopenharmony_ci#include "jerryscript.h" 19425bb815Sopenharmony_ci#include "jmem.h" 20425bb815Sopenharmony_ci#include "config-jupiter.h" 21425bb815Sopenharmony_ci#include "generate-bytecode.h" 22425bb815Sopenharmony_ci#include "los_task.h" 23425bb815Sopenharmony_ci 24425bb815Sopenharmony_ci#define MAX_CONTEXT_NUM (g_taskMaxNum+1) 25425bb815Sopenharmony_ci 26425bb815Sopenharmony_ciuint8_t* input_buffer; 27425bb815Sopenharmony_ciuint8_t* snapshot_buffer; 28425bb815Sopenharmony_ciuint8_t* bms_context_and_heap; 29425bb815Sopenharmony_ciuint8_t* js_context_and_heap; 30425bb815Sopenharmony_ciContextRecord* g_contextRecords; 31425bb815Sopenharmony_ci 32425bb815Sopenharmony_civoid JerryPsRamMemInit() 33425bb815Sopenharmony_ci{ 34425bb815Sopenharmony_ci // memory for js task 35425bb815Sopenharmony_ci#ifdef INDEPENDENT_HEAP 36425bb815Sopenharmony_ci js_context_and_heap = OhosMalloc(MEM_TYPE_JERRY_HEAP, JS_TASK_CONTEXT_AND_HEAP_SIZE_BYTE); 37425bb815Sopenharmony_ci#else 38425bb815Sopenharmony_ci js_context_and_heap = OhosMalloc(MEM_TYPE_JERRY_LSRAM, JS_TASK_CONTEXT_AND_HEAP_SIZE_BYTE); 39425bb815Sopenharmony_ci#endif // INDEPENDENT_HEAP 40425bb815Sopenharmony_ci} 41425bb815Sopenharmony_ci 42425bb815Sopenharmony_civoid JerryBmsPsRamMemInit() 43425bb815Sopenharmony_ci{ 44425bb815Sopenharmony_ci // memory for input_js file, snapshot file and bms task 45425bb815Sopenharmony_ci input_buffer = OhosMalloc(MEM_TYPE_JERRY_LSRAM, INPUTJS_BUFFER_SIZE); 46425bb815Sopenharmony_ci snapshot_buffer = OhosMalloc(MEM_TYPE_JERRY_LSRAM, SNAPSHOT_BUFFER_SIZE); 47425bb815Sopenharmony_ci bms_context_and_heap = OhosMalloc(MEM_TYPE_JERRY_LSRAM, BMS_TASK_CONTEXT_AND_HEAP_SIZE * CONVERTION_RATIO); 48425bb815Sopenharmony_ci} 49425bb815Sopenharmony_ci 50425bb815Sopenharmony_civoid JerryInitContextRecords() 51425bb815Sopenharmony_ci{ 52425bb815Sopenharmony_ci g_contextRecords = (ContextRecord*)OhosMalloc(MEM_TYPE_JERRY, (MAX_CONTEXT_NUM) * sizeof(ContextRecord)); 53425bb815Sopenharmony_ci if (g_contextRecords == NULL) { 54425bb815Sopenharmony_ci jerry_port_log (JERRY_LOG_LEVEL_ERROR, "[JERRYSCRIPT]Init g_contextRecords Error.\n"); 55425bb815Sopenharmony_ci } 56425bb815Sopenharmony_ci} 57425bb815Sopenharmony_ci 58425bb815Sopenharmony_ci#endif // JERRY_IAR_JUPITER 59