Leave per-device work in init_video() for the moment.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc32/openbios.c | 3 +- openbios-devel/arch/x86/openbios.c | 8 ++- openbios-devel/config/scripts/switch-arch | 4 ++ openbios-devel/drivers/vga_vbe.c | 62 ++++++------------- openbios-devel/forth/device/display.fs | 2 +- openbios-devel/include/arch/sparc32/io.h | 7 +++ openbios-devel/include/libopenbios/video.h | 23 ++++++- openbios-devel/libopenbios/video_common.c | 89 +++++++++++++++++----------- 8 files changed, 114 insertions(+), 84 deletions(-)
diff --git a/openbios-devel/arch/sparc32/openbios.c b/openbios-devel/arch/sparc32/openbios.c index ef3c973..84dd3f6 100644 --- a/openbios-devel/arch/sparc32/openbios.c +++ b/openbios-devel/arch/sparc32/openbios.c @@ -875,7 +875,8 @@ arch_init( void ) #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 diff --git a/openbios-devel/arch/x86/openbios.c b/openbios-devel/arch/x86/openbios.c index dd444fa..4c18952 100644 --- a/openbios-devel/arch/x86/openbios.c +++ b/openbios-devel/arch/x86/openbios.c @@ -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 @@ arch_init( void ) 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(); diff --git a/openbios-devel/config/scripts/switch-arch b/openbios-devel/config/scripts/switch-arch index f92d730..dccf5c0 100755 --- a/openbios-devel/config/scripts/switch-arch +++ b/openbios-devel/config/scripts/switch-arch @@ -198,6 +198,10 @@ for ARCH in $arch_list; do xbox-x86) xbox="yes" ;; + builtin-sparc32) + builtin="yes" + qemu="yes" + ;; builtin-sparc64) builtin="yes" qemu="yes" diff --git a/openbios-devel/drivers/vga_vbe.c b/openbios-devel/drivers/vga_vbe.c index f7a736f..884c261 100644 --- a/openbios-devel/drivers/vga_vbe.c +++ b/openbios-devel/drivers/vga_vbe.c @@ -103,50 +103,24 @@ void vga_vbe_set_mode(int width, int height, int depth) 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 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, 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 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, 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 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, } }
- init_video(fb, width, height, depth, linebytes); + init_video(); } diff --git a/openbios-devel/forth/device/display.fs b/openbios-devel/forth/device/display.fs index 85a0001..cf709fa 100644 --- a/openbios-devel/forth/device/display.fs +++ b/openbios-devel/forth/device/display.fs @@ -72,7 +72,7 @@ defer draw-logo ( line# addr width height -- )
defer fb-emit ( x -- )
-: depth-bytes ( bits -- bytes ) +: depth-bytes ( -- bytes ) depth-bits 1+ 8 / ;
diff --git a/openbios-devel/include/arch/sparc32/io.h b/openbios-devel/include/arch/sparc32/io.h index 2241bb4..011770a 100644 --- a/openbios-devel/include/arch/sparc32/io.h +++ b/openbios-devel/include/arch/sparc32/io.h @@ -191,4 +191,11 @@ extern void outl(u32 reg, u32 val); 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 */ diff --git a/openbios-devel/include/libopenbios/video.h b/openbios-devel/include/libopenbios/video.h index 8f322bd..20ba6c8 100644 --- a/openbios-devel/include/libopenbios/video.h +++ b/openbios-devel/include/libopenbios/video.h @@ -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); diff --git a/openbios-devel/libopenbios/video_common.c b/openbios-devel/libopenbios/video_common.c index 0f733ad..64e43cc 100644 --- a/openbios-devel/libopenbios/video_common.c +++ b/openbios-devel/libopenbios/video_common.c @@ -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 @@ video_fill_rect(void) } }
-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 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) 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 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) 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;