コード例 #1
0
ファイル: main.c プロジェクト: GDI123/smart.js
static void pre_init(struct v7 *v7) {
  sj_init_sys(v7);

  init_smartjs(v7);

  mongoose_init();
  sj_init_uart(v7);

  init_device(v7);
  run_init_script(v7);
}
コード例 #2
0
ファイル: user_main.c プロジェクト: a-kazantsev/smart.js
/*
 * SmartJS initialization, called as an SDK timer callback (`os_timer_...()`).
 */
void sjs_init(void *dummy) {
  /*
   * In order to see debug output (at least errors) during boot we have to
   * initialize debug in this point. But default we put debug to UART0 with
   * level=LL_ERROR, then configuration is loaded this settings are overridden
   */
  {
    struct esp_uart_config *u0cfg = esp_sj_uart_default_config(0);
#if ESP_DEBUG_UART == 0
    u0cfg->baud_rate = ESP_DEBUG_UART_BAUD_RATE;
#endif
    esp_uart_init(u0cfg);
    struct esp_uart_config *u1cfg = esp_sj_uart_default_config(1);
    /* UART1 has no RX pin, no point in allocating a buffer. */
    u1cfg->rx_buf_size = 0;
#if ESP_DEBUG_UART == 1
    u1cfg->baud_rate = ESP_DEBUG_UART_BAUD_RATE;
#endif
    esp_uart_init(u1cfg);
    fs_set_stdout_uart(0);
    fs_set_stderr_uart(ESP_DEBUG_UART);
    setvbuf(stdout, NULL, _IONBF, 0);
    setvbuf(stderr, NULL, _IONBF, 0);
    cs_log_set_level(LL_DEBUG);
    os_install_putc1(dbg_putc);
    system_set_os_print(1);
#ifdef ESP_ENABLE_HEAP_LOG
    uart_initialized = 1;
#endif
  }

  init_v7(&dummy);
  /* disable GC during further initialization */
  v7_set_gc_enabled(v7, 0);

  esp_sj_uart_init(v7);

#ifndef V7_NO_FS
#ifndef DISABLE_OTA
  fs_init(get_fs_addr(get_current_rom()), get_fs_size(get_current_rom()));
  finish_update();
#else
  fs_init(FS_ADDR, FS_SIZE);
#endif
#endif

  sj_common_api_setup(v7);
  sj_common_init(v7);

  sj_init_sys(v7);

  mongoose_init();

  /* NOTE(lsm): must be done after mongoose_init(). */
  if (!init_device(v7)) {
    LOG(LL_ERROR, ("init_device failed"));
    abort();
  }

  esp_print_reset_info();

#ifndef DISABLE_OTA
  init_updater(v7);
#endif
  LOG(LL_INFO, ("Sys init done, SDK %s", system_get_sdk_version()));

  if (!sj_app_init(v7)) {
    LOG(LL_ERROR, ("App init failed"));
    abort();
  }
  LOG(LL_INFO, ("App init done"));

  /* SJS initialized, enable GC back, and trigger it */
  v7_set_gc_enabled(v7, 1);
  v7_gc(v7, 1);

#ifndef V7_NO_FS
  run_init_script();
#endif

  /* Install prompt if enabled in the config and user's app has not installed
   * a custom RX handler. */
  if (get_cfg()->debug.enable_prompt &&
      v7_is_undefined(esp_sj_uart_get_recv_handler(0))) {
    sj_prompt_init(v7);
    esp_sj_uart_set_prompt(0);
  }

#ifdef ESP_UMM_ENABLE
  /*
   * We want to use our own heap functions instead of the ones provided by the
   * SDK.
   *
   * We have marked `pvPortMalloc` and friends weak, so that we can override
   * them with our own implementations, but to actually make it work, we have
   * to reference any function from the file with our implementation, so that
   * linker will not garbage-collect the whole compilation unit.
   *
   * So, we have a call to the no-op `esp_umm_init()` here.
   */
  esp_umm_init();
#endif
}
コード例 #3
0
void kernel_init(multiboot_info_t *mboot_info)
{
	extern char __start_bss[], __stop_bss[];

	memset(__start_bss, 0, __stop_bss - __start_bss);
	/* mboot_info is a physical address.  while some arches currently have the
	 * lower memory mapped, everyone should have it mapped at kernbase by now.
	 * also, it might be in 'free' memory, so once we start dynamically using
	 * memory, we may clobber it. */
	multiboot_kaddr = (struct multiboot_info*)((physaddr_t)mboot_info
                                               + KERNBASE);
	extract_multiboot_cmdline(multiboot_kaddr);

	cons_init();
	print_cpuinfo();

	printk("Boot Command Line: '%s'\n", boot_cmdline);

	exception_table_init();
	cache_init();					// Determine systems's cache properties
	pmem_init(multiboot_kaddr);
	kmem_cache_init();              // Sets up slab allocator
	kmalloc_init();
	hashtable_init();
	radix_init();
	cache_color_alloc_init();       // Inits data structs
	colored_page_alloc_init();      // Allocates colors for agnostic processes
	acpiinit();
	topology_init();
	kthread_init();					/* might need to tweak when this happens */
	vmr_init();
	file_init();
	page_check();
	idt_init();
	kernel_msg_init();
	timer_init();
	vfs_init();
	devfs_init();
	train_timing();
	kb_buf_init(&cons_buf);
	arch_init();
	block_init();
	enable_irq();
	run_linker_funcs();
	/* reset/init devtab after linker funcs 3 and 4.  these run NIC and medium
	 * pre-inits, which need to happen before devether. */
	devtabreset();
	devtabinit();

#ifdef CONFIG_EXT2FS
	mount_fs(&ext2_fs_type, "/dev/ramdisk", "/mnt", 0);
#endif /* CONFIG_EXT2FS */
#ifdef CONFIG_ETH_AUDIO
	eth_audio_init();
#endif /* CONFIG_ETH_AUDIO */
	get_coreboot_info(&sysinfo);
	booting = 0;

#ifdef CONFIG_RUN_INIT_SCRIPT
	if (run_init_script()) {
		printk("Configured to run init script, but no script specified!\n");
		manager();
	}
#else
	manager();
#endif
}