blob: 4bb183df2fdf1c6d8977d54dcc048b7e8cea3df1 [file] [log] [blame]
Damien George075d5972014-11-27 20:30:33 +00001/*
2 * This file is part of the Micro Python project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2014 Damien P. George
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
27#include <stdio.h>
28#include <string.h>
29
Damien Georgefe7d5422015-01-01 21:16:58 +000030#include "py/nlr.h"
31#include "py/parsehelper.h"
32#include "py/compile.h"
33#include "py/runtime0.h"
34#include "py/runtime.h"
35#include "py/gc.h"
Damien George075d5972014-11-27 20:30:33 +000036#include "pyexec.h"
37#include "gccollect.h"
38#include MICROPY_HAL_H
39
40void user_init(void) {
Damien Georgefbea8102014-11-28 14:58:25 +000041soft_reset:
Damien George075d5972014-11-27 20:30:33 +000042 //mp_stack_set_limit((char*)&_ram_end - (char*)&_heap_end - 1024);
43 mp_hal_init();
44 gc_init(&_heap_start, &_heap_end);
45 gc_collect_init();
46 mp_init();
47 mp_obj_list_init(mp_sys_path, 0);
48 mp_obj_list_init(mp_sys_argv, 0);
49
50 printf("\n");
51
52 for (;;) {
53 if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
54 if (pyexec_raw_repl() != 0) {
55 break;
56 }
57 } else {
58 if (pyexec_friendly_repl() != 0) {
59 break;
60 }
61 }
62 }
Damien Georgefbea8102014-11-28 14:58:25 +000063
64 goto soft_reset;
Damien George075d5972014-11-27 20:30:33 +000065}
66
67mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
68 return NULL;
69}
70
71mp_import_stat_t mp_import_stat(const char *path) {
72 return MP_IMPORT_STAT_NO_EXIST;
73}
74
75mp_obj_t mp_builtin_open(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
76 return mp_const_none;
77}
78MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
79
80void nlr_jump_fail(void *val) {
81 printf("NLR jump failed\n");
82 for (;;) {
83 }
84}
85
86//void __assert(const char *file, int line, const char *func, const char *expr) {
87void __assert(const char *file, int line, const char *expr) {
88 printf("Assertion '%s' failed, at file %s:%d\n", expr, file, line);
89 for (;;) {
90 }
91}