Пример #1
0
/* blocking call for a character */
int conio_getch() {
	int key = -1;
	uint8 b;

	switch (conio_ttymode) {
		case CONIO_TTY_PVR:
#ifdef GFX
			while ((key = kbd_get_key()) == -1) { thd_pass(); }
#endif
			break;
		case CONIO_TTY_SERIAL: {
			while ((key = scif_read()) == -1) { thd_pass(); }

			if (key == 3)
				arch_exit();
	
			break;
		}
		case CONIO_TTY_STDIO: {
			int i;
			i = fs_read(conio_serial_fd, &b, 1);
			if (i <= 0)
				return -1;
			key = b;
			if (key == '\n')
				return conio_getch();
			break;
		}
	}

	return key;
}
Пример #2
0
/* Check to see if a key has been pressed */
int conio_check_getch() {
	int key = -1;
	uint8 b;

	switch (conio_ttymode) {
		case CONIO_TTY_PVR:
#ifdef GFX
			key = kbd_get_key();
#endif
			break;
		case CONIO_TTY_SERIAL: {
			key = scif_read();

			if (key == 3)
				arch_exit();
	
			break;
		}
		case CONIO_TTY_STDIO:
			if (fs_total(conio_serial_fd) > 0) {
				if (fs_read(conio_serial_fd, &b, 1) == 1)
					key = b;
			}
			if (key == '\n')
				key = -1;
			break;
	}

	return key;
}
Пример #3
0
/**
 * To avoid hang on exit we launch a special thread that will force
 * exit after 5 seconds
 */
static void *
shutdown_eject(void *aux)
{
  sleep(5);
  arch_exit();
  return NULL;
}
Пример #4
0
/* arch_init */
int arch_init_buffer(AsmArch * arch, char const * buffer, size_t size)
{
#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif
	if(arch->plugin != NULL)
		arch_exit(arch);
	arch->base = 0;
	arch->filename = "buffer";
	arch->fp = NULL;
	arch->buffer = buffer;
	arch->buffer_cnt = size;
	arch->buffer_pos = 0;
	arch->helper.arch = arch;
	arch->helper.get_filename = _arch_get_filename;
	arch->helper.get_function_by_id = _arch_get_function_by_id;
	arch->helper.get_instruction_by_opcode = arch_get_instruction_by_opcode;
	arch->helper.get_register_by_id_size = arch_get_register_by_id_size;
	arch->helper.get_register_by_name_size = arch_get_register_by_name_size;
	arch->helper.get_string_by_id = _arch_get_string_by_id;
	arch->helper.write = NULL;
	arch->helper.peek = _arch_peek_buffer;
	arch->helper.read = _arch_read_buffer;
	arch->helper.seek = _arch_seek_buffer;
	if(arch->definition->init != NULL
			&& (arch->plugin = arch->definition->init(
					&arch->helper)) == NULL)
		return -1;
	return 0;
}
Пример #5
0
/* arch_init */
int arch_init(AsmArch * arch, char const * filename, FILE * fp)
{
#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s(\"%s\", %p)\n", __func__, filename,
			(void *)fp);
#endif
	if(arch->plugin != NULL)
		arch_exit(arch);
	arch->base = 0;
	arch->filename = filename;
	arch->fp = fp;
	arch->buffer = NULL;
	arch->buffer_cnt = 0;
	arch->buffer_pos = 0; /* XXX used as offset */
	arch->helper.arch = arch;
	arch->helper.get_filename = _arch_get_filename;
	arch->helper.get_function_by_id = _arch_get_function_by_id;
	arch->helper.get_instruction_by_opcode = arch_get_instruction_by_opcode;
	arch->helper.get_register_by_id_size = arch_get_register_by_id_size;
	arch->helper.get_register_by_name_size = arch_get_register_by_name_size;
	arch->helper.get_string_by_id = _arch_get_string_by_id;
	arch->helper.peek = _arch_peek;
	arch->helper.read = _arch_read;
	arch->helper.seek = _arch_seek;
	arch->helper.write = _arch_write;
	if(arch->definition->init != NULL
			&& (arch->plugin = arch->definition->init(
					&arch->helper)) == NULL)
		return -1;
	return 0;
}
Пример #6
0
/**
 * The end of all things
 */
static void
finalize(void)
{
    audio_fini();
    backend_fini();
    shutdown_hook_run(0);
    arch_exit(showtime_retcode);
}
Пример #7
0
void
app_shutdown(int retcode)
{
  TRACE(TRACE_DEBUG, "core", "Shutdown requested, returncode = %d", retcode);

  if(gconf.exit_code != 1) {
    // Force exit
    gconf.exit_code = retcode;
    arch_exit();
  }

  gconf.exit_code = retcode;

  hts_thread_create_detached("eject", shutdown_eject, NULL, THREAD_PRIO_BGTASK);
  hts_thread_create_detached("shutdown", do_shutdown, NULL, THREAD_PRIO_BGTASK);

}
Пример #8
0
/**
 * Linux main
 */
