socsvn commit: r272121 - soc2014/seiya/bootsplash/sys/dev/fb
seiya at FreeBSD.org
seiya at FreeBSD.org
Sat Aug 9 10:47:45 UTC 2014
Author: seiya
Date: Sat Aug 9 10:47:44 2014
New Revision: 272121
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272121
Log:
some enhancements
Modified:
soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c
Modified: soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c
==============================================================================
--- soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c Sat Aug 9 10:30:02 2014 (r272120)
+++ soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c Sat Aug 9 10:47:44 2014 (r272121)
@@ -47,6 +47,8 @@
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768
+static int bsplash_init (void);
+static void bsplash_exit (void);
static void update_animation(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);
@@ -74,6 +76,80 @@
bsplash_stop = _bsplash_stop;
}
+
+int
+bsplash_prompt_user(const char *tag)
+{
+ char env_name[64];
+ char *s;
+ int y_origin;
+
+ in_prompt = 1;
+ snprintf(env_name, sizeof(env_name), "bsplash_%s_prompt_y_origin", tag);
+
+ if ((s = getenv((const char *) env_name)) == NULL) {
+ return 1;
+ } else {
+ y_origin = strtol(s, NULL, 10);
+ }
+ freeenv(s);
+
+ if (draw_bmp(&bmp_info, y_origin, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) != 0){
+ printf("bsplash: failed to draw BMP (tag: %s)\n", tag);
+ return 1;
+ }
+
+ return 0;
+}
+
+
+int
+bsplash_prompt_failure(const char *tag)
+{
+ char env[64];
+ int y_origin;
+
+ snprintf(env, sizeof(env), "bsplash_%s_failure_y_origin", tag);
+
+ if (!getenv_int(env, &y_origin))
+ return 1;
+
+ if (draw_bmp(&bmp_info, y_origin, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) != 0){
+ bsplash_exit();
+ printf("bsplash: failed to draw BMP (tag: %s)\n", tag);
+ return 1;
+ }
+
+ /* display a failure screen for a few seconds */
+ pause("bsplash", 2*hz);
+
+ return 0;
+}
+
+
+int
+bsplash_prompt_success(const char *tag)
+{
+ if (draw_bmp(&bmp_info, background_y_origin, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) != 0){
+ printf("bsplash: failed to draw BMP (background)\n");
+ in_prompt = 0;
+ return 1;
+ }
+
+ in_prompt = 0;
+ return 0;
+}
+
+
+static void
+bsplash_exit (void){
+
+ if (adp != NULL){
+ (*bsplash_stop)(adp, sc);
+ adp = NULL;
+ }
+}
+
static int
bsplash_init(void)
{
@@ -81,7 +157,7 @@
void *p;
char *s;
- if(adp == NULL)
+ if (adp == NULL)
return 1;
/*
@@ -175,11 +251,13 @@
*/
if (background_enabled &&
draw_bmp(&bmp_info, background_y_origin, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) != 0){
+ bsplash_exit();
printf("bsplash: failed to draw BMP (background)\n");
return 1;
}
if (kthread_add(update_animation, NULL, NULL, NULL, 0, 0, "bsplash") != 0){
+ bsplash_exit();
printf("bsplash: failed to start kernel thread 'update_animation()'\n");
return 1;
}
@@ -229,7 +307,7 @@
if (progress >= 100 /* boot has finished */ || count > 50 /* FIX<E */){
/* terminate boot splash */
- (*bsplash_stop)(adp, sc);
+ bsplash_exit();
kthread_exit();
}
}
@@ -239,64 +317,6 @@
}
-int
-bsplash_prompt_user(const char *tag)
-{
- char env_name[64];
- char *s;
- int y_origin;
-
- in_prompt = 1;
- snprintf(env_name, sizeof(env_name), "bsplash_%s_prompt_y_origin", tag);
-
- if ((s = getenv((const char *) env_name)) == NULL) {
- return 1;
- } else {
- y_origin = strtol(s, NULL, 10);
- }
- freeenv(s);
-
- if (draw_bmp(&bmp_info, y_origin, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) != 0){
- printf("bsplash: failed to draw BMP (tag: %s)\n", tag);
- return 1;
- }
-
- return 0;
-}
-
-int
-bsplash_prompt_failure(const char *tag)
-{
- char env[64];
- int y_origin;
-
- snprintf(env, sizeof(env), "bsplash_%s_failure_y_origin", tag);
-
- if (!getenv_int(env, &y_origin))
- return 1;
-
- if (draw_bmp(&bmp_info, y_origin, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) != 0){
- printf("bsplash: failed to draw BMP (tag: %s)\n", tag);
- return 1;
- }
-
- return 0;
-}
-
-int
-bsplash_prompt_success(const char *tag)
-{
- if (draw_bmp(&bmp_info, background_y_origin, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) != 0){
- printf("bsplash: failed to draw BMP (background)\n");
- in_prompt = 0;
- return 1;
- }
-
- in_prompt = 0;
- return 0;
-}
-
-
static int
load_bmp(BMP_INFO *bmp, void* data)
{
@@ -312,6 +332,7 @@
return 0;
}
+
static int
draw_bmp(BMP_INFO *bmp, int iy, int sy, int sx, int width, int height)
{
@@ -330,6 +351,7 @@
bsplash_init();
break;
case MOD_UNLOAD:
+ bsplash_exit();
break;
default:
return EOPNOTSUPP;
More information about the svn-soc-all
mailing list