[OpenBIOS] [commit] r1182 - in trunk/openbios-devel: arch/sparc32 arch/x86 config/scripts drivers forth/device include/arch/sparc32 include/libopenbios libopenbios

repository service svn at openbios.org
Sat Jul 27 12:14:45 CEST 2013


Author: mcayland
Date: Sat Jul 27 12:14:44 2013
New Revision: 1182
URL: http://tracker.coreboot.org/trac/openbios/changeset/1182

Log:
video_common.c: split video setup routines into setup_video()

Leave per-device work in init_video() for the moment.

As part of this commit we fix up switch-arch so that CONFIG_QEMU works for
SPARC32 - if we are given the framebuffer information via the QEMU firmware
interface we use it. Otherwise fall back to the values of the VGA_DEFAULT_*
constants.

This commit requires a corresponding patch for QEMU as currently the
framebuffer width/height are not passed via the firmware interface for
SPARC32.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>

Modified:
   trunk/openbios-devel/arch/sparc32/openbios.c
   trunk/openbios-devel/arch/x86/openbios.c
   trunk/openbios-devel/config/scripts/switch-arch
   trunk/openbios-devel/drivers/vga_vbe.c
   trunk/openbios-devel/forth/device/display.fs
   trunk/openbios-devel/include/arch/sparc32/io.h
   trunk/openbios-devel/include/libopenbios/video.h
   trunk/openbios-devel/libopenbios/video_common.c

Modified: trunk/openbios-devel/arch/sparc32/openbios.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/openbios.c	Sat Jul 27 12:14:41 2013	(r1181)
+++ trunk/openbios-devel/arch/sparc32/openbios.c	Sat Jul 27 12:14:44 2013	(r1182)
@@ -875,7 +875,8 @@
 #endif
 #ifdef CONFIG_DRIVER_SBUS
 #ifdef CONFIG_DEBUG_CONSOLE_VIDEO
-	init_video((unsigned long)vmem, 1024, 768, 8, 1024);
+	setup_video(hwdef->tcx_base + 0x00800000ULL, (unsigned long)vmem);
+	init_video();
 #endif
 	ob_sbus_init(hwdef->iommu_base + 0x1000ULL, qemu_machine_type);
 #endif

Modified: trunk/openbios-devel/arch/x86/openbios.c
==============================================================================
--- trunk/openbios-devel/arch/x86/openbios.c	Sat Jul 27 12:14:41 2013	(r1181)
+++ trunk/openbios-devel/arch/x86/openbios.c	Sat Jul 27 12:14:44 2013	(r1182)
@@ -16,6 +16,7 @@
 #include "drivers/drivers.h"
 #include "drivers/pci.h"
 #include "libopenbios/sys_info.h"
+#include "libopenbios/video.h"
 #include "openbios.h"
 #include "relocate.h"
 #include "boot.h"
@@ -61,7 +62,12 @@
 	ob_floppy_init("/isa", "floppy0", 0x3f0, 0);
 #endif
 #ifdef CONFIG_XBOX
-	init_video(phys_to_virt(0x3C00000), 640, 480, 32, 2560);
+	setup_video(0x3C00000, phys_to_virt(0x3C00000));
+
+	/* Force video to 32-bit depth */
+	VIDEO_DICT_VALUE(video.depth) = 32;
+
+	init_video();
 	node_methods_init();
 #endif
 	device_end();

Modified: trunk/openbios-devel/config/scripts/switch-arch
==============================================================================
--- trunk/openbios-devel/config/scripts/switch-arch	Sat Jul 27 12:14:41 2013	(r1181)
+++ trunk/openbios-devel/config/scripts/switch-arch	Sat Jul 27 12:14:44 2013	(r1182)
@@ -198,6 +198,10 @@
             xbox-x86)
             xbox="yes"
             ;;
+            builtin-sparc32)
+            builtin="yes"
+            qemu="yes"
+            ;;
             builtin-sparc64)
             builtin="yes"
             qemu="yes"

Modified: trunk/openbios-devel/drivers/vga_vbe.c
==============================================================================
--- trunk/openbios-devel/drivers/vga_vbe.c	Sat Jul 27 12:14:41 2013	(r1181)
+++ trunk/openbios-devel/drivers/vga_vbe.c	Sat Jul 27 12:14:44 2013	(r1182)
@@ -103,50 +103,24 @@
         vga_build_rgb_palette();
 }
 
