drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / payloads / libpayload / include / cbfs_glue.h
blobbff63eea4ab8fd384b9ffaf84872dff65651ae88
1 /* SPDX-License-Identifier: BSD-3-Clause */
3 #ifndef _CBFS_CBFS_GLUE_H
4 #define _CBFS_CBFS_GLUE_H
6 #include <libpayload-config.h>
7 #include <boot_device.h>
8 #include <stdbool.h>
9 #include <stdio.h>
11 #define CBFS_ENABLE_HASHING CONFIG(LP_CBFS_VERIFICATION)
12 #define CBFS_HASH_HWCRYPTO cbfs_hwcrypto_allowed()
14 #define ERROR(...) printf("CBFS ERROR: " __VA_ARGS__)
15 #define LOG(...) printf("CBFS: " __VA_ARGS__)
16 #define DEBUG(...) \
17 do { \
18 if (CONFIG(LP_DEBUG_CBFS)) \
19 printf("CBFS DEBUG: " __VA_ARGS__); \
20 } while (0)
22 struct cbfs_dev {
23 size_t offset;
24 size_t size;
27 struct cbfs_boot_device {
28 struct cbfs_dev dev;
29 void *mcache;
30 size_t mcache_size;
33 typedef const struct cbfs_dev *cbfs_dev_t;
35 static inline ssize_t cbfs_dev_read(cbfs_dev_t dev, void *buffer, size_t offset, size_t size)
37 if (offset + size < offset || offset + size > dev->size)
38 return CB_ERR_ARG;
40 return boot_device_read(buffer, dev->offset + offset, size);
43 static inline size_t cbfs_dev_size(cbfs_dev_t dev)
45 return dev->size;
48 bool cbfs_hwcrypto_allowed(void);
50 #endif /* _CBFS_CBFS_GLUE_H */