mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-08-18 01:21:49 +01:00
Instead of printing only the best hart memory protection name at boot time let's print a list of all hart projection mechanisms. Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com> Reviewed-by: Rahul Pathak <rahul.pathak@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260727042504.1743250-6-anup.patel@oss.qualcomm.com Signed-off-by: Anup Patel <anup@brainfault.org>
134 lines
3.8 KiB
C
134 lines
3.8 KiB
C
/*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2025 Ventana Micro Systems Inc.
|
|
*/
|
|
|
|
#ifndef __SBI_HART_PROTECTION_H__
|
|
#define __SBI_HART_PROTECTION_H__
|
|
|
|
#include <sbi/sbi_types.h>
|
|
#include <sbi/sbi_list.h>
|
|
|
|
struct sbi_scratch;
|
|
struct sbi_domain;
|
|
|
|
/** Different types of hart protection mechanisms */
|
|
enum sbi_hart_protection_type {
|
|
SBI_HART_PROTECTION_TYPE_MEMORY = 0,
|
|
SBI_HART_PROTECTION_TYPE_ID,
|
|
SBI_HART_PROTECTION_TYPE_MAX
|
|
};
|
|
|
|
/** Representation of hart protection mechanism */
|
|
struct sbi_hart_protection {
|
|
/** List head */
|
|
struct sbi_dlist head;
|
|
|
|
/** Name of the hart protection mechanism */
|
|
char name[32];
|
|
|
|
/** Type of the hart protection mechanism */
|
|
enum sbi_hart_protection_type type;
|
|
|
|
/** Ratings of the hart protection mechanism (higher is better) */
|
|
unsigned long rating;
|
|
|
|
/** Configure protection for current HART (Mandatory) */
|
|
int (*configure)(struct sbi_scratch *scratch, struct sbi_domain *dom);
|
|
|
|
/** Unconfigure protection for current HART (Optional) */
|
|
void (*unconfigure)(struct sbi_scratch *scratch, struct sbi_domain *dom);
|
|
|
|
/** Create temporary mapping to access address range on current HART (Optional) */
|
|
int (*map_range)(struct sbi_scratch *scratch,
|
|
unsigned long base, unsigned long size);
|
|
|
|
/** Destroy temporary mapping on current HART (Optional) */
|
|
int (*unmap_range)(struct sbi_scratch *scratch,
|
|
unsigned long base, unsigned long size);
|
|
};
|
|
|
|
/**
|
|
* Get a string containing names of protection mechanisms
|
|
*
|
|
* @param out_str pointer to output string
|
|
* @param out_str_size maximum size of output string
|
|
*
|
|
* @return pointer to best hart memory protection mechanism
|
|
*/
|
|
void sbi_hart_protection_get_str(char *out_str, int out_str_size);
|
|
|
|
/**
|
|
* Register a hart protection mechanism
|
|
*
|
|
* @param hprot pointer to hart protection mechanism
|
|
*
|
|
* @return 0 on success and negative error code on failure
|
|
*/
|
|
int sbi_hart_protection_register(struct sbi_hart_protection *hprot);
|
|
|
|
/**
|
|
* Unregister a hart protection mechanism
|
|
*
|
|
* @param hprot pointer to hart protection mechanism
|
|
*/
|
|
void sbi_hart_protection_unregister(struct sbi_hart_protection *hprot);
|
|
|
|
/**
|
|
* Configure protection for current HART
|
|
*
|
|
* @param scratch pointer to scratch space of current HART
|
|
* @param dom pointer to the domain for which HART protection
|
|
* is being configured
|
|
*
|
|
* @return 0 on success and negative error code on failure
|
|
*/
|
|
int sbi_hart_protection_configure(struct sbi_scratch *scratch,
|
|
struct sbi_domain *dom);
|
|
|
|
/**
|
|
* Unconfigure protection for current HART
|
|
*
|
|
* @param scratch pointer to scratch space of current HART
|
|
* @param dom pointer to the domain for which HART protection
|
|
* is being unconfigured
|
|
*/
|
|
void sbi_hart_protection_unconfigure(struct sbi_scratch *scratch,
|
|
struct sbi_domain *dom);
|
|
|
|
/**
|
|
* Re-configure protection for current HART
|
|
*
|
|
* @param scratch pointer to scratch space of current HART
|
|
* @param current_dom pointer to the current domain for which
|
|
* HART protection is being unconfigured
|
|
* @param next_dom pointer to the next domain for which HART
|
|
* protection is being configured
|
|
*/
|
|
int sbi_hart_protection_reconfigure(struct sbi_scratch *scratch,
|
|
struct sbi_domain *current_dom,
|
|
struct sbi_domain *next_dom);
|
|
|
|
/**
|
|
* Create temporary mapping to access address range on current HART
|
|
*
|
|
* @param base base address of the temporary mapping
|
|
* @param size size of the temporary mapping
|
|
*
|
|
* @return 0 on success and negative error code on failure
|
|
*/
|
|
int sbi_hart_protection_map_range(unsigned long base, unsigned long size);
|
|
|
|
/**
|
|
* Destroy temporary mapping to access address range on current HART
|
|
*
|
|
* @param base base address of the temporary mapping
|
|
* @param size size of the temporary mapping
|
|
*
|
|
* @return 0 on success and negative error code on failure
|
|
*/
|
|
int sbi_hart_protection_unmap_range(unsigned long base, unsigned long size);
|
|
|
|
#endif /* __SBI_HART_PROTECTION_H__ */
|