Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpfs_opensbi_setup: Provide hartid and next_addr as parameters #15590

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions arch/risc-v/src/mpfs/mpfs_entrypoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,22 @@ void mpfs_jump_to_app(void)
"csrw pmpcfg0, t0\n"
"csrw pmpcfg2, zero\n"
#endif
#ifdef CONFIG_MPFS_OPENSBI
"slli t1, a0, 3\n" /* To entrypoint offset */
"la t0, g_app_entrypoints\n" /* Entrypoint table base */
"add t0, t0, t1\n" /* Index in table */
"ld a1, 0(t0)\n" /* Load the address from table */
"li t1, 1\n"
"la t2, g_cpus_booted\n"
"ld t0, g_hart_use_sbi\n" /* Load sbi usage bitmask */
"amoadd.w.aqrl zero, t1, 0(t2)\n" /* g_cpus_booted + 1 */
#ifdef CONFIG_MPFS_OPENSBI
"srl t0, t0, a0\n" /* Shift right by this hart */
"andi t0, t0, 1\n" /* Check the 0 bit */
"beqz t0, 1f\n" /* If bit was 1, jump to sbi */
"tail mpfs_opensbi_prepare_hart\n"
"1:\n"
#endif
"slli t1, a0, 3\n" /* To entrypoint offset */
"la t0, g_app_entrypoints\n" /* Entrypoint table base */
"add t0, t0, t1\n" /* Index in table */
"ld t0, 0(t0)\n" /* Load the address from table */
"li t1, 1\n"
"la t2, g_cpus_booted\n"
"amoadd.w.aqrl zero, t1, 0(t2)\n" /* g_cpus_booted + 1 */
"jr t0\n" /* Jump to entrypoint */
"jr a1\n" /* Jump to entrypoint */
:
#ifdef CONFIG_MPFS_BOARD_PMP
: "i" (ENTRY_STACK)
Expand Down
9 changes: 5 additions & 4 deletions arch/risc-v/src/mpfs/mpfs_opensbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,16 +596,17 @@ static int mpfs_opensbi_ecall_handler(long funcid,
* - Calls the sbi_init() that will not return
*
* Input Parameters:
* None
* a0 - hartid
* a1 - next_addr
*
* Returned Value:
* None - this will never return
*
****************************************************************************/

void __attribute__((noreturn)) mpfs_opensbi_setup(void)
void __attribute__((noreturn)) mpfs_opensbi_setup(uintptr_t hartid,
uintptr_t next_addr)
{
uint32_t hartid = current_hartid();
size_t i;

for (i = 0; i < nitems(mpfs_hart_index2id); i++)
Expand All @@ -618,7 +619,7 @@ void __attribute__((noreturn)) mpfs_opensbi_setup(void)

csr_write(mscratch, &g_scratches[hartid].scratch);
g_scratches[hartid].scratch.next_mode = PRV_S;
g_scratches[hartid].scratch.next_addr = mpfs_get_entrypt(hartid);
g_scratches[hartid].scratch.next_addr = next_addr;
g_scratches[hartid].scratch.next_arg1 = 0;

sbi_init(&g_scratches[hartid].scratch);
Expand Down
7 changes: 4 additions & 3 deletions arch/risc-v/src/mpfs/mpfs_opensbi_utils.S
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ mpfs_global_pointer:
* times.
*
* Input Parameters:
* None
* a0 - hartid
* a1 - next_addr
*
* Returned Value:
* None
Expand All @@ -87,9 +88,9 @@ mpfs_opensbi_prepare_hart:

/* Setup stacks per hart, the stack top is the end of the hart's scratch */

csrr a0, CSR_MHARTID
csrr t0, CSR_MHARTID
li t1, SBI_SCRATCH_SIZE
mul t0, a0, t1
mul t0, t0, t1
la sp, g_scratches
add sp, sp, t0
tail mpfs_opensbi_setup
Loading