From owner-svn-soc-all@FreeBSD.ORG Sat Aug 16 11:05:48 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4EAB971A for ; Sat, 16 Aug 2014 11:05:48 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3975E2D4D for ; Sat, 16 Aug 2014 11:05:48 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7GB5m0O035371 for ; Sat, 16 Aug 2014 11:05:48 GMT (envelope-from seiya@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s7GB5lte035367 for svn-soc-all@FreeBSD.org; Sat, 16 Aug 2014 11:05:47 GMT (envelope-from seiya@FreeBSD.org) Date: Sat, 16 Aug 2014 11:05:47 GMT Message-Id: <201408161105.s7GB5lte035367@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to seiya@FreeBSD.org using -f From: seiya@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r272493 - in soc2014/seiya/bootsplash: etc sys/boot/forth sys/dev/fb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Aug 2014 11:05:48 -0000 Author: seiya Date: Sat Aug 16 11:05:46 2014 New Revision: 272493 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272493 Log: scrub code Modified: soc2014/seiya/bootsplash/etc/rc soc2014/seiya/bootsplash/sys/boot/forth/loader.conf soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c Modified: soc2014/seiya/bootsplash/etc/rc ============================================================================== --- soc2014/seiya/bootsplash/etc/rc Sat Aug 16 10:47:24 2014 (r272492) +++ soc2014/seiya/bootsplash/etc/rc Sat Aug 16 11:05:46 2014 (r272493) @@ -126,13 +126,13 @@ files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* ${local_rc} 2>/dev/null` files_num=`echo "$files" | wc -l` files_num_per_10=`expr $files_num / 10` # FIXME +boot_progress=0 i=0 -BOOT_PROGRESS=0 for _rc_elem in ${files}; do i=`expr $i + 1` if [ $files_num_per_10 -eq $i ]; then - BOOT_PROGRESS=`expr $BOOT_PROGRESS + 10` - kenv BOOT_PROGRESS=$BOOT_PROGRESS > /dev/null + boot_progress=`expr $boot_progress + 10` + kenv boot_progress=$boot_progress > /dev/null i=0 fi @@ -153,7 +153,7 @@ fi # terminate boot splash -kenv BOOT_PROGRESS=100 > /dev/null +kenv boot_progress=100 > /dev/null echo '' date Modified: soc2014/seiya/bootsplash/sys/boot/forth/loader.conf ============================================================================== --- soc2014/seiya/bootsplash/sys/boot/forth/loader.conf Sat Aug 16 10:47:24 2014 (r272492) +++ soc2014/seiya/bootsplash/sys/boot/forth/loader.conf Sat Aug 16 11:05:46 2014 (r272493) @@ -40,7 +40,7 @@ bsplash_load="NO" # Set this to YES to enable enhanced bootsplash! bsplash_image_load="NO" bsplash_image_type="bsplash_image" - +boot_progress="0" ############################################################## ### Random number generator configuration ################### Modified: soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c ============================================================================== --- soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c Sat Aug 16 10:47:24 2014 (r272492) +++ soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c Sat Aug 16 11:05:46 2014 (r272493) @@ -49,7 +49,7 @@ static int bsplash_init (void); static void bsplash_exit (void); -static void update_animation(void *unused); +static void update_animation_thread(void *unused); static int load_bmp(BMP_INFO *bmp, void* data); static int draw_bmp(BMP_INFO *bmp, int iy, int sy, int sx, int width, int height); @@ -76,7 +76,9 @@ bsplash_stop = _bsplash_stop; } - +/* + * Displays a prompt screen. Note that characters are not echoed. + */ int bsplash_prompt_user(const char *tag) { @@ -103,6 +105,9 @@ } +/* + * Displays a failure screen for a few seconds + */ int bsplash_prompt_failure(const char *tag) { @@ -120,13 +125,15 @@ return 1; } - /* display a failure screen for a few seconds */ pause("bsplash", 2*hz); return 0; } +/* + * Clears prompt screen and displays boot splash screen. + */ int bsplash_prompt_success(const char *tag) { @@ -150,6 +157,7 @@ } } + static int bsplash_init(void) { @@ -256,63 +264,86 @@ return 1; } - if (kthread_add(update_animation, NULL, NULL, NULL, 0, 0, "bsplash") != 0){ + if (kthread_add(update_animation_thread, NULL, NULL, NULL, 0, 0, "bsplash") != 0){ bsplash_exit(); - printf("bsplash: failed to start kernel thread 'update_animation()'\n"); + printf("bsplash: failed to start kernel thread 'update_animation_thread()'\n"); return 1; } return 0; } + static void -update_animation(void *unused) +update_animation (int *iy) { - static int count = 0; - static int iy; - char *s; - int progress = 0; - int stop_animation = 0; + static int stop = 0; - iy = animation_y_origin; - for (;;){ - // update animation - if(!in_prompt){ - if(!stop_animation){ - if (draw_bmp(&bmp_info, iy, animation_y, animation_x, - animation_width, animation_height) == 0){ - iy += animation_height; - } else { - if (!repeat_animation){ - stop_animation = 1; - } else { - iy = animation_y_origin; - // try again - if (draw_bmp(&bmp_info, iy, animation_y, animation_x, - animation_width, animation_height) == 0) - iy += animation_height; - } - } - } + if (stop) + return; + + if (draw_bmp(&bmp_info, *iy, animation_y, animation_x, + animation_width, animation_height) == 0){ + *iy += animation_height; + } else { + /* It failed to draw. */ + + if (!repeat_animation){ + stop = 1; + } else { + // re-start from the origin + *iy = animation_y_origin; + // try again + if (draw_bmp(&bmp_info, *iy, animation_y, animation_x, + animation_width, animation_height) == 0) + *iy += animation_height; + } + } +} + + +static void +update_progress_bar (void) +{ + static int progress; + + // get the progress of boot + if (!getenv_int("boot_progress", &progress)) + progress = 100; // abort bootsplash + + if (progress >= 100 /* boot has finished */){ + // terminate boot splash + bsplash_exit(); + kthread_exit(); + } + + // update the progress bar + draw_bmp(&bmp_info, progress_bar_y_origin + ((progress / 10) * progress_bar_height), + progress_bar_y, progress_bar_x, progress_bar_width, progress_bar_height); +} - // get the progress of boot - if ((s = getenv("BOOT_PROGRESS")) != NULL){ - progress = strtol(s, NULL, 10); - freeenv(s); - } - // update the progress bar - draw_bmp(&bmp_info, progress_bar_y_origin + ((progress / 10) * progress_bar_height), - progress_bar_y, progress_bar_x, progress_bar_width, progress_bar_height); +static void +update_animation_thread(void *unused) +{ + static int count = 0; + static int iy; + + iy = animation_y_origin; + for (;;){ + if (!in_prompt){ + update_animation(&iy); + update_progress_bar(); + count++; - if (progress >= 100 /* boot has finished */ || count > 50 /* FIX 50 /* boot takes too long times */){ + // terminate boot splash bsplash_exit(); kthread_exit(); } } - count++; - pause("bsplash", 3*hz /* FIXME: this is because draw_bmp() takes too long time */); + + pause("bsplash", 3 * hz); } } @@ -336,6 +367,8 @@ static int draw_bmp(BMP_INFO *bmp, int iy, int sy, int sx, int width, int height) { + if (adp == NULL) + return 1; if (bmp_draw(adp, bmp, iy, sy, sx, width, height) != 0) return 1;