This is an old revision of the document!
A new enhanced bootsplash
Project description
I propose a new bootsplash mechanism. Currently, we can enable bootsplash by adding few options such as splash_bmp_load to /boot/loader.conf but it only displays an image file so I cannot reassure that the system works well. Therefore, I want to develop a new bootsplash mechanism which enables enhancements of attractiveness, such as progress bar. I think this will greatly improve user experience. I’m planning to implement this using src/sys/dev/fb, SYSINIT and kernel module system.
Approach to solving the problem
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.
loader(8)
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"
Deliverables
- Implementation of a new bootsplash mechanism in the kernel
- Makefile and scripts for creating bootsplash themes
- Example themes
Milestones
Work Period #1
- (May 19) Start of coding
- (May 19 - May 25) implement direct drawing (only draw an image file at once just like splash_bmp_load, but it enables rendering multiple image files)
- May 26 - June 8: add changes to src/sys (e.g. SYSINIT framework)
- June 9 - June 15: write Makefile and scripts for creating themes
- June 16 - June 22: create and enjoy a flip book in bootsplash using direct drawing
- July 27: Mid-term evaluations deadline
- June 23 - June 29: print characters in a framebuffer
- June 30 - July 20: implement layered drawing (draw stacked images and text at once)
- July 21 - July 27: support layered drawing in scripts for creating themes
- July 28 - 'pencils down' date: create themes
- August 11: End of coding (soft)
- August 18: End of coding (hard)
Test Plan
#1
- Write code in VM on VirtualBox
makeand copy generated kernel and modules to /boot- Launch .vdi of the VM with QEMU on host OS
- Check output and dmesg
#2
make buildinstallon a real machine.- boot it
- check output and dmesg