X-Sender: ddkilzer@mail.earthlink.net
X-Files: Sundays at 8 PM CDT on Fox!
Date: Sun, 30 Aug 1998 16:34:42 -0500
To: Geert Uytterhoeven <Geert.Uytterhoeven@cs.kuleuven.ac.be>,
        Michael Schmitz <SCHMITZ@LCBVAX.CCHEM.BERKELEY.EDU>
From: "David D. Kilzer" <ddkilzer@earthlink.net>
Subject: L68K: Patch for struct fbcon_font_desc offsets
Cc: Linux-m68k Mailing List <linux-m68k@lists.linux-m68k.org>
X-MIME-Autoconverted: from quoted-printable to 8bit by www.phil.uni-sb.de id XAA02814
Sender: owner-linux-m68k@phil.uni-sb.de

Hi Geert,

The patch below adds structure offsets for struct fbcon_font_desc.  The Mac version of head.S uses console fonts during its boot sequence, and with the changes to the fonts (declaring the font data static), I needed the offsets of the structure.  The drivers/video/font.h file seemed like the best place.

If you decide to use different names in future patches, please let me know.

Also included below is the diff for the MACINTOSH VERSION of head.S (after it's been patched by a mac-2.1.X-vanilla patch).  Mac hackers may find it useful.  The changes will be incoporated in my next mac-2.1.X-vanilla diff.

Dave ``Rediscovering m68k assembly for the first time'' Kilzer


diff -u5 linux-2.1.115-michael/drivers/video/font.h.cln linux-2.1.115-michael/drivers/video/font.h
--- linux-2.1.115-michael/drivers/video/font.h.cln	Fri Aug 28 01:04:28 1998
+++ linux-2.1.115-michael/drivers/video/font.h	Sun Aug 30 15:06:46 1998
@@ -9,10 +9,21 @@
  */
 
 #ifndef _FONT_H_
 #define _FONT_H_
 
+#ifdef __ASSEMBLY__
+
+#define FBCON_FONT_DESC_idx	0
+#define FBCON_FONT_DESC_name	(FBCON_FONT_DESC_idx   +4)
+#define FBCON_FONT_DESC_width	(FBCON_FONT_DESC_name  +4)
+#define FBCON_FONT_DESC_height	(FBCON_FONT_DESC_width +4)
+#define FBCON_FONT_DESC_data	(FBCON_FONT_DESC_height+4)
+#define FBCON_FONT_DESC_pref	(FBCON_FONT_DESC_data  +4)
+
+#else /* __ASSEMBLY__ */
+
 #include <linux/types.h>
 
 struct fbcon_font_desc {
     int idx;
     char *name;
@@ -45,7 +56,9 @@
 
 extern struct fbcon_font_desc *fbcon_get_default_font(int xres, int yres);
 
 /* Max. length for the name of a predefined font */
 #define MAX_FONT_NAME	32
+
+#endif /* __ASSEMBLY__ */
 
 #endif /* _FONT_H_ */


diff -u5 linux-2.1.115-michael/arch/m68k/kernel/head.S.orig linux-2.1.115-michael/arch/m68k/kernel/head.S
--- linux-2.1.115-michael/arch/m68k/kernel/head.S.orig	Wed Aug 26 22:21:09 1998
+++ linux-2.1.115-michael/arch/m68k/kernel/head.S	Sun Aug 30 15:28:52 1998
@@ -18,10 +18,12 @@
 ** ++ Bjoern & Roman: ATARI-68040 support for the Medusa
 ** 95/11/18 Richard Hirst: Added MVME166 support
 ** 96/04/26 Guenther Kelleter: fixed identity mapping for Falcon with
 ** 			      Magnum- and FX-alternate ram
 ** 98/04/25 Phil Blundell: added HP300 support
+** 1998/08/30 David Kilzer: Added support for fbcon_font_desc structures
+**            for linux-2.1.115
 **
 ** This file is subject to the terms and conditions of the GNU General Public
 ** License. See the file README.legal in the main directory of this archive
 ** for more details.
 **
@@ -244,28 +246,38 @@
  * FONT_8x8:
  * FONT_8x16:
  *		In theory these could be determined at run time or handed
  *		over by the booter.  But, let's be real, it's a fine hard
  *		coded value.  (But, you will notice the code is run-time
- *		flexible!)
+ *		flexible!)  A pointer to the font's struct fbcon_font_desc
+ *		is kept locally in Lconsole_font.  It is used to determine
+ *		font size information dynamically.
  */
 
 #include <linux/config.h>
 #include <linux/linkage.h>
 #include <asm/bootinfo.h>
 #include <asm/setup.h>
 #include <asm/pgtable.h>
+#include "../../../drivers/video/font.h"	/* offsets for struct fbcon_font_desc */
 
 #if defined(CONFIG_MAC)
 #define CONSOLE
 #endif
 #undef MMU_PRINT
 #undef MMU_NOCACHE_KERNEL
 #define SERIAL_DEBUG
 #undef DEBUG
 #undef MMU_PRINT_PAGE_USAGE
-#undef FONT_6x11
+
+/*
+ * For the head.S console, there are three supported fonts, 6x11, 8x16 and 8x8.
+ * The 8x8 font is harder to read but fits more on the screen.
+ */
+#define FONT_8x8 	/* default */
+/* #define FONT_8x16	/* 2nd choice */
+/* #define FONT_6x11	/* 3rd choice */
 	
 .globl SYMBOL_NAME(kernel_pg_dir)
 .globl SYMBOL_NAME(kpt)
 .globl SYMBOL_NAME(availmem)
 .globl SYMBOL_NAME(mvme_bdid_ptr)
@@ -3015,20 +3027,10 @@
 #define Lconsole_struct_num_columns	8
 #define Lconsole_struct_num_rows	12
 #define Lconsole_struct_left_edge	16
 #define Lconsole_struct_penguin_putc	20
 
-/*
- * For the head.S console, there are two supported Font heights, 8 and 16.
- * 8 is harder to read but fits more on the screen.
- * Following are the offsets into a structure that allows for dynamic resizing of the font
- * at run time.  Actually not resizing but the fonts are sized at init.
- */
-#define FONTWIDTH	0
-#define FONTHEIGHT	4
-
-
 Lconsole_init:
 	/*
  	 *	Some of the register usage that follows
 	 *		a0 = pointer to boot_info
 	 *		a1 = pointer to screen
@@ -3064,38 +3066,40 @@
 	movel	#0xffffffff,%a1@+	/* Mac_black */
 	movel	#0xffffffff,%a1@+	/* Mac_black */
 	dbra	%d6,console_clear_loop
 
 	/* Calculate font size */
-#if defined(FONT_6x11)
-	moveql	#6,%d0
-#else
-	moveql	#8,%d0			/* Default is 8x8 */
-#endif
-	lea	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)),%a0
-	movel	%d0,%a0@(FONTWIDTH)
-#if defined(FONT_8x16)
-	addql	#8,%d0
+
+#if   defined(FONT_8x8)
+	lea	%pc@(SYMBOL_NAME(font_vga_8x8)), %a0
+#elif defined(FONT_8x16)
+	lea	%pc@(SYMBOL_NAME(font_vga_8x16)),%a0
 #elif defined(FONT_6x11)
