summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2018-12-22 09:32:31 +0300
committerAnup Patel <anup@brainfault.org>2018-12-22 18:19:52 +0300
commit1cf7ec9e3bbf287fc9d601d2346b9e73fda40a84 (patch)
tree0ab39a58c0582317ec9e6a11a839f9123cfa1e50 /firmware
parent24b4d48674ad2dc088949cdf852231ab1e81f56b (diff)
downloadopensbi-1cf7ec9e3bbf287fc9d601d2346b9e73fda40a84.tar.xz
firmware: Remove stack section from common linker script
We don't need a separate stack section for per-HART stack instead we create per-HART stack at the end of firmware (i.e. after _fw_end symbol). Signed-off-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/fw_common.S61
-rw-r--r--firmware/fw_common.ldS12
2 files changed, 42 insertions, 31 deletions
diff --git a/firmware/fw_common.S b/firmware/fw_common.S
index 198aa0b..4c11e85 100644
--- a/firmware/fw_common.S
+++ b/firmware/fw_common.S
@@ -122,18 +122,28 @@ _start_warm:
csrw mie, zero
csrw mip, zero
- /* set MSIE bit to receive IPI */
+ /* Set MSIE bit to receive IPI */
li a2, MIP_MSIP
csrw mie, a2
+
+ /* Preload per-HART details
+ * s6 -> HART ID
+ * s7 -> HART Count
+ * s8 -> HART Stack Size
+ */
+ csrr s6, mhartid
+ li s7, PLAT_HART_COUNT
+ li s8, PLAT_HART_STACK_SIZE
+
/* HART ID should be within expected limit */
- csrr a6, mhartid
- li a5, PLAT_HART_COUNT
- bge a6, a5, _start_hang
+ csrr s6, mhartid
+ bge s6, s7, _start_hang
/* Setup scratch space */
- li a5, PLAT_HART_STACK_SIZE
- la tp, _stack_end
- mul a5, a5, a6
+ la tp, _fw_end
+ mul a5, s7, s8
+ add tp, tp, a5
+ mul a5, s8, s6
sub tp, tp, a5
li a5, RISCV_SCRATCH_SIZE
sub tp, tp, a5
@@ -143,6 +153,8 @@ _start_warm:
REG_S zero, RISCV_SCRATCH_TMP0_OFFSET(tp)
la a4, _fw_start
la a5, _fw_end
+ mul t0, s7, s8
+ add a5, a5, t0
sub a5, a5, a4
REG_S a4, RISCV_SCRATCH_FW_START_OFFSET(tp)
REG_S a5, RISCV_SCRATCH_FW_SIZE_OFFSET(tp)
@@ -180,18 +192,29 @@ _start_warm:
.section .entry, "ax", %progbits
.globl _hartid_to_scratch
_hartid_to_scratch:
- add sp, sp, -(2 * __SIZEOF_POINTER__)
- REG_S a1, (sp)
- REG_S a2, (__SIZEOF_POINTER__)(sp)
- li a1, PLAT_HART_STACK_SIZE
- la a2, _stack_end
- mul a1, a1, a0
- sub a2, a2, a1
- li a1, RISCV_SCRATCH_SIZE
- sub a0, a2, a1
- REG_L a1, (sp)
- REG_L a2, (__SIZEOF_POINTER__)(sp)
- add sp, sp, (2 * __SIZEOF_POINTER__)
+ add sp, sp, -(3 * __SIZEOF_POINTER__)
+ REG_S s0, (sp)
+ REG_S s1, (__SIZEOF_POINTER__)(sp)
+ REG_S s2, (__SIZEOF_POINTER__ * 2)(sp)
+ /*
+ * a0 -> HART ID (passed by caller)
+ * s0 -> HART Stack Size
+ * s1 -> HART Stack End
+ * s2 -> Temporary
+ */
+ li s0, PLAT_HART_STACK_SIZE
+ li s2, PLAT_HART_COUNT
+ mul s2, s2, s0
+ la s1, _fw_end
+ add s1, s1, s2
+ mul s2, s0, a0
+ sub s1, s1, s2
+ li s2, RISCV_SCRATCH_SIZE
+ sub a0, s1, s2
+ REG_L s0, (sp)
+ REG_L s1, (__SIZEOF_POINTER__)(sp)
+ REG_L s2, (__SIZEOF_POINTER__ * 2)(sp)
+ add sp, sp, (3 * __SIZEOF_POINTER__)
ret
.align 3
diff --git a/firmware/fw_common.ldS b/firmware/fw_common.ldS
index 3761d62..52771f8 100644
--- a/firmware/fw_common.ldS
+++ b/firmware/fw_common.ldS
@@ -61,18 +61,6 @@
. = ALIGN(0x1000); /* Ensure next section is page aligned */
- .stack :
- {
- PROVIDE(_stack_start = .);
- *(.stack)
- *(.stack.*)
- . = . + (PLAT_HART_STACK_SIZE * PLAT_HART_COUNT);
- . = ALIGN(8);
- PROVIDE(_stack_end = .);
- }
-
- . = ALIGN(0x1000); /* Ensure next section is page aligned */
-
.bss :
{
PROVIDE(_bss_start = .);