[PATCH 3/4] bsp: Generalize riscv_generic BSP to work for riscv64
Hesham Almatary
heshamelmatary at gmail.com
Fri Oct 27 09:49:32 UTC 2017
Update #3109
---
c/src/lib/libbsp/riscv32/riscv_generic/include/bsp.h | 6 +++---
c/src/lib/libbsp/riscv32/riscv_generic/start/start.S | 10 ++++------
c/src/lib/libbsp/riscv32/riscv_generic/startup/linkcmds | 10 ++++++----
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/c/src/lib/libbsp/riscv32/riscv_generic/include/bsp.h b/c/src/lib/libbsp/riscv32/riscv_generic/include/bsp.h
index 99fe958..79f359a 100644
--- a/c/src/lib/libbsp/riscv32/riscv_generic/include/bsp.h
+++ b/c/src/lib/libbsp/riscv32/riscv_generic/include/bsp.h
@@ -60,11 +60,11 @@ extern "C" {
* @{
*/
-#define REG(x) (*((volatile uint32_t *) (x)))
+#define REG(x) (*((volatile unsigned long *) (x)))
#define BIT(n) (1 << (n))
-#define MTIME_MM 0x0200bff8
-#define MTIMECMP_MM 0x02004000
+#define MTIME_MM 0x000000000200bff8
+#define MTIMECMP_MM 0x0000000002004000
#ifdef __cplusplus
}
diff --git a/c/src/lib/libbsp/riscv32/riscv_generic/start/start.S b/c/src/lib/libbsp/riscv32/riscv_generic/start/start.S
index 692afe5..ccefb81 100644
--- a/c/src/lib/libbsp/riscv32/riscv_generic/start/start.S
+++ b/c/src/lib/libbsp/riscv32/riscv_generic/start/start.S
@@ -28,11 +28,9 @@
*/
#include <bsp/linker-symbols.h>
#include <rtems/score/riscv-utility.h>
+#include <rtems/score/cpu.h>
#include <rtems/asm.h>
-# define LREG lw
-# define SREG sw
-
EXTERN(bsp_section_bss_begin)
EXTERN(bsp_section_bss_end)
EXTERN(ISR_Handler)
@@ -90,8 +88,8 @@ SYM(_start):
_loop_clear_bss:
bge t0, t1, _end_clear_bss
- sw x0, 0(t0)
- addi t0, t0, 4
+ SREG x0, 0(t0)
+ addi t0, t0, CPU_SIZEOF_POINTER
j _loop_clear_bss
_end_clear_bss:
@@ -101,7 +99,7 @@ _end_clear_bss:
j boot_card
- .align 2
+ .align 4
bsp_start_vector_table_begin:
.word _RISCV_Exception_default /* User int */
.word _RISCV_Exception_default /* Supervisor int */
diff --git a/c/src/lib/libbsp/riscv32/riscv_generic/startup/linkcmds b/c/src/lib/libbsp/riscv32/riscv_generic/startup/linkcmds
index 0ed37ad..eda1030 100644
--- a/c/src/lib/libbsp/riscv32/riscv_generic/startup/linkcmds
+++ b/c/src/lib/libbsp/riscv32/riscv_generic/startup/linkcmds
@@ -33,14 +33,13 @@
* SUCH DAMAGE.
*/
-OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")
OUTPUT_ARCH (riscv)
ENTRY (_start)
MEMORY
{
- RAM : ORIGIN = 0x0000000080000000, LENGTH = 0x10000000
+ RAM : ORIGIN = 0x10000000, LENGTH = 0x10000000
}
REGION_ALIAS ("REGION_VECTOR", RAM);
@@ -68,9 +67,9 @@ bsp_section_xbarrier_align = DEFINED (bsp_section_xbarrier_align) ? bsp_section
bsp_section_robarrier_align = DEFINED (bsp_section_robarrier_align) ? bsp_section_robarrier_align : 1;
bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1;
-bsp_stack_align = DEFINED (bsp_stack_align) ? bsp_stack_align : 8;
+bsp_stack_align = DEFINED (bsp_stack_align) ? bsp_stack_align : 16;
-bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 1024;
+bsp_stack_main_size = DEFINED (bsp_stack_main_size) ? bsp_stack_main_size : 4096;
bsp_stack_main_size = ALIGN (bsp_stack_main_size, bsp_stack_align);
_bsp_processor_count = DEFINED (_bsp_processor_count) ? _bsp_processor_count : 1;
@@ -110,6 +109,7 @@ SECTIONS {
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
+ *(.gnu.linkonce.t.*)
*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
} > REGION_TEXT AT > REGION_TEXT_LOAD
.init : {
@@ -132,6 +132,7 @@ SECTIONS {
. = ALIGN(8);
bsp_section_rodata_begin = .;
*(.rodata .rodata.* .gnu.linkonce.r.*)
+ *(.gnu.linkonce.r.*)
} > REGION_RODATA AT > REGION_RODATA_LOAD
.eh_frame : {
KEEP (*(.eh_frame))
@@ -324,6 +325,7 @@ SECTIONS {
. = ALIGN(8);
bsp_section_data_begin = .;
*(.data .data.* .gnu.linkonce.d.*)
+ *(.comment)
SORT(CONSTRUCTORS)
} > REGION_DATA AT > REGION_DATA_LOAD
.data1 : {
--
2.7.4
More information about the devel
mailing list