[rtems commit] bsps/arm: Move implementation to inline functions

Sebastian Huber sebh at rtems.org
Fri May 3 15:29:26 UTC 2013


Module:    rtems
Branch:    master
Commit:    fb0584fff85c4f03edbd26b44f10f07ec4eb5001
Changeset: http://git.rtems.org/rtems/commit/?id=fb0584fff85c4f03edbd26b44f10f07ec4eb5001

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri May  3 10:39:26 2013 +0200

bsps/arm: Move implementation to inline functions

---

 c/src/lib/libbsp/arm/lm3s69xx/Makefile.am          |    1 -
 .../lib/libbsp/arm/lm3s69xx/startup/bspstarthook.c |    1 +
 c/src/lib/libbsp/arm/lpc24xx/Makefile.am           |    1 -
 .../lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c |    1 +
 c/src/lib/libbsp/arm/shared/include/start.h        |   49 +++++++++++++-
 .../arm/shared/startup/bsp-start-copy-sections.c   |   68 --------------------
 c/src/lib/libbsp/arm/stm32f4/Makefile.am           |    1 -
 .../lib/libbsp/arm/stm32f4/startup/bspstarthook.c  |    1 +
 8 files changed, 49 insertions(+), 74 deletions(-)

diff --git a/c/src/lib/libbsp/arm/lm3s69xx/Makefile.am b/c/src/lib/libbsp/arm/lm3s69xx/Makefile.am
index 6d2ad7f..589112a 100644
--- a/c/src/lib/libbsp/arm/lm3s69xx/Makefile.am
+++ b/c/src/lib/libbsp/arm/lm3s69xx/Makefile.am
@@ -73,7 +73,6 @@ libbsp_a_SOURCES += ../../shared/sbrk.c
 libbsp_a_SOURCES += ../../shared/src/stackalloc.c
 
 # Startup
-libbsp_a_SOURCES += ../shared/startup/bsp-start-copy-sections.c
 libbsp_a_SOURCES += ../shared/startup/bsp-start-memcpy.S
 libbsp_a_SOURCES += startup/bspstart.c
 libbsp_a_SOURCES += startup/bspstarthook.c
diff --git a/c/src/lib/libbsp/arm/lm3s69xx/startup/bspstarthook.c b/c/src/lib/libbsp/arm/lm3s69xx/startup/bspstarthook.c
index 241e54e..9c7bfa5 100644
--- a/c/src/lib/libbsp/arm/lm3s69xx/startup/bspstarthook.c
+++ b/c/src/lib/libbsp/arm/lm3s69xx/startup/bspstarthook.c
@@ -23,6 +23,7 @@ void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
 void BSP_START_TEXT_SECTION bsp_start_hook_1(void)
 {
   bsp_start_copy_sections();
+  bsp_start_clear_bss();
 
   /* At this point we can use objects outside the .start section */
 }
diff --git a/c/src/lib/libbsp/arm/lpc24xx/Makefile.am b/c/src/lib/libbsp/arm/lpc24xx/Makefile.am
index 63e9d2f..9aa574d 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/Makefile.am
+++ b/c/src/lib/libbsp/arm/lpc24xx/Makefile.am
@@ -101,7 +101,6 @@ libbsp_a_SOURCES += ../../shared/bootcard.c \
 	../../shared/src/uart-output-char.c
 
 # Startup
-libbsp_a_SOURCES += ../shared/startup/bsp-start-copy-sections.c
 libbsp_a_SOURCES += ../shared/startup/bsp-start-memcpy.S
 libbsp_a_SOURCES += startup/bspreset.c
 libbsp_a_SOURCES += startup/bspstart.c
diff --git a/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c
index c80a919..232a1b9 100644
--- a/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c
+++ b/c/src/lib/libbsp/arm/lpc24xx/startup/bspstarthooks.c
@@ -527,6 +527,7 @@ BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
   lpc24xx_stop_ethernet();
   lpc24xx_stop_usb();
   bsp_start_copy_sections();
+  bsp_start_clear_bss();
 
   /* At this point we can use objects outside the .start section */
 }
diff --git a/c/src/lib/libbsp/arm/shared/include/start.h b/c/src/lib/libbsp/arm/shared/include/start.h
index 7642391..3f5301c 100644
--- a/c/src/lib/libbsp/arm/shared/include/start.h
+++ b/c/src/lib/libbsp/arm/shared/include/start.h
@@ -7,7 +7,7 @@
  */
 
 /*
- * Copyright (c) 2008-2011 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2008-2013 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Obere Lagerstr. 30
@@ -23,7 +23,9 @@
 #ifndef LIBBSP_ARM_SHARED_START_H
 #define LIBBSP_ARM_SHARED_START_H
 
-#include <stddef.h>
+#include <string.h>
+
+#include <bsp/linker-symbols.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -81,7 +83,48 @@ void bsp_start_memcpy_arm(int *dest, const int *src, size_t n);
 /**
  * @brief Copies all standard sections from the load to the runtime area.
  */