-#ifdef CONFIG_VGA_WIDTH
-#define VGA_DEFAULT_WIDTH	CONFIG_VGA_WIDTH
-#else
-#define VGA_DEFAULT_WIDTH	800
-#endif
-
-#ifdef CONFIG_VGA_HEIGHT
-#define VGA_DEFAULT_HEIGHT	CONFIG_VGA_HEIGHT
-#else
-#define VGA_DEFAULT_HEIGHT	600
-#endif
-
-#ifdef CONFIG_VGA_DEPTH
-#define VGA_DEFAULT_DEPTH	CONFIG_VGA_DEPTH
-#else
-#define VGA_DEFAULT_DEPTH	8
-#endif
-
-#define VGA_DEFAULT_LINEBYTES	(VGA_DEFAULT_WIDTH*((VGA_DEFAULT_DEPTH+7)/8))
-
 void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size,
                   unsigned long rom, uint32_t rom_size)
 {
+	phys_addr_t phys;
 	phandle_t ph, chosen, aliases, options;
 	char buf[6];
-	int width = VGA_DEFAULT_WIDTH;
-	int height = VGA_DEFAULT_HEIGHT;
-	int depth = VGA_DEFAULT_DEPTH;
-	int linebytes = VGA_DEFAULT_LINEBYTES;
-
-#if defined(CONFIG_QEMU) && (defined(CONFIG_PPC) || defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64))
-	int w, h, d;
-        w = fw_cfg_read_i16(FW_CFG_ARCH_WIDTH);
-        h = fw_cfg_read_i16(FW_CFG_ARCH_HEIGHT);
-        d = fw_cfg_read_i16(FW_CFG_ARCH_DEPTH);
-	if (w && h && d) {
-		width = w;
-		height = h;
-		depth = d;
-		linebytes = (width * ((depth + 7) / 8));
-	}
+
+	phys = fb;
+
+#if defined(CONFIG_SPARC64)
+	/* Fix virtual address on SPARC64 somewhere else */
+	fb = 0xfe000000ULL;
 #endif
 
-	vga_vbe_set_mode(width, height, depth);
+	setup_video(phys, fb);
+	vga_vbe_set_mode(VIDEO_DICT_VALUE(video.w),
+			 VIDEO_DICT_VALUE(video.h),
+			 VIDEO_DICT_VALUE(video.depth));
 
 #if 0
     ph = find_dev(path);
@@ -154,10 +128,10 @@
     ph = get_cur_dev();
 #endif
 
-	set_int_property(ph, "width", width);
-	set_int_property(ph, "height", height);
-	set_int_property(ph, "depth", depth);
-	set_int_property(ph, "linebytes", linebytes);
+	set_int_property(ph, "width", VIDEO_DICT_VALUE(video.w));
+	set_int_property(ph, "height", VIDEO_DICT_VALUE(video.h));
+	set_int_property(ph, "depth", VIDEO_DICT_VALUE(video.depth));
+	set_int_property(ph, "linebytes", VIDEO_DICT_VALUE(video.rb));
 	set_int_property(ph, "address", (u32)(fb & ~0x0000000F));
 
 	chosen = find_dev("/chosen");
@@ -169,9 +143,9 @@
 	set_property(aliases, "screen", path, strlen(path) + 1);
 
 	options = find_dev("/options");
-	snprintf(buf, sizeof(buf), "%d", width / FONT_WIDTH);
+	snprintf(buf, sizeof(buf), FMT_ucell, VIDEO_DICT_VALUE(video.w) / FONT_WIDTH);
 	set_property(options, "screen-#columns", buf, strlen(buf) + 1);
-	snprintf(buf, sizeof(buf), "%d", height / FONT_HEIGHT);
+	snprintf(buf, sizeof(buf), FMT_ucell, VIDEO_DICT_VALUE(video.h) / FONT_HEIGHT);
 	set_property(options, "screen-#rows", buf, strlen(buf) + 1);
 
 	if (rom_size >= 8) {
@@ -186,5 +160,5 @@
 		}
 	}
 
-	init_video(fb, width, height, depth, linebytes);
+	init_video();
 }

