mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 23:41:23 +01:00
lib: sbi: Introduce domain data
Different parts of OpenSBI require their own per-domain data so introduce domain data (or sbi_domain_data) which can be registered by any part of OpenSBI. Using the domain data, the domain framework will create a data pointer for every domain which can be used to maintain some per-domain state. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Yu Chien Peter Lin <peterlin@andestech.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <sbi/sbi_types.h>
|
||||
#include <sbi/sbi_hartmask.h>
|
||||
#include <sbi/sbi_domain_context.h>
|
||||
#include <sbi/sbi_domain_data.h>
|
||||
|
||||
struct sbi_scratch;
|
||||
|
||||
@@ -163,6 +164,8 @@ struct sbi_domain_memregion {
|
||||
struct sbi_domain {
|
||||
/** Node in linked list of domains */
|
||||
struct sbi_dlist node;
|
||||
/** Internal state of per-domain data */
|
||||
struct sbi_domain_data_priv data_priv;
|
||||
/** Logical index of this domain */
|
||||
u32 index;
|
||||
/** HARTs assigned to this domain */
|
||||
|
93
include/sbi/sbi_domain_data.h
Normal file
93
include/sbi/sbi_domain_data.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2024 Ventana Micro Systems Inc.
|
||||
*/
|
||||
|
||||
#ifndef __SBI_DOMAIN_DATA_H__
|
||||
#define __SBI_DOMAIN_DATA_H__
|
||||
|
||||
#include <sbi/sbi_types.h>
|
||||
#include <sbi/sbi_list.h>
|
||||
|
||||
struct sbi_domain;
|
||||
|
||||
/** Maximum domain data per-domain */
|
||||
#define SBI_DOMAIN_MAX_DATA_PTRS 32
|
||||
|
||||
/** Representation of per-domain data */
|
||||
struct sbi_domain_data_priv {
|
||||
/** Array of domain data pointers indexed by domain data identifier */
|
||||
void *idx_to_data_ptr[SBI_DOMAIN_MAX_DATA_PTRS];
|
||||
};
|
||||
|
||||
/** Representation of a domain data */
|
||||
struct sbi_domain_data {
|
||||
/**
|
||||
* Head is used for maintaining data list
|
||||
*
|
||||
* Note: initialized by domain framework
|
||||
*/
|
||||
struct sbi_dlist head;
|
||||
/**
|
||||
* Identifier which used to locate per-domain data
|
||||
*
|
||||
* Note: initialized by domain framework
|
||||
*/
|
||||
unsigned long data_idx;
|
||||
/** Size of per-domain data */
|
||||
unsigned long data_size;
|
||||
/** Optional callback to setup domain data */
|
||||
int (*data_setup)(struct sbi_domain *dom,
|
||||
struct sbi_domain_data *data, void *data_ptr);
|
||||
/** Optional callback to cleanup domain data */
|
||||
void (*data_cleanup)(struct sbi_domain *dom,
|
||||
struct sbi_domain_data *data, void *data_ptr);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get per-domain data pointer for a given domain
|
||||
* @param dom pointer to domain
|
||||
* @param data pointer to domain data
|
||||
*
|
||||
* @return per-domain data pointer
|
||||
*/
|
||||
void *sbi_domain_data_ptr(struct sbi_domain *dom, struct sbi_domain_data *data);
|
||||
|
||||
/**
|
||||
* Setup all domain data for a domain
|
||||
* @param dom pointer to domain
|
||||
*
|
||||
* @return 0 on success and negative error code on failure
|
||||
*
|
||||
* Note: This function is used internally within domain framework.
|
||||
*/
|
||||
int sbi_domain_setup_data(struct sbi_domain *dom);
|
||||
|
||||
/**
|
||||
* Cleanup all domain data for a domain
|
||||
* @param dom pointer to domain
|
||||
*
|
||||
* Note: This function is used internally within domain framework.
|
||||
*/
|
||||
void sbi_domain_cleanup_data(struct sbi_domain *dom);
|
||||
|
||||
/**
|
||||
* Register a domain data
|
||||
* @param hndl pointer to domain data
|
||||
*
|
||||
* @return 0 on success and negative error code on failure
|
||||
*
|
||||
* Note: This function must be used only in cold boot path.
|
||||
*/
|
||||
int sbi_domain_register_data(struct sbi_domain_data *data);
|
||||
|
||||
/**
|
||||
* Unregister a domain data
|
||||
* @param hndl pointer to domain data
|
||||
*
|
||||
* Note: This function must be used only in cold boot path.
|
||||
*/
|
||||
void sbi_domain_unregister_data(struct sbi_domain_data *data);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user