1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2020-2021 The FreeBSD Foundation
5 * Copyright (c) 2022 Bjoern A. Zeeb
6 *
7 * This software was developed by Björn Zeeb under sponsorship from
8 * the FreeBSD Foundation.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $FreeBSD$
32 */
33
34 #ifndef _LINUXKPI_LINUX_FIRMWARE_H
35 #define _LINUXKPI_LINUX_FIRMWARE_H
36
37 #include <sys/types.h>
38 #include <linux/types.h>
39 #include <linux/device.h>
40
41 struct firmware;
42
43 struct linuxkpi_firmware {
44 size_t size;
45 const uint8_t *data;
46 /* XXX Does Linux expose anything else? */
47
48 /* This is LinuxKPI implementation private. */
49 const struct firmware *fbdfw;
50 };
51
52 int linuxkpi_request_firmware_nowait(struct module *, bool, const char *,
53 struct device *, gfp_t, void *,
54 void(*cont)(const struct linuxkpi_firmware *, void *));
55 int linuxkpi_request_firmware(const struct linuxkpi_firmware **,
56 const char *, struct device *);
57 int linuxkpi_firmware_request_nowarn(const struct linuxkpi_firmware **,
58 const char *, struct device *);
59 void linuxkpi_release_firmware(const struct linuxkpi_firmware *);
60 int linuxkpi_request_partial_firmware_into_buf(const struct linuxkpi_firmware **,
61 const char *, struct device *, uint8_t *, size_t, size_t);
62
63
64 static __inline int
65 request_firmware_nowait(struct module *mod, bool _t,
66 const char *fw_name, struct device *dev, gfp_t gfp, void *drv,
67 void(*cont)(const struct linuxkpi_firmware *, void *))
68 {
69
70
71 return (linuxkpi_request_firmware_nowait(mod, _t, fw_name, dev, gfp,
72 drv, cont));
73 }
74
75 static __inline int
76 request_firmware(const struct linuxkpi_firmware **fw,
77 const char *fw_name, struct device *dev)
78 {
79
80 return (linuxkpi_request_firmware(fw, fw_name, dev));
81 }
82
83 static __inline int
84 request_firmware_direct(const struct linuxkpi_firmware **fw,
85 const char *fw_name, struct device *dev)
86 {
87
88 return (linuxkpi_request_firmware(fw, fw_name, dev));
89 }
90
91 static __inline int
92 firmware_request_nowarn(const struct linuxkpi_firmware **fw,
93 const char *fw_name, struct device *dev)
94 {
95
96 return (linuxkpi_firmware_request_nowarn(fw, fw_name, dev));
97 }
98
99 static __inline void
100 release_firmware(const struct linuxkpi_firmware *fw)
101 {
102
103 linuxkpi_release_firmware(fw);
104 }
105
106 static inline int
107 request_partial_firmware_into_buf(const struct linuxkpi_firmware **fw,
108 const char *fw_name, struct device *dev, void *buf, size_t buflen,
109 size_t offset)
110 {
111
112 return (linuxkpi_request_partial_firmware_into_buf(fw, fw_name,
113 dev, buf, buflen, offset));
114 }
115
116 #define firmware linuxkpi_firmware
117
118 #endif /* _LINUXKPI_LINUX_FIRMWARE_H */
Cache object: 75081240d040bd7f0e2b9240f9578421
|