xen: ARM HDLCD video driver
v5 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.
Changes in v5:
- move the barriers outside the loop in flush_xen_data_tlb_range_va;
- move out of "introduce early_ioremap" any changes related to flush_xen_data_tlb_range_va and PAGE masks;
- remove lfb_alloc and the now unused __initdata variables;
- fix indentation and long lines;
- reword commit message of "move setup_mm right after setup_pagetables";
- turn printk in setup_mm into an early_printk in setup_mm;
- actually include the Makefile for xen/arch/arm/platforms.
Changes in v4:
- rename flush_xen_data_tlb_range to flush_xen_data_tlb_range_va;
- replace all the calls to flush_xen_data_tlb_va, with calls to flush_xen_data_tlb_range_va;
- flush the entire 2MB mapping at BOOT_MISC_VIRT_START rather than just the first 4k;
- remove flush_xen_data_tlb_va;
- fix indentation;
- rename EARLY_VMAP_START/END to EARLY_VMAP_VIRT_START/END;
- mark early_ioremap as __init;
- reduce the amount of casts in early_ioremap;
- squash the vesa.c changes into this patch;
- rename fb* to lfb*;
- pass a pointer to fb_init;
- use %u for screen dimensions;
- specify loglevel in printk;
- call fb_free on error in fb_alloc;
- no __init on declarations;
- do not break messages to fit 80 columns;
- remove "preserve DTB mappings";
- introduce a new "move setup_mm right after setup_pagetables" patch;
- stop iterating over the DT nodes in device_tree_for_each_node if func returns a value != 0;
- return 1 from _find_compatible_node when a node is found;
- move the wait loop and the syscfg cfgctrl write into a separate function;
- fix comments;
- define all registers in write;
- move platform_vexpress.c to platforms/vexpress.c;
- move platform_vexpress.h to arm-arm/platforms/vexpress.h;
- use a lookup table to set the color masks;
- fix indentation;
- make sure mode_string is not NULL and is not bigger than 16 chars before continuing;
- introduce 2 separate error messages for !hdlcd_start and !framebuffer_start at the beginning of video_init;
- mark get_color_masks and set_pixclock as __init;
- check that we are running on a vexpress machine before calling vexpress_syscfg.
Changes in v3:
- rename fb_cr to fb_carriage_return.
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 (10):
xen/arm: add missing FIRST, SECOND and THIRD MASK and SIZE definitions xen/arm: introduce flush_xen_data_tlb_range_va
xen/arm: flush the entire dest_va 2MB mapping
xen/arm: introduce early_ioremap
xen: infrastructure to have cross-platform video drivers
xen: introduce a generic framebuffer driver
xen/arm: move setup_mm right after setup_pagetables 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/mm.c | 40 ++++- xen/arch/arm/mode_switch.S | 2 +- xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/vexpress.c | 100 +++++++++++ xen/arch/arm/setup.c | 12 +- xen/arch/x86/Rules.mk | 1 + xen/common/device_tree.c | 56 ++++++- xen/drivers/Makefile | 2 +- xen/drivers/char/console.c | 12 +- xen/drivers/video/Makefile | 12 +- xen/drivers/video/arm_hdlcd.c | 276 ++++++++++++++++++++++++++++++ xen/drivers/video/lfb.c | 191 +++++++++++++++++++++ xen/drivers/video/lfb.h | 46 +++++ xen/drivers/video/modelines.h | 77 +++++++++ xen/drivers/video/vesa.c | 177 +++----------------- xen/drivers/video/vga.c | 12 +- xen/include/asm-arm/config.h | 6 + xen/include/asm-arm/mm.h | 3 +- xen/include/asm-arm/page.h | 24 ++- xen/include/asm-arm/platform_vexpress.h | 17 -- xen/include/asm-arm/platforms/vexpress.h | 40 +++++ 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 +++ 27 files changed, 929 insertions(+), 218 deletions(-)
Cheers,
Stefano
PATCH v5 1/10 xen/arm: add missing FIRST, SECOND and THIRD MASK and SIZE definitions
--- xen/include/asm-arm/page.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
xen/include/asm-arm/page.h +6 -0
@@ -418,8 +418,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 v5 2/10 xen/arm: introduce flush_xen_data_tlb_range_va
In reply to Stefano StabelliniAdd flush_xen_data_tlb_range_va, that flushes a range of virtual addresses. Replace all the calls to flush_xen_data_tlb_va with calls to flush_xen_data_tlb_range_va and remove flush_xen_data_tlb_va.
Changes in v5:
- move the barriers outside the loop in flush_xen_data_tlb_range_va.
--- xen/arch/arm/mm.c | 8 ++++---- xen/include/asm-arm/page.h | 18 +++++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-)
xen/arch/arm/mm.c +4 -4
@@ -112,7 +112,7 @@ void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes) pte.pt.ai = attributes; pte.pt.xn =1 ;write_pte (xen_fixmap +third_table_offset (FIXMAP_ADDR (map)), pte); -flush_xen_data_tlb_va (FIXMAP_ADDR (map)); +flush_xen_data_tlb_range_va (FIXMAP_ADDR (map),PAGE_SIZE ); }/* Remove a mapping from a fixmap entry */
@@ -120,7 +120,7 @@ void clear_fixmap(unsigned map) {lpae_t pte = {0 };write_pte (xen_fixmap +third_table_offset (FIXMAP_ADDR (map)), pte); -flush_xen_data_tlb_va (FIXMAP_ADDR (map)); +flush_xen_data_tlb_range_va (FIXMAP_ADDR (map),PAGE_SIZE ); }/* Map a page of domheap memory */
@@ -184,7 +184,7 @@ void *map_domain_page(unsigned long mfn)* We may not have flushed this specific subpage at map time, * since we only flush the 4k page not the superpage */ -flush_xen_data_tlb_va (va); +flush_xen_data_tlb_range_va (va,PAGE_SIZE );return (void *)va; }
@@ -219,7 +219,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) dest_va =BOOT_MISC_VIRT_START ; pte =mfn_to_xen_entry (xen_paddr >>PAGE_SHIFT );write_pte (xen_second +second_table_offset (dest_va), pte); -flush_xen_data_tlb_va (dest_va); +flush_xen_data_tlb_range_va (dest_va,PAGE_SIZE );/* Calculate virt-to-phys offset for the new location */ phys_offset = xen_paddr - (unsigned long ) _start;
xen/include/asm-arm/page.h +11 -7
@@ -316,16 +316,20 @@ static inline void flush_xen_data_tlb(void) }/* -* Flush one VA's hypervisor mappings from the data TLB. This is not +* 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_va (unsigned long va) +static inline void flush_xen_data_tlb_range_va (unsigned long va,unsigned long size) { - asmvolatile ("dsb;" /* Ensure preceding are visible */ - STORE_CP32(0, TLBIMVAH) - "dsb;" /* Ensure completion of the TLB flush */ - "isb;" - : : "r" (va) : "memory"); +unsigned long end = va + size; +dsb ();/* Ensure preceding are visible */ +while ( va < end ) { + asm volatile(STORE_CP32(0, TLBIMVAH) + : : "r" (va) : "memory"); + va += PAGE_SIZE; + } +dsb ();/* Ensure completion of the TLB flush */ +isb (); }/* Flush all non-hypervisor mappings from the TLB */
Signature · 1 line
1.7.2.5
PATCH v5 3/10 xen/arm: flush the entire dest_va 2MB mapping
In reply to Stefano StabelliniAt the beginning of setup_pagetables we modify a 2MB mapping but we only flush the first 4KB of it.
--- xen/arch/arm/mm.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
xen/arch/arm/mm.c +1 -1
@@ -219,7 +219,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) dest_va =BOOT_MISC_VIRT_START ; pte =mfn_to_xen_entry (xen_paddr >>PAGE_SHIFT );write_pte (xen_second +second_table_offset (dest_va), pte); -flush_xen_data_tlb_range_va (dest_va,PAGE_SIZE ); +flush_xen_data_tlb_range_va (dest_va,SECOND_SIZE );/* Calculate virt-to-phys offset for the new location */ phys_offset = xen_paddr - (unsigned long ) _start;
Signature · 1 line
1.7.2.5
PATCH v5 4/10 xen/arm: introduce early_ioremap
In reply to Stefano StabelliniIntroduce 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.
Changes in v5:
- move out of this patch any changes related toflush_xen_data_tlb_range_va and PAGE masks.
Changes in v4:
- rename flush_xen_data_tlb_range to flush_xen_data_tlb_range_va;
- replace all the calls to flush_xen_data_tlb_va, with calls to flush_xen_data_tlb_range_va;
- flush the entire 2MB mapping at BOOT_MISC_VIRT_START rather than just the first 4k;
- remove flush_xen_data_tlb_va;
- fix indentation;
- rename EARLY_VMAP_START/END to EARLY_VMAP_VIRT_START/END;
- mark early_ioremap as __init;
- reduce the amount of casts in early_ioremap.
--- xen/arch/arm/mm.c | 32 ++++++++++++++++++++++++++++++++ xen/include/asm-arm/config.h | 4 ++++ xen/include/asm-arm/mm.h | 3 ++- 3 files changed, 38 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_VIRT_END - EARLY_VMAP_VIRT_START. +*/ +void *__init early_ioremap (paddr_t start,size_t len,unsigned attributes) +{ +static unsigned long virt_start =EARLY_VMAP_VIRT_START ; +unsigned long ret_addr = 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_VIRT_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_va (ret_addr, len); + +return (void *)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 +4 -0
@@ -60,6 +60,8 @@* 6M - 8M Early boot misc (see below) * * 32M - 128M Frametable: 24 bytes per page for 16GB of RAM +* 256M - 1G VMAP: ioremap and early_ioremap use this virtual address +* space * * 1G - 2G Xenheap: always-mapped memory * 2G - 4G Domheap: on-demand-mapped
@@ -73,9 +75,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_VIRT_START mk_unsigned_long(0x10000000)#define XENHEAP_VIRT_START mk_unsigned_long(0x40000000)#define DOMHEAP_VIRT_START mk_unsigned_long(0x80000000) +#define EARLY_VMAP_VIRT_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); \
Signature · 1 line
1.7.2.5
PATCH v5 5/10 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 v5 6/10 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.
Make use of the new functions in vesa.c.
Changes in v5:
- remove lfb_alloc and the now unused __initdata variables;
- fix indentation and long lines.
Changes in v4:
- squash the vesa.c changes into this patch;
- rename fb* to lfb*;
- pass a pointer to fb_init;
- use %u for screen dimensions;
- specify loglevel in printk;
- call fb_free on error in fb_alloc;
- no __init on declarations;
- do not break messages to fit 80 columns.
--- xen/drivers/video/Makefile | 1 + xen/drivers/video/lfb.c | 191 ++++++++++++++++++++++++++++++++++++++++++++ xen/drivers/video/lfb.h | 46 +++++++++++ xen/drivers/video/vesa.c | 177 ++++++----------------------------------- 4 files changed, 262 insertions(+), 153 deletions(-) create mode 100644 xen/drivers/video/lfb.c create mode 100644 xen/drivers/video/lfb.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) += lfb.o obj-$(HAS_VGA) += vesa.o
xen/drivers/video/lfb.c new file +191 -0
191 lines not on this page · raw message
xen/drivers/video/lfb.h new file +46 -0
46 lines not on this page · raw message
xen/drivers/video/vesa.c +24 -153
227 lines not on this page · raw message
Signature · 1 line
1.7.2.5
Re: [PATCH v5 06/10] xen: introduce a generic framebuffer driver
Quoted 16 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini
xen/drivers/video/lfb.c new file +15
-0+int __init lfb_init (struct lfb_prop *lfbp) +{ +if ( lfbp->width >MAX_XRES || lfbp->height >MAX_YRES ) + { +printk (XENLOG_WARNING "Couldn't initialize a %ux%u framebuffer early.\n" , + lfbp->width, lfbp->height); +return -EINVAL ; + } + + lfb.lfbp = *lfbp; + lfb.lbuf =NULL ; + lfb.text_buf =NULL ; + lfb.line_len =NULL ; + + lfb.lbuf =xmalloc_bytes (lfb.lfbp.bytes_per_line);
xen/drivers/video/lfb.c line 175
Quoted 10 lines
xen/drivers/video/lfb.c new file +10
-0+if ( !lfb.lbuf ) + goto fail; + + lfb.text_buf =xzalloc_bytes (lfb.lfbp.text_columns * lfb.lfbp.text_rows); +if ( !lfb.text_buf ) + goto fail; + + lfb.line_len = xzalloc_array(unsigned int, lfb.lfbp.text_columns); +if ( !lfb.line_len ) + goto fail;
While minor, this is inefficient (and needlessly growing the source size): The initialization to NULL above could be dropped, the allocs all done in a row, and the results could be checked in one go.
xen/drivers/video/lfb.c line 184
Quoted 9 lines
xen/drivers/video/lfb.c new file +9
-0+ +return 0 ; + +fail: +printk (XENLOG_ERR "Couldn't allocate enough memory to drive the framebuffer\n" ); +lfb_free (); + +return -ENOMEM ; +}
Irrespective of the comment above, but provided there's no hidden change in the code that got moved around, feel free to stick my ack on it.
Jan
Re: [PATCH v5 06/10] xen: introduce a generic framebuffer driver
Quoted 22 lines · Jan Beulich
Quoted 22 lines
Quoted 1 line
Quoted 1 line · Stefano Stabellini
xen/drivers/video/lfb.c new file +21
-0+int __init lfb_init (struct lfb_prop *lfbp) +{ +if ( lfbp->width >MAX_XRES || lfbp->height >MAX_YRES ) + { +printk (XENLOG_WARNING "Couldn't initialize a %ux%u framebuffer early.\n" , + lfbp->width, lfbp->height); +return -EINVAL ; + } + + lfb.lfbp = *lfbp; + lfb.lbuf =NULL ; + lfb.text_buf =NULL ; + lfb.line_len =NULL ; + + lfb.lbuf =xmalloc_bytes (lfb.lfbp.bytes_per_line); +if ( !lfb.lbuf ) + goto fail; + + lfb.text_buf =xzalloc_bytes (lfb.lfbp.text_columns * lfb.lfbp.text_rows); +if ( !lfb.text_buf ) + goto fail;
Quoted 8 lines
xen/drivers/video/lfb.c line 175
Quoted 4 lines
xen/drivers/video/lfb.c new file +4
-0+ + lfb.line_len = xzalloc_array(unsigned int, lfb.lfbp.text_columns); +if ( !lfb.line_len ) + goto fail;While minor, this is inefficient (and needlessly growing the source size): The initialization to NULL above could be dropped, the allocs all done in a row, and the results could be checked in one go.
You are right, I'll make the changes
Quoted 5 lines
Quoted 5 lines
xen/drivers/video/lfb.c new file +5
-0+ +return 0 ; + +fail: +printk (XENLOG_ERR "Couldn't allocate enough memory to drive the framebuffer\n" );
Quoted 8 lines
xen/drivers/video/lfb.c line 184
Quoted 4 lines
xen/drivers/video/lfb.c new file +4
-0+lfb_free (); + +return -ENOMEM ; +}Irrespective of the comment above, but provided there's no hidden change in the code that got moved around, feel free to stick my ack on it.
Thanks!
PATCH v5 7/10 xen/arm: move setup_mm right after setup_pagetables
In reply to Stefano StabelliniAt the moment we destroy the DTB mappings we have in setup_pagetables and we restore them only in setup_mm.
Move setup_mm right after setup_pagetables.
This ensures we have a valid DTB mapping while running the subsequent initialization code.
Changes in v5:
- reword commit message;
- turn printk in setup_mm into an early_printk.
--- xen/arch/arm/setup.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
xen/arch/arm/setup.c +2 -3
@@ -135,7 +135,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size) xenheap_pages =min (1ul << (30 -PAGE_SHIFT ), heap_pages); domheap_pages = heap_pages - xenheap_pages; -printk ("Xen heap: %lu pages Dom heap: %lu pages\n" , xenheap_pages, domheap_pages); +early_printk ("Xen heap: %lu pages Dom heap: %lu pages\n" , xenheap_pages, domheap_pages);setup_xenheap_mappings (ram_start >>PAGE_SHIFT , xenheap_pages);
@@ -212,6 +212,7 @@ void __init start_xen(unsigned long boot_phys_offset,cmdline_parse (device_tree_bootargs (fdt));setup_pagetables (boot_phys_offset,get_xen_paddr ()); +setup_mm (atag_paddr, fdt_size);#ifdef EARLY_UART_ADDRESS /* TODO Need to get device tree or command line for UART address */
@@ -229,8 +230,6 @@ void __init start_xen(unsigned long boot_phys_offset,init_xen_time (); -setup_mm (atag_paddr, fdt_size); -/* Setup Hyp vector base */ WRITE_CP32 ((uint32_t ) hyp_traps_vector,HVBAR ); printk("Set hyp vector base to %"PRIx32" (expected %p)\n",
Signature · 1 line
1.7.2.5
PATCH v5 8/10 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 v4:
- stop iterating over the DT nodes in device_tree_for_each_node if func returns a value != 0;
- return 1 from _find_compatible_node when a node is found.
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 | 56 +++++++++++++++++++++++++++++++++++++++- xen/include/xen/device_tree.h | 3 ++ 3 files changed, 60 insertions(+), 6 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,12 +203,12 @@ 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 (); -cmdline_parse (device_tree_bootargs (fdt)); +cmdline_parse (device_tree_bootargs (device_tree_flattened));setup_pagetables (boot_phys_offset,get_xen_paddr ());setup_mm (atag_paddr, fdt_size);
xen/common/device_tree.c +54 -2
73 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 v5 9/10 xen/arm: introduce vexpress_syscfg
In reply to Stefano StabelliniIntroduce a Versatile Express specific function to read/write motherboard settings.
Changes in v5:
- actually include the Makefile.
Changes in v4:
- move the wait loop and the syscfg cfgctrl write into a separate function;
- fix comments;
- define all registers in write;
- move platform_vexpress.c to platforms/vexpress.c;
- move platform_vexpress.h to arm-arm/platforms/vexpress.h.
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/mode_switch.S | 2 +- xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/vexpress.c | 100 ++++++++++++++++++++++++++++++ xen/include/asm-arm/platform_vexpress.h | 17 ----- xen/include/asm-arm/platforms/vexpress.h | 40 ++++++++++++ 6 files changed, 143 insertions(+), 18 deletions(-) create mode 100644 xen/arch/arm/platforms/Makefile create mode 100644 xen/arch/arm/platforms/vexpress.c delete mode 100644 xen/include/asm-arm/platform_vexpress.h create mode 100644 xen/include/asm-arm/platforms/vexpress.h
xen/arch/arm/Makefile +1 -0
@@ -1,4 +1,5 @@ subdir-y += lib +subdir-y += platforms obj-y += dummy.o obj-y += early_printk.o
xen/arch/arm/mode_switch.S +1 -1
@@ -19,7 +19,7 @@ #include <asm/config.h> #include <asm/page.h> -#include <asm/platform_vexpress.h> +#include <asm/platforms/vexpress.h> #include <asm/asm_defns.h> #include "gic.h"
xen/arch/arm/platforms/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += vexpress.o
xen/arch/arm/platforms/vexpress.c new file +100 -0
100 lines not on this page · raw message
xen/include/asm-arm/platform_vexpress.h deleted +0 -17
@@ -1,17 +0,0 @@ -#ifndef __ASM_ARM_PLATFORM_H -#define __ASM_ARM_PLATFORM_H - -/* V2M */ -#define V2M_SYS_MMIO_BASE (0x1c010000) -#define V2M_SYS_FLAGSSET (0x30) -#define V2M_SYS_FLAGSCLR (0x34) - -#endif /* __ASM_ARM_PLATFORM_H */ -/* -* Local variables: -* mode: C -* c-set-style: "BSD" -* c-basic-offset: 4 -* indent-tabs-mode: nil -* End: -*/
xen/include/asm-arm/platforms/vexpress.h new file +40 -0
@@ -0,0 +1,40 @@ +#ifndef __ASM_ARM_PLATFORMS_VEXPRESS_H +#define __ASM_ARM_PLATFORMS_VEXPRESS_H + +/* V2M */ +#define V2M_SYS_MMIO_BASE (0x1c010000) +#define V2M_SYS_FLAGSSET (0x30) +#define V2M_SYS_FLAGSCLR (0x34) + +#define V2M_SYS_CFGDATA (0x00A0) +#define V2M_SYS_CFGCTRL (0x00A4) +#define V2M_SYS_CFGSTAT (0x00A8) + +#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_PLATFORMS_VEXPRESS_H */ +/* +* Local variables: +* mode: C +* c-set-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
1.7.2.5
PATCH v5 10/10 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 v4:
- use a lookup table to set the color masks;
- fix indentation;
- make sure mode_string is not NULL and is not bigger than 16 chars before continuing;
- introduce 2 separate error messages for !hdlcd_start and !framebuffer_start at the beginning of video_init;
- mark get_color_masks and set_pixclock as __init;
- check that we are running on a vexpress machine before calling vexpress_syscfg.
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 | 276 +++++++++++++++++++++++++++++++++++++++++ xen/drivers/video/modelines.h | 77 ++++++++++++ xen/include/asm-arm/config.h | 2 + 5 files changed, 357 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) += lfb.o obj-$(HAS_VGA) += vesa.o +obj-$(HAS_ARM_HDLCD) += arm_hdlcd.o
xen/drivers/video/arm_hdlcd.c new file +276 -0
276 lines not on this page · raw message
xen/drivers/video/modelines.h new file +77 -0
77 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