Пример #1
0
Файл: init.c Проект: zwh8800/zOS
int init(void)
{
	void* zImage_start;
	zImage* imgs;
	int i, n;

	init_device();

	/* 设置SysTick中断 */
	SysTick_Config(72 * 1000);

	zImage_start = get_zimage_start();

	kprintf("flash_end=0x%.8p\r\n", zImage_start);

	imgs = malloc(5 * sizeof(zImage));
	n = find_zImage(zImage_start, imgs, 5 * sizeof(zImage));
	kprintf("%d zImage(s) on flash\r\n", n);
	for (i = 0; i < n; ++i)
	{
		kprintf("zImage #%d\r\n", i);
		kprintf("\tlocation: %.8p\r\n", imgs[i].location);
		kprintf("\tname: %s\r\n", imgs[i].header.name);
		kprintf("\tsize: 0x%.4x\r\n", imgs[i].header.size);
	}

	init_system_exception();
	dump_scb();
	
	/* 初始化三个进程列表 */
	kprintf("初始化进程列表\r\n");
	init_proc_list(&ready);
	init_proc_list(&inactive);
	init_proc_list(&pending);
	
	//test_proc_list();
	//test_pend_sv();
	//test_newlib();
	test_schedule();
	
	/*zImage_start = (char*)zImage_start + sizeof(zImage_header);
	BitM(&zImage_start, 0) = 1;
	__asm__(
		"blx %[addr]"
		:
		: [addr]"r"(zImage_start)
		:
	);*/

    while(1)
    	__WFI();
}
Пример #2
0
int main(int argc, char* argv[])
{
  char* path_to_config;
  char* path_to_errors;
  int   is_batch_mode;
  int key = 0;
  int list_scr = 0;
  struct process_list* proc_list;
  screen_t* screen = NULL;
  int screen_num = 0;
  int q;
  int paranoia_level;

  /* Check OS to make sure we can run. */
  paranoia_level = check();

  init_options(&options);
  options.paranoia_level = paranoia_level;

  path_to_config = get_path_to_config(argc, argv);
  path_to_errors = get_path_to_error(argc, argv);
  is_batch_mode = get_batch_mode(argc, argv);

  init_errors(is_batch_mode, path_to_errors);

  q = read_config(path_to_config, &options);
  if (q == 0) {
    debug_printf("Config file successfully parsed.\n");
    options.config_file = 1;
  }
  else
    debug_printf("Could not parse config file.\n");

  /* Parse command line arguments. */
  parse_command_line(argc, argv, &options, &list_scr, &screen_num);


  /* Add default screens */
  if (options.default_screen == 1)
    init_screen();

  /* Remove unused but declared counters */
  tamp_counters();

  if (list_scr) {
    list_screens();
    delete_screens();
    exit(0);
  }

  if (options.spawn_pos) {
    /* monitor only spawned process */
    int child = spawn(argv + options.spawn_pos);
    options.only_pid = child;
    options.idle = 1;
  }

  do {
    if (screen_num >= 0)
      screen = get_screen(screen_num);
    else
      screen = get_screen_by_name(argv[-screen_num]);

    if (!screen) {
      fprintf(stderr, "No such screen.\n");
      exit(EXIT_FAILURE);
    }

    /* initialize the list of processes, and then run */
    proc_list = init_proc_list();

    if (options.spawn_pos) {
      options.spawn_pos = 0;  /* do this only once */
      new_processes(proc_list, screen, &options);
      start_child();
    }

    if (options.batch) {
      batch_mode(proc_list, screen);
      key = 'q';
    }
#ifdef HAVE_LIBCURSES
    else {
      key = live_mode(proc_list, screen);
      if ((key == '+')  || (key == KEY_RIGHT)) {
        screen_num = (screen_num + 1) % get_num_screens();
        active_col = 0;
        done_proc_list(proc_list);
        free(header);
      }
      if ((key == '-') || (key == KEY_LEFT)) {
        int n = get_num_screens();
        screen_num = (screen_num + n - 1) % n;
        active_col = 0;
        done_proc_list(proc_list);
        free(header);
      }
      if ((key == 'u') || (key == 'K') || (key == 'p')) {
        done_proc_list(proc_list);
      }
    }
#endif
  } while (key != 'q');

  /* done, free memory (makes valgrind happy) */
  close_error();
  delete_screens();
  done_proc_list(proc_list);
  free_options(&options);
  return 0;
}