From owner-svn-soc-all@FreeBSD.ORG Sat Aug 9 10:47:45 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 93A2A273 for ; Sat, 9 Aug 2014 10:47:45 +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 749632B1E for ; Sat, 9 Aug 2014 10:47:45 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id s79Alj91058440 for ; Sat, 9 Aug 2014 10:47:45 GMT (envelope-from seiya@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id s79Alj9X058438 for svn-soc-all@FreeBSD.org; Sat, 9 Aug 2014 10:47:45 GMT (envelope-from seiya@FreeBSD.org) Date: Sat, 9 Aug 2014 10:47:45 GMT Message-Id: <201408091047.s79Alj9X058438@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: r272121 - soc2014/seiya/bootsplash/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 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, 09 Aug 2014 10:47:45 -0000 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