[PATCH has to be redone] arm/raspberrypi: call VideoCore framebuffer initialization

Pavel Pisa ppisa4lists at pikron.com
Thu Apr 28 11:32:52 UTC 2016


From: YANG Qiao <yangqiao0505 at me.com>
Date: Thu, 13 Aug 2015 00:06:10 +0200

--
This change is reason I have asked for update and more checking
and didnot proposed patches for mainlining at end of 2015 GSoC.

diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index 258f8a0..5faca68 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -82,7 +82,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
@@ -96,6 +95,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
@@ -151,7 +152,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 d8319c6..06c2240 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 0000000..07a38e9
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspgetworkarea.c
@@ -0,0 +1,61 @@
+/**
+ * @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
+ */
+
+#include <bsp.h>
+#include <bsp/bootcard.h>
+#include <bsp/vc.h>
+#ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN
+  #include <rtems/config.h>
+#endif
+
+#if defined(HAS_UBOOT) && !defined(BSP_DISABLE_UBOOT_WORK_AREA_CONFIG)
+  #define USE_UBOOT
+#endif
+
+extern char WorkAreaBase[];
+
+#ifdef USE_UBOOT
+  #include <bsp/u-boot.h>
+#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_arm_memory_entries arm_entry;
+  bcm2835_get_vc_memory_entries vc_entry;
+
+  #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..81d4f8d 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
@@ -37,8 +37,9 @@
 
 MEMORY {
         VECTOR_RAM     (AIW) : ORIGIN = 0x0       , LENGTH = 0x8000
-        RAM            (AIW) : ORIGIN = 0x00008000, LENGTH = 128M - 48K
-	RAM_MMU        (AIW) : ORIGIN = 128M - 16k, LENGTH = 16k
+        GPU_RAM        (AIW) : ORIGIN = 256M - 64M, LENGTH = 64M
+        RAM            (AIW) : ORIGIN = 0x00008000, LENGTH = 256M - 64M - 48K
+	RAM_MMU        (AIW) : ORIGIN = 256M - 64M - 16k, LENGTH = 16k
 }
 
 REGION_ALIAS ("REGION_START", RAM);
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c b/c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c
new file mode 100644
index 0000000..e012060
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/mminit.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 Yang Qiao
+ * based on work by:
+ * Copyright (c) 2013 Hesham AL-Matary.
+ *
+ * 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.
+ */
+
+#define ARM_CP15_TEXT_SECTION BSP_START_TEXT_SECTION
+
+#include <bsp/start.h>
+#include <bsp/arm-cp15-start.h>
+#include <bsp/linker-symbols.h>
+#include <bsp/mm.h>
+#include <rtems/fb.h>
+
+extern int raspberrypi_get_var_screen_info( struct fb_var_screeninfo *info );
+
+BSP_START_TEXT_SECTION void bsp_memory_management_initialize(void)
+{
+  uint32_t ctrl = arm_cp15_get_control();
+
+  ctrl |= ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_S | ARM_CP15_CTRL_XP;
+
+  struct fb_fix_screeninfo fb_fix_info;
+  raspberrypi_get_fix_screen_info(&fb_fix_info);
+
+  arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
+    ctrl,
+    (uint32_t *) bsp_translation_table_base,
+    ARM_MMU_DEFAULT_CLIENT_DOMAIN,
+    &arm_cp15_start_mmu_config_table[0],
+    arm_cp15_start_mmu_config_table_size
+  );
+
+  arm_cp15_set_translation_table_entries(fb_fix_info.smem_start,
+                                        fb_fix_info.smem_start +
+                                        fb_fix_info.smem_len,
+                                        ARMV7_MMU_DATA_READ_WRITE_CACHED);
+}



More information about the devel mailing list