mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-02-27 18:01:45 +00:00
Add functions to enable/disable the cache. Signed-off-by: Ben Zong-You Xie <ben717@andestech.com> Link: https://lore.kernel.org/r/20251229071914.1451587-4-ben717@andestech.com Signed-off-by: Anup Patel <anup@brainfault.org>
81 lines
1.7 KiB
C
81 lines
1.7 KiB
C
/*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2025 SiFive Inc.
|
|
*/
|
|
|
|
#ifndef __CACHE_H__
|
|
#define __CACHE_H__
|
|
|
|
#include <sbi/sbi_list.h>
|
|
#include <sbi/sbi_types.h>
|
|
|
|
#define CACHE_NAME_LEN 32
|
|
|
|
struct cache_device;
|
|
|
|
struct cache_ops {
|
|
/** Warm init **/
|
|
int (*warm_init)(struct cache_device *dev);
|
|
/** Flush entire cache **/
|
|
int (*cache_flush_all)(struct cache_device *dev);
|
|
/** Enable/Disable cache **/
|
|
int (*cache_enable)(struct cache_device *dev, bool enable);
|
|
};
|
|
|
|
struct cache_device {
|
|
/** Name of the device **/
|
|
char name[CACHE_NAME_LEN];
|
|
/** List node for search **/
|
|
struct sbi_dlist node;
|
|
/** Point to the next level cache **/
|
|
struct cache_device *next;
|
|
/** Cache Management Operations **/
|
|
struct cache_ops *ops;
|
|
/** CPU private cache **/
|
|
bool cpu_private;
|
|
/** The unique id of this cache device **/
|
|
u32 id;
|
|
};
|
|
|
|
/**
|
|
* Find a registered cache device
|
|
*
|
|
* @param id unique ID of the cache device
|
|
*
|
|
* @return the cache device or NULL
|
|
*/
|
|
struct cache_device *cache_find(u32 id);
|
|
|
|
/**
|
|
* Register a cache device
|
|
*
|
|
* cache_device->id must be initialized already and must not change during the life
|
|
* of the cache_device object.
|
|
*
|
|
* @param dev the cache device to register
|
|
*
|
|
* @return 0 on success, or a negative error code on failure
|
|
*/
|
|
int cache_add(struct cache_device *dev);
|
|
|
|
/**
|
|
* Flush the entire cache
|
|
*
|
|
* @param dev the cache to flush
|
|
*
|
|
* @return 0 on success, or a negative error code on failure
|
|
*/
|
|
int cache_flush_all(struct cache_device *dev);
|
|
|
|
/**
|
|
* Enable/Disable the cache
|
|
*
|
|
* @param dev the cache to enable/disable
|
|
*
|
|
* @return 0 on success, or a negative error code on failure
|
|
*/
|
|
int cache_enable(struct cache_device *dev, bool enable);
|
|
|
|
#endif
|