forked from Mirrors/opensbi
		
	lib: Add system early_exit and final_exit APIs
This patch adds system-level early_exit and final_exit APIs with corresponding platform hooks. These new APIs will be primarily used by sbi_exit() in OpenSBI exit path. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
		@@ -76,6 +76,11 @@ struct sbi_platform_operations {
 | 
			
		||||
	/** Platform final initialization */
 | 
			
		||||
	int (*final_init)(bool cold_boot);
 | 
			
		||||
 | 
			
		||||
	/** Platform early exit */
 | 
			
		||||
	void (*early_exit)(void);
 | 
			
		||||
	/** Platform final exit */
 | 
			
		||||
	void (*final_exit)(void);
 | 
			
		||||
 | 
			
		||||
	/** For platforms that do not implement misa, non-standard
 | 
			
		||||
	 * methods are needed to determine cpu extension.
 | 
			
		||||
	 */
 | 
			
		||||
@@ -301,6 +306,28 @@ static inline int sbi_platform_final_init(const struct sbi_platform *plat,
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Early exit for current HART
 | 
			
		||||
 *
 | 
			
		||||
 * @param plat pointer to struct sbi_platform
 | 
			
		||||
 */
 | 
			
		||||
static inline void sbi_platform_early_exit(const struct sbi_platform *plat)
 | 
			
		||||
{
 | 
			
		||||
	if (plat && sbi_platform_ops(plat)->early_exit)
 | 
			
		||||
		sbi_platform_ops(plat)->early_exit();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Final exit for current HART
 | 
			
		||||
 *
 | 
			
		||||
 * @param plat pointer to struct sbi_platform
 | 
			
		||||
 */
 | 
			
		||||
static inline void sbi_platform_final_exit(const struct sbi_platform *plat)
 | 
			
		||||
{
 | 
			
		||||
	if (plat && sbi_platform_ops(plat)->final_exit)
 | 
			
		||||
		sbi_platform_ops(plat)->final_exit();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Check CPU extension in MISA
 | 
			
		||||
 *
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,10 @@ int sbi_system_early_init(struct sbi_scratch *scratch, bool cold_boot);
 | 
			
		||||
 | 
			
		||||
int sbi_system_final_init(struct sbi_scratch *scratch, bool cold_boot);
 | 
			
		||||
 | 
			
		||||
void sbi_system_early_exit(struct sbi_scratch *scratch);
 | 
			
		||||
 | 
			
		||||
void sbi_system_final_exit(struct sbi_scratch *scratch);
 | 
			
		||||
 | 
			
		||||
void __attribute__((noreturn))
 | 
			
		||||
sbi_system_reboot(struct sbi_scratch *scratch, u32 type);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -203,5 +203,9 @@ void __noreturn sbi_exit(struct sbi_scratch *scratch)
 | 
			
		||||
 | 
			
		||||
	sbi_hart_unmark_available(hartid);
 | 
			
		||||
 | 
			
		||||
	sbi_platform_early_exit(plat);
 | 
			
		||||
 | 
			
		||||
	sbi_platform_final_exit(plat);
 | 
			
		||||
 | 
			
		||||
	sbi_hart_hang();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,16 @@ int sbi_system_final_init(struct sbi_scratch *scratch, bool cold_boot)
 | 
			
		||||
	return sbi_platform_final_init(sbi_platform_ptr(scratch), cold_boot);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void sbi_system_early_exit(struct sbi_scratch *scratch)
 | 
			
		||||
{
 | 
			
		||||
	sbi_platform_early_exit(sbi_platform_ptr(scratch));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void sbi_system_final_exit(struct sbi_scratch *scratch)
 | 
			
		||||
{
 | 
			
		||||
	sbi_platform_final_exit(sbi_platform_ptr(scratch));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void __attribute__((noreturn))
 | 
			
		||||
sbi_system_reboot(struct sbi_scratch *scratch, u32 type)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user