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_entrypoints.c: Add simple ACK mechanism for CPU boot #325

Merged
merged 1 commit into from
Dec 10, 2024
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
25 changes: 25 additions & 0 deletions arch/risc-v/src/mpfs/mpfs_entrypoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <stdint.h>
#include <stdbool.h>

#include <nuttx/atomic.h>
#include <nuttx/compiler.h>

#include <sys/types.h>
Expand Down Expand Up @@ -90,6 +91,8 @@ uint8_t g_mpfs_boot_stacks[ENTRY_STACK * ENTRYPT_CNT]
aligned_data(STACK_ALIGNMENT);
#endif

static int g_cpus_booted;

/****************************************************************************
* Public Functions
****************************************************************************/
Expand Down Expand Up @@ -128,6 +131,9 @@ void mpfs_jump_to_app(void)
"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 */
:
#ifdef CONFIG_MPFS_BOARD_PMP
Expand Down Expand Up @@ -246,4 +252,23 @@ bool mpfs_get_use_sbi(uint64_t hartid)
return false;
}

/****************************************************************************
* Name: mpfs_cpus_booted
*
* Description:
* Get amount of CPUs that have completed boot.
*
* Input Parameters:
* None.
*
* Returned value:
* Amount of CPUs that have booted.
*
****************************************************************************/

int mpfs_cpus_booted(void)
{
return atomic_load(&g_cpus_booted);
}

#endif /* CONFIG_MPFS_BOOTLOADER */
16 changes: 16 additions & 0 deletions arch/risc-v/src/mpfs/mpfs_entrypoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ int mpfs_set_use_sbi(uint64_t hartid, bool use_sbi);

bool mpfs_get_use_sbi(uint64_t hartid);

/****************************************************************************
* Name: mpfs_cpus_booted
*
* Description:
* Get amount of CPUs that have completed boot.
*
* Input Parameters:
* None.
*
* Returned value:
* Amount of CPUs that have booted.
*
****************************************************************************/

int mpfs_cpus_booted(void);

#if defined(__cplusplus)
}
#endif
Expand Down
Loading