Skip to contentSkip to conversation

Patch, please TEST: linux-2.4.9 console font modularization

PATCH Adam J. Richter 2 participants 2 messages Aug 19, 2001 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

Here is my first pass at modularizing the framebuffer console
fonts. The benefits of this change are primarily for users who compile more than just the default console font in their kernel:

o Saves unswappable kernel memory.

o Enables smaller boot floppies (more drivers) and boot partitions.

o At least after I get font unloading working, it will make it feasible to upgrade console font modules without rebooting.

With this change, you do not have to have all of the console
fonts that you would ever want to use without rebooting locked into kernel memory. Instead, you can just load the fonts that to use and still have the possibility to load other fonts later if you want.

One big deficiency with this code is that it will
not allow you to unload a font once it has been used, because I have not added any calls to my new release_font() routine. However, this is still no worse than the status quo.

fbcon_find_font will now attempt to use modprobe to load
a font that it fails to find; however, since the font names do not currently match the module names, you will need to edit your /etc/modules.conf file to make this work. Also, this functionality does not currently extend to fbcon_get_default_font, since it does not take a font name, although I could add a request_module("default_font") for users to define in /etc/modules.conf if they want, if nothing smarter can be done.

All that I know about behavior of this patch right now is that
it does not break my VGA console (which does not use these fonts, to the best of my knowledge). Since this new code causes fonts to initialized by module_init() declarations, and those routines are called rather late in kernel initialization, I suspect that there may be order of initialization problem with that, and would appreciate confirmation.

Signature · 4 lines
Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
[email protected]     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America
fax +1 408 261-6631      "Free Software For The Rest Of Us."
include/video/font.h +19 -0
@@ -12,6 +12,8 @@
 #define _VIDEO_FONT_H
 
 #include <linux/types.h>
+#include <linux/module.h>
+#include <linux/init.h>
 
 struct fbcon_font_desc {
     int idx;
@@ -19,6 +21,8 @@
     int width, height;
     void *data;
     int pref;
+    struct module *module;
+    struct fbcon_font_desc *next;
 };
 
 #define VGA8x8_IDX	0
@@ -37,6 +41,9 @@
 				font_sun_12x22,
 				font_acorn_8x8;
 
+extern void fbcon_register_font(struct fbcon_font_desc *font);
+extern void fbcon_unregister_font(struct fbcon_font_desc *font);
+
 /* Find a font with a specific name */
 
 extern struct fbcon_font_desc *fbcon_find_font(char *name);
@@ -47,5 +54,17 @@
 
 /* Max. length for the name of a predefined font */
 #define MAX_FONT_NAME	32
+
+#define DECLARE_FONT_MODULE(font)			\
+	static int __init font_init(void) {		\
+		(font)->module = THIS_MODULE;		\
+		fbcon_register_font(font);		\
+		return 0;				\
+	}						\
+	static void __exit font_exit(void) {		\
+		fbcon_unregister_font(font);		\
+	}						\
+	module_init(font_init);				\
+	module_exit(font_exit);				\
 
 #endif /* _VIDEO_FONT_H */
drivers/video/Config.in +33 -28

105 lines not on this page · raw message

drivers/video/Makefile +1 -1
diff -r -u linux-2.4.9/drivers/video/Makefile linux/drivers/video/Makefile
@@ -9,7 +9,7 @@
 # All of the (potential) objects that export symbols.
 # This list comes from 'grep -l EXPORT_SYMBOL *.[hc]'.
 
-export-objs    := fbmem.o fbcmap.o fbcon.o fbmon.o modedb.o \
+export-objs    := fbmem.o fbcmap.o fbcon.o fbmon.o fonts.o modedb.o \
 		  fbcon-afb.o fbcon-ilbm.o \
 		  fbcon-vga.o fbcon-iplan2p2.o fbcon-iplan2p4.o \
 		  fbcon-iplan2p8.o fbcon-vga-planes.o fbcon-cfb16.o \
drivers/video/font_6x11.c +3 -1
diff -r -u linux-2.4.9/drivers/video/font_6x11.c linux/drivers/video/font_6x11.c
@@ -3341,7 +3341,7 @@
 };
 
 