Modified: trunk/openbios-devel/forth/device/display.fs
==============================================================================
--- trunk/openbios-devel/forth/device/display.fs	Sat Jul 27 12:14:41 2013	(r1181)
+++ trunk/openbios-devel/forth/device/display.fs	Sat Jul 27 12:14:44 2013	(r1182)
@@ -72,7 +72,7 @@
 
 defer fb-emit ( x -- )
 
-: depth-bytes ( bits -- bytes )
+: depth-bytes ( -- bytes )
   depth-bits 1+ 8 /
 ;
 

Modified: trunk/openbios-devel/include/arch/sparc32/io.h
==============================================================================
--- trunk/openbios-devel/include/arch/sparc32/io.h	Sat Jul 27 12:14:41 2013	(r1181)
+++ trunk/openbios-devel/include/arch/sparc32/io.h	Sat Jul 27 12:14:44 2013	(r1182)
@@ -191,4 +191,11 @@
 extern void outsw(u32 reg, const void *addr, unsigned long count);
 #endif
 #endif
+
+#if defined(CONFIG_QEMU)
+#define FW_CFG_ARCH_DEPTH        (FW_CFG_ARCH_LOCAL + 0x00)
+#define FW_CFG_ARCH_WIDTH        (FW_CFG_ARCH_LOCAL + 0x01)
+#define FW_CFG_ARCH_HEIGHT       (FW_CFG_ARCH_LOCAL + 0x02)
+#endif
+
 #endif /* _ASM_IO_H */

Modified: trunk/openbios-devel/include/libopenbios/video.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/video.h	Sat Jul 27 12:14:41 2013	(r1181)
+++ trunk/openbios-devel/include/libopenbios/video.h	Sat Jul 27 12:14:44 2013	(r1182)
@@ -1,5 +1,26 @@
 
-void init_video(unsigned long fb, int width, int height, int depth, int rb);
+#ifdef CONFIG_VGA_WIDTH
+#define VGA_DEFAULT_WIDTH	CONFIG_VGA_WIDTH
+#else
+#define VGA_DEFAULT_WIDTH	800
+#endif
+
+#ifdef CONFIG_VGA_HEIGHT
+#define VGA_DEFAULT_HEIGHT	CONFIG_VGA_HEIGHT
+#else
+#define VGA_DEFAULT_HEIGHT	600
+#endif
+
+#ifdef CONFIG_VGA_DEPTH
+#define VGA_DEFAULT_DEPTH	CONFIG_VGA_DEPTH
+#else
+#define VGA_DEFAULT_DEPTH	8
+#endif
+
+#define VGA_DEFAULT_LINEBYTES	(VGA_DEFAULT_WIDTH*((VGA_DEFAULT_DEPTH+7)/8))
+
+void setup_video(phys_addr_t phys, ucell virt);
+void init_video(void);
 unsigned long video_get_color(int col_ind);
 void video_set_color(int ind, unsigned long color);
 int video_get_res(int *w, int *h);

Modified: trunk/openbios-devel/libopenbios/video_common.c
==============================================================================
--- trunk/openbios-devel/libopenbios/video_common.c	Sat Jul 27 12:14:41 2013	(r1181)
+++ trunk/openbios-devel/libopenbios/video_common.c	Sat Jul 27 12:14:44 2013	(r1182)
@@ -22,6 +22,8 @@
 #include "libopenbios/video.h"
 #include "packages/video.h"
 #include "drivers/vga.h"
+#define NO_QEMU_PROTOS
+#include "arch/common/fw_cfg.h"
 
 struct video_info video;
 
@@ -221,21 +223,14 @@
 	}
 }
 
