mirror of
https://github.com/google/pebble.git
synced 2025-06-24 18:16:15 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
16
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/defconfig
vendored
Normal file
16
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/defconfig
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
CONFIG_AUTO_SERVICE_INIT=y
|
||||
CONFIG_CFW_PROXY=y
|
||||
CONFIG_CFW_QUARK_SE_HELPERS=y
|
||||
CONFIG_LOG_SLAVE=y
|
||||
CONFIG_MEM_POOL_DEF_PATH="$(PROJECT_PATH)/arc"
|
||||
CONFIG_OS_ZEPHYR=y
|
||||
CONFIG_SERVICES_QUARK_SE_ADC_IMPL=y
|
||||
CONFIG_SERVICES_QUARK_SE_GPIO_IMPL=y
|
||||
CONFIG_SOC_GPIO_AON=y
|
||||
CONFIG_SOC_GPIO=y
|
||||
CONFIG_SS_ADC=y
|
||||
CONFIG_SS_GPIO=y
|
||||
CONFIG_TCMD_SLAVE=y
|
||||
CONFIG_TCMD=y
|
||||
CONFIG_ZEPHYR_BOARD="arduino_101_sss"
|
||||
CONFIG_CONSOLE_HANDLER_SHELL=y
|
35
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/main.c
vendored
Normal file
35
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/main.c
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* infra */
|
||||
#include "infra/log.h"
|
||||
#include "infra/bsp.h"
|
||||
#include "infra/xloop.h"
|
||||
#include "cfw/cfw.h"
|
||||
|
||||
static xloop_t loop;
|
||||
|
||||
void main (void)
|
||||
{
|
||||
T_QUEUE queue = bsp_init ();
|
||||
|
||||
pr_info (LOG_MODULE_MAIN, "BSP init done");
|
||||
|
||||
cfw_init (queue);
|
||||
pr_info (LOG_MODULE_MAIN, "CFW init done");
|
||||
|
||||
xloop_init_from_queue (&loop, queue);
|
||||
|
||||
xloop_run (&loop);
|
||||
}
|
36
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/memory_pool_list.def
vendored
Normal file
36
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/memory_pool_list.def
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definition of the memory pools used by balloc/bfree:
|
||||
* DECLARE_MEMORY_POOL( <index>, <size>, <count>, <align> )
|
||||
* <index> : must start at 0 and be of consecutive values *
|
||||
* <size> : size in bytes of each block from the pool
|
||||
* <count> : number of blocks in the pool
|
||||
*
|
||||
* * Pool definitions must be sorted according the block size
|
||||
* value: pool with <index> 0 must have the smallest <size>.
|
||||
*/
|
||||
|
||||
DECLARE_MEMORY_POOL(0,8,32)
|
||||
DECLARE_MEMORY_POOL(1,16,32)
|
||||
DECLARE_MEMORY_POOL(2,32,48)
|
||||
DECLARE_MEMORY_POOL(3,64,16)
|
||||
DECLARE_MEMORY_POOL(4,96,24)
|
||||
DECLARE_MEMORY_POOL(5,128,6)
|
||||
DECLARE_MEMORY_POOL(6,256,5)
|
||||
DECLARE_MEMORY_POOL(7,512,1)
|
||||
|
||||
#undef DECLARE_MEMORY_POOL
|
30
third_party/jerryscript/targets/curie_bsp/jerry_app/include/project_mapping.h
vendored
Normal file
30
third_party/jerryscript/targets/curie_bsp/jerry_app/include/project_mapping.h
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allow project to override this partition scheme
|
||||
* The following variables are allowed to be defined:
|
||||
*
|
||||
* QUARK_START_PAGE the first page where the QUARK code is located
|
||||
* QUARK_NB_PAGE the number of pages reserved for the QUARK. The ARC gets the
|
||||
* remaining pages (out of 148).
|
||||
*/
|
||||
#ifndef PROJECT_MAPPING_H
|
||||
#define PROJECT_MAPPING_H
|
||||
|
||||
#define QUARK_NB_PAGE 125
|
||||
#include "machine/soc/intel/quark_se/quark_se_mapping.h"
|
||||
|
||||
#endif /* !PROJECT_MAPPING_H */
|
35
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/defconfig
vendored
Normal file
35
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/defconfig
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
CONFIG_AUTO_SERVICE_INIT=y
|
||||
CONFIG_CFW_QUARK_SE_HELPERS=y
|
||||
CONFIG_CONSOLE_MANAGER=y
|
||||
CONFIG_DEBUG_PANIC_TCMD=y
|
||||
CONFIG_FACTORY_DATA_WRITE=y
|
||||
CONFIG_FACTORY_DATA=y
|
||||
CONFIG_INTEL_QRK_AON_PT=y
|
||||
CONFIG_INTEL_QRK_RTC=y
|
||||
CONFIG_INTEL_QRK_SPI=y
|
||||
CONFIG_INTEL_QRK_WDT=y
|
||||
CONFIG_LOG_CBUFFER_SIZE=2048
|
||||
CONFIG_LOG_CBUFFER=y
|
||||
CONFIG_MEMORY_POOLS_BALLOC_STATISTICS=y
|
||||
CONFIG_MEMORY_POOLS_BALLOC_TRACK_OWNER=y
|
||||
CONFIG_MEM_POOL_DEF_PATH="$(PROJECT_PATH)/quark"
|
||||
CONFIG_OS_ZEPHYR=y
|
||||
CONFIG_PANIC_ON_BUS_ERROR=y
|
||||
CONFIG_QUARK_SE_PROPERTIES_STORAGE=y
|
||||
CONFIG_QUARK=y
|
||||
CONFIG_SERVICES_QUARK_SE_ADC=y
|
||||
CONFIG_SERVICES_QUARK_SE_GPIO_IMPL=y
|
||||
CONFIG_SERVICES_QUARK_SE_GPIO=y
|
||||
CONFIG_SOC_FLASH=y
|
||||
CONFIG_SOC_GPIO_32=y
|
||||
CONFIG_SOC_GPIO=y
|
||||
CONFIG_SOC_ROM=y
|
||||
CONFIG_SPI_FLASH_W25Q16DV=y
|
||||
CONFIG_STORAGE_TASK=y
|
||||
CONFIG_TCMD_CONSOLE=y
|
||||
CONFIG_TCMD_MASTER=y
|
||||
CONFIG_TCMD=y
|
||||
CONFIG_UART_NS16550=y
|
||||
CONFIG_UART_PM_NS16550=y
|
||||
CONFIG_ZEPHYR_BOARD="arduino_101"
|
||||
CONFIG_CONSOLE_HANDLER_SHELL=y
|
167
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/main.c
vendored
Normal file
167
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/main.c
vendored
Normal file
|
@ -0,0 +1,167 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Infra */
|
||||
#include "infra/bsp.h"
|
||||
#include "infra/reboot.h"
|
||||
#include "infra/log.h"
|
||||
#include "infra/time.h"
|
||||
#include "infra/system_events.h"
|
||||
#include "infra/tcmd/handler.h"
|
||||
|
||||
#include "cfw/cfw.h"
|
||||
/* Watchdog helper */
|
||||
#include "infra/wdt_helper.h"
|
||||
|
||||
#include "jerry-api.h"
|
||||
#include "string.h"
|
||||
#include "jerry-port.h"
|
||||
|
||||
#include "zephyr.h"
|
||||
#include "microkernel/task.h"
|
||||
#include "os/os.h"
|
||||
|
||||
static T_QUEUE queue;
|
||||
|
||||
jerry_value_t print_function;
|
||||
|
||||
void jerry_resolve_error (jerry_value_t ret_value)
|
||||
{
|
||||
if (jerry_value_has_error_flag (ret_value))
|
||||
{
|
||||
jerry_value_clear_error_flag (&ret_value);
|
||||
jerry_value_t err_str_val = jerry_value_to_string (ret_value);
|
||||
jerry_size_t err_str_size = jerry_get_string_size (err_str_val);
|
||||
jerry_char_t *err_str_buf = (jerry_char_t *) balloc (err_str_size, NULL);
|
||||
jerry_size_t sz = jerry_string_to_char_buffer (err_str_val, err_str_buf, err_str_size);
|
||||
err_str_buf[sz] = 0;
|
||||
jerry_port_console ("Script Error: unhandled exception: %s\n", err_str_buf);
|
||||
bfree(err_str_buf);
|
||||
jerry_release_value (err_str_val);
|
||||
}
|
||||
}
|
||||
|
||||
void help ()
|
||||
{
|
||||
jerry_port_console ("Usage:\n");
|
||||
jerry_port_console ("js e 'JavaScript Command'\n");
|
||||
jerry_port_console ("eg. js e print ('Hello World');\n");
|
||||
}
|
||||
|
||||
void eval_jerry_script (int argc, char *argv[], struct tcmd_handler_ctx *ctx)
|
||||
{
|
||||
if (argc < 3)
|
||||
{
|
||||
TCMD_RSP_ERROR (ctx, NULL);
|
||||
help ();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
OS_ERR_TYPE err;
|
||||
size_t str_total_length = 0;
|
||||
size_t *str_lens = (size_t *) balloc ((argc - 2) * sizeof(size_t), &err);
|
||||
if (str_lens == NULL || err != E_OS_OK)
|
||||
{
|
||||
jerry_port_console ("%s: allocate memory failed!", __func__);
|
||||
TCMD_RSP_ERROR (ctx, NULL);
|
||||
return;
|
||||
}
|
||||
for (int i = 2; i < argc; ++i)
|
||||
{
|
||||
str_lens[i - 2] = strlen (argv[i]);
|
||||
str_total_length += str_lens[i - 2] + 1;
|
||||
}
|
||||
err = E_OS_OK;
|
||||
char *buffer = (char *) balloc (str_total_length, &err);
|
||||
if (buffer == NULL || err != E_OS_OK)
|
||||
{
|
||||
jerry_port_console ("%s: allocate memory failed!", __func__);
|
||||
TCMD_RSP_ERROR (ctx, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
char *p = buffer;
|
||||
for (int i = 2; i < argc; ++i)
|
||||
{
|
||||
for (int j =0; j < str_lens[i - 2]; ++j)
|
||||
{
|
||||
*p = argv[i][j];
|
||||
++p;
|
||||
}
|
||||
*p = ' ';
|
||||
++p;
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
jerry_value_t eval_ret = jerry_eval (buffer, str_total_length - 1, false);
|
||||
|
||||
if (jerry_value_has_error_flag (eval_ret))
|
||||
{
|
||||
jerry_resolve_error (eval_ret);
|
||||
TCMD_RSP_ERROR (ctx, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
jerry_value_t args[] = {eval_ret};
|
||||
jerry_value_t ret_val_print = jerry_call_function (print_function,
|
||||
jerry_create_undefined (),
|
||||
args,
|
||||
1);
|
||||
jerry_release_value (ret_val_print);
|
||||
TCMD_RSP_FINAL (ctx, NULL);
|
||||
}
|
||||
jerry_release_value (eval_ret);
|
||||
bfree (buffer);
|
||||
bfree (str_lens);
|
||||
}
|
||||
}
|
||||
|
||||
void jerry_start ()
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
jerry_value_t global_obj_val = jerry_get_global_object ();
|
||||
jerry_value_t print_func_name_val = jerry_create_string ((jerry_char_t *) "print");
|
||||
print_function = jerry_get_property (global_obj_val, print_func_name_val);
|
||||
jerry_release_value (print_func_name_val);
|
||||
jerry_release_value (global_obj_val);
|
||||
}
|
||||
|
||||
/* Application main entry point */
|
||||
void main_task (void *param)
|
||||
{
|
||||
/* Init BSP (also init BSP on ARC core) */
|
||||
queue = bsp_init ();
|
||||
/* start Quark watchdog */
|
||||
wdt_start (WDT_MAX_TIMEOUT_MS);
|
||||
/* Init the CFW */
|
||||
cfw_init (queue);
|
||||
jerry_start ();
|
||||
/* Loop to process message queue */
|
||||
while (1)
|
||||
{
|
||||
OS_ERR_TYPE err = E_OS_OK;
|
||||
/* Process message with a given timeout */
|
||||
queue_process_message_wait (queue, 5000, &err);
|
||||
/* Acknowledge the system watchdog to prevent panic and reset */
|
||||
wdt_keepalive ();
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_TEST_COMMAND (js, e, eval_jerry_script);
|
36
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/memory_pool_list.def
vendored
Normal file
36
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/memory_pool_list.def
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definition of the memory pools used by balloc/bfree:
|
||||
* DECLARE_MEMORY_POOL( <index>, <size>, <count>, <align> )
|
||||
* <index> : must start at 0 and be of consecutive values *
|
||||
* <size> : size in bytes of each block from the pool
|
||||
* <count> : number of blocks in the pool
|
||||
*
|
||||
* * Pool definitions must be sorted according the block size
|
||||
* value: pool with <index> 0 must have the smallest <size>.
|
||||
*/
|
||||
|
||||
DECLARE_MEMORY_POOL(0,8,32)
|
||||
DECLARE_MEMORY_POOL(1,16,64)
|
||||
DECLARE_MEMORY_POOL(2,32,64)
|
||||
DECLARE_MEMORY_POOL(3,64,48)
|
||||
DECLARE_MEMORY_POOL(4,128,8)
|
||||
DECLARE_MEMORY_POOL(5,256,4)
|
||||
DECLARE_MEMORY_POOL(6,512,3)
|
||||
DECLARE_MEMORY_POOL(7,4096,1)
|
||||
|
||||
#undef DECLARE_MEMORY_POOL
|
Loading…
Add table
Add a link
Reference in a new issue