-struct fbcon_font_desc font_vga_6x11 = {
+static struct fbcon_font_desc font_vga_6x11 = {
 	VGA6x11_IDX,
 	"ProFont6x11",
 	6,
@@ -3349,3 +3349,5 @@
 	fontdata_6x11,
 	-2000	/* Try avoiding this font if possible unless on MAC */
 };
+
+DECLARE_FONT_MODULE(&font_vga_6x11);
drivers/video/font_8x16.c +3 -1
diff -r -u linux-2.4.9/drivers/video/font_8x16.c linux/drivers/video/font_8x16.c
@@ -4621,7 +4621,7 @@
 };
 
 
-struct fbcon_font_desc font_vga_8x16 = {
+static struct fbcon_font_desc font_vga_8x16 = {
 	VGA8x16_IDX,
 	"VGA8x16",
 	8,
@@ -4629,3 +4629,5 @@
 	fontdata_8x16,
 	0
 };
+
+DECLARE_FONT_MODULE(&font_vga_8x16);
drivers/video/font_8x8.c +3 -1
diff -r -u linux-2.4.9/drivers/video/font_8x8.c linux/drivers/video/font_8x8.c
@@ -2573,7 +2573,7 @@
 };
 
 
-struct fbcon_font_desc font_vga_8x8 = {
+static struct fbcon_font_desc font_vga_8x8 = {
 	VGA8x8_IDX,
 	"VGA8x8",
 	8,
@@ -2581,3 +2581,5 @@
 	fontdata_8x8,
 	0
 };
+
+DECLARE_FONT_MODULE(&font_vga_8x8);
drivers/video/font_acorn_8x8.c +3 -1
diff -r -u linux-2.4.9/drivers/video/font_acorn_8x8.c linux/drivers/video/font_acorn_8x8.c
@@ -263,7 +263,7 @@
 /* FF */  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
 
-struct fbcon_font_desc font_acorn_8x8 = {
+static struct fbcon_font_desc font_acorn_8x8 = {
 	ACORN8x8_IDX,
 	"Acorn8x8",
 	8,
@@ -275,3 +275,5 @@
 	0
 #endif
 };
+
+DECLARE_FONT_MODULE(&font_acorn_8x8);
drivers/video/font_pearl_8x8.c +3 -1
diff -r -u linux-2.4.9/drivers/video/font_pearl_8x8.c linux/drivers/video/font_pearl_8x8.c
@@ -2577,7 +2577,7 @@
 
 };
 
-struct fbcon_font_desc font_pearl_8x8 = {
+static struct fbcon_font_desc font_pearl_8x8 = {
 	PEARL8x8_IDX,
 	"PEARL8x8",
 	8,
@@ -2585,3 +2585,5 @@
 	fontdata_pearl8x8,
 	2
 };
+
+DECLARE_FONT_MODULE(&font_pearl_8x8);
drivers/video/font_sun12x22.c +3 -1
diff -r -u linux-2.4.9/drivers/video/font_sun12x22.c linux/drivers/video/font_sun12x22.c
@@ -6206,7 +6206,7 @@
 };
 
 
-struct fbcon_font_desc font_sun_12x22 = {
+static struct fbcon_font_desc font_sun_12x22 = {
 	SUN12x22_IDX,
 	"SUN12x22",
 	12,
@@ -6218,3 +6218,5 @@
 	-1
 #endif
 };
+
+DECLARE_FONT_MODULE(&font_sun_12x22);
drivers/video/font_sun8x16.c +3 -1
diff -r -u linux-2.4.9/drivers/video/font_sun8x16.c linux/drivers/video/font_sun8x16.c
@@ -261,7 +261,7 @@
 /* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 };
 
-struct fbcon_font_desc font_sun_8x16 = {
+static struct fbcon_font_desc font_sun_8x16 = {
 	SUN8x16_IDX,
 	"SUN8x16",
 	8,
@@ -273,3 +273,5 @@
 	-1
 #endif
 };
+
+DECLARE_FONT_MODULE(&font_sun_8x16);
drivers/video/fonts.c +86 -47

173 lines not on this page · raw message

#1 lore raw

See Geerts email about the proper solution. The only reason we have font images in the kernel is because fbdev devices usually don't have hardware fonts. Otherwise we wouldn't have them here. Personally I like to seem them __initdata so they go away after boot time.