xen: ARM HDLCD video driver
v2 cover xen: ARM HDLCD video driver
Hi all,
this patch series introduces a very simple driver for the ARM HDLCD Controller, that means that we can finally have something on the screen while Xen is booting on ARM :)
The driver is capable of reading the mode property on device tree and setting the HDLCD accordingly. It is also capable of setting the required OSC5 timer to the right frequency for the pixel clock.
In order to reduce code duplication with x86, I tried to generalize the existing vesa character rendering functions into a architecture agnostic framebuffer driver that can be used by vesa and the hdlcd drivers.
I would very much appreciate if you could give a close look at the vesa changes because I don't have any x86 test machines that boot in vesa mode, therefore I couldn't test it.
Changes in v2:
- rebase on latest xen-unstable;
- add support for multiple resolutions;
- add support to dynamically change the OSC5 motherboard timer;
- add the patch "preserve DTB mappings".
Stefano Stabellini (8):
xen/arm: introduce early_ioremap
xen: infrastructure to have cross-platform video drivers
xen: introduce a generic framebuffer driver xen/vesa: use the new fb_* functions
xen/arm: preserve DTB mappings xen/device_tree: introduce find_compatible_node xen/arm: introduce vexpress_syscfg
xen/arm: introduce a driver for the ARM HDLCD controller
xen/arch/arm/Makefile | 1 + xen/arch/arm/Rules.mk | 2 + xen/arch/arm/kernel.h | 2 + xen/arch/arm/mm.c | 44 +++++ xen/arch/arm/platform_vexpress.c | 97 +++++++++++ xen/arch/arm/setup.c | 8 +- xen/arch/x86/Rules.mk | 1 + xen/common/device_tree.c | 51 ++++++ xen/drivers/Makefile | 2 +- xen/drivers/char/console.c | 12 +- xen/drivers/video/Makefile | 12 +- xen/drivers/video/arm_hdlcd.c | 282 +++++++++++++++++++++++++++++++ xen/drivers/video/fb.c | 209 +++++++++++++++++++++++ xen/drivers/video/fb.h | 49 ++++++ xen/drivers/video/modelines.h | 69 ++++++++ xen/drivers/video/vesa.c | 179 +++----------------- xen/drivers/video/vga.c | 12 +- xen/include/asm-arm/config.h | 4 + xen/include/asm-arm/mm.h | 5 +- xen/include/asm-arm/page.h | 23 +++ xen/include/asm-arm/platform_vexpress.h | 23 +++ xen/include/asm-x86/config.h | 1 + xen/include/xen/device_tree.h | 3 + xen/include/xen/vga.h | 9 +- xen/include/xen/video.h | 24 +++ 25 files changed, 940 insertions(+), 184 deletions(-)
Cheers,
Stefano
PATCH v2 1/8 xen/arm: introduce early_ioremap
Introduce a function to map a range of physical memory into Xen virtual memory.
It doesn't need domheap to be setup.
It is going to be used to map the videoram.
Add flush_xen_data_tlb_range, that flushes a range of virtual addresses.
--- xen/arch/arm/mm.c | 32 ++++++++++++++++++++++++++++++++ xen/include/asm-arm/config.h | 2 ++ xen/include/asm-arm/mm.h | 3 ++- xen/include/asm-arm/page.h | 23 +++++++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletions(-)
xen/arch/arm/mm.c +32 -0
@@ -367,6 +367,38 @@ void __init setup_frametable_mappings(paddr_t ps, paddr_t pe) frametable_virt_end =FRAMETABLE_VIRT_START + (nr_pages *sizeof (struct page_info )); } +/* Map the physical memory range start - start + len into virtual +* memory and return the virtual address of the mapping. +* start has to be 2MB aligned. +* len has to be < EARLY_VMAP_END - EARLY_VMAP_START. +*/ +void *early_ioremap (paddr_t start,size_t len,unsigned attributes) +{ +static unsigned long virt_start =EARLY_VMAP_START ; +void * ret_addr = (void *)virt_start; +paddr_t end = start + len; + +ASSERT (!(start & (~SECOND_MASK ))); +ASSERT (!(virt_start & (~SECOND_MASK ))); + +/* The range we need to map is too big */ +if ( virt_start + len >=EARLY_VMAP_END ) +return NULL ; + +while ( start < end ) + { +lpae_t e =mfn_to_xen_entry (start >>PAGE_SHIFT ); + e.pt.ai = attributes; +write_pte (xen_second +second_table_offset (virt_start), e); + + start +=SECOND_SIZE ; + virt_start +=SECOND_SIZE ; + } +flush_xen_data_tlb_range ((unsigned long ) ret_addr, len); + +return ret_addr; +} +enum mg { mg_clear, mg_ro, mg_rw, mg_rx };static void set_pte_flags_on_range (const char *p,unsigned long l,enum mg mg) {
xen/include/asm-arm/config.h +2 -0
@@ -73,9 +73,11 @@#define FIXMAP_ADDR (n) (mk_unsigned_long(0x00400000) + (n) * PAGE_SIZE)#define BOOT_MISC_VIRT_START mk_unsigned_long(0x00600000)#define FRAMETABLE_VIRT_START mk_unsigned_long(0x02000000) +#define EARLY_VMAP_START mk_unsigned_long(0x10000000)#define XENHEAP_VIRT_START mk_unsigned_long(0x40000000)#define DOMHEAP_VIRT_START mk_unsigned_long(0x80000000) +#define EARLY_VMAP_END XENHEAP_VIRT_START#define HYPERVISOR_VIRT_START XEN_VIRT_START#define DOMHEAP_ENTRIES 1024/* 1024 2MB mapping slots */
xen/include/asm-arm/mm.h +2 -1
@@ -150,7 +150,8 @@ extern void setup_frametable_mappings(paddr_t ps, paddr_t pe);extern void set_fixmap (unsigned map,unsigned long mfn,unsigned attributes);/* Remove a mapping from a fixmap entry */ extern void clear_fixmap (unsigned map); - +/* map a 2MB aligned physical range in virtual memory. */ +void *early_ioremap (paddr_t start,size_t len,unsigned attributes);#define mfn_valid (mfn) ({ \ unsigned long __m_f_n = (mfn); \
xen/include/asm-arm/page.h +23 -0
@@ -328,6 +328,23 @@ static inline void flush_xen_data_tlb_va(unsigned long va) : : "r" (va) : "memory"); } +/* +* Flush a range of VA's hypervisor mappings from the data TLB. This is not +* sufficient when changing code mappings or for self modifying code. +*/ +static inline void flush_xen_data_tlb_range (unsigned long va,unsigned long size) +{ +unsigned long end = va + size; +while ( va < end ) { + asmvolatile ("dsb;" /* Ensure preceding are visible */ + STORE_CP32(0, TLBIMVAH) + "dsb;" /* Ensure completion of the TLB flush */ + "isb;" + : : "r" (va) : "memory"); + va += PAGE_SIZE; + } +} +/* Flush all non-hypervisor mappings from the TLB */ static inline void flush_guest_tlb (void ) {
@@ -418,8 +435,14 @@ static inline uint64_t gva_to_ipa(uint32_t va)#define LPAE_ENTRY_MASK (LPAE_ENTRIES - 1)#define THIRD_SHIFT PAGE_SHIFT +#define THIRD_SIZE (1u << THIRD_SHIFT) +#define THIRD_MASK (~(THIRD_SIZE - 1))#define SECOND_SHIFT (THIRD_SHIFT + LPAE_SHIFT) +#define SECOND_SIZE (1u << SECOND_SHIFT) +#define SECOND_MASK (~(SECOND_SIZE - 1))#define FIRST_SHIFT (SECOND_SHIFT + LPAE_SHIFT) +#define FIRST_SIZE (1u << FIRST_SHIFT) +#define FIRST_MASK (~(FIRST_SIZE - 1))/* Calculate the offsets into the pagetables for a given VA */ #define first_linear_offset (va) (va >> FIRST_SHIFT)
Signature · 1 line
1.7.2.5
PATCH v2 2/8 xen: infrastructure to have cross-platform video drivers
In reply to Stefano Stabellini- introduce a new HAS_VIDEO config variable;
- build xen/drivers/video/font* if HAS_VIDEO;
- rename vga_puts to video_puts;
- rename vga_init to video_init;
- rename vga_endboot to video_endboot.
--- xen/arch/arm/Rules.mk | 1 + xen/arch/x86/Rules.mk | 1 + xen/drivers/Makefile | 2 +- xen/drivers/char/console.c | 12 ++++++------ xen/drivers/video/Makefile | 10 +++++----- xen/drivers/video/vesa.c | 4 ++-- xen/drivers/video/vga.c | 12 ++++++------ xen/include/asm-x86/config.h | 1 + xen/include/xen/vga.h | 9 +-------- xen/include/xen/video.h | 24 ++++++++++++++++++++++++ 10 files changed, 48 insertions(+), 28 deletions(-) create mode 100644 xen/include/xen/video.h
xen/arch/arm/Rules.mk +1 -0
@@ -7,6 +7,7 @@ # HAS_DEVICE_TREE := y +HAS_VIDEO := y CFLAGS += -fno-builtin -fno-common -Wredundant-decls CFLAGS += -iwithprefix include -Werror -Wno-pointer-arith -pipe
xen/arch/x86/Rules.mk +1 -0
@@ -3,6 +3,7 @@ HAS_ACPI := y HAS_VGA := y +HAS_VIDEO := y HAS_CPUFREQ := y HAS_PCI := y HAS_PASSTHROUGH := y
xen/drivers/Makefile +1 -1
@@ -3,4 +3,4 @@ subdir-$(HAS_CPUFREQ) += cpufreq subdir-$(HAS_PCI) += pci subdir-$(HAS_PASSTHROUGH) += passthrough subdir-$(HAS_ACPI) += acpi -subdir-$(HAS_VGA) += video +subdir-$(HAS_VIDEO) += video
xen/drivers/char/console.c +6 -6
@@ -21,7 +21,7 @@#include <xen/delay.h> #include <xen/guest_access.h> #include <xen/shutdown.h> -#include <xen/vga.h> +#include <xen/video.h> #include <xen/kexec.h> #include <asm/debugger.h> #include <asm/div64.h>
@@ -297,7 +297,7 @@ static void dump_console_ring_key(unsigned char key) buf[sofar] ='\0' ;sercon_puts (buf); -vga_puts (buf); +video_puts (buf);free_xenheap_pages (buf, order); }
@@ -383,7 +383,7 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, int count)spin_lock_irq (&console_lock);sercon_puts (kbuf); -vga_puts (kbuf); +video_puts (kbuf);if ( opt_console_to_ring ) {
@@ -464,7 +464,7 @@ static void __putstr(const char *str)ASSERT (spin_is_locked (&console_lock));sercon_puts (str); -vga_puts (str); +video_puts (str);if ( !console_locks_busted ) {
@@ -592,7 +592,7 @@ void __init console_init_preirq(void)if ( *p ==',' ) p++;if ( !strncmp (p,"vga" ,3 ) ) -vga_init (); +video_init ();else if ( !strncmp (p,"none" ,4 ) )continue ;else if ( (sh =serial_parse_handle (p)) >=0 )
@@ -694,7 +694,7 @@ void __init console_endboot(void)printk ("\n" ); } -vga_endboot (); +video_endboot ();/* * If user specifies so, we fool the switch routine to redirect input
xen/drivers/video/Makefile +5 -5
@@ -1,5 +1,5 @@ -obj-y := vga.o -obj-$(CONFIG_X86) += font_8x14.o -obj-$(CONFIG_X86) += font_8x16.o -obj-$(CONFIG_X86) += font_8x8.o -obj-$(CONFIG_X86) += vesa.o +obj-$(HAS_VGA) := vga.o +obj-$(HAS_VIDEO) += font_8x14.o +obj-$(HAS_VIDEO) += font_8x16.o +obj-$(HAS_VIDEO) += font_8x8.o +obj-$(HAS_VGA) += vesa.o
xen/drivers/video/vesa.c +2 -2
@@ -108,7 +108,7 @@ void __init vesa_init(void)memset (lfb,0 , vram_remap); - vga_puts = vesa_redraw_puts; + video_puts = vesa_redraw_puts; printk(XENLOG_INFO "vesafb: framebuffer at %#x, mapped to 0x%p, " "using %uk, total %uk\n",
@@ -193,7 +193,7 @@ void __init vesa_endboot(bool_t keep)if ( keep ) { xpos =0 ; - vga_puts = vesa_scroll_puts; + video_puts = vesa_scroll_puts; }else {
xen/drivers/video/vga.c +6 -6
@@ -21,7 +21,7 @@ static unsigned char *video;static void vga_text_puts (const char *s);static void vga_noop_puts (const char *s) {} -void (*vga_puts)(const char *) = vga_noop_puts; +void (*video_puts)(const char *) = vga_noop_puts;/* * 'vga=<mode-specifier>[,keep]' where <mode-specifier> is one of:
@@ -62,7 +62,7 @@ void vesa_endboot(bool_t keep);#define vesa_endboot (x) ((void)0)#endif -void __init vga_init (void ) +void __init video_init (void ) {char *p;
@@ -85,7 +85,7 @@ void __init vga_init(void) columns = vga_console_info.u.text_mode_3.columns; lines = vga_console_info.u.text_mode_3.rows;memset (video,0 , columns * lines *2 ); - vga_puts = vga_text_puts; + video_puts = vga_text_puts;break ;case XEN_VGATYPE_VESA_LFB :case XEN_VGATYPE_EFI_LFB :
@@ -97,16 +97,16 @@ void __init vga_init(void) } } -void __init vga_endboot (void ) +void __init video_endboot (void ) { -if ( vga_puts == vga_noop_puts ) +if ( video_puts == vga_noop_puts )return ;printk ("Xen is %s VGA console.\n" , vgacon_keep ?"keeping" :"relinquishing" );if ( !vgacon_keep ) - vga_puts = vga_noop_puts; + video_puts = vga_noop_puts;else {int bus, devfn;
xen/include/asm-x86/config.h +1 -0
@@ -38,6 +38,7 @@#define CONFIG_ACPI_CSTATE 1#define CONFIG_VGA 1 +#define CONFIG_VIDEO 1#define CONFIG_HOTPLUG 1#define CONFIG_HOTPLUG_CPU 1
xen/include/xen/vga.h +1 -8
@@ -9,17 +9,10 @@#ifndef _XEN_VGA_H#define _XEN_VGA_H -#include <public/xen.h> +#include <xen/video.h> #ifdef CONFIG_VGA extern struct xen_vga_console_info vga_console_info; -void vga_init (void ); -void vga_endboot (void ); -extern void (*vga_puts)(const char *); -#else -#define vga_init () ((void)0) -#define vga_endboot () ((void)0) -#define vga_puts (s) ((void)0)#endif #endif /* _XEN_VGA_H */
xen/include/xen/video.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* video.h +* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file COPYING in the main directory of this archive +* for more details. +*/ + +#ifndef _XEN_VIDEO_H +#define _XEN_VIDEO_H + +#include <public/xen.h> + +#ifdef CONFIG_VIDEO +void video_init (void ); +extern void (*video_puts)(const char *); +void video_endboot (void ); +#else +#define video_init () ((void)0) +#define video_puts (s) ((void)0) +#define video_endboot () ((void)0) +#endif + +#endif /* _XEN_VIDEO_H */
Signature · 1 line
1.7.2.5
PATCH v2 3/8 xen: introduce a generic framebuffer driver
In reply to Stefano StabelliniAbstract away from vesa.c the funcions to handle a linear framebuffer and print characters to it.
The corresponding functions are going to be removed from vesa.c in the next patch.
--- xen/drivers/video/Makefile | 1 + xen/drivers/video/fb.c | 209 ++++++++++++++++++++++++++++++++++++++++++++ xen/drivers/video/fb.h | 49 ++++++++++ 3 files changed, 259 insertions(+), 0 deletions(-) create mode 100644 xen/drivers/video/fb.c create mode 100644 xen/drivers/video/fb.h
xen/drivers/video/Makefile +1 -0
@@ -2,4 +2,5 @@ obj-$(HAS_VGA) := vga.o obj-$(HAS_VIDEO) += font_8x14.o obj-$(HAS_VIDEO) += font_8x16.o obj-$(HAS_VIDEO) += font_8x8.o +obj-$(HAS_VIDEO) += fb.o obj-$(HAS_VGA) += vesa.o
xen/drivers/video/fb.c new file +209 -0
209 lines not on this page · raw message
xen/drivers/video/fb.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
1.7.2.5
Re: [PATCH v2 3/8] xen: introduce a generic framebuffer driver
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 07.12.12 at 19:02, Stefano Stabellini <[email protected]>
Quoted 282 lines · wrote:
Abstract away from
vesa.cthe funcions to handle a linear framebuffer and print characters to it.
The corresponding functions are going to be removed fromvesa.cin the next patch.Signed-off-by Stefano Stabellini <[email protected]>--- xen/drivers/video/Makefile | 1 + xen/drivers/video/fb.c | 209 ++++++++++++++++++++++++++++++++++++++++++++ xen/drivers/video/fb.h | 49 ++++++++++ 3 files changed, 259 insertions(+), 0 deletions(-) create mode 100644 xen/drivers/video/fb.c create mode 100644 xen/drivers/video/fb.hxen/drivers/video/Makefile +1
-0@@ -2,4 +2,5 @@ obj-$(HAS_VGA) := vga.o obj-$(HAS_VIDEO) += font_8x14.o obj-$(HAS_VIDEO) += font_8x16.o obj-$(HAS_VIDEO) += font_8x8.o +obj-$(HAS_VIDEO) += fb.o obj-$(HAS_VGA) += vesa.oxen/drivers/video/fb.c new file +1
-0@@ -0,0 +1,209 @@ +/************************************************************************** ****
+ *fb.c
+ *
+ * linear frame buffer handling.
+ */xen/drivers/video/fb.c new file +78
-0+ +#include <xen/config.h> +#include <xen/kernel.h> +#include <xen/lib.h> +#include <xen/errno.h> +#include "fb.h" +#include "font.h" + +#define MAX_XRES 1900 +#define MAX_YRES 1200 +#define MAX_BPP 4 +#define MAX_FONT_W 8 +#define MAX_FONT_H 16 +static __initdata unsigned int line_len[MAX_XRES /MAX_FONT_W ]; +static __initdata unsigned char lbuf[MAX_XRES *MAX_BPP ]; +static __initdata unsigned char text_buf[(MAX_XRES / MAX_FONT_W) * \ + (MAX_YRES /MAX_FONT_H )]; + +struct fb_status { +struct fb_prop fbp; + +unsigned char *lbuf, *text_buf; +unsigned int *line_len; +unsigned int xpos, ypos; +}; +static struct fb_status fb; + +static void fb_show_line ( +const unsigned char *text_line, +unsigned char *video_line, +unsigned int nr_chars, +unsigned int nr_cells) +{ +unsigned int i, j, b, bpp, pixel; + + bpp = (fb.fbp.bits_per_pixel +7 ) >>3 ; + +for ( i =0 ; i < fb.fbp.font->height; i++ ) + { +unsigned char *ptr = fb.lbuf; + +for ( j =0 ; j < nr_chars; j++ ) + { +const unsigned char *bits = fb.fbp.font->data; + bits += ((text_line[j] * fb.fbp.font->height + i) * + ((fb.fbp.font->width +7 ) >>3 )); +for ( b = fb.fbp.font->width; b--; ) + { + pixel = (*bits & (1u <<b)) ? fb.fbp.pixel_on :0 ; +memcpy (ptr, &pixel, bpp); + ptr += bpp; + } + } + +memset (ptr,0 , (fb.fbp.width - nr_chars * fb.fbp.font->width) * bpp); +memcpy (video_line, fb.lbuf, nr_cells * fb.fbp.font->width * bpp); + video_line += fb.fbp.bytes_per_line; + } +} + +/* Fast mode which redraws all modified parts of a 2D text buffer. */ +void fb_redraw_puts (const char *s) +{ +unsigned int i, min_redraw_y = fb.ypos; +char c; + +/* Paste characters into text buffer. */ +while ( (c = *s++) !='\0' ) + { +if ( (c =='\n' ) || (fb.xpos >= fb.fbp.text_columns) ) + { +if ( ++fb.ypos >= fb.fbp.text_rows ) + { + min_redraw_y =0 ; + fb.ypos = fb.fbp.text_rows -1 ; +memmove (fb.text_buf, fb.text_buf + fb.fbp.text_columns, + fb.ypos * fb.fbp.text_columns); + memset(fb.text_buf + fb.ypos * fb.fbp.text_columns, 0,fb.xpos);
xen/drivers/video/fb.c new file +9
-0+ } + fb.xpos =0 ; + } + +if ( c !='\n' ) + fb.text_buf[fb.xpos++ + fb.ypos * fb.fbp.text_columns] = c; + } + +/* Render modified section of text buffer to VESA linear framebuffer. */
xen/drivers/video/fb.c new file +10
-0+ for ( i = min_redraw_y; i <= fb.ypos; i++ ) + { + const unsigned char *line = fb.text_buf + i * fb.fbp.text_columns; + unsigned int width; + + for ( width = fb.fbp.text_columns; width; --width ) + if ( line[width - 1] ) + break; + fb_show_line(line, + fb.fbp.lfb + i * fb.fbp.font->height *fb.fbp.bytes_per_line,
xen/drivers/video/fb.c new file +20
-0+ width, max(fb.line_len[i], width)); + fb.line_len[i] = width; + } + + fb.fbp.flush (); +} + +/* Slower line-based scroll mode which interacts better with dom0. */ +void fb_scroll_puts (const char *s) +{ +unsigned int i; +char c; + +while ( (c = *s++) !='\0' ) + { +if ( (c =='\n' ) || (fb.xpos >= fb.fbp.text_columns) ) + { +unsigned int bytes = (fb.fbp.width * + ((fb.fbp.bits_per_pixel +7 ) >>3 )); + unsigned char *src = fb.fbp.lfb + fb.fbp.font->height *fb.fbp.bytes_per_line;
xen/drivers/video/fb.c new file +14
-0+unsigned char *dst = fb.fbp.lfb; + +/* New line: scroll all previous rows up one line. */ +for ( i = fb.fbp.font->height; i < fb.fbp.height; i++ ) + { +memcpy (dst, src, bytes); + src += fb.fbp.bytes_per_line; + dst += fb.fbp.bytes_per_line; + } + +/* Render new line. */ +fb_show_line ( + fb.text_buf, + fb.fbp.lfb + (fb.fbp.text_rows-1) * fb.fbp.font->height *fb.fbp.bytes_per_line,
xen/drivers/video/fb.c new file +73
-0+ fb.xpos, fb.fbp.text_columns); + + fb.xpos =0 ; + } + +if ( c !='\n' ) + fb.text_buf[fb.xpos++] = c; + } + + fb.fbp.flush (); +} + +void fb_cr (void ) +{ + fb.xpos =0 ; +} + +int __init fb_init (struct fb_prop fbp) +{ +if ( fbp.width >MAX_XRES || fbp.height >MAX_YRES ) + { +printk ("Couldn't initialize a %xx%x framebuffer early.\n" , + fbp.width, fbp.height); +return -EINVAL ; + } + + fb.fbp = fbp; + fb.lbuf = lbuf; + fb.text_buf = text_buf; + fb.line_len = line_len; +return 0 ; +} + +int __init fb_alloc (void ) +{ + fb.lbuf =NULL ; + fb.text_buf =NULL ; + fb.line_len =NULL ; + + fb.lbuf =xmalloc_bytes (fb.fbp.bytes_per_line); +if ( !fb.lbuf ) + goto fail; + + fb.text_buf =xzalloc_bytes (fb.fbp.text_columns * fb.fbp.text_rows); +if ( !fb.text_buf ) + goto fail; + + fb.line_len = xzalloc_array(unsigned int, fb.fbp.text_columns); +if ( !fb.line_len ) + goto fail; + +memcpy (fb.lbuf, lbuf, fb.fbp.bytes_per_line); +memcpy (fb.text_buf, text_buf, fb.fbp.text_columns * fb.fbp.text_rows); +memcpy (fb.line_len, line_len, fb.fbp.text_columns); + +return 0 ; + +fail: +printk (XENLOG_ERR "Couldn't allocate enough memory to drive " +"the framebuffer\n" ); +xfree (fb.lbuf); +xfree (fb.text_buf); +xfree (fb.line_len); + +return -ENOMEM ; +} + +void fb_free (void ) +{ +xfree (fb.lbuf); +xfree (fb.text_buf); +xfree (fb.line_len); +}xen/drivers/video/fb.h new file +30
-0@@ -0,0 +1,49 @@ +/* +* xen/drivers/video/fb.h +* +* Cross-platform framebuffer library +* +* Stefano Stabellini <[email protected]> +* Copyright (c) 2012 Citrix Systems. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef _XEN_FB_H +#define _XEN_FB_H + +#include <xen/init.h> + +struct fb_prop { + const struct font_desc *font; + unsigned char *lfb; + unsigned int pixel_on; + uint16_t width, height; + uint16_t bytes_per_line;
xen/drivers/video/fb.h line 40
Quoted 10 lines
xen/drivers/video/fb.h new file +10
-0+uint16_t bits_per_pixel; +void (*flush)(void ); + +unsigned int text_columns; +unsigned int text_rows; +}; + +void fb_redraw_puts (const char *s); +void fb_scroll_puts (const char *s); +void fb_cr (void );
Please make this fb_create() or alike - "cr" alone could well be mistaken as "carriage return".
Jan
Quoted 11 lines
xen/drivers/video/fb.h new file +9
-0+void fb_free (void ); + +/* initialize the framebuffer, can be called early (before xmalloc is +* available) */ +int __init fb_init (struct fb_prop fbp); +/* fb_alloc allocates internal structures using xmalloc */ +int __init fb_alloc (void ); + +#endif Signature · 1 line
1.7.2.5
Re: [PATCH v2 3/8] xen: introduce a generic framebuffer driver
Quoted 289 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 07.12.12 at 19:02, Stefano Stabellini <[email protected]>
Quoted 287 lines · wrote:
Abstract away from
vesa.cthe funcions to handle a linear framebuffer and print characters to it.
The corresponding functions are going to be removed fromvesa.cin the next patch.Signed-off-by Stefano Stabellini <[email protected]>--- xen/drivers/video/Makefile | 1 + xen/drivers/video/fb.c | 209 ++++++++++++++++++++++++++++++++++++++++++++ xen/drivers/video/fb.h | 49 ++++++++++ 3 files changed, 259 insertions(+), 0 deletions(-) create mode 100644 xen/drivers/video/fb.c create mode 100644 xen/drivers/video/fb.hxen/drivers/video/Makefile +1
-0@@ -2,4 +2,5 @@ obj-$(HAS_VGA) := vga.o obj-$(HAS_VIDEO) += font_8x14.o obj-$(HAS_VIDEO) += font_8x16.o obj-$(HAS_VIDEO) += font_8x8.o +obj-$(HAS_VIDEO) += fb.o obj-$(HAS_VGA) += vesa.oxen/drivers/video/fb.c new file +1
-0@@ -0,0 +1,209 @@ +/************************************************************************** ****
+ *fb.c
+ *
+ * linear frame buffer handling.
+ */xen/drivers/video/fb.c new file +78
-0+ +#include <xen/config.h> +#include <xen/kernel.h> +#include <xen/lib.h> +#include <xen/errno.h> +#include "fb.h" +#include "font.h" + +#define MAX_XRES 1900 +#define MAX_YRES 1200 +#define MAX_BPP 4 +#define MAX_FONT_W 8 +#define MAX_FONT_H 16 +static __initdata unsigned int line_len[MAX_XRES /MAX_FONT_W ]; +static __initdata unsigned char lbuf[MAX_XRES *MAX_BPP ]; +static __initdata unsigned char text_buf[(MAX_XRES / MAX_FONT_W) * \ + (MAX_YRES /MAX_FONT_H )]; + +struct fb_status { +struct fb_prop fbp; + +unsigned char *lbuf, *text_buf; +unsigned int *line_len; +unsigned int xpos, ypos; +}; +static struct fb_status fb; + +static void fb_show_line ( +const unsigned char *text_line, +unsigned char *video_line, +unsigned int nr_chars, +unsigned int nr_cells) +{ +unsigned int i, j, b, bpp, pixel; + + bpp = (fb.fbp.bits_per_pixel +7 ) >>3 ; + +for ( i =0 ; i < fb.fbp.font->height; i++ ) + { +unsigned char *ptr = fb.lbuf; + +for ( j =0 ; j < nr_chars; j++ ) + { +const unsigned char *bits = fb.fbp.font->data; + bits += ((text_line[j] * fb.fbp.font->height + i) * + ((fb.fbp.font->width +7 ) >>3 )); +for ( b = fb.fbp.font->width; b--; ) + { + pixel = (*bits & (1u <<b)) ? fb.fbp.pixel_on :0 ; +memcpy (ptr, &pixel, bpp); + ptr += bpp; + } + } + +memset (ptr,0 , (fb.fbp.width - nr_chars * fb.fbp.font->width) * bpp); +memcpy (video_line, fb.lbuf, nr_cells * fb.fbp.font->width * bpp); + video_line += fb.fbp.bytes_per_line; + } +} + +/* Fast mode which redraws all modified parts of a 2D text buffer. */ +void fb_redraw_puts (const char *s) +{ +unsigned int i, min_redraw_y = fb.ypos; +char c; + +/* Paste characters into text buffer. */ +while ( (c = *s++) !='\0' ) + { +if ( (c =='\n' ) || (fb.xpos >= fb.fbp.text_columns) ) + { +if ( ++fb.ypos >= fb.fbp.text_rows ) + { + min_redraw_y =0 ; + fb.ypos = fb.fbp.text_rows -1 ; +memmove (fb.text_buf, fb.text_buf + fb.fbp.text_columns, + fb.ypos * fb.fbp.text_columns); + memset(fb.text_buf + fb.ypos * fb.fbp.text_columns, 0,fb.xpos);
xen/drivers/video/fb.c new file +9
-0+ } + fb.xpos =0 ; + } + +if ( c !='\n' ) + fb.text_buf[fb.xpos++ + fb.ypos * fb.fbp.text_columns] = c; + } + +/* Render modified section of text buffer to VESA linear framebuffer. */
xen/drivers/video/fb.c new file +10
-0+ for ( i = min_redraw_y; i <= fb.ypos; i++ ) + { + const unsigned char *line = fb.text_buf + i * fb.fbp.text_columns; + unsigned int width; + + for ( width = fb.fbp.text_columns; width; --width ) + if ( line[width - 1] ) + break; + fb_show_line(line, + fb.fbp.lfb + i * fb.fbp.font->height *fb.fbp.bytes_per_line,
xen/drivers/video/fb.c new file +20
-0+ width, max(fb.line_len[i], width)); + fb.line_len[i] = width; + } + + fb.fbp.flush (); +} + +/* Slower line-based scroll mode which interacts better with dom0. */ +void fb_scroll_puts (const char *s) +{ +unsigned int i; +char c; + +while ( (c = *s++) !='\0' ) + { +if ( (c =='\n' ) || (fb.xpos >= fb.fbp.text_columns) ) + { +unsigned int bytes = (fb.fbp.width * + ((fb.fbp.bits_per_pixel +7 ) >>3 )); + unsigned char *src = fb.fbp.lfb + fb.fbp.font->height *fb.fbp.bytes_per_line;
xen/drivers/video/fb.c new file +14
-0+unsigned char *dst = fb.fbp.lfb; + +/* New line: scroll all previous rows up one line. */ +for ( i = fb.fbp.font->height; i < fb.fbp.height; i++ ) + { +memcpy (dst, src, bytes); + src += fb.fbp.bytes_per_line; + dst += fb.fbp.bytes_per_line; + } + +/* Render new line. */ +fb_show_line ( + fb.text_buf, + fb.fbp.lfb + (fb.fbp.text_rows-1) * fb.fbp.font->height *fb.fbp.bytes_per_line,
xen/drivers/video/fb.c new file +73
-0+ fb.xpos, fb.fbp.text_columns); + + fb.xpos =0 ; + } + +if ( c !='\n' ) + fb.text_buf[fb.xpos++] = c; + } + + fb.fbp.flush (); +} + +void fb_cr (void ) +{ + fb.xpos =0 ; +} + +int __init fb_init (struct fb_prop fbp) +{ +if ( fbp.width >MAX_XRES || fbp.height >MAX_YRES ) + { +printk ("Couldn't initialize a %xx%x framebuffer early.\n" , + fbp.width, fbp.height); +return -EINVAL ; + } + + fb.fbp = fbp; + fb.lbuf = lbuf; + fb.text_buf = text_buf; + fb.line_len = line_len; +return 0 ; +} + +int __init fb_alloc (void ) +{ + fb.lbuf =NULL ; + fb.text_buf =NULL ; + fb.line_len =NULL ; + + fb.lbuf =xmalloc_bytes (fb.fbp.bytes_per_line); +if ( !fb.lbuf ) + goto fail; + + fb.text_buf =xzalloc_bytes (fb.fbp.text_columns * fb.fbp.text_rows); +if ( !fb.text_buf ) + goto fail; + + fb.line_len = xzalloc_array(unsigned int, fb.fbp.text_columns); +if ( !fb.line_len ) + goto fail; + +memcpy (fb.lbuf, lbuf, fb.fbp.bytes_per_line); +memcpy (fb.text_buf, text_buf, fb.fbp.text_columns * fb.fbp.text_rows); +memcpy (fb.line_len, line_len, fb.fbp.text_columns); + +return 0 ; + +fail: +printk (XENLOG_ERR "Couldn't allocate enough memory to drive " +"the framebuffer\n" ); +xfree (fb.lbuf); +xfree (fb.text_buf); +xfree (fb.line_len); + +return -ENOMEM ; +} + +void fb_free (void ) +{ +xfree (fb.lbuf); +xfree (fb.text_buf); +xfree (fb.line_len); +}xen/drivers/video/fb.h new file +35
-0@@ -0,0 +1,49 @@ +/* +* xen/drivers/video/fb.h +* +* Cross-platform framebuffer library +* +* Stefano Stabellini <[email protected]> +* Copyright (c) 2012 Citrix Systems. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef _XEN_FB_H +#define _XEN_FB_H + +#include <xen/init.h> + +struct fb_prop { + const struct font_desc *font; + unsigned char *lfb; + unsigned int pixel_on; + uint16_t width, height; + uint16_t bytes_per_line; + uint16_t bits_per_pixel; + void (*flush)(void); + + unsigned int text_columns; + unsigned int text_rows;
Quoted 8 lines
xen/drivers/video/fb.h line 40
Quoted 5 lines
xen/drivers/video/fb.h new file +5
-0+}; + +void fb_redraw_puts (const char *s); +void fb_scroll_puts (const char *s); +void fb_cr (void );Please make this
fb_create()or alike - "cr" alone could well be mistaken as "carriage return".
Actually it is supposed to be "cr": it is used by vesa_endboot to reset the cursor to column 0.
Re: [PATCH v2 3/8] xen: introduce a generic framebuffer driver
On Mon, 2012-12-10 at 17:51 +0000, Stefano Stabellini wrote:
[snip, 300 lines of unnecessarily quoted material, come on guys!]
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+void
fb_cr(void);Please make this
fb_create()or alike - "cr" alone could well be mistaken as "carriage return".
Or control register which was my first thought.
Quoted 2 lines
Actually it is supposed to be "cr": it is used by
vesa_endbootto reset the cursor to column 0.
fb_carriage_return? It's not called so frequently that a little extra typing will hurt.
Ian.
Re: [PATCH v2 3/8] xen: introduce a generic framebuffer driver
Quoted 9 lines · Ian Campbell
On Mon, 2012-12-10 at 17:51 +0000, Stefano Stabellini wrote:
[snip, 300 lines of unnecessarily quoted material, come on guys!]
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+void
fb_cr(void);Please make this
fb_create()or alike - "cr" alone could well be mistaken as "carriage return".
Quoted 7 lines
Or control register which was my first thought.
Quoted 2 lines
Actually it is supposed to be "cr": it is used by
vesa_endbootto reset the cursor to column 0.
fb_carriage_return? It's not called so frequently that a little extra typing will hurt.
Yeah.. good idea
PATCH v2 4/8 xen/vesa: use the new fb_* functions
In reply to Stefano StabelliniMake use of the framebuffer functions previously introduced.
--- xen/drivers/video/vesa.c | 179 +++++++--------------------------------------- 1 files changed, 26 insertions(+), 153 deletions(-)
xen/drivers/video/vesa.c +26 -153
@@ -13,20 +13,15 @@#include <asm/io.h> #include <asm/page.h> #include "font.h" +#include "fb.h" #define vlfb_info vga_console_info.u.vesa_lfb -#define text_columns (vlfb_info.width / font->width) -#define text_rows (vlfb_info.height / font->height) -static void vesa_redraw_puts (const char *s); -static void vesa_scroll_puts (const char *s); +static void lfb_flush (void ); -static unsigned char *lfb, *lbuf, *text_buf; -static unsigned int *__initdata line_len; +static unsigned char *lfb;static const struct font_desc *font;static bool_t vga_compat; -static unsigned int pixel_on; -static unsigned int xpos, ypos;static unsigned int vram_total;integer_param ("vesa-ram" , vram_total);
@@ -87,29 +82,26 @@ void __init vesa_early_init(void)void __init vesa_init (void ) { -if ( !font ) - goto fail; - - lbuf =xmalloc_bytes (vlfb_info.bytes_per_line); -if ( !lbuf ) - goto fail; +struct fb_prop fbp; - text_buf =xzalloc_bytes (text_columns * text_rows); -if ( !text_buf ) - goto fail; +if ( !font ) +return ; - line_len = xzalloc_array(unsigned int, text_columns); -if ( !line_len ) - goto fail; + fbp.font = font; + fbp.bits_per_pixel = vlfb_info.bits_per_pixel; + fbp.bytes_per_line = vlfb_info.bytes_per_line; + fbp.width = vlfb_info.width; + fbp.height = vlfb_info.height; + fbp.flush = lfb_flush; + fbp.text_columns = vlfb_info.width / font->width; + fbp.text_rows = vlfb_info.height / font->height; - lfb =ioremap (vlfb_info.lfb_base, vram_remap); + fbp.lfb = lfb =ioremap (vlfb_info.lfb_base, vram_remap);if ( !lfb ) - goto fail; +return ;memset (lfb,0 , vram_remap); - video_puts = vesa_redraw_puts; - printk(XENLOG_INFO "vesafb: framebuffer at %#x, mapped to 0x%p, " "using %uk, total %uk\n", vlfb_info.lfb_base, lfb,
@@ -131,7 +123,7 @@ void __init vesa_init(void) {/* Light grey in truecolor. */ unsigned int grey =0xaaaaaaaa ; - pixel_on = + fbp.pixel_on = ((grey >> (32 - vlfb_info. red_size)) << vlfb_info. red_pos) | ((grey >> (32 - vlfb_info.green_size)) << vlfb_info.green_pos) | ((grey >> (32 - vlfb_info. blue_size)) << vlfb_info. blue_pos);
@@ -139,15 +131,14 @@ void __init vesa_init(void)else {/* White(ish) in default pseudocolor palette. */ - pixel_on =7 ; + fbp.pixel_on =7 ; } -return ; - - fail: -xfree (lbuf); -xfree (text_buf); -xfree (line_len); +if (fb_init (fbp) <0 ) +return ; +if (fb_alloc () <0 ) +return ; + video_puts = fb_redraw_puts; }#include <asm/mtrr.h>
@@ -192,8 +183,8 @@ void __init vesa_endboot(bool_t keep) {if ( keep ) { - xpos =0 ; - video_puts = vesa_scroll_puts; + video_puts = fb_scroll_puts; +fb_cr (); }else {
@@ -202,124 +193,6 @@ void __init vesa_endboot(bool_t keep)memset (lfb + i * vlfb_info.bytes_per_line,0 , vlfb_info.width * bpp);lfb_flush (); +fb_free (); } - -xfree (line_len); -} - -/* Render one line of text to given linear framebuffer line. */ -static void vesa_show_line ( -const unsigned char *text_line, -unsigned char *video_line, -unsigned int nr_chars, -unsigned int nr_cells) -{ -unsigned int i, j, b, bpp, pixel; - - bpp = (vlfb_info.bits_per_pixel +7 ) >>3 ; - -for ( i =0 ; i < font->height; i++ ) - { -unsigned char *ptr = lbuf; - -for ( j =0 ; j < nr_chars; j++ ) - { -const unsigned char *bits = font->data; - bits += ((text_line[j] * font->height + i) * - ((font->width +7 ) >>3 )); -for ( b = font->width; b--; ) - { - pixel = (*bits & (1u <<b)) ? pixel_on :0 ; -memcpy (ptr, &pixel, bpp); - ptr += bpp; - } - } - -memset (ptr,0 , (vlfb_info.width - nr_chars * font->width) * bpp); -memcpy (video_line, lbuf, nr_cells * font->width * bpp); - video_line += vlfb_info.bytes_per_line; - } -} - -/* Fast mode which redraws all modified parts of a 2D text buffer. */ -static void __init vesa_redraw_puts (const char *s) -{ -unsigned int i, min_redraw_y = ypos; -char c; - -/* Paste characters into text buffer. */ -while ( (c = *s++) !='\0' ) - { -if ( (c =='\n' ) || (xpos >= text_columns) ) - { -if ( ++ypos >= text_rows ) - { - min_redraw_y =0 ; - ypos = text_rows -1 ; -memmove (text_buf, text_buf + text_columns, - ypos * text_columns); -memset (text_buf + ypos * text_columns,0 , xpos); - } - xpos =0 ; - } - -if ( c !='\n' ) - text_buf[xpos++ + ypos * text_columns] = c; - } - -/* Render modified section of text buffer to VESA linear framebuffer. */ -for ( i = min_redraw_y; i <= ypos; i++ ) - { -const unsigned char *line = text_buf + i * text_columns; -unsigned int width; - -for ( width = text_columns; width; --width ) -if ( line[width -1 ] ) -break ; -vesa_show_line (line, - lfb + i * font->height * vlfb_info.bytes_per_line, - width,max (line_len[i], width)); - line_len[i] = width; - } - -lfb_flush (); -} - -/* Slower line-based scroll mode which interacts better with dom0. */ -static void vesa_scroll_puts (const char *s) -{ -unsigned int i; -char c; - -while ( (c = *s++) !='\0' ) - { -if ( (c =='\n' ) || (xpos >= text_columns) ) - { -unsigned int bytes = (vlfb_info.width * - ((vlfb_info.bits_per_pixel +7 ) >>3 )); -unsigned char *src = lfb + font->height * vlfb_info.bytes_per_line; -unsigned char *dst = lfb; - -/* New line: scroll all previous rows up one line. */ -for ( i = font->height; i < vlfb_info.height; i++ ) - { -memcpy (dst, src, bytes); - src += vlfb_info.bytes_per_line; - dst += vlfb_info.bytes_per_line; - } - -/* Render new line. */ -vesa_show_line ( - text_buf, - lfb + (text_rows-1 ) * font->height * vlfb_info.bytes_per_line, - xpos, text_columns); - - xpos =0 ; - } - -if ( c !='\n' ) - text_buf[xpos++] = c; - } - -lfb_flush (); }
Signature · 1 line
1.7.2.5
Re: [PATCH v2 4/8] xen/vesa: use the new fb_* functions
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 07.12.12 at 19:02, Stefano Stabellini <[email protected]>
Quoted 18 lines · wrote:
Make use of the framebuffer functions previously introduced.
Signed-off-by Stefano Stabellini <[email protected]>--- xen/drivers/video/vesa.c | 179 +++++++--------------------------------------- 1 files changed, 26 insertions(+), 153 deletions(-)xen/drivers/video/vesa.c +1
-0@@ -13,20 +13,15 @@#include <asm/io.h> #include <asm/page.h> #include "font.h" +#include "fb.h" #define vlfb_info vga_console_info.u.vesa_lfb
xen/drivers/video/vesa.c line 22
Quoted 10 lines
xen/drivers/video/vesa.c +2
-6-#define text_columns (vlfb_info.width / font->width) -#define text_rows (vlfb_info.height / font->height) -static void vesa_redraw_puts (const char *s); -static void vesa_scroll_puts (const char *s); +static void lfb_flush (void ); -static unsigned char *lfb, *lbuf, *text_buf; -static unsigned int *__initdata line_len; +static unsigned char *lfb;
What's the point of retaining this, when ...
Quoted 29 lines
xen/drivers/video/vesa.c +4
-14static const struct font_desc *font;static bool_t vga_compat; -static unsigned int pixel_on; -static unsigned int xpos, ypos;static unsigned int vram_total;integer_param ("vesa-ram" , vram_total);@@ -87,29 +82,26 @@ void __init vesa_early_init(void)void __init vesa_init (void ) { -if ( !font ) - goto fail; - - lbuf =xmalloc_bytes (vlfb_info.bytes_per_line); -if ( !lbuf ) - goto fail; +struct fb_prop fbp; - text_buf =xzalloc_bytes (text_columns * text_rows); -if ( !text_buf ) - goto fail; +if ( !font ) +return ; - line_len = xzalloc_array(unsigned int, text_columns); -if ( !line_len ) - goto fail; + fbp.font = font;
xen/drivers/video/vesa.c void __init vesa_early_init(void) · line 99
Quoted 10 lines
xen/drivers/video/vesa.c +8
-1+ fbp.bits_per_pixel = vlfb_info.bits_per_pixel; + fbp.bytes_per_line = vlfb_info.bytes_per_line; + fbp.width = vlfb_info.width; + fbp.height = vlfb_info.height; + fbp.flush = lfb_flush; + fbp.text_columns = vlfb_info.width / font->width; + fbp.text_rows = vlfb_info.height / font->height; - lfb =ioremap (vlfb_info.lfb_base, vram_remap); + fbp.lfb = lfb =ioremap (vlfb_info.lfb_base, vram_remap);
... you set up the consolidated field at the same time anyway?
Jan
Quoted 182 lines
xen/drivers/video/vesa.c +11
-132if ( !lfb ) - goto fail; +return ;memset (lfb,0 , vram_remap); - video_puts = vesa_redraw_puts; - printk(XENLOG_INFO "vesafb: framebuffer at %#x, mapped to 0x%p, " "using %uk, total %uk\n", vlfb_info.lfb_base, lfb,@@ -131,7 +123,7 @@ void __init vesa_init(void) {/* Light grey in truecolor. */ unsigned int grey =0xaaaaaaaa ; - pixel_on = + fbp.pixel_on = ((grey >> (32 - vlfb_info. red_size)) << vlfb_info. red_pos) | ((grey >> (32 - vlfb_info.green_size)) << vlfb_info.green_pos) | ((grey >> (32 - vlfb_info. blue_size)) << vlfb_info. blue_pos);@@ -139,15 +131,14 @@ void __init vesa_init(void)else {/* White(ish) in default pseudocolor palette. */ - pixel_on =7 ; + fbp.pixel_on =7 ; } -return ; - - fail: -xfree (lbuf); -xfree (text_buf); -xfree (line_len); +if (fb_init (fbp) <0 ) +return ; +if (fb_alloc () <0 ) +return ; + video_puts = fb_redraw_puts; }#include <asm/mtrr.h> @@ -192,8 +183,8 @@ void __init vesa_endboot(bool_t keep) {if ( keep ) { - xpos =0 ; - video_puts = vesa_scroll_puts; + video_puts = fb_scroll_puts; +fb_cr (); }else {@@ -202,124 +193,6 @@ void __init vesa_endboot(bool_t keep)memset (lfb + i * vlfb_info.bytes_per_line,0 , vlfb_info.width * bpp);lfb_flush (); +fb_free (); } - -xfree (line_len); -} - -/* Render one line of text to given linear framebuffer line. */ -static void vesa_show_line ( -const unsigned char *text_line, -unsigned char *video_line, -unsigned int nr_chars, -unsigned int nr_cells) -{ -unsigned int i, j, b, bpp, pixel; - - bpp = (vlfb_info.bits_per_pixel +7 ) >>3 ; - -for ( i =0 ; i < font->height; i++ ) - { -unsigned char *ptr = lbuf; - -for ( j =0 ; j < nr_chars; j++ ) - { -const unsigned char *bits = font->data; - bits += ((text_line[j] * font->height + i) * - ((font->width +7 ) >>3 )); -for ( b = font->width; b--; ) - { - pixel = (*bits & (1u <<b)) ? pixel_on :0 ; -memcpy (ptr, &pixel, bpp); - ptr += bpp; - } - } - -memset (ptr,0 , (vlfb_info.width - nr_chars * font->width) * bpp); -memcpy (video_line, lbuf, nr_cells * font->width * bpp); - video_line += vlfb_info.bytes_per_line; - } -} - -/* Fast mode which redraws all modified parts of a 2D text buffer. */ -static void __init vesa_redraw_puts (const char *s) -{ -unsigned int i, min_redraw_y = ypos; -char c; - -/* Paste characters into text buffer. */ -while ( (c = *s++) !='\0' ) - { -if ( (c =='\n' ) || (xpos >= text_columns) ) - { -if ( ++ypos >= text_rows ) - { - min_redraw_y =0 ; - ypos = text_rows -1 ; -memmove (text_buf, text_buf + text_columns, - ypos * text_columns); -memset (text_buf + ypos * text_columns,0 , xpos); - } - xpos =0 ; - } - -if ( c !='\n' ) - text_buf[xpos++ + ypos * text_columns] = c; - } - -/* Render modified section of text buffer to VESA linear framebuffer. */ -for ( i = min_redraw_y; i <= ypos; i++ ) - { -const unsigned char *line = text_buf + i * text_columns; -unsigned int width; - -for ( width = text_columns; width; --width ) -if ( line[width -1 ] ) -break ; -vesa_show_line (line, - lfb + i * font->height * vlfb_info.bytes_per_line, - width,max (line_len[i], width)); - line_len[i] = width; - } - -lfb_flush (); -} - -/* Slower line-based scroll mode which interacts better with dom0. */ -static void vesa_scroll_puts (const char *s) -{ -unsigned int i; -char c; - -while ( (c = *s++) !='\0' ) - { -if ( (c =='\n' ) || (xpos >= text_columns) ) - { -unsigned int bytes = (vlfb_info.width * - ((vlfb_info.bits_per_pixel +7 ) >>3 )); -unsigned char *src = lfb + font->height * vlfb_info.bytes_per_line; -unsigned char *dst = lfb; - -/* New line: scroll all previous rows up one line. */ -for ( i = font->height; i < vlfb_info.height; i++ ) - { -memcpy (dst, src, bytes); - src += vlfb_info.bytes_per_line; - dst += vlfb_info.bytes_per_line; - } - -/* Render new line. */ -vesa_show_line ( - text_buf, - lfb + (text_rows-1 ) * font->height * vlfb_info.bytes_per_line, - xpos, text_columns); - - xpos =0 ; - } - -if ( c !='\n' ) - text_buf[xpos++] = c; - } - -lfb_flush ();}
Signature · 1 line
1.7.2.5
Re: [PATCH v2 4/8] xen/vesa: use the new fb_* functions
Quoted 70 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 07.12.12 at 19:02, Stefano Stabellini <[email protected]>
Quoted 18 lines · wrote:
Make use of the framebuffer functions previously introduced.
Signed-off-by Stefano Stabellini <[email protected]>--- xen/drivers/video/vesa.c | 179 +++++++--------------------------------------- 1 files changed, 26 insertions(+), 153 deletions(-)xen/drivers/video/vesa.c +1
-0@@ -13,20 +13,15 @@#include <asm/io.h> #include <asm/page.h> #include "font.h" +#include "fb.h" #define vlfb_info vga_console_info.u.vesa_lfbxen/drivers/video/vesa.c line 22
Quoted 10 lines
xen/drivers/video/vesa.c +2
-6-#define text_columns (vlfb_info.width / font->width) -#define text_rows (vlfb_info.height / font->height) -static void vesa_redraw_puts (const char *s); -static void vesa_scroll_puts (const char *s); +static void lfb_flush (void ); -static unsigned char *lfb, *lbuf, *text_buf; -static unsigned int *__initdata line_len; +static unsigned char *lfb;What's the point of retaining this, when ...
Quoted 37 lines
xen/drivers/video/vesa.c +11
-14static const struct font_desc *font;static bool_t vga_compat; -static unsigned int pixel_on; -static unsigned int xpos, ypos;static unsigned int vram_total;integer_param ("vesa-ram" , vram_total);@@ -87,29 +82,26 @@ void __init vesa_early_init(void)void __init vesa_init (void ) { -if ( !font ) - goto fail; - - lbuf =xmalloc_bytes (vlfb_info.bytes_per_line); -if ( !lbuf ) - goto fail; +struct fb_prop fbp; - text_buf =xzalloc_bytes (text_columns * text_rows); -if ( !text_buf ) - goto fail; +if ( !font ) +return ; - line_len = xzalloc_array(unsigned int, text_columns); -if ( !line_len ) - goto fail; + fbp.font = font; + fbp.bits_per_pixel = vlfb_info.bits_per_pixel; + fbp.bytes_per_line = vlfb_info.bytes_per_line; + fbp.width = vlfb_info.width; + fbp.height = vlfb_info.height; + fbp.flush = lfb_flush; + fbp.text_columns = vlfb_info.width / font->width; + fbp.text_rows = vlfb_info.height / font->height;
Quoted 4 lines
xen/drivers/video/vesa.c void __init vesa_early_init(void) · line 99
Quoted 2 lines
xen/drivers/video/vesa.c +1
-1- lfb =ioremap (vlfb_info.lfb_base, vram_remap); + fbp.lfb = lfb =ioremap (vlfb_info.lfb_base, vram_remap);... you set up the consolidated field at the same time anyway?
It is used by vesa_mtrr_init and vesa_endboot.
At the moment I don't store fbp in a static variable so after vesa_init returns, vesa.c doesn't have a way to retrieve it.
Maybe I should introduce a "struct fb_prop fbp" static variable that replaces lfb?
Re: [PATCH v2 4/8] xen/vesa: use the new fb_* functions
Quoted 67 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini
Quoted 60 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini
xen/drivers/video/vesa.c +1
-0@@ -13,20 +13,15 @@#include <asm/io.h> #include <asm/page.h> #include "font.h" +#include "fb.h" #define vlfb_info vga_console_info.u.vesa_lfbxen/drivers/video/vesa.c line 22
Quoted 10 lines
xen/drivers/video/vesa.c +2
-6-#define text_columns (vlfb_info.width / font->width) -#define text_rows (vlfb_info.height / font->height) -static void vesa_redraw_puts (const char *s); -static void vesa_scroll_puts (const char *s); +static void lfb_flush (void ); -static unsigned char *lfb, *lbuf, *text_buf; -static unsigned int *__initdata line_len; +static unsigned char *lfb;What's the point of retaining this, when ...
Quoted 37 lines
xen/drivers/video/vesa.c +11
-14static const struct font_desc *font;static bool_t vga_compat; -static unsigned int pixel_on; -static unsigned int xpos, ypos;static unsigned int vram_total;integer_param ("vesa-ram" , vram_total);@@ -87,29 +82,26 @@ void __init vesa_early_init(void)void __init vesa_init (void ) { -if ( !font ) - goto fail; - - lbuf =xmalloc_bytes (vlfb_info.bytes_per_line); -if ( !lbuf ) - goto fail; +struct fb_prop fbp; - text_buf =xzalloc_bytes (text_columns * text_rows); -if ( !text_buf ) - goto fail; +if ( !font ) +return ; - line_len = xzalloc_array(unsigned int, text_columns); -if ( !line_len ) - goto fail; + fbp.font = font; + fbp.bits_per_pixel = vlfb_info.bits_per_pixel; + fbp.bytes_per_line = vlfb_info.bytes_per_line; + fbp.width = vlfb_info.width; + fbp.height = vlfb_info.height; + fbp.flush = lfb_flush; + fbp.text_columns = vlfb_info.width / font->width; + fbp.text_rows = vlfb_info.height / font->height;Quoted 4 lines
xen/drivers/video/vesa.c void __init vesa_early_init(void) · line 99
Quoted 2 lines
xen/drivers/video/vesa.c +1
-1- lfb =ioremap (vlfb_info.lfb_base, vram_remap); + fbp.lfb = lfb =ioremap (vlfb_info.lfb_base, vram_remap);... you set up the consolidated field at the same time anyway?
Quoted 5 lines
It is used by
vesa_mtrr_initandvesa_endboot.
At the moment I don't store fbp in a static variable so aftervesa_initreturns,vesa.cdoesn't have a way to retrieve it.
Maybe I should introduce a "structfb_propfbp" static variable that replaces lfb?
Oh, I didn't realize that the static is private to the new fb.c. I'd think sharing this would make sense (and the specific driver could then fill the generic fields there directly). But I'll leave that up to you then which way you prefer - it just looked like unnecessary redundancy to me.
Jan
PATCH v2 5/8 xen/arm: preserve DTB mappings
In reply to Stefano StabelliniAt the moment we destroy the DTB mappings we have in setup_pagetables and we don't restore them until setup_mm.
Keep the temporary DTB mapping until we create the new ones.
--- xen/arch/arm/kernel.h | 2 ++ xen/arch/arm/mm.c | 12 ++++++++++++ xen/arch/arm/setup.c | 1 + xen/include/asm-arm/mm.h | 2 ++ 4 files changed, 17 insertions(+), 0 deletions(-)
xen/arch/arm/kernel.h +2 -0
@@ -38,4 +38,6 @@ struct kernel_info {int kernel_prepare (struct kernel_info *info);void kernel_load (struct kernel_info *info); +extern char _sdtb[]; +#endif /* #ifdef __ARCH_ARM_KERNEL_H__ */
xen/arch/arm/mm.c +12 -0
@@ -34,6 +34,7 @@#include <asm/current.h> #include <public/memory.h> #include <xen/sched.h> +#include "kernel.h" struct domain *dom_xen, *dom_io;
@@ -295,12 +296,23 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr)write_pte (xen_second +second_linear_offset (XEN_VIRT_START ), pte);/* TLBFLUSH and ISB would be needed here, but wait until we set WXN */ +/* preserve the DTB mapping a little while longer */ + pte =mfn_to_xen_entry (((unsigned long ) _sdtb + boot_phys_offset) >>PAGE_SHIFT ); +write_pte (xen_second +second_linear_offset (BOOT_MISC_VIRT_START ), pte); +/* From now on, no mapping may be both writable and executable. */ WRITE_CP32 (READ_CP32 (HSCTLR ) |SCTLR_WXN ,HSCTLR );/* Flush everything after setting WXN bit. */ flush_xen_text_tlb (); } +void __init destroy_dtb_mapping (void ) +{ +/* destroy old DTB mapping */ + xen_second[second_linear_offset (BOOT_MISC_VIRT_START )].bits =0 ; +dsb (); +} +/* MMU setup for secondary CPUS (which already have paging enabled) */ void __cpuinit mmu_init_secondary_cpu (void ) {
xen/arch/arm/setup.c +1 -0
@@ -230,6 +230,7 @@ void __init start_xen(unsigned long boot_phys_offset,init_xen_time (); +destroy_dtb_mapping ();setup_mm (atag_paddr, fdt_size);/* Setup Hyp vector base */
xen/include/asm-arm/mm.h +2 -0
@@ -139,6 +139,8 @@ extern unsigned long total_pages;/* Boot-time pagetable setup */ extern void setup_pagetables (unsigned long boot_phys_offset,paddr_t xen_paddr); +/* Destroy temporary DTB mapping */ +extern void destroy_dtb_mapping (void );/* MMU setup for seccondary CPUS (which already have paging enabled) */ extern void __cpuinit mmu_init_secondary_cpu (void );/* Set up the xenheap: up to 1GB of contiguous, always-mapped memory.
Signature · 1 line
1.7.2.5
PATCH v2 6/8 xen/device_tree: introduce find_compatible_node
In reply to Stefano StabelliniIntroduce a find_compatible_node function that can be used by device drivers to find the node corresponding to their device in the device tree.
Initialize device_tree_flattened early in start_xen, so that it is available before setup_mm. Get rid of fdt in the process.
Also add device_tree_node_compatible to device_tree.h, that is currently missing.
Changes in v2:
- remove fdt;
- return early from _find_compatible_node, if a node has already been found.
--- xen/arch/arm/setup.c | 7 ++--- xen/common/device_tree.c | 51 +++++++++++++++++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 3 ++ 3 files changed, 57 insertions(+), 4 deletions(-)
xen/arch/arm/setup.c +3 -4
@@ -196,7 +196,6 @@ void __init start_xen(unsigned long boot_phys_offset, unsigned long atag_paddr, unsigned long cpuid) { - void *fdt;size_t fdt_size;int cpus, i;
@@ -204,13 +203,13 @@ void __init start_xen(unsigned long boot_phys_offset,smp_clear_cpu_maps (); - fdt = (void *)BOOT_MISC_VIRT_START + device_tree_flattened = (void *)BOOT_MISC_VIRT_START + (atag_paddr & ((1 <<SECOND_SHIFT ) -1 )); - fdt_size =device_tree_early_init (fdt); + fdt_size =device_tree_early_init (device_tree_flattened); cpus =smp_get_max_cpus (); cpus =1 ; -cmdline_parse (device_tree_bootargs (fdt)); +cmdline_parse (device_tree_bootargs (device_tree_flattened));setup_pagetables (boot_phys_offset,get_xen_paddr ());
xen/common/device_tree.c +51 -0
57 lines not on this page · raw message
xen/include/xen/device_tree.h +3 -0
@@ -54,6 +54,9 @@ void device_tree_set_reg(u32 **cell, u32 address_cells, u32 size_cells, u64 start, u64 size);u32 device_tree_get_u32 (const void *fdt,int node,const char *prop_name);bool_t device_tree_node_matches (const void *fdt,int node,const char *match); +bool_t device_tree_node_compatible (const void *fdt,int node,const char *match); +int find_compatible_node (const char *compatible,int *node,int *depth, +u32 *address_cells,u32 *size_cells);int device_tree_for_each_node (const void *fdt,device_tree_node_func func,void *data);const char *device_tree_bootargs (const void *fdt);
Signature · 1 line
1.7.2.5
PATCH v2 7/8 xen/arm: introduce vexpress_syscfg
In reply to Stefano StabelliniIntroduce a Versatile Express specific function to read/write motherboard settings.
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/platform_vexpress.c | 97 +++++++++++++++++++++++++++++++ xen/include/asm-arm/platform_vexpress.h | 23 +++++++ 3 files changed, 121 insertions(+), 0 deletions(-) create mode 100644 xen/arch/arm/platform_vexpress.c
xen/arch/arm/Makefile +1 -0
@@ -18,6 +18,7 @@ obj-y += p2m.o obj-y += percpu.o obj-y += guestcopy.o obj-y += physdev.o +obj-y += platform_vexpress.o obj-y += setup.o obj-y += time.o obj-y += smpboot.o
xen/arch/arm/platform_vexpress.c new file +97 -0
97 lines not on this page · raw message
xen/include/asm-arm/platform_vexpress.h +23 -0
@@ -6,6 +6,29 @@#define V2M_SYS_FLAGSSET (0x30)#define V2M_SYS_FLAGSCLR (0x34) +#define V2M_SYS_CFGDATA (0x00A0/4) +#define V2M_SYS_CFGCTRL (0x00A4/4) +#define V2M_SYS_CFGSTAT (0x00A8/4) + +#define V2M_SYS_CFG_START (1<<31) +#define V2M_SYS_CFG_WRITE (1<<30) +#define V2M_SYS_CFG_ERROR (1<<1) +#define V2M_SYS_CFG_COMPLETE (1<<0) + +#define V2M_SYS_CFG_OSC_FUNC 1 +#define V2M_SYS_CFG_OSC0 0 +#define V2M_SYS_CFG_OSC1 1 +#define V2M_SYS_CFG_OSC2 2 +#define V2M_SYS_CFG_OSC3 3 +#define V2M_SYS_CFG_OSC4 4 +#define V2M_SYS_CFG_OSC5 5 + +#ifndef __ASSEMBLY__ +#include <xen/inttypes.h> + +int vexpress_syscfg (int write,int function,int device,uint32_t *data); +#endif +#endif /* __ASM_ARM_PLATFORM_H */ /* * Local variables:
Signature · 1 line
1.7.2.5
PATCH v2 8/8 xen/arm: introduce a driver for the ARM HDLCD controller
In reply to Stefano StabelliniRead the screen resolution setting from device tree, find the corresponding modeline in a small table of standard video modes, set the hardware accordingly.
Use vexpress_syscfg to configure the pixel clock.
Use the generic framebuffer functions to print on the screen.
Changes in v2:
- read mode from DT;
- support multiple resolutions;
- use vexpress_syscfg to set the pixclock.
--- xen/arch/arm/Rules.mk | 1 + xen/drivers/video/Makefile | 1 + xen/drivers/video/arm_hdlcd.c | 282 +++++++++++++++++++++++++++++++++++++++++ xen/drivers/video/modelines.h | 69 ++++++++++ xen/include/asm-arm/config.h | 2 + 5 files changed, 355 insertions(+), 0 deletions(-) create mode 100644 xen/drivers/video/arm_hdlcd.c create mode 100644 xen/drivers/video/modelines.h
xen/arch/arm/Rules.mk +1 -0
@@ -8,6 +8,7 @@ HAS_DEVICE_TREE := y HAS_VIDEO := y +HAS_ARM_HDLCD := y CFLAGS += -fno-builtin -fno-common -Wredundant-decls CFLAGS += -iwithprefix include -Werror -Wno-pointer-arith -pipe
xen/drivers/video/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(HAS_VIDEO) += font_8x16.o obj-$(HAS_VIDEO) += font_8x8.o obj-$(HAS_VIDEO) += fb.o obj-$(HAS_VGA) += vesa.o +obj-$(HAS_ARM_HDLCD) += arm_hdlcd.o
xen/drivers/video/arm_hdlcd.c new file +282 -0
282 lines not on this page · raw message
xen/drivers/video/modelines.h new file +69 -0
69 lines not on this page · raw message
xen/include/asm-arm/config.h +2 -0
@@ -19,6 +19,8 @@#define CONFIG_DOMAIN_PAGE 1 +#define CONFIG_VIDEO 1 +#define OPT_CONSOLE_STR "com1"#ifdef MAX_PHYS_CPUS
Signature · 1 line
1.7.2.5