-	addql	#5,%d0
-#else
-	/* Don't have to do anything, %d0 == 8 */
+	lea	%pc@(SYMBOL_NAME(font_vga_6x11)),%a0
+#else	/*   (FONT_8x8) default */
+	lea	%pc@(SYMBOL_NAME(font_vga_8x8)), %a0
 #endif
-	movel	%d0,%a0@(FONTHEIGHT)
-	
+
+	/*
+	 *	At this point we make a shift in register usage
+	 *	a1 = address of Lconsole_font pointer
+	 */
+	lea	%pc@(SYMBOL_NAME(Lconsole_font)),%a1
+	movel	%a0,%a1@	/* store pointer to struct fbcon_font_desc in Lconsole_font */
+
 	/*
 	 *	Calculate global maxs
 	 *	Note - we can use either an 
 	 *	8 x 16 or 8 x 8 character font
 	 *	6 x 11 also supported
 	 */
-	lea	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)),%a0
+		/* ASSERT: a0 = contents of Lconsole_font */
 	movel	%d3,%d0			/* screen width in pixels */
-	divul	%a0@(FONTWIDTH),%d0		/* d0 = max num chars per row */
+	divul	%a0@(FBCON_FONT_DESC_width),%d0		/* d0 = max num chars per row */
 
 	movel	%d4,%d1			 /* screen height in pixels */
-	divul	%a0@(FONTHEIGHT),%d1	 /* d1 = max num rows */
+	divul	%a0@(FBCON_FONT_DESC_height),%d1	 /* d1 = max num rows */
 
 	movel	%d0,%a2@(Lconsole_struct_num_columns)
 	movel	%d1,%a2@(Lconsole_struct_num_rows)
 
 	/*
@@ -3209,11 +3213,12 @@
 	lea	%pc@(SYMBOL_NAME(mac_videobase)),%a0
 	movel	%a0@,%a1
 	movel	%a1,%a2
 	lea	%pc@(SYMBOL_NAME(mac_rowbytes)),%a0
 	movel	%a0@,%d5
-	mulul	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)+FONTHEIGHT),%d5 /* account for # scan lines per character */
+	movel	%pc@(SYMBOL_NAME(Lconsole_font)),%a0
+	mulul	%a0@(FBCON_FONT_DESC_height),%d5	/* account for # scan lines per character */
 	addal	%d5,%a2
 
 	/*
 	 * Get dimensions
 	 */
@@ -3227,11 +3232,12 @@
 	/*
 	 * Calculate number of bytes to move
 	 */
 	lea	%pc@(SYMBOL_NAME(mac_rowbytes)),%a0
 	movel	%a0@,%d6
-	subl	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)+FONTHEIGHT),%d4 /* we're not scrolling the top row! */
+	movel	%pc@(SYMBOL_NAME(Lconsole_font)),%a0
+	subl	%a0@(FBCON_FONT_DESC_height),%d4	/* we're not scrolling the top row! */
 	mulul	%d4,%d6		/* scan line bytes x num scan lines */
 	divul	#32,%d6		/* we'll move 8 longs at a time */
 	subq	#1,%d6
 	
 console_scroll_loop:
