Ejemplo n.º 1
0
static void
start_animation (ply_boot_splash_plugin_t *plugin)
{
        ply_list_node_t *node;

        if (plugin->is_animating)
                return;

        node = ply_list_get_first_node (plugin->views);
        while (node != NULL) {
                ply_list_node_t *next_node;
                view_t *view;

                view = ply_list_node_get_data (node);
                next_node = ply_list_get_next_node (plugin->views, node);

                view_start_animation (view);

                node = next_node;
        }

        plugin->is_animating = true;

        plugin->start_time = ply_get_timestamp ();
        animate_at_time (plugin, plugin->start_time);

        if (plugin->mode == PLY_BOOT_SPLASH_MODE_SHUTDOWN)
                return;

        ply_event_loop_watch_for_timeout (plugin->loop,
                                          1.0 / FRAMES_PER_SECOND,
                                          (ply_event_loop_timeout_handler_t)
                                          on_timeout, plugin);
}
Ejemplo n.º 2
0
static void
ply_terminal_reopen_device (ply_terminal_t *terminal)
{
    ply_terminal_open_result_t open_result;

    ply_trace ("trying to reopen terminal '%s' (attempt %d)",
               terminal->name,
               terminal->number_of_reopen_tries);

    terminal->number_of_reopen_tries++;

    open_result = ply_terminal_open_device (terminal);

    if (open_result == PLY_TERMINAL_OPEN_RESULT_INCOMPLETE) {
        int total_retries;

        total_retries = (int) (PLY_TERMINAL_REOPEN_TIMEOUT / PLY_TERMINAL_REOPEN_INTERVAL);

        if (terminal->number_of_reopen_tries < total_retries) {
            ply_event_loop_watch_for_timeout (terminal->loop,
                                              PLY_TERMINAL_REOPEN_INTERVAL,
                                              (ply_event_loop_timeout_handler_t)
                                              ply_terminal_reopen_device,
                                              terminal);
        } else {
            ply_trace ("couldn't reopen tty, giving up");
            terminal->number_of_reopen_tries = 0;
        }
    }
}
Ejemplo n.º 3
0
static void
on_timeout (ply_throbber_t *throbber)
{
        double sleep_time;
        bool should_continue;

        throbber->now = ply_get_timestamp ();

        should_continue = animate_at_time (throbber,
                                           throbber->now - throbber->start_time);

        sleep_time = 1.0 / FRAMES_PER_SECOND;
        sleep_time = MAX (sleep_time - (ply_get_timestamp () - throbber->now),
                          0.005);

        if (!should_continue) {
                throbber->is_stopped = true;
                if (throbber->stop_trigger != NULL) {
                        ply_trigger_pull (throbber->stop_trigger, NULL);
                        throbber->stop_trigger = NULL;
                }
        } else {
                ply_event_loop_watch_for_timeout (throbber->loop,
                                                  sleep_time,
                                                  (ply_event_loop_timeout_handler_t)
                                                  on_timeout, throbber);
        }
}
Ejemplo n.º 4
0
bool
ply_throbber_start (ply_throbber_t      *throbber,
                    ply_event_loop_t    *loop,
                    ply_pixel_display_t *display,
                    long                 x,
                    long                 y)
{
        assert (throbber != NULL);
        assert (throbber->loop == NULL);

        throbber->loop = loop;
        throbber->display = display;
        throbber->is_stopped = false;

        throbber->x = x;
        throbber->y = y;

        throbber->start_time = ply_get_timestamp ();

        ply_event_loop_watch_for_timeout (throbber->loop,
                                          1.0 / FRAMES_PER_SECOND,
                                          (ply_event_loop_timeout_handler_t)
                                          on_timeout, throbber);

        return true;
}
Ejemplo n.º 5
0
bool
ply_animation_start (ply_animation_t    *animation,
                     ply_pixel_display_t *display,
                     ply_trigger_t      *stop_trigger,
                     long                x,
                     long                y)
{
  assert (animation != NULL);

  if (!animation->is_stopped)
    return true;

  animation->loop = ply_event_loop_get_default ();
  animation->display = display;
  animation->stop_trigger = stop_trigger;
  animation->is_stopped = false;
  animation->stop_requested = false;

  animation->x = x;
  animation->y = y;

  animation->start_time = ply_get_timestamp ();

  ply_event_loop_watch_for_timeout (animation->loop,
                                    1.0 / FRAMES_PER_SECOND,
                                    (ply_event_loop_timeout_handler_t)
                                    on_timeout, animation);

  return true;
}
Ejemplo n.º 6
0
static void on_timeout(void* dummy)
{
	time_t t = time(NULL);
	time_t delay;

	display_totp();
	delay = 30 - (t % 30);
	ply_event_loop_watch_for_timeout(ply_loop, delay, on_timeout, NULL);
}
Ejemplo n.º 7
0
static void
on_timeout (ply_boot_splash_plugin_t *plugin)
{
  static int frame = 0;

  frame += 1;
  frame %= 8;

  animate_frame (plugin, frame);

  ply_event_loop_watch_for_timeout (plugin->loop, 1.0,
                                    (ply_event_loop_timeout_handler_t)
                                    on_timeout, plugin);
}
Ejemplo n.º 8
0
static void
on_timeout (ply_boot_splash_plugin_t *plugin)
{
  double sleep_time;

  sleep_time = 1.0 / FRAMES_PER_SECOND;
  ply_event_loop_watch_for_timeout (plugin->loop,
                                    sleep_time,
                                    (ply_event_loop_timeout_handler_t)
                                    on_timeout, plugin);

  script_lib_plymouth_on_refresh (plugin->script_state,
                                  plugin->script_plymouth_lib);
                                  
  pause_displays (plugin);
  script_lib_sprite_refresh (plugin->script_sprite_lib);
  unpause_displays (plugin);

}
Ejemplo n.º 9
0
static void
on_timeout (ply_boot_splash_plugin_t *plugin)
{
        double sleep_time;

        plugin->now = ply_get_timestamp ();

        /* The choice below is between
         *
         * 1) keeping a constant animation speed, and dropping
         * frames when necessary
         * 2) showing every frame, but slowing down the animation
         * when a frame would be otherwise dropped.
         *
         * It turns out there are parts of boot up where the animation
         * can get sort of choppy.  By default we choose 2, since the
         * nature of this animation means it looks natural even when it
         * is slowed down
         */
#ifdef REAL_TIME_ANIMATION
        animate_at_time (plugin,
                         plugin->now - plugin->start_time);
#else
        static double time = 0.0;
        time += 1.0 / FRAMES_PER_SECOND;
        animate_at_time (plugin, time);
#endif

        sleep_time = 1.0 / FRAMES_PER_SECOND;
        sleep_time = MAX (sleep_time - (ply_get_timestamp () - plugin->now),
                          0.005);

        ply_event_loop_watch_for_timeout (plugin->loop,
                                          sleep_time,
                                          (ply_event_loop_timeout_handler_t)
                                          on_timeout, plugin);
}
Ejemplo n.º 10
0
static void
start_animation (ply_boot_splash_plugin_t *plugin)
{
  ply_list_node_t *node;

  assert (plugin != NULL);
  assert (plugin->loop != NULL);

  redraw_views (plugin);

  if (plugin->message != NULL)
    show_message (plugin);

  if (plugin->is_animating)
     return;

  node = ply_list_get_first_node (plugin->views);
  while (node != NULL)
    {
      ply_list_node_t *next_node;
      view_t *view;

      view = ply_list_node_get_data (node);
      next_node = ply_list_get_next_node (plugin->views, node);

      view_start_animation (view);

      node = next_node;
    }

  plugin->is_animating = true;

  animate_frame (plugin, 0);
  ply_event_loop_watch_for_timeout (plugin->loop, 1.0,
                                    (ply_event_loop_timeout_handler_t)
                                    on_timeout, plugin);
}
Ejemplo n.º 11
0
static void
on_timeout (ply_animation_t *animation)
{
  double sleep_time;
  bool should_continue;
  animation->previous_time = animation->now;
  animation->now = ply_get_timestamp ();

#ifdef REAL_TIME_ANIMATION
  should_continue = animate_at_time (animation,
                                     animation->now - animation->start_time);
#else
  static double time = 0.0;
  time += 1.0 / FRAMES_PER_SECOND;
  should_continue = animate_at_time (animation, time);
#endif

  sleep_time = 1.0 / FRAMES_PER_SECOND;
  sleep_time = MAX (sleep_time - (ply_get_timestamp () - animation->now),
                    0.005);

  if (!should_continue)
    {
      if (animation->stop_trigger != NULL)
        {
          ply_trigger_pull (animation->stop_trigger, NULL);
          animation->stop_trigger = NULL;
        }
    }
  else
    {
      ply_event_loop_watch_for_timeout (animation->loop,
                                        sleep_time,
                                        (ply_event_loop_timeout_handler_t)
                                        on_timeout, animation);
    }
}
Ejemplo n.º 12
0
int main(int argc, char *argv[])
{
	int ret;
	struct stat sbuf;	
	uint32_t parhandle;	/* handle of parent key */
	unsigned char blob[4096];	/* resulting sealed blob */
	unsigned int bloblen = 322;	/* blob length */
	unsigned char passptr1[20] = {0};
	int fd, outlen, i;
	time_t t, delay;

	parhandle = 0x40000000;

	ret = TPM_NV_ReadValue(0x10004d47, 0, 322, blob, &bloblen, NULL);
	if (ret != 0) {
		for (i=1; i<argc; i++) {
			fd = open(argv[1], O_RDONLY);
			if (fd < 0) {
				argv++;
			}
		}

		if (fd < 0) {
			perror("Unable to open file");
			return -1;
		}

		ret = fstat(fd, &sbuf);
		if (ret) {
			perror("Unable to stat file");
			return -1;
		}
		bloblen = sbuf.st_size;
		ret = read(fd, blob, bloblen);

		if (ret != bloblen) {
			fprintf(stderr, "Unable to read data\n");
			return -1;
		}

		if (strncmp(argv[1], efivarfs, strlen(efivarfs)) == 0) {
			bloblen -= sizeof(int);
			memmove (blob, blob + sizeof(int), bloblen);
		}
	}

	ret = TPM_Unseal(parhandle,	/* KEY Entity Value */
			 passptr1,	/* Key Password */
			 NULL,
			 blob, bloblen,
			 key, &outlen);

	if (ret == 24) {
		fprintf(stderr, "TPM refused to decrypt key - boot process attests that it is modified\n");
		return -1;
	}

	if (ret != 0) {
		printf("Error %s from TPM_Unseal\n", TPM_GetErrMsg(ret));
		exit(6);
	}

	if (outlen != keylen) {
		fprintf(stderr, "Returned buffer is incorrect length\n");
		return -1;
	}

	ply_client = ply_boot_client_new();
	ply_loop = ply_event_loop_new();
	if (!ply_boot_client_connect (ply_client, (ply_boot_client_disconnect_handler_t) on_disconnect, NULL)) {
		fprintf(stderr, "Plymouth not running\n");
		return -1;
	}
	ply_boot_client_attach_to_event_loop(ply_client, ply_loop);
	display_totp();

	t = time(NULL);
	delay = 30 - (t % 30);
	ply_event_loop_watch_for_timeout(ply_loop, delay, on_timeout, NULL);

	ply_event_loop_run(ply_loop);
	return 0;
}