-void bsp_start_copy_sections(void);
+BSP_START_TEXT_SECTION static inline void bsp_start_copy_sections(void)
+{
+  /* Copy .text section */
+  bsp_start_memcpy(
+    (int *) bsp_section_text_begin,
+    (const int *) bsp_section_text_load_begin,
+    (size_t) bsp_section_text_size
+  );
+
+  /* Copy .rodata section */
+  bsp_start_memcpy(
+    (int *) bsp_section_rodata_begin,
+    (const int *) bsp_section_rodata_load_begin,
+    (size_t) bsp_section_rodata_size
+  );
+
+  /* Copy .data section */
+  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 */
+  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 */
+  bsp_start_memcpy(
+    (int *) bsp_section_fast_data_begin,
+    (const int *) bsp_section_fast_data_load_begin,
+    (size_t) bsp_section_fast_data_size
+  );
+}
+
+BSP_START_TEXT_SECTION static inline void bsp_start_clear_bss(void)
+{
+  memset(bsp_section_bss_begin, 0, (size_t) bsp_section_bss_size);
+}
 
 /** @} */
 
diff --git a/c/src/lib/libbsp/arm/shared/startup/bsp-start-copy-sections.c b/c/src/lib/libbsp/arm/shared/startup/bsp-start-copy-sections.c
deleted file mode 100644
index b7eb1f9..0000000
--- a/c/src/lib/libbsp/arm/shared/startup/bsp-start-copy-sections.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2008-2011 embedded brains GmbH.  All rights reserved.
- *
- *  embedded brains GmbH
- *  Obere Lagerstr. 30
- *  82178 Puchheim
- *  Germany
- *  <rtems at 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 <bsp/start.h>
-#include <bsp/linker-symbols.h>
-
-static void BSP_START_TEXT_SECTION bsp_start_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;
-  }
-}
-
-void BSP_START_TEXT_SECTION bsp_start_copy_sections(void)
-{
-  /* Copy .text section */
-  bsp_start_memcpy(
-    (int *) bsp_section_text_begin,
-    (const int *) bsp_section_text_load_begin,
-    (size_t) bsp_section_text_size
-  );
-
-  /* Copy .rodata section */
-  bsp_start_memcpy(
-    (int *) bsp_section_rodata_begin,
-    (const int *) bsp_section_rodata_load_begin,
-    (size_t) bsp_section_rodata_size
-  );
-
-  /* Copy .data section */
-  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 */
-  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 */
-  bsp_start_memcpy(
-    (int *) bsp_section_fast_data_begin,
-    (const int *) bsp_section_fast_data_load_begin,
-    (size_t) bsp_section_fast_data_size
-  );
-
-  bsp_start_clear_bss();
-}
diff --git a/c/src/lib/libbsp/arm/stm32f4/Makefile.am b/c/src/lib/libbsp/arm/stm32f4/Makefile.am
index a54d974..6203aa3 100644
--- a/c/src/lib/libbsp/arm/stm32f4/Makefile.am
+++ b/c/src/lib/libbsp/arm/stm32f4/Makefile.am
@@ -72,7 +72,6 @@ libbsp_a_SOURCES += ../../shared/sbrk.c
 libbsp_a_SOURCES += ../../shared/src/stackalloc.c
 
 # Startup
-libbsp_a_SOURCES += ../shared/startup/bsp-start-copy-sections.c
 libbsp_a_SOURCES += ../shared/startup/bsp-start-memcpy.S
 libbsp_a_SOURCES += startup/bspstart.c
 libbsp_a_SOURCES += startup/bspstarthook.c
diff --git a/c/src/lib/libbsp/arm/stm32f4/startup/bspstarthook.c b/c/src/lib/libbsp/arm/stm32f4/startup/bspstarthook.c
index 1a69da7..0db8652 100644
--- a/c/src/lib/libbsp/arm/stm32f4/startup/bspstarthook.c
+++ b/c/src/lib/libbsp/arm/stm32f4/startup/bspstarthook.c
@@ -23,6 +23,7 @@ void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
 void BSP_START_TEXT_SECTION bsp_start_hook_1(void)
 {
   bsp_start_copy_sections();
+  bsp_start_clear_bss();
 
   /* At this point we can use objects outside the .start section */
 }




More information about the vc mailing list