socsvn commit: r272493 - in soc2014/seiya/bootsplash: etc sys/boot/forth sys/dev/fb
seiya at FreeBSD.org
seiya at FreeBSD.org
Sat Aug 16 11:05:48 UTC 2014
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<E */){
- /* terminate boot splash */
+ if (count > 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;
More information about the svn-soc-all
mailing list