/src/barebox/include/tlv/tlv.h
Line | Count | Source |
1 | | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | | #ifndef __TLV_H_ |
3 | | #define __TLV_H_ |
4 | | |
5 | | #include <linux/compiler.h> |
6 | | #include <linux/kernel.h> |
7 | | #include <linux/types.h> |
8 | | #include <linux/err.h> |
9 | | #include <asm/unaligned.h> |
10 | | #include <unistd.h> |
11 | | #include <driver.h> |
12 | | |
13 | | #include <tlv/format.h> |
14 | | |
15 | | struct tlv *tlv_next(const struct tlv_header *header, const struct tlv *tlv); |
16 | | |
17 | | struct tlv_header *tlv_read(const char *filename, size_t *nread); |
18 | | |
19 | | struct device_node; |
20 | | struct tlv_device; |
21 | | struct tlv_mapping; |
22 | | |
23 | | struct tlv_mapping { |
24 | | u16 tag; |
25 | | int (*handle)(struct tlv_device *dev, struct tlv_mapping *map, |
26 | | u16 len, const u8 *val); |
27 | | const char *prop; |
28 | | }; |
29 | | |
30 | | extern struct tlv_mapping barebox_tlv_v1_mappings[]; |
31 | | |
32 | | extern const char *__tlv_format_str(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val); |
33 | | extern int tlv_format_str(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val); |
34 | | extern int tlv_format_dec(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val); |
35 | | #define tlv_format_timestamp tlv_format_dec /* For timestamps since the UNIX epoch */ |
36 | | extern int tlv_format_hex(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val); |
37 | | extern int tlv_format_mac(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val); |
38 | | extern int tlv_format_blob(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val); |
39 | | extern int tlv_handle_serial(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val); |
40 | | extern int tlv_bind_soc_uid(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val); |
41 | | extern int tlv_handle_eth_address(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val); |
42 | | extern int tlv_handle_eth_address_seq(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val); |
43 | | |
44 | | struct tlv_decoder { |
45 | | u32 magic; |
46 | | const char *signature_keyring; |
47 | | struct tlv_mapping **mappings; |
48 | | struct driver driver; |
49 | | /* private members */ |
50 | | struct driver _platform_driver; |
51 | | struct list_head list; |
52 | | }; |
53 | | |
54 | | struct tlv_device { |
55 | | struct device dev; |
56 | | u32 magic; |
57 | | }; |
58 | | |
59 | | static inline struct device_node *tlv_of_node(struct tlv_device *tlvdev) |
60 | 35.5k | { |
61 | 35.5k | return tlvdev->dev.device_node; |
62 | 35.5k | } Line | Count | Source | 60 | 1.05k | { | 61 | 1.05k | return tlvdev->dev.device_node; | 62 | 1.05k | } |
Unexecuted instantiation: bus.c:tlv_of_node Unexecuted instantiation: register.c:tlv_of_node Unexecuted instantiation: drv.c:tlv_of_node Line | Count | Source | 60 | 34.5k | { | 61 | 34.5k | return tlvdev->dev.device_node; | 62 | 34.5k | } |
|
63 | | |
64 | | struct tlv_device *tlv_register_device(struct tlv_header *header, size_t size, |
65 | | struct device *parent); |
66 | | static inline struct tlv_header *tlv_device_header(struct tlv_device *tlvdev) |
67 | 674 | { |
68 | 674 | return tlvdev->dev.platform_data; |
69 | 674 | } parser.c:tlv_device_header Line | Count | Source | 67 | 674 | { | 68 | 674 | return tlvdev->dev.platform_data; | 69 | 674 | } |
Unexecuted instantiation: bus.c:tlv_device_header Unexecuted instantiation: register.c:tlv_device_header Unexecuted instantiation: drv.c:tlv_device_header Unexecuted instantiation: barebox.c:tlv_device_header |
70 | | |
71 | | void tlv_free_device(struct tlv_device *tlvdev); |
72 | | |
73 | | int tlv_register_decoder(struct tlv_decoder *decoder); |
74 | | |
75 | | int tlv_parse(struct tlv_device *tlvdev, |
76 | | const struct tlv_decoder *decoder); |
77 | | |
78 | | int of_tlv_fixup(struct device_node *root, void *ctx); |
79 | | |
80 | | int tlv_of_register_fixup(struct tlv_device *tlvdev); |
81 | | void tlv_of_unregister_fixup(struct tlv_device *tlvdev); |
82 | | |
83 | | extern struct bus_type tlv_bus; |
84 | | |
85 | 1.34k | #define to_tlv_decoder(drv) ( \ |
86 | 1.34k | drv->bus == &tlv_bus ? container_of_const(drv, struct tlv_decoder, driver) : \ |
87 | 1.34k | drv->bus == &platform_bus ? container_of_const(drv, struct tlv_decoder, _platform_driver) : \ |
88 | 0 | NULL \ |
89 | 1.34k | ) |
90 | | |
91 | | static inline struct tlv_device *to_tlv_device(struct device *dev) |
92 | 1.34k | { |
93 | 1.34k | return container_of(dev, struct tlv_device, dev); |
94 | 1.34k | } Unexecuted instantiation: parser.c:to_tlv_device Line | Count | Source | 92 | 674 | { | 93 | 674 | return container_of(dev, struct tlv_device, dev); | 94 | 674 | } |
Line | Count | Source | 92 | 674 | { | 93 | 674 | return container_of(dev, struct tlv_device, dev); | 94 | 674 | } |
Unexecuted instantiation: drv.c:to_tlv_device Unexecuted instantiation: barebox.c:to_tlv_device |
95 | | |
96 | | struct tlv_device *tlv_register_device_by_path(const char *path, struct device *parent); |
97 | | struct tlv_device *tlv_ensure_probed_by_alias(const char *alias); |
98 | | |
99 | | #endif |