Zephyr Project API 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
emul_bbram.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 Google LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#ifndef INCLUDE_ZEPHYR_DRIVERS_EMUL_BBRAM_H_
7#define INCLUDE_ZEPHYR_DRIVERS_EMUL_BBRAM_H_
8
10
11#include <stdint.h>
12
27__subsystem struct emul_bbram_driver_api {
29 int (*set_data)(const struct emul *target, size_t offset, size_t count,
30 const uint8_t *data);
32 int (*get_data)(const struct emul *target, size_t offset, size_t count, uint8_t *data);
33};
34
50static inline int emul_bbram_backend_set_data(const struct emul *target, size_t offset,
51 size_t count, const uint8_t *data)
52{
53 if (target == NULL || target->backend_api == NULL) {
54 return -ENOTSUP;
55 }
56
57 struct emul_bbram_driver_api *api = (struct emul_bbram_driver_api *)target->backend_api;
58
59 if (api->set_data == NULL) {
60 return -ENOTSUP;
61 }
62
63 return api->set_data(target, offset, count, data);
64}
65
77static inline int emul_bbram_backend_get_data(const struct emul *target, size_t offset,
78 size_t count, uint8_t *data)
79{
80 if (target == NULL || target->backend_api == NULL) {
81 return -ENOTSUP;
82 }
83
84 struct emul_bbram_driver_api *api = (struct emul_bbram_driver_api *)target->backend_api;
85
86 if (api->get_data == NULL) {
87 return -ENOTSUP;
88 }
89
90 return api->get_data(target, offset, count, data);
91}
92
97#endif /* INCLUDE_ZEPHYR_DRIVERS_EMUL_BBRAM_H_ */
static int emul_bbram_backend_get_data(const struct emul *target, size_t offset, size_t count, uint8_t *data)
Get the expected data in the bbram region.
Definition emul_bbram.h:77
static int emul_bbram_backend_set_data(const struct emul *target, size_t offset, size_t count, const uint8_t *data)
Set the expected data in the bbram region.
Definition emul_bbram.h:50
#define ENOTSUP
Unsupported value.
Definition errno.h:114
#define NULL
Definition iar_missing_defs.h:20
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition emul.h:82
void * data
Emulator-specific data.
Definition emul.h:90
const void * backend_api
Address of the API structure exposed by the emulator instance.
Definition emul.h:103