[PATCH 0/7] Raspberry Pi updates to boot by U-boot and preparation for GSoC 2016
From: Pavel Pisa Patches required to boot by U-boot * bsps/arm: CP15 support for flush prefetch buffer and table base control. * arm/raspberrypi: ensure that RTEMS application image can be started by U-boot. Correction of weirdness * arm/raspberrypi: correct GPIO pin function selection. * arm/raspberrypi: add locking around GPIO pin function selection. Apply library parts of GSoC 2015 project to add RPi VideoCore support * arm/raspberrypi: add VideoCore mailbox support read and write * arm/raspberrypi: add VideoCore frame buffer control support * arm/raspberrypi: add cmdline support for rpi bsp. The more pending patches with page table translation update to support VideoCore and VideoCore initialization needs to decide about final page table location and then more testing. I have tested updated master only with Raspberry Pi 1 and U-boot. It would be great if somebody with version 2 test them as well. Be carefull, actual Newlib snapshot based toolchain can be broken in strlen() support for ARMv6 architecture. Actual NewLib GIT contains fix. Sumamry Pavel Pisa (5): bsps/arm: CP15 support for flush prefetch buffer and table base control. arm/raspberrypi: ensure that RTEMS application image can be started by U-boot. arm/raspberrypi: correct GPIO pin function selection. arm/raspberrypi: add locking around GPIO pin function selection. arm/raspberrypi: add cmdline support for rpi bsp. YANG Qiao (2): arm/raspberrypi: add VideoCore mailbox support read and write arm/raspberrypi: add VideoCore frame buffer control support c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 9 + c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c | 23 +- c/src/lib/libbsp/arm/raspberrypi/include/bsp.h | 6 + c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h | 32 ++ .../libbsp/arm/raspberrypi/include/raspberrypi.h | 49 +++ .../lib/libbsp/arm/raspberrypi/include/rpi-gpio.h | 3 +- c/src/lib/libbsp/arm/raspberrypi/include/vc.h | 140 +++ c/src/lib/libbsp/arm/raspberrypi/irq/irq.c | 4 + c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c| 56 +++ c/src/lib/libbsp/arm/raspberrypi/misc/vc.c | 248 c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h | 436 + c/src/lib/libbsp/arm/raspberrypi/preinstall.am | 8 + .../libbsp/arm/raspberrypi/startup/bspstarthooks.c | 36 +- c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c | 47 +++ c/src/lib/libcpu/arm/shared/include/arm-cp15.h | 48 +++ 15 files changed, 1134 insertions(+), 11 deletions(-) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/vc.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/misc/vc.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 1/7] bsps/arm: CP15 support for flush prefetch buffer and table base control.
From: Pavel Pisa --- c/src/lib/libcpu/arm/shared/include/arm-cp15.h | 48 ++ 1 file changed, 48 insertions(+) diff --git a/c/src/lib/libcpu/arm/shared/include/arm-cp15.h b/c/src/lib/libcpu/arm/shared/include/arm-cp15.h index 76b0582..4c1966d 100644 --- a/c/src/lib/libcpu/arm/shared/include/arm-cp15.h +++ b/c/src/lib/libcpu/arm/shared/include/arm-cp15.h @@ -358,6 +358,37 @@ arm_cp15_set_translation_table_base(uint32_t *base) ); } +/* Translation Table Base Control Register - DDI0301H arm1176jzfs TRM 3.2.15 */ +ARM_CP15_TEXT_SECTION static inline uint32_t +*arm_cp15_get_translation_table_base_control_register(void) +{ + ARM_SWITCH_REGISTERS; + uint32_t ttb_cr; + + __asm__ volatile ( +ARM_SWITCH_TO_ARM +"mrc p15, 0, %[ttb_cr], c2, c0, 2\n" +ARM_SWITCH_BACK +: [ttb_cr] "=&r" (ttb_cr) ARM_SWITCH_ADDITIONAL_OUTPUT + ); + + return ttb_cr; +} + +ARM_CP15_TEXT_SECTION static inline void +arm_cp15_set_translation_table_base_control_register(uint32_t ttb_cr) +{ + ARM_SWITCH_REGISTERS; + + __asm__ volatile ( +ARM_SWITCH_TO_ARM +"mcr p15, 0, %[ttb_cr], c2, c0, 2\n" +ARM_SWITCH_BACK +: ARM_SWITCH_OUTPUT +: [ttb_cr] "r" (ttb_cr) + ); +} + ARM_CP15_TEXT_SECTION static inline uint32_t arm_cp15_get_domain_access_control(void) { @@ -858,6 +889,23 @@ arm_cp15_branch_predictor_invalidate_all(void) ); } +/* Flush Prefetch Buffer - DDI0301H arm1176jzfs TRM 3.2.22 */ +ARM_CP15_TEXT_SECTION static inline void +arm_cp15_flush_prefetch_buffer(void) +{ + ARM_SWITCH_REGISTERS; + uint32_t sbz = 0; + + __asm__ volatile ( +ARM_SWITCH_TO_ARM +"mcr p15, 0, %[sbz], c7, c5, 4\n" +ARM_SWITCH_BACK +: ARM_SWITCH_OUTPUT +: [sbz] "r" (sbz) +: "memory" + ); +} + ARM_CP15_TEXT_SECTION static inline void arm_cp15_instruction_cache_invalidate(void) { -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 4/7] arm/raspberrypi: add locking around GPIO pin function selection.
From: Pavel Pisa This is required if function or direction is changed by some driver after start of thread multitasking or in interrupts drivers. There can be problem with calling GPIO function selection before data section is initialized. But actual ticket lock implementation seems to be compatible even with memory initialized to zero oven on SMP. --- c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c | 5 + 1 file changed, 5 insertions(+) diff --git a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c index 40acd84..2788d36 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c +++ b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c @@ -21,6 +21,8 @@ #include +RTEMS_INTERRUPT_LOCK_DEFINE( static, rtems_gpio_bsp_lock, "rtems_gpio_bsp_lock" ); + /* Calculates a bitmask to assign an alternate function to a given pin. */ #define SELECT_PIN_FUNCTION(fn, pn) (fn << ((pn % 10) * 3)) @@ -56,11 +58,14 @@ static rtems_status_code rpi_select_pin_function( (pin / 10); uint32_t reg_old; uint32_t reg_new; + rtems_interrupt_lock_context lock_context; + rtems_interrupt_lock_acquire(&rtems_gpio_bsp_lock, &lock_context); reg_new = reg_old = *pin_addr; reg_new &= ~SELECT_PIN_FUNCTION(RPI_ALT_FUNC_MASK, pin); reg_new |= SELECT_PIN_FUNCTION(type, pin); *pin_addr = reg_new; + rtems_interrupt_lock_release(&rtems_gpio_bsp_lock, &lock_context); return RTEMS_SUCCESSFUL; } -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 5/7] arm/raspberrypi: add VideoCore mailbox support read and write
From: YANG Qiao --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 4 ++ c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h | 32 + .../libbsp/arm/raspberrypi/include/raspberrypi.h | 49 +++ c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c| 56 ++ c/src/lib/libbsp/arm/raspberrypi/preinstall.am | 4 ++ 5 files changed, 145 insertions(+) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index a092a28..2d74c68 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -48,6 +48,7 @@ include_bsp_HEADERS += include/raspberrypi.h include_bsp_HEADERS += include/rpi-gpio.h include_bsp_HEADERS += include/i2c.h include_bsp_HEADERS += include/spi.h +include_bsp_HEADERS += include/mailbox.h include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \ ../../../libcpu/arm/shared/include/arm-cp15.h @@ -112,6 +113,9 @@ libbsp_a_SOURCES += ../../shared/console_write.c libbsp_a_SOURCES += console/console-config.c libbsp_a_SOURCES += console/usart.c +# Mailbox +libbsp_a_SOURCES += misc/mailbox.c + # clock libbsp_a_SOURCES += clock/clockdrv.c ../../../shared/clockdrv_shell.h diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h b/c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h new file mode 100644 index 000..e6cb0f8 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/include/mailbox.h @@ -0,0 +1,32 @@ +/** + * @file + * + * @ingroup raspberrypi + * + * @brief mailbox support. + */ +/* + * Copyright (c) 2015 Yang Qiao + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.org/license/LICENSE + * + */ + +#ifndef LIBBSP_ARM_RASPBERRYPI_MAILBOX_H +#define LIBBSP_ARM_RASPBERRYPI_MAILBOX_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +extern unsigned int raspberrypi_mailbox_read(unsigned int channel); +extern void raspberrypi_mailbox_write(unsigned int channel, unsigned int data); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LIBBSP_ARM_RASPBERRYPI_MAILBOX_H */ diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h b/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h index 2a4d772..d6f00e8 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h @@ -9,6 +9,7 @@ /* * Copyright (c) 2014-2015 Andre Marques * Copyright (c) 2013 Alan Cudmore. + * Copyright (c) 2015 Yang Qiao * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -287,6 +288,54 @@ /** @} */ +/** +* @name Mailbox Registers +* +* @{ +*/ + +#define BCM2835_MBOX_BASE (RPI_PERIPHERAL_BASE+0xB880) + +#define BCM2835_MBOX_PEEK (BCM2835_MBOX_BASE+0x10) +#define BCM2835_MBOX_READ (BCM2835_MBOX_BASE+0x00) +#define BCM2835_MBOX_WRITE (BCM2835_MBOX_BASE+0x20) +#define BCM2835_MBOX_STATUS (BCM2835_MBOX_BASE+0x18) +#define BCM2835_MBOX_SENDER (BCM2835_MBOX_BASE+0x14) +#define BCM2835_MBOX_CONFIG (BCM2835_MBOX_BASE+0x1C) + +#define BCM2835_MBOX_FULL 0x8000 +#define BCM2835_MBOX_EMPTY 0x4000 + +/** @} */ + +/** +* @name Mailbox Channels +* +* @{ +*/ + +/* Power Manager channel */ +#define BCM2835_MBOX_CHANNEL_PM 0 +/* Framebuffer channel */ +#define BCM2835_MBOX_CHANNEL_FB 1 + /* Virtual UART channel */ +#define BCM2835_MBOX_CHANNEL_VUART 2 + /* VCHIQ channel */ +#define BCM2835_MBOX_CHANNEL_VCHIQ 3 + /* LEDs channel */ +#define BCM2835_MBOX_CHANNEL_LED4 + /* Button channel */ +#define BCM2835_MBOX_CHANNEL_BUTTON 5 + /* Touch screen channel */ +#define BCM2835_MBOX_CHANNEL_TOUCHS 6 +/* Property tags (ARM <-> VC) channel */ +#define BCM2835_MBOX_CHANNEL_PROP_AVC 8 + /* Property tags (VC <-> ARM) channel */ +#define BCM2835_MBOX_CHANNEL_PROP_VCA 9 + +/** @} */ + + /** @} */ #endif /* LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H */ diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c b/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c new file mode 100644 index 000..9d70c72 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c @@ -0,0 +1,56 @@ +/** + * @file + * + * @ingroup raspberrypi + * + * @brief mailbox support. + */ +/* + * Copyright (c) 2015 Yang Qiao + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.org/license/LICENSE + * + */ + +#include +#include +#include +#include + +#define BCM2835_MBOX_DATA_MASK(data) (data & 0xFFF0U) +#define BCM2835_MBOX_CHANNEL_MASK(data) (data & 0xFU) + +static inline bool bcm2835_mailbox_is_empty(void) +
[PATCH 2/7] arm/raspberrypi: ensure that RTEMS application image can be started by U-boot.
From: Pavel Pisa The current versions of U-boot start kernel/RTEMS application image with instruction and data caches enabled and it sets exception base register to new address after its self-relocation. ldr r0, [r9, #GD_RELOCADDR] /* r0 = gd->relocaddr */ mcr p15, 0, r0, c12, c0, 0 /* Set VBAR */ Included changes in bsp_start_hook_0 restore default state to allow RTEMS image to run after startup from newer U-boot version on Raspberry Pi. Clear interrupt enable registers in interrupt controller to ensure that RTEMS starts from well defined state. --- c/src/lib/libbsp/arm/raspberrypi/irq/irq.c | 4 +++ .../libbsp/arm/raspberrypi/startup/bspstarthooks.c | 36 +- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c b/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c index 0867b6b..96b16fb 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c +++ b/c/src/lib/libbsp/arm/raspberrypi/irq/irq.c @@ -207,5 +207,9 @@ void bsp_interrupt_handler_default(rtems_vector_number vector) rtems_status_code bsp_interrupt_facility_initialize(void) { raspberrypi_set_exception_handler(ARM_EXCEPTION_IRQ, _ARMV4_Exception_interrupt); + BCM2835_REG(BCM2835_IRQ_DISABLE1) = 0x; + BCM2835_REG(BCM2835_IRQ_DISABLE2) = 0x; + BCM2835_REG(BCM2835_IRQ_DISABLE_BASIC) = 0x; + BCM2835_REG(BCM2835_IRQ_FIQ_CTRL) = 0; return RTEMS_SUCCESSFUL; } diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c index 047c8ad..d44be03 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c +++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c @@ -26,11 +26,45 @@ #include #include #include +#include void BSP_START_TEXT_SECTION bsp_start_hook_0(void) { -} + uint32_t sctlr_val; + + sctlr_val = arm_cp15_get_control(); + + /* + * Current U-boot loader seems to start kernel image + * with I and D caches on and MMU enabled. + * If RTEMS application image finds that cache is on + * during startup then disable caches. + */ + if (sctlr_val & (ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M)) { +if (sctlr_val & (ARM_CP15_CTRL_C | ARM_CP15_CTRL_M)) { + /* + * If the data cache is on then ensure that it is clean + * before switching off to be extra carefull. + */ + arm_cp15_drain_write_buffer(); + arm_cp15_data_cache_clean_and_invalidate(); +} +arm_cp15_flush_prefetch_buffer(); +sctlr_val &= ~(ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M | ARM_CP15_CTRL_A); +arm_cp15_set_control(sctlr_val); +arm_cp15_tlb_invalidate(); +arm_cp15_flush_prefetch_buffer(); +arm_cp15_data_cache_invalidate(); +arm_cp15_instruction_cache_invalidate(); + } + + /* Clear Translation Table Base Control Register */ + arm_cp15_set_translation_table_base_control_register(0); + + /* Clear Secure or Non-secure Vector Base Address Register */ + arm_cp15_set_vector_base_address(0); +} void BSP_START_TEXT_SECTION bsp_start_hook_1(void) { -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 3/7] arm/raspberrypi: correct GPIO pin function selection.
From: Pavel Pisa Original implementation does only bitwise-or with previous register value for all functions except IN. Switch from one to other function would lead to incorrect value. --- c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c| 18 +- c/src/lib/libbsp/arm/raspberrypi/include/rpi-gpio.h | 3 ++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c index 642666a..40acd84 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c +++ b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c @@ -52,15 +52,15 @@ static rtems_status_code rpi_select_pin_function( uint32_t type ) { /* Calculate the pin function select register address. */ - volatile unsigned int *pin_addr = (unsigned int *) BCM2835_GPIO_REGS_BASE + -(pin / 10); - - if ( type == RPI_DIGITAL_IN ) { -*(pin_addr) &= ~SELECT_PIN_FUNCTION(RPI_DIGITAL_IN, pin); - } - else { -*(pin_addr) |= SELECT_PIN_FUNCTION(type, pin); - } + volatile uint32_t *pin_addr = (uint32_t *) BCM2835_GPIO_REGS_BASE + + (pin / 10); + uint32_t reg_old; + uint32_t reg_new; + + reg_new = reg_old = *pin_addr; + reg_new &= ~SELECT_PIN_FUNCTION(RPI_ALT_FUNC_MASK, pin); + reg_new |= SELECT_PIN_FUNCTION(type, pin); + *pin_addr = reg_new; return RTEMS_SUCCESSFUL; } diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/rpi-gpio.h b/c/src/lib/libbsp/arm/raspberrypi/include/rpi-gpio.h index 7f4d802..82ba4b1 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/rpi-gpio.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/rpi-gpio.h @@ -26,7 +26,7 @@ extern "C" { /** * @brief Raspberry Pi GPIO functions. */ -#define RPI_DIGITAL_IN 7 +#define RPI_DIGITAL_IN 0 #define RPI_DIGITAL_OUT 1 #define RPI_ALT_FUNC_0 4 #define RPI_ALT_FUNC_1 5 @@ -34,6 +34,7 @@ extern "C" { #define RPI_ALT_FUNC_3 7 #define RPI_ALT_FUNC_4 3 #define RPI_ALT_FUNC_5 2 +#define RPI_ALT_FUNC_MASK 7 /** * @brief Setups a JTAG interface. -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 6/7] arm/raspberrypi: add VideoCore frame buffer control support
From: YANG Qiao --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 4 + c/src/lib/libbsp/arm/raspberrypi/include/vc.h | 140 +++ c/src/lib/libbsp/arm/raspberrypi/misc/vc.c | 248 c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h | 436 + c/src/lib/libbsp/arm/raspberrypi/preinstall.am | 4 + 5 files changed, 832 insertions(+) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/vc.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/misc/vc.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/misc/vc_defines.h diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index 2d74c68..91f327e 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -49,6 +49,7 @@ include_bsp_HEADERS += include/rpi-gpio.h include_bsp_HEADERS += include/i2c.h include_bsp_HEADERS += include/spi.h include_bsp_HEADERS += include/mailbox.h +include_bsp_HEADERS += include/vc.h include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \ ../../../libcpu/arm/shared/include/arm-cp15.h @@ -116,6 +117,9 @@ libbsp_a_SOURCES += console/usart.c # Mailbox libbsp_a_SOURCES += misc/mailbox.c +# VideoCore +libbsp_a_SOURCES += misc/vc.c + # clock libbsp_a_SOURCES += clock/clockdrv.c ../../../shared/clockdrv_shell.h diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/vc.h b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h new file mode 100644 index 000..4e91fde --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/include/vc.h @@ -0,0 +1,140 @@ +/** + * @file + * + * @ingroup raspberrypi_vc + * + * @brief video core support. + * + */ + +/* + * Copyright (c) 2015 Yang Qiao + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.org/license/LICENSE + * + */ + +#ifndef LIBBSP_ARM_RASPBERRYPI_VC_H +#define LIBBSP_ARM_RASPBERRYPI_VC_H + +/** + * @defgroup raspberrypi_vc Register Definitions + * + * @ingroup arm_raspberrypi + * + * @brief Register Definitions + * + * @{ + */ + +typedef struct +{ + uint32_t width; + uint32_t height; +} bcm2835_get_display_size_entries; + +int +bcm2835_mailbox_get_display_size(bcm2835_get_display_size_entries* _entries); + + +typedef enum +{ + bcm2835_mailbox_pixel_order_bgr = 0, + bcm2835_mailbox_pixel_order_rgb = 1 +} bcm2835_pixel_order; + +typedef enum +{ + bcm2835_mailbox_alpha_mode_0_opaque = 0, + bcm2835_mailbox_alpha_mode_0_transparent = 1, + bcm2835_mailbox_alpha_mode_ignored= 2 +} bcm2835_alpha_mode; + +typedef struct +{ + uint32_t xres; + uint32_t yres; + uint32_t xvirt; + uint32_t yvirt; + uint32_t depth; + bcm2835_pixel_order pixel_order; + bcm2835_alpha_mode alpha_mode; + uint32_t voffset_x; + uint32_t voffset_y; + uint32_t overscan_left; + uint32_t overscan_right; + uint32_t overscan_top; + uint32_t overscan_bottom; + uint32_t base; + size_t size; + uint32_t pitch; +} bcm2835_init_frame_buffer_entries; + +int +bcm2835_mailbox_init_frame_buffer(bcm2835_init_frame_buffer_entries* _entries); + +typedef struct +{ + uint32_t pitch; +}bcm2835_get_pitch_entries; + +int +bcm2835_mailbox_get_pitch(bcm2835_get_pitch_entries* _entries); + +typedef struct +{ + char cmdline[1024]; +} bcm2835_get_cmdline_entries; + +int +bcm2835_mailbox_get_cmdline(bcm2835_get_cmdline_entries* _entries); + +typedef enum +{ + bcm2835_mailbox_power_udid_sd_card = 0xu, + bcm2835_mailbox_power_udid_uart0 = 0x0001u, + bcm2835_mailbox_power_udid_uart1 = 0x0002u, + bcm2835_mailbox_power_udid_usb_hcd = 0x0003u, + bcm2835_mailbox_power_udid_i2c0 = 0x0004u, + bcm2835_mailbox_power_udid_i2c1 = 0x0005u, + bcm2835_mailbox_power_udid_i2c2 = 0x0006u, + bcm2835_mailbox_power_udid_spi = 0x0007u, + bcm2835_mailbox_power_udid_ccp2tx = 0x0008u, +} bcm2835_power_device_id; + +typedef struct +{ + bcm2835_power_device_id dev_id; + uint32_t state; +} bcm2835_set_power_state_entries; + +#define BCM2835_MAILBOX_SET_POWER_STATE_REQ_ON(1 << 0) +#define BCM2835_MAILBOX_SET_POWER_STATE_REQ_WAIT (1 << 1) +#define BCM2835_MAILBOX_POWER_STATE_ON (1 << 0) +#define BCM2835_MAILBOX_POWER_STATE_NODEV(1 << 1) +int +bcm2835_mailbox_set_power_state(bcm2835_set_power_state_entries* _entries); + +typedef struct +{ + uint32_t base; + size_t size; +}bcm2835_get_arm_memory_entries; + +int +bcm2835_mailbox_get_arm_memory(bcm2835_get_arm_memory_entries* _entries); + +typedef struct +{ + uint32_t base; + size_t size; +}bcm2835_get_vc_memory_entries; + +int +bcm2835_mailbox_get_vc_memory(bcm2835_get_vc_memory_entries* _entries); +/** @} */ + +#endif /* LIBBSP_ARM_RASPBERRYPI_VC_H */ diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c new file mode 100644 index 000..9c89fab --- /dev/null +++ b/c/src/lib/libbsp/arm/rasp
[PATCH 7/7] arm/raspberrypi: add cmdline support for rpi bsp.
From: Pavel Pisa --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 1 + c/src/lib/libbsp/arm/raspberrypi/include/bsp.h | 6 +++ c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c | 47 ++ 3 files changed, 54 insertions(+) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index 91f327e..258f8a0 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -95,6 +95,7 @@ libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c # Startup libbsp_a_SOURCES += ../../shared/bspreset_loop.c libbsp_a_SOURCES += startup/bspstart.c +libbsp_a_SOURCES += startup/cmdline.c # IRQ libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h index 0abeed6..18a94ea 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h @@ -7,6 +7,7 @@ */ /* + * Copyright (c) 2015 Yang Qiao * Copyright (c) 2013 Alan Cudmore * * The license and distribution terms for this file may be @@ -35,6 +36,11 @@ extern "C" { #define BSP_GPIO_PINS_PER_BANK 32 #define BSP_GPIO_PINS_PER_SELECT_BANK 10 +void rpi_init_cmdline(void); +const char *rpi_cmdline_get_cached(void); +const char *rpi_cmdline_get_raw(void); +const char *rpi_cmdline_get_arg(const char* arg); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c b/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c new file mode 100644 index 000..f8a7182 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c @@ -0,0 +1,47 @@ +/** + * @file + * + * @ingroup raspberrypi + * + * @brief mailbox support. + */ +/* + * Copyright (c) 2015 Yang Qiao + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.org/license/LICENSE + * + */ + +#include +#include + +#define MAX_CMDLINE_LENGTH 1024 +static int rpi_cmdline_ready; +static char rpi_cmdline_cached[MAX_CMDLINE_LENGTH]; +static bcm2835_get_cmdline_entries rpi_cmdline_entries; + +const char *rpi_cmdline_get_raw(void) +{ + memset(&rpi_cmdline_entries, 0, sizeof(rpi_cmdline_entries)); + bcm2835_mailbox_get_cmdline(&rpi_cmdline_entries); + return rpi_cmdline_entries.cmdline; +} + +const char *rpi_cmdline_get_cached(void) +{ + if (!rpi_cmdline_ready) { +const char *line = rpi_cmdline_get_raw(); +strncpy(rpi_cmdline_cached, line, MAX_CMDLINE_LENGTH - 1); +rpi_cmdline_cached[MAX_CMDLINE_LENGTH - 1] = 0; +rpi_cmdline_ready = 1; + } + return rpi_cmdline_cached; +} + +const char *rpi_cmdline_get_arg(const char* arg) +{ + return strstr (rpi_cmdline_get_cached(), arg); +} -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 0/5] Raspberry Pi VideoCore support for console on HDMI output
From: Pavel Pisa The series updates and cleans YANG Qiao GSoC 2015 work for actual RTEMS 4.12 development version. The changes require that VideoCore firmware is running even if video output is not used because mailbox based communication with VideoCore is used to obtain SD command line parameters passed to the RTEMS application image and to limit RTEMS RAM workarea to not go beyond VideoCore assigned memory start. The two options configurable by "cmdline.txt" file read and made accessible by VideoCore firmware are present --video= possible values auto - select mode automatically according to the connected monitor off (or none) - disable video support width x height with optional bpp - for example 800x600 or 800x600-32 --console= fbcons - redirect RTEMS console output to the connected monitor if --video= is not specified/enabled or monitor is not detected then output stays to be connected to the UART Typical "cmdline.txt" content for testing --video=auto --console=fbcons WARNING: the used VideoCore service for command line arguments retrieval returns only these arguments setup in "cmdline.txt". Arguments provided to U-boot or other loader are ignored. Code has been tested or Raspberry Pi 1 with U-boot + TFTP and with direct boot from SD card with and without monitor connected. Pavel Pisa (2): arm/raspberrypi: cmdline enhancement and early access workaround. arm/raspberrypi: move MMU in front of application image to respect variable memory size. YANG Qiao (3): arm/raspberrypi: add VideoCore framebuffer without initialization arm/raspberrypi: add video outchar support for rpi bsp arm/raspberrypi: add fbcons support for rpi bsp c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 13 +- .../arm/raspberrypi/console/console-config.c | 12 +- .../arm/raspberrypi/console/console_select.c | 114 + c/src/lib/libbsp/arm/raspberrypi/console/fb.c | 385 ++ c/src/lib/libbsp/arm/raspberrypi/console/fbcons.c | 184 + c/src/lib/libbsp/arm/raspberrypi/console/fbcons.h | 47 + .../lib/libbsp/arm/raspberrypi/console/font_data.h | 4639 c/src/lib/libbsp/arm/raspberrypi/console/outch.c | 411 ++ c/src/lib/libbsp/arm/raspberrypi/include/bsp.h |9 + c/src/lib/libbsp/arm/raspberrypi/include/rpi-fb.h | 53 + c/src/lib/libbsp/arm/raspberrypi/preinstall.am |8 + .../arm/raspberrypi/startup/bspgetworkarea.c | 74 + .../libbsp/arm/raspberrypi/startup/bspstarthooks.c |4 + c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c | 12 +- c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds |6 +- c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c | 31 + 16 files changed, 5991 insertions(+), 11 deletions(-) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/console_select.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fb.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fbcons.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fbcons.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/font_data.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/outch.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/rpi-fb.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 2/5] arm/raspberrypi: add VideoCore framebuffer without initialization
From: YANG Qiao --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 2 + c/src/lib/libbsp/arm/raspberrypi/console/fb.c | 385 ++ c/src/lib/libbsp/arm/raspberrypi/include/rpi-fb.h | 53 +++ c/src/lib/libbsp/arm/raspberrypi/preinstall.am| 4 + 4 files changed, 444 insertions(+) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fb.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/rpi-fb.h diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index 258f8a0..285da4f 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -50,6 +50,7 @@ include_bsp_HEADERS += include/i2c.h include_bsp_HEADERS += include/spi.h include_bsp_HEADERS += include/mailbox.h include_bsp_HEADERS += include/vc.h +include_bsp_HEADERS += include/rpi-fb.h include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \ ../../../libcpu/arm/shared/include/arm-cp15.h @@ -114,6 +115,7 @@ libbsp_a_SOURCES += ../../shared/console_select.c libbsp_a_SOURCES += ../../shared/console_write.c libbsp_a_SOURCES += console/console-config.c libbsp_a_SOURCES += console/usart.c +libbsp_a_SOURCES += console/fb.c # Mailbox libbsp_a_SOURCES += misc/mailbox.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/fb.c b/c/src/lib/libbsp/arm/raspberrypi/console/fb.c new file mode 100644 index 000..ba285e7 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/console/fb.c @@ -0,0 +1,385 @@ +/** + * @file + * + * @ingroup raspberrypi + * + * @brief framebuffer support. + */ + +/* + * Copyright (c) 2015 Yang Qiao + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.org/license/LICENSE + * + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#define SCREEN_WIDTH 1024 +#define SCREEN_HEIGHT 768 +#define BPP 32 + +/* flag to limit driver to protect against multiple opens */ +static Atomic_Flag driver_mutex; + +/* + * screen information for the driver (fb0). + */ + +static struct fb_var_screeninfo fb_var_info = { + .xres= SCREEN_WIDTH, + .yres= SCREEN_HEIGHT, + .bits_per_pixel = BPP +}; + +static struct fb_fix_screeninfo fb_fix_info = { + .smem_start = (void *) NULL, + .smem_len= 0, + .type= FB_TYPE_PACKED_PIXELS, + .visual = FB_VISUAL_TRUECOLOR, + .line_length = 0 +}; + +typedef enum { +NO_SUITABLE_MODE= -1, +BAD_FORMAT = -2, +AUTO_SELECT = -3, +DONT_INIT = -4, +NO_MODE_REQ = -5, +} mode_err_ret_val; + +int raspberrypi_get_fix_screen_info( struct fb_fix_screeninfo *info ) +{ + *info = fb_fix_info; + return 0; +} + +int raspberrypi_get_var_screen_info( struct fb_var_screeninfo *info ) +{ + *info = fb_var_info; + return 0; +} + +/** + * @brief Find mode given in string format. + * + * expected format + * x[-] + * numbers , and are decadic + * + * @param[out] fb_var_ptr pointer to variable mode part filled by function + * @param[in] video_string string to be parsed + * @retval video mode number to be set + * @retval -1 no suitable mode found + * @retval -2 bad format of the video_string + * @retval -3 automatic mode selection requested + * @retval -4 request to not initialize graphics + * @retval -5 no mode requested/empty video string + */ + +static int +parse_mode_from_string(struct fb_var_screeninfo *fb_var_ptr, + const char *video_string) +{ + const char* opt; + char* endptr; + uint32_t width; + uint32_t height; + uint32_t bpp = 0; + + opt = video_string; + + if (opt == NULL) +return NO_MODE_REQ; + if (strncmp(opt, "auto", 4) == 0) +return AUTO_SELECT; + if (strncmp(opt, "none", 4) == 0 || + strncmp(opt, "off", 3) == 0) +return DONT_INIT; + + width = strtol(opt, &endptr, 10); + if (*endptr != 'x') + { +return BAD_FORMAT; + } + opt = endptr + 1; + height = strtol(opt, &endptr, 10); + switch (*endptr) + { +case '-': + opt = endptr + 1; + endptr = NULL; + bpp = strtol(opt, &endptr, 10); + if ((endptr == opt) || (endptr == NULL)) +return BAD_FORMAT; + if (*endptr && (*endptr != ' ')) +return BAD_FORMAT; + break; +case ' ': +case 0: + break; +default: + return BAD_FORMAT; + } + + fb_var_ptr->xres= width; + fb_var_ptr->yres= height; + if (bpp != 0) +fb_var_ptr->bits_per_pixel = bpp; + + return 0; +} + +static int +find_mode_from_vc(void) +{ + bcm2835_get_display_size_entries entries; + bcm2835_mailbox_get_display_size(&entries); + unsigned int width = entries.width; + unsigned int height = entries.height; + + if (width == 0 || height == 0) +
[PATCH 3/5] arm/raspberrypi: move MMU in front of application image to respect variable memory size.
From: Pavel Pisa The page table is placed at address 0x4000 which provides required 16 kB space till the start of application image. The RAM size specified in a linker script is upper limit address of RAM utilized for the work area initialization. If VideoCore reports to use lower address than expected then work area size is adjusted (shrinked) appropriately. --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 4 +- c/src/lib/libbsp/arm/raspberrypi/include/bsp.h | 2 + .../arm/raspberrypi/startup/bspgetworkarea.c | 74 ++ c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds | 6 +- c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c | 31 + 5 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index 285da4f..3373d08 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -83,7 +83,6 @@ libbsp_a_LIBADD = # Shared libbsp_a_SOURCES += ../../shared/bootcard.c libbsp_a_SOURCES += ../../shared/bspclean.c -libbsp_a_SOURCES += ../../shared/bspgetworkarea.c libbsp_a_SOURCES += ../../shared/bsppredriverhook.c libbsp_a_SOURCES += ../../shared/cpucounterread.c libbsp_a_SOURCES += ../../shared/cpucounterdiff.c @@ -97,6 +96,7 @@ libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c libbsp_a_SOURCES += ../../shared/bspreset_loop.c libbsp_a_SOURCES += startup/bspstart.c libbsp_a_SOURCES += startup/cmdline.c +libbsp_a_SOURCES += startup/bspgetworkarea.c # IRQ libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c @@ -153,7 +153,7 @@ libbsp_a_SOURCES += startup/bspstarthooks.c # LIBMM libbsp_a_SOURCES += startup/mm_config_table.c -libbsp_a_SOURCES += ../shared/mminit.c +libbsp_a_SOURCES += startup/mminit.c ### # Network# diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h index 18a94ea..c6cd571 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h @@ -32,6 +32,8 @@ extern "C" { #define BSP_FEATURE_IRQ_EXTENSION +#define RPI_L2_CACHE_ENABLE 1 + #define BSP_GPIO_PIN_COUNT 32 #define BSP_GPIO_PINS_PER_BANK 32 #define BSP_GPIO_PINS_PER_SELECT_BANK 10 diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c new file mode 100644 index 000..bb81437 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c @@ -0,0 +1,74 @@ +/** + * @file + * + * @ingroup arm_start + * + * @brief Raspberry pi workarea initialization. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2011-2012 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * Copyright (c) 2015 YANG Qiao + * + * Code is based on c/src/lib/libbsp/shared/bspgetworkarea.c + */ + +#include +#include +#include +#ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN + #include +#endif + +#if defined(HAS_UBOOT) && !defined(BSP_DISABLE_UBOOT_WORK_AREA_CONFIG) + #define USE_UBOOT +#endif + +/* + * These are provided by the linkcmds for ALL of the BSPs which use this file. + */ +extern char WorkAreaBase[]; + +/* + * We may get the size information from U-Boot or the linker scripts. + */ +#ifdef USE_UBOOT + #include +#else + extern char RamBase[]; + extern char RamSize[]; +#endif + +void bsp_work_area_initialize(void) +{ + uintptr_t work_base = (uintptr_t) WorkAreaBase; + uintptr_t ram_end; + bcm2835_get_vc_memory_entries vc_entry; + /* + * bcm2835_get_arm_memory_entries arm_entry; + * is another alternative how to obtain usable memory size + */ + + #ifdef USE_UBOOT +ram_end = (uintptr_t) bsp_uboot_board_info.bi_memstart + + bsp_uboot_board_info.bi_memsize; + #else +ram_end = (uintptr_t)RamBase + (uintptr_t)RamSize; + #endif + + #ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN +work_base += rtems_configuration_get_interrupt_stack_size(); + #endif + + bcm2835_mailbox_get_vc_memory(&vc_entry); + ram_end = ram_end > vc_entry.base? vc_entry.base: ram_end; + bsp_work_area_initialize_default( (void *) work_base, ram_end - work_base ); +} diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds index f1ad11c..fc72b5c 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds +++ b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds @@ -36,9 +36,9 @@ */
[PATCH 4/5] arm/raspberrypi: add video outchar support for rpi bsp
From: YANG Qiao --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am |3 + .../lib/libbsp/arm/raspberrypi/console/font_data.h | 4639 c/src/lib/libbsp/arm/raspberrypi/console/outch.c | 411 ++ c/src/lib/libbsp/arm/raspberrypi/include/bsp.h |4 + 4 files changed, 5057 insertions(+) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/font_data.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/outch.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index 3373d08..f5b87ab 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -26,6 +26,8 @@ nodist_include_HEADERS = ../../shared/include/coverhd.h \ nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h +noinst_HEADERS = console/font_data.h + include_bsp_HEADERS = include_bsp_HEADERS += ../../../libbsp/shared/include/mm.h include_bsp_HEADERS += ../../shared/include/utility.h @@ -116,6 +118,7 @@ libbsp_a_SOURCES += ../../shared/console_write.c libbsp_a_SOURCES += console/console-config.c libbsp_a_SOURCES += console/usart.c libbsp_a_SOURCES += console/fb.c +libbsp_a_SOURCES += console/outch.c # Mailbox libbsp_a_SOURCES += misc/mailbox.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/font_data.h b/c/src/lib/libbsp/arm/raspberrypi/console/font_data.h new file mode 100644 index 000..852310c --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/console/font_data.h @@ -0,0 +1,4639 @@ +/** + * @file + * + * @ingroup raspberrypi + * + * @brief graphic text console font file + * + */ +/* + * Copyright (c) 2015 Yang Qiao + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.org/license/LICENSE + * + */ + +#ifndef LIBBSP_ARM_RASPBERRYPI_FONT_DATA_H +#define LIBBSP_ARM_RASPBERRYPI_FONT_DATA_H + +#define RPI_FONT_CHARS 256 +#define RPI_FONT_WIDTH 8 +#define RPI_FONT_HEIGHT 16 +#define RPI_FONT_SIZE (RPI_FONT_CHARS * RPI_FONT_HEIGHT) + +static unsigned char rpi_font[RPI_FONT_SIZE] = { + + /* 0 0x00 '^@' */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 1 0x01 '^A' */ + 0x00, /* */ + 0x00, /* */ + 0x7e, /* 0110 */ + 0x81, /* 1001 */ + 0xa5, /* 10100101 */ + 0x81, /* 1001 */ + 0x81, /* 1001 */ + 0xbd, /* 1001 */ + 0x99, /* 10011001 */ + 0x81, /* 1001 */ + 0x81, /* 1001 */ + 0x7e, /* 0110 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 2 0x02 '^B' */ + 0x00, /* */ + 0x00, /* */ + 0x7e, /* 0110 */ + 0xff, /* */ + 0xdb, /* 11011011 */ + 0xff, /* */ + 0xff, /* */ + 0xc3, /* 1111 */ + 0xe7, /* 11100111 */ + 0xff, /* */ + 0xff, /* */ + 0x7e, /* 0110 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 3 0x03 '^C' */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x6c, /* 01101100 */ + 0xfe, /* 1110 */ + 0xfe, /* 1110 */ + 0xfe, /* 1110 */ + 0xfe, /* 1110 */ + 0x7c, /* 0100 */ + 0x38, /* 00111000 */ + 0x10, /* 0001 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 4 0x04 '^D' */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x10, /* 0001 */ + 0x38, /* 00111000 */ + 0x7c, /* 0100 */ + 0xfe, /* 1110 */ + 0x7c, /* 0100 */ + 0x38, /* 00111000 */ + 0x10, /* 0001 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 5 0x05 '^E' */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x18, /* 00011000 */ + 0x3c, /* 0000 */ + 0x3c, /* 0000 */ + 0xe7, /* 11100111 */ + 0xe7, /* 11100111 */ + 0xe7, /* 11100111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 0000 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 6 0x06 '^F' */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x18, /* 00011000 */ + 0x3c, /* 0000 */ + 0x7e, /* 0110 */ + 0xff, /* */ + 0xff, /* */ + 0x7e, /* 0110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 0000 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* 00
[PATCH 1/5] arm/raspberrypi: cmdline enhancement and early access workaround.
From: Pavel Pisa cmdline argument is returned without option name. The calls to command line parsing can be called earlier before BSS is cleaned out. --- c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c b/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c index f8a7182..d585e31 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c +++ b/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c @@ -19,8 +19,8 @@ #include #define MAX_CMDLINE_LENGTH 1024 -static int rpi_cmdline_ready; -static char rpi_cmdline_cached[MAX_CMDLINE_LENGTH]; +static int rpi_cmdline_ready = -1; +static char rpi_cmdline_cached[MAX_CMDLINE_LENGTH] = "force .data placement"; static bcm2835_get_cmdline_entries rpi_cmdline_entries; const char *rpi_cmdline_get_raw(void) @@ -32,7 +32,7 @@ const char *rpi_cmdline_get_raw(void) const char *rpi_cmdline_get_cached(void) { - if (!rpi_cmdline_ready) { + if (rpi_cmdline_ready <= 0) { const char *line = rpi_cmdline_get_raw(); strncpy(rpi_cmdline_cached, line, MAX_CMDLINE_LENGTH - 1); rpi_cmdline_cached[MAX_CMDLINE_LENGTH - 1] = 0; @@ -43,5 +43,9 @@ const char *rpi_cmdline_get_cached(void) const char *rpi_cmdline_get_arg(const char* arg) { - return strstr (rpi_cmdline_get_cached(), arg); + const char *opt_data; + opt_data = strstr(rpi_cmdline_get_cached(), arg); + if (opt_data) +opt_data += strlen(arg); + return opt_data; } -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 5/5] arm/raspberrypi: add fbcons support for rpi bsp
From: YANG Qiao --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 4 +- .../arm/raspberrypi/console/console-config.c | 12 +- .../arm/raspberrypi/console/console_select.c | 114 + c/src/lib/libbsp/arm/raspberrypi/console/fbcons.c | 184 + c/src/lib/libbsp/arm/raspberrypi/console/fbcons.h | 47 ++ c/src/lib/libbsp/arm/raspberrypi/include/bsp.h | 3 + c/src/lib/libbsp/arm/raspberrypi/preinstall.am | 4 + .../libbsp/arm/raspberrypi/startup/bspstarthooks.c | 4 + 8 files changed, 370 insertions(+), 2 deletions(-) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/console_select.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fbcons.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fbcons.h diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index f5b87ab..e115745 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -53,6 +53,7 @@ include_bsp_HEADERS += include/spi.h include_bsp_HEADERS += include/mailbox.h include_bsp_HEADERS += include/vc.h include_bsp_HEADERS += include/rpi-fb.h +include_bsp_HEADERS += console/fbcons.h include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \ ../../../libcpu/arm/shared/include/arm-cp15.h @@ -113,11 +114,12 @@ libbsp_a_SOURCES += irq/irq.c libbsp_a_SOURCES += ../../shared/console.c libbsp_a_SOURCES += ../../shared/console_control.c libbsp_a_SOURCES += ../../shared/console_read.c -libbsp_a_SOURCES += ../../shared/console_select.c libbsp_a_SOURCES += ../../shared/console_write.c libbsp_a_SOURCES += console/console-config.c +libbsp_a_SOURCES += console/console_select.c libbsp_a_SOURCES += console/usart.c libbsp_a_SOURCES += console/fb.c +libbsp_a_SOURCES += console/fbcons.c libbsp_a_SOURCES += console/outch.c # Mailbox diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/console-config.c b/c/src/lib/libbsp/arm/raspberrypi/console/console-config.c index b948b77..dfb9826 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/console/console-config.c +++ b/c/src/lib/libbsp/arm/raspberrypi/console/console-config.c @@ -7,6 +7,8 @@ */ /* + * Copyright (c) 2015 Yang Qiao + * based on work by: * Copyright (c) 2013 Alan Cudmore * * The license and distribution terms for this file may be @@ -24,6 +26,7 @@ #include #include #include +#include console_tbl Console_Configuration_Ports [] = { { @@ -36,7 +39,14 @@ console_tbl Console_Configuration_Ports [] = { .ulCtrlPort2 = 0, .ulClock = USART0_DEFAULT_BAUD, .ulIntVector = BCM2835_IRQ_ID_UART -} +}, +{ + .sDeviceName ="/dev/fbcons", + .deviceType = SERIAL_CUSTOM, + .pDeviceFns = &fbcons_fns, + .deviceProbe = fbcons_probe, + .pDeviceFlow = NULL, +}, }; #define PORT_COUNT \ diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/console_select.c b/c/src/lib/libbsp/arm/raspberrypi/console/console_select.c new file mode 100644 index 000..2b5d872 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/console/console_select.c @@ -0,0 +1,114 @@ +/** + * @file + * + * @ingroup raspberrypi_console + * + * @brief console select + */ + +/* + * Copyright (c) 2015 Yang Qiao + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.org/license/LICENSE + * + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include "../../../shared/console_private.h" +#include + +rtems_device_minor_number BSPPrintkPort = 0; + +/* + * Method to return true if the device associated with the + * minor number probs available. + */ +static bool bsp_Is_Available( rtems_device_minor_number minor ) +{ + console_tbl *cptr = Console_Port_Tbl[minor]; + + /* + * First perform the configuration dependent probe, then the + * device dependent probe + */ + if ((!cptr->deviceProbe || cptr->deviceProbe(minor)) && + cptr->pDeviceFns->deviceProbe(minor)) { +return true; + } + return false; +} + +/* + * Method to return the first available device. + */ +static rtems_device_minor_number bsp_First_Available_Device( void ) +{ + rtems_device_minor_number minor; + + for (minor=0; minor < Console_Port_Count ; minor++) { +console_tbl *cptr = Console_Port_Tbl[minor]; + +/* + * First perform the configuration dependent probe, then the + * device dependent probe + */ + +if ((!cptr->deviceProbe || cptr->deviceProbe(minor)) && + cptr->pDeviceFns->deviceProbe(minor)) { + return minor; +} + } + + /* + * Error No devices were found. We will want to bail here. + */ + bsp_fatal(BSP_FATAL_CONSOLE_NO_DEV); +} + +void bsp_console_select(void) +{ + + /* + * Reset Console_Port_Minor and + * BSPPrintkPort here if desired. + * + * This default
[PATCH v2 1/7] arm/raspberrypi: cmdline enhancement and early access workaround.
From: Pavel Pisa cmdline argument is returned without option name. The calls to command line parsing can be called earlier before BSS is cleaned out. --- c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c b/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c index f8a7182..d585e31 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c +++ b/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c @@ -19,8 +19,8 @@ #include #define MAX_CMDLINE_LENGTH 1024 -static int rpi_cmdline_ready; -static char rpi_cmdline_cached[MAX_CMDLINE_LENGTH]; +static int rpi_cmdline_ready = -1; +static char rpi_cmdline_cached[MAX_CMDLINE_LENGTH] = "force .data placement"; static bcm2835_get_cmdline_entries rpi_cmdline_entries; const char *rpi_cmdline_get_raw(void) @@ -32,7 +32,7 @@ const char *rpi_cmdline_get_raw(void) const char *rpi_cmdline_get_cached(void) { - if (!rpi_cmdline_ready) { + if (rpi_cmdline_ready <= 0) { const char *line = rpi_cmdline_get_raw(); strncpy(rpi_cmdline_cached, line, MAX_CMDLINE_LENGTH - 1); rpi_cmdline_cached[MAX_CMDLINE_LENGTH - 1] = 0; @@ -43,5 +43,9 @@ const char *rpi_cmdline_get_cached(void) const char *rpi_cmdline_get_arg(const char* arg) { - return strstr (rpi_cmdline_get_cached(), arg); + const char *opt_data; + opt_data = strstr(rpi_cmdline_get_cached(), arg); + if (opt_data) +opt_data += strlen(arg); + return opt_data; } -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 0/7] Raspberry Pi VideoCore support for console on HDMI output
From: Pavel Pisa The series updates and cleans YANG Qiao GSoC 2015 work for actual RTEMS 4.12 development version. The changes require that VideoCore firmware is running even if video output is not used because mailbox based communication with VideoCore is used to obtain SD command line parameters passed to the RTEMS application image and to limit RTEMS RAM workarea to not go beyond VideoCore assigned memory start. The two options configurable by "cmdline.txt" file read and made accessible by VideoCore firmware are present --video= possible values auto - select mode automatically according to the connected monitor off (or none) - disable video support width x height with optional bpp - for example 800x600 or 800x600-32 --console= fbcons - redirect RTEMS console output to the connected monitor if --video= is not specified/enabled or monitor is not detected then output stays to be connected to the UART Typical "cmdline.txt" content for testing --video=auto --console=fbcons WARNING: the used VideoCore service for command line arguments retrieval returns only these arguments setup in "cmdline.txt". Arguments provided to U-boot or other loader are ignored. Code has been tested or Raspberry Pi 1 with U-boot + TFTP and with direct boot from SD card with and without monitor connected. Code tested to not break standard serial console output for Raspberry Pi 2 on QEMU. Graphic output under QEMU results write abort because QEMU reported framebuffer size is not completely accessible, only 400 rows from 640x480 reported screen works for the given mode. [PATCH v2] Updates to v2 version - formatting of newly introduced files normalized by rtems.uncrustify - incorrect clean after release spot by Gedare Bloom corrected - HDMI monitor presence test commented (solution is not ideal but works and if some more straightforward solution is found in future, then it can be replaced) - atomic flag used to ensure framebuffer single open only is left in a place - more cleanups and adjustment of compatibility with RPi2 Pavel Pisa (4): arm/raspberrypi: cmdline enhancement and early access workaround. arm/raspberrypi: ensure that correct RPI_PERIPHERAL_BASE is provided by raspberrypi.h arm/raspberrypi: Raspberry Pi v2 ALLOCATE_BUFFER VC4 operation returns direct address. arm/raspberrypi: move MMU in front of application image to respect variable memory size. YANG Qiao (3): arm/raspberrypi: add VideoCore framebuffer without initialization arm/raspberrypi: add video outchar support for rpi bsp arm/raspberrypi: add fbcons support for rpi bsp c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 13 +- .../arm/raspberrypi/console/console-config.c | 12 +- .../arm/raspberrypi/console/console_select.c | 113 + c/src/lib/libbsp/arm/raspberrypi/console/fb.c | 409 ++ c/src/lib/libbsp/arm/raspberrypi/console/fbcons.c | 177 + c/src/lib/libbsp/arm/raspberrypi/console/fbcons.h | 47 + .../lib/libbsp/arm/raspberrypi/console/font_data.h | 4639 c/src/lib/libbsp/arm/raspberrypi/console/outch.c | 463 ++ c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c |1 + c/src/lib/libbsp/arm/raspberrypi/include/bsp.h |9 + .../libbsp/arm/raspberrypi/include/raspberrypi.h |1 + c/src/lib/libbsp/arm/raspberrypi/include/rpi-fb.h | 54 + c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c|1 + c/src/lib/libbsp/arm/raspberrypi/misc/timer.c |1 + c/src/lib/libbsp/arm/raspberrypi/misc/vc.c |4 + c/src/lib/libbsp/arm/raspberrypi/preinstall.am |8 + .../arm/raspberrypi/startup/bspgetworkarea.c | 77 + .../libbsp/arm/raspberrypi/startup/bspstarthooks.c |4 + c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c | 12 +- c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds |6 +- c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c | 31 + 21 files changed, 6071 insertions(+), 11 deletions(-) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/console_select.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fb.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fbcons.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fbcons.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/font_data.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/outch.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/rpi-fb.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 2/7] arm/raspberrypi: ensure that correct RPI_PERIPHERAL_BASE is provided by raspberrypi.h
From: Pavel Pisa If the raspberrypi.h has been included without preceding inclussion of bsp.h then BSP_IS_RPI2 has not been set for Raspberry Pi 2 BSP variant and bad things happen later. The patch includes bspopts.h by raspberrypi.h and even includes bsp.h in critical peripherals support. --- c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c | 1 + c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h | 1 + c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c| 1 + c/src/lib/libbsp/arm/raspberrypi/misc/timer.c | 1 + 4 files changed, 4 insertions(+) diff --git a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c index 2788d36..6c01d62 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c +++ b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c @@ -14,6 +14,7 @@ * http://www.rtems.org/license/LICENSE. */ +#include #include #include #include diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h b/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h index d6f00e8..60645b9 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h @@ -21,6 +21,7 @@ #ifndef LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H #define LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H +#include #include #include diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c b/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c index 9d70c72..37890dd 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/mailbox.c @@ -17,6 +17,7 @@ #include #include +#include #include #include diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/timer.c b/c/src/lib/libbsp/arm/raspberrypi/misc/timer.c index e90af08..1047b3e 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/timer.c +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/timer.c @@ -16,6 +16,7 @@ * */ +#include #include #include #include -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 3/7] arm/raspberrypi: Raspberry Pi v2 ALLOCATE_BUFFER VC4 operation returns direct address.
From: Pavel Pisa --- c/src/lib/libbsp/arm/raspberrypi/misc/vc.c | 4 1 file changed, 4 insertions(+) diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c index 9c89fab..54935af 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/vc.c @@ -124,8 +124,12 @@ bcm2835_mailbox_init_frame_buffer(bcm2835_init_frame_buffer_entries* _entries) _entries->xvirt = buffer.set_virtual_size.body.resp.vwidth; _entries->yvirt = buffer.set_virtual_size.body.resp.vheight; _entries->depth = buffer.set_depth.body.resp.depth; +#if (BSP_IS_RPI2 == 1) + _entries->base = buffer.allocate_buffer.body.resp.base; +#else _entries->base = buffer.allocate_buffer.body.resp.base - BCM2835_VC_MEMORY_MAPPING; +#endif _entries->size = buffer.allocate_buffer.body.resp.size; _entries->pixel_order = buffer.set_pixel_order.body.resp.pixel_order; _entries->alpha_mode = buffer.set_alpha_mode.body.resp.alpha_mode; -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH v2 4/7] arm/raspberrypi: add VideoCore framebuffer without initialization
From: YANG Qiao --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 2 + c/src/lib/libbsp/arm/raspberrypi/console/fb.c | 409 ++ c/src/lib/libbsp/arm/raspberrypi/include/rpi-fb.h | 54 +++ c/src/lib/libbsp/arm/raspberrypi/preinstall.am| 4 + 4 files changed, 469 insertions(+) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fb.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/include/rpi-fb.h diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index 258f8a0..285da4f 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -50,6 +50,7 @@ include_bsp_HEADERS += include/i2c.h include_bsp_HEADERS += include/spi.h include_bsp_HEADERS += include/mailbox.h include_bsp_HEADERS += include/vc.h +include_bsp_HEADERS += include/rpi-fb.h include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \ ../../../libcpu/arm/shared/include/arm-cp15.h @@ -114,6 +115,7 @@ libbsp_a_SOURCES += ../../shared/console_select.c libbsp_a_SOURCES += ../../shared/console_write.c libbsp_a_SOURCES += console/console-config.c libbsp_a_SOURCES += console/usart.c +libbsp_a_SOURCES += console/fb.c # Mailbox libbsp_a_SOURCES += misc/mailbox.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/fb.c b/c/src/lib/libbsp/arm/raspberrypi/console/fb.c new file mode 100644 index 000..185db29 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/console/fb.c @@ -0,0 +1,409 @@ +/** + * @file + * + * @ingroup raspberrypi + * + * @brief framebuffer support. + */ + +/* + * Copyright (c) 2015 Yang Qiao + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.org/license/LICENSE + * + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#define SCREEN_WIDTH 1024 +#define SCREEN_HEIGHT 768 +#define BPP 32 + +/* flag to limit driver to protect against multiple opens */ +static Atomic_Flag driver_mutex; + +/* + * screen information for the driver (fb0). + */ + +static struct fb_var_screeninfo fb_var_info = { + .xres= SCREEN_WIDTH, + .yres= SCREEN_HEIGHT, + .bits_per_pixel = BPP +}; + +static struct fb_fix_screeninfo fb_fix_info = { + .smem_start = (void *) NULL, + .smem_len= 0, + .type= FB_TYPE_PACKED_PIXELS, + .visual = FB_VISUAL_TRUECOLOR, + .line_length = 0 +}; + +typedef enum { + NO_SUITABLE_MODE = -1, + BAD_FORMAT = -2, + AUTO_SELECT = -3, + DONT_INIT= -4, + NO_MODE_REQ = -5, +} mode_err_ret_val; + +int rpi_get_fix_screen_info( struct fb_fix_screeninfo *info ) +{ + *info = fb_fix_info; + return 0; +} + +int rpi_get_var_screen_info( struct fb_var_screeninfo *info ) +{ + *info = fb_var_info; + return 0; +} + +/** + * @brief Find mode given in string format. + * + * expected format + * x[-] + * numbers , and are decadic + * + * @param[out] fb_var_ptr pointer to variable mode part filled by function + * @param[in] video_string string to be parsed + * @retval video mode number to be set + * @retval -1 no suitable mode found + * @retval -2 bad format of the video_string + * @retval -3 automatic mode selection requested + * @retval -4 request to not initialize graphics + * @retval -5 no mode requested/empty video string + */ + +static int parse_mode_from_string( + struct fb_var_screeninfo *fb_var_ptr, + const char *video_string +) +{ + const char *opt; + char *endptr; + uint32_twidth; + uint32_theight; + uint32_tbpp = 0; + + opt = video_string; + + if ( opt == NULL ) +return NO_MODE_REQ; + + if ( strncmp( opt, "auto", 4 ) == 0 ) +return AUTO_SELECT; + + if ( strncmp( opt, "none", 4 ) == 0 || + strncmp( opt, "off", 3 ) == 0 ) +return DONT_INIT; + + width = strtol( opt, &endptr, 10 ); + + if ( *endptr != 'x' ) { +return BAD_FORMAT; + } + + opt = endptr + 1; + height = strtol( opt, &endptr, 10 ); + + switch ( *endptr ) { +case '-': + opt = endptr + 1; + endptr = NULL; + bpp = strtol( opt, &endptr, 10 ); + + if ( ( endptr == opt ) || ( endptr == NULL ) ) +return BAD_FORMAT; + + if ( *endptr && ( *endptr != ' ' ) ) +return BAD_FORMAT; + + break; +case ' ': +case 0: + break; +default: + return BAD_FORMAT; + } + + fb_var_ptr->xres = width; + fb_var_ptr->yres = height; + + if ( bpp != 0 ) +fb_var_ptr->bits_per_pixel = bpp; + + return 0; +} + +static int find_mode_from_vc( void ) +{ + bcm2835_get_display_size_entries entries; + + bcm2835_mailbox_get_display_size( &entries ); + unsigned int width = entries.width; + unsigned int height = entr
[PATCH v2 5/7] arm/raspberrypi: move MMU in front of application image to respect variable memory size.
From: Pavel Pisa The page table is placed at address 0x4000 which provides required 16 kB space till the start of application image. The RAM size specified in a linker script is upper limit address of RAM utilized for the work area initialization. If VideoCore reports to use lower address than expected then work area size is adjusted (shrinked) appropriately. --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 4 +- c/src/lib/libbsp/arm/raspberrypi/include/bsp.h | 2 + .../arm/raspberrypi/startup/bspgetworkarea.c | 77 ++ c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds | 6 +- c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c | 31 + 5 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index 285da4f..3373d08 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -83,7 +83,6 @@ libbsp_a_LIBADD = # Shared libbsp_a_SOURCES += ../../shared/bootcard.c libbsp_a_SOURCES += ../../shared/bspclean.c -libbsp_a_SOURCES += ../../shared/bspgetworkarea.c libbsp_a_SOURCES += ../../shared/bsppredriverhook.c libbsp_a_SOURCES += ../../shared/cpucounterread.c libbsp_a_SOURCES += ../../shared/cpucounterdiff.c @@ -97,6 +96,7 @@ libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c libbsp_a_SOURCES += ../../shared/bspreset_loop.c libbsp_a_SOURCES += startup/bspstart.c libbsp_a_SOURCES += startup/cmdline.c +libbsp_a_SOURCES += startup/bspgetworkarea.c # IRQ libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c @@ -153,7 +153,7 @@ libbsp_a_SOURCES += startup/bspstarthooks.c # LIBMM libbsp_a_SOURCES += startup/mm_config_table.c -libbsp_a_SOURCES += ../shared/mminit.c +libbsp_a_SOURCES += startup/mminit.c ### # Network# diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h index 18a94ea..c6cd571 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h +++ b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h @@ -32,6 +32,8 @@ extern "C" { #define BSP_FEATURE_IRQ_EXTENSION +#define RPI_L2_CACHE_ENABLE 1 + #define BSP_GPIO_PIN_COUNT 32 #define BSP_GPIO_PINS_PER_BANK 32 #define BSP_GPIO_PINS_PER_SELECT_BANK 10 diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c new file mode 100644 index 000..9dc7e02 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c @@ -0,0 +1,77 @@ +/** + * @file + * + * @ingroup arm_start + * + * @brief Raspberry pi workarea initialization. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2011-2012 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * Copyright (c) 2015 YANG Qiao + * + * Code is based on c/src/lib/libbsp/shared/bspgetworkarea.c + */ + +#include +#include +#include +#include +#ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN + #include +#endif + +#if defined(HAS_UBOOT) && !defined(BSP_DISABLE_UBOOT_WORK_AREA_CONFIG) + #define USE_UBOOT +#endif + +/* + * These are provided by the linkcmds for ALL of the BSPs which use this file. + */ +extern char WorkAreaBase[]; + +/* + * We may get the size information from U-Boot or the linker scripts. + */ +#ifdef USE_UBOOT + #include +#else + extern char RamBase[]; + extern char RamSize[]; +#endif + +void bsp_work_area_initialize(void) +{ + uintptr_t work_base = (uintptr_t) WorkAreaBase; + uintptr_t ram_end; + bcm2835_get_vc_memory_entries vc_entry; + /* + * bcm2835_get_arm_memory_entries arm_entry; + * is another alternative how to obtain usable memory size + */ + + #ifdef USE_UBOOT +ram_end = (uintptr_t) bsp_uboot_board_info.bi_memstart + + bsp_uboot_board_info.bi_memsize; + #else +ram_end = (uintptr_t)RamBase + (uintptr_t)RamSize; + #endif + + #ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN +work_base += rtems_configuration_get_interrupt_stack_size(); + #endif + + memset( &vc_entry, 0, sizeof(vc_entry) ); + bcm2835_mailbox_get_vc_memory( &vc_entry ); + if (vc_entry.base != 0) +ram_end = ram_end > vc_entry.base? vc_entry.base: ram_end; + bsp_work_area_initialize_default( (void *) work_base, ram_end - work_base ); +} diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds index f1ad11c..fc72b5c 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/startup/
[PATCH v2 6/7] arm/raspberrypi: add video outchar support for rpi bsp
From: YANG Qiao --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am |3 + .../lib/libbsp/arm/raspberrypi/console/font_data.h | 4639 c/src/lib/libbsp/arm/raspberrypi/console/outch.c | 463 ++ c/src/lib/libbsp/arm/raspberrypi/include/bsp.h |4 + 4 files changed, 5109 insertions(+) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/font_data.h create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/outch.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index 3373d08..f5b87ab 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -26,6 +26,8 @@ nodist_include_HEADERS = ../../shared/include/coverhd.h \ nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h +noinst_HEADERS = console/font_data.h + include_bsp_HEADERS = include_bsp_HEADERS += ../../../libbsp/shared/include/mm.h include_bsp_HEADERS += ../../shared/include/utility.h @@ -116,6 +118,7 @@ libbsp_a_SOURCES += ../../shared/console_write.c libbsp_a_SOURCES += console/console-config.c libbsp_a_SOURCES += console/usart.c libbsp_a_SOURCES += console/fb.c +libbsp_a_SOURCES += console/outch.c # Mailbox libbsp_a_SOURCES += misc/mailbox.c diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/font_data.h b/c/src/lib/libbsp/arm/raspberrypi/console/font_data.h new file mode 100644 index 000..852310c --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/console/font_data.h @@ -0,0 +1,4639 @@ +/** + * @file + * + * @ingroup raspberrypi + * + * @brief graphic text console font file + * + */ +/* + * Copyright (c) 2015 Yang Qiao + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.org/license/LICENSE + * + */ + +#ifndef LIBBSP_ARM_RASPBERRYPI_FONT_DATA_H +#define LIBBSP_ARM_RASPBERRYPI_FONT_DATA_H + +#define RPI_FONT_CHARS 256 +#define RPI_FONT_WIDTH 8 +#define RPI_FONT_HEIGHT 16 +#define RPI_FONT_SIZE (RPI_FONT_CHARS * RPI_FONT_HEIGHT) + +static unsigned char rpi_font[RPI_FONT_SIZE] = { + + /* 0 0x00 '^@' */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 1 0x01 '^A' */ + 0x00, /* */ + 0x00, /* */ + 0x7e, /* 0110 */ + 0x81, /* 1001 */ + 0xa5, /* 10100101 */ + 0x81, /* 1001 */ + 0x81, /* 1001 */ + 0xbd, /* 1001 */ + 0x99, /* 10011001 */ + 0x81, /* 1001 */ + 0x81, /* 1001 */ + 0x7e, /* 0110 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 2 0x02 '^B' */ + 0x00, /* */ + 0x00, /* */ + 0x7e, /* 0110 */ + 0xff, /* */ + 0xdb, /* 11011011 */ + 0xff, /* */ + 0xff, /* */ + 0xc3, /* 1111 */ + 0xe7, /* 11100111 */ + 0xff, /* */ + 0xff, /* */ + 0x7e, /* 0110 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 3 0x03 '^C' */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x6c, /* 01101100 */ + 0xfe, /* 1110 */ + 0xfe, /* 1110 */ + 0xfe, /* 1110 */ + 0xfe, /* 1110 */ + 0x7c, /* 0100 */ + 0x38, /* 00111000 */ + 0x10, /* 0001 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 4 0x04 '^D' */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x10, /* 0001 */ + 0x38, /* 00111000 */ + 0x7c, /* 0100 */ + 0xfe, /* 1110 */ + 0x7c, /* 0100 */ + 0x38, /* 00111000 */ + 0x10, /* 0001 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 5 0x05 '^E' */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x18, /* 00011000 */ + 0x3c, /* 0000 */ + 0x3c, /* 0000 */ + 0xe7, /* 11100111 */ + 0xe7, /* 11100111 */ + 0xe7, /* 11100111 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 0000 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + + /* 6 0x06 '^F' */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x18, /* 00011000 */ + 0x3c, /* 0000 */ + 0x7e, /* 0110 */ + 0xff, /* */ + 0xff, /* */ + 0x7e, /* 0110 */ + 0x18, /* 00011000 */ + 0x18, /* 00011000 */ + 0x3c, /* 0000 */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* */ + 0x00, /* 00
[PATCH v2 7/7] arm/raspberrypi: add fbcons support for rpi bsp
From: YANG Qiao --- c/src/lib/libbsp/arm/raspberrypi/Makefile.am | 4 +- .../arm/raspberrypi/console/console-config.c | 12 +- .../arm/raspberrypi/console/console_select.c | 113 + c/src/lib/libbsp/arm/raspberrypi/console/fbcons.c | 177 + c/src/lib/libbsp/arm/raspberrypi/console/fbcons.h | 47 ++ c/src/lib/libbsp/arm/raspberrypi/include/bsp.h | 3 + c/src/lib/libbsp/arm/raspberrypi/preinstall.am | 4 + .../libbsp/arm/raspberrypi/startup/bspstarthooks.c | 4 + 8 files changed, 362 insertions(+), 2 deletions(-) create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/console_select.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fbcons.c create mode 100644 c/src/lib/libbsp/arm/raspberrypi/console/fbcons.h diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am index f5b87ab..e115745 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am +++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am @@ -53,6 +53,7 @@ include_bsp_HEADERS += include/spi.h include_bsp_HEADERS += include/mailbox.h include_bsp_HEADERS += include/vc.h include_bsp_HEADERS += include/rpi-fb.h +include_bsp_HEADERS += console/fbcons.h include_libcpu_HEADERS = ../../../libcpu/arm/shared/include/cache_.h \ ../../../libcpu/arm/shared/include/arm-cp15.h @@ -113,11 +114,12 @@ libbsp_a_SOURCES += irq/irq.c libbsp_a_SOURCES += ../../shared/console.c libbsp_a_SOURCES += ../../shared/console_control.c libbsp_a_SOURCES += ../../shared/console_read.c -libbsp_a_SOURCES += ../../shared/console_select.c libbsp_a_SOURCES += ../../shared/console_write.c libbsp_a_SOURCES += console/console-config.c +libbsp_a_SOURCES += console/console_select.c libbsp_a_SOURCES += console/usart.c libbsp_a_SOURCES += console/fb.c +libbsp_a_SOURCES += console/fbcons.c libbsp_a_SOURCES += console/outch.c # Mailbox diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/console-config.c b/c/src/lib/libbsp/arm/raspberrypi/console/console-config.c index b948b77..dfb9826 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/console/console-config.c +++ b/c/src/lib/libbsp/arm/raspberrypi/console/console-config.c @@ -7,6 +7,8 @@ */ /* + * Copyright (c) 2015 Yang Qiao + * based on work by: * Copyright (c) 2013 Alan Cudmore * * The license and distribution terms for this file may be @@ -24,6 +26,7 @@ #include #include #include +#include console_tbl Console_Configuration_Ports [] = { { @@ -36,7 +39,14 @@ console_tbl Console_Configuration_Ports [] = { .ulCtrlPort2 = 0, .ulClock = USART0_DEFAULT_BAUD, .ulIntVector = BCM2835_IRQ_ID_UART -} +}, +{ + .sDeviceName ="/dev/fbcons", + .deviceType = SERIAL_CUSTOM, + .pDeviceFns = &fbcons_fns, + .deviceProbe = fbcons_probe, + .pDeviceFlow = NULL, +}, }; #define PORT_COUNT \ diff --git a/c/src/lib/libbsp/arm/raspberrypi/console/console_select.c b/c/src/lib/libbsp/arm/raspberrypi/console/console_select.c new file mode 100644 index 000..c038cd9 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/console/console_select.c @@ -0,0 +1,113 @@ +/** + * @file + * + * @ingroup raspberrypi_console + * + * @brief console select + */ + +/* + * Copyright (c) 2015 Yang Qiao + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.org/license/LICENSE + * + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include "../../../shared/console_private.h" +#include + +rtems_device_minor_number BSPPrintkPort = 0; + +/* + * Method to return true if the device associated with the + * minor number probs available. + */ +static bool bsp_Is_Available( rtems_device_minor_number minor ) +{ + console_tbl *cptr = Console_Port_Tbl[ minor ]; + + /* + * First perform the configuration dependent probe, then the + * device dependent probe + */ + if ( ( !cptr->deviceProbe || cptr->deviceProbe( minor ) ) && + cptr->pDeviceFns->deviceProbe( minor ) ) { +return true; + } + + return false; +} + +/* + * Method to return the first available device. + */ +static rtems_device_minor_number bsp_First_Available_Device( void ) +{ + rtems_device_minor_number minor; + + for ( minor = 0; minor < Console_Port_Count; minor++ ) { +console_tbl *cptr = Console_Port_Tbl[ minor ]; + +/* + * First perform the configuration dependent probe, then the + * device dependent probe + */ + +if ( ( !cptr->deviceProbe || cptr->deviceProbe( minor ) ) && + cptr->pDeviceFns->deviceProbe( minor ) ) { + return minor; +} + } + + /* + * Error No devices were found. We will want to bail here. + */ + bsp_fatal( BSP_FATAL_CONSOLE_NO_DEV ); +} + +void bsp_console_select( void ) +{ + /* + * Reset Console_Port_Minor and + * BSPPrintkPort here if desired. + * +