summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/raspberrypi/startup
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/arm/raspberrypi/startup')
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/startup/bspreset.c35
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/startup/bspstart.c29
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c114
-rw-r--r--c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds62
4 files changed, 240 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspreset.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspreset.c
new file mode 100644
index 0000000000..588a33ec09
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspreset.c
@@ -0,0 +1,35 @@
+/**
+ * @file
+ *
+ * @ingroup raspberrypi
+ *
+ * @brief Reset code.
+ */
+
+/*
+ * Copyright (c) 2013 by Alan Cudmore
+ * Based on work by:
+ * Copyright (c) 2009
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ *
+ * http://www.rtems.com/license/LICENSE
+ *
+ */
+
+#include <rtems.h>
+
+#include <bsp/bootcard.h>
+
+void bsp_reset( void)
+{
+ while (true) {
+ /* Do nothing */
+ }
+}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstart.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstart.c
new file mode 100644
index 0000000000..e48dd532a4
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstart.c
@@ -0,0 +1,29 @@
+/**
+ * @file
+ *
+ * @ingroup raspberrypi
+ *
+ * @brief Startup code.
+ */
+
+/*
+ * Copyright (c) 2013 by Alan Cudmore
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ *
+ * http://www.rtems.com/license/LICENSE
+ */
+
+#include <bsp.h>
+#include <bsp/bootcard.h>
+#include <bsp/irq-generic.h>
+#include <bsp/irq.h>
+#include <bsp/linker-symbols.h>
+#include <bsp/stackalloc.h>
+#include <bsp/raspberrypi.h>
+
+void bsp_start(void)
+{
+ bsp_interrupt_initialize();
+}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
new file mode 100644
index 0000000000..6f57264119
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
@@ -0,0 +1,114 @@
+/**
+ * @file
+ *
+ * @ingroup raspberrypi
+ *
+ * @brief Startup code.
+ */
+
+/*
+ * Copyright (c) 2013 by Alan Cudmore
+ * based on work by:
+ * Copyright (c) 2009
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * D-82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE
+ */
+
+#include <stdbool.h>
+
+#include <bspopts.h>
+#include <bsp/start.h>
+#include <bsp/raspberrypi.h>
+#include <bsp/mmu.h>
+#include <bsp/linker-symbols.h>
+#include <bsp/uart-output-char.h>
+
+static void BSP_START_TEXT_SECTION clear_bss(void)
+{
+ const int *end = (const int *) bsp_section_bss_end;
+ int *out = (int *) bsp_section_bss_begin;
+
+ /* Clear BSS */
+ while (out != end) {
+ *out = 0;
+ ++out;
+ }
+}
+
+static void BSP_START_TEXT_SECTION raspberrypi_cache_setup(void)
+{
+ uint32_t ctrl = 0;
+
+ /* Disable MMU and cache, basic settings */
+ ctrl = arm_cp15_get_control();
+ ctrl &= ~(ARM_CP15_CTRL_I | ARM_CP15_CTRL_R | ARM_CP15_CTRL_C
+ | ARM_CP15_CTRL_V | ARM_CP15_CTRL_M);
+ ctrl |= ARM_CP15_CTRL_S | ARM_CP15_CTRL_A;
+ arm_cp15_set_control(ctrl);
+
+ arm_cp15_cache_invalidate();
+ arm_cp15_tlb_invalidate();
+
+}
+
+
+void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
+{
+ raspberrypi_cache_setup();
+}
+
+
+void BSP_START_TEXT_SECTION bsp_start_hook_1(void)
+{
+
+ /* Copy .text section */
+ arm_cp15_instruction_cache_invalidate();
+ bsp_start_memcpy(
+ (int *) bsp_section_text_begin,
+ (const int *) bsp_section_text_load_begin,
+ (size_t) bsp_section_text_size
+ );
+
+ /* Copy .rodata section */
+ arm_cp15_instruction_cache_invalidate();
+ bsp_start_memcpy(
+ (int *) bsp_section_rodata_begin,
+ (const int *) bsp_section_rodata_load_begin,
+ (size_t) bsp_section_rodata_size
+ );
+
+ /* Copy .data section */
+ arm_cp15_instruction_cache_invalidate();
+ bsp_start_memcpy(
+ (int *) bsp_section_data_begin,
+ (const int *) bsp_section_data_load_begin,
+ (size_t) bsp_section_data_size
+ );
+
+ /* Copy .fast_text section */
+ arm_cp15_instruction_cache_invalidate();
+ bsp_start_memcpy(
+ (int *) bsp_section_fast_text_begin,
+ (const int *) bsp_section_fast_text_load_begin,
+ (size_t) bsp_section_fast_text_size
+ );
+
+ /* Copy .fast_data section */
+ arm_cp15_instruction_cache_invalidate();
+ bsp_start_memcpy(
+ (int *) bsp_section_fast_data_begin,
+ (const int *) bsp_section_fast_data_load_begin,
+ (size_t) bsp_section_fast_data_size
+ );
+
+ /* Clear .bss section */
+ clear_bss();
+
+}
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
new file mode 100644
index 0000000000..b9a0dd88dc
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds
@@ -0,0 +1,62 @@
+/**
+ * @file
+ *
+ * @ingroup raspberry_pi
+ *
+ * @brief Memory map.
+ */
+
+/**
+ * @defgroup raspberry_pi Memory Map
+ *
+ * @ingroup bsp_linker
+ *
+ * @brief Raspberry Pi memory map.
+ *
+ * <table>
+ * <tr><th>Region Name</th><th>Region Begin</th><th>Region Size</th></tr>
+ * <tr><td>VECTOR_RAM</td><td>0x08000000</td><td>8k</td></tr>
+ * <tr><td>RAM</td><td>0x80008000</td><td>128M</td></tr>
+ * </table>
+ *
+ * <table>
+ * <tr><th>Section Name</th><th>Section Runtime Region</th><th>Section Load Region</th></tr>
+ * <tr><td>.start</td><td>RAM</td><td></td></tr>
+ * <tr><td>.vector</td><td>VECTOR_RAM</td><td></td></tr>
+ * <tr><td>.text</td><td>RAM</td><td>RAM_EXT</td></tr>
+ * <tr><td>.rodata</td><td>RAM</td><td>RAM_EXT</td></tr>
+ * <tr><td>.data</td><td>RAM</td><td>RAM_EXT</td></tr>
+ * <tr><td>.fast</td><td>RAM</td><td>RAM_EXT</td></tr>
+ * <tr><td>.bss</td><td>RAM</td><td></td></tr>
+ * <tr><td>.work</td><td>RAM</td><td></td></tr>
+ * <tr><td>.stack</td><td>RAM</td><td></td></tr>
+ * </table>
+ */
+
+MEMORY {
+ VECTOR_RAM (AIW) : ORIGIN = 0x0 , LENGTH = 0x8000
+ RAM (AIW) : ORIGIN = 0x00008000, LENGTH = 128M - 0x8000
+}
+
+REGION_ALIAS ("REGION_START", RAM);
+REGION_ALIAS ("REGION_VECTOR", VECTOR_RAM);
+REGION_ALIAS ("REGION_TEXT", RAM);
+REGION_ALIAS ("REGION_TEXT_LOAD", RAM);
+REGION_ALIAS ("REGION_RODATA", RAM);
+REGION_ALIAS ("REGION_RODATA_LOAD", RAM);
+REGION_ALIAS ("REGION_DATA", RAM);
+REGION_ALIAS ("REGION_DATA_LOAD", RAM);
+REGION_ALIAS ("REGION_FAST_TEXT", RAM);
+REGION_ALIAS ("REGION_FAST_TEXT_LOAD", RAM);
+REGION_ALIAS ("REGION_FAST_DATA", RAM);
+REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM);
+REGION_ALIAS ("REGION_BSS", RAM);
+REGION_ALIAS ("REGION_WORK", RAM);
+REGION_ALIAS ("REGION_STACK", RAM);
+
+bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096;
+bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
+
+bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1M;
+
+INCLUDE linkcmds.armv4