2020-04-02 23:48:27 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2013-09-07 07:41:48 +02:00
|
|
|
|
2014-04-22 19:46:06 +02:00
|
|
|
#ifndef _COMMON_MRC_CACHE_H_
|
|
|
|
#define _COMMON_MRC_CACHE_H_
|
2013-09-07 07:41:48 +02:00
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
2017-12-17 22:16:42 +01:00
|
|
|
#include <commonlib/region.h>
|
2013-09-07 07:41:48 +02:00
|
|
|
|
2016-12-04 05:08:20 +01:00
|
|
|
enum {
|
|
|
|
MRC_TRAINING_DATA,
|
|
|
|
MRC_VARIABLE_DATA,
|
|
|
|
};
|
2016-11-06 07:57:02 +01:00
|
|
|
|
2016-12-04 05:08:20 +01:00
|
|
|
/*
|
|
|
|
* It's up to the caller to decide when to retrieve and stash data. There is
|
2020-07-24 20:24:27 +02:00
|
|
|
* differentiation on recovery mode CONFIG(HAS_RECOVERY_MRC_CACHE), but that's
|
2016-12-04 05:08:20 +01:00
|
|
|
* only for locating where to retrieve and save the data. If a platform doesn't
|
|
|
|
* want to update the data then it shouldn't stash the data for saving.
|
|
|
|
* Similarly, if the platform doesn't need the data for booting because of a
|
|
|
|
* policy don't request the data.
|
|
|
|
*/
|
2013-09-07 07:41:48 +02:00
|
|
|
|
2020-07-24 01:10:52 +02:00
|
|
|
/* Get and stash data for saving provided the type passed in. */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mrc_cache_load_current
|
|
|
|
*
|
|
|
|
* Fill in the buffer with the latest slot data. This will be a
|
2020-10-07 00:14:24 +02:00
|
|
|
* common entry point for ARM platforms. Returns < 0 on error, size
|
|
|
|
* of the returned data on success.
|
2020-07-24 01:10:52 +02:00
|
|
|
*/
|
2020-10-07 00:14:24 +02:00
|
|
|
ssize_t mrc_cache_load_current(int type, uint32_t version, void *buffer,
|
|
|
|
size_t buffer_size);
|
2020-07-24 01:10:52 +02:00
|
|
|
/**
|
|
|
|
* mrc_cache_mmap_leak
|
|
|
|
*
|
|
|
|
* Return a pointer to a buffer with the latest slot data. An mmap
|
|
|
|
* will be executed (without a matching unmap). This will be a common
|
|
|
|
* entry point for platforms where mmap is considered a noop, like x86
|
|
|
|
*/
|
|
|
|
void *mrc_cache_current_mmap_leak(int type, uint32_t version,
|
|
|
|
size_t *data_size);
|
|
|
|
/**
|
|
|
|
* Returns < 0 on error, 0 on success.
|
|
|
|
*/
|
2016-12-04 05:08:20 +01:00
|
|
|
int mrc_cache_stash_data(int type, uint32_t version, const void *data,
|
2020-07-24 01:10:52 +02:00
|
|
|
size_t size);
|
2014-04-22 19:46:06 +02:00
|
|
|
|
|
|
|
#endif /* _COMMON_MRC_CACHE_H_ */
|