Zephyr Project API 4.4.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
11
12#ifndef INCLUDE_ZEPHYR_DRIVERS_EMUL_BBRAM_H_
13#define INCLUDE_ZEPHYR_DRIVERS_EMUL_BBRAM_H_
14
15#include <zephyr/drivers/emul.h>
16
17#include <stdint.h>
18
26
32
33__subsystem struct emul_bbram_driver_api {
35 int (*set_data)(const struct emul *target, size_t offset, size_t count,
36 const uint8_t *data);
38 int (*get_data)(const struct emul *target, size_t offset, size_t count, uint8_t *data);
39};
40
44
56static inline int emul_bbram_backend_set_data(const struct emul *target, size_t offset,
57 size_t count, const uint8_t *data)
58{
59 if (target == NULL || target->backend_api == NULL) {
60 return -ENOTSUP;
61 }
62
63 struct emul_bbram_driver_api *api = (struct emul_bbram_driver_api *)target->backend_api;
64
65 if (api->set_data == NULL) {
66 return -ENOTSUP;
67 }
68
69 return api->set_data(target, offset, count, data);
70}
71
83static inline int emul_bbram_backend_get_data(const struct emul *target, size_t offset,
84 size_t count, uint8_t *data)
85{
86 if (target == NULL || target->backend_api == NULL) {
87 return -ENOTSUP;
88 }
89
90 struct emul_bbram_driver_api *api = (struct emul_bbram_driver_api *)target->backend_api;
91
92 if (api->get_data == NULL) {
93 return -ENOTSUP;
94 }
95
96 return api->get_data(target, offset, count, data);
97}
98
102
103#endif /* INCLUDE_ZEPHYR_DRIVERS_EMUL_BBRAM_H_ */
Public APIs for the device emulation framework.
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:83
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:56
#define ENOTSUP
Unsupported value.
Definition errno.h:115
#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:88
void * data
Emulator-specific data.
Definition emul.h:96
const void * backend_api
Address of the API structure exposed by the emulator instance.
Definition emul.h:109