1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifdef JERRY_IAR_JUPITER
17
18 #include "jerryscript.h"
19 #include "jmem.h"
20 #include "config-jupiter.h"
21 #include "generate-bytecode.h"
22 #include "los_task.h"
23
24 #define MAX_CONTEXT_NUM (g_taskMaxNum+1)
25
26 uint8_t* input_buffer;
27 uint8_t* snapshot_buffer;
28 uint8_t* bms_context_and_heap;
29 uint8_t* js_context_and_heap;
30 ContextRecord* g_contextRecords;
31
JerryPsRamMemInit()32 void JerryPsRamMemInit()
33 {
34 // memory for js task
35 #ifdef INDEPENDENT_HEAP
36 js_context_and_heap = OhosMalloc(MEM_TYPE_JERRY_HEAP, JS_TASK_CONTEXT_AND_HEAP_SIZE_BYTE);
37 #else
38 js_context_and_heap = OhosMalloc(MEM_TYPE_JERRY_LSRAM, JS_TASK_CONTEXT_AND_HEAP_SIZE_BYTE);
39 #endif // INDEPENDENT_HEAP
40 }
41
JerryBmsPsRamMemInit()42 void JerryBmsPsRamMemInit()
43 {
44 // memory for input_js file, snapshot file and bms task
45 input_buffer = OhosMalloc(MEM_TYPE_JERRY_LSRAM, INPUTJS_BUFFER_SIZE);
46 snapshot_buffer = OhosMalloc(MEM_TYPE_JERRY_LSRAM, SNAPSHOT_BUFFER_SIZE);
47 bms_context_and_heap = OhosMalloc(MEM_TYPE_JERRY_LSRAM, BMS_TASK_CONTEXT_AND_HEAP_SIZE * CONVERTION_RATIO);
48 }
49
JerryInitContextRecords()50 void JerryInitContextRecords()
51 {
52 g_contextRecords = (ContextRecord*)OhosMalloc(MEM_TYPE_JERRY, (MAX_CONTEXT_NUM) * sizeof(ContextRecord));
53 if (g_contextRecords == NULL) {
54 jerry_port_log (JERRY_LOG_LEVEL_ERROR, "[JERRYSCRIPT]Init g_contextRecords Error.\n");
55 }
56 }
57
58 #endif // JERRY_IAR_JUPITER
59