@@ -3245,11 +3251,12 @@
 	movel	%a2@+,%a1@+
 	dbra	%d6,console_scroll_loop
 
 	lea	%pc@(SYMBOL_NAME(mac_rowbytes)),%a0
 	movel	%a0@,%d6
-	mulul	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)+FONTHEIGHT),%d6	/* scan line bytes x font height */
+	movel	%pc@(SYMBOL_NAME(Lconsole_font)),%a0
+	mulul	%a0@(FBCON_FONT_DESC_height),%d6	/* scan line bytes x font height */
 	divul	#32,%d6			/* we'll move 8 words at a time */
 	subq	#1,%d6
 
 	moveq	#-1,%d0
 console_scroll_clear_loop:
@@ -3322,29 +3329,19 @@
 	putr()		/* recursion is OK! */
 	movel	%sp@+,%d7
 1:	
 	movel	%a0@(Lconsole_struct_cur_row),%d1
 	
-	movel	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)+FONTHEIGHT),%d2
-	cmpil	#16,%d2
-	beq	console_8x16
-	cmpil	#11,%d2
-	beq	console_6x11
-console_8x8:
-	lea	%pc@(SYMBOL_NAME(fontdata_8x8)),%a1
-	jbra	console_got_fontaddr
-	
-console_8x16:
-	lea	%pc@(SYMBOL_NAME(fontdata_8x16)),%a1
-	jbra	console_got_fontaddr
-
-console_6x11:
-	lea	%pc@(SYMBOL_NAME(fontdata_6x11)),%a1
-	
-console_got_fontaddr:
+	/*
+	 *	At this point we make a shift in register usage
+ 	 *	a0 = address of pointer to font data (fbcon_font_desc)
+	 */
+	movel	%pc@(SYMBOL_NAME(Lconsole_font)),%a0
+	movel	%a0@(FBCON_FONT_DESC_data),%a1	/* Load fbcon_font_desc.data into a1 */
 	andl	#0x000000ff,%d7
-	mulul	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)+FONTHEIGHT),%d7	/* d7 = index into font data */
+		/* ASSERT: a0 = contents of Lconsole_font */
+	mulul	%a0@(FBCON_FONT_DESC_height),%d7	/* d7 = index into font data */
 	addl	%d7,%a1			/* a1 = points to char image */
 	
 	/*
 	 *	At this point we make a shift in register usage
 	 *	d0 = pixel coordinate, x
@@ -3352,28 +3349,31 @@
 	 *	d2 = (bit 0) 1/0 for white/black (!) pixel on screen
 	 *	d3 = font scan line data (8 pixels)
 	 *	d6 = count down for the font's pixel width (8)
 	 *	d7 = count down for the font's pixel count in height
 	 */
-	mulul	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)+FONTWIDTH),%d0
-	mulul	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)+FONTHEIGHT),%d1
-	movel	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)+FONTHEIGHT),%d7
+		/* ASSERT: a0 = contents of Lconsole_font */
+	mulul	%a0@(FBCON_FONT_DESC_width),%d0
+	mulul	%a0@(FBCON_FONT_DESC_height),%d1
+	movel	%a0@(FBCON_FONT_DESC_height),%d7	/* Load fbcon_font_desc.height into d7 */
 	subq	#1,%d7
 console_read_char_scanline:
 	moveb	%a1@+,%d3
 
-	movel	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)+FONTWIDTH),%d6
+		/* ASSERT: a0 = contents of Lconsole_font */
+	movel	%a0@(FBCON_FONT_DESC_width),%d6	/* Load fbcon_font_desc.width into d6 */
 	subql	#1,%d6
 
 console_do_font_scanline:
 	lslb	#1,%d3
 	scsb	%d2		/* convert 1 bit into a byte */
 	jbsr	console_plot_pixel
 	addq	#1,%d0
 	dbra	%d6,console_do_font_scanline
 	
-	subl	%pc@(SYMBOL_NAME(Lconsole_font_dimensions)+FONTWIDTH),%d0
+		/* ASSERT: a0 = contents of Lconsole_font */
+	subl	%a0@(FBCON_FONT_DESC_width),%d0
 	addq	#1,%d1
 	dbra	%d7,console_read_char_scanline
 	
 console_exit:		
 	moveml	%sp@+,%a0/%a1/%d0-%d7
@@ -3564,13 +3564,12 @@
 	.long	0		/* cursor row */
 	.long	0		/* max num columns */
 	.long	0		/* max num rows */
 	.long	0		/* left edge */
 	.long	0		/* mac putc */
-Lconsole_font_dimensions:
-	.long	0		/* FONTWIDTH */
-	.long	0		/* FONTHEIGHT */
+Lconsole_font:
+	.long	0		/* pointer to console font (struct fbcon_font_desc) */
 #endif /* CONSOLE */
 
 #if defined(MMU_PRINT)
 Lmmu_print_data:
 	.long	0		/* valid flag */


