summaryrefslogtreecommitdiffstats
path: root/bsps/arm/raspberrypi/start/bspgetworkarea.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 10:35:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 13:52:14 +0200
commit99648958668d3a33ee57974479b36201fe303f34 (patch)
tree6f27ea790e2823c6156e71219a4f54680263fac6 /bsps/arm/raspberrypi/start/bspgetworkarea.c
parentbsps: Move start files to bsps (diff)
downloadrtems-99648958668d3a33ee57974479b36201fe303f34.tar.bz2
bsps: Move startup files to bsps
Adjust build support files to new directory layout. This patch is a part of the BSP source reorganization. Update #3285.
Diffstat (limited to 'bsps/arm/raspberrypi/start/bspgetworkarea.c')
-rw-r--r--bsps/arm/raspberrypi/start/bspgetworkarea.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/bsps/arm/raspberrypi/start/bspgetworkarea.c b/bsps/arm/raspberrypi/start/bspgetworkarea.c
new file mode 100644
index 0000000000..6a43e3c437
--- /dev/null
+++ b/bsps/arm/raspberrypi/start/bspgetworkarea.c
@@ -0,0 +1,78 @@
+/**
+ * @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 <string.h>
+#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
+
+/*
+ * 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 <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_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) );
+ if (bcm2835_mailbox_get_vc_memory( &vc_entry ) >= 0) {
+ if (vc_entry.base > 10 * 1024 *1024)
+ ram_end = ram_end > vc_entry.base? vc_entry.base: ram_end;
+ }
+ bsp_work_area_initialize_default( (void *) work_base, ram_end - work_base );
+}