mpfs_entrypoints.c: Add simple ACK mechanism for CPU boot

CPUs will acknowledge that they have booted, the primary CPU handling the
boot can then wait for others to complete their boot, before booting
itself.
This commit is contained in:
Ville Juven
2024-12-09 11:59:54 +02:00
committed by Xiang Xiao
parent 0aa99e223f
commit fd20684a7b
2 changed files with 41 additions and 0 deletions
+25
View File
@@ -31,6 +31,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <nuttx/atomic.h>
#include <nuttx/compiler.h>
#include <sys/types.h>
@@ -92,6 +93,8 @@ uint8_t g_mpfs_boot_stacks[ENTRY_STACK * ENTRYPT_CNT]
aligned_data(STACK_ALIGNMENT);
#endif
static int g_cpus_booted;
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -130,6 +133,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
@@ -248,4 +254,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
View File
@@ -104,6 +104,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