Now that we have OFMEM, as long as we have a PCI bus then we can configure the address of the framebuffer automatically without having an architecture-specific hack. The only thing we need to do is override the virtual address from the OFMEM phys == virt default.
Similarly we can remove all reference to the video memory variables _vmem and _evmem since the memory is allocated outside of the OpenBIOS image.
This commit also fixes another couple of issues: switch video.c to use virtual instead of physical addresses for architectures that require it (the default is the existing behaviour where phys_addr == virt_addr) and also correct the framebuffer size calculation which was also adding the framebuffer start address to size of the framebuffer to be mapped.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc64/ldscript | 6 ----- openbios-devel/drivers/vga_vbe.c | 9 +------ openbios-devel/include/arch/sparc64/io.h | 2 +- openbios-devel/packages/video.c | 36 +++++++++++++++++------------ 4 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/openbios-devel/arch/sparc64/ldscript b/openbios-devel/arch/sparc64/ldscript index 11167c0..ace00e5 100644 --- a/openbios-devel/arch/sparc64/ldscript +++ b/openbios-devel/arch/sparc64/ldscript @@ -12,7 +12,6 @@ BASE_ADDR = 0x00000000ffd00000;
/* 16KB stack */ STACK_SIZE = 16384; -VMEM_SIZE = 128 * 1024; IOMEM_SIZE = 256 * 1024 + 768 * 1024;
SECTIONS @@ -51,11 +50,6 @@ SECTIONS *(.bss.*) *(COMMON)
- . = ALIGN(4096); - _vmem = .; - . += VMEM_SIZE; - _evmem = .; - _stack = .; . += STACK_SIZE; . = ALIGN(16); diff --git a/openbios-devel/drivers/vga_vbe.c b/openbios-devel/drivers/vga_vbe.c index 2c229b4..569e70d 100644 --- a/openbios-devel/drivers/vga_vbe.c +++ b/openbios-devel/drivers/vga_vbe.c @@ -133,7 +133,7 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, int depth = VGA_DEFAULT_DEPTH; int linebytes = VGA_DEFAULT_LINEBYTES;
-#if defined(CONFIG_QEMU) && (defined(CONFIG_PPC) || defined(CONFIG_SPARC64)) +#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); @@ -144,13 +144,6 @@ void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, depth = d; linebytes = (width * ((depth + 7) / 8)); } -#ifdef CONFIG_SPARC64 -#define VGA_VADDR 0xfe000000 - ofmem_claim_phys(fb, fb_size, 0); - ofmem_claim_virt(VGA_VADDR, fb_size, 0); - ofmem_map(fb, VGA_VADDR, fb_size, 0x76); - fb = VGA_VADDR; -#endif #endif
vga_vbe_set_mode(width, height, depth); diff --git a/openbios-devel/include/arch/sparc64/io.h b/openbios-devel/include/arch/sparc64/io.h index 68d6121..2e4dfa3 100644 --- a/openbios-devel/include/arch/sparc64/io.h +++ b/openbios-devel/include/arch/sparc64/io.h @@ -9,7 +9,7 @@
extern unsigned long va_shift; // Set in entry.S // Defined in ldscript -extern char _start, _data, _stack, _estack, _end, _vmem, _evmem, _iomem; +extern char _start, _data, _stack, _estack, _end, _iomem;
// XXX check use and merge #define phys_to_virt(phys) ((void *) ((unsigned long) (phys))) diff --git a/openbios-devel/packages/video.c b/openbios-devel/packages/video.c index 9eddd0f..5a2bf18 100644 --- a/openbios-devel/packages/video.c +++ b/openbios-devel/packages/video.c @@ -25,6 +25,7 @@
typedef struct osi_fb_info { unsigned long mphys; + unsigned long mvirt; int rb, w, h, depth; } osi_fb_info_t;
@@ -79,7 +80,7 @@ startup_splash( void ) dx = (video.fb.w - width)/2; dy = (video.fb.h - height)/3;
- pp = (char*)video.fb.mphys + dy * video.fb.rb + dx * (video.fb.depth >= 24 ? 4 : 2); + pp = (char*)video.fb.mvirt + dy * video.fb.rb + dx * (video.fb.depth >= 24 ? 4 : 2);
for( y=0 ; y<height; y++, pp += video.fb.rb ) { if( video.fb.depth >= 24 ) { @@ -121,7 +122,7 @@ get_color( int col_ind ) void draw_pixel( int x, int y, int colind ) { - char *p = (char*)video.fb.mphys + video.fb.rb * y; + char *p = (char*)video.fb.mvirt + video.fb.rb * y; int color, d = video.fb.depth;
if( x < 0 || y < 0 || x >= video.fb.w || y >=video.fb.h ) @@ -146,7 +147,7 @@ fill_rect( int col_ind, int x, int y, int w, int h ) x + w > video.fb.w || y + h > video.fb.h) return;
- pp = (char*)video.fb.mphys + video.fb.rb * y; + pp = (char*)video.fb.mvirt + video.fb.rb * y; for( ; h--; pp += video.fb.rb ) { int ww = w; if( video.fb.depth == 24 || video.fb.depth == 32 ) { @@ -209,8 +210,8 @@ video_scroll( int height ) } offs = video.fb.rb * height; size = (video.fb.h * video.fb.rb - offs)/16; - dest = (int*)video.fb.mphys; - src = (int*)(video.fb.mphys + offs); + dest = (int*)video.fb.mvirt; + src = (int*)(video.fb.mvirt + offs);
for( i=0; i<size; i++ ) { dest[0] = src[0]; @@ -309,15 +310,21 @@ NODE_METHODS( video ) = { /************************************************************************/
void -init_video( unsigned long fb, int width, int height, int depth, int rb ) +init_video( unsigned long fb, int width, int height, int depth, int rb ) { int i; -#ifdef CONFIG_PPC - int s, size; +#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) + int size; #endif phandle_t ph=0;
- video.fb.mphys = fb; + video.fb.mphys = video.fb.mvirt = fb; + +#if defined(CONFIG_SPARC64) + /* Fix virtual address on SPARC64 somewhere else */ + video.fb.mvirt = 0xfe000000; +#endif + video.fb.w = width; video.fb.h = height; video.fb.depth = depth; @@ -327,18 +334,17 @@ init_video( unsigned long fb, int width, int height, int depth, int rb ) set_int_property( ph, "height", video.fb.h ); set_int_property( ph, "depth", video.fb.depth ); set_int_property( ph, "linebytes", video.fb.rb ); - set_int_property( ph, "address", video.fb.mphys ); + set_int_property( ph, "address", video.fb.mvirt ); } video.has_video = 1; video.pal = malloc( 256 * sizeof(unsigned long) );
-#ifdef CONFIG_PPC - s = (video.fb.mphys & 0xfff); - size = ((video.fb.h * video.fb.rb + s) + 0xfff) & ~0xfff; +#if defined(CONFIG_OFMEM) && defined(CONFIG_DRIVER_PCI) + size = ((video.fb.h * video.fb.rb) + 0xfff) & ~0xfff;
ofmem_claim_phys( video.fb.mphys, size, 0 ); - ofmem_claim_virt( video.fb.mphys, size, 0 ); - ofmem_map( video.fb.mphys, video.fb.mphys, size, -1 ); + ofmem_claim_virt( video.fb.mvirt, size, 0 ); + ofmem_map( video.fb.mphys, video.fb.mvirt, size, ofmem_arch_io_translation_mode(video.fb.mphys) ); #endif
for( i=0; i<256; i++ )