1 /* Copyright JS Foundation and other contributors, http://js.foundation
2 *
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 #include <infra/time.h>
17 #include <misc/printk.h>
18 #include <stdint.h>
19 #include <stdbool.h>
20 #include <stddef.h>
21 #include "jerryscript-port.h"
22
23 /**
24 * Provide log message implementation for the engine.
25 * Curie BSP implementation
26 */
27 void
jerry_port_log(jerry_log_level_t level,const char * format,...)28 jerry_port_log (jerry_log_level_t level, /**< log level */
29 const char *format, /**< format string */
30 ...) /**< parameters */
31 {
32 if (level <= JERRY_LOG_LEVEL_ERROR)
33 {
34 char buf[256];
35 int length = 0;
36 va_list args;
37 va_start (args, format);
38 length = vsnprintf (buf, 256, format, args);
39 buf[length] = '\0';
40 printk ("%s", buf);
41 va_end (args);
42 }
43 } /* jerry_port_log */
44
45 /**
46 * Curie BSP implementation of jerry_port_fatal.
47 */
jerry_port_fatal(jerry_fatal_code_t code)48 void jerry_port_fatal (jerry_fatal_code_t code)
49 {
50 jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Jerry Fatal Error!\n");
51 while (true);
52 } /* jerry_port_fatal */
53
54 /**
55 * Curie BSP implementation of jerry_port_get_local_time_zone_adjustment.
56 */
jerry_port_get_local_time_zone_adjustment(double unix_ms,bool is_utc)57 double jerry_port_get_local_time_zone_adjustment (double unix_ms, bool is_utc)
58 {
59 //EMPTY implementation
60 return 0;
61 } /* jerry_port_get_local_time_zone_adjustment */
62
63 /**
64 * Curie BSP implementation of jerry_port_get_current_time.
65 */
jerry_port_get_current_time(void)66 double jerry_port_get_current_time (void)
67 {
68 uint32_t uptime_ms = get_uptime_ms ();
69 uint32_t epoch_time = uptime_to_epoch (uptime_ms);
70
71 return ((double) epoch_time) * 1000.0;
72 } /* jerry_port_get_current_time */
73