int
main(int argc, char **argv)
{
    gconf.binary = argv[0];

    posix_init();

    XInitThreads();
    hts_mutex_init(&gdk_mutex);

    g_thread_init(NULL);
    gdk_threads_set_lock_functions(gdk_obtain, gdk_release);

    gdk_threads_init();
    gdk_threads_enter();
    gtk_init(&argc, &argv);

    parse_opts(argc, argv);

    linux_init();

    main_init();

    if(gconf.ui && !strcmp(gconf.ui, "gu"))
        ui_wanted = &ui_gu;

    glibcourier = glib_courier_create(g_main_context_default());

    prop_subscribe(0,
                   PROP_TAG_NAME("global", "eventSink"),
                   PROP_TAG_CALLBACK_EVENT, linux_global_eventsink, NULL,
                   PROP_TAG_COURIER, glibcourier,
                   NULL);

    add_xdg_paths();

    mainloop();

    main_fini();

    arch_exit();
}
Пример #9
0
void
showtime_shutdown(int retcode)
{
  TRACE(TRACE_DEBUG, "core", "Shutdown requested, returncode = %d", retcode);

  if(gconf.exit_code != 1) {
    // Force exit
    gconf.exit_code = retcode;
    arch_exit();
  }

  gconf.exit_code = retcode;

  // run early shutdown hooks (those must be fast)
  shutdown_hook_run(1);

  htsmsg_store_flush();

  event_to_ui(event_create_type(EVENT_STOP_UI));
}
Пример #10
0
void
showtime_shutdown(int retcode)
{
    TRACE(TRACE_DEBUG, "core", "Shutdown requested, returncode = %d", retcode);

    if(showtime_retcode != 1) {
        // Force exit
        arch_exit(retcode);
    }

    showtime_retcode = retcode;

    // run early shutdown hooks (those must be fast)
    shutdown_hook_run(1);

    htsmsg_store_flush();

    if(ui_shutdown() == -1) {
        // Primary UI has no shutdown method, launch a new thread to stop
        hts_thread_create_detached("shutdown", showtime_shutdown0, NULL,
                                   THREAD_PRIO_NORMAL);
    }
}
Пример #11
0
/**
 * Linux main
 */
int
main(int argc, char **argv)
{
  gconf.binary = argv[0];

  posix_init();

#if ENABLE_GU
  extern void gu_init(int *argc, char ***argv);
  gu_init(&argc, &argv);
#endif

  parse_opts(argc, argv);

  gconf.concurrency = get_system_concurrency();

  trap_init();

  showtime_init();

  linux_init_monitors();

#if ENABLE_GU
  if(gconf.ui && !strcmp(gconf.ui, "gu")) {
    extern void gu_start(void);
    gu_start();
  } else
#endif
 {
  extern void glw_x11_start(void);
  glw_x11_start();
 }

  showtime_fini();

  arch_exit();
}
Пример #12
0
static void interact() {
	char tmp[16];
	char *buf;
	int cnt=0;

	curdir[0] = '/'; curdir[1] = 0;

	while(1) {
		sprintf(tmp, "%d", cnt); dbgio_write_str(tmp);
		dbgio_write(' ');
		dbgio_write_str(curdir);
		dbgio_write('>');
		/*write_str("%d %s> ", cnt, curdir); */
		buf = read_line();

		if (buf[0] == 0) {
			cnt++;
			continue;
		}
					
		if (!strcmp(buf, "quit") || !strcmp(buf, "exit")) {
			break;
		} else if (!strcmp(buf, "die")) {
			arch_exit();
		} else if (!strcmp(buf, "ps")) {
			thd_pslist();
		} else if (!strcmp(buf, "reboot")) {
			arch_reboot();
		} else if (!strcmp(buf, "menu")) {
		        (*(void(**)())0x8c0000e0)(1);
		} else {
			dbgio_write_str("commands: die quit/exit reboot menu ps\n");
		}
		
		cnt++;
	}
}
Пример #13
0
/* This is the entry point inside the C program */
void arch_main() {
	int rv;

	/* Ensure that we pull in crtend.c in the linking process */
	__crtend_pullin();

	/* Ensure that UBC is not enabled from a previous session */
	// ubc_disable_all();

	/* Initialize memory management */
	mm_init();

	/* Do auto-init stuff */
	arch_auto_init();

	/* Run ctors */
	arch_ctors();

	/* Call the user's main function */
	rv = main(0, NULL);

	/* Call kernel exit */
	arch_exit();
}
Пример #14
0
/* If something goes badly wrong in the kernel and you don't think you
   can recover, call this. This is a pretty standard tactic from *nixy
   kernels which ought to be avoided if at all possible. */
void panic(const char *msg) {
	printf("%s\r\n", msg);
	arch_exit();
}