-void
-init_video( unsigned long fb, int width, int height, int depth, int rb )
+void setup_video(phys_addr_t phys, ucell virt)
 {
-        int i;
-#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI)
-        int size;
-#endif
-	phandle_t ph=0, saved_ph=0;
-
-	video.mphys = fb;
-
 	/* Make everything inside the video_info structure point to the
 	   values in the Forth dictionary. Hence everything is always in
 	   sync. */
 
+	video.mphys = phys;
+
 	feval("['] qemu-video-addr cell+");
 	video.mvirt = cell2pointer(POP());
 	feval("['] qemu-video-width cell+");
@@ -249,32 +244,6 @@
 	feval("['] color-palette cell+");
 	video.pal = cell2pointer(POP());
 
-	VIDEO_DICT_VALUE(video.mvirt) = (ucell)fb;
-	VIDEO_DICT_VALUE(video.w) = (ucell)width;
-	VIDEO_DICT_VALUE(video.h) = (ucell)height;
-	VIDEO_DICT_VALUE(video.depth) = (ucell)depth;
-	VIDEO_DICT_VALUE(video.rb) = (ucell)rb;
-
-#if defined(CONFIG_SPARC64)
-	/* Fix virtual address on SPARC64 somewhere else */
-	VIDEO_DICT_VALUE(video.mvirt) = 0xfe000000ULL;
-#endif
-
-	saved_ph = get_cur_dev();
-	while( (ph=dt_iterate_type(ph, "display")) ) {
-		set_int_property( ph, "width", VIDEO_DICT_VALUE(video.w) );
-		set_int_property( ph, "height", VIDEO_DICT_VALUE(video.h) );
-		set_int_property( ph, "depth", VIDEO_DICT_VALUE(video.depth) );
-		set_int_property( ph, "linebytes", VIDEO_DICT_VALUE(video.rb) );
-		set_int_property( ph, "address", VIDEO_DICT_VALUE(video.mvirt) );
-
-		activate_dev(ph);
-
-		molvideo_init();
-	}
-	video.has_video = 1;
-	activate_dev(saved_ph);
-
 	/* Set global variables ready for fb8-install */
 	PUSH( pointer2cell(video_mask_blit) );
 	fword("is-noname-cfunc");
@@ -294,6 +263,54 @@
 	PUSH(FONT_WIDTH);
 	feval("to (romfont-width)");
 
+	/* Initialise the structure */
+	VIDEO_DICT_VALUE(video.mvirt) = virt;
+	VIDEO_DICT_VALUE(video.w) = VGA_DEFAULT_WIDTH;
+	VIDEO_DICT_VALUE(video.h) = VGA_DEFAULT_HEIGHT;
+	VIDEO_DICT_VALUE(video.depth) = VGA_DEFAULT_DEPTH;
+	VIDEO_DICT_VALUE(video.rb) = VGA_DEFAULT_LINEBYTES;
+
+#if defined(CONFIG_QEMU) && (defined(CONFIG_PPC) || defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64))
+	/* If running from QEMU, grab the parameters from the firmware interface */
+	int w, h, d;
+
+	w = fw_cfg_read_i16(FW_CFG_ARCH_WIDTH);
+        h = fw_cfg_read_i16(FW_CFG_ARCH_HEIGHT);
+        d = fw_cfg_read_i16(FW_CFG_ARCH_DEPTH);
+	if (w && h && d) {
+		VIDEO_DICT_VALUE(video.w) = w;
+		VIDEO_DICT_VALUE(video.h) = h;
+		VIDEO_DICT_VALUE(video.depth) = d;
+		VIDEO_DICT_VALUE(video.rb) = (w * ((d + 7) / 8));
+	}
+#endif
+}
+
+void
+init_video(void)
+{
+        int i;
+#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI)
+        int size;
+#endif
+	phandle_t ph=0, saved_ph=0;
+
+	saved_ph = get_cur_dev();
+	while( (ph=dt_iterate_type(ph, "display")) ) {
+		video.has_video = 1;
+
+		set_int_property( ph, "width", VIDEO_DICT_VALUE(video.w) );
+		set_int_property( ph, "height", VIDEO_DICT_VALUE(video.h) );
+		set_int_property( ph, "depth", VIDEO_DICT_VALUE(video.depth) );
+		set_int_property( ph, "linebytes", VIDEO_DICT_VALUE(video.rb) );
+		set_int_property( ph, "address", VIDEO_DICT_VALUE(video.mvirt) );
+
+		activate_dev(ph);
+
+		molvideo_init();
+	}
+	activate_dev(saved_ph);
+
 #if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI)
         size = ((VIDEO_DICT_VALUE(video.h) * VIDEO_DICT_VALUE(video.rb))  + 0xfff) & ~0xfff;
 



More information about the OpenBIOS mailing list