This is an old revision of the document!
A new bootsplash system for FreeBSD
Design
A bootsplash theme is a kernel module which implements these functions using API described below.
void bstheme_early_init(int screen_size_y, int screen_size_x): Draw image before kernel thread mechanism is activated.void bstheme_init(void): Add a kernel thread to update screen periodically if needed.void bstheme_kmsg(const char *msg): Print a message if needed. msg is a kernel messsagesvoid bstheme_update(int percentage): Advance the position of progress bar if needed.void bstheme_uninit(void): Go back into text mode.
API for themes
The bootsplash system holds a array of struct bs_layer below. Themes receives pointers of them by ns_new_*_layer*() and manipulate variables.
struct bs_layer{ void* data; /* The pointer to content of a file/text. */ int screen_y, screen_x; /* Position on screen. */ int image_y, image_x; /* Stating on the image. It is unused in text layers. */ int height; /* The height of this layer. It is unused in text layers. */ int width; /* The width of this layer. It is unused in text layers. */ int visibility; /* If visiblility is NOT 0, this layer will be drawn by bs_draw_layers(). */ int z-index; /* The stack order of layers. A layer with the greater value is drawn above layers with lesser value. */ };
void bootsplash_drawImage(const char *filename): Draw image (.pcx or .bmp) in the screen. It determines file type by the extension.struct bs_layer *bs_new_image_layer(const char *filename): Create a layer with a image (.pcx or .bmp) file. I want to support .png files with libpng.struct bs_layer *bs_new_text_layer(const char *text): Create a layer with a text.void bs_draw_layers(): Draw layers.void bs_go_back_into_text_mode(): Go back into text mode.
Implementation
loader(8) loads bootsplash theme as a kernel module and load images in /boot/splash as splash_image.
bstheme_early_init(): is called before copyright printed.bstheme_init(): is called after kernel thread mechanism is activated.bstheme_kmsg(): is called each lines of kernel messages.bstheme_update(): is called before each SYSINIT element initialization.bstheme_uninit(): is called after kernel initialization has finished. I want to let it be called just before login(1) has started but I have no good idea to implement it.
loader.rc
Load splash images by /boot/splash/splash.4th (auto generated)
# loader.rc include /boot/splash/splash.4th # splash.4th load -t splash_image /boot/splash/image_1.bmp load -t splash_image /boot/splash/image_2.bmp # ...
Integration with the existing grahpical bootloader
I'll develop a theme which can parse an extended configuration file based on https://wiki.freebsd.org/OliverFromme/BootLoader. It makes creating bootsplash theme more easier. The extended theme.conf looks like this:
theme_background="/boot/themes/default/biglogo.pcx" theme_font="/boot/themes/default/default.font" theme_bgcolor="0 0 0" # black theme_fgcolor="255 255 255" # white theme_options_xy="64 10" theme_actions_xy="64 82" # ***** extended configuration are as follows ***** theme_on_kernel_init_enable="YES" # it enables configurations below # # Bootsplash system loads files specified in `theme_progress_images' to draw a progress bar. # `%' will be replaced with 10,20,30,...,100. # You have to prepare progress_bar10.pcx, progress_bar20.pcx, ..., progress_bar100.pcx in /boot/themes/default. # theme_progress_bar_enable="YES" theme_progress_bar_images="/boot/themes/default/progress_bar%.pcx" theme_progress_bar_xy="150 300" # # Bootsplash system loads files speicifed in `theme_boot_animation_images' to render a animation on boot. # `%' will be replaced with 1,2,3,...,100. # You have to prepare animation1.pcx at least in /boot/themes/default. # theme_boot_animation_enable="YES" theme_boot_animation_images="/boot/themes/default/animation%.pcx" theme_boot_animation_xy="150 100" theme_boot_animation_fps="15" theme_boot_animation_repeat="YES" # Bootsplash system updates it per lines. theme_boot_kmsg_enable="YES" theme_boot_kmsg_xy = "150 400"