socsvn commit: r268743 - in soc2014/seiya/bootsplash/sys: boot/forth dev/fb sys
seiya at FreeBSD.org
seiya at FreeBSD.org
Wed May 28 06:04:28 UTC 2014
Author: seiya
Date: Wed May 28 06:04:26 2014
New Revision: 268743
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=268743
Log:
use kenv instead of config parser in the kernel
trasz@ taught me that parsing config files in the kernel is unusual.
So I consulted with my mentor and in conclusion kenv is preferable.
Discussed with: kmoore@
Modified:
soc2014/seiya/bootsplash/sys/boot/forth/loader.conf
soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c
soc2014/seiya/bootsplash/sys/sys/kernel.h
Modified: soc2014/seiya/bootsplash/sys/boot/forth/loader.conf
==============================================================================
--- soc2014/seiya/bootsplash/sys/boot/forth/loader.conf Wed May 28 05:57:35 2014 (r268742)
+++ soc2014/seiya/bootsplash/sys/boot/forth/loader.conf Wed May 28 06:04:26 2014 (r268743)
@@ -38,9 +38,10 @@
bitmap_type="splash_image_data" # and place it on the module_path
bsplash_load="NO" # Set this to YES to enable enhanced bootsplash!
-bsplash_conf_load="NO" # Set this to YES to enable enhanced bootsplash too!
-bsplash_conf_name="/boot/splash/default/splash.conf" # name of configuration file
-bsplash_conf_type="bsplash_conf"
+# bsplash_first_image="/boot/splash/foo/bg.bmp" # an image drawn before animation
+# bsplash_animation_images="/boot/splash/foo/animation%.bmp" # animation images
+# bsplash_animation_fps="15" # frame per second
+
##############################################################
### Random number generator configuration ###################
Modified: soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c
==============================================================================
--- soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c Wed May 28 05:57:35 2014 (r268742)
+++ soc2014/seiya/bootsplash/sys/dev/fb/bsplash.c Wed May 28 06:04:26 2014 (r268743)
@@ -35,140 +35,28 @@
#include <sys/libkern.h>
#include <sys/malloc.h>
-MALLOC_DEFINE(M_BSPLASH, "bsplash", "Buffers to store configuration");
-
-enum config_keys {
- CONF_FULLSCREEN_FIRST_IMAGE = 0,
- CONF_FULLSCREEN_AMINATION_IMAGES = 1,
- CONF_ANIMATION_FPS = 2,
- CONF_NUM = 3
-};
-
-#define CONF_VAL_MAX 256
-
-static char *config [CONF_NUM];
-
-static int load_config(void)
-{
- caddr_t conf;
- char *ptr;
- char *key;
- char *val;
- int line;
-
- conf = preload_search_by_type("bsplash_conf");
- if(conf == NULL) {
- printf("bsplash: failed to load bootsplash configuration\n");
- return -1;
- }
-
- ptr = preload_fetch_addr(conf);
-
- for(int i=0; i < CONF_NUM; i++) {
- if((config[i] = malloc(CONF_VAL_MAX, M_BSPLASH, M_NOWAIT)) == NULL) {
- printf("bsplash: malloc() returned NULL, aborted\n");
- return -1;
- }
- }
-
- /*
- * parse config file
- */
- for(line = 1; *ptr; line++) {
- /* skip whitespaces / tabs */
- while(*ptr && (*ptr == ' ' || *ptr == '\t'))
- ptr++;
- if(*ptr == '\0')
- break;
-
- if(*ptr != '\n' && *ptr != '#') {
- /*
- * parse a line
- */
-
- key = ptr;
- while(*ptr && *ptr != '=')
- ptr++;
- /* '=' not found */
- if(*ptr == '\0')
- goto parse_error;
-
- *ptr = '\0'; /* '=' -> '\0' */
- val = ++ptr;
-
- /* '\n' -> '\0' */
- while(*ptr && *ptr != '\n')
- ptr++;
- if(*ptr){
- *ptr = '\0';
- ptr++;
- }
-
- if(*val == '\0' || val[0] != '"' || val[strlen(val)-1] != '"')
- goto parse_error;
-
- /* FIXME: ignore if `val' is too long */
- if(strlen(val) > CONF_VAL_MAX){
- printf("bsplash: line %d is too long, ignored\n", line);
- }else{
-
- /*
- * save config
- */
- if(!strcmp(key, "fullscreen_first_image")) {
- strcpy(config[CONF_FULLSCREEN_FIRST_IMAGE], val);
- }else if(!strcmp(key, "fullscreen_animation_images")) {
- strcpy(config[CONF_FULLSCREEN_AMINATION_IMAGES], val);
- }else if(!strcmp(key, "animation_fps")) {
- strcpy(config[CONF_ANIMATION_FPS], val);
- }else{
- printf("bsplash: unknown configuration '%s', ignored\n", key);
- }
- }
-
- /* in comment line or blank line */
- }else{
- /* skip this line */
- while(*ptr && *ptr != '\n')
- ptr++;
- if(*ptr)
- ptr++;
- }
- }
-
- return 0;
-
- parse_error:
- printf("bsplash: configuration parse error at line %d\n", line);
- return -1;
-}
-
/*
* Load configuration and draw image before kernel thread mechanism is activated.
*/
static void bsplash_early_init (void){
+ char *first_image;
- for(int i=0; i < CONF_NUM; i++)
- config[i] = NULL;
-
- load_config();
+ first_image = getenv("bsplash_first_image");
+ if (first_image != NULL) {
+ printf("first_image: %s\n", first_image);
+ /* TODO: render first_image */
+ }
+ freeenv(first_image);
}
static void bsplash_uninit (void){
-
- for(int i=0; i < CONF_NUM; i++) {
- if(config[i])
- free(config[i], M_BSPLASH);
- }
}
static int modevent(module_t mod, int type, void *data)
{
- printf("bsplash: hello world!\n");
-
switch ((modeventtype_t)type) {
case MOD_LOAD:
bsplash_early_init();
Modified: soc2014/seiya/bootsplash/sys/sys/kernel.h
==============================================================================
--- soc2014/seiya/bootsplash/sys/sys/kernel.h Wed May 28 05:57:35 2014 (r268742)
+++ soc2014/seiya/bootsplash/sys/sys/kernel.h Wed May 28 06:04:26 2014 (r268743)
@@ -89,7 +89,6 @@
SI_SUB_DUMMY = 0x0000000, /* not executed; for linker*/
SI_SUB_DONE = 0x0000001, /* processed*/
SI_SUB_TUNABLES = 0x0700000, /* establish tunable values */
- SI_SUB_BOOTSPLASH = 0x0780000, /* bootsplash */
SI_SUB_COPYRIGHT = 0x0800001, /* first use of console*/
SI_SUB_SETTINGS = 0x0880000, /* check and recheck settings */
SI_SUB_MTX_POOL_STATIC = 0x0900000, /* static mutex pool */
More information about the svn-soc-all
mailing list