1 /*
2  * Copyright (c) 2020 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef _ABSTRACT_DRIVER_H_
8 #define _ABSTRACT_DRIVER_H_
9 
10 #include <zephyr/ztest.h>
11 #include <zephyr/device.h>
12 #include <zephyr/sys/check.h>
13 
14 /* define subsystem common API for drivers */
15 typedef int (*abstract_do_this_t)(const struct device *dev, int foo, int bar);
16 typedef void (*abstract_do_that_t)(const struct device *dev, unsigned int *baz);
17 
18 __subsystem struct abstract_driver_api {
19 	abstract_do_this_t do_this;
20 	abstract_do_that_t do_that;
21 };
22 
23 __syscall int abstract_do_this(const struct device *dev, int foo, int bar);
24 
z_impl_abstract_do_this(const struct device * dev,int foo,int bar)25 static inline int z_impl_abstract_do_this(const struct device *dev, int foo, int bar)
26 {
27 	__ASSERT_NO_MSG(DEVICE_API_IS(abstract, dev));
28 
29 	return DEVICE_API_GET(abstract, dev)->do_this(dev, foo, bar);
30 }
31 
32 __syscall void abstract_do_that(const struct device *dev, unsigned int *baz);
33 
z_impl_abstract_do_that(const struct device * dev,unsigned int * baz)34 static inline void z_impl_abstract_do_that(const struct device *dev, unsigned int *baz)
35 {
36 	__ASSERT_NO_MSG(DEVICE_API_IS(abstract, dev));
37 
38 	DEVICE_API_GET(abstract, dev)->do_that(dev, baz);
39 }
40 
41 #include <syscalls/abstract_driver.h>
42 
43 #endif /* _ABSTRACT_DRIVER_H_ */
44